1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <cpu/intel/cpu_ids.h>
5 #include <device/device.h>
6 #include <device/pci.h>
10 #include <soc/chip_common.h>
11 #include <soc/pci_devs.h>
12 #include <soc/soc_util.h>
15 #include <MemoryMapDataHob.h>
17 const char *pciroot_res_to_domain_type(const UDS_STACK_RES
*sr
, const UDS_PCIROOT_RES
*pr
)
22 for (; index
< sr
->PciRootBridgeNum
; index
++) {
23 if (sr
->PciRoot
[index
].UidType
== pr
->UidType
)
25 if (sr
->PciRoot
[index
].BusBase
== pr
->BusBase
)
29 if (index
== sr
->PciRootBridgeNum
)
32 switch (pr
->UidType
) {
34 return DOMAIN_TYPE_PCIE
;
36 return DOMAIN_TYPE_DINO
;
38 return DOMAIN_TYPE_CPM0
;
40 return DOMAIN_TYPE_HQM0
;
42 return (instance
== 0) ? DOMAIN_TYPE_UBX0
: DOMAIN_TYPE_UBX1
;
48 static bool is_domain_type_supported_on_stack(const xSTACK_RES
*sr
, const char *dt
)
50 for (unsigned int index
= 0; index
< sr
->PciRootBridgeNum
; index
++)
51 if (!strcmp(dt
, pciroot_res_to_domain_type(sr
, &sr
->PciRoot
[index
])))
57 bool is_pcie_iio_stack_res(const xSTACK_RES
*res
)
59 return is_domain_type_supported_on_stack(res
, DOMAIN_TYPE_PCIE
);
62 bool is_ioat_iio_stack_res(const xSTACK_RES
*res
)
64 return (is_domain_type_supported_on_stack(res
, DOMAIN_TYPE_DINO
) ||
65 is_domain_type_supported_on_stack(res
, DOMAIN_TYPE_CPM0
) ||
66 is_domain_type_supported_on_stack(res
, DOMAIN_TYPE_HQM0
));
70 bool is_ubox_stack_res(const xSTACK_RES
*res
)
72 return (is_domain_type_supported_on_stack(res
, DOMAIN_TYPE_UBX0
) ||
73 is_domain_type_supported_on_stack(res
, DOMAIN_TYPE_UBX1
));
76 bool is_iio_cxl_stack_res(const xSTACK_RES
*res
)
81 const struct SystemMemoryMapHob
*get_system_memory_map(void)
84 const EFI_GUID mem_hob_guid
= MEMORY_MAP_HOB_GUID
;
85 const struct SystemMemoryMapHob
**memmap_addr
;
87 memmap_addr
= (const struct SystemMemoryMapHob
**)
88 fsp_find_extension_hob_by_guid((uint8_t *)&mem_hob_guid
, &hob_size
);
89 /* hob_size is the size of the 8-byte address not the hob data */
90 assert(memmap_addr
!= NULL
&& hob_size
!= 0);
91 /* assert the pointer to the hob is not NULL */
92 assert(*memmap_addr
!= NULL
);
97 const struct SystemMemoryMapElement
*get_system_memory_map_elment(uint8_t *num
)
99 const struct SystemMemoryMapHob
*hob
= get_system_memory_map();
103 *num
= hob
->numberEntries
;
107 const CXL_NODE_SOCKET
*get_cxl_node(void)
110 static const CXL_NODE_SOCKET
*hob
;
111 const EFI_GUID fsp_hob_cxl_node_socket_guid
= CXL_NODE_HOB_GUID
;
116 hob
= fsp_find_extension_hob_by_guid((uint8_t *)&fsp_hob_cxl_node_socket_guid
, &hob_size
);
117 if (hob
== NULL
|| hob_size
== 0) {
118 printk(BIOS_DEBUG
, "CXL_NODE_HOB_GUID not found: CXL may not be installed\n");
124 uint8_t get_cxl_node_count(void)
126 const CXL_NODE_SOCKET
*hob
= get_cxl_node();
131 for (unsigned int skt_id
= 0 ; skt_id
< MAX_SOCKET
; skt_id
++)
132 count
+= hob
[skt_id
].CxlNodeCount
;
137 bool is_memtype_reserved(uint16_t mem_type
)
142 bool is_memtype_non_volatile(uint16_t mem_type
)
147 bool is_memtype_processor_attached(uint16_t mem_type
)
152 bool get_mmio_high_base_size(resource_t
*base
, resource_t
*size
)