Debian Codegraph @

src/soc/intel/xeon_sp/cpx/soc_util.c

raw symbols SCIP
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/pci_devs.h>
8 #include <soc/soc_util.h>
9 #include <soc/util.h>
10 #include <pc80/mc146818rtc.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 && hob_size != 0);
22 /* assert the pointer to the hob is not NULL */
23 assert(*memmap_addr);
24
25 return *memmap_addr;
26 }
27
28 bool is_pcie_iio_stack_res(const STACK_RES *res)
29 {
30 return res->Personality == TYPE_UBOX_IIO;
31 }
32
33 bool is_ubox_stack_res(const STACK_RES *res)
34 {
35 return res->Personality == TYPE_UBOX;
36 }
37
38 void soc_set_mrc_cold_boot_flag(bool cold_boot_required)
39 {
40 uint8_t mrc_status = cmos_read(CMOS_OFFSET_MRC_STATUS);
41 uint8_t new_mrc_status = (mrc_status & 0xfe) | cold_boot_required;
42 printk(BIOS_SPEW, "MRC status: 0x%02x want 0x%02x\n", mrc_status, new_mrc_status);
43 if (new_mrc_status != mrc_status) {
44 cmos_write(new_mrc_status, CMOS_OFFSET_MRC_STATUS);
45 }
46 }
47
48 void get_iiostack_info(struct iiostack_resource *info)
49 {
50 const IIO_UDS *hob = get_iio_uds();
51
52 // copy IIO Stack info from FSP HOB
53 info->no_of_stacks = 0;
54 for (int socket = 0, iio = 0; iio < hob->PlatformData.numofIIO; ++socket) {
55 if (!soc_cpu_is_enabled(socket))
56 continue;
57 iio++;
58 for (int x = 0; x < MAX_IIO_STACK; ++x) {
59 const STACK_RES *ri;
60 ri = &hob->PlatformData.IIO_resource[socket].StackRes[x];
61 if (!is_pcie_iio_stack_res(ri))
62 continue;
63 assert(info->no_of_stacks < (CONFIG_MAX_SOCKET * MAX_IIO_STACK));
64 memcpy(&info->res[info->no_of_stacks++], ri, sizeof(STACK_RES));
65 }
66 }
67 }
68
69 bool is_memtype_reserved(uint16_t mem_type)
70 {
71 return !!(mem_type & MEM_TYPE_RESERVED);
72 }
73
74 bool is_memtype_non_volatile(uint16_t mem_type)
75 {
76 return !(mem_type & MEMTYPE_VOLATILE_MASK);
77 }
78
79 bool is_memtype_processor_attached(uint16_t mem_type)
80 {
81 return true;
82 }
83
84 uint8_t get_cxl_node_count(void)
85 {
86 return 0;
87 }
88
89 bool get_mmio_high_base_size(resource_t *base, resource_t *size)
90 {
91 return false;
92 }