Patrick Georgi | 11f0079 | 2020-03-04 15:10:45 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 3 | /* |
Martin Roth | 20bbd81 | 2019-08-30 21:09:37 -0600 | [diff] [blame] | 4 | * coreboot ACPI Table support |
Stefan Reinauer | 777224c | 2005-01-19 14:06:41 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 7 | /* |
Stefan Reinauer | 777224c | 2005-01-19 14:06:41 +0000 | [diff] [blame] | 8 | * Each system port implementing ACPI has to provide two functions: |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 9 | * |
Stefan Reinauer | 777224c | 2005-01-19 14:06:41 +0000 | [diff] [blame] | 10 | * write_acpi_tables() |
| 11 | * acpi_dump_apics() |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 12 | * |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 13 | * See Kontron 986LCD-M port for a good example of an ACPI implementation |
| 14 | * in coreboot. |
Ronald G. Minnich | 02fa3b2 | 2004-10-06 17:33:54 +0000 | [diff] [blame] | 15 | */ |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 16 | |
| 17 | #include <console/console.h> |
| 18 | #include <string.h> |
| 19 | #include <arch/acpi.h> |
Martin Roth | a66df49 | 2016-09-06 10:22:34 -0600 | [diff] [blame] | 20 | #include <arch/acpi_ivrs.h> |
Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 21 | #include <arch/acpigen.h> |
Stefan Reinauer | 777224c | 2005-01-19 14:06:41 +0000 | [diff] [blame] | 22 | #include <device/pci.h> |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 23 | #include <cbmem.h> |
Elyes HAOUAS | e2d152c | 2019-06-21 07:06:50 +0200 | [diff] [blame] | 24 | #include <commonlib/helpers.h> |
Patrick Georgi | c8feedd | 2012-02-16 18:43:25 +0100 | [diff] [blame] | 25 | #include <cpu/x86/lapic_def.h> |
Duncan Laurie | 11290c4 | 2012-10-03 19:07:05 -0700 | [diff] [blame] | 26 | #include <cpu/cpu.h> |
Vladimir Serbinenko | 351fefc | 2014-10-26 20:42:08 +0100 | [diff] [blame] | 27 | #include <cbfs.h> |
Elyes HAOUAS | 26071aa | 2019-02-15 08:21:33 +0100 | [diff] [blame] | 28 | #include <version.h> |
Werner Zeh | db561e6 | 2019-02-19 13:39:56 +0100 | [diff] [blame] | 29 | #include <commonlib/sort.h> |
Ronald G. Minnich | 02fa3b2 | 2004-10-06 17:33:54 +0000 | [diff] [blame] | 30 | |
Patrick Rudolph | cfe08ff | 2019-09-10 15:40:47 +0200 | [diff] [blame] | 31 | static acpi_rsdp_t *valid_rsdp(acpi_rsdp_t *rsdp); |
| 32 | |
Ronald G. Minnich | 02fa3b2 | 2004-10-06 17:33:54 +0000 | [diff] [blame] | 33 | u8 acpi_checksum(u8 *table, u32 length) |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 34 | { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 35 | u8 ret = 0; |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 36 | while (length--) { |
| 37 | ret += *table; |
| 38 | table++; |
| 39 | } |
Stefan Reinauer | a7648c2 | 2004-01-29 17:31:34 +0000 | [diff] [blame] | 40 | return -ret; |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 41 | } |
| 42 | |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 43 | /** |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 44 | * Add an ACPI table to the RSDT (and XSDT) structure, recalculate length |
| 45 | * and checksum. |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 46 | */ |
Stefan Reinauer | b657a3c | 2009-07-21 21:38:33 +0000 | [diff] [blame] | 47 | void acpi_add_table(acpi_rsdp_t *rsdp, void *table) |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 48 | { |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 49 | int i, entries_num; |
Stefan Reinauer | b657a3c | 2009-07-21 21:38:33 +0000 | [diff] [blame] | 50 | acpi_rsdt_t *rsdt; |
| 51 | acpi_xsdt_t *xsdt = NULL; |
| 52 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 53 | /* The RSDT is mandatory... */ |
Stefan Reinauer | defee17 | 2015-06-18 01:11:19 -0700 | [diff] [blame] | 54 | rsdt = (acpi_rsdt_t *)(uintptr_t)rsdp->rsdt_address; |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 55 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 56 | /* ...while the XSDT is not. */ |
| 57 | if (rsdp->xsdt_address) |
Stefan Reinauer | defee17 | 2015-06-18 01:11:19 -0700 | [diff] [blame] | 58 | xsdt = (acpi_xsdt_t *)((uintptr_t)rsdp->xsdt_address); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 59 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 60 | /* This should always be MAX_ACPI_TABLES. */ |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 61 | entries_num = ARRAY_SIZE(rsdt->entry); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 62 | |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 63 | for (i = 0; i < entries_num; i++) { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 64 | if (rsdt->entry[i] == 0) |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 65 | break; |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 66 | } |
| 67 | |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 68 | if (i >= entries_num) { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 69 | printk(BIOS_ERR, "ACPI: Error: Could not add ACPI table, " |
Cristian Măgherușan-Stanciu | ba48281 | 2011-07-02 00:57:07 +0300 | [diff] [blame] | 70 | "too many tables.\n"); |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 71 | return; |
| 72 | } |
| 73 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 74 | /* Add table to the RSDT. */ |
Stefan Reinauer | defee17 | 2015-06-18 01:11:19 -0700 | [diff] [blame] | 75 | rsdt->entry[i] = (uintptr_t)table; |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 76 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 77 | /* Fix RSDT length or the kernel will assume invalid entries. */ |
| 78 | rsdt->header.length = sizeof(acpi_header_t) + (sizeof(u32) * (i + 1)); |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 79 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 80 | /* Re-calculate checksum. */ |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 81 | rsdt->header.checksum = 0; /* Hope this won't get optimized away */ |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 82 | rsdt->header.checksum = acpi_checksum((u8 *)rsdt, rsdt->header.length); |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 83 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 84 | /* |
| 85 | * And now the same thing for the XSDT. We use the same index as for |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 86 | * now we want the XSDT and RSDT to always be in sync in coreboot. |
| 87 | */ |
| 88 | if (xsdt) { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 89 | /* Add table to the XSDT. */ |
Stefan Reinauer | defee17 | 2015-06-18 01:11:19 -0700 | [diff] [blame] | 90 | xsdt->entry[i] = (u64)(uintptr_t)table; |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 91 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 92 | /* Fix XSDT length. */ |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 93 | xsdt->header.length = sizeof(acpi_header_t) + |
Cristian Măgherușan-Stanciu | ba48281 | 2011-07-02 00:57:07 +0300 | [diff] [blame] | 94 | (sizeof(u64) * (i + 1)); |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 95 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 96 | /* Re-calculate checksum. */ |
| 97 | xsdt->header.checksum = 0; |
| 98 | xsdt->header.checksum = acpi_checksum((u8 *)xsdt, |
Cristian Măgherușan-Stanciu | ba48281 | 2011-07-02 00:57:07 +0300 | [diff] [blame] | 99 | xsdt->header.length); |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 100 | } |
| 101 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 102 | printk(BIOS_DEBUG, "ACPI: added table %d/%d, length now %d\n", |
Cristian Măgherușan-Stanciu | ba48281 | 2011-07-02 00:57:07 +0300 | [diff] [blame] | 103 | i + 1, entries_num, rsdt->header.length); |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 104 | } |
| 105 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 106 | int acpi_create_mcfg_mmconfig(acpi_mcfg_mmconfig_t *mmconfig, u32 base, |
Cristian Măgherușan-Stanciu | ba48281 | 2011-07-02 00:57:07 +0300 | [diff] [blame] | 107 | u16 seg_nr, u8 start, u8 end) |
Stefan Reinauer | 26d431a | 2009-01-20 19:17:51 +0000 | [diff] [blame] | 108 | { |
Vladimir Serbinenko | 60fccdc | 2014-10-05 11:05:16 +0200 | [diff] [blame] | 109 | memset(mmconfig, 0, sizeof(*mmconfig)); |
Rudolf Marek | e6409f2 | 2007-11-03 12:50:26 +0000 | [diff] [blame] | 110 | mmconfig->base_address = base; |
| 111 | mmconfig->base_reserved = 0; |
| 112 | mmconfig->pci_segment_group_number = seg_nr; |
| 113 | mmconfig->start_bus_number = start; |
| 114 | mmconfig->end_bus_number = end; |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 115 | |
| 116 | return sizeof(acpi_mcfg_mmconfig_t); |
Rudolf Marek | e6409f2 | 2007-11-03 12:50:26 +0000 | [diff] [blame] | 117 | } |
| 118 | |
Stefan Reinauer | 777224c | 2005-01-19 14:06:41 +0000 | [diff] [blame] | 119 | int acpi_create_madt_lapic(acpi_madt_lapic_t *lapic, u8 cpu, u8 apic) |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 120 | { |
Himanshu Sahdev | 8c09b82 | 2019-10-21 18:50:50 +0530 | [diff] [blame] | 121 | lapic->type = LOCAL_APIC; /* Local APIC structure */ |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 122 | lapic->length = sizeof(acpi_madt_lapic_t); |
| 123 | lapic->flags = (1 << 0); /* Processor/LAPIC enabled */ |
| 124 | lapic->processor_id = cpu; |
| 125 | lapic->apic_id = apic; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 126 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 127 | return lapic->length; |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 128 | } |
| 129 | |
Stefan Reinauer | da65fbf | 2009-04-22 08:18:37 +0000 | [diff] [blame] | 130 | unsigned long acpi_create_madt_lapics(unsigned long current) |
| 131 | { |
Edward O'Callaghan | 2c9d2cf | 2014-10-27 23:29:29 +1100 | [diff] [blame] | 132 | struct device *cpu; |
Werner Zeh | 423adfb | 2019-03-06 09:31:02 +0100 | [diff] [blame] | 133 | int index, apic_ids[CONFIG_MAX_CPUS] = {0}, num_cpus = 0; |
Stefan Reinauer | da65fbf | 2009-04-22 08:18:37 +0000 | [diff] [blame] | 134 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 135 | for (cpu = all_devices; cpu; cpu = cpu->next) { |
Stefan Reinauer | da65fbf | 2009-04-22 08:18:37 +0000 | [diff] [blame] | 136 | if ((cpu->path.type != DEVICE_PATH_APIC) || |
Stefan Reinauer | 0aa37c4 | 2013-02-12 15:20:54 -0800 | [diff] [blame] | 137 | (cpu->bus->dev->path.type != DEVICE_PATH_CPU_CLUSTER)) { |
Stefan Reinauer | da65fbf | 2009-04-22 08:18:37 +0000 | [diff] [blame] | 138 | continue; |
| 139 | } |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 140 | if (!cpu->enabled) |
Stefan Reinauer | da65fbf | 2009-04-22 08:18:37 +0000 | [diff] [blame] | 141 | continue; |
Werner Zeh | db561e6 | 2019-02-19 13:39:56 +0100 | [diff] [blame] | 142 | if (num_cpus >= ARRAY_SIZE(apic_ids)) |
| 143 | break; |
| 144 | apic_ids[num_cpus++] = cpu->path.apic.apic_id; |
| 145 | } |
Werner Zeh | fedb36e | 2019-03-12 07:07:50 +0100 | [diff] [blame] | 146 | if (num_cpus > 1) |
| 147 | bubblesort(apic_ids, num_cpus, NUM_ASCENDING); |
Werner Zeh | db561e6 | 2019-02-19 13:39:56 +0100 | [diff] [blame] | 148 | for (index = 0; index < num_cpus; index++) { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 149 | current += acpi_create_madt_lapic((acpi_madt_lapic_t *)current, |
Werner Zeh | db561e6 | 2019-02-19 13:39:56 +0100 | [diff] [blame] | 150 | index, apic_ids[index]); |
Stefan Reinauer | da65fbf | 2009-04-22 08:18:37 +0000 | [diff] [blame] | 151 | } |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 152 | |
Stefan Reinauer | da65fbf | 2009-04-22 08:18:37 +0000 | [diff] [blame] | 153 | return current; |
| 154 | } |
| 155 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 156 | int acpi_create_madt_ioapic(acpi_madt_ioapic_t *ioapic, u8 id, u32 addr, |
Cristian Măgherușan-Stanciu | ba48281 | 2011-07-02 00:57:07 +0300 | [diff] [blame] | 157 | u32 gsi_base) |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 158 | { |
Himanshu Sahdev | 8c09b82 | 2019-10-21 18:50:50 +0530 | [diff] [blame] | 159 | ioapic->type = IO_APIC; /* I/O APIC structure */ |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 160 | ioapic->length = sizeof(acpi_madt_ioapic_t); |
| 161 | ioapic->reserved = 0x00; |
| 162 | ioapic->gsi_base = gsi_base; |
| 163 | ioapic->ioapic_id = id; |
| 164 | ioapic->ioapic_addr = addr; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 165 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 166 | return ioapic->length; |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 167 | } |
| 168 | |
Stefan Reinauer | 777224c | 2005-01-19 14:06:41 +0000 | [diff] [blame] | 169 | int acpi_create_madt_irqoverride(acpi_madt_irqoverride_t *irqoverride, |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 170 | u8 bus, u8 source, u32 gsirq, u16 flags) |
| 171 | { |
Himanshu Sahdev | 8c09b82 | 2019-10-21 18:50:50 +0530 | [diff] [blame] | 172 | irqoverride->type = IRQ_SOURCE_OVERRIDE; /* Interrupt source override */ |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 173 | irqoverride->length = sizeof(acpi_madt_irqoverride_t); |
| 174 | irqoverride->bus = bus; |
| 175 | irqoverride->source = source; |
| 176 | irqoverride->gsirq = gsirq; |
| 177 | irqoverride->flags = flags; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 178 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 179 | return irqoverride->length; |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 180 | } |
| 181 | |
Stefan Reinauer | 777224c | 2005-01-19 14:06:41 +0000 | [diff] [blame] | 182 | int acpi_create_madt_lapic_nmi(acpi_madt_lapic_nmi_t *lapic_nmi, u8 cpu, |
Cristian Măgherușan-Stanciu | ba48281 | 2011-07-02 00:57:07 +0300 | [diff] [blame] | 183 | u16 flags, u8 lint) |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 184 | { |
Himanshu Sahdev | 8c09b82 | 2019-10-21 18:50:50 +0530 | [diff] [blame] | 185 | lapic_nmi->type = LOCAL_APIC_NMI; /* Local APIC NMI structure */ |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 186 | lapic_nmi->length = sizeof(acpi_madt_lapic_nmi_t); |
| 187 | lapic_nmi->flags = flags; |
| 188 | lapic_nmi->processor_id = cpu; |
| 189 | lapic_nmi->lint = lint; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 190 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 191 | return lapic_nmi->length; |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 192 | } |
| 193 | |
Stefan Reinauer | 777224c | 2005-01-19 14:06:41 +0000 | [diff] [blame] | 194 | void acpi_create_madt(acpi_madt_t *madt) |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 195 | { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 196 | acpi_header_t *header = &(madt->header); |
| 197 | unsigned long current = (unsigned long)madt + sizeof(acpi_madt_t); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 198 | |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 199 | memset((void *)madt, 0, sizeof(acpi_madt_t)); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 200 | |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 201 | if (!header) |
| 202 | return; |
| 203 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 204 | /* Fill out header fields. */ |
Stefan Reinauer | cdfe376 | 2009-07-21 22:15:43 +0000 | [diff] [blame] | 205 | memcpy(header->signature, "APIC", 4); |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 206 | memcpy(header->oem_id, OEM_ID, 6); |
Stefan Reinauer | cdfe376 | 2009-07-21 22:15:43 +0000 | [diff] [blame] | 207 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 208 | memcpy(header->asl_compiler_id, ASLC, 4); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 209 | |
Elyes HAOUAS | f8f2e8c | 2019-02-25 15:42:07 +0100 | [diff] [blame] | 210 | header->asl_compiler_revision = asl_revision; |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 211 | header->length = sizeof(acpi_madt_t); |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 212 | header->revision = get_acpi_table_revision(MADT); |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 213 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 214 | madt->lapic_addr = LOCAL_APIC_ADDR; |
Nico Huber | 9df72e0 | 2018-11-24 18:25:50 +0100 | [diff] [blame] | 215 | if (CONFIG(ACPI_HAVE_PCAT_8259)) |
| 216 | madt->flags |= 1; |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 217 | |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 218 | current = acpi_fill_madt(current); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 219 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 220 | /* (Re)calculate length and checksum. */ |
| 221 | header->length = current - (unsigned long)madt; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 222 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 223 | header->checksum = acpi_checksum((void *)madt, header->length); |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 224 | } |
| 225 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 226 | /* MCFG is defined in the PCI Firmware Specification 3.0. */ |
Rudolf Marek | e6409f2 | 2007-11-03 12:50:26 +0000 | [diff] [blame] | 227 | void acpi_create_mcfg(acpi_mcfg_t *mcfg) |
| 228 | { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 229 | acpi_header_t *header = &(mcfg->header); |
| 230 | unsigned long current = (unsigned long)mcfg + sizeof(acpi_mcfg_t); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 231 | |
Rudolf Marek | e6409f2 | 2007-11-03 12:50:26 +0000 | [diff] [blame] | 232 | memset((void *)mcfg, 0, sizeof(acpi_mcfg_t)); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 233 | |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 234 | if (!header) |
| 235 | return; |
| 236 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 237 | /* Fill out header fields. */ |
Stefan Reinauer | cdfe376 | 2009-07-21 22:15:43 +0000 | [diff] [blame] | 238 | memcpy(header->signature, "MCFG", 4); |
Rudolf Marek | e6409f2 | 2007-11-03 12:50:26 +0000 | [diff] [blame] | 239 | memcpy(header->oem_id, OEM_ID, 6); |
Stefan Reinauer | cdfe376 | 2009-07-21 22:15:43 +0000 | [diff] [blame] | 240 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
Rudolf Marek | e6409f2 | 2007-11-03 12:50:26 +0000 | [diff] [blame] | 241 | memcpy(header->asl_compiler_id, ASLC, 4); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 242 | |
Elyes HAOUAS | f8f2e8c | 2019-02-25 15:42:07 +0100 | [diff] [blame] | 243 | header->asl_compiler_revision = asl_revision; |
Rudolf Marek | e6409f2 | 2007-11-03 12:50:26 +0000 | [diff] [blame] | 244 | header->length = sizeof(acpi_mcfg_t); |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 245 | header->revision = get_acpi_table_revision(MCFG); |
Rudolf Marek | e6409f2 | 2007-11-03 12:50:26 +0000 | [diff] [blame] | 246 | |
| 247 | current = acpi_fill_mcfg(current); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 248 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 249 | /* (Re)calculate length and checksum. */ |
| 250 | header->length = current - (unsigned long)mcfg; |
| 251 | header->checksum = acpi_checksum((void *)mcfg, header->length); |
Rudolf Marek | e6409f2 | 2007-11-03 12:50:26 +0000 | [diff] [blame] | 252 | } |
| 253 | |
Vladimir Serbinenko | f44ac13 | 2015-05-20 19:52:01 +0200 | [diff] [blame] | 254 | static void *get_tcpa_log(u32 *size) |
| 255 | { |
| 256 | const struct cbmem_entry *ce; |
| 257 | const u32 tcpa_default_log_len = 0x10000; |
| 258 | void *lasa; |
Philipp Deppenwiese | 791ba97 | 2018-07-30 01:15:20 +0200 | [diff] [blame] | 259 | ce = cbmem_entry_find(CBMEM_ID_TCPA_TCG_LOG); |
Vladimir Serbinenko | f44ac13 | 2015-05-20 19:52:01 +0200 | [diff] [blame] | 260 | if (ce) { |
| 261 | lasa = cbmem_entry_start(ce); |
| 262 | *size = cbmem_entry_size(ce); |
| 263 | printk(BIOS_DEBUG, "TCPA log found at %p\n", lasa); |
| 264 | return lasa; |
| 265 | } |
Philipp Deppenwiese | 791ba97 | 2018-07-30 01:15:20 +0200 | [diff] [blame] | 266 | lasa = cbmem_add(CBMEM_ID_TCPA_TCG_LOG, tcpa_default_log_len); |
Vladimir Serbinenko | f44ac13 | 2015-05-20 19:52:01 +0200 | [diff] [blame] | 267 | if (!lasa) { |
| 268 | printk(BIOS_ERR, "TCPA log creation failed\n"); |
| 269 | return NULL; |
| 270 | } |
| 271 | |
| 272 | printk(BIOS_DEBUG, "TCPA log created at %p\n", lasa); |
Lee Leahy | 024b13d | 2017-03-16 13:41:11 -0700 | [diff] [blame] | 273 | memset(lasa, 0, tcpa_default_log_len); |
Vladimir Serbinenko | f44ac13 | 2015-05-20 19:52:01 +0200 | [diff] [blame] | 274 | |
| 275 | *size = tcpa_default_log_len; |
| 276 | return lasa; |
| 277 | } |
| 278 | |
| 279 | static void acpi_create_tcpa(acpi_tcpa_t *tcpa) |
| 280 | { |
| 281 | acpi_header_t *header = &(tcpa->header); |
| 282 | u32 tcpa_log_len; |
| 283 | void *lasa; |
| 284 | |
| 285 | memset((void *)tcpa, 0, sizeof(acpi_tcpa_t)); |
| 286 | |
| 287 | lasa = get_tcpa_log(&tcpa_log_len); |
Lee Leahy | 9c7c6f7 | 2017-03-16 11:24:09 -0700 | [diff] [blame] | 288 | if (!lasa) |
Vladimir Serbinenko | f44ac13 | 2015-05-20 19:52:01 +0200 | [diff] [blame] | 289 | return; |
Vladimir Serbinenko | f44ac13 | 2015-05-20 19:52:01 +0200 | [diff] [blame] | 290 | |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 291 | if (!header) |
| 292 | return; |
| 293 | |
Vladimir Serbinenko | f44ac13 | 2015-05-20 19:52:01 +0200 | [diff] [blame] | 294 | /* Fill out header fields. */ |
| 295 | memcpy(header->signature, "TCPA", 4); |
| 296 | memcpy(header->oem_id, OEM_ID, 6); |
| 297 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 298 | memcpy(header->asl_compiler_id, ASLC, 4); |
| 299 | |
Elyes HAOUAS | f8f2e8c | 2019-02-25 15:42:07 +0100 | [diff] [blame] | 300 | header->asl_compiler_revision = asl_revision; |
Vladimir Serbinenko | f44ac13 | 2015-05-20 19:52:01 +0200 | [diff] [blame] | 301 | header->length = sizeof(acpi_tcpa_t); |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 302 | header->revision = get_acpi_table_revision(TCPA); |
Vladimir Serbinenko | f44ac13 | 2015-05-20 19:52:01 +0200 | [diff] [blame] | 303 | |
| 304 | tcpa->platform_class = 0; |
| 305 | tcpa->laml = tcpa_log_len; |
Stefan Reinauer | defee17 | 2015-06-18 01:11:19 -0700 | [diff] [blame] | 306 | tcpa->lasa = (uintptr_t) lasa; |
Vladimir Serbinenko | f44ac13 | 2015-05-20 19:52:01 +0200 | [diff] [blame] | 307 | |
| 308 | /* Calculate checksum. */ |
| 309 | header->checksum = acpi_checksum((void *)tcpa, header->length); |
| 310 | } |
| 311 | |
Michał Żygowski | 6e8692e | 2018-11-22 16:57:50 +0100 | [diff] [blame] | 312 | static void *get_tpm2_log(u32 *size) |
| 313 | { |
| 314 | const struct cbmem_entry *ce; |
| 315 | const u32 tpm2_default_log_len = 0x10000; |
| 316 | void *lasa; |
| 317 | ce = cbmem_entry_find(CBMEM_ID_TPM2_TCG_LOG); |
| 318 | if (ce) { |
| 319 | lasa = cbmem_entry_start(ce); |
| 320 | *size = cbmem_entry_size(ce); |
| 321 | printk(BIOS_DEBUG, "TPM2 log found at %p\n", lasa); |
| 322 | return lasa; |
| 323 | } |
| 324 | lasa = cbmem_add(CBMEM_ID_TPM2_TCG_LOG, tpm2_default_log_len); |
| 325 | if (!lasa) { |
| 326 | printk(BIOS_ERR, "TPM2 log creation failed\n"); |
| 327 | return NULL; |
| 328 | } |
| 329 | |
| 330 | printk(BIOS_DEBUG, "TPM2 log created at %p\n", lasa); |
| 331 | memset(lasa, 0, tpm2_default_log_len); |
| 332 | |
| 333 | *size = tpm2_default_log_len; |
| 334 | return lasa; |
| 335 | } |
| 336 | |
Philipp Deppenwiese | 296164e0 | 2018-10-18 15:39:34 +0200 | [diff] [blame] | 337 | static void acpi_create_tpm2(acpi_tpm2_t *tpm2) |
| 338 | { |
| 339 | acpi_header_t *header = &(tpm2->header); |
Michał Żygowski | 6e8692e | 2018-11-22 16:57:50 +0100 | [diff] [blame] | 340 | u32 tpm2_log_len; |
| 341 | void *lasa; |
Philipp Deppenwiese | 296164e0 | 2018-10-18 15:39:34 +0200 | [diff] [blame] | 342 | |
| 343 | memset((void *)tpm2, 0, sizeof(acpi_tpm2_t)); |
| 344 | |
Michał Żygowski | 6e8692e | 2018-11-22 16:57:50 +0100 | [diff] [blame] | 345 | /* |
| 346 | * Some payloads like SeaBIOS depend on log area to use TPM2. |
| 347 | * Get the memory size and address of TPM2 log area or initialize it. |
| 348 | */ |
| 349 | lasa = get_tpm2_log(&tpm2_log_len); |
| 350 | if (!lasa) |
| 351 | tpm2_log_len = 0; |
| 352 | |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 353 | if (!header) |
| 354 | return; |
| 355 | |
Philipp Deppenwiese | 296164e0 | 2018-10-18 15:39:34 +0200 | [diff] [blame] | 356 | /* Fill out header fields. */ |
| 357 | memcpy(header->signature, "TPM2", 4); |
| 358 | memcpy(header->oem_id, OEM_ID, 6); |
| 359 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 360 | memcpy(header->asl_compiler_id, ASLC, 4); |
| 361 | |
Elyes HAOUAS | f8f2e8c | 2019-02-25 15:42:07 +0100 | [diff] [blame] | 362 | header->asl_compiler_revision = asl_revision; |
Philipp Deppenwiese | 296164e0 | 2018-10-18 15:39:34 +0200 | [diff] [blame] | 363 | header->length = sizeof(acpi_tpm2_t); |
| 364 | header->revision = get_acpi_table_revision(TPM2); |
| 365 | |
| 366 | /* Hard to detect for coreboot. Just set it to 0 */ |
| 367 | tpm2->platform_class = 0; |
Christian Walter | 26e0d4c | 2019-07-14 15:47:23 +0200 | [diff] [blame] | 368 | if (CONFIG(CRB_TPM)) { |
| 369 | /* Must be set to 7 for CRB Support */ |
| 370 | tpm2->control_area = CONFIG_CRB_TPM_BASE_ADDRESS + 0x40; |
| 371 | tpm2->start_method = 7; |
| 372 | } else { |
| 373 | /* Must be set to 0 for FIFO interface support */ |
| 374 | tpm2->control_area = 0; |
| 375 | tpm2->start_method = 6; |
| 376 | } |
Philipp Deppenwiese | 296164e0 | 2018-10-18 15:39:34 +0200 | [diff] [blame] | 377 | memset(tpm2->msp, 0, sizeof(tpm2->msp)); |
| 378 | |
Michał Żygowski | 6e8692e | 2018-11-22 16:57:50 +0100 | [diff] [blame] | 379 | /* Fill the log area size and start address fields. */ |
| 380 | tpm2->laml = tpm2_log_len; |
| 381 | tpm2->lasa = (uintptr_t) lasa; |
| 382 | |
Philipp Deppenwiese | 296164e0 | 2018-10-18 15:39:34 +0200 | [diff] [blame] | 383 | /* Calculate checksum. */ |
| 384 | header->checksum = acpi_checksum((void *)tpm2, header->length); |
| 385 | } |
| 386 | |
Duncan Laurie | 3731903 | 2016-05-26 12:47:05 -0700 | [diff] [blame] | 387 | static void acpi_ssdt_write_cbtable(void) |
| 388 | { |
| 389 | const struct cbmem_entry *cbtable; |
| 390 | uintptr_t base; |
| 391 | uint32_t size; |
| 392 | |
| 393 | cbtable = cbmem_entry_find(CBMEM_ID_CBTABLE); |
| 394 | if (!cbtable) |
| 395 | return; |
| 396 | base = (uintptr_t)cbmem_entry_start(cbtable); |
| 397 | size = cbmem_entry_size(cbtable); |
| 398 | |
| 399 | acpigen_write_device("CTBL"); |
| 400 | acpigen_write_coreboot_hid(COREBOOT_ACPI_ID_CBTABLE); |
| 401 | acpigen_write_name_integer("_UID", 0); |
David Wu | 5dff396 | 2018-03-21 16:48:53 +0800 | [diff] [blame] | 402 | acpigen_write_STA(ACPI_STATUS_DEVICE_HIDDEN_ON); |
Duncan Laurie | 3731903 | 2016-05-26 12:47:05 -0700 | [diff] [blame] | 403 | acpigen_write_name("_CRS"); |
| 404 | acpigen_write_resourcetemplate_header(); |
| 405 | acpigen_write_mem32fixed(0, base, size); |
| 406 | acpigen_write_resourcetemplate_footer(); |
| 407 | acpigen_pop_len(); |
| 408 | } |
| 409 | |
Myles Watson | 3fe6b70 | 2009-10-09 20:13:43 +0000 | [diff] [blame] | 410 | void acpi_create_ssdt_generator(acpi_header_t *ssdt, const char *oem_table_id) |
Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 411 | { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 412 | unsigned long current = (unsigned long)ssdt + sizeof(acpi_header_t); |
| 413 | |
Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 414 | memset((void *)ssdt, 0, sizeof(acpi_header_t)); |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 415 | |
Stefan Reinauer | cdfe376 | 2009-07-21 22:15:43 +0000 | [diff] [blame] | 416 | memcpy(&ssdt->signature, "SSDT", 4); |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 417 | ssdt->revision = get_acpi_table_revision(SSDT); |
Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 418 | memcpy(&ssdt->oem_id, OEM_ID, 6); |
| 419 | memcpy(&ssdt->oem_table_id, oem_table_id, 8); |
| 420 | ssdt->oem_revision = 42; |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 421 | memcpy(&ssdt->asl_compiler_id, ASLC, 4); |
Elyes HAOUAS | 26071aa | 2019-02-15 08:21:33 +0100 | [diff] [blame] | 422 | ssdt->asl_compiler_revision = asl_revision; |
Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 423 | ssdt->length = sizeof(acpi_header_t); |
| 424 | |
Stefan Reinauer | 8dcd50b | 2009-03-06 17:24:29 +0000 | [diff] [blame] | 425 | acpigen_set_current((char *) current); |
Duncan Laurie | 3731903 | 2016-05-26 12:47:05 -0700 | [diff] [blame] | 426 | |
| 427 | /* Write object to declare coreboot tables */ |
| 428 | acpi_ssdt_write_cbtable(); |
| 429 | |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 430 | { |
Edward O'Callaghan | 2c9d2cf | 2014-10-27 23:29:29 +1100 | [diff] [blame] | 431 | struct device *dev; |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 432 | for (dev = all_devices; dev; dev = dev->next) |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame] | 433 | if (dev->ops && dev->ops->acpi_fill_ssdt) |
| 434 | dev->ops->acpi_fill_ssdt(dev); |
Vladimir Serbinenko | 0a66991 | 2014-10-05 14:34:17 +0200 | [diff] [blame] | 435 | current = (unsigned long) acpigen_get_current(); |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 436 | } |
Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 437 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 438 | /* (Re)calculate length and checksum. */ |
Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 439 | ssdt->length = current - (unsigned long)ssdt; |
| 440 | ssdt->checksum = acpi_checksum((void *)ssdt, ssdt->length); |
| 441 | } |
| 442 | |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 443 | int acpi_create_srat_lapic(acpi_srat_lapic_t *lapic, u8 node, u8 apic) |
| 444 | { |
Myles Watson | 0b4c9f0 | 2009-03-10 18:06:47 +0000 | [diff] [blame] | 445 | memset((void *)lapic, 0, sizeof(acpi_srat_lapic_t)); |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 446 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 447 | lapic->type = 0; /* Processor local APIC/SAPIC affinity structure */ |
| 448 | lapic->length = sizeof(acpi_srat_lapic_t); |
| 449 | lapic->flags = (1 << 0); /* Enabled (the use of this structure). */ |
| 450 | lapic->proximity_domain_7_0 = node; |
| 451 | /* TODO: proximity_domain_31_8, local SAPIC EID, clock domain. */ |
| 452 | lapic->apic_id = apic; |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 453 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 454 | return lapic->length; |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 455 | } |
| 456 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 457 | int acpi_create_srat_mem(acpi_srat_mem_t *mem, u8 node, u32 basek, u32 sizek, |
Cristian Măgherușan-Stanciu | ba48281 | 2011-07-02 00:57:07 +0300 | [diff] [blame] | 458 | u32 flags) |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 459 | { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 460 | mem->type = 1; /* Memory affinity structure */ |
| 461 | mem->length = sizeof(acpi_srat_mem_t); |
| 462 | mem->base_address_low = (basek << 10); |
| 463 | mem->base_address_high = (basek >> (32 - 10)); |
| 464 | mem->length_low = (sizek << 10); |
| 465 | mem->length_high = (sizek >> (32 - 10)); |
| 466 | mem->proximity_domain = node; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 467 | mem->flags = flags; |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 468 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 469 | return mem->length; |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 470 | } |
| 471 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 472 | /* http://www.microsoft.com/whdc/system/sysinternals/sratdwn.mspx */ |
Vladimir Serbinenko | 5e59757 | 2014-10-11 23:45:40 +0200 | [diff] [blame] | 473 | void acpi_create_srat(acpi_srat_t *srat, |
| 474 | unsigned long (*acpi_fill_srat)(unsigned long current)) |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 475 | { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 476 | acpi_header_t *header = &(srat->header); |
| 477 | unsigned long current = (unsigned long)srat + sizeof(acpi_srat_t); |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 478 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 479 | memset((void *)srat, 0, sizeof(acpi_srat_t)); |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 480 | |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 481 | if (!header) |
| 482 | return; |
| 483 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 484 | /* Fill out header fields. */ |
| 485 | memcpy(header->signature, "SRAT", 4); |
| 486 | memcpy(header->oem_id, OEM_ID, 6); |
| 487 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 488 | memcpy(header->asl_compiler_id, ASLC, 4); |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 489 | |
Elyes HAOUAS | f8f2e8c | 2019-02-25 15:42:07 +0100 | [diff] [blame] | 490 | header->asl_compiler_revision = asl_revision; |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 491 | header->length = sizeof(acpi_srat_t); |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 492 | header->revision = get_acpi_table_revision(SRAT); |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 493 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 494 | srat->resv = 1; /* Spec: Reserved to 1 for backwards compatibility. */ |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 495 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 496 | current = acpi_fill_srat(current); |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 497 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 498 | /* (Re)calculate length and checksum. */ |
| 499 | header->length = current - (unsigned long)srat; |
| 500 | header->checksum = acpi_checksum((void *)srat, header->length); |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 501 | } |
| 502 | |
Nico Huber | e561f35 | 2015-10-26 11:51:25 +0100 | [diff] [blame] | 503 | void acpi_create_dmar(acpi_dmar_t *dmar, enum dmar_flags flags, |
Lee Leahy | 024b13d | 2017-03-16 13:41:11 -0700 | [diff] [blame] | 504 | unsigned long (*acpi_fill_dmar)(unsigned long)) |
Patrick Georgi | 3b590ff | 2012-09-11 15:21:01 +0200 | [diff] [blame] | 505 | { |
| 506 | acpi_header_t *header = &(dmar->header); |
| 507 | unsigned long current = (unsigned long)dmar + sizeof(acpi_dmar_t); |
| 508 | |
| 509 | memset((void *)dmar, 0, sizeof(acpi_dmar_t)); |
| 510 | |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 511 | if (!header) |
| 512 | return; |
| 513 | |
Patrick Georgi | 3b590ff | 2012-09-11 15:21:01 +0200 | [diff] [blame] | 514 | /* Fill out header fields. */ |
| 515 | memcpy(header->signature, "DMAR", 4); |
| 516 | memcpy(header->oem_id, OEM_ID, 6); |
| 517 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 518 | memcpy(header->asl_compiler_id, ASLC, 4); |
| 519 | |
Elyes HAOUAS | f8f2e8c | 2019-02-25 15:42:07 +0100 | [diff] [blame] | 520 | header->asl_compiler_revision = asl_revision; |
Patrick Georgi | 3b590ff | 2012-09-11 15:21:01 +0200 | [diff] [blame] | 521 | header->length = sizeof(acpi_dmar_t); |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 522 | header->revision = get_acpi_table_revision(DMAR); |
Patrick Georgi | 3b590ff | 2012-09-11 15:21:01 +0200 | [diff] [blame] | 523 | |
Jacob Laska | f3f654d | 2016-03-15 21:53:27 -0500 | [diff] [blame] | 524 | dmar->host_address_width = cpu_phys_address_size() - 1; |
Nico Huber | e561f35 | 2015-10-26 11:51:25 +0100 | [diff] [blame] | 525 | dmar->flags = flags; |
Patrick Georgi | 3b590ff | 2012-09-11 15:21:01 +0200 | [diff] [blame] | 526 | |
| 527 | current = acpi_fill_dmar(current); |
| 528 | |
| 529 | /* (Re)calculate length and checksum. */ |
| 530 | header->length = current - (unsigned long)dmar; |
| 531 | header->checksum = acpi_checksum((void *)dmar, header->length); |
| 532 | } |
| 533 | |
| 534 | unsigned long acpi_create_dmar_drhd(unsigned long current, u8 flags, |
Matt DeVillier | 7866d49 | 2018-03-29 14:59:57 +0200 | [diff] [blame] | 535 | u16 segment, u64 bar) |
Patrick Georgi | 3b590ff | 2012-09-11 15:21:01 +0200 | [diff] [blame] | 536 | { |
| 537 | dmar_entry_t *drhd = (dmar_entry_t *)current; |
| 538 | memset(drhd, 0, sizeof(*drhd)); |
| 539 | drhd->type = DMAR_DRHD; |
| 540 | drhd->length = sizeof(*drhd); /* will be fixed up later */ |
| 541 | drhd->flags = flags; |
| 542 | drhd->segment = segment; |
| 543 | drhd->bar = bar; |
| 544 | |
| 545 | return drhd->length; |
| 546 | } |
| 547 | |
Matt DeVillier | 7866d49 | 2018-03-29 14:59:57 +0200 | [diff] [blame] | 548 | unsigned long acpi_create_dmar_rmrr(unsigned long current, u16 segment, |
| 549 | u64 bar, u64 limit) |
| 550 | { |
| 551 | dmar_rmrr_entry_t *rmrr = (dmar_rmrr_entry_t *)current; |
| 552 | memset(rmrr, 0, sizeof(*rmrr)); |
| 553 | rmrr->type = DMAR_RMRR; |
| 554 | rmrr->length = sizeof(*rmrr); /* will be fixed up later */ |
| 555 | rmrr->segment = segment; |
| 556 | rmrr->bar = bar; |
| 557 | rmrr->limit = limit; |
| 558 | |
| 559 | return rmrr->length; |
| 560 | } |
| 561 | |
Werner Zeh | d4d7695 | 2016-07-27 06:56:36 +0200 | [diff] [blame] | 562 | unsigned long acpi_create_dmar_atsr(unsigned long current, u8 flags, |
| 563 | u16 segment) |
| 564 | { |
| 565 | dmar_atsr_entry_t *atsr = (dmar_atsr_entry_t *)current; |
| 566 | memset(atsr, 0, sizeof(*atsr)); |
| 567 | atsr->type = DMAR_ATSR; |
| 568 | atsr->length = sizeof(*atsr); /* will be fixed up later */ |
| 569 | atsr->flags = flags; |
| 570 | atsr->segment = segment; |
| 571 | |
| 572 | return atsr->length; |
| 573 | } |
| 574 | |
John Zhao | 76e7067 | 2019-04-04 11:03:28 -0700 | [diff] [blame] | 575 | unsigned long acpi_create_dmar_rhsa(unsigned long current, u64 base_addr, |
| 576 | u32 proximity_domain) |
| 577 | { |
| 578 | dmar_rhsa_entry_t *rhsa = (dmar_rhsa_entry_t *)current; |
| 579 | memset(rhsa, 0, sizeof(*rhsa)); |
| 580 | rhsa->type = DMAR_RHSA; |
| 581 | rhsa->length = sizeof(*rhsa); |
| 582 | rhsa->base_address = base_addr; |
| 583 | rhsa->proximity_domain = proximity_domain; |
| 584 | |
| 585 | return rhsa->length; |
| 586 | } |
| 587 | |
| 588 | unsigned long acpi_create_dmar_andd(unsigned long current, u8 device_number, |
| 589 | const char *device_name) |
| 590 | { |
| 591 | dmar_andd_entry_t *andd = (dmar_andd_entry_t *)current; |
| 592 | int andd_len = sizeof(dmar_andd_entry_t) + strlen(device_name) + 1; |
| 593 | memset(andd, 0, andd_len); |
| 594 | andd->type = DMAR_ANDD; |
| 595 | andd->length = andd_len; |
| 596 | andd->device_number = device_number; |
| 597 | memcpy(&andd->device_name, device_name, strlen(device_name)); |
| 598 | |
| 599 | return andd->length; |
| 600 | } |
| 601 | |
Patrick Georgi | 3b590ff | 2012-09-11 15:21:01 +0200 | [diff] [blame] | 602 | void acpi_dmar_drhd_fixup(unsigned long base, unsigned long current) |
| 603 | { |
| 604 | dmar_entry_t *drhd = (dmar_entry_t *)base; |
| 605 | drhd->length = current - base; |
| 606 | } |
| 607 | |
Matt DeVillier | 7866d49 | 2018-03-29 14:59:57 +0200 | [diff] [blame] | 608 | void acpi_dmar_rmrr_fixup(unsigned long base, unsigned long current) |
| 609 | { |
| 610 | dmar_rmrr_entry_t *rmrr = (dmar_rmrr_entry_t *)base; |
| 611 | rmrr->length = current - base; |
| 612 | } |
| 613 | |
Werner Zeh | d4d7695 | 2016-07-27 06:56:36 +0200 | [diff] [blame] | 614 | void acpi_dmar_atsr_fixup(unsigned long base, unsigned long current) |
| 615 | { |
| 616 | dmar_atsr_entry_t *atsr = (dmar_atsr_entry_t *)base; |
| 617 | atsr->length = current - base; |
| 618 | } |
| 619 | |
Matt DeVillier | 7866d49 | 2018-03-29 14:59:57 +0200 | [diff] [blame] | 620 | static unsigned long acpi_create_dmar_ds(unsigned long current, |
Nico Huber | 6c4751d | 2015-10-26 12:03:54 +0100 | [diff] [blame] | 621 | enum dev_scope_type type, u8 enumeration_id, u8 bus, u8 dev, u8 fn) |
Patrick Georgi | 3b590ff | 2012-09-11 15:21:01 +0200 | [diff] [blame] | 622 | { |
Nico Huber | 6c4751d | 2015-10-26 12:03:54 +0100 | [diff] [blame] | 623 | /* we don't support longer paths yet */ |
| 624 | const size_t dev_scope_length = sizeof(dev_scope_t) + 2; |
| 625 | |
Patrick Georgi | 3b590ff | 2012-09-11 15:21:01 +0200 | [diff] [blame] | 626 | dev_scope_t *ds = (dev_scope_t *)current; |
Nico Huber | 6c4751d | 2015-10-26 12:03:54 +0100 | [diff] [blame] | 627 | memset(ds, 0, dev_scope_length); |
| 628 | ds->type = type; |
| 629 | ds->length = dev_scope_length; |
| 630 | ds->enumeration = enumeration_id; |
| 631 | ds->start_bus = bus; |
| 632 | ds->path[0].dev = dev; |
| 633 | ds->path[0].fn = fn; |
Patrick Georgi | 3b590ff | 2012-09-11 15:21:01 +0200 | [diff] [blame] | 634 | |
| 635 | return ds->length; |
| 636 | } |
| 637 | |
Matt DeVillier | 7866d49 | 2018-03-29 14:59:57 +0200 | [diff] [blame] | 638 | unsigned long acpi_create_dmar_ds_pci_br(unsigned long current, u8 bus, |
Werner Zeh | 21a5bff | 2016-07-27 07:07:20 +0200 | [diff] [blame] | 639 | u8 dev, u8 fn) |
| 640 | { |
Matt DeVillier | 7866d49 | 2018-03-29 14:59:57 +0200 | [diff] [blame] | 641 | return acpi_create_dmar_ds(current, |
Werner Zeh | 21a5bff | 2016-07-27 07:07:20 +0200 | [diff] [blame] | 642 | SCOPE_PCI_SUB, 0, bus, dev, fn); |
| 643 | } |
| 644 | |
Matt DeVillier | 7866d49 | 2018-03-29 14:59:57 +0200 | [diff] [blame] | 645 | unsigned long acpi_create_dmar_ds_pci(unsigned long current, u8 bus, |
Nico Huber | 6c4751d | 2015-10-26 12:03:54 +0100 | [diff] [blame] | 646 | u8 dev, u8 fn) |
| 647 | { |
Matt DeVillier | 7866d49 | 2018-03-29 14:59:57 +0200 | [diff] [blame] | 648 | return acpi_create_dmar_ds(current, |
Nico Huber | 6c4751d | 2015-10-26 12:03:54 +0100 | [diff] [blame] | 649 | SCOPE_PCI_ENDPOINT, 0, bus, dev, fn); |
| 650 | } |
| 651 | |
Matt DeVillier | 7866d49 | 2018-03-29 14:59:57 +0200 | [diff] [blame] | 652 | unsigned long acpi_create_dmar_ds_ioapic(unsigned long current, |
Nico Huber | 6c4751d | 2015-10-26 12:03:54 +0100 | [diff] [blame] | 653 | u8 enumeration_id, u8 bus, u8 dev, u8 fn) |
| 654 | { |
Matt DeVillier | 7866d49 | 2018-03-29 14:59:57 +0200 | [diff] [blame] | 655 | return acpi_create_dmar_ds(current, |
Nico Huber | 6c4751d | 2015-10-26 12:03:54 +0100 | [diff] [blame] | 656 | SCOPE_IOAPIC, enumeration_id, bus, dev, fn); |
| 657 | } |
| 658 | |
Matt DeVillier | 7866d49 | 2018-03-29 14:59:57 +0200 | [diff] [blame] | 659 | unsigned long acpi_create_dmar_ds_msi_hpet(unsigned long current, |
Nico Huber | 6c4751d | 2015-10-26 12:03:54 +0100 | [diff] [blame] | 660 | u8 enumeration_id, u8 bus, u8 dev, u8 fn) |
| 661 | { |
Matt DeVillier | 7866d49 | 2018-03-29 14:59:57 +0200 | [diff] [blame] | 662 | return acpi_create_dmar_ds(current, |
Nico Huber | 6c4751d | 2015-10-26 12:03:54 +0100 | [diff] [blame] | 663 | SCOPE_MSI_HPET, enumeration_id, bus, dev, fn); |
| 664 | } |
| 665 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 666 | /* http://h21007.www2.hp.com/portal/download/files/unprot/Itanium/slit.pdf */ |
Vladimir Serbinenko | 5e59757 | 2014-10-11 23:45:40 +0200 | [diff] [blame] | 667 | void acpi_create_slit(acpi_slit_t *slit, |
| 668 | unsigned long (*acpi_fill_slit)(unsigned long current)) |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 669 | { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 670 | acpi_header_t *header = &(slit->header); |
| 671 | unsigned long current = (unsigned long)slit + sizeof(acpi_slit_t); |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 672 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 673 | memset((void *)slit, 0, sizeof(acpi_slit_t)); |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 674 | |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 675 | if (!header) |
| 676 | return; |
| 677 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 678 | /* Fill out header fields. */ |
| 679 | memcpy(header->signature, "SLIT", 4); |
| 680 | memcpy(header->oem_id, OEM_ID, 6); |
| 681 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 682 | memcpy(header->asl_compiler_id, ASLC, 4); |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 683 | |
Elyes HAOUAS | f8f2e8c | 2019-02-25 15:42:07 +0100 | [diff] [blame] | 684 | header->asl_compiler_revision = asl_revision; |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 685 | header->length = sizeof(acpi_slit_t); |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 686 | header->revision = get_acpi_table_revision(SLIT); |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 687 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 688 | current = acpi_fill_slit(current); |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 689 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 690 | /* (Re)calculate length and checksum. */ |
| 691 | header->length = current - (unsigned long)slit; |
| 692 | header->checksum = acpi_checksum((void *)slit, header->length); |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 693 | } |
| 694 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 695 | /* http://www.intel.com/hardwaredesign/hpetspec_1.pdf */ |
Stefan Reinauer | 777224c | 2005-01-19 14:06:41 +0000 | [diff] [blame] | 696 | void acpi_create_hpet(acpi_hpet_t *hpet) |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 697 | { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 698 | acpi_header_t *header = &(hpet->header); |
| 699 | acpi_addr_t *addr = &(hpet->addr); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 700 | |
Stefan Reinauer | a7648c2 | 2004-01-29 17:31:34 +0000 | [diff] [blame] | 701 | memset((void *)hpet, 0, sizeof(acpi_hpet_t)); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 702 | |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 703 | if (!header) |
| 704 | return; |
| 705 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 706 | /* Fill out header fields. */ |
Stefan Reinauer | 4704dc5 | 2009-07-22 01:11:37 +0000 | [diff] [blame] | 707 | memcpy(header->signature, "HPET", 4); |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 708 | memcpy(header->oem_id, OEM_ID, 6); |
Stefan Reinauer | cdfe376 | 2009-07-21 22:15:43 +0000 | [diff] [blame] | 709 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 710 | memcpy(header->asl_compiler_id, ASLC, 4); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 711 | |
Elyes HAOUAS | f8f2e8c | 2019-02-25 15:42:07 +0100 | [diff] [blame] | 712 | header->asl_compiler_revision = asl_revision; |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 713 | header->length = sizeof(acpi_hpet_t); |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 714 | header->revision = get_acpi_table_revision(HPET); |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 715 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 716 | /* Fill out HPET address. */ |
| 717 | addr->space_id = 0; /* Memory */ |
| 718 | addr->bit_width = 64; |
| 719 | addr->bit_offset = 0; |
Patrick Georgi | 9aeb694 | 2012-10-05 21:54:38 +0200 | [diff] [blame] | 720 | addr->addrl = CONFIG_HPET_ADDRESS & 0xffffffff; |
| 721 | addr->addrh = ((unsigned long long)CONFIG_HPET_ADDRESS) >> 32; |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 722 | |
Lee Leahy | 024b13d | 2017-03-16 13:41:11 -0700 | [diff] [blame] | 723 | hpet->id = *(unsigned int *)CONFIG_HPET_ADDRESS; |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 724 | hpet->number = 0; |
Patrick Georgi | 9aeb694 | 2012-10-05 21:54:38 +0200 | [diff] [blame] | 725 | hpet->min_tick = CONFIG_HPET_MIN_TICKS; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 726 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 727 | header->checksum = acpi_checksum((void *)hpet, sizeof(acpi_hpet_t)); |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 728 | } |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 729 | |
Patrick Rudolph | a5c2ac6 | 2016-03-31 20:04:23 +0200 | [diff] [blame] | 730 | void acpi_create_vfct(struct device *device, |
Himanshu Sahdev | 7f1da07 | 2019-10-21 15:27:19 +0530 | [diff] [blame] | 731 | acpi_vfct_t *vfct, |
Lee Leahy | 6f80ccc | 2017-03-16 15:18:22 -0700 | [diff] [blame] | 732 | unsigned long (*acpi_fill_vfct)(struct device *device, |
Himanshu Sahdev | 7f1da07 | 2019-10-21 15:27:19 +0530 | [diff] [blame] | 733 | acpi_vfct_t *vfct_struct, unsigned long current)) |
Patrick Rudolph | a5c2ac6 | 2016-03-31 20:04:23 +0200 | [diff] [blame] | 734 | { |
| 735 | acpi_header_t *header = &(vfct->header); |
Himanshu Sahdev | 7f1da07 | 2019-10-21 15:27:19 +0530 | [diff] [blame] | 736 | unsigned long current = (unsigned long)vfct + sizeof(acpi_vfct_t); |
Patrick Rudolph | a5c2ac6 | 2016-03-31 20:04:23 +0200 | [diff] [blame] | 737 | |
Himanshu Sahdev | 7f1da07 | 2019-10-21 15:27:19 +0530 | [diff] [blame] | 738 | memset((void *)vfct, 0, sizeof(acpi_vfct_t)); |
Patrick Rudolph | a5c2ac6 | 2016-03-31 20:04:23 +0200 | [diff] [blame] | 739 | |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 740 | if (!header) |
| 741 | return; |
| 742 | |
Patrick Rudolph | a5c2ac6 | 2016-03-31 20:04:23 +0200 | [diff] [blame] | 743 | /* Fill out header fields. */ |
| 744 | memcpy(header->signature, "VFCT", 4); |
| 745 | memcpy(header->oem_id, OEM_ID, 6); |
| 746 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 747 | memcpy(header->asl_compiler_id, ASLC, 4); |
| 748 | |
Elyes HAOUAS | f8f2e8c | 2019-02-25 15:42:07 +0100 | [diff] [blame] | 749 | header->asl_compiler_revision = asl_revision; |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 750 | header->revision = get_acpi_table_revision(VFCT); |
Patrick Rudolph | a5c2ac6 | 2016-03-31 20:04:23 +0200 | [diff] [blame] | 751 | |
| 752 | current = acpi_fill_vfct(device, vfct, current); |
| 753 | |
Kyösti Mälkki | fb49379 | 2019-06-30 06:29:52 +0300 | [diff] [blame] | 754 | /* If no BIOS image, return with header->length == 0. */ |
| 755 | if (!vfct->VBIOSImageOffset) |
| 756 | return; |
| 757 | |
Patrick Rudolph | a5c2ac6 | 2016-03-31 20:04:23 +0200 | [diff] [blame] | 758 | /* (Re)calculate length and checksum. */ |
| 759 | header->length = current - (unsigned long)vfct; |
| 760 | header->checksum = acpi_checksum((void *)vfct, header->length); |
| 761 | } |
| 762 | |
Patrick Rudolph | 9d98e5a | 2019-06-14 19:00:04 +0200 | [diff] [blame] | 763 | void acpi_create_ipmi(struct device *device, |
| 764 | struct acpi_spmi *spmi, |
| 765 | const u16 ipmi_revision, |
| 766 | const acpi_addr_t *addr, |
| 767 | const enum acpi_ipmi_interface_type type, |
| 768 | const s8 gpe_interrupt, |
| 769 | const u32 apic_interrupt, |
| 770 | const u32 uid) |
| 771 | { |
| 772 | acpi_header_t *header = &(spmi->header); |
| 773 | memset((void *)spmi, 0, sizeof(struct acpi_spmi)); |
| 774 | |
| 775 | /* Fill out header fields. */ |
| 776 | memcpy(header->signature, "SPMI", 4); |
| 777 | memcpy(header->oem_id, OEM_ID, 6); |
| 778 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 779 | memcpy(header->asl_compiler_id, ASLC, 4); |
| 780 | |
| 781 | header->asl_compiler_revision = asl_revision; |
| 782 | header->length = sizeof(struct acpi_spmi); |
| 783 | header->revision = get_acpi_table_revision(SPMI); |
| 784 | |
| 785 | spmi->reserved = 1; |
| 786 | |
| 787 | if (device->path.type == DEVICE_PATH_PCI) { |
| 788 | spmi->pci_device_flag = ACPI_IPMI_PCI_DEVICE_FLAG; |
| 789 | spmi->pci_bus = device->bus->secondary; |
| 790 | spmi->pci_device = device->path.pci.devfn >> 3; |
| 791 | spmi->pci_function = device->path.pci.devfn & 0x7; |
| 792 | } else if (type != IPMI_INTERFACE_SSIF) { |
| 793 | memcpy(spmi->uid, &uid, sizeof(spmi->uid)); |
| 794 | } |
| 795 | |
| 796 | spmi->base_address = *addr; |
| 797 | spmi->specification_revision = ipmi_revision; |
| 798 | |
| 799 | spmi->interface_type = type; |
| 800 | |
| 801 | if (gpe_interrupt >= 0 && gpe_interrupt < 32) { |
| 802 | spmi->gpe = gpe_interrupt; |
| 803 | spmi->interrupt_type |= ACPI_IPMI_INT_TYPE_SCI; |
| 804 | } |
| 805 | if (apic_interrupt > 0) { |
| 806 | spmi->global_system_interrupt = apic_interrupt; |
| 807 | spmi->interrupt_type |= ACPI_IPMI_INT_TYPE_APIC; |
| 808 | } |
| 809 | |
| 810 | /* Calculate checksum. */ |
| 811 | header->checksum = acpi_checksum((void *)spmi, header->length); |
| 812 | } |
| 813 | |
Timothy Pearson | ff8ccf0 | 2015-08-11 17:48:32 -0500 | [diff] [blame] | 814 | void acpi_create_ivrs(acpi_ivrs_t *ivrs, |
Lee Leahy | 6f80ccc | 2017-03-16 15:18:22 -0700 | [diff] [blame] | 815 | unsigned long (*acpi_fill_ivrs)(acpi_ivrs_t *ivrs_struct, |
| 816 | unsigned long current)) |
Timothy Pearson | ff8ccf0 | 2015-08-11 17:48:32 -0500 | [diff] [blame] | 817 | { |
| 818 | acpi_header_t *header = &(ivrs->header); |
| 819 | unsigned long current = (unsigned long)ivrs + sizeof(acpi_ivrs_t); |
| 820 | |
| 821 | memset((void *)ivrs, 0, sizeof(acpi_ivrs_t)); |
| 822 | |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 823 | if (!header) |
| 824 | return; |
| 825 | |
Timothy Pearson | ff8ccf0 | 2015-08-11 17:48:32 -0500 | [diff] [blame] | 826 | /* Fill out header fields. */ |
| 827 | memcpy(header->signature, "IVRS", 4); |
| 828 | memcpy(header->oem_id, OEM_ID, 6); |
| 829 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 830 | memcpy(header->asl_compiler_id, ASLC, 4); |
| 831 | |
Elyes HAOUAS | f8f2e8c | 2019-02-25 15:42:07 +0100 | [diff] [blame] | 832 | header->asl_compiler_revision = asl_revision; |
Timothy Pearson | ff8ccf0 | 2015-08-11 17:48:32 -0500 | [diff] [blame] | 833 | header->length = sizeof(acpi_ivrs_t); |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 834 | header->revision = get_acpi_table_revision(IVRS); |
Timothy Pearson | ff8ccf0 | 2015-08-11 17:48:32 -0500 | [diff] [blame] | 835 | |
| 836 | current = acpi_fill_ivrs(ivrs, current); |
| 837 | |
| 838 | /* (Re)calculate length and checksum. */ |
| 839 | header->length = current - (unsigned long)ivrs; |
| 840 | header->checksum = acpi_checksum((void *)ivrs, header->length); |
| 841 | } |
| 842 | |
Elyes HAOUAS | 9dd89cd | 2018-05-04 17:56:47 +0200 | [diff] [blame] | 843 | unsigned long acpi_write_hpet(struct device *device, unsigned long current, |
Lee Leahy | 6f80ccc | 2017-03-16 15:18:22 -0700 | [diff] [blame] | 844 | acpi_rsdp_t *rsdp) |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 845 | { |
| 846 | acpi_hpet_t *hpet; |
| 847 | |
| 848 | /* |
| 849 | * We explicitly add these tables later on: |
| 850 | */ |
| 851 | printk(BIOS_DEBUG, "ACPI: * HPET\n"); |
| 852 | |
| 853 | hpet = (acpi_hpet_t *) current; |
| 854 | current += sizeof(acpi_hpet_t); |
Felix Held | c469712 | 2019-06-20 13:50:17 +0200 | [diff] [blame] | 855 | current = ALIGN_UP(current, 16); |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 856 | acpi_create_hpet(hpet); |
| 857 | acpi_add_table(rsdp, hpet); |
| 858 | |
| 859 | return current; |
| 860 | } |
| 861 | |
Duncan Laurie | e4a36c7 | 2017-11-11 19:33:25 -0800 | [diff] [blame] | 862 | void acpi_create_dbg2(acpi_dbg2_header_t *dbg2, |
| 863 | int port_type, int port_subtype, |
| 864 | acpi_addr_t *address, uint32_t address_size, |
| 865 | const char *device_path) |
| 866 | { |
| 867 | uintptr_t current; |
| 868 | acpi_dbg2_device_t *device; |
| 869 | uint32_t *dbg2_addr_size; |
| 870 | acpi_header_t *header; |
| 871 | size_t path_len; |
| 872 | const char *path; |
| 873 | char *namespace; |
| 874 | |
| 875 | /* Fill out header fields. */ |
| 876 | current = (uintptr_t)dbg2; |
| 877 | memset(dbg2, 0, sizeof(acpi_dbg2_header_t)); |
| 878 | header = &(dbg2->header); |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 879 | |
| 880 | if (!header) |
| 881 | return; |
| 882 | |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 883 | header->revision = get_acpi_table_revision(DBG2); |
Duncan Laurie | e4a36c7 | 2017-11-11 19:33:25 -0800 | [diff] [blame] | 884 | memcpy(header->signature, "DBG2", 4); |
| 885 | memcpy(header->oem_id, OEM_ID, 6); |
| 886 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 887 | memcpy(header->asl_compiler_id, ASLC, 4); |
Elyes HAOUAS | f8f2e8c | 2019-02-25 15:42:07 +0100 | [diff] [blame] | 888 | header->asl_compiler_revision = asl_revision; |
Duncan Laurie | e4a36c7 | 2017-11-11 19:33:25 -0800 | [diff] [blame] | 889 | |
| 890 | /* One debug device defined */ |
| 891 | dbg2->devices_offset = sizeof(acpi_dbg2_header_t); |
| 892 | dbg2->devices_count = 1; |
| 893 | current += sizeof(acpi_dbg2_header_t); |
| 894 | |
| 895 | /* Device comes after the header */ |
| 896 | device = (acpi_dbg2_device_t *)current; |
| 897 | memset(device, 0, sizeof(acpi_dbg2_device_t)); |
| 898 | current += sizeof(acpi_dbg2_device_t); |
| 899 | |
| 900 | device->revision = 0; |
| 901 | device->address_count = 1; |
| 902 | device->port_type = port_type; |
| 903 | device->port_subtype = port_subtype; |
| 904 | |
| 905 | /* Base Address comes after device structure */ |
| 906 | memcpy((void *)current, address, sizeof(acpi_addr_t)); |
| 907 | device->base_address_offset = current - (uintptr_t)device; |
| 908 | current += sizeof(acpi_addr_t); |
| 909 | |
| 910 | /* Address Size comes after address structure */ |
| 911 | dbg2_addr_size = (uint32_t *)current; |
| 912 | device->address_size_offset = current - (uintptr_t)device; |
| 913 | *dbg2_addr_size = address_size; |
| 914 | current += sizeof(uint32_t); |
| 915 | |
| 916 | /* Namespace string comes last, use '.' if not provided */ |
| 917 | path = device_path ? : "."; |
| 918 | /* Namespace string length includes NULL terminator */ |
| 919 | path_len = strlen(path) + 1; |
| 920 | namespace = (char *)current; |
| 921 | device->namespace_string_length = path_len; |
| 922 | device->namespace_string_offset = current - (uintptr_t)device; |
| 923 | strncpy(namespace, path, path_len); |
| 924 | current += path_len; |
| 925 | |
| 926 | /* Update structure lengths and checksum */ |
| 927 | device->length = current - (uintptr_t)device; |
| 928 | header->length = current - (uintptr_t)dbg2; |
| 929 | header->checksum = acpi_checksum((uint8_t *)dbg2, header->length); |
| 930 | } |
| 931 | |
| 932 | unsigned long acpi_write_dbg2_pci_uart(acpi_rsdp_t *rsdp, unsigned long current, |
Aamir Bohra | e825d3f | 2019-07-30 10:11:41 +0530 | [diff] [blame] | 933 | const struct device *dev, uint8_t access_size) |
Duncan Laurie | e4a36c7 | 2017-11-11 19:33:25 -0800 | [diff] [blame] | 934 | { |
| 935 | acpi_dbg2_header_t *dbg2 = (acpi_dbg2_header_t *)current; |
| 936 | struct resource *res; |
| 937 | acpi_addr_t address; |
| 938 | |
| 939 | if (!dev) { |
Wim Vervoorn | 6cd5243 | 2020-02-03 14:41:46 +0100 | [diff] [blame] | 940 | printk(BIOS_DEBUG, "%s: Device not found\n", __func__); |
Duncan Laurie | e4a36c7 | 2017-11-11 19:33:25 -0800 | [diff] [blame] | 941 | return current; |
| 942 | } |
Mario Scheithauer | f1eb0ea | 2017-11-21 13:52:53 +0100 | [diff] [blame] | 943 | if (!dev->enabled) { |
| 944 | printk(BIOS_INFO, "%s: Device not enabled\n", __func__); |
| 945 | return current; |
| 946 | } |
Duncan Laurie | e4a36c7 | 2017-11-11 19:33:25 -0800 | [diff] [blame] | 947 | res = find_resource(dev, PCI_BASE_ADDRESS_0); |
| 948 | if (!res) { |
| 949 | printk(BIOS_ERR, "%s: Unable to find resource for %s\n", |
| 950 | __func__, dev_path(dev)); |
| 951 | return current; |
| 952 | } |
| 953 | |
| 954 | memset(&address, 0, sizeof(address)); |
| 955 | if (res->flags & IORESOURCE_IO) |
| 956 | address.space_id = ACPI_ADDRESS_SPACE_IO; |
| 957 | else if (res->flags & IORESOURCE_MEM) |
| 958 | address.space_id = ACPI_ADDRESS_SPACE_MEMORY; |
| 959 | else { |
| 960 | printk(BIOS_ERR, "%s: Unknown address space type\n", __func__); |
| 961 | return current; |
| 962 | } |
| 963 | |
| 964 | address.addrl = (uint32_t)res->base; |
| 965 | address.addrh = (uint32_t)((res->base >> 32) & 0xffffffff); |
| 966 | address.access_size = access_size; |
| 967 | |
| 968 | acpi_create_dbg2(dbg2, |
| 969 | ACPI_DBG2_PORT_SERIAL, |
| 970 | ACPI_DBG2_PORT_SERIAL_16550, |
| 971 | &address, res->size, |
| 972 | acpi_device_path(dev)); |
| 973 | |
| 974 | if (dbg2->header.length) { |
| 975 | current += dbg2->header.length; |
| 976 | current = acpi_align_current(current); |
| 977 | acpi_add_table(rsdp, dbg2); |
| 978 | } |
| 979 | |
| 980 | return current; |
| 981 | } |
| 982 | |
Stefan Reinauer | 777224c | 2005-01-19 14:06:41 +0000 | [diff] [blame] | 983 | void acpi_create_facs(acpi_facs_t *facs) |
Ronald G. Minnich | 02fa3b2 | 2004-10-06 17:33:54 +0000 | [diff] [blame] | 984 | { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 985 | memset((void *)facs, 0, sizeof(acpi_facs_t)); |
Ronald G. Minnich | 02fa3b2 | 2004-10-06 17:33:54 +0000 | [diff] [blame] | 986 | |
Stefan Reinauer | cdfe376 | 2009-07-21 22:15:43 +0000 | [diff] [blame] | 987 | memcpy(facs->signature, "FACS", 4); |
Ronald G. Minnich | 02fa3b2 | 2004-10-06 17:33:54 +0000 | [diff] [blame] | 988 | facs->length = sizeof(acpi_facs_t); |
| 989 | facs->hardware_signature = 0; |
| 990 | facs->firmware_waking_vector = 0; |
| 991 | facs->global_lock = 0; |
| 992 | facs->flags = 0; |
| 993 | facs->x_firmware_waking_vector_l = 0; |
| 994 | facs->x_firmware_waking_vector_h = 0; |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 995 | facs->version = get_acpi_table_revision(FACS); |
Ronald G. Minnich | 02fa3b2 | 2004-10-06 17:33:54 +0000 | [diff] [blame] | 996 | } |
Stefan Reinauer | 777224c | 2005-01-19 14:06:41 +0000 | [diff] [blame] | 997 | |
Vladimir Serbinenko | 351fefc | 2014-10-26 20:42:08 +0100 | [diff] [blame] | 998 | static void acpi_write_rsdt(acpi_rsdt_t *rsdt, char *oem_id, char *oem_table_id) |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 999 | { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1000 | acpi_header_t *header = &(rsdt->header); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 1001 | |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 1002 | if (!header) |
| 1003 | return; |
| 1004 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1005 | /* Fill out header fields. */ |
Stefan Reinauer | cdfe376 | 2009-07-21 22:15:43 +0000 | [diff] [blame] | 1006 | memcpy(header->signature, "RSDT", 4); |
Vladimir Serbinenko | 351fefc | 2014-10-26 20:42:08 +0100 | [diff] [blame] | 1007 | memcpy(header->oem_id, oem_id, 6); |
| 1008 | memcpy(header->oem_table_id, oem_table_id, 8); |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 1009 | memcpy(header->asl_compiler_id, ASLC, 4); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 1010 | |
Elyes HAOUAS | f8f2e8c | 2019-02-25 15:42:07 +0100 | [diff] [blame] | 1011 | header->asl_compiler_revision = asl_revision; |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 1012 | header->length = sizeof(acpi_rsdt_t); |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 1013 | header->revision = get_acpi_table_revision(RSDT); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 1014 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1015 | /* Entries are filled in later, we come with an empty set. */ |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 1016 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1017 | /* Fix checksum. */ |
Stefan Reinauer | b657a3c | 2009-07-21 21:38:33 +0000 | [diff] [blame] | 1018 | header->checksum = acpi_checksum((void *)rsdt, sizeof(acpi_rsdt_t)); |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 1019 | } |
| 1020 | |
Vladimir Serbinenko | 351fefc | 2014-10-26 20:42:08 +0100 | [diff] [blame] | 1021 | static void acpi_write_xsdt(acpi_xsdt_t *xsdt, char *oem_id, char *oem_table_id) |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 1022 | { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1023 | acpi_header_t *header = &(xsdt->header); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 1024 | |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 1025 | if (!header) |
| 1026 | return; |
| 1027 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1028 | /* Fill out header fields. */ |
Stefan Reinauer | cdfe376 | 2009-07-21 22:15:43 +0000 | [diff] [blame] | 1029 | memcpy(header->signature, "XSDT", 4); |
Vladimir Serbinenko | 351fefc | 2014-10-26 20:42:08 +0100 | [diff] [blame] | 1030 | memcpy(header->oem_id, oem_id, 6); |
| 1031 | memcpy(header->oem_table_id, oem_table_id, 8); |
Stefan Reinauer | b657a3c | 2009-07-21 21:38:33 +0000 | [diff] [blame] | 1032 | memcpy(header->asl_compiler_id, ASLC, 4); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 1033 | |
Elyes HAOUAS | f8f2e8c | 2019-02-25 15:42:07 +0100 | [diff] [blame] | 1034 | header->asl_compiler_revision = asl_revision; |
Stefan Reinauer | b657a3c | 2009-07-21 21:38:33 +0000 | [diff] [blame] | 1035 | header->length = sizeof(acpi_xsdt_t); |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 1036 | header->revision = get_acpi_table_revision(XSDT); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 1037 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1038 | /* Entries are filled in later, we come with an empty set. */ |
Stefan Reinauer | b657a3c | 2009-07-21 21:38:33 +0000 | [diff] [blame] | 1039 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1040 | /* Fix checksum. */ |
Stefan Reinauer | b657a3c | 2009-07-21 21:38:33 +0000 | [diff] [blame] | 1041 | header->checksum = acpi_checksum((void *)xsdt, sizeof(acpi_xsdt_t)); |
| 1042 | } |
| 1043 | |
Vladimir Serbinenko | 351fefc | 2014-10-26 20:42:08 +0100 | [diff] [blame] | 1044 | static void acpi_write_rsdp(acpi_rsdp_t *rsdp, acpi_rsdt_t *rsdt, |
| 1045 | acpi_xsdt_t *xsdt, char *oem_id) |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 1046 | { |
Stefan Reinauer | d18faac | 2009-11-05 18:06:43 +0000 | [diff] [blame] | 1047 | memset(rsdp, 0, sizeof(acpi_rsdp_t)); |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1048 | |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 1049 | memcpy(rsdp->signature, RSDP_SIG, 8); |
Vladimir Serbinenko | 351fefc | 2014-10-26 20:42:08 +0100 | [diff] [blame] | 1050 | memcpy(rsdp->oem_id, oem_id, 6); |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1051 | |
| 1052 | rsdp->length = sizeof(acpi_rsdp_t); |
Stefan Reinauer | defee17 | 2015-06-18 01:11:19 -0700 | [diff] [blame] | 1053 | rsdp->rsdt_address = (uintptr_t)rsdt; |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1054 | |
| 1055 | /* |
| 1056 | * Revision: ACPI 1.0: 0, ACPI 2.0/3.0/4.0: 2. |
| 1057 | * |
| 1058 | * Some OSes expect an XSDT to be present for RSD PTR revisions >= 2. |
| 1059 | * If we don't have an ACPI XSDT, force ACPI 1.0 (and thus RSD PTR |
| 1060 | * revision 0). |
Stefan Reinauer | b657a3c | 2009-07-21 21:38:33 +0000 | [diff] [blame] | 1061 | */ |
| 1062 | if (xsdt == NULL) { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1063 | rsdp->revision = 0; |
Stefan Reinauer | b657a3c | 2009-07-21 21:38:33 +0000 | [diff] [blame] | 1064 | } else { |
Stefan Reinauer | defee17 | 2015-06-18 01:11:19 -0700 | [diff] [blame] | 1065 | rsdp->xsdt_address = (u64)(uintptr_t)xsdt; |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 1066 | rsdp->revision = get_acpi_table_revision(RSDP); |
Stefan Reinauer | b657a3c | 2009-07-21 21:38:33 +0000 | [diff] [blame] | 1067 | } |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1068 | |
| 1069 | /* Calculate checksums. */ |
| 1070 | rsdp->checksum = acpi_checksum((void *)rsdp, 20); |
| 1071 | rsdp->ext_checksum = acpi_checksum((void *)rsdp, sizeof(acpi_rsdp_t)); |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 1072 | } |
| 1073 | |
Lee Leahy | 6f80ccc | 2017-03-16 15:18:22 -0700 | [diff] [blame] | 1074 | unsigned long acpi_create_hest_error_source(acpi_hest_t *hest, |
| 1075 | acpi_hest_esd_t *esd, u16 type, void *data, u16 data_len) |
zbao | caf494c8 | 2012-04-13 13:57:14 +0800 | [diff] [blame] | 1076 | { |
| 1077 | acpi_header_t *header = &(hest->header); |
| 1078 | acpi_hest_hen_t *hen; |
| 1079 | void *pos; |
| 1080 | u16 len; |
| 1081 | |
| 1082 | pos = esd; |
| 1083 | memset(pos, 0, sizeof(acpi_hest_esd_t)); |
| 1084 | len = 0; |
| 1085 | esd->type = type; /* MCE */ |
| 1086 | esd->source_id = hest->error_source_count; |
| 1087 | esd->flags = 0; /* FIRMWARE_FIRST */ |
| 1088 | esd->enabled = 1; |
| 1089 | esd->prealloc_erecords = 1; |
| 1090 | esd->max_section_per_record = 0x1; |
| 1091 | |
| 1092 | len += sizeof(acpi_hest_esd_t); |
| 1093 | pos = esd + 1; |
| 1094 | |
| 1095 | switch (type) { |
| 1096 | case 0: /* MCE */ |
| 1097 | break; |
| 1098 | case 1: /* CMC */ |
| 1099 | hen = (acpi_hest_hen_t *) (pos); |
| 1100 | memset(pos, 0, sizeof(acpi_hest_hen_t)); |
| 1101 | hen->type = 3; /* SCI? */ |
| 1102 | hen->length = sizeof(acpi_hest_hen_t); |
Lee Leahy | 6f80ccc | 2017-03-16 15:18:22 -0700 | [diff] [blame] | 1103 | hen->conf_we = 0; /* Configuration Write Enable. */ |
zbao | caf494c8 | 2012-04-13 13:57:14 +0800 | [diff] [blame] | 1104 | hen->poll_interval = 0; |
| 1105 | hen->vector = 0; |
| 1106 | hen->sw2poll_threshold_val = 0; |
| 1107 | hen->sw2poll_threshold_win = 0; |
| 1108 | hen->error_threshold_val = 0; |
| 1109 | hen->error_threshold_win = 0; |
| 1110 | len += sizeof(acpi_hest_hen_t); |
| 1111 | pos = hen + 1; |
| 1112 | break; |
| 1113 | case 2: /* NMI */ |
| 1114 | case 6: /* AER Root Port */ |
| 1115 | case 7: /* AER Endpoint */ |
| 1116 | case 8: /* AER Bridge */ |
| 1117 | case 9: /* Generic Hardware Error Source. */ |
| 1118 | /* TODO: */ |
| 1119 | break; |
| 1120 | default: |
| 1121 | printk(BIOS_DEBUG, "Invalid type of Error Source."); |
| 1122 | break; |
| 1123 | } |
Lee Leahy | 024b13d | 2017-03-16 13:41:11 -0700 | [diff] [blame] | 1124 | hest->error_source_count++; |
zbao | caf494c8 | 2012-04-13 13:57:14 +0800 | [diff] [blame] | 1125 | |
| 1126 | memcpy(pos, data, data_len); |
| 1127 | len += data_len; |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 1128 | if (header) |
| 1129 | header->length += len; |
zbao | caf494c8 | 2012-04-13 13:57:14 +0800 | [diff] [blame] | 1130 | |
| 1131 | return len; |
| 1132 | } |
| 1133 | |
| 1134 | /* ACPI 4.0 */ |
Vladimir Serbinenko | 807127f | 2014-11-09 13:36:18 +0100 | [diff] [blame] | 1135 | void acpi_write_hest(acpi_hest_t *hest, |
| 1136 | unsigned long (*acpi_fill_hest)(acpi_hest_t *hest)) |
zbao | caf494c8 | 2012-04-13 13:57:14 +0800 | [diff] [blame] | 1137 | { |
| 1138 | acpi_header_t *header = &(hest->header); |
| 1139 | |
| 1140 | memset(hest, 0, sizeof(acpi_hest_t)); |
| 1141 | |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 1142 | if (!header) |
| 1143 | return; |
| 1144 | |
zbao | caf494c8 | 2012-04-13 13:57:14 +0800 | [diff] [blame] | 1145 | memcpy(header->signature, "HEST", 4); |
| 1146 | memcpy(header->oem_id, OEM_ID, 6); |
| 1147 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 1148 | memcpy(header->asl_compiler_id, ASLC, 4); |
Elyes HAOUAS | f8f2e8c | 2019-02-25 15:42:07 +0100 | [diff] [blame] | 1149 | header->asl_compiler_revision = asl_revision; |
zbao | caf494c8 | 2012-04-13 13:57:14 +0800 | [diff] [blame] | 1150 | header->length += sizeof(acpi_hest_t); |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 1151 | header->revision = get_acpi_table_revision(HEST); |
zbao | caf494c8 | 2012-04-13 13:57:14 +0800 | [diff] [blame] | 1152 | |
| 1153 | acpi_fill_hest(hest); |
| 1154 | |
| 1155 | /* Calculate checksums. */ |
| 1156 | header->checksum = acpi_checksum((void *)hest, header->length); |
| 1157 | } |
| 1158 | |
Marshall Dawson | 1d8d369 | 2018-09-04 13:45:26 -0600 | [diff] [blame] | 1159 | /* ACPI 3.0b */ |
| 1160 | void acpi_write_bert(acpi_bert_t *bert, uintptr_t region, size_t length) |
| 1161 | { |
| 1162 | acpi_header_t *header = &(bert->header); |
| 1163 | |
| 1164 | memset(bert, 0, sizeof(acpi_bert_t)); |
| 1165 | |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 1166 | if (!header) |
| 1167 | return; |
| 1168 | |
Marshall Dawson | 1d8d369 | 2018-09-04 13:45:26 -0600 | [diff] [blame] | 1169 | memcpy(header->signature, "BERT", 4); |
| 1170 | memcpy(header->oem_id, OEM_ID, 6); |
| 1171 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 1172 | memcpy(header->asl_compiler_id, ASLC, 4); |
Elyes HAOUAS | f8f2e8c | 2019-02-25 15:42:07 +0100 | [diff] [blame] | 1173 | header->asl_compiler_revision = asl_revision; |
Marshall Dawson | 1d8d369 | 2018-09-04 13:45:26 -0600 | [diff] [blame] | 1174 | header->length += sizeof(acpi_bert_t); |
| 1175 | header->revision = get_acpi_table_revision(BERT); |
| 1176 | |
| 1177 | bert->error_region = region; |
| 1178 | bert->region_length = length; |
| 1179 | |
| 1180 | /* Calculate checksums. */ |
| 1181 | header->checksum = acpi_checksum((void *)bert, header->length); |
| 1182 | } |
| 1183 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 1184 | #if CONFIG(COMMON_FADT) |
Lee Leahy | 024b13d | 2017-03-16 13:41:11 -0700 | [diff] [blame] | 1185 | void acpi_create_fadt(acpi_fadt_t *fadt, acpi_facs_t *facs, void *dsdt) |
Vladimir Serbinenko | c21e073 | 2014-10-16 12:48:19 +0200 | [diff] [blame] | 1186 | { |
| 1187 | acpi_header_t *header = &(fadt->header); |
| 1188 | |
| 1189 | memset((void *) fadt, 0, sizeof(acpi_fadt_t)); |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 1190 | |
| 1191 | if (!header) |
| 1192 | return; |
| 1193 | |
Vladimir Serbinenko | c21e073 | 2014-10-16 12:48:19 +0200 | [diff] [blame] | 1194 | memcpy(header->signature, "FACP", 4); |
| 1195 | header->length = sizeof(acpi_fadt_t); |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 1196 | header->revision = get_acpi_table_revision(FADT); |
Vladimir Serbinenko | c21e073 | 2014-10-16 12:48:19 +0200 | [diff] [blame] | 1197 | memcpy(header->oem_id, OEM_ID, 6); |
| 1198 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 1199 | memcpy(header->asl_compiler_id, ASLC, 4); |
Elyes HAOUAS | 26071aa | 2019-02-15 08:21:33 +0100 | [diff] [blame] | 1200 | header->asl_compiler_revision = asl_revision; |
Vladimir Serbinenko | c21e073 | 2014-10-16 12:48:19 +0200 | [diff] [blame] | 1201 | |
| 1202 | fadt->firmware_ctrl = (unsigned long) facs; |
| 1203 | fadt->dsdt = (unsigned long) dsdt; |
| 1204 | |
| 1205 | fadt->x_firmware_ctl_l = (unsigned long)facs; |
| 1206 | fadt->x_firmware_ctl_h = 0; |
| 1207 | fadt->x_dsdt_l = (unsigned long)dsdt; |
| 1208 | fadt->x_dsdt_h = 0; |
| 1209 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 1210 | if (CONFIG(SYSTEM_TYPE_CONVERTIBLE) || |
| 1211 | CONFIG(SYSTEM_TYPE_LAPTOP)) |
Vladimir Serbinenko | c21e073 | 2014-10-16 12:48:19 +0200 | [diff] [blame] | 1212 | fadt->preferred_pm_profile = PM_MOBILE; |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 1213 | else if (CONFIG(SYSTEM_TYPE_DETACHABLE) || |
| 1214 | CONFIG(SYSTEM_TYPE_TABLET)) |
Duncan Laurie | fa9c6f1 | 2019-02-07 11:30:06 -0800 | [diff] [blame] | 1215 | fadt->preferred_pm_profile = PM_TABLET; |
Lee Leahy | 9c7c6f7 | 2017-03-16 11:24:09 -0700 | [diff] [blame] | 1216 | else |
Vladimir Serbinenko | c21e073 | 2014-10-16 12:48:19 +0200 | [diff] [blame] | 1217 | fadt->preferred_pm_profile = PM_DESKTOP; |
Vladimir Serbinenko | c21e073 | 2014-10-16 12:48:19 +0200 | [diff] [blame] | 1218 | |
Vladimir Serbinenko | ab83ef0 | 2014-10-25 15:18:25 +0200 | [diff] [blame] | 1219 | acpi_fill_fadt(fadt); |
Vladimir Serbinenko | c21e073 | 2014-10-16 12:48:19 +0200 | [diff] [blame] | 1220 | |
| 1221 | header->checksum = |
| 1222 | acpi_checksum((void *) fadt, header->length); |
| 1223 | } |
| 1224 | #endif |
| 1225 | |
Aaron Durbin | 6403167 | 2018-04-21 14:45:32 -0600 | [diff] [blame] | 1226 | unsigned long __weak fw_cfg_acpi_tables(unsigned long start) |
Vladimir Serbinenko | 41877d8 | 2014-09-01 22:18:01 +0200 | [diff] [blame] | 1227 | { |
| 1228 | return 0; |
| 1229 | } |
| 1230 | |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1231 | unsigned long write_acpi_tables(unsigned long start) |
| 1232 | { |
| 1233 | unsigned long current; |
| 1234 | acpi_rsdp_t *rsdp; |
| 1235 | acpi_rsdt_t *rsdt; |
| 1236 | acpi_xsdt_t *xsdt; |
| 1237 | acpi_fadt_t *fadt; |
| 1238 | acpi_facs_t *facs; |
Vladimir Serbinenko | 351fefc | 2014-10-26 20:42:08 +0100 | [diff] [blame] | 1239 | acpi_header_t *slic_file, *slic; |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1240 | acpi_header_t *ssdt; |
Vladimir Serbinenko | 36f8d27 | 2015-05-31 12:31:59 +0200 | [diff] [blame] | 1241 | acpi_header_t *dsdt_file, *dsdt; |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1242 | acpi_mcfg_t *mcfg; |
Vladimir Serbinenko | f44ac13 | 2015-05-20 19:52:01 +0200 | [diff] [blame] | 1243 | acpi_tcpa_t *tcpa; |
Philipp Deppenwiese | 296164e0 | 2018-10-18 15:39:34 +0200 | [diff] [blame] | 1244 | acpi_tpm2_t *tpm2; |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1245 | acpi_madt_t *madt; |
Edward O'Callaghan | 2c9d2cf | 2014-10-27 23:29:29 +1100 | [diff] [blame] | 1246 | struct device *dev; |
Vladimir Serbinenko | 41877d8 | 2014-09-01 22:18:01 +0200 | [diff] [blame] | 1247 | unsigned long fw; |
Vladimir Serbinenko | 36f8d27 | 2015-05-31 12:31:59 +0200 | [diff] [blame] | 1248 | size_t slic_size, dsdt_size; |
Vladimir Serbinenko | 351fefc | 2014-10-26 20:42:08 +0100 | [diff] [blame] | 1249 | char oem_id[6], oem_table_id[8]; |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1250 | |
| 1251 | current = start; |
| 1252 | |
| 1253 | /* Align ACPI tables to 16byte */ |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame] | 1254 | current = acpi_align_current(current); |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1255 | |
Patrick Rudolph | cfe08ff | 2019-09-10 15:40:47 +0200 | [diff] [blame] | 1256 | /* Special case for qemu */ |
Vladimir Serbinenko | 41877d8 | 2014-09-01 22:18:01 +0200 | [diff] [blame] | 1257 | fw = fw_cfg_acpi_tables(current); |
Patrick Rudolph | cfe08ff | 2019-09-10 15:40:47 +0200 | [diff] [blame] | 1258 | if (fw) { |
| 1259 | rsdp = NULL; |
| 1260 | /* Find RSDP. */ |
| 1261 | for (void *p = (void *)current; p < (void *)fw; p += 16) { |
| 1262 | if (valid_rsdp((acpi_rsdp_t *)p)) { |
| 1263 | rsdp = p; |
| 1264 | break; |
| 1265 | } |
| 1266 | } |
| 1267 | if (!rsdp) |
| 1268 | return fw; |
| 1269 | |
| 1270 | /* Add BOOT0000 for Linux google firmware driver */ |
| 1271 | printk(BIOS_DEBUG, "ACPI: * SSDT\n"); |
| 1272 | ssdt = (acpi_header_t *)fw; |
| 1273 | current = (unsigned long)ssdt + sizeof(acpi_header_t); |
| 1274 | |
| 1275 | memset((void *)ssdt, 0, sizeof(acpi_header_t)); |
| 1276 | |
| 1277 | memcpy(&ssdt->signature, "SSDT", 4); |
| 1278 | ssdt->revision = get_acpi_table_revision(SSDT); |
| 1279 | memcpy(&ssdt->oem_id, OEM_ID, 6); |
| 1280 | memcpy(&ssdt->oem_table_id, oem_table_id, 8); |
| 1281 | ssdt->oem_revision = 42; |
| 1282 | memcpy(&ssdt->asl_compiler_id, ASLC, 4); |
| 1283 | ssdt->asl_compiler_revision = asl_revision; |
| 1284 | ssdt->length = sizeof(acpi_header_t); |
| 1285 | |
| 1286 | acpigen_set_current((char *) current); |
| 1287 | |
| 1288 | /* Write object to declare coreboot tables */ |
| 1289 | acpi_ssdt_write_cbtable(); |
| 1290 | |
| 1291 | /* (Re)calculate length and checksum. */ |
| 1292 | ssdt->length = current - (unsigned long)ssdt; |
| 1293 | ssdt->checksum = acpi_checksum((void *)ssdt, ssdt->length); |
| 1294 | |
| 1295 | acpi_create_ssdt_generator(ssdt, ACPI_TABLE_CREATOR); |
| 1296 | |
| 1297 | acpi_add_table(rsdp, ssdt); |
| 1298 | |
Vladimir Serbinenko | 41877d8 | 2014-09-01 22:18:01 +0200 | [diff] [blame] | 1299 | return fw; |
Patrick Rudolph | cfe08ff | 2019-09-10 15:40:47 +0200 | [diff] [blame] | 1300 | } |
Vladimir Serbinenko | 41877d8 | 2014-09-01 22:18:01 +0200 | [diff] [blame] | 1301 | |
Vladimir Serbinenko | a4cf83d | 2015-06-02 21:40:29 +0200 | [diff] [blame] | 1302 | dsdt_file = cbfs_boot_map_with_leak( |
Vladimir Serbinenko | 36f8d27 | 2015-05-31 12:31:59 +0200 | [diff] [blame] | 1303 | CONFIG_CBFS_PREFIX "/dsdt.aml", |
| 1304 | CBFS_TYPE_RAW, &dsdt_size); |
| 1305 | if (!dsdt_file) { |
| 1306 | printk(BIOS_ERR, "No DSDT file, skipping ACPI tables\n"); |
| 1307 | return current; |
| 1308 | } |
| 1309 | |
| 1310 | if (dsdt_file->length > dsdt_size |
Elyes HAOUAS | 7d87e76 | 2016-10-03 22:11:07 +0200 | [diff] [blame] | 1311 | || dsdt_file->length < sizeof(acpi_header_t) |
Vladimir Serbinenko | 36f8d27 | 2015-05-31 12:31:59 +0200 | [diff] [blame] | 1312 | || memcmp(dsdt_file->signature, "DSDT", 4) != 0) { |
| 1313 | printk(BIOS_ERR, "Invalid DSDT file, skipping ACPI tables\n"); |
| 1314 | return current; |
| 1315 | } |
| 1316 | |
Aaron Durbin | 899d13d | 2015-05-15 23:39:23 -0500 | [diff] [blame] | 1317 | slic_file = cbfs_boot_map_with_leak(CONFIG_CBFS_PREFIX "/slic", |
Vladimir Serbinenko | 351fefc | 2014-10-26 20:42:08 +0100 | [diff] [blame] | 1318 | CBFS_TYPE_RAW, &slic_size); |
Vladimir Serbinenko | 2cb2978 | 2015-05-31 11:32:09 +0200 | [diff] [blame] | 1319 | if (slic_file |
| 1320 | && (slic_file->length > slic_size |
Elyes HAOUAS | 7d87e76 | 2016-10-03 22:11:07 +0200 | [diff] [blame] | 1321 | || slic_file->length < sizeof(acpi_header_t) |
Vladimir Serbinenko | 2cb2978 | 2015-05-31 11:32:09 +0200 | [diff] [blame] | 1322 | || memcmp(slic_file->signature, "SLIC", 4) != 0)) { |
Vladimir Serbinenko | 351fefc | 2014-10-26 20:42:08 +0100 | [diff] [blame] | 1323 | slic_file = 0; |
| 1324 | } |
| 1325 | |
| 1326 | if (slic_file) { |
| 1327 | memcpy(oem_id, slic_file->oem_id, 6); |
| 1328 | memcpy(oem_table_id, slic_file->oem_table_id, 8); |
| 1329 | } else { |
| 1330 | memcpy(oem_id, OEM_ID, 6); |
| 1331 | memcpy(oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 1332 | } |
| 1333 | |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1334 | printk(BIOS_INFO, "ACPI: Writing ACPI tables at %lx.\n", start); |
| 1335 | |
| 1336 | /* We need at least an RSDP and an RSDT Table */ |
| 1337 | rsdp = (acpi_rsdp_t *) current; |
| 1338 | current += sizeof(acpi_rsdp_t); |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame] | 1339 | current = acpi_align_current(current); |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1340 | rsdt = (acpi_rsdt_t *) current; |
| 1341 | current += sizeof(acpi_rsdt_t); |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame] | 1342 | current = acpi_align_current(current); |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1343 | xsdt = (acpi_xsdt_t *) current; |
| 1344 | current += sizeof(acpi_xsdt_t); |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame] | 1345 | current = acpi_align_current(current); |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1346 | |
| 1347 | /* clear all table memory */ |
| 1348 | memset((void *) start, 0, current - start); |
| 1349 | |
Vladimir Serbinenko | 351fefc | 2014-10-26 20:42:08 +0100 | [diff] [blame] | 1350 | acpi_write_rsdp(rsdp, rsdt, xsdt, oem_id); |
| 1351 | acpi_write_rsdt(rsdt, oem_id, oem_table_id); |
| 1352 | acpi_write_xsdt(xsdt, oem_id, oem_table_id); |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1353 | |
| 1354 | printk(BIOS_DEBUG, "ACPI: * FACS\n"); |
Felix Held | c469712 | 2019-06-20 13:50:17 +0200 | [diff] [blame] | 1355 | current = ALIGN_UP(current, 64); |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1356 | facs = (acpi_facs_t *) current; |
| 1357 | current += sizeof(acpi_facs_t); |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame] | 1358 | current = acpi_align_current(current); |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1359 | acpi_create_facs(facs); |
| 1360 | |
| 1361 | printk(BIOS_DEBUG, "ACPI: * DSDT\n"); |
| 1362 | dsdt = (acpi_header_t *) current; |
Vladimir Serbinenko | 36f8d27 | 2015-05-31 12:31:59 +0200 | [diff] [blame] | 1363 | memcpy(dsdt, dsdt_file, sizeof(acpi_header_t)); |
Vladimir Serbinenko | 334fd8e | 2014-10-05 11:10:35 +0200 | [diff] [blame] | 1364 | if (dsdt->length >= sizeof(acpi_header_t)) { |
| 1365 | current += sizeof(acpi_header_t); |
| 1366 | |
| 1367 | acpigen_set_current((char *) current); |
| 1368 | for (dev = all_devices; dev; dev = dev->next) |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame] | 1369 | if (dev->ops && dev->ops->acpi_inject_dsdt) |
| 1370 | dev->ops->acpi_inject_dsdt(dev); |
Vladimir Serbinenko | 334fd8e | 2014-10-05 11:10:35 +0200 | [diff] [blame] | 1371 | current = (unsigned long) acpigen_get_current(); |
| 1372 | memcpy((char *)current, |
Vladimir Serbinenko | 36f8d27 | 2015-05-31 12:31:59 +0200 | [diff] [blame] | 1373 | (char *)dsdt_file + sizeof(acpi_header_t), |
Vladimir Serbinenko | 334fd8e | 2014-10-05 11:10:35 +0200 | [diff] [blame] | 1374 | dsdt->length - sizeof(acpi_header_t)); |
| 1375 | current += dsdt->length - sizeof(acpi_header_t); |
| 1376 | |
| 1377 | /* (Re)calculate length and checksum. */ |
| 1378 | dsdt->length = current - (unsigned long)dsdt; |
| 1379 | dsdt->checksum = 0; |
| 1380 | dsdt->checksum = acpi_checksum((void *)dsdt, dsdt->length); |
| 1381 | } |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1382 | |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame] | 1383 | current = acpi_align_current(current); |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1384 | |
| 1385 | printk(BIOS_DEBUG, "ACPI: * FADT\n"); |
| 1386 | fadt = (acpi_fadt_t *) current; |
| 1387 | current += sizeof(acpi_fadt_t); |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame] | 1388 | current = acpi_align_current(current); |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1389 | |
| 1390 | acpi_create_fadt(fadt, facs, dsdt); |
| 1391 | acpi_add_table(rsdp, fadt); |
| 1392 | |
Vladimir Serbinenko | 351fefc | 2014-10-26 20:42:08 +0100 | [diff] [blame] | 1393 | if (slic_file) { |
| 1394 | printk(BIOS_DEBUG, "ACPI: * SLIC\n"); |
| 1395 | slic = (acpi_header_t *)current; |
| 1396 | memcpy(slic, slic_file, slic_file->length); |
| 1397 | current += slic_file->length; |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame] | 1398 | current = acpi_align_current(current); |
Vladimir Serbinenko | 351fefc | 2014-10-26 20:42:08 +0100 | [diff] [blame] | 1399 | acpi_add_table(rsdp, slic); |
| 1400 | } |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1401 | |
| 1402 | printk(BIOS_DEBUG, "ACPI: * SSDT\n"); |
| 1403 | ssdt = (acpi_header_t *)current; |
| 1404 | acpi_create_ssdt_generator(ssdt, ACPI_TABLE_CREATOR); |
Vladimir Serbinenko | 9310df8 | 2014-10-10 20:40:41 +0200 | [diff] [blame] | 1405 | if (ssdt->length > sizeof(acpi_header_t)) { |
| 1406 | current += ssdt->length; |
| 1407 | acpi_add_table(rsdp, ssdt); |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame] | 1408 | current = acpi_align_current(current); |
Vladimir Serbinenko | 9310df8 | 2014-10-10 20:40:41 +0200 | [diff] [blame] | 1409 | } |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1410 | |
| 1411 | printk(BIOS_DEBUG, "ACPI: * MCFG\n"); |
| 1412 | mcfg = (acpi_mcfg_t *) current; |
| 1413 | acpi_create_mcfg(mcfg); |
| 1414 | if (mcfg->header.length > sizeof(acpi_mcfg_t)) { |
| 1415 | current += mcfg->header.length; |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame] | 1416 | current = acpi_align_current(current); |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1417 | acpi_add_table(rsdp, mcfg); |
| 1418 | } |
| 1419 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 1420 | if (CONFIG(TPM1)) { |
Philipp Deppenwiese | 296164e0 | 2018-10-18 15:39:34 +0200 | [diff] [blame] | 1421 | printk(BIOS_DEBUG, "ACPI: * TCPA\n"); |
| 1422 | tcpa = (acpi_tcpa_t *) current; |
| 1423 | acpi_create_tcpa(tcpa); |
| 1424 | if (tcpa->header.length >= sizeof(acpi_tcpa_t)) { |
| 1425 | current += tcpa->header.length; |
| 1426 | current = acpi_align_current(current); |
| 1427 | acpi_add_table(rsdp, tcpa); |
| 1428 | } |
| 1429 | } |
| 1430 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 1431 | if (CONFIG(TPM2)) { |
Philipp Deppenwiese | 296164e0 | 2018-10-18 15:39:34 +0200 | [diff] [blame] | 1432 | printk(BIOS_DEBUG, "ACPI: * TPM2\n"); |
| 1433 | tpm2 = (acpi_tpm2_t *) current; |
| 1434 | acpi_create_tpm2(tpm2); |
| 1435 | if (tpm2->header.length >= sizeof(acpi_tpm2_t)) { |
| 1436 | current += tpm2->header.length; |
| 1437 | current = acpi_align_current(current); |
| 1438 | acpi_add_table(rsdp, tpm2); |
| 1439 | } |
Vladimir Serbinenko | f44ac13 | 2015-05-20 19:52:01 +0200 | [diff] [blame] | 1440 | } |
| 1441 | |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1442 | printk(BIOS_DEBUG, "ACPI: * MADT\n"); |
| 1443 | |
| 1444 | madt = (acpi_madt_t *) current; |
| 1445 | acpi_create_madt(madt); |
| 1446 | if (madt->header.length > sizeof(acpi_madt_t)) { |
Lee Leahy | 024b13d | 2017-03-16 13:41:11 -0700 | [diff] [blame] | 1447 | current += madt->header.length; |
| 1448 | acpi_add_table(rsdp, madt); |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1449 | } |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame] | 1450 | current = acpi_align_current(current); |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1451 | |
| 1452 | printk(BIOS_DEBUG, "current = %lx\n", current); |
| 1453 | |
| 1454 | for (dev = all_devices; dev; dev = dev->next) { |
| 1455 | if (dev->ops && dev->ops->write_acpi_tables) { |
Lee Leahy | 6f80ccc | 2017-03-16 15:18:22 -0700 | [diff] [blame] | 1456 | current = dev->ops->write_acpi_tables(dev, current, |
| 1457 | rsdp); |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame] | 1458 | current = acpi_align_current(current); |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1459 | } |
| 1460 | } |
| 1461 | |
| 1462 | printk(BIOS_INFO, "ACPI: done.\n"); |
| 1463 | return current; |
| 1464 | } |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1465 | |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 1466 | static acpi_rsdp_t *valid_rsdp(acpi_rsdp_t *rsdp) |
| 1467 | { |
| 1468 | if (strncmp((char *)rsdp, RSDP_SIG, sizeof(RSDP_SIG) - 1) != 0) |
| 1469 | return NULL; |
| 1470 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 1471 | printk(BIOS_DEBUG, "Looking on %p for valid checksum\n", rsdp); |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 1472 | |
| 1473 | if (acpi_checksum((void *)rsdp, 20) != 0) |
| 1474 | return NULL; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 1475 | printk(BIOS_DEBUG, "Checksum 1 passed\n"); |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 1476 | |
| 1477 | if ((rsdp->revision > 1) && (acpi_checksum((void *)rsdp, |
| 1478 | rsdp->length) != 0)) |
| 1479 | return NULL; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 1480 | printk(BIOS_DEBUG, "Checksum 2 passed all OK\n"); |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 1481 | |
| 1482 | return rsdp; |
| 1483 | } |
| 1484 | |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 1485 | void *acpi_find_wakeup_vector(void) |
| 1486 | { |
| 1487 | char *p, *end; |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 1488 | acpi_rsdt_t *rsdt; |
| 1489 | acpi_facs_t *facs; |
Martin Roth | c5f4926 | 2012-12-14 19:17:55 -0700 | [diff] [blame] | 1490 | acpi_fadt_t *fadt = NULL; |
Kyösti Mälkki | 072d436b | 2016-06-17 08:44:40 +0300 | [diff] [blame] | 1491 | acpi_rsdp_t *rsdp = NULL; |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1492 | void *wake_vec; |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 1493 | int i; |
| 1494 | |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 1495 | if (!acpi_is_wakeup()) |
| 1496 | return NULL; |
| 1497 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1498 | printk(BIOS_DEBUG, "Trying to find the wakeup vector...\n"); |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 1499 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1500 | /* Find RSDP. */ |
| 1501 | for (p = (char *)0xe0000; p < (char *)0xfffff; p += 16) { |
Lee Leahy | 0b5678f | 2017-03-16 16:01:40 -0700 | [diff] [blame] | 1502 | rsdp = valid_rsdp((acpi_rsdp_t *)p); |
| 1503 | if (rsdp) |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 1504 | break; |
| 1505 | } |
| 1506 | |
Angel Pons | 98a68ad | 2018-11-04 12:25:25 +0100 | [diff] [blame] | 1507 | if (rsdp == NULL) { |
| 1508 | printk(BIOS_ALERT, |
| 1509 | "No RSDP found, wake up from S3 not possible.\n"); |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 1510 | return NULL; |
Angel Pons | 98a68ad | 2018-11-04 12:25:25 +0100 | [diff] [blame] | 1511 | } |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 1512 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 1513 | printk(BIOS_DEBUG, "RSDP found at %p\n", rsdp); |
Stefan Reinauer | 71a3018 | 2015-07-30 16:28:13 -0700 | [diff] [blame] | 1514 | rsdt = (acpi_rsdt_t *)(uintptr_t)rsdp->rsdt_address; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 1515 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1516 | end = (char *)rsdt + rsdt->header.length; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 1517 | printk(BIOS_DEBUG, "RSDT found at %p ends at %p\n", rsdt, end); |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 1518 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1519 | for (i = 0; ((char *)&rsdt->entry[i]) < end; i++) { |
Stefan Reinauer | 71a3018 | 2015-07-30 16:28:13 -0700 | [diff] [blame] | 1520 | fadt = (acpi_fadt_t *)(uintptr_t)rsdt->entry[i]; |
Stefan Reinauer | cdfe376 | 2009-07-21 22:15:43 +0000 | [diff] [blame] | 1521 | if (strncmp((char *)fadt, "FACP", 4) == 0) |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 1522 | break; |
| 1523 | fadt = NULL; |
| 1524 | } |
| 1525 | |
Angel Pons | 98a68ad | 2018-11-04 12:25:25 +0100 | [diff] [blame] | 1526 | if (fadt == NULL) { |
| 1527 | printk(BIOS_ALERT, |
| 1528 | "No FADT found, wake up from S3 not possible.\n"); |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 1529 | return NULL; |
Angel Pons | 98a68ad | 2018-11-04 12:25:25 +0100 | [diff] [blame] | 1530 | } |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 1531 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 1532 | printk(BIOS_DEBUG, "FADT found at %p\n", fadt); |
Stefan Reinauer | 71a3018 | 2015-07-30 16:28:13 -0700 | [diff] [blame] | 1533 | facs = (acpi_facs_t *)(uintptr_t)fadt->firmware_ctrl; |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 1534 | |
Stefan Reinauer | 7e9771c | 2009-04-22 08:17:38 +0000 | [diff] [blame] | 1535 | if (facs == NULL) { |
Angel Pons | 98a68ad | 2018-11-04 12:25:25 +0100 | [diff] [blame] | 1536 | printk(BIOS_ALERT, |
| 1537 | "No FACS found, wake up from S3 not possible.\n"); |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 1538 | return NULL; |
Stefan Reinauer | 7e9771c | 2009-04-22 08:17:38 +0000 | [diff] [blame] | 1539 | } |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 1540 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 1541 | printk(BIOS_DEBUG, "FACS found at %p\n", facs); |
Stefan Reinauer | 71a3018 | 2015-07-30 16:28:13 -0700 | [diff] [blame] | 1542 | wake_vec = (void *)(uintptr_t)facs->firmware_waking_vector; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 1543 | printk(BIOS_DEBUG, "OS waking vector is %p\n", wake_vec); |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1544 | |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 1545 | return wake_vec; |
| 1546 | } |
| 1547 | |
Aaron Durbin | 6403167 | 2018-04-21 14:45:32 -0600 | [diff] [blame] | 1548 | __weak int acpi_get_gpe(int gpe) |
Duncan Laurie | 1f6e681 | 2016-09-19 12:04:19 -0700 | [diff] [blame] | 1549 | { |
| 1550 | return -1; /* implemented by SOC */ |
| 1551 | } |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 1552 | |
| 1553 | int get_acpi_table_revision(enum acpi_tables table) |
| 1554 | { |
| 1555 | switch (table) { |
| 1556 | case FADT: |
Matt DeVillier | 8bee86ef2 | 2020-03-04 18:14:54 -0600 | [diff] [blame] | 1557 | return ACPI_FADT_REV_ACPI_3_0; |
Elyes HAOUAS | f288b39 | 2018-11-11 15:22:30 +0100 | [diff] [blame] | 1558 | case MADT: /* ACPI 3.0: 2, ACPI 4.0/5.0: 3, ACPI 6.2b/6.3: 5 */ |
Marc Jones | 4ddd476 | 2018-08-21 10:50:57 -0600 | [diff] [blame] | 1559 | return 2; |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 1560 | case MCFG: |
| 1561 | return 1; |
| 1562 | case TCPA: |
| 1563 | return 2; |
Philipp Deppenwiese | 296164e0 | 2018-10-18 15:39:34 +0200 | [diff] [blame] | 1564 | case TPM2: |
| 1565 | return 4; |
Elyes HAOUAS | f288b39 | 2018-11-11 15:22:30 +0100 | [diff] [blame] | 1566 | case SSDT: /* ACPI 3.0 upto 6.3: 2 */ |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 1567 | return 2; |
Elyes HAOUAS | f288b39 | 2018-11-11 15:22:30 +0100 | [diff] [blame] | 1568 | case SRAT: /* ACPI 2.0: 1, ACPI 3.0: 2, ACPI 4.0 upto 6.3: 3 */ |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 1569 | return 1; /* TODO Should probably be upgraded to 2 */ |
| 1570 | case DMAR: |
| 1571 | return 1; |
Elyes HAOUAS | f288b39 | 2018-11-11 15:22:30 +0100 | [diff] [blame] | 1572 | case SLIT: /* ACPI 2.0 upto 6.3: 1 */ |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 1573 | return 1; |
Patrick Rudolph | 9d98e5a | 2019-06-14 19:00:04 +0200 | [diff] [blame] | 1574 | case SPMI: /* IMPI 2.0 */ |
| 1575 | return 5; |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 1576 | case HPET: /* Currently 1. Table added in ACPI 2.0. */ |
| 1577 | return 1; |
Elyes HAOUAS | f288b39 | 2018-11-11 15:22:30 +0100 | [diff] [blame] | 1578 | case VFCT: /* ACPI 2.0/3.0/4.0: 1 */ |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 1579 | return 1; |
| 1580 | case IVRS: |
| 1581 | return IVRS_FORMAT_FIXED; |
| 1582 | case DBG2: |
| 1583 | return 0; |
Elyes HAOUAS | f288b39 | 2018-11-11 15:22:30 +0100 | [diff] [blame] | 1584 | case FACS: /* ACPI 2.0/3.0: 1, ACPI 4.0 upto 6.3: 2 */ |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 1585 | return 1; |
Elyes HAOUAS | f288b39 | 2018-11-11 15:22:30 +0100 | [diff] [blame] | 1586 | case RSDT: /* ACPI 1.0 upto 6.3: 1 */ |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 1587 | return 1; |
Elyes HAOUAS | f288b39 | 2018-11-11 15:22:30 +0100 | [diff] [blame] | 1588 | case XSDT: /* ACPI 2.0 upto 6.3: 1 */ |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 1589 | return 1; |
Elyes HAOUAS | f288b39 | 2018-11-11 15:22:30 +0100 | [diff] [blame] | 1590 | case RSDP: /* ACPI 2.0 upto 6.3: 2 */ |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 1591 | return 2; |
| 1592 | case HEST: |
| 1593 | return 1; |
| 1594 | case NHLT: |
| 1595 | return 5; |
Marshall Dawson | 44705c6 | 2018-09-04 13:47:15 -0600 | [diff] [blame] | 1596 | case BERT: |
| 1597 | return 1; |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 1598 | default: |
| 1599 | return -1; |
| 1600 | } |
| 1601 | return -1; |
| 1602 | } |