Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | |
| 3 | #include <acpi/acpigen.h> |
Felix Held | 4b2464f | 2022-02-23 17:54:20 +0100 | [diff] [blame] | 4 | #include <arch/hpet.h> |
Patrick Rudolph | 57ddd68 | 2023-02-28 09:17:40 +0100 | [diff] [blame] | 5 | #include <arch/ioapic.h> |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 6 | #include <assert.h> |
| 7 | #include <cbmem.h> |
Naresh Solanki | 559f9ed | 2023-01-20 19:38:07 +0100 | [diff] [blame] | 8 | #include <cpu/x86/lapic.h> |
Arthur Heymans | 36e6f9b | 2022-10-27 15:11:05 +0200 | [diff] [blame] | 9 | #include <commonlib/sort.h> |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 10 | #include <device/mmio.h> |
| 11 | #include <device/pci.h> |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 12 | #include <device/pciexp.h> |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 13 | #include <soc/acpi.h> |
Rocky Phagura | d4db36e | 2021-04-03 08:49:32 -0700 | [diff] [blame] | 14 | #include <soc/hest.h> |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 15 | #include <soc/iomap.h> |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 16 | #include <soc/numa.h> |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 17 | #include <soc/pci_devs.h> |
| 18 | #include <soc/soc_util.h> |
Marc Jones | 18960ce | 2020-11-02 12:41:12 -0700 | [diff] [blame] | 19 | #include <soc/util.h> |
Arthur Heymans | 695dd29 | 2020-11-12 21:05:09 +0100 | [diff] [blame] | 20 | #include <intelblocks/p2sb.h> |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 21 | |
| 22 | #include "chip.h" |
| 23 | |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 24 | /* NUMA related ACPI table generation. SRAT, SLIT, etc */ |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 25 | |
Arthur Heymans | 36e6f9b | 2022-10-27 15:11:05 +0200 | [diff] [blame] | 26 | /* Increase if necessary. Currently all x86 CPUs only have 2 SMP threads */ |
| 27 | #define MAX_THREAD 2 |
| 28 | |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 29 | unsigned long acpi_create_srat_lapics(unsigned long current) |
| 30 | { |
| 31 | struct device *cpu; |
Arthur Heymans | 36e6f9b | 2022-10-27 15:11:05 +0200 | [diff] [blame] | 32 | unsigned int num_cpus = 0; |
| 33 | int apic_ids[CONFIG_MAX_CPUS] = {}; |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 34 | |
Arthur Heymans | 36e6f9b | 2022-10-27 15:11:05 +0200 | [diff] [blame] | 35 | unsigned int sort_start = 0; |
| 36 | for (unsigned int thread_id = 0; thread_id < MAX_THREAD; thread_id++) { |
| 37 | for (cpu = all_devices; cpu; cpu = cpu->next) { |
| 38 | if (!is_enabled_cpu(cpu)) |
| 39 | continue; |
| 40 | if (num_cpus >= ARRAY_SIZE(apic_ids)) |
| 41 | break; |
| 42 | if (cpu->path.apic.thread_id != thread_id) |
| 43 | continue; |
| 44 | apic_ids[num_cpus++] = cpu->path.apic.apic_id; |
| 45 | } |
| 46 | bubblesort(&apic_ids[sort_start], num_cpus - sort_start, NUM_ASCENDING); |
| 47 | sort_start = num_cpus; |
| 48 | } |
| 49 | |
| 50 | for (unsigned int i = 0; i < num_cpus; i++) { |
| 51 | /* Match the sorted apic_ids to a struct device */ |
| 52 | for (cpu = all_devices; cpu; cpu = cpu->next) { |
| 53 | if (!is_enabled_cpu(cpu)) |
| 54 | continue; |
| 55 | if (cpu->path.apic.apic_id == apic_ids[i]) |
| 56 | break; |
| 57 | } |
| 58 | if (!cpu) |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 59 | continue; |
Naresh Solanki | 559f9ed | 2023-01-20 19:38:07 +0100 | [diff] [blame] | 60 | |
| 61 | if (is_x2apic_mode()) { |
Arthur Heymans | 36e6f9b | 2022-10-27 15:11:05 +0200 | [diff] [blame] | 62 | printk(BIOS_DEBUG, "SRAT: x2apic cpu_index=%04x, node_id=%02x, apic_id=%08x\n", |
| 63 | i, cpu->path.apic.node_id, cpu->path.apic.apic_id); |
Naresh Solanki | 559f9ed | 2023-01-20 19:38:07 +0100 | [diff] [blame] | 64 | |
| 65 | current += acpi_create_srat_x2apic((acpi_srat_x2apic_t *)current, |
| 66 | cpu->path.apic.node_id, cpu->path.apic.apic_id); |
| 67 | } else { |
| 68 | printk(BIOS_DEBUG, "SRAT: lapic cpu_index=%02x, node_id=%02x, apic_id=%02x\n", |
Arthur Heymans | 36e6f9b | 2022-10-27 15:11:05 +0200 | [diff] [blame] | 69 | i, cpu->path.apic.node_id, cpu->path.apic.apic_id); |
Naresh Solanki | 559f9ed | 2023-01-20 19:38:07 +0100 | [diff] [blame] | 70 | |
| 71 | current += acpi_create_srat_lapic((acpi_srat_lapic_t *)current, |
| 72 | cpu->path.apic.node_id, cpu->path.apic.apic_id); |
| 73 | } |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 74 | } |
| 75 | return current; |
| 76 | } |
| 77 | |
| 78 | static unsigned int get_srat_memory_entries(acpi_srat_mem_t *srat_mem) |
| 79 | { |
| 80 | const struct SystemMemoryMapHob *memory_map; |
| 81 | unsigned int mmap_index; |
| 82 | |
| 83 | memory_map = get_system_memory_map(); |
Elyes Haouas | f1ba7d6 | 2022-09-13 10:03:44 +0200 | [diff] [blame] | 84 | assert(memory_map); |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 85 | printk(BIOS_DEBUG, "memory_map: %p\n", memory_map); |
| 86 | |
| 87 | mmap_index = 0; |
| 88 | for (int e = 0; e < memory_map->numberEntries; ++e) { |
| 89 | const struct SystemMemoryMapElement *mem_element = &memory_map->Element[e]; |
| 90 | uint64_t addr = |
Elyes Haouas | 9018dee | 2022-11-18 15:07:33 +0100 | [diff] [blame] | 91 | (uint64_t)((uint64_t)mem_element->BaseAddress << |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 92 | MEM_ADDR_64MB_SHIFT_BITS); |
| 93 | uint64_t size = |
Elyes Haouas | 9018dee | 2022-11-18 15:07:33 +0100 | [diff] [blame] | 94 | (uint64_t)((uint64_t)mem_element->ElementSize << |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 95 | MEM_ADDR_64MB_SHIFT_BITS); |
| 96 | |
| 97 | printk(BIOS_DEBUG, "memory_map %d addr: 0x%llx, BaseAddress: 0x%x, size: 0x%llx, " |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 98 | "ElementSize: 0x%x, type: %d, reserved: %d\n", |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 99 | e, addr, mem_element->BaseAddress, size, |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 100 | mem_element->ElementSize, mem_element->Type, |
| 101 | (mem_element->Type & MEM_TYPE_RESERVED)); |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 102 | |
| 103 | assert(mmap_index < MAX_ACPI_MEMORY_AFFINITY_COUNT); |
| 104 | |
| 105 | /* skip reserved memory region */ |
| 106 | if (mem_element->Type & MEM_TYPE_RESERVED) |
| 107 | continue; |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 108 | #if CONFIG(SOC_INTEL_SAPPHIRERAPIDS_SP) |
| 109 | /* Skip all non processor attached memory regions */ |
| 110 | /* In other words, skip all the types >= MemTypeCxlAccVolatileMem */ |
| 111 | if (mem_element->Type >= MemTypeCxlAccVolatileMem) |
| 112 | continue; |
| 113 | #endif |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 114 | |
| 115 | /* skip if this address is already added */ |
| 116 | bool skip = false; |
| 117 | for (int idx = 0; idx < mmap_index; ++idx) { |
| 118 | uint64_t base_addr = ((uint64_t)srat_mem[idx].base_address_high << 32) + |
| 119 | srat_mem[idx].base_address_low; |
| 120 | if (addr == base_addr) { |
| 121 | skip = true; |
| 122 | break; |
| 123 | } |
| 124 | } |
| 125 | if (skip) |
| 126 | continue; |
| 127 | |
| 128 | srat_mem[mmap_index].type = 1; /* Memory affinity structure */ |
| 129 | srat_mem[mmap_index].length = sizeof(acpi_srat_mem_t); |
Elyes Haouas | 9018dee | 2022-11-18 15:07:33 +0100 | [diff] [blame] | 130 | srat_mem[mmap_index].base_address_low = (uint32_t)(addr & 0xffffffff); |
| 131 | srat_mem[mmap_index].base_address_high = (uint32_t)(addr >> 32); |
| 132 | srat_mem[mmap_index].length_low = (uint32_t)(size & 0xffffffff); |
| 133 | srat_mem[mmap_index].length_high = (uint32_t)(size >> 32); |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 134 | srat_mem[mmap_index].proximity_domain = mem_element->SocketId; |
Shuo Liu | 3108ba5 | 2022-07-05 22:56:28 +0800 | [diff] [blame] | 135 | srat_mem[mmap_index].flags = ACPI_SRAT_MEMORY_ENABLED; |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 136 | if ((mem_element->Type & MEMTYPE_VOLATILE_MASK) == 0) |
Shuo Liu | 3108ba5 | 2022-07-05 22:56:28 +0800 | [diff] [blame] | 137 | srat_mem[mmap_index].flags |= ACPI_SRAT_MEMORY_NONVOLATILE; |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 138 | ++mmap_index; |
| 139 | } |
| 140 | |
| 141 | return mmap_index; |
| 142 | } |
| 143 | |
| 144 | static unsigned long acpi_fill_srat(unsigned long current) |
| 145 | { |
| 146 | acpi_srat_mem_t srat_mem[MAX_ACPI_MEMORY_AFFINITY_COUNT]; |
| 147 | unsigned int mem_count; |
| 148 | |
| 149 | /* create all subtables for processors */ |
| 150 | current = acpi_create_srat_lapics(current); |
| 151 | |
Naresh Solanki | 9fd5c69 | 2023-05-22 16:47:47 +0200 | [diff] [blame] | 152 | memset(srat_mem, 0, sizeof(srat_mem)); |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 153 | mem_count = get_srat_memory_entries(srat_mem); |
| 154 | for (int i = 0; i < mem_count; ++i) { |
| 155 | printk(BIOS_DEBUG, "adding srat memory %d entry length: %d, addr: 0x%x%x, " |
| 156 | "length: 0x%x%x, proximity_domain: %d, flags: %x\n", |
| 157 | i, srat_mem[i].length, |
| 158 | srat_mem[i].base_address_high, srat_mem[i].base_address_low, |
| 159 | srat_mem[i].length_high, srat_mem[i].length_low, |
| 160 | srat_mem[i].proximity_domain, srat_mem[i].flags); |
| 161 | memcpy((acpi_srat_mem_t *)current, &srat_mem[i], sizeof(srat_mem[i])); |
| 162 | current += srat_mem[i].length; |
| 163 | } |
| 164 | |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 165 | if (CONFIG(SOC_INTEL_HAS_CXL)) |
| 166 | current = cxl_fill_srat(current); |
| 167 | |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 168 | return current; |
| 169 | } |
| 170 | |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 171 | #if CONFIG(SOC_INTEL_SAPPHIRERAPIDS_SP) |
| 172 | /* |
| 173 | Because pds.num_pds comes from spr/numa.c function fill_pds(). |
| 174 | pds.num_pds = soc_get_num_cpus() + get_cxl_node_count(). |
| 175 | */ |
| 176 | /* SPR-SP platform has Generic Initiator domain in addition to processor domain */ |
| 177 | static unsigned long acpi_fill_slit(unsigned long current) |
| 178 | { |
| 179 | uint8_t *p = (uint8_t *)current; |
| 180 | /* According to table 5.60 of ACPI 6.4 spec, "Number of System Localities" field takes |
| 181 | up 8 bytes. Following that, each matrix entry takes up 1 byte. */ |
| 182 | memset(p, 0, 8 + pds.num_pds * pds.num_pds); |
| 183 | *p = (uint8_t)pds.num_pds; |
| 184 | p += 8; |
| 185 | |
| 186 | for (int i = 0; i < pds.num_pds; i++) { |
| 187 | for (int j = 0; j < pds.num_pds; j++) |
| 188 | p[i * pds.num_pds + j] = pds.pds[i].distances[j]; |
| 189 | } |
| 190 | |
| 191 | current += 8 + pds.num_pds * pds.num_pds; |
| 192 | return current; |
| 193 | } |
| 194 | #else |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 195 | static unsigned long acpi_fill_slit(unsigned long current) |
| 196 | { |
Marc Jones | 70907b0 | 2020-10-28 17:00:31 -0600 | [diff] [blame] | 197 | unsigned int nodes = soc_get_num_cpus(); |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 198 | |
| 199 | uint8_t *p = (uint8_t *)current; |
| 200 | memset(p, 0, 8 + nodes * nodes); |
| 201 | *p = (uint8_t)nodes; |
| 202 | p += 8; |
| 203 | |
| 204 | /* this assumes fully connected socket topology */ |
| 205 | for (int i = 0; i < nodes; i++) { |
| 206 | for (int j = 0; j < nodes; j++) { |
| 207 | if (i == j) |
| 208 | p[i*nodes+j] = 10; |
| 209 | else |
| 210 | p[i*nodes+j] = 16; |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | current += 8 + nodes * nodes; |
| 215 | return current; |
| 216 | } |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 217 | #endif |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 218 | |
| 219 | /* |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 220 | * This function adds PCIe bridge device entry in DMAR table. If it is called |
| 221 | * in the context of ATSR subtable, it adds ATSR subtable when it is first called. |
| 222 | */ |
| 223 | static unsigned long acpi_create_dmar_ds_pci_br_for_port(unsigned long current, |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 224 | const struct device *bridge_dev, |
| 225 | uint32_t pcie_seg, |
| 226 | bool is_atsr, bool *first) |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 227 | { |
Arthur Heymans | 7fcd4d5 | 2023-08-24 15:12:19 +0200 | [diff] [blame] | 228 | const uint32_t bus = bridge_dev->upstream->secondary; |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 229 | const uint32_t dev = PCI_SLOT(bridge_dev->path.pci.devfn); |
| 230 | const uint32_t func = PCI_FUNC(bridge_dev->path.pci.devfn); |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 231 | |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 232 | if (bus == 0) |
| 233 | return current; |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 234 | |
| 235 | unsigned long atsr_size = 0; |
| 236 | unsigned long pci_br_size = 0; |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 237 | if (is_atsr == true && first && *first == true) { |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 238 | printk(BIOS_DEBUG, "[Root Port ATS Capability] Flags: 0x%x, " |
| 239 | "PCI Segment Number: 0x%x\n", 0, pcie_seg); |
| 240 | atsr_size = acpi_create_dmar_atsr(current, 0, pcie_seg); |
| 241 | *first = false; |
| 242 | } |
| 243 | |
| 244 | printk(BIOS_DEBUG, " [PCI Bridge Device] Enumeration ID: 0x%x, " |
| 245 | "PCI Bus Number: 0x%x, PCI Path: 0x%x, 0x%x\n", |
| 246 | 0, bus, dev, func); |
| 247 | pci_br_size = acpi_create_dmar_ds_pci_br(current + atsr_size, bus, dev, func); |
| 248 | |
| 249 | return (atsr_size + pci_br_size); |
| 250 | } |
| 251 | |
| 252 | static unsigned long acpi_create_drhd(unsigned long current, int socket, |
| 253 | int stack, const IIO_UDS *hob) |
| 254 | { |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 255 | unsigned long tmp = current; |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 256 | const STACK_RES *ri = &hob->PlatformData.IIO_resource[socket].StackRes[stack]; |
| 257 | const uint32_t bus = ri->BusBase; |
| 258 | const uint32_t pcie_seg = hob->PlatformData.CpuQpiInfo[socket].PcieSegment; |
| 259 | const uint32_t reg_base = ri->VtdBarAddress; |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 260 | printk(BIOS_SPEW, "%s socket: %d, stack: %d, bus: 0x%x, pcie_seg: 0x%x, reg_base: 0x%x\n", |
| 261 | __func__, socket, stack, bus, pcie_seg, reg_base); |
| 262 | |
| 263 | /* Do not generate DRHD for non-PCIe stack */ |
| 264 | if (!reg_base) |
| 265 | return current; |
| 266 | |
Arthur Heymans | a1c4ad3 | 2021-05-04 18:40:28 +0200 | [diff] [blame] | 267 | // Add DRHD Hardware Unit |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 268 | |
| 269 | if (socket == 0 && stack == IioStack0) { |
Arthur Heymans | a1c4ad3 | 2021-05-04 18:40:28 +0200 | [diff] [blame] | 270 | printk(BIOS_DEBUG, "[Hardware Unit Definition] Flags: 0x%x, PCI Segment Number: 0x%x, " |
| 271 | "Register Base Address: 0x%x\n", |
| 272 | DRHD_INCLUDE_PCI_ALL, pcie_seg, reg_base); |
| 273 | current += acpi_create_dmar_drhd(current, DRHD_INCLUDE_PCI_ALL, |
| 274 | pcie_seg, reg_base); |
| 275 | } else { |
| 276 | printk(BIOS_DEBUG, "[Hardware Unit Definition] Flags: 0x%x, PCI Segment Number: 0x%x, " |
| 277 | "Register Base Address: 0x%x\n", 0, pcie_seg, reg_base); |
| 278 | current += acpi_create_dmar_drhd(current, 0, pcie_seg, reg_base); |
| 279 | } |
| 280 | |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 281 | // Add PCH IOAPIC |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 282 | if (socket == 0 && stack == IioStack0) { |
Arthur Heymans | 6e425e1 | 2020-11-12 21:12:05 +0100 | [diff] [blame] | 283 | union p2sb_bdf ioapic_bdf = p2sb_get_ioapic_bdf(); |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 284 | printk(BIOS_DEBUG, " [IOAPIC Device] Enumeration ID: 0x%x, PCI Bus Number: 0x%x, " |
Patrick Rudolph | 57ddd68 | 2023-02-28 09:17:40 +0100 | [diff] [blame] | 285 | "PCI Path: 0x%x, 0x%x\n", get_ioapic_id(VIO_APIC_VADDR), ioapic_bdf.bus, |
| 286 | ioapic_bdf.dev, ioapic_bdf.fn); |
| 287 | current += acpi_create_dmar_ds_ioapic_from_hw(current, |
| 288 | IO_APIC_ADDR, ioapic_bdf.bus, ioapic_bdf.dev, ioapic_bdf.fn); |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 289 | } |
| 290 | |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 291 | /* SPR has no per stack IOAPIC or CBDMA devices */ |
| 292 | #if CONFIG(SOC_INTEL_SKYLAKE_SP) || CONFIG(SOC_INTEL_COOPERLAKE_SP) |
| 293 | uint32_t enum_id; |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 294 | // Add IOAPIC entry |
Arthur Heymans | a1cc557 | 2020-11-06 12:53:33 +0100 | [diff] [blame] | 295 | enum_id = soc_get_iio_ioapicid(socket, stack); |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 296 | printk(BIOS_DEBUG, " [IOAPIC Device] Enumeration ID: 0x%x, PCI Bus Number: 0x%x, " |
| 297 | "PCI Path: 0x%x, 0x%x\n", enum_id, bus, APIC_DEV_NUM, APIC_FUNC_NUM); |
| 298 | current += acpi_create_dmar_ds_ioapic(current, enum_id, bus, |
| 299 | APIC_DEV_NUM, APIC_FUNC_NUM); |
| 300 | |
| 301 | // Add CBDMA devices for CSTACK |
| 302 | if (socket != 0 && stack == CSTACK) { |
| 303 | for (int cbdma_func_id = 0; cbdma_func_id < 8; ++cbdma_func_id) { |
| 304 | printk(BIOS_DEBUG, " [PCI Endpoint Device] Enumeration ID: 0x%x, " |
| 305 | "PCI Bus Number: 0x%x, PCI Path: 0x%x, 0x%x\n", |
| 306 | 0, bus, CBDMA_DEV_NUM, cbdma_func_id); |
| 307 | current += acpi_create_dmar_ds_pci(current, |
| 308 | bus, CBDMA_DEV_NUM, cbdma_func_id); |
| 309 | } |
| 310 | } |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 311 | #endif |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 312 | |
| 313 | // Add PCIe Ports |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 314 | if (socket != 0 || stack != IioStack0) { |
| 315 | struct device *dev = pcidev_path_on_bus(bus, PCI_DEVFN(0, 0)); |
| 316 | while (dev) { |
| 317 | if ((dev->hdr_type & 0x7f) == PCI_HEADER_TYPE_BRIDGE) |
| 318 | current += |
| 319 | acpi_create_dmar_ds_pci_br_for_port( |
| 320 | current, dev, pcie_seg, false, NULL); |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 321 | |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 322 | dev = dev->sibling; |
| 323 | } |
| 324 | |
| 325 | #if CONFIG(SOC_INTEL_SKYLAKE_SP) || CONFIG(SOC_INTEL_COOPERLAKE_SP) |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 326 | // Add VMD |
| 327 | if (hob->PlatformData.VMDStackEnable[socket][stack] && |
| 328 | stack >= PSTACK0 && stack <= PSTACK2) { |
| 329 | printk(BIOS_DEBUG, " [PCI Endpoint Device] Enumeration ID: 0x%x, " |
| 330 | "PCI Bus Number: 0x%x, PCI Path: 0x%x, 0x%x\n", |
| 331 | 0, bus, VMD_DEV_NUM, VMD_FUNC_NUM); |
| 332 | current += acpi_create_dmar_ds_pci(current, |
| 333 | bus, VMD_DEV_NUM, VMD_FUNC_NUM); |
| 334 | } |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 335 | #endif |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 336 | } |
| 337 | |
Shuo Liu | 08f1f05 | 2024-01-20 02:52:17 +0800 | [diff] [blame] | 338 | // Add IOAT End Points (with memory resources. We don't report every End Point device.) |
Shuo Liu | 313b18a | 2024-02-21 18:54:31 +0800 | [diff] [blame] | 339 | if (CONFIG(HAVE_IOAT_DOMAINS) && is_ioat_iio_stack_res(ri)) { |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 340 | for (int b = ri->BusBase; b <= ri->BusLimit; ++b) { |
| 341 | struct device *dev = pcidev_path_on_bus(b, PCI_DEVFN(0, 0)); |
| 342 | while (dev) { |
| 343 | /* This may also require a check for IORESOURCE_PREFETCH, |
| 344 | * but that would not include the FPU (4942/0) */ |
| 345 | if ((dev->resource_list->flags & |
| 346 | (IORESOURCE_MEM | IORESOURCE_PCI64 | IORESOURCE_ASSIGNED)) == |
| 347 | (IORESOURCE_MEM | IORESOURCE_PCI64 | IORESOURCE_ASSIGNED)) { |
| 348 | const uint32_t d = PCI_SLOT(dev->path.pci.devfn); |
| 349 | const uint32_t f = PCI_FUNC(dev->path.pci.devfn); |
| 350 | printk(BIOS_DEBUG, " [PCIE Endpoint Device] " |
| 351 | "Enumeration ID: 0x%x, PCI Bus Number: 0x%x, " |
| 352 | " PCI Path: 0x%x, 0x%x\n", 0, b, d, f); |
| 353 | current += acpi_create_dmar_ds_pci(current, b, d, f); |
| 354 | } |
| 355 | dev = dev->sibling; |
| 356 | } |
| 357 | } |
| 358 | } |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 359 | |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 360 | // Add HPET |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 361 | if (socket == 0 && stack == IioStack0) { |
Elyes Haouas | 167b7fcd | 2022-12-11 10:38:35 +0100 | [diff] [blame] | 362 | uint16_t hpet_capid = read16p(HPET_BASE_ADDRESS); |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 363 | uint16_t num_hpets = (hpet_capid >> 0x08) & 0x1F; // Bits [8:12] has hpet count |
| 364 | printk(BIOS_SPEW, "%s hpet_capid: 0x%x, num_hpets: 0x%x\n", |
| 365 | __func__, hpet_capid, num_hpets); |
| 366 | //BIT 15 |
| 367 | if (num_hpets && (num_hpets != 0x1f) && |
Elyes Haouas | 167b7fcd | 2022-12-11 10:38:35 +0100 | [diff] [blame] | 368 | (read32p(HPET_BASE_ADDRESS + 0x100) & (0x00008000))) { |
Arthur Heymans | 695dd29 | 2020-11-12 21:05:09 +0100 | [diff] [blame] | 369 | union p2sb_bdf hpet_bdf = p2sb_get_hpet_bdf(); |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 370 | printk(BIOS_DEBUG, " [Message-capable HPET Device] Enumeration ID: 0x%x, " |
| 371 | "PCI Bus Number: 0x%x, PCI Path: 0x%x, 0x%x\n", |
Arthur Heymans | 695dd29 | 2020-11-12 21:05:09 +0100 | [diff] [blame] | 372 | 0, hpet_bdf.bus, hpet_bdf.dev, hpet_bdf.fn); |
| 373 | current += acpi_create_dmar_ds_msi_hpet(current, 0, hpet_bdf.bus, |
| 374 | hpet_bdf.dev, hpet_bdf.fn); |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 375 | } |
| 376 | } |
| 377 | |
| 378 | acpi_dmar_drhd_fixup(tmp, current); |
| 379 | |
| 380 | return current; |
| 381 | } |
| 382 | |
| 383 | static unsigned long acpi_create_atsr(unsigned long current, const IIO_UDS *hob) |
| 384 | { |
Patrick Rudolph | ac02857 | 2023-07-14 17:44:33 +0200 | [diff] [blame] | 385 | for (int socket = 0, iio = 0; iio < hob->PlatformData.numofIIO; ++socket) { |
| 386 | if (!soc_cpu_is_enabled(socket)) |
| 387 | continue; |
| 388 | iio++; |
| 389 | |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 390 | uint32_t pcie_seg = hob->PlatformData.CpuQpiInfo[socket].PcieSegment; |
| 391 | unsigned long tmp = current; |
| 392 | bool first = true; |
| 393 | IIO_RESOURCE_INSTANCE iio_resource = |
| 394 | hob->PlatformData.IIO_resource[socket]; |
| 395 | |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 396 | for (int stack = 0; stack < MAX_LOGIC_IIO_STACK; ++stack) { |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 397 | uint32_t bus = iio_resource.StackRes[stack].BusBase; |
| 398 | uint32_t vtd_base = iio_resource.StackRes[stack].VtdBarAddress; |
| 399 | if (!vtd_base) |
| 400 | continue; |
Elyes Haouas | 167b7fcd | 2022-12-11 10:38:35 +0100 | [diff] [blame] | 401 | uint64_t vtd_mmio_cap = read64p(vtd_base + VTD_EXT_CAP_LOW); |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 402 | printk(BIOS_SPEW, "%s socket: %d, stack: %d, bus: 0x%x, vtd_base: 0x%x, " |
| 403 | "vtd_mmio_cap: 0x%llx\n", |
| 404 | __func__, socket, stack, bus, vtd_base, vtd_mmio_cap); |
| 405 | |
| 406 | // ATSR is applicable only for platform supporting device IOTLBs |
| 407 | // through the VT-d extended capability register |
| 408 | assert(vtd_mmio_cap != 0xffffffffffffffff); |
| 409 | if ((vtd_mmio_cap & 0x4) == 0) // BIT 2 |
| 410 | continue; |
| 411 | |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 412 | if (bus == 0) |
| 413 | continue; |
| 414 | |
| 415 | struct device *dev = pcidev_path_on_bus(bus, PCI_DEVFN(0, 0)); |
| 416 | while (dev) { |
| 417 | if ((dev->hdr_type & 0x7f) == PCI_HEADER_TYPE_BRIDGE) |
| 418 | current += |
| 419 | acpi_create_dmar_ds_pci_br_for_port( |
| 420 | current, dev, pcie_seg, true, &first); |
| 421 | |
| 422 | dev = dev->sibling; |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 423 | } |
| 424 | } |
| 425 | if (tmp != current) |
| 426 | acpi_dmar_atsr_fixup(tmp, current); |
| 427 | } |
| 428 | |
| 429 | return current; |
| 430 | } |
| 431 | |
| 432 | static unsigned long acpi_create_rmrr(unsigned long current) |
| 433 | { |
| 434 | uint32_t size = ALIGN_UP(MEM_BLK_COUNT * sizeof(MEM_BLK), 0x1000); |
| 435 | |
| 436 | uint32_t *ptr; |
| 437 | |
| 438 | // reserve memory |
| 439 | ptr = cbmem_find(CBMEM_ID_STORAGE_DATA); |
| 440 | if (!ptr) { |
| 441 | ptr = cbmem_add(CBMEM_ID_STORAGE_DATA, size); |
Elyes Haouas | f1ba7d6 | 2022-09-13 10:03:44 +0200 | [diff] [blame] | 442 | assert(ptr); |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 443 | memset(ptr, 0, size); |
| 444 | } |
| 445 | |
| 446 | unsigned long tmp = current; |
| 447 | printk(BIOS_DEBUG, "[Reserved Memory Region] PCI Segment Number: 0x%x, Base Address: 0x%x, " |
| 448 | "End Address (limit): 0x%x\n", |
Elyes Haouas | 9018dee | 2022-11-18 15:07:33 +0100 | [diff] [blame] | 449 | 0, (uint32_t)ptr, (uint32_t)((uint32_t)ptr + size - 1)); |
| 450 | current += acpi_create_dmar_rmrr(current, 0, (uint32_t)ptr, |
| 451 | (uint32_t)((uint32_t)ptr + size - 1)); |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 452 | |
| 453 | printk(BIOS_DEBUG, " [PCI Endpoint Device] Enumeration ID: 0x%x, PCI Bus Number: 0x%x, " |
| 454 | "PCI Path: 0x%x, 0x%x\n", |
| 455 | 0, XHCI_BUS_NUMBER, PCH_DEV_SLOT_XHCI, XHCI_FUNC_NUM); |
| 456 | current += acpi_create_dmar_ds_pci(current, XHCI_BUS_NUMBER, |
| 457 | PCH_DEV_SLOT_XHCI, XHCI_FUNC_NUM); |
| 458 | |
| 459 | acpi_dmar_rmrr_fixup(tmp, current); |
| 460 | |
| 461 | return current; |
| 462 | } |
| 463 | |
| 464 | static unsigned long acpi_create_rhsa(unsigned long current) |
| 465 | { |
Arthur Heymans | 83b2622 | 2020-11-06 11:50:55 +0100 | [diff] [blame] | 466 | const IIO_UDS *hob = get_iio_uds(); |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 467 | |
Patrick Rudolph | ac02857 | 2023-07-14 17:44:33 +0200 | [diff] [blame] | 468 | for (int socket = 0, iio = 0; iio < hob->PlatformData.numofIIO; ++socket) { |
| 469 | if (!soc_cpu_is_enabled(socket)) |
| 470 | continue; |
| 471 | iio++; |
| 472 | |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 473 | IIO_RESOURCE_INSTANCE iio_resource = |
| 474 | hob->PlatformData.IIO_resource[socket]; |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 475 | for (int stack = 0; stack < MAX_LOGIC_IIO_STACK; ++stack) { |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 476 | uint32_t vtd_base = iio_resource.StackRes[stack].VtdBarAddress; |
| 477 | if (!vtd_base) |
| 478 | continue; |
| 479 | |
| 480 | printk(BIOS_DEBUG, "[Remapping Hardware Static Affinity] Base Address: 0x%x, " |
| 481 | "Proximity Domain: 0x%x\n", vtd_base, socket); |
| 482 | current += acpi_create_dmar_rhsa(current, vtd_base, socket); |
| 483 | } |
| 484 | } |
| 485 | |
| 486 | return current; |
| 487 | } |
| 488 | |
Shuo Liu | 08f1f05 | 2024-01-20 02:52:17 +0800 | [diff] [blame] | 489 | static unsigned long xeonsp_create_satc_ioat(unsigned long current, const STACK_RES *ri) |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 490 | { |
| 491 | for (int b = ri->BusBase; b <= ri->BusLimit; ++b) { |
| 492 | struct device *dev = pcidev_path_on_bus(b, PCI_DEVFN(0, 0)); |
| 493 | while (dev) { |
| 494 | if (pciexp_find_extended_cap(dev, PCIE_EXT_CAP_ID_ATS, 0)) { |
| 495 | const uint32_t d = PCI_SLOT(dev->path.pci.devfn); |
| 496 | const uint32_t f = PCI_FUNC(dev->path.pci.devfn); |
| 497 | printk(BIOS_DEBUG, " [SATC Endpoint Device] " |
| 498 | "Enumeration ID: 0x%x, PCI Bus Number: 0x%x, " |
| 499 | " PCI Path: 0x%x, 0x%x\n", 0, b, d, f); |
| 500 | current += acpi_create_dmar_ds_pci(current, b, d, f); |
| 501 | } |
| 502 | dev = dev->sibling; |
| 503 | } |
| 504 | } |
| 505 | return current; |
| 506 | } |
| 507 | |
| 508 | /* SoC Integrated Address Translation Cache */ |
| 509 | static unsigned long acpi_create_satc(unsigned long current, const IIO_UDS *hob) |
| 510 | { |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 511 | const unsigned long tmp = current; |
| 512 | |
| 513 | // Add the SATC header |
| 514 | current += acpi_create_dmar_satc(current, 0, 0); |
| 515 | |
Shuo Liu | 08f1f05 | 2024-01-20 02:52:17 +0800 | [diff] [blame] | 516 | // Find the IOAT devices on each socket |
Patrick Rudolph | ac02857 | 2023-07-14 17:44:33 +0200 | [diff] [blame] | 517 | for (int socket = CONFIG_MAX_SOCKET - 1; socket >= 0; --socket) { |
| 518 | if (!soc_cpu_is_enabled(socket)) |
| 519 | continue; |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 520 | for (int stack = (MAX_LOGIC_IIO_STACK - 1); stack >= 0; --stack) { |
| 521 | const STACK_RES *ri = &hob->PlatformData.IIO_resource[socket].StackRes[stack]; |
Shuo Liu | 08f1f05 | 2024-01-20 02:52:17 +0800 | [diff] [blame] | 522 | // Add the IOAT ATS devices to the SATC |
Shuo Liu | 313b18a | 2024-02-21 18:54:31 +0800 | [diff] [blame] | 523 | if (CONFIG(HAVE_IOAT_DOMAINS) && is_ioat_iio_stack_res(ri)) |
Shuo Liu | 08f1f05 | 2024-01-20 02:52:17 +0800 | [diff] [blame] | 524 | current = xeonsp_create_satc_ioat(current, ri); |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 525 | } |
| 526 | } |
| 527 | |
| 528 | acpi_dmar_satc_fixup(tmp, current); |
| 529 | return current; |
| 530 | } |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 531 | |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 532 | static unsigned long acpi_fill_dmar(unsigned long current) |
| 533 | { |
Arthur Heymans | 83b2622 | 2020-11-06 11:50:55 +0100 | [diff] [blame] | 534 | const IIO_UDS *hob = get_iio_uds(); |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 535 | |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 536 | // DRHD - socket 0 stack 0 must be the last DRHD entry. |
Patrick Rudolph | ac02857 | 2023-07-14 17:44:33 +0200 | [diff] [blame] | 537 | for (int socket = (CONFIG_MAX_SOCKET - 1); socket >= 0; --socket) { |
| 538 | if (!soc_cpu_is_enabled(socket)) |
| 539 | continue; |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 540 | for (int stack = (MAX_LOGIC_IIO_STACK - 1); stack >= 0; --stack) |
| 541 | current = acpi_create_drhd(current, socket, stack, hob); |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 542 | } |
| 543 | |
| 544 | // RMRR |
| 545 | current = acpi_create_rmrr(current); |
| 546 | |
| 547 | // Root Port ATS Capability |
| 548 | current = acpi_create_atsr(current, hob); |
| 549 | |
| 550 | // RHSA |
| 551 | current = acpi_create_rhsa(current); |
| 552 | |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 553 | // SATC |
Shuo Liu | 08f1f05 | 2024-01-20 02:52:17 +0800 | [diff] [blame] | 554 | if (CONFIG(HAVE_IOAT_DOMAINS)) |
| 555 | current = acpi_create_satc(current, hob); |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 556 | |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 557 | return current; |
| 558 | } |
| 559 | |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 560 | unsigned long northbridge_write_acpi_tables(const struct device *device, unsigned long current, |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 561 | struct acpi_rsdp *rsdp) |
| 562 | { |
| 563 | acpi_srat_t *srat; |
| 564 | acpi_slit_t *slit; |
| 565 | acpi_dmar_t *dmar; |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 566 | acpi_hmat_t *hmat; |
| 567 | acpi_cedt_t *cedt; |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 568 | |
| 569 | const config_t *const config = config_of(device); |
| 570 | |
| 571 | /* SRAT */ |
Elyes Haouas | d6b6b22 | 2022-10-10 12:34:21 +0200 | [diff] [blame] | 572 | current = ALIGN_UP(current, 8); |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 573 | printk(BIOS_DEBUG, "ACPI: * SRAT at %lx\n", current); |
Elyes Haouas | 9018dee | 2022-11-18 15:07:33 +0100 | [diff] [blame] | 574 | srat = (acpi_srat_t *)current; |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 575 | acpi_create_srat(srat, acpi_fill_srat); |
| 576 | current += srat->header.length; |
| 577 | acpi_add_table(rsdp, srat); |
| 578 | |
| 579 | /* SLIT */ |
Elyes Haouas | d6b6b22 | 2022-10-10 12:34:21 +0200 | [diff] [blame] | 580 | current = ALIGN_UP(current, 8); |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 581 | printk(BIOS_DEBUG, "ACPI: * SLIT at %lx\n", current); |
Elyes Haouas | 9018dee | 2022-11-18 15:07:33 +0100 | [diff] [blame] | 582 | slit = (acpi_slit_t *)current; |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 583 | acpi_create_slit(slit, acpi_fill_slit); |
| 584 | current += slit->header.length; |
| 585 | acpi_add_table(rsdp, slit); |
| 586 | |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 587 | if (CONFIG(SOC_INTEL_HAS_CXL)) { |
| 588 | /* HMAT*/ |
| 589 | current = ALIGN_UP(current, 8); |
| 590 | printk(BIOS_DEBUG, "ACPI: * HMAT at %lx\n", current); |
| 591 | hmat = (acpi_hmat_t *)current; |
| 592 | acpi_create_hmat(hmat, acpi_fill_hmat); |
| 593 | current += hmat->header.length; |
| 594 | acpi_add_table(rsdp, hmat); |
| 595 | } |
| 596 | |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 597 | /* DMAR */ |
| 598 | if (config->vtd_support) { |
Elyes Haouas | d6b6b22 | 2022-10-10 12:34:21 +0200 | [diff] [blame] | 599 | current = ALIGN_UP(current, 8); |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 600 | dmar = (acpi_dmar_t *)current; |
Marc Jones | b7e591e | 2020-11-13 15:55:31 -0700 | [diff] [blame] | 601 | enum dmar_flags flags = DMAR_INTR_REMAP; |
| 602 | |
| 603 | /* SKX FSP doesn't support X2APIC, but CPX FSP does */ |
| 604 | if (CONFIG(SOC_INTEL_SKYLAKE_SP)) |
| 605 | flags |= DMAR_X2APIC_OPT_OUT; |
| 606 | |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 607 | printk(BIOS_DEBUG, "ACPI: * DMAR at %lx\n", current); |
Marc Jones | b7e591e | 2020-11-13 15:55:31 -0700 | [diff] [blame] | 608 | printk(BIOS_DEBUG, "[DMA Remapping table] Flags: 0x%x\n", flags); |
| 609 | acpi_create_dmar(dmar, flags, acpi_fill_dmar); |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 610 | current += dmar->header.length; |
| 611 | current = acpi_align_current(current); |
| 612 | acpi_add_table(rsdp, dmar); |
| 613 | } |
| 614 | |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 615 | if (CONFIG(SOC_INTEL_HAS_CXL)) { |
| 616 | /* CEDT: CXL Early Discovery Table */ |
| 617 | if (get_cxl_node_count() > 0) { |
| 618 | current = ALIGN_UP(current, 8); |
| 619 | printk(BIOS_DEBUG, "ACPI: * CEDT at %lx\n", current); |
| 620 | cedt = (acpi_cedt_t *)current; |
| 621 | acpi_create_cedt(cedt, acpi_fill_cedt); |
| 622 | current += cedt->header.length; |
| 623 | acpi_add_table(rsdp, cedt); |
| 624 | } |
| 625 | } |
| 626 | |
| 627 | if (CONFIG(SOC_ACPI_HEST)) { |
| 628 | printk(BIOS_DEBUG, "ACPI: * HEST at %lx\n", current); |
Rocky Phagura | d4db36e | 2021-04-03 08:49:32 -0700 | [diff] [blame] | 629 | current = hest_create(current, rsdp); |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 630 | } |
Rocky Phagura | d4db36e | 2021-04-03 08:49:32 -0700 | [diff] [blame] | 631 | |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 632 | return current; |
| 633 | } |