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> |
| 4 | #include <assert.h> |
| 5 | #include <cbmem.h> |
| 6 | #include <device/mmio.h> |
| 7 | #include <device/pci.h> |
| 8 | #include <intelblocks/acpi.h> |
| 9 | #include <soc/acpi.h> |
| 10 | #include <soc/cpu.h> |
| 11 | #include <soc/iomap.h> |
| 12 | #include <soc/pci_devs.h> |
| 13 | #include <soc/soc_util.h> |
| 14 | |
| 15 | #include "chip.h" |
| 16 | |
| 17 | /* Northbridge(NUMA) ACPI table generation. SRAT, SLIT, etc */ |
| 18 | |
| 19 | unsigned long acpi_create_srat_lapics(unsigned long current) |
| 20 | { |
| 21 | struct device *cpu; |
| 22 | unsigned int cpu_index = 0; |
| 23 | |
| 24 | for (cpu = all_devices; cpu; cpu = cpu->next) { |
| 25 | if ((cpu->path.type != DEVICE_PATH_APIC) || |
| 26 | (cpu->bus->dev->path.type != DEVICE_PATH_CPU_CLUSTER)) { |
| 27 | continue; |
| 28 | } |
| 29 | if (!cpu->enabled) |
| 30 | continue; |
| 31 | printk(BIOS_DEBUG, "SRAT: lapic cpu_index=%02x, node_id=%02x, apic_id=%02x\n", |
| 32 | cpu_index, cpu->path.apic.node_id, cpu->path.apic.apic_id); |
| 33 | current += acpi_create_srat_lapic((acpi_srat_lapic_t *)current, |
| 34 | cpu->path.apic.node_id, cpu->path.apic.apic_id); |
| 35 | cpu_index++; |
| 36 | } |
| 37 | return current; |
| 38 | } |
| 39 | |
| 40 | static unsigned int get_srat_memory_entries(acpi_srat_mem_t *srat_mem) |
| 41 | { |
| 42 | const struct SystemMemoryMapHob *memory_map; |
| 43 | unsigned int mmap_index; |
| 44 | |
| 45 | memory_map = get_system_memory_map(); |
| 46 | assert(memory_map != NULL); |
| 47 | printk(BIOS_DEBUG, "memory_map: %p\n", memory_map); |
| 48 | |
| 49 | mmap_index = 0; |
| 50 | for (int e = 0; e < memory_map->numberEntries; ++e) { |
| 51 | const struct SystemMemoryMapElement *mem_element = &memory_map->Element[e]; |
| 52 | uint64_t addr = |
| 53 | (uint64_t) ((uint64_t)mem_element->BaseAddress << |
| 54 | MEM_ADDR_64MB_SHIFT_BITS); |
| 55 | uint64_t size = |
| 56 | (uint64_t) ((uint64_t)mem_element->ElementSize << |
| 57 | MEM_ADDR_64MB_SHIFT_BITS); |
| 58 | |
| 59 | printk(BIOS_DEBUG, "memory_map %d addr: 0x%llx, BaseAddress: 0x%x, size: 0x%llx, " |
| 60 | "ElementSize: 0x%x, reserved: %d\n", |
| 61 | e, addr, mem_element->BaseAddress, size, |
| 62 | mem_element->ElementSize, (mem_element->Type & MEM_TYPE_RESERVED)); |
| 63 | |
| 64 | assert(mmap_index < MAX_ACPI_MEMORY_AFFINITY_COUNT); |
| 65 | |
| 66 | /* skip reserved memory region */ |
| 67 | if (mem_element->Type & MEM_TYPE_RESERVED) |
| 68 | continue; |
| 69 | |
| 70 | /* skip if this address is already added */ |
| 71 | bool skip = false; |
| 72 | for (int idx = 0; idx < mmap_index; ++idx) { |
| 73 | uint64_t base_addr = ((uint64_t)srat_mem[idx].base_address_high << 32) + |
| 74 | srat_mem[idx].base_address_low; |
| 75 | if (addr == base_addr) { |
| 76 | skip = true; |
| 77 | break; |
| 78 | } |
| 79 | } |
| 80 | if (skip) |
| 81 | continue; |
| 82 | |
| 83 | srat_mem[mmap_index].type = 1; /* Memory affinity structure */ |
| 84 | srat_mem[mmap_index].length = sizeof(acpi_srat_mem_t); |
| 85 | srat_mem[mmap_index].base_address_low = (uint32_t) (addr & 0xffffffff); |
| 86 | srat_mem[mmap_index].base_address_high = (uint32_t) (addr >> 32); |
| 87 | srat_mem[mmap_index].length_low = (uint32_t) (size & 0xffffffff); |
| 88 | srat_mem[mmap_index].length_high = (uint32_t) (size >> 32); |
| 89 | srat_mem[mmap_index].proximity_domain = mem_element->SocketId; |
| 90 | srat_mem[mmap_index].flags = SRAT_ACPI_MEMORY_ENABLED; |
| 91 | if ((mem_element->Type & MEMTYPE_VOLATILE_MASK) == 0) |
| 92 | srat_mem[mmap_index].flags |= SRAT_ACPI_MEMORY_NONVOLATILE; |
| 93 | ++mmap_index; |
| 94 | } |
| 95 | |
| 96 | return mmap_index; |
| 97 | } |
| 98 | |
| 99 | static unsigned long acpi_fill_srat(unsigned long current) |
| 100 | { |
| 101 | acpi_srat_mem_t srat_mem[MAX_ACPI_MEMORY_AFFINITY_COUNT]; |
| 102 | unsigned int mem_count; |
| 103 | |
| 104 | /* create all subtables for processors */ |
| 105 | current = acpi_create_srat_lapics(current); |
| 106 | |
| 107 | mem_count = get_srat_memory_entries(srat_mem); |
| 108 | for (int i = 0; i < mem_count; ++i) { |
| 109 | printk(BIOS_DEBUG, "adding srat memory %d entry length: %d, addr: 0x%x%x, " |
| 110 | "length: 0x%x%x, proximity_domain: %d, flags: %x\n", |
| 111 | i, srat_mem[i].length, |
| 112 | srat_mem[i].base_address_high, srat_mem[i].base_address_low, |
| 113 | srat_mem[i].length_high, srat_mem[i].length_low, |
| 114 | srat_mem[i].proximity_domain, srat_mem[i].flags); |
| 115 | memcpy((acpi_srat_mem_t *)current, &srat_mem[i], sizeof(srat_mem[i])); |
| 116 | current += srat_mem[i].length; |
| 117 | } |
| 118 | |
| 119 | return current; |
| 120 | } |
| 121 | |
| 122 | static unsigned long acpi_fill_slit(unsigned long current) |
| 123 | { |
Marc Jones | 70907b0 | 2020-10-28 17:00:31 -0600 | [diff] [blame] | 124 | unsigned int nodes = soc_get_num_cpus(); |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 125 | |
| 126 | uint8_t *p = (uint8_t *)current; |
| 127 | memset(p, 0, 8 + nodes * nodes); |
| 128 | *p = (uint8_t)nodes; |
| 129 | p += 8; |
| 130 | |
| 131 | /* this assumes fully connected socket topology */ |
| 132 | for (int i = 0; i < nodes; i++) { |
| 133 | for (int j = 0; j < nodes; j++) { |
| 134 | if (i == j) |
| 135 | p[i*nodes+j] = 10; |
| 136 | else |
| 137 | p[i*nodes+j] = 16; |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | current += 8 + nodes * nodes; |
| 142 | return current; |
| 143 | } |
| 144 | |
| 145 | /* |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 146 | * This function adds PCIe bridge device entry in DMAR table. If it is called |
| 147 | * in the context of ATSR subtable, it adds ATSR subtable when it is first called. |
| 148 | */ |
| 149 | static unsigned long acpi_create_dmar_ds_pci_br_for_port(unsigned long current, |
Jacob Garber | 6df3870 | 2020-10-24 16:23:45 -0600 | [diff] [blame^] | 150 | int port, int stack, const IIO_RESOURCE_INSTANCE *iio_resource, uint32_t pcie_seg, |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 151 | bool is_atsr, bool *first) |
| 152 | { |
| 153 | |
Marc Jones | 995a7e2 | 2020-10-28 17:08:54 -0600 | [diff] [blame] | 154 | if (soc_get_stack_for_port(port) != stack) |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 155 | return 0; |
| 156 | |
Jacob Garber | 6df3870 | 2020-10-24 16:23:45 -0600 | [diff] [blame^] | 157 | const uint32_t bus = iio_resource->StackRes[stack].BusBase; |
| 158 | const uint32_t dev = iio_resource->PcieInfo.PortInfo[port].Device; |
| 159 | const uint32_t func = iio_resource->PcieInfo.PortInfo[port].Function; |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 160 | |
| 161 | const uint32_t id = pci_mmio_read_config32(PCI_DEV(bus, dev, func), |
| 162 | PCI_VENDOR_ID); |
| 163 | if (id == 0xffffffff) |
| 164 | return 0; |
| 165 | |
| 166 | unsigned long atsr_size = 0; |
| 167 | unsigned long pci_br_size = 0; |
| 168 | if (is_atsr == true && first && *first == true) { |
| 169 | printk(BIOS_DEBUG, "[Root Port ATS Capability] Flags: 0x%x, " |
| 170 | "PCI Segment Number: 0x%x\n", 0, pcie_seg); |
| 171 | atsr_size = acpi_create_dmar_atsr(current, 0, pcie_seg); |
| 172 | *first = false; |
| 173 | } |
| 174 | |
| 175 | printk(BIOS_DEBUG, " [PCI Bridge Device] Enumeration ID: 0x%x, " |
| 176 | "PCI Bus Number: 0x%x, PCI Path: 0x%x, 0x%x\n", |
| 177 | 0, bus, dev, func); |
| 178 | pci_br_size = acpi_create_dmar_ds_pci_br(current + atsr_size, bus, dev, func); |
| 179 | |
| 180 | return (atsr_size + pci_br_size); |
| 181 | } |
| 182 | |
| 183 | static unsigned long acpi_create_drhd(unsigned long current, int socket, |
| 184 | int stack, const IIO_UDS *hob) |
| 185 | { |
| 186 | int IoApicID[] = { |
| 187 | // socket 0 |
| 188 | PC00_IOAPIC_ID, PC01_IOAPIC_ID, PC02_IOAPIC_ID, PC03_IOAPIC_ID, |
| 189 | PC04_IOAPIC_ID, PC05_IOAPIC_ID, |
| 190 | // socket 1 |
| 191 | PC06_IOAPIC_ID, PC07_IOAPIC_ID, PC08_IOAPIC_ID, PC09_IOAPIC_ID, |
| 192 | PC10_IOAPIC_ID, PC11_IOAPIC_ID, |
| 193 | }; |
| 194 | |
| 195 | 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 | |
| 209 | // 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 | |
| 222 | // Add PCH IOAPIC |
| 223 | if (socket == 0 && stack == CSTACK) { |
| 224 | printk(BIOS_DEBUG, " [IOAPIC Device] Enumeration ID: 0x%x, PCI Bus Number: 0x%x, " |
| 225 | "PCI Path: 0x%x, 0x%x\n", |
| 226 | PCH_IOAPIC_ID, PCH_IOAPIC_BUS_NUMBER, |
| 227 | PCH_IOAPIC_DEV_NUM, PCH_IOAPIC_FUNC_NUM); |
| 228 | current += acpi_create_dmar_ds_ioapic(current, PCH_IOAPIC_ID, |
| 229 | PCH_IOAPIC_BUS_NUMBER, PCH_IOAPIC_DEV_NUM, PCH_IOAPIC_FUNC_NUM); |
| 230 | } |
| 231 | |
| 232 | // Add IOAPIC entry |
| 233 | enum_id = IoApicID[(socket*MAX_IIO_STACK)+stack]; |
| 234 | 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 Garber | 6df3870 | 2020-10-24 16:23:45 -0600 | [diff] [blame^] | 256 | &iio_resource, pcie_seg, false, NULL); |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 257 | |
| 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) { |
| 271 | uint16_t hpet_capid = read16((void *)HPET_BASE_ADDRESS); |
| 272 | 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) && |
| 277 | (read32((void *)(HPET_BASE_ADDRESS + 0x100)) & (0x00008000))) { |
| 278 | printk(BIOS_DEBUG, " [Message-capable HPET Device] Enumeration ID: 0x%x, " |
| 279 | "PCI Bus Number: 0x%x, PCI Path: 0x%x, 0x%x\n", |
| 280 | 0, HPET_BUS_NUM, HPET_DEV_NUM, HPET0_FUNC_NUM); |
| 281 | current += acpi_create_dmar_ds_msi_hpet(current, 0, HPET_BUS_NUM, |
| 282 | HPET_DEV_NUM, HPET0_FUNC_NUM); |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | acpi_dmar_drhd_fixup(tmp, current); |
| 287 | |
| 288 | return current; |
| 289 | } |
| 290 | |
| 291 | static unsigned long acpi_create_atsr(unsigned long current, const IIO_UDS *hob) |
| 292 | { |
| 293 | for (int socket = 0; socket < hob->PlatformData.numofIIO; ++socket) { |
| 294 | uint32_t pcie_seg = hob->PlatformData.CpuQpiInfo[socket].PcieSegment; |
| 295 | unsigned long tmp = current; |
| 296 | bool first = true; |
| 297 | IIO_RESOURCE_INSTANCE iio_resource = |
| 298 | hob->PlatformData.IIO_resource[socket]; |
| 299 | |
| 300 | for (int stack = 0; stack <= PSTACK2; ++stack) { |
| 301 | uint32_t bus = iio_resource.StackRes[stack].BusBase; |
| 302 | uint32_t vtd_base = iio_resource.StackRes[stack].VtdBarAddress; |
| 303 | if (!vtd_base) |
| 304 | continue; |
| 305 | uint64_t vtd_mmio_cap = read64((void *)(vtd_base + VTD_EXT_CAP_LOW)); |
| 306 | printk(BIOS_SPEW, "%s socket: %d, stack: %d, bus: 0x%x, vtd_base: 0x%x, " |
| 307 | "vtd_mmio_cap: 0x%llx\n", |
| 308 | __func__, socket, stack, bus, vtd_base, vtd_mmio_cap); |
| 309 | |
| 310 | // ATSR is applicable only for platform supporting device IOTLBs |
| 311 | // through the VT-d extended capability register |
| 312 | assert(vtd_mmio_cap != 0xffffffffffffffff); |
| 313 | if ((vtd_mmio_cap & 0x4) == 0) // BIT 2 |
| 314 | continue; |
| 315 | |
| 316 | for (int p = PORT_0; p < MAX_PORTS; ++p) { |
| 317 | if (socket == 0 && p == PORT_0) |
| 318 | continue; |
| 319 | current += acpi_create_dmar_ds_pci_br_for_port(current, p, |
Jacob Garber | 6df3870 | 2020-10-24 16:23:45 -0600 | [diff] [blame^] | 320 | stack, &iio_resource, pcie_seg, true, &first); |
Marc Jones | 97321db | 2020-09-28 23:35:08 -0600 | [diff] [blame] | 321 | } |
| 322 | } |
| 323 | if (tmp != current) |
| 324 | acpi_dmar_atsr_fixup(tmp, current); |
| 325 | } |
| 326 | |
| 327 | return current; |
| 328 | } |
| 329 | |
| 330 | static unsigned long acpi_create_rmrr(unsigned long current) |
| 331 | { |
| 332 | uint32_t size = ALIGN_UP(MEM_BLK_COUNT * sizeof(MEM_BLK), 0x1000); |
| 333 | |
| 334 | uint32_t *ptr; |
| 335 | |
| 336 | // reserve memory |
| 337 | ptr = cbmem_find(CBMEM_ID_STORAGE_DATA); |
| 338 | if (!ptr) { |
| 339 | ptr = cbmem_add(CBMEM_ID_STORAGE_DATA, size); |
| 340 | assert(ptr != NULL); |
| 341 | memset(ptr, 0, size); |
| 342 | } |
| 343 | |
| 344 | unsigned long tmp = current; |
| 345 | printk(BIOS_DEBUG, "[Reserved Memory Region] PCI Segment Number: 0x%x, Base Address: 0x%x, " |
| 346 | "End Address (limit): 0x%x\n", |
| 347 | 0, (uint32_t) ptr, (uint32_t) ((uint32_t) ptr + size - 1)); |
| 348 | current += acpi_create_dmar_rmrr(current, 0, (uint32_t) ptr, |
| 349 | (uint32_t) ((uint32_t) ptr + size - 1)); |
| 350 | |
| 351 | printk(BIOS_DEBUG, " [PCI Endpoint Device] Enumeration ID: 0x%x, PCI Bus Number: 0x%x, " |
| 352 | "PCI Path: 0x%x, 0x%x\n", |
| 353 | 0, XHCI_BUS_NUMBER, PCH_DEV_SLOT_XHCI, XHCI_FUNC_NUM); |
| 354 | current += acpi_create_dmar_ds_pci(current, XHCI_BUS_NUMBER, |
| 355 | PCH_DEV_SLOT_XHCI, XHCI_FUNC_NUM); |
| 356 | |
| 357 | acpi_dmar_rmrr_fixup(tmp, current); |
| 358 | |
| 359 | return current; |
| 360 | } |
| 361 | |
| 362 | static unsigned long acpi_create_rhsa(unsigned long current) |
| 363 | { |
| 364 | size_t hob_size; |
| 365 | const uint8_t uds_guid[16] = FSP_HOB_IIO_UNIVERSAL_DATA_GUID; |
| 366 | const IIO_UDS *hob = fsp_find_extension_hob_by_guid(uds_guid, &hob_size); |
| 367 | assert(hob != NULL && hob_size != 0); |
| 368 | |
| 369 | for (int socket = 0; socket < hob->PlatformData.numofIIO; ++socket) { |
| 370 | IIO_RESOURCE_INSTANCE iio_resource = |
| 371 | hob->PlatformData.IIO_resource[socket]; |
| 372 | for (int stack = 0; stack <= PSTACK2; ++stack) { |
| 373 | uint32_t vtd_base = iio_resource.StackRes[stack].VtdBarAddress; |
| 374 | if (!vtd_base) |
| 375 | continue; |
| 376 | |
| 377 | printk(BIOS_DEBUG, "[Remapping Hardware Static Affinity] Base Address: 0x%x, " |
| 378 | "Proximity Domain: 0x%x\n", vtd_base, socket); |
| 379 | current += acpi_create_dmar_rhsa(current, vtd_base, socket); |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | return current; |
| 384 | } |
| 385 | |
| 386 | static unsigned long acpi_fill_dmar(unsigned long current) |
| 387 | { |
| 388 | size_t hob_size; |
| 389 | const uint8_t uds_guid[16] = FSP_HOB_IIO_UNIVERSAL_DATA_GUID; |
| 390 | const IIO_UDS *hob = fsp_find_extension_hob_by_guid(uds_guid, &hob_size); |
| 391 | assert(hob != NULL && hob_size != 0); |
| 392 | |
| 393 | // DRHD |
| 394 | for (int iio = 1; iio <= hob->PlatformData.numofIIO; ++iio) { |
| 395 | int socket = iio; |
| 396 | if (socket == hob->PlatformData.numofIIO) // socket 0 should be last DRHD entry |
| 397 | socket = 0; |
| 398 | |
| 399 | if (socket == 0) { |
| 400 | for (int stack = 1; stack <= PSTACK2; ++stack) |
| 401 | current = acpi_create_drhd(current, socket, stack, hob); |
| 402 | current = acpi_create_drhd(current, socket, CSTACK, hob); |
| 403 | } else { |
| 404 | for (int stack = 0; stack <= PSTACK2; ++stack) |
| 405 | current = acpi_create_drhd(current, socket, stack, hob); |
| 406 | } |
| 407 | } |
| 408 | |
| 409 | // RMRR |
| 410 | current = acpi_create_rmrr(current); |
| 411 | |
| 412 | // Root Port ATS Capability |
| 413 | current = acpi_create_atsr(current, hob); |
| 414 | |
| 415 | // RHSA |
| 416 | current = acpi_create_rhsa(current); |
| 417 | |
| 418 | return current; |
| 419 | } |
| 420 | |
| 421 | unsigned long northbridge_write_acpi_tables(const struct device *device, |
| 422 | unsigned long current, |
| 423 | struct acpi_rsdp *rsdp) |
| 424 | { |
| 425 | acpi_srat_t *srat; |
| 426 | acpi_slit_t *slit; |
| 427 | acpi_dmar_t *dmar; |
| 428 | |
| 429 | const config_t *const config = config_of(device); |
| 430 | |
| 431 | /* SRAT */ |
| 432 | current = ALIGN(current, 8); |
| 433 | printk(BIOS_DEBUG, "ACPI: * SRAT at %lx\n", current); |
| 434 | srat = (acpi_srat_t *) current; |
| 435 | acpi_create_srat(srat, acpi_fill_srat); |
| 436 | current += srat->header.length; |
| 437 | acpi_add_table(rsdp, srat); |
| 438 | |
| 439 | /* SLIT */ |
| 440 | current = ALIGN(current, 8); |
| 441 | printk(BIOS_DEBUG, "ACPI: * SLIT at %lx\n", current); |
| 442 | slit = (acpi_slit_t *) current; |
| 443 | acpi_create_slit(slit, acpi_fill_slit); |
| 444 | current += slit->header.length; |
| 445 | acpi_add_table(rsdp, slit); |
| 446 | |
| 447 | /* DMAR */ |
| 448 | if (config->vtd_support) { |
| 449 | current = ALIGN(current, 8); |
| 450 | dmar = (acpi_dmar_t *)current; |
| 451 | printk(BIOS_DEBUG, "ACPI: * DMAR\n"); |
| 452 | printk(BIOS_DEBUG, "[DMA Remapping table] Flags: 0x%x\n", DMAR_INTR_REMAP); |
| 453 | acpi_create_dmar(dmar, DMAR_INTR_REMAP, acpi_fill_dmar); |
| 454 | current += dmar->header.length; |
| 455 | current = acpi_align_current(current); |
| 456 | acpi_add_table(rsdp, dmar); |
| 457 | } |
| 458 | |
| 459 | return current; |
| 460 | } |