blob: 89deb886656883e4f1d80d50738dc63a53ef5dde [file] [log] [blame]
Marc Jones97321db2020-09-28 23:35:08 -06001/* SPDX-License-Identifier: GPL-2.0-or-later */
2
3#include <acpi/acpigen.h>
Felix Held4b2464f2022-02-23 17:54:20 +01004#include <arch/hpet.h>
Marc Jones97321db2020-09-28 23:35:08 -06005#include <assert.h>
6#include <cbmem.h>
Naresh Solanki559f9ed2023-01-20 19:38:07 +01007#include <cpu/x86/lapic.h>
Marc Jones97321db2020-09-28 23:35:08 -06008#include <device/mmio.h>
9#include <device/pci.h>
Marc Jones97321db2020-09-28 23:35:08 -060010#include <soc/acpi.h>
Rocky Phagurad4db36e2021-04-03 08:49:32 -070011#include <soc/hest.h>
Marc Jones97321db2020-09-28 23:35:08 -060012#include <soc/iomap.h>
13#include <soc/pci_devs.h>
14#include <soc/soc_util.h>
Marc Jones18960ce2020-11-02 12:41:12 -070015#include <soc/util.h>
Arthur Heymans695dd292020-11-12 21:05:09 +010016#include <intelblocks/p2sb.h>
Marc Jones97321db2020-09-28 23:35:08 -060017
18#include "chip.h"
19
20/* Northbridge(NUMA) ACPI table generation. SRAT, SLIT, etc */
21
22unsigned long acpi_create_srat_lapics(unsigned long current)
23{
24 struct device *cpu;
25 unsigned int cpu_index = 0;
26
27 for (cpu = all_devices; cpu; cpu = cpu->next) {
Fabio Aiuto45aae7f2022-09-23 16:51:34 +020028 if (!is_enabled_cpu(cpu))
Marc Jones97321db2020-09-28 23:35:08 -060029 continue;
Naresh Solanki559f9ed2023-01-20 19:38:07 +010030
31 if (is_x2apic_mode()) {
32 printk(BIOS_DEBUG, "SRAT: x2apic cpu_index=%08x, node_id=%02x, apic_id=%08x\n",
33 cpu_index, cpu->path.apic.node_id, cpu->path.apic.apic_id);
34
35 current += acpi_create_srat_x2apic((acpi_srat_x2apic_t *)current,
36 cpu->path.apic.node_id, cpu->path.apic.apic_id);
37 } else {
38 printk(BIOS_DEBUG, "SRAT: lapic cpu_index=%02x, node_id=%02x, apic_id=%02x\n",
39 cpu_index, cpu->path.apic.node_id, cpu->path.apic.apic_id);
40
41 current += acpi_create_srat_lapic((acpi_srat_lapic_t *)current,
42 cpu->path.apic.node_id, cpu->path.apic.apic_id);
43 }
Marc Jones97321db2020-09-28 23:35:08 -060044 cpu_index++;
45 }
46 return current;
47}
48
49static unsigned int get_srat_memory_entries(acpi_srat_mem_t *srat_mem)
50{
51 const struct SystemMemoryMapHob *memory_map;
52 unsigned int mmap_index;
53
54 memory_map = get_system_memory_map();
Elyes Haouasf1ba7d62022-09-13 10:03:44 +020055 assert(memory_map);
Marc Jones97321db2020-09-28 23:35:08 -060056 printk(BIOS_DEBUG, "memory_map: %p\n", memory_map);
57
58 mmap_index = 0;
59 for (int e = 0; e < memory_map->numberEntries; ++e) {
60 const struct SystemMemoryMapElement *mem_element = &memory_map->Element[e];
61 uint64_t addr =
Elyes Haouas9018dee2022-11-18 15:07:33 +010062 (uint64_t)((uint64_t)mem_element->BaseAddress <<
Marc Jones97321db2020-09-28 23:35:08 -060063 MEM_ADDR_64MB_SHIFT_BITS);
64 uint64_t size =
Elyes Haouas9018dee2022-11-18 15:07:33 +010065 (uint64_t)((uint64_t)mem_element->ElementSize <<
Marc Jones97321db2020-09-28 23:35:08 -060066 MEM_ADDR_64MB_SHIFT_BITS);
67
68 printk(BIOS_DEBUG, "memory_map %d addr: 0x%llx, BaseAddress: 0x%x, size: 0x%llx, "
69 "ElementSize: 0x%x, reserved: %d\n",
70 e, addr, mem_element->BaseAddress, size,
71 mem_element->ElementSize, (mem_element->Type & MEM_TYPE_RESERVED));
72
73 assert(mmap_index < MAX_ACPI_MEMORY_AFFINITY_COUNT);
74
75 /* skip reserved memory region */
76 if (mem_element->Type & MEM_TYPE_RESERVED)
77 continue;
78
79 /* skip if this address is already added */
80 bool skip = false;
81 for (int idx = 0; idx < mmap_index; ++idx) {
82 uint64_t base_addr = ((uint64_t)srat_mem[idx].base_address_high << 32) +
83 srat_mem[idx].base_address_low;
84 if (addr == base_addr) {
85 skip = true;
86 break;
87 }
88 }
89 if (skip)
90 continue;
91
92 srat_mem[mmap_index].type = 1; /* Memory affinity structure */
93 srat_mem[mmap_index].length = sizeof(acpi_srat_mem_t);
Elyes Haouas9018dee2022-11-18 15:07:33 +010094 srat_mem[mmap_index].base_address_low = (uint32_t)(addr & 0xffffffff);
95 srat_mem[mmap_index].base_address_high = (uint32_t)(addr >> 32);
96 srat_mem[mmap_index].length_low = (uint32_t)(size & 0xffffffff);
97 srat_mem[mmap_index].length_high = (uint32_t)(size >> 32);
Marc Jones97321db2020-09-28 23:35:08 -060098 srat_mem[mmap_index].proximity_domain = mem_element->SocketId;
99 srat_mem[mmap_index].flags = SRAT_ACPI_MEMORY_ENABLED;
100 if ((mem_element->Type & MEMTYPE_VOLATILE_MASK) == 0)
101 srat_mem[mmap_index].flags |= SRAT_ACPI_MEMORY_NONVOLATILE;
102 ++mmap_index;
103 }
104
105 return mmap_index;
106}
107
108static unsigned long acpi_fill_srat(unsigned long current)
109{
110 acpi_srat_mem_t srat_mem[MAX_ACPI_MEMORY_AFFINITY_COUNT];
111 unsigned int mem_count;
112
113 /* create all subtables for processors */
114 current = acpi_create_srat_lapics(current);
115
116 mem_count = get_srat_memory_entries(srat_mem);
117 for (int i = 0; i < mem_count; ++i) {
118 printk(BIOS_DEBUG, "adding srat memory %d entry length: %d, addr: 0x%x%x, "
119 "length: 0x%x%x, proximity_domain: %d, flags: %x\n",
120 i, srat_mem[i].length,
121 srat_mem[i].base_address_high, srat_mem[i].base_address_low,
122 srat_mem[i].length_high, srat_mem[i].length_low,
123 srat_mem[i].proximity_domain, srat_mem[i].flags);
124 memcpy((acpi_srat_mem_t *)current, &srat_mem[i], sizeof(srat_mem[i]));
125 current += srat_mem[i].length;
126 }
127
128 return current;
129}
130
131static unsigned long acpi_fill_slit(unsigned long current)
132{
Marc Jones70907b02020-10-28 17:00:31 -0600133 unsigned int nodes = soc_get_num_cpus();
Marc Jones97321db2020-09-28 23:35:08 -0600134
135 uint8_t *p = (uint8_t *)current;
136 memset(p, 0, 8 + nodes * nodes);
137 *p = (uint8_t)nodes;
138 p += 8;
139
140 /* this assumes fully connected socket topology */
141 for (int i = 0; i < nodes; i++) {
142 for (int j = 0; j < nodes; j++) {
143 if (i == j)
144 p[i*nodes+j] = 10;
145 else
146 p[i*nodes+j] = 16;
147 }
148 }
149
150 current += 8 + nodes * nodes;
151 return current;
152}
153
154/*
Marc Jones97321db2020-09-28 23:35:08 -0600155 * This function adds PCIe bridge device entry in DMAR table. If it is called
156 * in the context of ATSR subtable, it adds ATSR subtable when it is first called.
157 */
158static unsigned long acpi_create_dmar_ds_pci_br_for_port(unsigned long current,
Jacob Garber6df38702020-10-24 16:23:45 -0600159 int port, int stack, const IIO_RESOURCE_INSTANCE *iio_resource, uint32_t pcie_seg,
Marc Jones97321db2020-09-28 23:35:08 -0600160 bool is_atsr, bool *first)
161{
162
Marc Jones995a7e22020-10-28 17:08:54 -0600163 if (soc_get_stack_for_port(port) != stack)
Marc Jones97321db2020-09-28 23:35:08 -0600164 return 0;
165
Jacob Garber6df38702020-10-24 16:23:45 -0600166 const uint32_t bus = iio_resource->StackRes[stack].BusBase;
167 const uint32_t dev = iio_resource->PcieInfo.PortInfo[port].Device;
168 const uint32_t func = iio_resource->PcieInfo.PortInfo[port].Function;
Marc Jones97321db2020-09-28 23:35:08 -0600169
Nico Huberf4f365f2021-10-14 18:16:39 +0200170 const uint32_t id = pci_s_read_config32(PCI_DEV(bus, dev, func),
Marc Jones97321db2020-09-28 23:35:08 -0600171 PCI_VENDOR_ID);
172 if (id == 0xffffffff)
173 return 0;
174
175 unsigned long atsr_size = 0;
176 unsigned long pci_br_size = 0;
Elyes HAOUASfa999822022-01-27 14:27:05 +0100177 if (is_atsr && first && *first) {
Marc Jones97321db2020-09-28 23:35:08 -0600178 printk(BIOS_DEBUG, "[Root Port ATS Capability] Flags: 0x%x, "
179 "PCI Segment Number: 0x%x\n", 0, pcie_seg);
180 atsr_size = acpi_create_dmar_atsr(current, 0, pcie_seg);
181 *first = false;
182 }
183
184 printk(BIOS_DEBUG, " [PCI Bridge Device] Enumeration ID: 0x%x, "
185 "PCI Bus Number: 0x%x, PCI Path: 0x%x, 0x%x\n",
186 0, bus, dev, func);
187 pci_br_size = acpi_create_dmar_ds_pci_br(current + atsr_size, bus, dev, func);
188
189 return (atsr_size + pci_br_size);
190}
191
192static unsigned long acpi_create_drhd(unsigned long current, int socket,
193 int stack, const IIO_UDS *hob)
194{
Marc Jones97321db2020-09-28 23:35:08 -0600195 uint32_t enum_id;
196 unsigned long tmp = current;
197
198 uint32_t bus = hob->PlatformData.IIO_resource[socket].StackRes[stack].BusBase;
199 uint32_t pcie_seg = hob->PlatformData.CpuQpiInfo[socket].PcieSegment;
200 uint32_t reg_base =
201 hob->PlatformData.IIO_resource[socket].StackRes[stack].VtdBarAddress;
202 printk(BIOS_SPEW, "%s socket: %d, stack: %d, bus: 0x%x, pcie_seg: 0x%x, reg_base: 0x%x\n",
203 __func__, socket, stack, bus, pcie_seg, reg_base);
204
205 /* Do not generate DRHD for non-PCIe stack */
206 if (!reg_base)
207 return current;
208
Arthur Heymansa1c4ad32021-05-04 18:40:28 +0200209 // Add DRHD Hardware Unit
210 if (socket == 0 && stack == CSTACK) {
211 printk(BIOS_DEBUG, "[Hardware Unit Definition] Flags: 0x%x, PCI Segment Number: 0x%x, "
212 "Register Base Address: 0x%x\n",
213 DRHD_INCLUDE_PCI_ALL, pcie_seg, reg_base);
214 current += acpi_create_dmar_drhd(current, DRHD_INCLUDE_PCI_ALL,
215 pcie_seg, reg_base);
216 } else {
217 printk(BIOS_DEBUG, "[Hardware Unit Definition] Flags: 0x%x, PCI Segment Number: 0x%x, "
218 "Register Base Address: 0x%x\n", 0, pcie_seg, reg_base);
219 current += acpi_create_dmar_drhd(current, 0, pcie_seg, reg_base);
220 }
221
Marc Jones97321db2020-09-28 23:35:08 -0600222 // Add PCH IOAPIC
223 if (socket == 0 && stack == CSTACK) {
Arthur Heymans6e425e12020-11-12 21:12:05 +0100224 union p2sb_bdf ioapic_bdf = p2sb_get_ioapic_bdf();
Marc Jones97321db2020-09-28 23:35:08 -0600225 printk(BIOS_DEBUG, " [IOAPIC Device] Enumeration ID: 0x%x, PCI Bus Number: 0x%x, "
226 "PCI Path: 0x%x, 0x%x\n",
Arthur Heymans6e425e12020-11-12 21:12:05 +0100227 PCH_IOAPIC_ID, ioapic_bdf.bus, ioapic_bdf.dev, ioapic_bdf.fn);
Marc Jones97321db2020-09-28 23:35:08 -0600228 current += acpi_create_dmar_ds_ioapic(current, PCH_IOAPIC_ID,
Arthur Heymans6e425e12020-11-12 21:12:05 +0100229 ioapic_bdf.bus, ioapic_bdf.dev, ioapic_bdf.fn);
Marc Jones97321db2020-09-28 23:35:08 -0600230 }
231
232 // Add IOAPIC entry
Arthur Heymansa1cc5572020-11-06 12:53:33 +0100233 enum_id = soc_get_iio_ioapicid(socket, stack);
Marc Jones97321db2020-09-28 23:35:08 -0600234 printk(BIOS_DEBUG, " [IOAPIC Device] Enumeration ID: 0x%x, PCI Bus Number: 0x%x, "
235 "PCI Path: 0x%x, 0x%x\n", enum_id, bus, APIC_DEV_NUM, APIC_FUNC_NUM);
236 current += acpi_create_dmar_ds_ioapic(current, enum_id, bus,
237 APIC_DEV_NUM, APIC_FUNC_NUM);
238
239 // Add CBDMA devices for CSTACK
240 if (socket != 0 && stack == CSTACK) {
241 for (int cbdma_func_id = 0; cbdma_func_id < 8; ++cbdma_func_id) {
242 printk(BIOS_DEBUG, " [PCI Endpoint Device] Enumeration ID: 0x%x, "
243 "PCI Bus Number: 0x%x, PCI Path: 0x%x, 0x%x\n",
244 0, bus, CBDMA_DEV_NUM, cbdma_func_id);
245 current += acpi_create_dmar_ds_pci(current,
246 bus, CBDMA_DEV_NUM, cbdma_func_id);
247 }
248 }
249
250 // Add PCIe Ports
251 if (socket != 0 || stack != CSTACK) {
252 IIO_RESOURCE_INSTANCE iio_resource =
253 hob->PlatformData.IIO_resource[socket];
254 for (int p = PORT_0; p < MAX_PORTS; ++p)
255 current += acpi_create_dmar_ds_pci_br_for_port(current, p, stack,
Jacob Garber6df38702020-10-24 16:23:45 -0600256 &iio_resource, pcie_seg, false, NULL);
Marc Jones97321db2020-09-28 23:35:08 -0600257
258 // Add VMD
259 if (hob->PlatformData.VMDStackEnable[socket][stack] &&
260 stack >= PSTACK0 && stack <= PSTACK2) {
261 printk(BIOS_DEBUG, " [PCI Endpoint Device] Enumeration ID: 0x%x, "
262 "PCI Bus Number: 0x%x, PCI Path: 0x%x, 0x%x\n",
263 0, bus, VMD_DEV_NUM, VMD_FUNC_NUM);
264 current += acpi_create_dmar_ds_pci(current,
265 bus, VMD_DEV_NUM, VMD_FUNC_NUM);
266 }
267 }
268
269 // Add HPET
270 if (socket == 0 && stack == CSTACK) {
Elyes Haouas167b7fcd2022-12-11 10:38:35 +0100271 uint16_t hpet_capid = read16p(HPET_BASE_ADDRESS);
Marc Jones97321db2020-09-28 23:35:08 -0600272 uint16_t num_hpets = (hpet_capid >> 0x08) & 0x1F; // Bits [8:12] has hpet count
273 printk(BIOS_SPEW, "%s hpet_capid: 0x%x, num_hpets: 0x%x\n",
274 __func__, hpet_capid, num_hpets);
275 //BIT 15
276 if (num_hpets && (num_hpets != 0x1f) &&
Elyes Haouas167b7fcd2022-12-11 10:38:35 +0100277 (read32p(HPET_BASE_ADDRESS + 0x100) & (0x00008000))) {
Arthur Heymans695dd292020-11-12 21:05:09 +0100278 union p2sb_bdf hpet_bdf = p2sb_get_hpet_bdf();
Marc Jones97321db2020-09-28 23:35:08 -0600279 printk(BIOS_DEBUG, " [Message-capable HPET Device] Enumeration ID: 0x%x, "
280 "PCI Bus Number: 0x%x, PCI Path: 0x%x, 0x%x\n",
Arthur Heymans695dd292020-11-12 21:05:09 +0100281 0, hpet_bdf.bus, hpet_bdf.dev, hpet_bdf.fn);
282 current += acpi_create_dmar_ds_msi_hpet(current, 0, hpet_bdf.bus,
283 hpet_bdf.dev, hpet_bdf.fn);
Marc Jones97321db2020-09-28 23:35:08 -0600284 }
285 }
286
287 acpi_dmar_drhd_fixup(tmp, current);
288
289 return current;
290}
291
292static unsigned long acpi_create_atsr(unsigned long current, const IIO_UDS *hob)
293{
294 for (int socket = 0; socket < hob->PlatformData.numofIIO; ++socket) {
295 uint32_t pcie_seg = hob->PlatformData.CpuQpiInfo[socket].PcieSegment;
296 unsigned long tmp = current;
297 bool first = true;
298 IIO_RESOURCE_INSTANCE iio_resource =
299 hob->PlatformData.IIO_resource[socket];
300
301 for (int stack = 0; stack <= PSTACK2; ++stack) {
302 uint32_t bus = iio_resource.StackRes[stack].BusBase;
303 uint32_t vtd_base = iio_resource.StackRes[stack].VtdBarAddress;
304 if (!vtd_base)
305 continue;
Elyes Haouas167b7fcd2022-12-11 10:38:35 +0100306 uint64_t vtd_mmio_cap = read64p(vtd_base + VTD_EXT_CAP_LOW);
Marc Jones97321db2020-09-28 23:35:08 -0600307 printk(BIOS_SPEW, "%s socket: %d, stack: %d, bus: 0x%x, vtd_base: 0x%x, "
308 "vtd_mmio_cap: 0x%llx\n",
309 __func__, socket, stack, bus, vtd_base, vtd_mmio_cap);
310
311 // ATSR is applicable only for platform supporting device IOTLBs
312 // through the VT-d extended capability register
313 assert(vtd_mmio_cap != 0xffffffffffffffff);
314 if ((vtd_mmio_cap & 0x4) == 0) // BIT 2
315 continue;
316
317 for (int p = PORT_0; p < MAX_PORTS; ++p) {
318 if (socket == 0 && p == PORT_0)
319 continue;
320 current += acpi_create_dmar_ds_pci_br_for_port(current, p,
Jacob Garber6df38702020-10-24 16:23:45 -0600321 stack, &iio_resource, pcie_seg, true, &first);
Marc Jones97321db2020-09-28 23:35:08 -0600322 }
323 }
324 if (tmp != current)
325 acpi_dmar_atsr_fixup(tmp, current);
326 }
327
328 return current;
329}
330
331static unsigned long acpi_create_rmrr(unsigned long current)
332{
333 uint32_t size = ALIGN_UP(MEM_BLK_COUNT * sizeof(MEM_BLK), 0x1000);
334
335 uint32_t *ptr;
336
337 // reserve memory
338 ptr = cbmem_find(CBMEM_ID_STORAGE_DATA);
339 if (!ptr) {
340 ptr = cbmem_add(CBMEM_ID_STORAGE_DATA, size);
Elyes Haouasf1ba7d62022-09-13 10:03:44 +0200341 assert(ptr);
Marc Jones97321db2020-09-28 23:35:08 -0600342 memset(ptr, 0, size);
343 }
344
345 unsigned long tmp = current;
346 printk(BIOS_DEBUG, "[Reserved Memory Region] PCI Segment Number: 0x%x, Base Address: 0x%x, "
347 "End Address (limit): 0x%x\n",
Elyes Haouas9018dee2022-11-18 15:07:33 +0100348 0, (uint32_t)ptr, (uint32_t)((uint32_t)ptr + size - 1));
349 current += acpi_create_dmar_rmrr(current, 0, (uint32_t)ptr,
350 (uint32_t)((uint32_t)ptr + size - 1));
Marc Jones97321db2020-09-28 23:35:08 -0600351
352 printk(BIOS_DEBUG, " [PCI Endpoint Device] Enumeration ID: 0x%x, PCI Bus Number: 0x%x, "
353 "PCI Path: 0x%x, 0x%x\n",
354 0, XHCI_BUS_NUMBER, PCH_DEV_SLOT_XHCI, XHCI_FUNC_NUM);
355 current += acpi_create_dmar_ds_pci(current, XHCI_BUS_NUMBER,
356 PCH_DEV_SLOT_XHCI, XHCI_FUNC_NUM);
357
358 acpi_dmar_rmrr_fixup(tmp, current);
359
360 return current;
361}
362
363static unsigned long acpi_create_rhsa(unsigned long current)
364{
Arthur Heymans83b26222020-11-06 11:50:55 +0100365 const IIO_UDS *hob = get_iio_uds();
Marc Jones97321db2020-09-28 23:35:08 -0600366
367 for (int socket = 0; socket < hob->PlatformData.numofIIO; ++socket) {
368 IIO_RESOURCE_INSTANCE iio_resource =
369 hob->PlatformData.IIO_resource[socket];
370 for (int stack = 0; stack <= PSTACK2; ++stack) {
371 uint32_t vtd_base = iio_resource.StackRes[stack].VtdBarAddress;
372 if (!vtd_base)
373 continue;
374
375 printk(BIOS_DEBUG, "[Remapping Hardware Static Affinity] Base Address: 0x%x, "
376 "Proximity Domain: 0x%x\n", vtd_base, socket);
377 current += acpi_create_dmar_rhsa(current, vtd_base, socket);
378 }
379 }
380
381 return current;
382}
383
384static unsigned long acpi_fill_dmar(unsigned long current)
385{
Arthur Heymans83b26222020-11-06 11:50:55 +0100386 const IIO_UDS *hob = get_iio_uds();
Marc Jones97321db2020-09-28 23:35:08 -0600387
388 // DRHD
389 for (int iio = 1; iio <= hob->PlatformData.numofIIO; ++iio) {
390 int socket = iio;
391 if (socket == hob->PlatformData.numofIIO) // socket 0 should be last DRHD entry
392 socket = 0;
393
394 if (socket == 0) {
395 for (int stack = 1; stack <= PSTACK2; ++stack)
396 current = acpi_create_drhd(current, socket, stack, hob);
397 current = acpi_create_drhd(current, socket, CSTACK, hob);
398 } else {
399 for (int stack = 0; stack <= PSTACK2; ++stack)
400 current = acpi_create_drhd(current, socket, stack, hob);
401 }
402 }
403
404 // RMRR
405 current = acpi_create_rmrr(current);
406
407 // Root Port ATS Capability
408 current = acpi_create_atsr(current, hob);
409
410 // RHSA
411 current = acpi_create_rhsa(current);
412
413 return current;
414}
415
416unsigned long northbridge_write_acpi_tables(const struct device *device,
417 unsigned long current,
418 struct acpi_rsdp *rsdp)
419{
420 acpi_srat_t *srat;
421 acpi_slit_t *slit;
422 acpi_dmar_t *dmar;
423
424 const config_t *const config = config_of(device);
425
426 /* SRAT */
Elyes Haouasd6b6b222022-10-10 12:34:21 +0200427 current = ALIGN_UP(current, 8);
Marc Jones97321db2020-09-28 23:35:08 -0600428 printk(BIOS_DEBUG, "ACPI: * SRAT at %lx\n", current);
Elyes Haouas9018dee2022-11-18 15:07:33 +0100429 srat = (acpi_srat_t *)current;
Marc Jones97321db2020-09-28 23:35:08 -0600430 acpi_create_srat(srat, acpi_fill_srat);
431 current += srat->header.length;
432 acpi_add_table(rsdp, srat);
433
434 /* SLIT */
Elyes Haouasd6b6b222022-10-10 12:34:21 +0200435 current = ALIGN_UP(current, 8);
Marc Jones97321db2020-09-28 23:35:08 -0600436 printk(BIOS_DEBUG, "ACPI: * SLIT at %lx\n", current);
Elyes Haouas9018dee2022-11-18 15:07:33 +0100437 slit = (acpi_slit_t *)current;
Marc Jones97321db2020-09-28 23:35:08 -0600438 acpi_create_slit(slit, acpi_fill_slit);
439 current += slit->header.length;
440 acpi_add_table(rsdp, slit);
441
442 /* DMAR */
443 if (config->vtd_support) {
Elyes Haouasd6b6b222022-10-10 12:34:21 +0200444 current = ALIGN_UP(current, 8);
Marc Jones97321db2020-09-28 23:35:08 -0600445 dmar = (acpi_dmar_t *)current;
Marc Jonesb7e591e2020-11-13 15:55:31 -0700446 enum dmar_flags flags = DMAR_INTR_REMAP;
447
448 /* SKX FSP doesn't support X2APIC, but CPX FSP does */
449 if (CONFIG(SOC_INTEL_SKYLAKE_SP))
450 flags |= DMAR_X2APIC_OPT_OUT;
451
Marc Jones97321db2020-09-28 23:35:08 -0600452 printk(BIOS_DEBUG, "ACPI: * DMAR\n");
Marc Jonesb7e591e2020-11-13 15:55:31 -0700453 printk(BIOS_DEBUG, "[DMA Remapping table] Flags: 0x%x\n", flags);
454 acpi_create_dmar(dmar, flags, acpi_fill_dmar);
Marc Jones97321db2020-09-28 23:35:08 -0600455 current += dmar->header.length;
456 current = acpi_align_current(current);
457 acpi_add_table(rsdp, dmar);
458 }
459
Rocky Phagurad4db36e2021-04-03 08:49:32 -0700460 if (CONFIG(SOC_ACPI_HEST))
461 current = hest_create(current, rsdp);
462
Marc Jones97321db2020-09-28 23:35:08 -0600463 return current;
464}