coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
soc_util.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <assert.h>
4 #include <device/device.h>
5 #include <device/pci.h>
6 #include <intelblocks/cpulib.h>
7 #include <soc/cpu.h>
8 #include <soc/pci_devs.h>
9 #include <soc/soc_util.h>
10 #include <soc/util.h>
11 
12 const struct SystemMemoryMapHob *get_system_memory_map(void)
13 {
14  size_t hob_size;
15  const uint8_t mem_hob_guid[16] = FSP_SYSTEM_MEMORYMAP_HOB_GUID;
16  const struct SystemMemoryMapHob **memmap_addr;
17 
18  memmap_addr = (const struct SystemMemoryMapHob **)
19  fsp_find_extension_hob_by_guid(mem_hob_guid, &hob_size);
20  /* hob_size is the size of the 8-byte address not the hob data */
21  assert(memmap_addr != NULL && hob_size != 0);
22  /* assert the pointer to the hob is not NULL */
23  assert(*memmap_addr != NULL);
24 
25  return *memmap_addr;
26 }
27 
28 bool is_iio_stack_res(const STACK_RES *res)
29 {
30  return res->Personality == TYPE_UBOX_IIO;
31 }
32 
34 {
35  const IIO_UDS *hob = get_iio_uds();
36 
37  assert(socket < hob->SystemStatus.numCpus && stack < MAX_LOGIC_IIO_STACK);
38 
39  return hob->PlatformData.IIO_resource[socket].StackRes[stack].BusBase;
40 }
41 
42 /*
43  * EX: CPX-SP
44  * Ports Stack Stack(HOB) IioConfigIou
45  * ==========================================
46  * 0 CSTACK stack 0 IOU0
47  * 1A..1D PSTACKZ stack 1 IOU1
48  * 2A..2D PSTACK1 stack 2 IOU2
49  * 3A..3D PSTACK2 stack 4 IOU3
50  */
52 {
53  if (port == PORT_0)
54  return CSTACK;
55  else if (port >= PORT_1A && port <= PORT_1D)
56  return PSTACK0;
57  else if (port >= PORT_2A && port <= PORT_2D)
58  return PSTACK1;
59  else if (port >= PORT_3A && port <= PORT_3D)
60  return PSTACK2;
61  else
62  return -1;
63 }
64 
65 uint8_t soc_get_iio_ioapicid(int socket, int stack)
66 {
67  uint8_t ioapic_id = socket ? 0xf : 0x9;
68  switch (stack) {
69  case CSTACK:
70  break;
71  case PSTACK0:
72  ioapic_id += 1;
73  break;
74  case PSTACK1:
75  ioapic_id += 2;
76  break;
77  case PSTACK2:
78  ioapic_id += 3;
79  break;
80  default:
81  return 0xff;
82  }
83  return ioapic_id;
84 }
#define assert(statement)
Definition: assert.h:74
const void * fsp_find_extension_hob_by_guid(const uint8_t *guid, size_t *size)
port
Definition: i915.h:29
bool is_iio_stack_res(const STACK_RES *res)
Definition: soc_util.c:28
uint8_t soc_get_iio_ioapicid(int socket, int stack)
Definition: soc_util.c:65
const struct SystemMemoryMapHob * get_system_memory_map(void)
Definition: soc_util.c:12
int soc_get_stack_for_port(int port)
Definition: soc_util.c:51
uint32_t get_socket_stack_busno(uint32_t socket, uint32_t stack)
Definition: soc_util.c:33
const IIO_UDS * get_iio_uds(void)
Definition: util.c:89
#define NULL
Definition: stddef.h:19
unsigned int uint32_t
Definition: stdint.h:14
unsigned char uint8_t
Definition: stdint.h:8