Patrick Georgi | 11f0079 | 2020-03-04 15:10:45 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 2 | /* |
Martin Roth | 20bbd81 | 2019-08-30 21:09:37 -0600 | [diff] [blame] | 3 | * coreboot ACPI Table support |
Stefan Reinauer | 777224c | 2005-01-19 14:06:41 +0000 | [diff] [blame] | 4 | */ |
| 5 | |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 6 | /* |
Stefan Reinauer | 777224c | 2005-01-19 14:06:41 +0000 | [diff] [blame] | 7 | * Each system port implementing ACPI has to provide two functions: |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 8 | * |
Stefan Reinauer | 777224c | 2005-01-19 14:06:41 +0000 | [diff] [blame] | 9 | * write_acpi_tables() |
| 10 | * acpi_dump_apics() |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 11 | * |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 12 | * See Kontron 986LCD-M port for a good example of an ACPI implementation |
| 13 | * in coreboot. |
Ronald G. Minnich | 02fa3b2 | 2004-10-06 17:33:54 +0000 | [diff] [blame] | 14 | */ |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 15 | |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 16 | #include <acpi/acpi.h> |
| 17 | #include <acpi/acpi_ivrs.h> |
| 18 | #include <acpi/acpigen.h> |
Felix Held | 972d9f2 | 2022-02-23 16:32:20 +0100 | [diff] [blame] | 19 | #include <arch/hpet.h> |
Kyösti Mälkki | ae1b2d4 | 2023-04-10 16:45:39 +0300 | [diff] [blame] | 20 | #include <arch/smp/mpspec.h> |
Jianjun Wang | 8565b94a | 2022-03-02 10:20:26 +0800 | [diff] [blame] | 21 | #include <cbfs.h> |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 22 | #include <cbmem.h> |
Elyes HAOUAS | e2d152c | 2019-06-21 07:06:50 +0200 | [diff] [blame] | 23 | #include <commonlib/helpers.h> |
Jianjun Wang | 8565b94a | 2022-03-02 10:20:26 +0800 | [diff] [blame] | 24 | #include <commonlib/sort.h> |
| 25 | #include <console/console.h> |
Duncan Laurie | 11290c4 | 2012-10-03 19:07:05 -0700 | [diff] [blame] | 26 | #include <cpu/cpu.h> |
Jianjun Wang | 8565b94a | 2022-03-02 10:20:26 +0800 | [diff] [blame] | 27 | #include <device/mmio.h> |
| 28 | #include <device/pci.h> |
| 29 | #include <pc80/mc146818rtc.h> |
| 30 | #include <string.h> |
Elyes HAOUAS | cdd2f63 | 2021-02-11 19:37:11 +0100 | [diff] [blame] | 31 | #include <types.h> |
Elyes HAOUAS | 26071aa | 2019-02-15 08:21:33 +0100 | [diff] [blame] | 32 | #include <version.h> |
Ronald G. Minnich | 02fa3b2 | 2004-10-06 17:33:54 +0000 | [diff] [blame] | 33 | |
Kyösti Mälkki | c7da027 | 2021-06-08 11:37:08 +0300 | [diff] [blame] | 34 | #if ENV_X86 |
| 35 | #include <arch/ioapic.h> |
| 36 | #endif |
| 37 | |
Patrick Rudolph | cfe08ff | 2019-09-10 15:40:47 +0200 | [diff] [blame] | 38 | static acpi_rsdp_t *valid_rsdp(acpi_rsdp_t *rsdp); |
| 39 | |
Ronald G. Minnich | 02fa3b2 | 2004-10-06 17:33:54 +0000 | [diff] [blame] | 40 | u8 acpi_checksum(u8 *table, u32 length) |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 41 | { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 42 | u8 ret = 0; |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 43 | while (length--) { |
| 44 | ret += *table; |
| 45 | table++; |
| 46 | } |
Stefan Reinauer | a7648c2 | 2004-01-29 17:31:34 +0000 | [diff] [blame] | 47 | return -ret; |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 48 | } |
| 49 | |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 50 | /** |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 51 | * Add an ACPI table to the RSDT (and XSDT) structure, recalculate length |
| 52 | * and checksum. |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 53 | */ |
Stefan Reinauer | b657a3c | 2009-07-21 21:38:33 +0000 | [diff] [blame] | 54 | void acpi_add_table(acpi_rsdp_t *rsdp, void *table) |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 55 | { |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 56 | int i, entries_num; |
Stefan Reinauer | b657a3c | 2009-07-21 21:38:33 +0000 | [diff] [blame] | 57 | acpi_rsdt_t *rsdt; |
| 58 | acpi_xsdt_t *xsdt = NULL; |
| 59 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 60 | /* The RSDT is mandatory... */ |
Stefan Reinauer | defee17 | 2015-06-18 01:11:19 -0700 | [diff] [blame] | 61 | rsdt = (acpi_rsdt_t *)(uintptr_t)rsdp->rsdt_address; |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 62 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 63 | /* ...while the XSDT is not. */ |
| 64 | if (rsdp->xsdt_address) |
Stefan Reinauer | defee17 | 2015-06-18 01:11:19 -0700 | [diff] [blame] | 65 | xsdt = (acpi_xsdt_t *)((uintptr_t)rsdp->xsdt_address); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 66 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 67 | /* This should always be MAX_ACPI_TABLES. */ |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 68 | entries_num = ARRAY_SIZE(rsdt->entry); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 69 | |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 70 | for (i = 0; i < entries_num; i++) { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 71 | if (rsdt->entry[i] == 0) |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 72 | break; |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 73 | } |
| 74 | |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 75 | if (i >= entries_num) { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 76 | 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] | 77 | "too many tables.\n"); |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 78 | return; |
| 79 | } |
| 80 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 81 | /* Add table to the RSDT. */ |
Stefan Reinauer | defee17 | 2015-06-18 01:11:19 -0700 | [diff] [blame] | 82 | rsdt->entry[i] = (uintptr_t)table; |
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 | /* Fix RSDT length or the kernel will assume invalid entries. */ |
| 85 | rsdt->header.length = sizeof(acpi_header_t) + (sizeof(u32) * (i + 1)); |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 86 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 87 | /* Re-calculate checksum. */ |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 88 | rsdt->header.checksum = 0; /* Hope this won't get optimized away */ |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 89 | rsdt->header.checksum = acpi_checksum((u8 *)rsdt, rsdt->header.length); |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 90 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 91 | /* |
| 92 | * 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] | 93 | * now we want the XSDT and RSDT to always be in sync in coreboot. |
| 94 | */ |
| 95 | if (xsdt) { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 96 | /* Add table to the XSDT. */ |
Stefan Reinauer | defee17 | 2015-06-18 01:11:19 -0700 | [diff] [blame] | 97 | xsdt->entry[i] = (u64)(uintptr_t)table; |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 98 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 99 | /* Fix XSDT length. */ |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 100 | xsdt->header.length = sizeof(acpi_header_t) + |
Cristian Măgherușan-Stanciu | ba48281 | 2011-07-02 00:57:07 +0300 | [diff] [blame] | 101 | (sizeof(u64) * (i + 1)); |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 102 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 103 | /* Re-calculate checksum. */ |
| 104 | xsdt->header.checksum = 0; |
| 105 | xsdt->header.checksum = acpi_checksum((u8 *)xsdt, |
Cristian Măgherușan-Stanciu | ba48281 | 2011-07-02 00:57:07 +0300 | [diff] [blame] | 106 | xsdt->header.length); |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 107 | } |
| 108 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 109 | 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] | 110 | i + 1, entries_num, rsdt->header.length); |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 111 | } |
| 112 | |
Arthur Heymans | 9362dd7 | 2023-06-08 19:56:51 +0200 | [diff] [blame^] | 113 | static 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] | 114 | u16 seg_nr, u8 start, u8 end) |
Stefan Reinauer | 26d431a | 2009-01-20 19:17:51 +0000 | [diff] [blame] | 115 | { |
Vladimir Serbinenko | 60fccdc | 2014-10-05 11:05:16 +0200 | [diff] [blame] | 116 | memset(mmconfig, 0, sizeof(*mmconfig)); |
Rudolf Marek | e6409f2 | 2007-11-03 12:50:26 +0000 | [diff] [blame] | 117 | mmconfig->base_address = base; |
| 118 | mmconfig->base_reserved = 0; |
| 119 | mmconfig->pci_segment_group_number = seg_nr; |
| 120 | mmconfig->start_bus_number = start; |
| 121 | mmconfig->end_bus_number = end; |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 122 | |
| 123 | return sizeof(acpi_mcfg_mmconfig_t); |
Rudolf Marek | e6409f2 | 2007-11-03 12:50:26 +0000 | [diff] [blame] | 124 | } |
| 125 | |
Kyösti Mälkki | 2e9f0d3 | 2023-04-07 23:05:46 +0300 | [diff] [blame] | 126 | static 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] | 127 | { |
Himanshu Sahdev | 8c09b82 | 2019-10-21 18:50:50 +0530 | [diff] [blame] | 128 | lapic->type = LOCAL_APIC; /* Local APIC structure */ |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 129 | lapic->length = sizeof(acpi_madt_lapic_t); |
| 130 | lapic->flags = (1 << 0); /* Processor/LAPIC enabled */ |
| 131 | lapic->processor_id = cpu; |
| 132 | lapic->apic_id = apic; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 133 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 134 | return lapic->length; |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 135 | } |
| 136 | |
Kyösti Mälkki | 2e9f0d3 | 2023-04-07 23:05:46 +0300 | [diff] [blame] | 137 | static int acpi_create_madt_lx2apic(acpi_madt_lx2apic_t *lapic, u32 cpu, u32 apic) |
Patrick Rudolph | 56a3ef2 | 2020-03-24 17:29:49 +0100 | [diff] [blame] | 138 | { |
| 139 | lapic->type = LOCAL_X2APIC; /* Local APIC structure */ |
| 140 | lapic->reserved = 0; |
| 141 | lapic->length = sizeof(acpi_madt_lx2apic_t); |
| 142 | lapic->flags = (1 << 0); /* Processor/LAPIC enabled */ |
| 143 | lapic->processor_id = cpu; |
| 144 | lapic->x2apic_id = apic; |
| 145 | |
| 146 | return lapic->length; |
| 147 | } |
| 148 | |
Kyösti Mälkki | 2e9f0d3 | 2023-04-07 23:05:46 +0300 | [diff] [blame] | 149 | unsigned long acpi_create_madt_one_lapic(unsigned long current, u32 index, u32 lapic_id) |
| 150 | { |
| 151 | if (lapic_id <= ACPI_MADT_MAX_LAPIC_ID) |
| 152 | current += acpi_create_madt_lapic((acpi_madt_lapic_t *)current, index, |
| 153 | lapic_id); |
| 154 | else |
| 155 | current += acpi_create_madt_lx2apic((acpi_madt_lx2apic_t *)current, index, |
| 156 | lapic_id); |
| 157 | |
| 158 | return current; |
| 159 | } |
| 160 | |
Arthur Heymans | 8547429 | 2022-11-04 14:00:35 +0100 | [diff] [blame] | 161 | /* Increase if necessary. Currently all x86 CPUs only have 2 SMP threads */ |
| 162 | #define MAX_THREAD_ID 1 |
| 163 | /* |
| 164 | * From ACPI 6.4 spec: |
| 165 | * "The advent of multi-threaded processors yielded multiple logical processors |
| 166 | * executing on common processor hardware. ACPI defines logical processors in |
| 167 | * an identical manner as physical processors. To ensure that non |
| 168 | * multi-threading aware OSPM implementations realize optimal performance on |
| 169 | * platforms containing multi-threaded processors, two guidelines should be |
| 170 | * followed. The first is the same as above, that is, OSPM should initialize |
| 171 | * processors in the order that they appear in the MADT. The second is that |
| 172 | * platform firmware should list the first logical processor of each of the |
| 173 | * individual multi-threaded processors in the MADT before listing any of the |
| 174 | * second logical processors. This approach should be used for all successive |
| 175 | * logical processors." |
| 176 | */ |
Kyösti Mälkki | 899c713 | 2021-06-16 11:06:26 +0300 | [diff] [blame] | 177 | static unsigned long acpi_create_madt_lapics(unsigned long current) |
Stefan Reinauer | da65fbf | 2009-04-22 08:18:37 +0000 | [diff] [blame] | 178 | { |
Edward O'Callaghan | 2c9d2cf | 2014-10-27 23:29:29 +1100 | [diff] [blame] | 179 | struct device *cpu; |
Arthur Heymans | 8547429 | 2022-11-04 14:00:35 +0100 | [diff] [blame] | 180 | int index, apic_ids[CONFIG_MAX_CPUS] = {0}, num_cpus = 0, sort_start = 0; |
| 181 | for (unsigned int thread_id = 0; thread_id <= MAX_THREAD_ID; thread_id++) { |
| 182 | for (cpu = all_devices; cpu; cpu = cpu->next) { |
| 183 | if (!is_enabled_cpu(cpu)) |
| 184 | continue; |
| 185 | if (num_cpus >= ARRAY_SIZE(apic_ids)) |
| 186 | break; |
| 187 | if (cpu->path.apic.thread_id != thread_id) |
| 188 | continue; |
| 189 | apic_ids[num_cpus++] = cpu->path.apic.apic_id; |
| 190 | } |
| 191 | bubblesort(&apic_ids[sort_start], num_cpus - sort_start, NUM_ASCENDING); |
| 192 | sort_start = num_cpus; |
Werner Zeh | db561e6 | 2019-02-19 13:39:56 +0100 | [diff] [blame] | 193 | } |
Kyösti Mälkki | 2e9f0d3 | 2023-04-07 23:05:46 +0300 | [diff] [blame] | 194 | for (index = 0; index < num_cpus; index++) |
| 195 | current = acpi_create_madt_one_lapic(current, index, apic_ids[index]); |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 196 | |
Stefan Reinauer | da65fbf | 2009-04-22 08:18:37 +0000 | [diff] [blame] | 197 | return current; |
| 198 | } |
| 199 | |
Arthur Heymans | 9362dd7 | 2023-06-08 19:56:51 +0200 | [diff] [blame^] | 200 | static 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] | 201 | u32 gsi_base) |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 202 | { |
Himanshu Sahdev | 8c09b82 | 2019-10-21 18:50:50 +0530 | [diff] [blame] | 203 | ioapic->type = IO_APIC; /* I/O APIC structure */ |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 204 | ioapic->length = sizeof(acpi_madt_ioapic_t); |
| 205 | ioapic->reserved = 0x00; |
| 206 | ioapic->gsi_base = gsi_base; |
| 207 | ioapic->ioapic_id = id; |
| 208 | ioapic->ioapic_addr = addr; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 209 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 210 | return ioapic->length; |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 211 | } |
| 212 | |
Kyösti Mälkki | c7da027 | 2021-06-08 11:37:08 +0300 | [diff] [blame] | 213 | #if ENV_X86 |
| 214 | /* For a system with multiple I/O APICs it's required that the one potentially |
| 215 | routing i8259 via ExtNMI delivery calls this first to get GSI #0. */ |
| 216 | int acpi_create_madt_ioapic_from_hw(acpi_madt_ioapic_t *ioapic, u32 addr) |
| 217 | { |
| 218 | static u32 gsi_base; |
| 219 | u32 my_base; |
| 220 | u8 id = get_ioapic_id((void *)(uintptr_t)addr); |
| 221 | u8 count = ioapic_get_max_vectors((void *)(uintptr_t)addr); |
| 222 | |
| 223 | my_base = gsi_base; |
| 224 | gsi_base += count; |
| 225 | return acpi_create_madt_ioapic(ioapic, id, addr, my_base); |
| 226 | } |
| 227 | #endif |
| 228 | |
Kyösti Mälkki | e742b68 | 2023-04-10 17:03:32 +0300 | [diff] [blame] | 229 | static u16 acpi_sci_int(void) |
Kyösti Mälkki | ae1b2d4 | 2023-04-10 16:45:39 +0300 | [diff] [blame] | 230 | { |
| 231 | #if ENV_X86 |
| 232 | u8 gsi, irq, flags; |
| 233 | |
| 234 | ioapic_get_sci_pin(&gsi, &irq, &flags); |
| 235 | |
| 236 | /* ACPI Release 6.5, 5.2.9 and 5.2.15.5. */ |
| 237 | if (!CONFIG(ACPI_HAVE_PCAT_8259)) |
| 238 | return gsi; |
| 239 | |
| 240 | assert(irq < 16); |
| 241 | return irq; |
| 242 | #else |
| 243 | return 0; |
| 244 | #endif |
| 245 | } |
| 246 | |
Arthur Heymans | 9362dd7 | 2023-06-08 19:56:51 +0200 | [diff] [blame^] | 247 | static int acpi_create_madt_irqoverride(acpi_madt_irqoverride_t *irqoverride, |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 248 | u8 bus, u8 source, u32 gsirq, u16 flags) |
| 249 | { |
Himanshu Sahdev | 8c09b82 | 2019-10-21 18:50:50 +0530 | [diff] [blame] | 250 | irqoverride->type = IRQ_SOURCE_OVERRIDE; /* Interrupt source override */ |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 251 | irqoverride->length = sizeof(acpi_madt_irqoverride_t); |
| 252 | irqoverride->bus = bus; |
| 253 | irqoverride->source = source; |
| 254 | irqoverride->gsirq = gsirq; |
| 255 | irqoverride->flags = flags; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 256 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 257 | return irqoverride->length; |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 258 | } |
| 259 | |
Arthur Heymans | 9362dd7 | 2023-06-08 19:56:51 +0200 | [diff] [blame^] | 260 | static int acpi_create_madt_sci_override(acpi_madt_irqoverride_t *irqoverride) |
Kyösti Mälkki | ae1b2d4 | 2023-04-10 16:45:39 +0300 | [diff] [blame] | 261 | { |
| 262 | u8 gsi, irq, flags; |
| 263 | |
| 264 | ioapic_get_sci_pin(&gsi, &irq, &flags); |
| 265 | |
| 266 | if (!CONFIG(ACPI_HAVE_PCAT_8259)) |
| 267 | irq = gsi; |
| 268 | |
| 269 | irqoverride->type = IRQ_SOURCE_OVERRIDE; /* Interrupt source override */ |
| 270 | irqoverride->length = sizeof(acpi_madt_irqoverride_t); |
| 271 | irqoverride->bus = MP_BUS_ISA; |
| 272 | irqoverride->source = irq; |
| 273 | irqoverride->gsirq = gsi; |
| 274 | irqoverride->flags = flags; |
| 275 | |
| 276 | return irqoverride->length; |
| 277 | } |
| 278 | |
Kyösti Mälkki | 10bdee1 | 2023-04-11 01:00:17 +0300 | [diff] [blame] | 279 | static unsigned long acpi_create_madt_ioapic_gsi0_default(unsigned long current) |
| 280 | { |
| 281 | current += acpi_create_madt_ioapic_from_hw((acpi_madt_ioapic_t *)current, IO_APIC_ADDR); |
| 282 | |
| 283 | current += acpi_create_madt_irqoverride((void *)current, MP_BUS_ISA, 0, 2, |
| 284 | MP_IRQ_TRIGGER_EDGE | MP_IRQ_POLARITY_HIGH); |
| 285 | |
| 286 | current += acpi_create_madt_sci_override((void *)current); |
| 287 | |
| 288 | return current; |
| 289 | } |
| 290 | |
Kyösti Mälkki | 9ac1fb7 | 2023-04-07 22:39:53 +0300 | [diff] [blame] | 291 | static 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] | 292 | u16 flags, u8 lint) |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 293 | { |
Himanshu Sahdev | 8c09b82 | 2019-10-21 18:50:50 +0530 | [diff] [blame] | 294 | lapic_nmi->type = LOCAL_APIC_NMI; /* Local APIC NMI structure */ |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 295 | lapic_nmi->length = sizeof(acpi_madt_lapic_nmi_t); |
| 296 | lapic_nmi->flags = flags; |
| 297 | lapic_nmi->processor_id = cpu; |
| 298 | lapic_nmi->lint = lint; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 299 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 300 | return lapic_nmi->length; |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 301 | } |
| 302 | |
Kyösti Mälkki | 9ac1fb7 | 2023-04-07 22:39:53 +0300 | [diff] [blame] | 303 | static int acpi_create_madt_lx2apic_nmi(acpi_madt_lx2apic_nmi_t *lapic_nmi, u32 cpu, |
Patrick Rudolph | 56a3ef2 | 2020-03-24 17:29:49 +0100 | [diff] [blame] | 304 | u16 flags, u8 lint) |
| 305 | { |
| 306 | lapic_nmi->type = LOCAL_X2APIC_NMI; /* Local APIC NMI structure */ |
| 307 | lapic_nmi->length = sizeof(acpi_madt_lx2apic_nmi_t); |
| 308 | lapic_nmi->flags = flags; |
| 309 | lapic_nmi->processor_id = cpu; |
| 310 | lapic_nmi->lint = lint; |
| 311 | lapic_nmi->reserved[0] = 0; |
| 312 | lapic_nmi->reserved[1] = 0; |
| 313 | lapic_nmi->reserved[2] = 0; |
| 314 | |
| 315 | return lapic_nmi->length; |
| 316 | } |
| 317 | |
Kyösti Mälkki | 9ac1fb7 | 2023-04-07 22:39:53 +0300 | [diff] [blame] | 318 | unsigned long acpi_create_madt_lapic_nmis(unsigned long current) |
Kyösti Mälkki | 66b5e1b | 2022-11-12 21:13:45 +0200 | [diff] [blame] | 319 | { |
| 320 | const u16 flags = MP_IRQ_TRIGGER_EDGE | MP_IRQ_POLARITY_HIGH; |
| 321 | |
Kyösti Mälkki | 66b5e1b | 2022-11-12 21:13:45 +0200 | [diff] [blame] | 322 | /* 1: LINT1 connect to NMI */ |
| 323 | /* create all subtables for processors */ |
| 324 | current += acpi_create_madt_lapic_nmi((acpi_madt_lapic_nmi_t *)current, |
| 325 | ACPI_MADT_LAPIC_NMI_ALL_PROCESSORS, flags, 1); |
| 326 | |
| 327 | if (!CONFIG(XAPIC_ONLY)) |
| 328 | current += acpi_create_madt_lx2apic_nmi((acpi_madt_lx2apic_nmi_t *)current, |
| 329 | ACPI_MADT_LX2APIC_NMI_ALL_PROCESSORS, flags, 1); |
| 330 | |
| 331 | return current; |
| 332 | } |
| 333 | |
Arthur Heymans | 9362dd7 | 2023-06-08 19:56:51 +0200 | [diff] [blame^] | 334 | static unsigned long acpi_create_madt_lapics_with_nmis(unsigned long current) |
Kyösti Mälkki | 9ac1fb7 | 2023-04-07 22:39:53 +0300 | [diff] [blame] | 335 | { |
| 336 | current = acpi_create_madt_lapics(current); |
| 337 | current = acpi_create_madt_lapic_nmis(current); |
| 338 | return current; |
| 339 | } |
| 340 | |
Arthur Heymans | 9368cf9 | 2023-04-25 16:07:49 +0200 | [diff] [blame] | 341 | static void acpi_create_madt(acpi_madt_t *madt) |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 342 | { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 343 | acpi_header_t *header = &(madt->header); |
| 344 | unsigned long current = (unsigned long)madt + sizeof(acpi_madt_t); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 345 | |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 346 | memset((void *)madt, 0, sizeof(acpi_madt_t)); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 347 | |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 348 | if (!header) |
| 349 | return; |
| 350 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 351 | /* Fill out header fields. */ |
Stefan Reinauer | cdfe376 | 2009-07-21 22:15:43 +0000 | [diff] [blame] | 352 | memcpy(header->signature, "APIC", 4); |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 353 | memcpy(header->oem_id, OEM_ID, 6); |
Stefan Reinauer | cdfe376 | 2009-07-21 22:15:43 +0000 | [diff] [blame] | 354 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 355 | memcpy(header->asl_compiler_id, ASLC, 4); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 356 | |
Elyes HAOUAS | f8f2e8c | 2019-02-25 15:42:07 +0100 | [diff] [blame] | 357 | header->asl_compiler_revision = asl_revision; |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 358 | header->length = sizeof(acpi_madt_t); |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 359 | header->revision = get_acpi_table_revision(MADT); |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 360 | |
Furquan Shaikh | b1859a6 | 2020-04-30 21:27:47 -0700 | [diff] [blame] | 361 | madt->lapic_addr = cpu_get_lapic_addr(); |
Nico Huber | 9df72e0 | 2018-11-24 18:25:50 +0100 | [diff] [blame] | 362 | if (CONFIG(ACPI_HAVE_PCAT_8259)) |
| 363 | madt->flags |= 1; |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 364 | |
Kyösti Mälkki | 69a1396 | 2023-04-08 14:10:48 +0300 | [diff] [blame] | 365 | if (CONFIG(ACPI_COMMON_MADT_LAPIC)) |
| 366 | current = acpi_create_madt_lapics_with_nmis(current); |
| 367 | |
Kyösti Mälkki | 10bdee1 | 2023-04-11 01:00:17 +0300 | [diff] [blame] | 368 | if (CONFIG(ACPI_COMMON_MADT_IOAPIC)) |
| 369 | current = acpi_create_madt_ioapic_gsi0_default(current); |
| 370 | |
| 371 | if (CONFIG(ACPI_CUSTOM_MADT)) |
Kyösti Mälkki | a5fa534 | 2022-11-18 13:23:52 +0200 | [diff] [blame] | 372 | current = acpi_fill_madt(current); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 373 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 374 | /* (Re)calculate length and checksum. */ |
| 375 | header->length = current - (unsigned long)madt; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 376 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 377 | header->checksum = acpi_checksum((void *)madt, header->length); |
Stefan Reinauer | 06feb88 | 2004-02-03 16:11:35 +0000 | [diff] [blame] | 378 | } |
| 379 | |
Kyösti Mälkki | b54388d | 2021-02-14 15:09:45 +0200 | [diff] [blame] | 380 | static unsigned long acpi_fill_mcfg(unsigned long current) |
| 381 | { |
| 382 | current += acpi_create_mcfg_mmconfig((acpi_mcfg_mmconfig_t *)current, |
Shelley Chen | 4e9bb33 | 2021-10-20 15:43:45 -0700 | [diff] [blame] | 383 | CONFIG_ECAM_MMCONF_BASE_ADDRESS, 0, 0, |
| 384 | CONFIG_ECAM_MMCONF_BUS_NUMBER - 1); |
Kyösti Mälkki | b54388d | 2021-02-14 15:09:45 +0200 | [diff] [blame] | 385 | return current; |
| 386 | } |
| 387 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 388 | /* MCFG is defined in the PCI Firmware Specification 3.0. */ |
Arthur Heymans | 9368cf9 | 2023-04-25 16:07:49 +0200 | [diff] [blame] | 389 | static void acpi_create_mcfg(acpi_mcfg_t *mcfg) |
Rudolf Marek | e6409f2 | 2007-11-03 12:50:26 +0000 | [diff] [blame] | 390 | { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 391 | acpi_header_t *header = &(mcfg->header); |
| 392 | unsigned long current = (unsigned long)mcfg + sizeof(acpi_mcfg_t); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 393 | |
Rudolf Marek | e6409f2 | 2007-11-03 12:50:26 +0000 | [diff] [blame] | 394 | memset((void *)mcfg, 0, sizeof(acpi_mcfg_t)); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 395 | |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 396 | if (!header) |
| 397 | return; |
| 398 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 399 | /* Fill out header fields. */ |
Stefan Reinauer | cdfe376 | 2009-07-21 22:15:43 +0000 | [diff] [blame] | 400 | memcpy(header->signature, "MCFG", 4); |
Rudolf Marek | e6409f2 | 2007-11-03 12:50:26 +0000 | [diff] [blame] | 401 | memcpy(header->oem_id, OEM_ID, 6); |
Stefan Reinauer | cdfe376 | 2009-07-21 22:15:43 +0000 | [diff] [blame] | 402 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
Rudolf Marek | e6409f2 | 2007-11-03 12:50:26 +0000 | [diff] [blame] | 403 | memcpy(header->asl_compiler_id, ASLC, 4); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 404 | |
Elyes HAOUAS | f8f2e8c | 2019-02-25 15:42:07 +0100 | [diff] [blame] | 405 | header->asl_compiler_revision = asl_revision; |
Rudolf Marek | e6409f2 | 2007-11-03 12:50:26 +0000 | [diff] [blame] | 406 | header->length = sizeof(acpi_mcfg_t); |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 407 | header->revision = get_acpi_table_revision(MCFG); |
Rudolf Marek | e6409f2 | 2007-11-03 12:50:26 +0000 | [diff] [blame] | 408 | |
Shelley Chen | 4e9bb33 | 2021-10-20 15:43:45 -0700 | [diff] [blame] | 409 | if (CONFIG(ECAM_MMCONF_SUPPORT)) |
Kyösti Mälkki | b54388d | 2021-02-14 15:09:45 +0200 | [diff] [blame] | 410 | current = acpi_fill_mcfg(current); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 411 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 412 | /* (Re)calculate length and checksum. */ |
| 413 | header->length = current - (unsigned long)mcfg; |
| 414 | header->checksum = acpi_checksum((void *)mcfg, header->length); |
Rudolf Marek | e6409f2 | 2007-11-03 12:50:26 +0000 | [diff] [blame] | 415 | } |
| 416 | |
Vladimir Serbinenko | f44ac13 | 2015-05-20 19:52:01 +0200 | [diff] [blame] | 417 | static void *get_tcpa_log(u32 *size) |
| 418 | { |
| 419 | const struct cbmem_entry *ce; |
| 420 | const u32 tcpa_default_log_len = 0x10000; |
| 421 | void *lasa; |
Philipp Deppenwiese | 791ba97 | 2018-07-30 01:15:20 +0200 | [diff] [blame] | 422 | ce = cbmem_entry_find(CBMEM_ID_TCPA_TCG_LOG); |
Vladimir Serbinenko | f44ac13 | 2015-05-20 19:52:01 +0200 | [diff] [blame] | 423 | if (ce) { |
| 424 | lasa = cbmem_entry_start(ce); |
| 425 | *size = cbmem_entry_size(ce); |
| 426 | printk(BIOS_DEBUG, "TCPA log found at %p\n", lasa); |
| 427 | return lasa; |
| 428 | } |
Philipp Deppenwiese | 791ba97 | 2018-07-30 01:15:20 +0200 | [diff] [blame] | 429 | lasa = cbmem_add(CBMEM_ID_TCPA_TCG_LOG, tcpa_default_log_len); |
Vladimir Serbinenko | f44ac13 | 2015-05-20 19:52:01 +0200 | [diff] [blame] | 430 | if (!lasa) { |
| 431 | printk(BIOS_ERR, "TCPA log creation failed\n"); |
| 432 | return NULL; |
| 433 | } |
| 434 | |
| 435 | printk(BIOS_DEBUG, "TCPA log created at %p\n", lasa); |
Lee Leahy | 024b13d | 2017-03-16 13:41:11 -0700 | [diff] [blame] | 436 | memset(lasa, 0, tcpa_default_log_len); |
Vladimir Serbinenko | f44ac13 | 2015-05-20 19:52:01 +0200 | [diff] [blame] | 437 | |
| 438 | *size = tcpa_default_log_len; |
| 439 | return lasa; |
| 440 | } |
| 441 | |
| 442 | static void acpi_create_tcpa(acpi_tcpa_t *tcpa) |
| 443 | { |
| 444 | acpi_header_t *header = &(tcpa->header); |
| 445 | u32 tcpa_log_len; |
| 446 | void *lasa; |
| 447 | |
| 448 | memset((void *)tcpa, 0, sizeof(acpi_tcpa_t)); |
| 449 | |
| 450 | lasa = get_tcpa_log(&tcpa_log_len); |
Lee Leahy | 9c7c6f7 | 2017-03-16 11:24:09 -0700 | [diff] [blame] | 451 | if (!lasa) |
Vladimir Serbinenko | f44ac13 | 2015-05-20 19:52:01 +0200 | [diff] [blame] | 452 | return; |
Vladimir Serbinenko | f44ac13 | 2015-05-20 19:52:01 +0200 | [diff] [blame] | 453 | |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 454 | if (!header) |
| 455 | return; |
| 456 | |
Vladimir Serbinenko | f44ac13 | 2015-05-20 19:52:01 +0200 | [diff] [blame] | 457 | /* Fill out header fields. */ |
| 458 | memcpy(header->signature, "TCPA", 4); |
| 459 | memcpy(header->oem_id, OEM_ID, 6); |
| 460 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 461 | memcpy(header->asl_compiler_id, ASLC, 4); |
| 462 | |
Elyes HAOUAS | f8f2e8c | 2019-02-25 15:42:07 +0100 | [diff] [blame] | 463 | header->asl_compiler_revision = asl_revision; |
Vladimir Serbinenko | f44ac13 | 2015-05-20 19:52:01 +0200 | [diff] [blame] | 464 | header->length = sizeof(acpi_tcpa_t); |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 465 | header->revision = get_acpi_table_revision(TCPA); |
Vladimir Serbinenko | f44ac13 | 2015-05-20 19:52:01 +0200 | [diff] [blame] | 466 | |
| 467 | tcpa->platform_class = 0; |
| 468 | tcpa->laml = tcpa_log_len; |
Elyes Haouas | 3141fbad | 2022-11-18 15:22:32 +0100 | [diff] [blame] | 469 | tcpa->lasa = (uintptr_t)lasa; |
Vladimir Serbinenko | f44ac13 | 2015-05-20 19:52:01 +0200 | [diff] [blame] | 470 | |
| 471 | /* Calculate checksum. */ |
| 472 | header->checksum = acpi_checksum((void *)tcpa, header->length); |
| 473 | } |
| 474 | |
Michał Żygowski | 6e8692e | 2018-11-22 16:57:50 +0100 | [diff] [blame] | 475 | static void *get_tpm2_log(u32 *size) |
| 476 | { |
| 477 | const struct cbmem_entry *ce; |
| 478 | const u32 tpm2_default_log_len = 0x10000; |
| 479 | void *lasa; |
| 480 | ce = cbmem_entry_find(CBMEM_ID_TPM2_TCG_LOG); |
| 481 | if (ce) { |
| 482 | lasa = cbmem_entry_start(ce); |
| 483 | *size = cbmem_entry_size(ce); |
| 484 | printk(BIOS_DEBUG, "TPM2 log found at %p\n", lasa); |
| 485 | return lasa; |
| 486 | } |
| 487 | lasa = cbmem_add(CBMEM_ID_TPM2_TCG_LOG, tpm2_default_log_len); |
| 488 | if (!lasa) { |
| 489 | printk(BIOS_ERR, "TPM2 log creation failed\n"); |
| 490 | return NULL; |
| 491 | } |
| 492 | |
| 493 | printk(BIOS_DEBUG, "TPM2 log created at %p\n", lasa); |
| 494 | memset(lasa, 0, tpm2_default_log_len); |
| 495 | |
| 496 | *size = tpm2_default_log_len; |
| 497 | return lasa; |
| 498 | } |
| 499 | |
Philipp Deppenwiese | 296164e0 | 2018-10-18 15:39:34 +0200 | [diff] [blame] | 500 | static void acpi_create_tpm2(acpi_tpm2_t *tpm2) |
| 501 | { |
| 502 | acpi_header_t *header = &(tpm2->header); |
Michał Żygowski | 6e8692e | 2018-11-22 16:57:50 +0100 | [diff] [blame] | 503 | u32 tpm2_log_len; |
| 504 | void *lasa; |
Philipp Deppenwiese | 296164e0 | 2018-10-18 15:39:34 +0200 | [diff] [blame] | 505 | |
| 506 | memset((void *)tpm2, 0, sizeof(acpi_tpm2_t)); |
| 507 | |
Michał Żygowski | 6e8692e | 2018-11-22 16:57:50 +0100 | [diff] [blame] | 508 | /* |
| 509 | * Some payloads like SeaBIOS depend on log area to use TPM2. |
| 510 | * Get the memory size and address of TPM2 log area or initialize it. |
| 511 | */ |
| 512 | lasa = get_tpm2_log(&tpm2_log_len); |
| 513 | if (!lasa) |
| 514 | tpm2_log_len = 0; |
| 515 | |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 516 | if (!header) |
| 517 | return; |
| 518 | |
Philipp Deppenwiese | 296164e0 | 2018-10-18 15:39:34 +0200 | [diff] [blame] | 519 | /* Fill out header fields. */ |
| 520 | memcpy(header->signature, "TPM2", 4); |
| 521 | memcpy(header->oem_id, OEM_ID, 6); |
| 522 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 523 | memcpy(header->asl_compiler_id, ASLC, 4); |
| 524 | |
Elyes HAOUAS | f8f2e8c | 2019-02-25 15:42:07 +0100 | [diff] [blame] | 525 | header->asl_compiler_revision = asl_revision; |
Philipp Deppenwiese | 296164e0 | 2018-10-18 15:39:34 +0200 | [diff] [blame] | 526 | header->length = sizeof(acpi_tpm2_t); |
| 527 | header->revision = get_acpi_table_revision(TPM2); |
| 528 | |
| 529 | /* Hard to detect for coreboot. Just set it to 0 */ |
| 530 | tpm2->platform_class = 0; |
Christian Walter | 26e0d4c | 2019-07-14 15:47:23 +0200 | [diff] [blame] | 531 | if (CONFIG(CRB_TPM)) { |
| 532 | /* Must be set to 7 for CRB Support */ |
| 533 | tpm2->control_area = CONFIG_CRB_TPM_BASE_ADDRESS + 0x40; |
| 534 | tpm2->start_method = 7; |
| 535 | } else { |
| 536 | /* Must be set to 0 for FIFO interface support */ |
| 537 | tpm2->control_area = 0; |
| 538 | tpm2->start_method = 6; |
| 539 | } |
Philipp Deppenwiese | 296164e0 | 2018-10-18 15:39:34 +0200 | [diff] [blame] | 540 | memset(tpm2->msp, 0, sizeof(tpm2->msp)); |
| 541 | |
Michał Żygowski | 6e8692e | 2018-11-22 16:57:50 +0100 | [diff] [blame] | 542 | /* Fill the log area size and start address fields. */ |
| 543 | tpm2->laml = tpm2_log_len; |
Elyes Haouas | 3141fbad | 2022-11-18 15:22:32 +0100 | [diff] [blame] | 544 | tpm2->lasa = (uintptr_t)lasa; |
Michał Żygowski | 6e8692e | 2018-11-22 16:57:50 +0100 | [diff] [blame] | 545 | |
Philipp Deppenwiese | 296164e0 | 2018-10-18 15:39:34 +0200 | [diff] [blame] | 546 | /* Calculate checksum. */ |
| 547 | header->checksum = acpi_checksum((void *)tpm2, header->length); |
| 548 | } |
| 549 | |
Duncan Laurie | 3731903 | 2016-05-26 12:47:05 -0700 | [diff] [blame] | 550 | static void acpi_ssdt_write_cbtable(void) |
| 551 | { |
| 552 | const struct cbmem_entry *cbtable; |
| 553 | uintptr_t base; |
| 554 | uint32_t size; |
| 555 | |
| 556 | cbtable = cbmem_entry_find(CBMEM_ID_CBTABLE); |
| 557 | if (!cbtable) |
| 558 | return; |
| 559 | base = (uintptr_t)cbmem_entry_start(cbtable); |
| 560 | size = cbmem_entry_size(cbtable); |
| 561 | |
| 562 | acpigen_write_device("CTBL"); |
| 563 | acpigen_write_coreboot_hid(COREBOOT_ACPI_ID_CBTABLE); |
| 564 | acpigen_write_name_integer("_UID", 0); |
David Wu | 5dff396 | 2018-03-21 16:48:53 +0800 | [diff] [blame] | 565 | acpigen_write_STA(ACPI_STATUS_DEVICE_HIDDEN_ON); |
Duncan Laurie | 3731903 | 2016-05-26 12:47:05 -0700 | [diff] [blame] | 566 | acpigen_write_name("_CRS"); |
| 567 | acpigen_write_resourcetemplate_header(); |
| 568 | acpigen_write_mem32fixed(0, base, size); |
| 569 | acpigen_write_resourcetemplate_footer(); |
| 570 | acpigen_pop_len(); |
| 571 | } |
| 572 | |
Arthur Heymans | 9368cf9 | 2023-04-25 16:07:49 +0200 | [diff] [blame] | 573 | static 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] | 574 | { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 575 | unsigned long current = (unsigned long)ssdt + sizeof(acpi_header_t); |
| 576 | |
Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 577 | memset((void *)ssdt, 0, sizeof(acpi_header_t)); |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 578 | |
Stefan Reinauer | cdfe376 | 2009-07-21 22:15:43 +0000 | [diff] [blame] | 579 | memcpy(&ssdt->signature, "SSDT", 4); |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 580 | ssdt->revision = get_acpi_table_revision(SSDT); |
Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 581 | memcpy(&ssdt->oem_id, OEM_ID, 6); |
| 582 | memcpy(&ssdt->oem_table_id, oem_table_id, 8); |
| 583 | ssdt->oem_revision = 42; |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 584 | memcpy(&ssdt->asl_compiler_id, ASLC, 4); |
Elyes HAOUAS | 26071aa | 2019-02-15 08:21:33 +0100 | [diff] [blame] | 585 | ssdt->asl_compiler_revision = asl_revision; |
Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 586 | ssdt->length = sizeof(acpi_header_t); |
| 587 | |
Elyes Haouas | 3141fbad | 2022-11-18 15:22:32 +0100 | [diff] [blame] | 588 | acpigen_set_current((char *)current); |
Duncan Laurie | 3731903 | 2016-05-26 12:47:05 -0700 | [diff] [blame] | 589 | |
| 590 | /* Write object to declare coreboot tables */ |
| 591 | acpi_ssdt_write_cbtable(); |
| 592 | |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 593 | { |
Edward O'Callaghan | 2c9d2cf | 2014-10-27 23:29:29 +1100 | [diff] [blame] | 594 | struct device *dev; |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 595 | for (dev = all_devices; dev; dev = dev->next) |
Karthikeyan Ramasubramanian | d1c0f95 | 2020-11-02 16:26:52 -0700 | [diff] [blame] | 596 | if (dev->enabled && dev->ops && dev->ops->acpi_fill_ssdt) |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame] | 597 | dev->ops->acpi_fill_ssdt(dev); |
Elyes Haouas | 3141fbad | 2022-11-18 15:22:32 +0100 | [diff] [blame] | 598 | current = (unsigned long)acpigen_get_current(); |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 599 | } |
Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 600 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 601 | /* (Re)calculate length and checksum. */ |
Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 602 | ssdt->length = current - (unsigned long)ssdt; |
| 603 | ssdt->checksum = acpi_checksum((void *)ssdt, ssdt->length); |
| 604 | } |
| 605 | |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 606 | int acpi_create_srat_lapic(acpi_srat_lapic_t *lapic, u8 node, u8 apic) |
| 607 | { |
Myles Watson | 0b4c9f0 | 2009-03-10 18:06:47 +0000 | [diff] [blame] | 608 | memset((void *)lapic, 0, sizeof(acpi_srat_lapic_t)); |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 609 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 610 | lapic->type = 0; /* Processor local APIC/SAPIC affinity structure */ |
| 611 | lapic->length = sizeof(acpi_srat_lapic_t); |
| 612 | lapic->flags = (1 << 0); /* Enabled (the use of this structure). */ |
| 613 | lapic->proximity_domain_7_0 = node; |
| 614 | /* TODO: proximity_domain_31_8, local SAPIC EID, clock domain. */ |
| 615 | lapic->apic_id = apic; |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 616 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 617 | return lapic->length; |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 618 | } |
| 619 | |
Naresh Solanki | 76835cc | 2023-01-20 19:13:02 +0100 | [diff] [blame] | 620 | int acpi_create_srat_x2apic(acpi_srat_x2apic_t *x2apic, u32 node, u32 apic) |
| 621 | { |
| 622 | memset((void *)x2apic, 0, sizeof(acpi_srat_x2apic_t)); |
| 623 | |
| 624 | x2apic->type = 2; /* Processor x2APIC structure */ |
| 625 | x2apic->length = sizeof(acpi_srat_x2apic_t); |
| 626 | x2apic->flags = (1 << 0); /* Enabled (the use of this structure). */ |
| 627 | x2apic->proximity_domain = node; |
| 628 | x2apic->x2apic_id = apic; |
| 629 | |
| 630 | return x2apic->length; |
| 631 | } |
| 632 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 633 | 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] | 634 | u32 flags) |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 635 | { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 636 | mem->type = 1; /* Memory affinity structure */ |
| 637 | mem->length = sizeof(acpi_srat_mem_t); |
| 638 | mem->base_address_low = (basek << 10); |
| 639 | mem->base_address_high = (basek >> (32 - 10)); |
| 640 | mem->length_low = (sizek << 10); |
| 641 | mem->length_high = (sizek >> (32 - 10)); |
| 642 | mem->proximity_domain = node; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 643 | mem->flags = flags; |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 644 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 645 | return mem->length; |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 646 | } |
| 647 | |
Jonathan Zhang | 3164b64 | 2021-04-21 17:51:31 -0700 | [diff] [blame] | 648 | int acpi_create_srat_gia_pci(acpi_srat_gia_t *gia, u32 proximity_domain, |
| 649 | u16 seg, u8 bus, u8 dev, u8 func, u32 flags) |
| 650 | { |
| 651 | gia->type = ACPI_SRAT_STRUCTURE_GIA; |
| 652 | gia->length = sizeof(acpi_srat_gia_t); |
| 653 | gia->proximity_domain = proximity_domain; |
| 654 | gia->dev_handle_type = ACPI_SRAT_GIA_DEV_HANDLE_PCI; |
| 655 | /* First two bytes has segment number */ |
| 656 | memcpy(gia->dev_handle, &seg, 2); |
| 657 | gia->dev_handle[2] = bus; /* Byte 2 has bus number */ |
| 658 | /* Byte 3 has bits 7:3 for dev, bits 2:0 for func */ |
| 659 | gia->dev_handle[3] = PCI_SLOT(dev) | PCI_FUNC(func); |
| 660 | gia->flags = flags; |
| 661 | |
| 662 | return gia->length; |
| 663 | } |
| 664 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 665 | /* http://www.microsoft.com/whdc/system/sysinternals/sratdwn.mspx */ |
Vladimir Serbinenko | 5e59757 | 2014-10-11 23:45:40 +0200 | [diff] [blame] | 666 | void acpi_create_srat(acpi_srat_t *srat, |
| 667 | unsigned long (*acpi_fill_srat)(unsigned long current)) |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 668 | { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 669 | acpi_header_t *header = &(srat->header); |
| 670 | unsigned long current = (unsigned long)srat + sizeof(acpi_srat_t); |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 671 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 672 | memset((void *)srat, 0, sizeof(acpi_srat_t)); |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 673 | |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 674 | if (!header) |
| 675 | return; |
| 676 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 677 | /* Fill out header fields. */ |
| 678 | memcpy(header->signature, "SRAT", 4); |
| 679 | memcpy(header->oem_id, OEM_ID, 6); |
| 680 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 681 | memcpy(header->asl_compiler_id, ASLC, 4); |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 682 | |
Elyes HAOUAS | f8f2e8c | 2019-02-25 15:42:07 +0100 | [diff] [blame] | 683 | header->asl_compiler_revision = asl_revision; |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 684 | header->length = sizeof(acpi_srat_t); |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 685 | header->revision = get_acpi_table_revision(SRAT); |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 686 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 687 | srat->resv = 1; /* Spec: Reserved to 1 for backwards compatibility. */ |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 688 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 689 | current = acpi_fill_srat(current); |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 690 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 691 | /* (Re)calculate length and checksum. */ |
| 692 | header->length = current - (unsigned long)srat; |
| 693 | header->checksum = acpi_checksum((void *)srat, header->length); |
Stefan Reinauer | f622d59 | 2005-11-26 16:56:05 +0000 | [diff] [blame] | 694 | } |
| 695 | |
Jonathan Zhang | 3dcafa8 | 2022-05-11 13:11:20 -0700 | [diff] [blame] | 696 | int acpi_create_cedt_chbs(acpi_cedt_chbs_t *chbs, u32 uid, u32 cxl_ver, u64 base) |
| 697 | { |
| 698 | memset((void *)chbs, 0, sizeof(acpi_cedt_chbs_t)); |
| 699 | |
| 700 | chbs->type = ACPI_CEDT_STRUCTURE_CHBS; |
| 701 | chbs->length = sizeof(acpi_cedt_chbs_t); |
| 702 | chbs->uid = uid; |
| 703 | chbs->cxl_ver = cxl_ver; |
| 704 | chbs->base = base; |
| 705 | |
| 706 | /* |
| 707 | * CXL spec 2.0 section 9.14.1.2 "CXL CHBS" |
| 708 | * CXL 1.1 spec compliant host bridge: 8KB |
| 709 | * CXL 2.0 spec compliant host bridge: 64KB |
| 710 | */ |
| 711 | if (cxl_ver == ACPI_CEDT_CHBS_CXL_VER_1_1) |
| 712 | chbs->len = 8 * KiB; |
| 713 | else if (cxl_ver == ACPI_CEDT_CHBS_CXL_VER_2_0) |
| 714 | chbs->len = 64 * KiB; |
| 715 | else |
| 716 | printk(BIOS_ERR, "ACPI(%s:%s): Incorrect CXL version:%d\n", __FILE__, __func__, |
| 717 | cxl_ver); |
| 718 | |
| 719 | return chbs->length; |
| 720 | } |
| 721 | |
| 722 | int acpi_create_cedt_cfmws(acpi_cedt_cfmws_t *cfmws, u64 base_hpa, u64 window_size, u8 eniw, |
| 723 | u32 hbig, u16 restriction, u16 qtg_id, const u32 *interleave_target) |
| 724 | { |
| 725 | memset((void *)cfmws, 0, sizeof(acpi_cedt_cfmws_t)); |
| 726 | |
| 727 | cfmws->type = ACPI_CEDT_STRUCTURE_CFMWS; |
| 728 | |
| 729 | u8 niw = 0; |
| 730 | if (eniw >= 8) |
| 731 | printk(BIOS_ERR, "ACPI(%s:%s): Incorrect eniw::%d\n", __FILE__, __func__, eniw); |
| 732 | else |
| 733 | /* NIW = 2 ** ENIW */ |
| 734 | niw = 0x1 << eniw; |
| 735 | /* 36 + 4 * NIW */ |
| 736 | cfmws->length = sizeof(acpi_cedt_cfmws_t) + 4 * niw; |
| 737 | |
| 738 | cfmws->base_hpa = base_hpa; |
| 739 | cfmws->window_size = window_size; |
| 740 | cfmws->eniw = eniw; |
| 741 | |
| 742 | // 0: Standard Modulo Arithmetic. Other values reserved. |
| 743 | cfmws->interleave_arithmetic = 0; |
| 744 | |
| 745 | cfmws->hbig = hbig; |
| 746 | cfmws->restriction = restriction; |
| 747 | cfmws->qtg_id = qtg_id; |
| 748 | memcpy(&cfmws->interleave_target, interleave_target, 4 * niw); |
| 749 | |
| 750 | return cfmws->length; |
| 751 | } |
| 752 | |
| 753 | void acpi_create_cedt(acpi_cedt_t *cedt, unsigned long (*acpi_fill_cedt)(unsigned long current)) |
| 754 | { |
| 755 | acpi_header_t *header = &(cedt->header); |
| 756 | unsigned long current = (unsigned long)cedt + sizeof(acpi_cedt_t); |
| 757 | |
| 758 | memset((void *)cedt, 0, sizeof(acpi_cedt_t)); |
| 759 | |
| 760 | if (!header) |
| 761 | return; |
| 762 | |
| 763 | /* Fill out header fields. */ |
| 764 | memcpy(header->signature, "CEDT", 4); |
| 765 | memcpy(header->oem_id, OEM_ID, 6); |
| 766 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 767 | memcpy(header->asl_compiler_id, ASLC, 4); |
| 768 | |
| 769 | header->asl_compiler_revision = asl_revision; |
| 770 | header->length = sizeof(acpi_cedt_t); |
| 771 | header->revision = get_acpi_table_revision(CEDT); |
| 772 | |
| 773 | current = acpi_fill_cedt(current); |
| 774 | |
| 775 | /* (Re)calculate length and checksum. */ |
| 776 | header->length = current - (unsigned long)cedt; |
| 777 | header->checksum = acpi_checksum((void *)cedt, header->length); |
| 778 | } |
| 779 | |
Jonathan Zhang | 2a4e1f4 | 2021-04-01 11:43:37 -0700 | [diff] [blame] | 780 | int acpi_create_hmat_mpda(acpi_hmat_mpda_t *mpda, u32 initiator, u32 memory) |
| 781 | { |
| 782 | memset((void *)mpda, 0, sizeof(acpi_hmat_mpda_t)); |
| 783 | |
| 784 | mpda->type = 0; /* Memory Proximity Domain Attributes structure */ |
| 785 | mpda->length = sizeof(acpi_hmat_mpda_t); |
| 786 | /* |
| 787 | * Proximity Domain for Attached Initiator field is valid. |
| 788 | * Bit 1 and bit 2 are reserved since HMAT revision 2. |
| 789 | */ |
| 790 | mpda->flags = (1 << 0); |
| 791 | mpda->proximity_domain_initiator = initiator; |
| 792 | mpda->proximity_domain_memory = memory; |
| 793 | |
| 794 | return mpda->length; |
| 795 | } |
| 796 | |
| 797 | void acpi_create_hmat(acpi_hmat_t *hmat, |
| 798 | unsigned long (*acpi_fill_hmat)(unsigned long current)) |
| 799 | { |
| 800 | acpi_header_t *header = &(hmat->header); |
| 801 | unsigned long current = (unsigned long)hmat + sizeof(acpi_hmat_t); |
| 802 | |
| 803 | memset((void *)hmat, 0, sizeof(acpi_hmat_t)); |
| 804 | |
| 805 | if (!header) |
| 806 | return; |
| 807 | |
| 808 | /* Fill out header fields. */ |
| 809 | memcpy(header->signature, "HMAT", 4); |
| 810 | memcpy(header->oem_id, OEM_ID, 6); |
| 811 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 812 | memcpy(header->asl_compiler_id, ASLC, 4); |
| 813 | |
| 814 | header->asl_compiler_revision = asl_revision; |
| 815 | header->length = sizeof(acpi_hmat_t); |
| 816 | header->revision = get_acpi_table_revision(HMAT); |
| 817 | |
| 818 | current = acpi_fill_hmat(current); |
| 819 | |
| 820 | /* (Re)calculate length and checksum. */ |
| 821 | header->length = current - (unsigned long)hmat; |
| 822 | header->checksum = acpi_checksum((void *)hmat, header->length); |
| 823 | } |
| 824 | |
Nico Huber | e561f35 | 2015-10-26 11:51:25 +0100 | [diff] [blame] | 825 | void acpi_create_dmar(acpi_dmar_t *dmar, enum dmar_flags flags, |
Lee Leahy | 024b13d | 2017-03-16 13:41:11 -0700 | [diff] [blame] | 826 | unsigned long (*acpi_fill_dmar)(unsigned long)) |
Patrick Georgi | 3b590ff | 2012-09-11 15:21:01 +0200 | [diff] [blame] | 827 | { |
| 828 | acpi_header_t *header = &(dmar->header); |
| 829 | unsigned long current = (unsigned long)dmar + sizeof(acpi_dmar_t); |
| 830 | |
| 831 | memset((void *)dmar, 0, sizeof(acpi_dmar_t)); |
| 832 | |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 833 | if (!header) |
| 834 | return; |
| 835 | |
Patrick Georgi | 3b590ff | 2012-09-11 15:21:01 +0200 | [diff] [blame] | 836 | /* Fill out header fields. */ |
| 837 | memcpy(header->signature, "DMAR", 4); |
| 838 | memcpy(header->oem_id, OEM_ID, 6); |
| 839 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 840 | memcpy(header->asl_compiler_id, ASLC, 4); |
| 841 | |
Elyes HAOUAS | f8f2e8c | 2019-02-25 15:42:07 +0100 | [diff] [blame] | 842 | header->asl_compiler_revision = asl_revision; |
Patrick Georgi | 3b590ff | 2012-09-11 15:21:01 +0200 | [diff] [blame] | 843 | header->length = sizeof(acpi_dmar_t); |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 844 | header->revision = get_acpi_table_revision(DMAR); |
Patrick Georgi | 3b590ff | 2012-09-11 15:21:01 +0200 | [diff] [blame] | 845 | |
Jacob Laska | f3f654d | 2016-03-15 21:53:27 -0500 | [diff] [blame] | 846 | dmar->host_address_width = cpu_phys_address_size() - 1; |
Nico Huber | e561f35 | 2015-10-26 11:51:25 +0100 | [diff] [blame] | 847 | dmar->flags = flags; |
Patrick Georgi | 3b590ff | 2012-09-11 15:21:01 +0200 | [diff] [blame] | 848 | |
| 849 | current = acpi_fill_dmar(current); |
| 850 | |
| 851 | /* (Re)calculate length and checksum. */ |
| 852 | header->length = current - (unsigned long)dmar; |
| 853 | header->checksum = acpi_checksum((void *)dmar, header->length); |
| 854 | } |
| 855 | |
| 856 | unsigned long acpi_create_dmar_drhd(unsigned long current, u8 flags, |
Matt DeVillier | 7866d49 | 2018-03-29 14:59:57 +0200 | [diff] [blame] | 857 | u16 segment, u64 bar) |
Patrick Georgi | 3b590ff | 2012-09-11 15:21:01 +0200 | [diff] [blame] | 858 | { |
| 859 | dmar_entry_t *drhd = (dmar_entry_t *)current; |
| 860 | memset(drhd, 0, sizeof(*drhd)); |
| 861 | drhd->type = DMAR_DRHD; |
| 862 | drhd->length = sizeof(*drhd); /* will be fixed up later */ |
| 863 | drhd->flags = flags; |
| 864 | drhd->segment = segment; |
| 865 | drhd->bar = bar; |
| 866 | |
| 867 | return drhd->length; |
| 868 | } |
| 869 | |
Matt DeVillier | 7866d49 | 2018-03-29 14:59:57 +0200 | [diff] [blame] | 870 | unsigned long acpi_create_dmar_rmrr(unsigned long current, u16 segment, |
| 871 | u64 bar, u64 limit) |
| 872 | { |
| 873 | dmar_rmrr_entry_t *rmrr = (dmar_rmrr_entry_t *)current; |
| 874 | memset(rmrr, 0, sizeof(*rmrr)); |
| 875 | rmrr->type = DMAR_RMRR; |
| 876 | rmrr->length = sizeof(*rmrr); /* will be fixed up later */ |
| 877 | rmrr->segment = segment; |
| 878 | rmrr->bar = bar; |
| 879 | rmrr->limit = limit; |
| 880 | |
| 881 | return rmrr->length; |
| 882 | } |
| 883 | |
Werner Zeh | d4d7695 | 2016-07-27 06:56:36 +0200 | [diff] [blame] | 884 | unsigned long acpi_create_dmar_atsr(unsigned long current, u8 flags, |
| 885 | u16 segment) |
| 886 | { |
| 887 | dmar_atsr_entry_t *atsr = (dmar_atsr_entry_t *)current; |
| 888 | memset(atsr, 0, sizeof(*atsr)); |
| 889 | atsr->type = DMAR_ATSR; |
| 890 | atsr->length = sizeof(*atsr); /* will be fixed up later */ |
| 891 | atsr->flags = flags; |
| 892 | atsr->segment = segment; |
| 893 | |
| 894 | return atsr->length; |
| 895 | } |
| 896 | |
John Zhao | 76e7067 | 2019-04-04 11:03:28 -0700 | [diff] [blame] | 897 | unsigned long acpi_create_dmar_rhsa(unsigned long current, u64 base_addr, |
| 898 | u32 proximity_domain) |
| 899 | { |
| 900 | dmar_rhsa_entry_t *rhsa = (dmar_rhsa_entry_t *)current; |
| 901 | memset(rhsa, 0, sizeof(*rhsa)); |
| 902 | rhsa->type = DMAR_RHSA; |
| 903 | rhsa->length = sizeof(*rhsa); |
| 904 | rhsa->base_address = base_addr; |
| 905 | rhsa->proximity_domain = proximity_domain; |
| 906 | |
| 907 | return rhsa->length; |
| 908 | } |
| 909 | |
| 910 | unsigned long acpi_create_dmar_andd(unsigned long current, u8 device_number, |
| 911 | const char *device_name) |
| 912 | { |
| 913 | dmar_andd_entry_t *andd = (dmar_andd_entry_t *)current; |
| 914 | int andd_len = sizeof(dmar_andd_entry_t) + strlen(device_name) + 1; |
| 915 | memset(andd, 0, andd_len); |
| 916 | andd->type = DMAR_ANDD; |
| 917 | andd->length = andd_len; |
| 918 | andd->device_number = device_number; |
| 919 | memcpy(&andd->device_name, device_name, strlen(device_name)); |
| 920 | |
| 921 | return andd->length; |
| 922 | } |
| 923 | |
John Zhao | 091532d | 2021-04-17 16:03:21 -0700 | [diff] [blame] | 924 | unsigned long acpi_create_dmar_satc(unsigned long current, u8 flags, u16 segment) |
John Zhao | 6edbb18 | 2021-03-24 11:55:09 -0700 | [diff] [blame] | 925 | { |
| 926 | dmar_satc_entry_t *satc = (dmar_satc_entry_t *)current; |
John Zhao | 091532d | 2021-04-17 16:03:21 -0700 | [diff] [blame] | 927 | int satc_len = sizeof(dmar_satc_entry_t); |
John Zhao | 6edbb18 | 2021-03-24 11:55:09 -0700 | [diff] [blame] | 928 | memset(satc, 0, satc_len); |
| 929 | satc->type = DMAR_SATC; |
| 930 | satc->length = satc_len; |
| 931 | satc->flags = flags; |
| 932 | satc->segment_number = segment; |
John Zhao | 6edbb18 | 2021-03-24 11:55:09 -0700 | [diff] [blame] | 933 | |
| 934 | return satc->length; |
| 935 | } |
| 936 | |
Patrick Georgi | 3b590ff | 2012-09-11 15:21:01 +0200 | [diff] [blame] | 937 | void acpi_dmar_drhd_fixup(unsigned long base, unsigned long current) |
| 938 | { |
| 939 | dmar_entry_t *drhd = (dmar_entry_t *)base; |
| 940 | drhd->length = current - base; |
| 941 | } |
| 942 | |
Matt DeVillier | 7866d49 | 2018-03-29 14:59:57 +0200 | [diff] [blame] | 943 | void acpi_dmar_rmrr_fixup(unsigned long base, unsigned long current) |
| 944 | { |
| 945 | dmar_rmrr_entry_t *rmrr = (dmar_rmrr_entry_t *)base; |
| 946 | rmrr->length = current - base; |
| 947 | } |
| 948 | |
Werner Zeh | d4d7695 | 2016-07-27 06:56:36 +0200 | [diff] [blame] | 949 | void acpi_dmar_atsr_fixup(unsigned long base, unsigned long current) |
| 950 | { |
| 951 | dmar_atsr_entry_t *atsr = (dmar_atsr_entry_t *)base; |
| 952 | atsr->length = current - base; |
| 953 | } |
| 954 | |
John Zhao | 6edbb18 | 2021-03-24 11:55:09 -0700 | [diff] [blame] | 955 | void acpi_dmar_satc_fixup(unsigned long base, unsigned long current) |
| 956 | { |
| 957 | dmar_satc_entry_t *satc = (dmar_satc_entry_t *)base; |
| 958 | satc->length = current - base; |
| 959 | } |
| 960 | |
Matt DeVillier | 7866d49 | 2018-03-29 14:59:57 +0200 | [diff] [blame] | 961 | static unsigned long acpi_create_dmar_ds(unsigned long current, |
Nico Huber | 6c4751d | 2015-10-26 12:03:54 +0100 | [diff] [blame] | 962 | 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] | 963 | { |
Nico Huber | 6c4751d | 2015-10-26 12:03:54 +0100 | [diff] [blame] | 964 | /* we don't support longer paths yet */ |
| 965 | const size_t dev_scope_length = sizeof(dev_scope_t) + 2; |
| 966 | |
Patrick Georgi | 3b590ff | 2012-09-11 15:21:01 +0200 | [diff] [blame] | 967 | dev_scope_t *ds = (dev_scope_t *)current; |
Nico Huber | 6c4751d | 2015-10-26 12:03:54 +0100 | [diff] [blame] | 968 | memset(ds, 0, dev_scope_length); |
| 969 | ds->type = type; |
| 970 | ds->length = dev_scope_length; |
| 971 | ds->enumeration = enumeration_id; |
| 972 | ds->start_bus = bus; |
| 973 | ds->path[0].dev = dev; |
| 974 | ds->path[0].fn = fn; |
Patrick Georgi | 3b590ff | 2012-09-11 15:21:01 +0200 | [diff] [blame] | 975 | |
| 976 | return ds->length; |
| 977 | } |
| 978 | |
Matt DeVillier | 7866d49 | 2018-03-29 14:59:57 +0200 | [diff] [blame] | 979 | 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] | 980 | u8 dev, u8 fn) |
| 981 | { |
Matt DeVillier | 7866d49 | 2018-03-29 14:59:57 +0200 | [diff] [blame] | 982 | return acpi_create_dmar_ds(current, |
Werner Zeh | 21a5bff | 2016-07-27 07:07:20 +0200 | [diff] [blame] | 983 | SCOPE_PCI_SUB, 0, bus, dev, fn); |
| 984 | } |
| 985 | |
Matt DeVillier | 7866d49 | 2018-03-29 14:59:57 +0200 | [diff] [blame] | 986 | unsigned long acpi_create_dmar_ds_pci(unsigned long current, u8 bus, |
Nico Huber | 6c4751d | 2015-10-26 12:03:54 +0100 | [diff] [blame] | 987 | u8 dev, u8 fn) |
| 988 | { |
Matt DeVillier | 7866d49 | 2018-03-29 14:59:57 +0200 | [diff] [blame] | 989 | return acpi_create_dmar_ds(current, |
Nico Huber | 6c4751d | 2015-10-26 12:03:54 +0100 | [diff] [blame] | 990 | SCOPE_PCI_ENDPOINT, 0, bus, dev, fn); |
| 991 | } |
| 992 | |
Matt DeVillier | 7866d49 | 2018-03-29 14:59:57 +0200 | [diff] [blame] | 993 | unsigned long acpi_create_dmar_ds_ioapic(unsigned long current, |
Nico Huber | 6c4751d | 2015-10-26 12:03:54 +0100 | [diff] [blame] | 994 | u8 enumeration_id, u8 bus, u8 dev, u8 fn) |
| 995 | { |
Matt DeVillier | 7866d49 | 2018-03-29 14:59:57 +0200 | [diff] [blame] | 996 | return acpi_create_dmar_ds(current, |
Nico Huber | 6c4751d | 2015-10-26 12:03:54 +0100 | [diff] [blame] | 997 | SCOPE_IOAPIC, enumeration_id, bus, dev, fn); |
| 998 | } |
| 999 | |
Arthur Heymans | bc8f859 | 2022-12-02 13:17:39 +0100 | [diff] [blame] | 1000 | unsigned long acpi_create_dmar_ds_ioapic_from_hw(unsigned long current, |
| 1001 | u32 addr, u8 bus, u8 dev, u8 fn) |
| 1002 | { |
| 1003 | u8 enumeration_id = get_ioapic_id((void *)(uintptr_t)addr); |
| 1004 | return acpi_create_dmar_ds(current, |
| 1005 | SCOPE_IOAPIC, enumeration_id, bus, dev, fn); |
| 1006 | } |
| 1007 | |
Matt DeVillier | 7866d49 | 2018-03-29 14:59:57 +0200 | [diff] [blame] | 1008 | unsigned long acpi_create_dmar_ds_msi_hpet(unsigned long current, |
Nico Huber | 6c4751d | 2015-10-26 12:03:54 +0100 | [diff] [blame] | 1009 | u8 enumeration_id, u8 bus, u8 dev, u8 fn) |
| 1010 | { |
Matt DeVillier | 7866d49 | 2018-03-29 14:59:57 +0200 | [diff] [blame] | 1011 | return acpi_create_dmar_ds(current, |
Nico Huber | 6c4751d | 2015-10-26 12:03:54 +0100 | [diff] [blame] | 1012 | SCOPE_MSI_HPET, enumeration_id, bus, dev, fn); |
| 1013 | } |
| 1014 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1015 | /* http://h21007.www2.hp.com/portal/download/files/unprot/Itanium/slit.pdf */ |
Vladimir Serbinenko | 5e59757 | 2014-10-11 23:45:40 +0200 | [diff] [blame] | 1016 | void acpi_create_slit(acpi_slit_t *slit, |
| 1017 | unsigned long (*acpi_fill_slit)(unsigned long current)) |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 1018 | { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1019 | acpi_header_t *header = &(slit->header); |
| 1020 | unsigned long current = (unsigned long)slit + sizeof(acpi_slit_t); |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 1021 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1022 | memset((void *)slit, 0, sizeof(acpi_slit_t)); |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 1023 | |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 1024 | if (!header) |
| 1025 | return; |
| 1026 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1027 | /* Fill out header fields. */ |
| 1028 | memcpy(header->signature, "SLIT", 4); |
| 1029 | memcpy(header->oem_id, OEM_ID, 6); |
| 1030 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 1031 | memcpy(header->asl_compiler_id, ASLC, 4); |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 1032 | |
Elyes HAOUAS | f8f2e8c | 2019-02-25 15:42:07 +0100 | [diff] [blame] | 1033 | header->asl_compiler_revision = asl_revision; |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1034 | header->length = sizeof(acpi_slit_t); |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 1035 | header->revision = get_acpi_table_revision(SLIT); |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 1036 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1037 | current = acpi_fill_slit(current); |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 1038 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1039 | /* (Re)calculate length and checksum. */ |
| 1040 | header->length = current - (unsigned long)slit; |
| 1041 | header->checksum = acpi_checksum((void *)slit, header->length); |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 1042 | } |
| 1043 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1044 | /* http://www.intel.com/hardwaredesign/hpetspec_1.pdf */ |
Arthur Heymans | 9368cf9 | 2023-04-25 16:07:49 +0200 | [diff] [blame] | 1045 | static void acpi_create_hpet(acpi_hpet_t *hpet) |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 1046 | { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1047 | acpi_header_t *header = &(hpet->header); |
| 1048 | acpi_addr_t *addr = &(hpet->addr); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 1049 | |
Stefan Reinauer | a7648c2 | 2004-01-29 17:31:34 +0000 | [diff] [blame] | 1050 | memset((void *)hpet, 0, sizeof(acpi_hpet_t)); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 1051 | |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 1052 | if (!header) |
| 1053 | return; |
| 1054 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1055 | /* Fill out header fields. */ |
Stefan Reinauer | 4704dc5 | 2009-07-22 01:11:37 +0000 | [diff] [blame] | 1056 | memcpy(header->signature, "HPET", 4); |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 1057 | memcpy(header->oem_id, OEM_ID, 6); |
Stefan Reinauer | cdfe376 | 2009-07-21 22:15:43 +0000 | [diff] [blame] | 1058 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 1059 | memcpy(header->asl_compiler_id, ASLC, 4); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 1060 | |
Elyes HAOUAS | f8f2e8c | 2019-02-25 15:42:07 +0100 | [diff] [blame] | 1061 | header->asl_compiler_revision = asl_revision; |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 1062 | header->length = sizeof(acpi_hpet_t); |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 1063 | header->revision = get_acpi_table_revision(HPET); |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 1064 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1065 | /* Fill out HPET address. */ |
Elyes HAOUAS | 04071f4 | 2020-07-20 17:05:24 +0200 | [diff] [blame] | 1066 | addr->space_id = ACPI_ADDRESS_SPACE_MEMORY; |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1067 | addr->bit_width = 64; |
| 1068 | addr->bit_offset = 0; |
Felix Held | 972d9f2 | 2022-02-23 16:32:20 +0100 | [diff] [blame] | 1069 | addr->addrl = HPET_BASE_ADDRESS & 0xffffffff; |
| 1070 | addr->addrh = ((unsigned long long)HPET_BASE_ADDRESS) >> 32; |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 1071 | |
Felix Held | 972d9f2 | 2022-02-23 16:32:20 +0100 | [diff] [blame] | 1072 | hpet->id = read32p(HPET_BASE_ADDRESS); |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1073 | hpet->number = 0; |
Patrick Georgi | 9aeb694 | 2012-10-05 21:54:38 +0200 | [diff] [blame] | 1074 | hpet->min_tick = CONFIG_HPET_MIN_TICKS; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 1075 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1076 | header->checksum = acpi_checksum((void *)hpet, sizeof(acpi_hpet_t)); |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 1077 | } |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1078 | |
Rocky Phagura | eff0713 | 2021-01-10 15:42:50 -0800 | [diff] [blame] | 1079 | /* |
| 1080 | * This method adds the ACPI error injection capability. It fills the default information. |
| 1081 | * HW dependent code (caller) can modify the defaults upon return. If no changes are necessary |
| 1082 | * and the defaults are acceptable then caller can simply add the table (acpi_add_table). |
| 1083 | * INPUTS: |
| 1084 | * einj - ptr to the starting location of EINJ table |
| 1085 | * actions - number of actions to trigger an error (HW dependent) |
| 1086 | * addr - address of trigger action table. This should be ACPI reserved memory and it will be |
| 1087 | * shared between OS and FW. |
| 1088 | */ |
| 1089 | void acpi_create_einj(acpi_einj_t *einj, uintptr_t addr, u8 actions) |
| 1090 | { |
| 1091 | int i; |
| 1092 | acpi_header_t *header = &(einj->header); |
| 1093 | acpi_injection_header_t *inj_header = &(einj->inj_header); |
| 1094 | acpi_einj_smi_t *einj_smi = (acpi_einj_smi_t *)addr; |
| 1095 | acpi_einj_trigger_table_t *tat; |
| 1096 | if (!header) |
| 1097 | return; |
| 1098 | |
| 1099 | printk(BIOS_DEBUG, "%s einj_smi = %p\n", __func__, einj_smi); |
| 1100 | memset(einj_smi, 0, sizeof(acpi_einj_smi_t)); |
Jonathan Zhang | d5d9b28 | 2022-11-07 17:30:14 -0800 | [diff] [blame] | 1101 | tat = (acpi_einj_trigger_table_t *)((uint8_t *)einj_smi + sizeof(acpi_einj_smi_t)); |
Rocky Phagura | eff0713 | 2021-01-10 15:42:50 -0800 | [diff] [blame] | 1102 | tat->header_size = 16; |
| 1103 | tat->revision = 0; |
| 1104 | tat->table_size = sizeof(acpi_einj_trigger_table_t) + |
| 1105 | sizeof(acpi_einj_action_table_t) * actions - 1; |
| 1106 | tat->entry_count = actions; |
| 1107 | printk(BIOS_DEBUG, "%s trigger_action_table = %p\n", __func__, tat); |
| 1108 | |
| 1109 | for (i = 0; i < actions; i++) { |
| 1110 | tat->trigger_action[i].action = TRIGGER_ERROR; |
| 1111 | tat->trigger_action[i].instruction = NO_OP; |
| 1112 | tat->trigger_action[i].flags = FLAG_IGNORE; |
| 1113 | tat->trigger_action[i].reg.space_id = ACPI_ADDRESS_SPACE_MEMORY; |
| 1114 | tat->trigger_action[i].reg.bit_width = 64; |
| 1115 | tat->trigger_action[i].reg.bit_offset = 0; |
| 1116 | tat->trigger_action[i].reg.access_size = ACPI_ACCESS_SIZE_QWORD_ACCESS; |
| 1117 | tat->trigger_action[i].reg.addr = 0; |
| 1118 | tat->trigger_action[i].value = 0; |
| 1119 | tat->trigger_action[i].mask = 0xFFFFFFFF; |
| 1120 | } |
| 1121 | |
| 1122 | acpi_einj_action_table_t default_actions[ACTION_COUNT] = { |
| 1123 | [0] = { |
| 1124 | .action = BEGIN_INJECT_OP, |
| 1125 | .instruction = WRITE_REGISTER_VALUE, |
| 1126 | .flags = FLAG_PRESERVE, |
| 1127 | .reg = EINJ_REG_MEMORY((u64)(uintptr_t)&einj_smi->op_state), |
| 1128 | .value = 0, |
| 1129 | .mask = 0xFFFFFFFF |
| 1130 | }, |
| 1131 | [1] = { |
| 1132 | .action = GET_TRIGGER_ACTION_TABLE, |
| 1133 | .instruction = READ_REGISTER, |
| 1134 | .flags = FLAG_IGNORE, |
| 1135 | .reg = EINJ_REG_MEMORY((u64)(uintptr_t)&einj_smi->trigger_action_table), |
| 1136 | .value = 0, |
| 1137 | .mask = 0xFFFFFFFFFFFFFFFF |
| 1138 | }, |
| 1139 | [2] = { |
| 1140 | .action = SET_ERROR_TYPE, |
| 1141 | .instruction = WRITE_REGISTER, |
| 1142 | .flags = FLAG_PRESERVE, |
| 1143 | .reg = EINJ_REG_MEMORY((u64)(uintptr_t)&einj_smi->err_inject[0]), |
| 1144 | .value = 0, |
| 1145 | .mask = 0xFFFFFFFF |
| 1146 | }, |
| 1147 | [3] = { |
| 1148 | .action = GET_ERROR_TYPE, |
| 1149 | .instruction = READ_REGISTER, |
| 1150 | .flags = FLAG_IGNORE, |
| 1151 | .reg = EINJ_REG_MEMORY((u64)(uintptr_t)&einj_smi->err_inj_cap), |
| 1152 | .value = 0, |
| 1153 | .mask = 0xFFFFFFFF |
| 1154 | }, |
| 1155 | [4] = { |
| 1156 | .action = END_INJECT_OP, |
| 1157 | .instruction = WRITE_REGISTER_VALUE, |
| 1158 | .flags = FLAG_PRESERVE, |
| 1159 | .reg = EINJ_REG_MEMORY((u64)(uintptr_t)&einj_smi->op_state), |
| 1160 | .value = 0, |
| 1161 | .mask = 0xFFFFFFFF |
| 1162 | |
| 1163 | }, |
| 1164 | [5] = { |
| 1165 | .action = EXECUTE_INJECT_OP, |
| 1166 | .instruction = WRITE_REGISTER_VALUE, |
| 1167 | .flags = FLAG_PRESERVE, |
| 1168 | .reg = EINJ_REG_IO(), |
| 1169 | .value = 0x9a, |
| 1170 | .mask = 0xFFFF, |
| 1171 | }, |
| 1172 | [6] = { |
| 1173 | .action = CHECK_BUSY_STATUS, |
| 1174 | .instruction = READ_REGISTER_VALUE, |
| 1175 | .flags = FLAG_IGNORE, |
| 1176 | .reg = EINJ_REG_MEMORY((u64)(uintptr_t)&einj_smi->op_status), |
| 1177 | .value = 1, |
| 1178 | .mask = 1, |
| 1179 | }, |
| 1180 | [7] = { |
| 1181 | .action = GET_CMD_STATUS, |
| 1182 | .instruction = READ_REGISTER, |
| 1183 | .flags = FLAG_PRESERVE, |
| 1184 | .reg = EINJ_REG_MEMORY((u64)(uintptr_t)&einj_smi->cmd_sts), |
| 1185 | .value = 0, |
| 1186 | .mask = 0x1fe, |
| 1187 | }, |
| 1188 | [8] = { |
| 1189 | .action = SET_ERROR_TYPE_WITH_ADDRESS, |
| 1190 | .instruction = WRITE_REGISTER, |
| 1191 | .flags = FLAG_PRESERVE, |
| 1192 | .reg = EINJ_REG_MEMORY((u64)(uintptr_t)&einj_smi->setaddrtable), |
| 1193 | .value = 1, |
| 1194 | .mask = 0xffffffff |
| 1195 | } |
| 1196 | }; |
| 1197 | |
| 1198 | einj_smi->err_inj_cap = ACPI_EINJ_DEFAULT_CAP; |
Elyes Haouas | 3141fbad | 2022-11-18 15:22:32 +0100 | [diff] [blame] | 1199 | einj_smi->trigger_action_table = (u64)(uintptr_t)tat; |
Rocky Phagura | eff0713 | 2021-01-10 15:42:50 -0800 | [diff] [blame] | 1200 | |
| 1201 | for (i = 0; i < ACTION_COUNT; i++) |
| 1202 | printk(BIOS_DEBUG, "default_actions[%d].reg.addr is %llx\n", i, |
| 1203 | default_actions[i].reg.addr); |
| 1204 | |
Rocky Phagura | b46a9e5 | 2021-05-21 13:34:03 -0700 | [diff] [blame] | 1205 | memset((void *)einj, 0, sizeof(*einj)); |
Rocky Phagura | eff0713 | 2021-01-10 15:42:50 -0800 | [diff] [blame] | 1206 | |
| 1207 | /* Fill out header fields. */ |
| 1208 | memcpy(header->signature, "EINJ", 4); |
| 1209 | memcpy(header->oem_id, OEM_ID, 6); |
| 1210 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 1211 | memcpy(header->asl_compiler_id, ASLC, 4); |
| 1212 | |
| 1213 | header->asl_compiler_revision = asl_revision; |
| 1214 | header->length = sizeof(acpi_einj_t); |
| 1215 | header->revision = 1; |
| 1216 | inj_header->einj_header_size = sizeof(acpi_injection_header_t); |
| 1217 | inj_header->entry_count = ACTION_COUNT; |
| 1218 | |
| 1219 | printk(BIOS_DEBUG, "%s einj->action_table = %p\n", |
| 1220 | __func__, einj->action_table); |
| 1221 | memcpy((void *)einj->action_table, (void *)default_actions, sizeof(einj->action_table)); |
Rocky Phagura | b46a9e5 | 2021-05-21 13:34:03 -0700 | [diff] [blame] | 1222 | header->checksum = acpi_checksum((void *)einj, sizeof(*einj)); |
Rocky Phagura | eff0713 | 2021-01-10 15:42:50 -0800 | [diff] [blame] | 1223 | } |
| 1224 | |
Furquan Shaikh | 0f007d8 | 2020-04-24 06:41:18 -0700 | [diff] [blame] | 1225 | void acpi_create_vfct(const struct device *device, |
Himanshu Sahdev | 7f1da07 | 2019-10-21 15:27:19 +0530 | [diff] [blame] | 1226 | acpi_vfct_t *vfct, |
Furquan Shaikh | 0f007d8 | 2020-04-24 06:41:18 -0700 | [diff] [blame] | 1227 | unsigned long (*acpi_fill_vfct)(const struct device *device, |
Himanshu Sahdev | 7f1da07 | 2019-10-21 15:27:19 +0530 | [diff] [blame] | 1228 | acpi_vfct_t *vfct_struct, unsigned long current)) |
Patrick Rudolph | a5c2ac6 | 2016-03-31 20:04:23 +0200 | [diff] [blame] | 1229 | { |
| 1230 | acpi_header_t *header = &(vfct->header); |
Himanshu Sahdev | 7f1da07 | 2019-10-21 15:27:19 +0530 | [diff] [blame] | 1231 | unsigned long current = (unsigned long)vfct + sizeof(acpi_vfct_t); |
Patrick Rudolph | a5c2ac6 | 2016-03-31 20:04:23 +0200 | [diff] [blame] | 1232 | |
Himanshu Sahdev | 7f1da07 | 2019-10-21 15:27:19 +0530 | [diff] [blame] | 1233 | memset((void *)vfct, 0, sizeof(acpi_vfct_t)); |
Patrick Rudolph | a5c2ac6 | 2016-03-31 20:04:23 +0200 | [diff] [blame] | 1234 | |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 1235 | if (!header) |
| 1236 | return; |
| 1237 | |
Patrick Rudolph | a5c2ac6 | 2016-03-31 20:04:23 +0200 | [diff] [blame] | 1238 | /* Fill out header fields. */ |
| 1239 | memcpy(header->signature, "VFCT", 4); |
| 1240 | memcpy(header->oem_id, OEM_ID, 6); |
| 1241 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 1242 | memcpy(header->asl_compiler_id, ASLC, 4); |
| 1243 | |
Elyes HAOUAS | f8f2e8c | 2019-02-25 15:42:07 +0100 | [diff] [blame] | 1244 | header->asl_compiler_revision = asl_revision; |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 1245 | header->revision = get_acpi_table_revision(VFCT); |
Patrick Rudolph | a5c2ac6 | 2016-03-31 20:04:23 +0200 | [diff] [blame] | 1246 | |
| 1247 | current = acpi_fill_vfct(device, vfct, current); |
| 1248 | |
Kyösti Mälkki | fb49379 | 2019-06-30 06:29:52 +0300 | [diff] [blame] | 1249 | /* If no BIOS image, return with header->length == 0. */ |
| 1250 | if (!vfct->VBIOSImageOffset) |
| 1251 | return; |
| 1252 | |
Patrick Rudolph | a5c2ac6 | 2016-03-31 20:04:23 +0200 | [diff] [blame] | 1253 | /* (Re)calculate length and checksum. */ |
| 1254 | header->length = current - (unsigned long)vfct; |
| 1255 | header->checksum = acpi_checksum((void *)vfct, header->length); |
| 1256 | } |
| 1257 | |
Furquan Shaikh | 0f007d8 | 2020-04-24 06:41:18 -0700 | [diff] [blame] | 1258 | void acpi_create_ipmi(const struct device *device, |
Patrick Rudolph | 9d98e5a | 2019-06-14 19:00:04 +0200 | [diff] [blame] | 1259 | struct acpi_spmi *spmi, |
| 1260 | const u16 ipmi_revision, |
| 1261 | const acpi_addr_t *addr, |
| 1262 | const enum acpi_ipmi_interface_type type, |
| 1263 | const s8 gpe_interrupt, |
| 1264 | const u32 apic_interrupt, |
| 1265 | const u32 uid) |
| 1266 | { |
| 1267 | acpi_header_t *header = &(spmi->header); |
| 1268 | memset((void *)spmi, 0, sizeof(struct acpi_spmi)); |
| 1269 | |
| 1270 | /* Fill out header fields. */ |
| 1271 | memcpy(header->signature, "SPMI", 4); |
| 1272 | memcpy(header->oem_id, OEM_ID, 6); |
| 1273 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 1274 | memcpy(header->asl_compiler_id, ASLC, 4); |
| 1275 | |
| 1276 | header->asl_compiler_revision = asl_revision; |
| 1277 | header->length = sizeof(struct acpi_spmi); |
| 1278 | header->revision = get_acpi_table_revision(SPMI); |
| 1279 | |
| 1280 | spmi->reserved = 1; |
| 1281 | |
| 1282 | if (device->path.type == DEVICE_PATH_PCI) { |
| 1283 | spmi->pci_device_flag = ACPI_IPMI_PCI_DEVICE_FLAG; |
| 1284 | spmi->pci_bus = device->bus->secondary; |
| 1285 | spmi->pci_device = device->path.pci.devfn >> 3; |
| 1286 | spmi->pci_function = device->path.pci.devfn & 0x7; |
| 1287 | } else if (type != IPMI_INTERFACE_SSIF) { |
| 1288 | memcpy(spmi->uid, &uid, sizeof(spmi->uid)); |
| 1289 | } |
| 1290 | |
| 1291 | spmi->base_address = *addr; |
| 1292 | spmi->specification_revision = ipmi_revision; |
| 1293 | |
| 1294 | spmi->interface_type = type; |
| 1295 | |
| 1296 | if (gpe_interrupt >= 0 && gpe_interrupt < 32) { |
| 1297 | spmi->gpe = gpe_interrupt; |
| 1298 | spmi->interrupt_type |= ACPI_IPMI_INT_TYPE_SCI; |
| 1299 | } |
| 1300 | if (apic_interrupt > 0) { |
| 1301 | spmi->global_system_interrupt = apic_interrupt; |
| 1302 | spmi->interrupt_type |= ACPI_IPMI_INT_TYPE_APIC; |
| 1303 | } |
| 1304 | |
| 1305 | /* Calculate checksum. */ |
| 1306 | header->checksum = acpi_checksum((void *)spmi, header->length); |
| 1307 | } |
| 1308 | |
Timothy Pearson | ff8ccf0 | 2015-08-11 17:48:32 -0500 | [diff] [blame] | 1309 | void acpi_create_ivrs(acpi_ivrs_t *ivrs, |
Lee Leahy | 6f80ccc | 2017-03-16 15:18:22 -0700 | [diff] [blame] | 1310 | unsigned long (*acpi_fill_ivrs)(acpi_ivrs_t *ivrs_struct, |
| 1311 | unsigned long current)) |
Timothy Pearson | ff8ccf0 | 2015-08-11 17:48:32 -0500 | [diff] [blame] | 1312 | { |
| 1313 | acpi_header_t *header = &(ivrs->header); |
| 1314 | unsigned long current = (unsigned long)ivrs + sizeof(acpi_ivrs_t); |
| 1315 | |
| 1316 | memset((void *)ivrs, 0, sizeof(acpi_ivrs_t)); |
| 1317 | |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 1318 | if (!header) |
| 1319 | return; |
| 1320 | |
Timothy Pearson | ff8ccf0 | 2015-08-11 17:48:32 -0500 | [diff] [blame] | 1321 | /* Fill out header fields. */ |
| 1322 | memcpy(header->signature, "IVRS", 4); |
| 1323 | memcpy(header->oem_id, OEM_ID, 6); |
| 1324 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 1325 | memcpy(header->asl_compiler_id, ASLC, 4); |
| 1326 | |
Elyes HAOUAS | f8f2e8c | 2019-02-25 15:42:07 +0100 | [diff] [blame] | 1327 | header->asl_compiler_revision = asl_revision; |
Timothy Pearson | ff8ccf0 | 2015-08-11 17:48:32 -0500 | [diff] [blame] | 1328 | header->length = sizeof(acpi_ivrs_t); |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 1329 | header->revision = get_acpi_table_revision(IVRS); |
Timothy Pearson | ff8ccf0 | 2015-08-11 17:48:32 -0500 | [diff] [blame] | 1330 | |
| 1331 | current = acpi_fill_ivrs(ivrs, current); |
| 1332 | |
| 1333 | /* (Re)calculate length and checksum. */ |
| 1334 | header->length = current - (unsigned long)ivrs; |
| 1335 | header->checksum = acpi_checksum((void *)ivrs, header->length); |
| 1336 | } |
| 1337 | |
Jason Glenesk | 61624b2 | 2020-11-02 20:06:23 -0800 | [diff] [blame] | 1338 | void acpi_create_crat(struct acpi_crat_header *crat, |
| 1339 | unsigned long (*acpi_fill_crat)(struct acpi_crat_header *crat_struct, |
| 1340 | unsigned long current)) |
| 1341 | { |
| 1342 | acpi_header_t *header = &(crat->header); |
| 1343 | unsigned long current = (unsigned long)crat + sizeof(struct acpi_crat_header); |
| 1344 | |
| 1345 | memset((void *)crat, 0, sizeof(struct acpi_crat_header)); |
| 1346 | |
| 1347 | if (!header) |
| 1348 | return; |
| 1349 | |
| 1350 | /* Fill out header fields. */ |
| 1351 | memcpy(header->signature, "CRAT", 4); |
| 1352 | memcpy(header->oem_id, OEM_ID, 6); |
| 1353 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 1354 | memcpy(header->asl_compiler_id, ASLC, 4); |
| 1355 | |
| 1356 | header->asl_compiler_revision = asl_revision; |
| 1357 | header->length = sizeof(struct acpi_crat_header); |
| 1358 | header->revision = get_acpi_table_revision(CRAT); |
| 1359 | |
| 1360 | current = acpi_fill_crat(crat, current); |
| 1361 | |
| 1362 | /* (Re)calculate length and checksum. */ |
| 1363 | header->length = current - (unsigned long)crat; |
| 1364 | header->checksum = acpi_checksum((void *)crat, header->length); |
| 1365 | } |
| 1366 | |
Furquan Shaikh | 0f007d8 | 2020-04-24 06:41:18 -0700 | [diff] [blame] | 1367 | unsigned long acpi_write_hpet(const struct device *device, unsigned long current, |
Lee Leahy | 6f80ccc | 2017-03-16 15:18:22 -0700 | [diff] [blame] | 1368 | acpi_rsdp_t *rsdp) |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1369 | { |
| 1370 | acpi_hpet_t *hpet; |
| 1371 | |
| 1372 | /* |
| 1373 | * We explicitly add these tables later on: |
| 1374 | */ |
| 1375 | printk(BIOS_DEBUG, "ACPI: * HPET\n"); |
| 1376 | |
Elyes Haouas | 3141fbad | 2022-11-18 15:22:32 +0100 | [diff] [blame] | 1377 | hpet = (acpi_hpet_t *)current; |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1378 | current += sizeof(acpi_hpet_t); |
Felix Held | c469712 | 2019-06-20 13:50:17 +0200 | [diff] [blame] | 1379 | current = ALIGN_UP(current, 16); |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1380 | acpi_create_hpet(hpet); |
| 1381 | acpi_add_table(rsdp, hpet); |
| 1382 | |
| 1383 | return current; |
| 1384 | } |
| 1385 | |
Arthur Heymans | 9368cf9 | 2023-04-25 16:07:49 +0200 | [diff] [blame] | 1386 | static void acpi_create_dbg2(acpi_dbg2_header_t *dbg2, |
Duncan Laurie | e4a36c7 | 2017-11-11 19:33:25 -0800 | [diff] [blame] | 1387 | int port_type, int port_subtype, |
| 1388 | acpi_addr_t *address, uint32_t address_size, |
| 1389 | const char *device_path) |
| 1390 | { |
| 1391 | uintptr_t current; |
| 1392 | acpi_dbg2_device_t *device; |
| 1393 | uint32_t *dbg2_addr_size; |
| 1394 | acpi_header_t *header; |
| 1395 | size_t path_len; |
| 1396 | const char *path; |
| 1397 | char *namespace; |
| 1398 | |
| 1399 | /* Fill out header fields. */ |
| 1400 | current = (uintptr_t)dbg2; |
| 1401 | memset(dbg2, 0, sizeof(acpi_dbg2_header_t)); |
| 1402 | header = &(dbg2->header); |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 1403 | |
| 1404 | if (!header) |
| 1405 | return; |
| 1406 | |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 1407 | header->revision = get_acpi_table_revision(DBG2); |
Duncan Laurie | e4a36c7 | 2017-11-11 19:33:25 -0800 | [diff] [blame] | 1408 | memcpy(header->signature, "DBG2", 4); |
| 1409 | memcpy(header->oem_id, OEM_ID, 6); |
| 1410 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 1411 | memcpy(header->asl_compiler_id, ASLC, 4); |
Elyes HAOUAS | f8f2e8c | 2019-02-25 15:42:07 +0100 | [diff] [blame] | 1412 | header->asl_compiler_revision = asl_revision; |
Duncan Laurie | e4a36c7 | 2017-11-11 19:33:25 -0800 | [diff] [blame] | 1413 | |
| 1414 | /* One debug device defined */ |
| 1415 | dbg2->devices_offset = sizeof(acpi_dbg2_header_t); |
| 1416 | dbg2->devices_count = 1; |
| 1417 | current += sizeof(acpi_dbg2_header_t); |
| 1418 | |
| 1419 | /* Device comes after the header */ |
| 1420 | device = (acpi_dbg2_device_t *)current; |
| 1421 | memset(device, 0, sizeof(acpi_dbg2_device_t)); |
| 1422 | current += sizeof(acpi_dbg2_device_t); |
| 1423 | |
| 1424 | device->revision = 0; |
| 1425 | device->address_count = 1; |
| 1426 | device->port_type = port_type; |
| 1427 | device->port_subtype = port_subtype; |
| 1428 | |
| 1429 | /* Base Address comes after device structure */ |
| 1430 | memcpy((void *)current, address, sizeof(acpi_addr_t)); |
| 1431 | device->base_address_offset = current - (uintptr_t)device; |
| 1432 | current += sizeof(acpi_addr_t); |
| 1433 | |
| 1434 | /* Address Size comes after address structure */ |
| 1435 | dbg2_addr_size = (uint32_t *)current; |
| 1436 | device->address_size_offset = current - (uintptr_t)device; |
| 1437 | *dbg2_addr_size = address_size; |
| 1438 | current += sizeof(uint32_t); |
| 1439 | |
| 1440 | /* Namespace string comes last, use '.' if not provided */ |
| 1441 | path = device_path ? : "."; |
| 1442 | /* Namespace string length includes NULL terminator */ |
| 1443 | path_len = strlen(path) + 1; |
| 1444 | namespace = (char *)current; |
| 1445 | device->namespace_string_length = path_len; |
| 1446 | device->namespace_string_offset = current - (uintptr_t)device; |
| 1447 | strncpy(namespace, path, path_len); |
| 1448 | current += path_len; |
| 1449 | |
| 1450 | /* Update structure lengths and checksum */ |
| 1451 | device->length = current - (uintptr_t)device; |
| 1452 | header->length = current - (uintptr_t)dbg2; |
| 1453 | header->checksum = acpi_checksum((uint8_t *)dbg2, header->length); |
| 1454 | } |
| 1455 | |
| 1456 | 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] | 1457 | const struct device *dev, uint8_t access_size) |
Duncan Laurie | e4a36c7 | 2017-11-11 19:33:25 -0800 | [diff] [blame] | 1458 | { |
| 1459 | acpi_dbg2_header_t *dbg2 = (acpi_dbg2_header_t *)current; |
| 1460 | struct resource *res; |
| 1461 | acpi_addr_t address; |
| 1462 | |
| 1463 | if (!dev) { |
Wim Vervoorn | 6cd5243 | 2020-02-03 14:41:46 +0100 | [diff] [blame] | 1464 | printk(BIOS_DEBUG, "%s: Device not found\n", __func__); |
Duncan Laurie | e4a36c7 | 2017-11-11 19:33:25 -0800 | [diff] [blame] | 1465 | return current; |
| 1466 | } |
Mario Scheithauer | f1eb0ea | 2017-11-21 13:52:53 +0100 | [diff] [blame] | 1467 | if (!dev->enabled) { |
| 1468 | printk(BIOS_INFO, "%s: Device not enabled\n", __func__); |
| 1469 | return current; |
| 1470 | } |
Angel Pons | 32d09be | 2021-11-03 13:27:45 +0100 | [diff] [blame] | 1471 | res = probe_resource(dev, PCI_BASE_ADDRESS_0); |
Duncan Laurie | e4a36c7 | 2017-11-11 19:33:25 -0800 | [diff] [blame] | 1472 | if (!res) { |
| 1473 | printk(BIOS_ERR, "%s: Unable to find resource for %s\n", |
| 1474 | __func__, dev_path(dev)); |
| 1475 | return current; |
| 1476 | } |
| 1477 | |
| 1478 | memset(&address, 0, sizeof(address)); |
| 1479 | if (res->flags & IORESOURCE_IO) |
| 1480 | address.space_id = ACPI_ADDRESS_SPACE_IO; |
| 1481 | else if (res->flags & IORESOURCE_MEM) |
| 1482 | address.space_id = ACPI_ADDRESS_SPACE_MEMORY; |
| 1483 | else { |
| 1484 | printk(BIOS_ERR, "%s: Unknown address space type\n", __func__); |
| 1485 | return current; |
| 1486 | } |
| 1487 | |
| 1488 | address.addrl = (uint32_t)res->base; |
| 1489 | address.addrh = (uint32_t)((res->base >> 32) & 0xffffffff); |
| 1490 | address.access_size = access_size; |
| 1491 | |
| 1492 | acpi_create_dbg2(dbg2, |
| 1493 | ACPI_DBG2_PORT_SERIAL, |
| 1494 | ACPI_DBG2_PORT_SERIAL_16550, |
| 1495 | &address, res->size, |
| 1496 | acpi_device_path(dev)); |
| 1497 | |
| 1498 | if (dbg2->header.length) { |
| 1499 | current += dbg2->header.length; |
| 1500 | current = acpi_align_current(current); |
| 1501 | acpi_add_table(rsdp, dbg2); |
| 1502 | } |
| 1503 | |
| 1504 | return current; |
| 1505 | } |
| 1506 | |
Arthur Heymans | 9368cf9 | 2023-04-25 16:07:49 +0200 | [diff] [blame] | 1507 | static void acpi_create_facs(acpi_facs_t *facs) |
Ronald G. Minnich | 02fa3b2 | 2004-10-06 17:33:54 +0000 | [diff] [blame] | 1508 | { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1509 | memset((void *)facs, 0, sizeof(acpi_facs_t)); |
Ronald G. Minnich | 02fa3b2 | 2004-10-06 17:33:54 +0000 | [diff] [blame] | 1510 | |
Stefan Reinauer | cdfe376 | 2009-07-21 22:15:43 +0000 | [diff] [blame] | 1511 | memcpy(facs->signature, "FACS", 4); |
Ronald G. Minnich | 02fa3b2 | 2004-10-06 17:33:54 +0000 | [diff] [blame] | 1512 | facs->length = sizeof(acpi_facs_t); |
| 1513 | facs->hardware_signature = 0; |
| 1514 | facs->firmware_waking_vector = 0; |
| 1515 | facs->global_lock = 0; |
| 1516 | facs->flags = 0; |
| 1517 | facs->x_firmware_waking_vector_l = 0; |
| 1518 | facs->x_firmware_waking_vector_h = 0; |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 1519 | facs->version = get_acpi_table_revision(FACS); |
Ronald G. Minnich | 02fa3b2 | 2004-10-06 17:33:54 +0000 | [diff] [blame] | 1520 | } |
Stefan Reinauer | 777224c | 2005-01-19 14:06:41 +0000 | [diff] [blame] | 1521 | |
Vladimir Serbinenko | 351fefc | 2014-10-26 20:42:08 +0100 | [diff] [blame] | 1522 | 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] | 1523 | { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1524 | acpi_header_t *header = &(rsdt->header); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 1525 | |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 1526 | if (!header) |
| 1527 | return; |
| 1528 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1529 | /* Fill out header fields. */ |
Stefan Reinauer | cdfe376 | 2009-07-21 22:15:43 +0000 | [diff] [blame] | 1530 | memcpy(header->signature, "RSDT", 4); |
Vladimir Serbinenko | 351fefc | 2014-10-26 20:42:08 +0100 | [diff] [blame] | 1531 | memcpy(header->oem_id, oem_id, 6); |
| 1532 | memcpy(header->oem_table_id, oem_table_id, 8); |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 1533 | memcpy(header->asl_compiler_id, ASLC, 4); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 1534 | |
Elyes HAOUAS | f8f2e8c | 2019-02-25 15:42:07 +0100 | [diff] [blame] | 1535 | header->asl_compiler_revision = asl_revision; |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 1536 | header->length = sizeof(acpi_rsdt_t); |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 1537 | header->revision = get_acpi_table_revision(RSDT); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 1538 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1539 | /* Entries are filled in later, we come with an empty set. */ |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 1540 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1541 | /* Fix checksum. */ |
Stefan Reinauer | b657a3c | 2009-07-21 21:38:33 +0000 | [diff] [blame] | 1542 | header->checksum = acpi_checksum((void *)rsdt, sizeof(acpi_rsdt_t)); |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 1543 | } |
| 1544 | |
Vladimir Serbinenko | 351fefc | 2014-10-26 20:42:08 +0100 | [diff] [blame] | 1545 | 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] | 1546 | { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1547 | acpi_header_t *header = &(xsdt->header); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 1548 | |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 1549 | if (!header) |
| 1550 | return; |
| 1551 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1552 | /* Fill out header fields. */ |
Stefan Reinauer | cdfe376 | 2009-07-21 22:15:43 +0000 | [diff] [blame] | 1553 | memcpy(header->signature, "XSDT", 4); |
Vladimir Serbinenko | 351fefc | 2014-10-26 20:42:08 +0100 | [diff] [blame] | 1554 | memcpy(header->oem_id, oem_id, 6); |
| 1555 | memcpy(header->oem_table_id, oem_table_id, 8); |
Stefan Reinauer | b657a3c | 2009-07-21 21:38:33 +0000 | [diff] [blame] | 1556 | memcpy(header->asl_compiler_id, ASLC, 4); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 1557 | |
Elyes HAOUAS | f8f2e8c | 2019-02-25 15:42:07 +0100 | [diff] [blame] | 1558 | header->asl_compiler_revision = asl_revision; |
Stefan Reinauer | b657a3c | 2009-07-21 21:38:33 +0000 | [diff] [blame] | 1559 | header->length = sizeof(acpi_xsdt_t); |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 1560 | header->revision = get_acpi_table_revision(XSDT); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 1561 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1562 | /* Entries are filled in later, we come with an empty set. */ |
Stefan Reinauer | b657a3c | 2009-07-21 21:38:33 +0000 | [diff] [blame] | 1563 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1564 | /* Fix checksum. */ |
Stefan Reinauer | b657a3c | 2009-07-21 21:38:33 +0000 | [diff] [blame] | 1565 | header->checksum = acpi_checksum((void *)xsdt, sizeof(acpi_xsdt_t)); |
| 1566 | } |
| 1567 | |
Vladimir Serbinenko | 351fefc | 2014-10-26 20:42:08 +0100 | [diff] [blame] | 1568 | static void acpi_write_rsdp(acpi_rsdp_t *rsdp, acpi_rsdt_t *rsdt, |
| 1569 | acpi_xsdt_t *xsdt, char *oem_id) |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 1570 | { |
Stefan Reinauer | d18faac | 2009-11-05 18:06:43 +0000 | [diff] [blame] | 1571 | memset(rsdp, 0, sizeof(acpi_rsdp_t)); |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1572 | |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 1573 | memcpy(rsdp->signature, RSDP_SIG, 8); |
Vladimir Serbinenko | 351fefc | 2014-10-26 20:42:08 +0100 | [diff] [blame] | 1574 | memcpy(rsdp->oem_id, oem_id, 6); |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1575 | |
| 1576 | rsdp->length = sizeof(acpi_rsdp_t); |
Stefan Reinauer | defee17 | 2015-06-18 01:11:19 -0700 | [diff] [blame] | 1577 | rsdp->rsdt_address = (uintptr_t)rsdt; |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1578 | |
| 1579 | /* |
| 1580 | * Revision: ACPI 1.0: 0, ACPI 2.0/3.0/4.0: 2. |
| 1581 | * |
| 1582 | * Some OSes expect an XSDT to be present for RSD PTR revisions >= 2. |
| 1583 | * If we don't have an ACPI XSDT, force ACPI 1.0 (and thus RSD PTR |
| 1584 | * revision 0). |
Stefan Reinauer | b657a3c | 2009-07-21 21:38:33 +0000 | [diff] [blame] | 1585 | */ |
| 1586 | if (xsdt == NULL) { |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1587 | rsdp->revision = 0; |
Stefan Reinauer | b657a3c | 2009-07-21 21:38:33 +0000 | [diff] [blame] | 1588 | } else { |
Stefan Reinauer | defee17 | 2015-06-18 01:11:19 -0700 | [diff] [blame] | 1589 | rsdp->xsdt_address = (u64)(uintptr_t)xsdt; |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 1590 | rsdp->revision = get_acpi_table_revision(RSDP); |
Stefan Reinauer | b657a3c | 2009-07-21 21:38:33 +0000 | [diff] [blame] | 1591 | } |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 1592 | |
| 1593 | /* Calculate checksums. */ |
| 1594 | rsdp->checksum = acpi_checksum((void *)rsdp, 20); |
| 1595 | rsdp->ext_checksum = acpi_checksum((void *)rsdp, sizeof(acpi_rsdp_t)); |
Stefan Reinauer | 688b385 | 2004-01-28 16:56:14 +0000 | [diff] [blame] | 1596 | } |
| 1597 | |
Lee Leahy | 6f80ccc | 2017-03-16 15:18:22 -0700 | [diff] [blame] | 1598 | unsigned long acpi_create_hest_error_source(acpi_hest_t *hest, |
| 1599 | acpi_hest_esd_t *esd, u16 type, void *data, u16 data_len) |
zbao | caf494c8 | 2012-04-13 13:57:14 +0800 | [diff] [blame] | 1600 | { |
| 1601 | acpi_header_t *header = &(hest->header); |
| 1602 | acpi_hest_hen_t *hen; |
| 1603 | void *pos; |
| 1604 | u16 len; |
| 1605 | |
| 1606 | pos = esd; |
| 1607 | memset(pos, 0, sizeof(acpi_hest_esd_t)); |
| 1608 | len = 0; |
| 1609 | esd->type = type; /* MCE */ |
| 1610 | esd->source_id = hest->error_source_count; |
| 1611 | esd->flags = 0; /* FIRMWARE_FIRST */ |
| 1612 | esd->enabled = 1; |
| 1613 | esd->prealloc_erecords = 1; |
| 1614 | esd->max_section_per_record = 0x1; |
| 1615 | |
| 1616 | len += sizeof(acpi_hest_esd_t); |
| 1617 | pos = esd + 1; |
| 1618 | |
| 1619 | switch (type) { |
| 1620 | case 0: /* MCE */ |
| 1621 | break; |
| 1622 | case 1: /* CMC */ |
Elyes Haouas | 3141fbad | 2022-11-18 15:22:32 +0100 | [diff] [blame] | 1623 | hen = (acpi_hest_hen_t *)(pos); |
zbao | caf494c8 | 2012-04-13 13:57:14 +0800 | [diff] [blame] | 1624 | memset(pos, 0, sizeof(acpi_hest_hen_t)); |
| 1625 | hen->type = 3; /* SCI? */ |
| 1626 | hen->length = sizeof(acpi_hest_hen_t); |
Lee Leahy | 6f80ccc | 2017-03-16 15:18:22 -0700 | [diff] [blame] | 1627 | hen->conf_we = 0; /* Configuration Write Enable. */ |
zbao | caf494c8 | 2012-04-13 13:57:14 +0800 | [diff] [blame] | 1628 | hen->poll_interval = 0; |
| 1629 | hen->vector = 0; |
| 1630 | hen->sw2poll_threshold_val = 0; |
| 1631 | hen->sw2poll_threshold_win = 0; |
| 1632 | hen->error_threshold_val = 0; |
| 1633 | hen->error_threshold_win = 0; |
| 1634 | len += sizeof(acpi_hest_hen_t); |
| 1635 | pos = hen + 1; |
| 1636 | break; |
| 1637 | case 2: /* NMI */ |
| 1638 | case 6: /* AER Root Port */ |
| 1639 | case 7: /* AER Endpoint */ |
| 1640 | case 8: /* AER Bridge */ |
| 1641 | case 9: /* Generic Hardware Error Source. */ |
| 1642 | /* TODO: */ |
| 1643 | break; |
| 1644 | default: |
| 1645 | printk(BIOS_DEBUG, "Invalid type of Error Source."); |
| 1646 | break; |
| 1647 | } |
Lee Leahy | 024b13d | 2017-03-16 13:41:11 -0700 | [diff] [blame] | 1648 | hest->error_source_count++; |
zbao | caf494c8 | 2012-04-13 13:57:14 +0800 | [diff] [blame] | 1649 | |
| 1650 | memcpy(pos, data, data_len); |
| 1651 | len += data_len; |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 1652 | if (header) |
| 1653 | header->length += len; |
zbao | caf494c8 | 2012-04-13 13:57:14 +0800 | [diff] [blame] | 1654 | |
| 1655 | return len; |
| 1656 | } |
| 1657 | |
| 1658 | /* ACPI 4.0 */ |
Vladimir Serbinenko | 807127f | 2014-11-09 13:36:18 +0100 | [diff] [blame] | 1659 | void acpi_write_hest(acpi_hest_t *hest, |
| 1660 | unsigned long (*acpi_fill_hest)(acpi_hest_t *hest)) |
zbao | caf494c8 | 2012-04-13 13:57:14 +0800 | [diff] [blame] | 1661 | { |
| 1662 | acpi_header_t *header = &(hest->header); |
| 1663 | |
| 1664 | memset(hest, 0, sizeof(acpi_hest_t)); |
| 1665 | |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 1666 | if (!header) |
| 1667 | return; |
| 1668 | |
zbao | caf494c8 | 2012-04-13 13:57:14 +0800 | [diff] [blame] | 1669 | memcpy(header->signature, "HEST", 4); |
| 1670 | memcpy(header->oem_id, OEM_ID, 6); |
| 1671 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 1672 | memcpy(header->asl_compiler_id, ASLC, 4); |
Elyes HAOUAS | f8f2e8c | 2019-02-25 15:42:07 +0100 | [diff] [blame] | 1673 | header->asl_compiler_revision = asl_revision; |
zbao | caf494c8 | 2012-04-13 13:57:14 +0800 | [diff] [blame] | 1674 | header->length += sizeof(acpi_hest_t); |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 1675 | header->revision = get_acpi_table_revision(HEST); |
zbao | caf494c8 | 2012-04-13 13:57:14 +0800 | [diff] [blame] | 1676 | |
| 1677 | acpi_fill_hest(hest); |
| 1678 | |
| 1679 | /* Calculate checksums. */ |
| 1680 | header->checksum = acpi_checksum((void *)hest, header->length); |
| 1681 | } |
| 1682 | |
Marshall Dawson | 1d8d369 | 2018-09-04 13:45:26 -0600 | [diff] [blame] | 1683 | /* ACPI 3.0b */ |
Arthur Heymans | 9368cf9 | 2023-04-25 16:07:49 +0200 | [diff] [blame] | 1684 | static void acpi_write_bert(acpi_bert_t *bert, uintptr_t region, size_t length) |
Marshall Dawson | 1d8d369 | 2018-09-04 13:45:26 -0600 | [diff] [blame] | 1685 | { |
| 1686 | acpi_header_t *header = &(bert->header); |
| 1687 | |
| 1688 | memset(bert, 0, sizeof(acpi_bert_t)); |
| 1689 | |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 1690 | if (!header) |
| 1691 | return; |
| 1692 | |
Marshall Dawson | 1d8d369 | 2018-09-04 13:45:26 -0600 | [diff] [blame] | 1693 | memcpy(header->signature, "BERT", 4); |
| 1694 | memcpy(header->oem_id, OEM_ID, 6); |
| 1695 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 1696 | memcpy(header->asl_compiler_id, ASLC, 4); |
Elyes HAOUAS | f8f2e8c | 2019-02-25 15:42:07 +0100 | [diff] [blame] | 1697 | header->asl_compiler_revision = asl_revision; |
Marshall Dawson | 1d8d369 | 2018-09-04 13:45:26 -0600 | [diff] [blame] | 1698 | header->length += sizeof(acpi_bert_t); |
| 1699 | header->revision = get_acpi_table_revision(BERT); |
| 1700 | |
| 1701 | bert->error_region = region; |
| 1702 | bert->region_length = length; |
| 1703 | |
| 1704 | /* Calculate checksums. */ |
| 1705 | header->checksum = acpi_checksum((void *)bert, header->length); |
| 1706 | } |
| 1707 | |
Angel Pons | 79572e4 | 2020-07-13 00:17:43 +0200 | [diff] [blame] | 1708 | __weak void arch_fill_fadt(acpi_fadt_t *fadt) { } |
Kyösti Mälkki | f9aac92 | 2020-05-30 16:16:28 +0300 | [diff] [blame] | 1709 | __weak void soc_fill_fadt(acpi_fadt_t *fadt) { } |
Kyösti Mälkki | 02fd15d | 2020-06-02 03:34:43 +0300 | [diff] [blame] | 1710 | __weak void mainboard_fill_fadt(acpi_fadt_t *fadt) { } |
Kyösti Mälkki | f9aac92 | 2020-05-30 16:16:28 +0300 | [diff] [blame] | 1711 | |
Arthur Heymans | 9368cf9 | 2023-04-25 16:07:49 +0200 | [diff] [blame] | 1712 | static 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] | 1713 | { |
| 1714 | acpi_header_t *header = &(fadt->header); |
| 1715 | |
Elyes Haouas | 3141fbad | 2022-11-18 15:22:32 +0100 | [diff] [blame] | 1716 | memset((void *)fadt, 0, sizeof(acpi_fadt_t)); |
John Zhao | 2ba303e | 2019-05-28 16:48:14 -0700 | [diff] [blame] | 1717 | |
| 1718 | if (!header) |
| 1719 | return; |
| 1720 | |
Vladimir Serbinenko | c21e073 | 2014-10-16 12:48:19 +0200 | [diff] [blame] | 1721 | memcpy(header->signature, "FACP", 4); |
| 1722 | header->length = sizeof(acpi_fadt_t); |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 1723 | header->revision = get_acpi_table_revision(FADT); |
Vladimir Serbinenko | c21e073 | 2014-10-16 12:48:19 +0200 | [diff] [blame] | 1724 | memcpy(header->oem_id, OEM_ID, 6); |
| 1725 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 1726 | memcpy(header->asl_compiler_id, ASLC, 4); |
Elyes HAOUAS | 26071aa | 2019-02-15 08:21:33 +0100 | [diff] [blame] | 1727 | header->asl_compiler_revision = asl_revision; |
Vladimir Serbinenko | c21e073 | 2014-10-16 12:48:19 +0200 | [diff] [blame] | 1728 | |
Elyes Haouas | 532e043 | 2022-02-21 18:13:58 +0100 | [diff] [blame] | 1729 | fadt->FADT_MinorVersion = get_acpi_fadt_minor_version(); |
Elyes Haouas | 3141fbad | 2022-11-18 15:22:32 +0100 | [diff] [blame] | 1730 | fadt->firmware_ctrl = (unsigned long)facs; |
Vladimir Serbinenko | c21e073 | 2014-10-16 12:48:19 +0200 | [diff] [blame] | 1731 | fadt->x_firmware_ctl_l = (unsigned long)facs; |
| 1732 | fadt->x_firmware_ctl_h = 0; |
Kyösti Mälkki | d4acee8 | 2020-06-03 07:20:55 +0300 | [diff] [blame] | 1733 | |
Elyes Haouas | 3141fbad | 2022-11-18 15:22:32 +0100 | [diff] [blame] | 1734 | fadt->dsdt = (unsigned long)dsdt; |
Vladimir Serbinenko | c21e073 | 2014-10-16 12:48:19 +0200 | [diff] [blame] | 1735 | fadt->x_dsdt_l = (unsigned long)dsdt; |
| 1736 | fadt->x_dsdt_h = 0; |
| 1737 | |
Kyösti Mälkki | d4acee8 | 2020-06-03 07:20:55 +0300 | [diff] [blame] | 1738 | /* should be 0 ACPI 3.0 */ |
| 1739 | fadt->reserved = 0; |
| 1740 | |
Kyösti Mälkki | 67c48a3 | 2023-04-14 10:20:03 +0300 | [diff] [blame] | 1741 | /* P_LVLx latencies are not used as CPU _CST will override them. */ |
| 1742 | fadt->p_lvl2_lat = ACPI_FADT_C2_NOT_SUPPORTED; |
| 1743 | fadt->p_lvl3_lat = ACPI_FADT_C3_NOT_SUPPORTED; |
| 1744 | |
Kyösti Mälkki | 9ff9797 | 2023-04-14 15:37:27 +0300 | [diff] [blame] | 1745 | /* Use CPU _PTC instead to provide P_CNT details. */ |
| 1746 | fadt->duty_offset = 0; |
| 1747 | fadt->duty_width = 0; |
| 1748 | |
Kyösti Mälkki | e0d3868 | 2020-06-07 12:01:58 +0300 | [diff] [blame] | 1749 | fadt->preferred_pm_profile = acpi_get_preferred_pm_profile(); |
Vladimir Serbinenko | c21e073 | 2014-10-16 12:48:19 +0200 | [diff] [blame] | 1750 | |
Kyösti Mälkki | e742b68 | 2023-04-10 17:03:32 +0300 | [diff] [blame] | 1751 | fadt->sci_int = acpi_sci_int(); |
| 1752 | |
Angel Pons | 79572e4 | 2020-07-13 00:17:43 +0200 | [diff] [blame] | 1753 | arch_fill_fadt(fadt); |
| 1754 | |
Vladimir Serbinenko | ab83ef0 | 2014-10-25 15:18:25 +0200 | [diff] [blame] | 1755 | acpi_fill_fadt(fadt); |
Vladimir Serbinenko | c21e073 | 2014-10-16 12:48:19 +0200 | [diff] [blame] | 1756 | |
Kyösti Mälkki | f9aac92 | 2020-05-30 16:16:28 +0300 | [diff] [blame] | 1757 | soc_fill_fadt(fadt); |
Kyösti Mälkki | 02fd15d | 2020-06-02 03:34:43 +0300 | [diff] [blame] | 1758 | mainboard_fill_fadt(fadt); |
Kyösti Mälkki | f9aac92 | 2020-05-30 16:16:28 +0300 | [diff] [blame] | 1759 | |
Vladimir Serbinenko | c21e073 | 2014-10-16 12:48:19 +0200 | [diff] [blame] | 1760 | header->checksum = |
Elyes Haouas | 3141fbad | 2022-11-18 15:22:32 +0100 | [diff] [blame] | 1761 | acpi_checksum((void *)fadt, header->length); |
Vladimir Serbinenko | c21e073 | 2014-10-16 12:48:19 +0200 | [diff] [blame] | 1762 | } |
Vladimir Serbinenko | c21e073 | 2014-10-16 12:48:19 +0200 | [diff] [blame] | 1763 | |
Arthur Heymans | 9368cf9 | 2023-04-25 16:07:49 +0200 | [diff] [blame] | 1764 | static void acpi_create_lpit(acpi_lpit_t *lpit) |
Michael Niewöhner | f0a44ae | 2021-01-01 21:04:09 +0100 | [diff] [blame] | 1765 | { |
| 1766 | acpi_header_t *header = &(lpit->header); |
| 1767 | unsigned long current = (unsigned long)lpit + sizeof(acpi_lpit_t); |
| 1768 | |
| 1769 | memset((void *)lpit, 0, sizeof(acpi_lpit_t)); |
| 1770 | |
| 1771 | if (!header) |
| 1772 | return; |
| 1773 | |
| 1774 | /* Fill out header fields. */ |
| 1775 | memcpy(header->signature, "LPIT", 4); |
| 1776 | memcpy(header->oem_id, OEM_ID, 6); |
| 1777 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 1778 | memcpy(header->asl_compiler_id, ASLC, 4); |
| 1779 | |
| 1780 | header->asl_compiler_revision = asl_revision; |
| 1781 | header->revision = get_acpi_table_revision(LPIT); |
| 1782 | header->oem_revision = 42; |
| 1783 | header->length = sizeof(acpi_lpit_t); |
| 1784 | |
| 1785 | current = acpi_fill_lpit(current); |
| 1786 | |
| 1787 | /* (Re)calculate length and checksum. */ |
| 1788 | header->length = current - (unsigned long)lpit; |
| 1789 | header->checksum = acpi_checksum((void *)lpit, header->length); |
| 1790 | } |
| 1791 | |
| 1792 | unsigned long acpi_create_lpi_desc_ncst(acpi_lpi_desc_ncst_t *lpi_desc, uint16_t uid) |
| 1793 | { |
| 1794 | memset(lpi_desc, 0, sizeof(acpi_lpi_desc_ncst_t)); |
| 1795 | lpi_desc->header.length = sizeof(acpi_lpi_desc_ncst_t); |
| 1796 | lpi_desc->header.type = ACPI_LPI_DESC_TYPE_NATIVE_CSTATE; |
| 1797 | lpi_desc->header.uid = uid; |
| 1798 | |
| 1799 | return lpi_desc->header.length; |
| 1800 | } |
| 1801 | |
Aaron Durbin | 6403167 | 2018-04-21 14:45:32 -0600 | [diff] [blame] | 1802 | unsigned long __weak fw_cfg_acpi_tables(unsigned long start) |
Vladimir Serbinenko | 41877d8 | 2014-09-01 22:18:01 +0200 | [diff] [blame] | 1803 | { |
| 1804 | return 0; |
| 1805 | } |
| 1806 | |
Raul E Rangel | 6b446b9 | 2021-11-19 11:38:35 -0700 | [diff] [blame] | 1807 | void preload_acpi_dsdt(void) |
| 1808 | { |
| 1809 | const char *file = CONFIG_CBFS_PREFIX "/dsdt.aml"; |
| 1810 | |
| 1811 | if (!CONFIG(CBFS_PRELOAD)) |
| 1812 | return; |
| 1813 | |
| 1814 | printk(BIOS_DEBUG, "Preloading %s\n", file); |
| 1815 | cbfs_preload(file); |
| 1816 | } |
| 1817 | |
Arthur Heymans | 2e7e2d9 | 2022-03-03 22:28:27 +0100 | [diff] [blame] | 1818 | static uintptr_t coreboot_rsdp; |
| 1819 | |
| 1820 | uintptr_t get_coreboot_rsdp(void) |
| 1821 | { |
| 1822 | return coreboot_rsdp; |
| 1823 | } |
| 1824 | |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1825 | unsigned long write_acpi_tables(unsigned long start) |
| 1826 | { |
| 1827 | unsigned long current; |
| 1828 | acpi_rsdp_t *rsdp; |
| 1829 | acpi_rsdt_t *rsdt; |
| 1830 | acpi_xsdt_t *xsdt; |
| 1831 | acpi_fadt_t *fadt; |
| 1832 | acpi_facs_t *facs; |
Vladimir Serbinenko | 351fefc | 2014-10-26 20:42:08 +0100 | [diff] [blame] | 1833 | acpi_header_t *slic_file, *slic; |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1834 | acpi_header_t *ssdt; |
Vladimir Serbinenko | 36f8d27 | 2015-05-31 12:31:59 +0200 | [diff] [blame] | 1835 | acpi_header_t *dsdt_file, *dsdt; |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1836 | acpi_mcfg_t *mcfg; |
Vladimir Serbinenko | f44ac13 | 2015-05-20 19:52:01 +0200 | [diff] [blame] | 1837 | acpi_tcpa_t *tcpa; |
Philipp Deppenwiese | 296164e0 | 2018-10-18 15:39:34 +0200 | [diff] [blame] | 1838 | acpi_tpm2_t *tpm2; |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1839 | acpi_madt_t *madt; |
Michael Niewöhner | f0a44ae | 2021-01-01 21:04:09 +0100 | [diff] [blame] | 1840 | acpi_lpit_t *lpit; |
Francois Toguo | 522e0db | 2021-01-21 09:55:19 -0800 | [diff] [blame] | 1841 | acpi_bert_t *bert; |
Edward O'Callaghan | 2c9d2cf | 2014-10-27 23:29:29 +1100 | [diff] [blame] | 1842 | struct device *dev; |
Vladimir Serbinenko | 41877d8 | 2014-09-01 22:18:01 +0200 | [diff] [blame] | 1843 | unsigned long fw; |
Vladimir Serbinenko | 36f8d27 | 2015-05-31 12:31:59 +0200 | [diff] [blame] | 1844 | size_t slic_size, dsdt_size; |
Vladimir Serbinenko | 351fefc | 2014-10-26 20:42:08 +0100 | [diff] [blame] | 1845 | char oem_id[6], oem_table_id[8]; |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1846 | |
| 1847 | current = start; |
| 1848 | |
| 1849 | /* Align ACPI tables to 16byte */ |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame] | 1850 | current = acpi_align_current(current); |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1851 | |
Patrick Rudolph | cfe08ff | 2019-09-10 15:40:47 +0200 | [diff] [blame] | 1852 | /* Special case for qemu */ |
Vladimir Serbinenko | 41877d8 | 2014-09-01 22:18:01 +0200 | [diff] [blame] | 1853 | fw = fw_cfg_acpi_tables(current); |
Patrick Rudolph | cfe08ff | 2019-09-10 15:40:47 +0200 | [diff] [blame] | 1854 | if (fw) { |
| 1855 | rsdp = NULL; |
| 1856 | /* Find RSDP. */ |
| 1857 | for (void *p = (void *)current; p < (void *)fw; p += 16) { |
| 1858 | if (valid_rsdp((acpi_rsdp_t *)p)) { |
| 1859 | rsdp = p; |
Bin Meng | f3027b8 | 2023-05-09 15:21:49 +0800 | [diff] [blame] | 1860 | coreboot_rsdp = (uintptr_t)rsdp; |
Patrick Rudolph | cfe08ff | 2019-09-10 15:40:47 +0200 | [diff] [blame] | 1861 | break; |
| 1862 | } |
| 1863 | } |
| 1864 | if (!rsdp) |
| 1865 | return fw; |
| 1866 | |
| 1867 | /* Add BOOT0000 for Linux google firmware driver */ |
| 1868 | printk(BIOS_DEBUG, "ACPI: * SSDT\n"); |
| 1869 | ssdt = (acpi_header_t *)fw; |
| 1870 | current = (unsigned long)ssdt + sizeof(acpi_header_t); |
| 1871 | |
| 1872 | memset((void *)ssdt, 0, sizeof(acpi_header_t)); |
| 1873 | |
| 1874 | memcpy(&ssdt->signature, "SSDT", 4); |
| 1875 | ssdt->revision = get_acpi_table_revision(SSDT); |
| 1876 | memcpy(&ssdt->oem_id, OEM_ID, 6); |
| 1877 | memcpy(&ssdt->oem_table_id, oem_table_id, 8); |
| 1878 | ssdt->oem_revision = 42; |
| 1879 | memcpy(&ssdt->asl_compiler_id, ASLC, 4); |
| 1880 | ssdt->asl_compiler_revision = asl_revision; |
| 1881 | ssdt->length = sizeof(acpi_header_t); |
| 1882 | |
Elyes Haouas | 3141fbad | 2022-11-18 15:22:32 +0100 | [diff] [blame] | 1883 | acpigen_set_current((char *)current); |
Patrick Rudolph | cfe08ff | 2019-09-10 15:40:47 +0200 | [diff] [blame] | 1884 | |
| 1885 | /* Write object to declare coreboot tables */ |
| 1886 | acpi_ssdt_write_cbtable(); |
| 1887 | |
| 1888 | /* (Re)calculate length and checksum. */ |
| 1889 | ssdt->length = current - (unsigned long)ssdt; |
| 1890 | ssdt->checksum = acpi_checksum((void *)ssdt, ssdt->length); |
| 1891 | |
| 1892 | acpi_create_ssdt_generator(ssdt, ACPI_TABLE_CREATOR); |
| 1893 | |
| 1894 | acpi_add_table(rsdp, ssdt); |
| 1895 | |
Vladimir Serbinenko | 41877d8 | 2014-09-01 22:18:01 +0200 | [diff] [blame] | 1896 | return fw; |
Patrick Rudolph | cfe08ff | 2019-09-10 15:40:47 +0200 | [diff] [blame] | 1897 | } |
Vladimir Serbinenko | 41877d8 | 2014-09-01 22:18:01 +0200 | [diff] [blame] | 1898 | |
Julius Werner | 834b3ec | 2020-03-04 16:52:08 -0800 | [diff] [blame] | 1899 | dsdt_file = cbfs_map(CONFIG_CBFS_PREFIX "/dsdt.aml", &dsdt_size); |
Vladimir Serbinenko | 36f8d27 | 2015-05-31 12:31:59 +0200 | [diff] [blame] | 1900 | if (!dsdt_file) { |
| 1901 | printk(BIOS_ERR, "No DSDT file, skipping ACPI tables\n"); |
| 1902 | return current; |
| 1903 | } |
| 1904 | |
| 1905 | if (dsdt_file->length > dsdt_size |
Elyes HAOUAS | 7d87e76 | 2016-10-03 22:11:07 +0200 | [diff] [blame] | 1906 | || dsdt_file->length < sizeof(acpi_header_t) |
Vladimir Serbinenko | 36f8d27 | 2015-05-31 12:31:59 +0200 | [diff] [blame] | 1907 | || memcmp(dsdt_file->signature, "DSDT", 4) != 0) { |
| 1908 | printk(BIOS_ERR, "Invalid DSDT file, skipping ACPI tables\n"); |
Grzegorz Bernacki | 042ac35 | 2023-04-21 13:19:58 +0000 | [diff] [blame] | 1909 | cbfs_unmap(dsdt_file); |
Vladimir Serbinenko | 36f8d27 | 2015-05-31 12:31:59 +0200 | [diff] [blame] | 1910 | return current; |
| 1911 | } |
| 1912 | |
Julius Werner | 834b3ec | 2020-03-04 16:52:08 -0800 | [diff] [blame] | 1913 | slic_file = cbfs_map(CONFIG_CBFS_PREFIX "/slic", &slic_size); |
Vladimir Serbinenko | 2cb2978 | 2015-05-31 11:32:09 +0200 | [diff] [blame] | 1914 | if (slic_file |
| 1915 | && (slic_file->length > slic_size |
Elyes HAOUAS | 7d87e76 | 2016-10-03 22:11:07 +0200 | [diff] [blame] | 1916 | || slic_file->length < sizeof(acpi_header_t) |
Benjamin Doron | 2b2dc0c | 2020-09-12 02:55:57 +0000 | [diff] [blame] | 1917 | || (memcmp(slic_file->signature, "SLIC", 4) != 0 |
| 1918 | && memcmp(slic_file->signature, "MSDM", 4) != 0))) { |
Grzegorz Bernacki | 042ac35 | 2023-04-21 13:19:58 +0000 | [diff] [blame] | 1919 | cbfs_unmap(slic_file); |
Vladimir Serbinenko | 351fefc | 2014-10-26 20:42:08 +0100 | [diff] [blame] | 1920 | slic_file = 0; |
| 1921 | } |
| 1922 | |
| 1923 | if (slic_file) { |
| 1924 | memcpy(oem_id, slic_file->oem_id, 6); |
| 1925 | memcpy(oem_table_id, slic_file->oem_table_id, 8); |
| 1926 | } else { |
| 1927 | memcpy(oem_id, OEM_ID, 6); |
| 1928 | memcpy(oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 1929 | } |
| 1930 | |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1931 | printk(BIOS_INFO, "ACPI: Writing ACPI tables at %lx.\n", start); |
| 1932 | |
| 1933 | /* We need at least an RSDP and an RSDT Table */ |
Elyes Haouas | 3141fbad | 2022-11-18 15:22:32 +0100 | [diff] [blame] | 1934 | rsdp = (acpi_rsdp_t *)current; |
Arthur Heymans | 2e7e2d9 | 2022-03-03 22:28:27 +0100 | [diff] [blame] | 1935 | coreboot_rsdp = (uintptr_t)rsdp; |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1936 | current += sizeof(acpi_rsdp_t); |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame] | 1937 | current = acpi_align_current(current); |
Elyes Haouas | 3141fbad | 2022-11-18 15:22:32 +0100 | [diff] [blame] | 1938 | rsdt = (acpi_rsdt_t *)current; |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1939 | current += sizeof(acpi_rsdt_t); |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame] | 1940 | current = acpi_align_current(current); |
Elyes Haouas | 3141fbad | 2022-11-18 15:22:32 +0100 | [diff] [blame] | 1941 | xsdt = (acpi_xsdt_t *)current; |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1942 | current += sizeof(acpi_xsdt_t); |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame] | 1943 | current = acpi_align_current(current); |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1944 | |
| 1945 | /* clear all table memory */ |
Elyes Haouas | 3141fbad | 2022-11-18 15:22:32 +0100 | [diff] [blame] | 1946 | memset((void *)start, 0, current - start); |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1947 | |
Vladimir Serbinenko | 351fefc | 2014-10-26 20:42:08 +0100 | [diff] [blame] | 1948 | acpi_write_rsdp(rsdp, rsdt, xsdt, oem_id); |
| 1949 | acpi_write_rsdt(rsdt, oem_id, oem_table_id); |
| 1950 | acpi_write_xsdt(xsdt, oem_id, oem_table_id); |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1951 | |
| 1952 | printk(BIOS_DEBUG, "ACPI: * FACS\n"); |
Felix Held | c469712 | 2019-06-20 13:50:17 +0200 | [diff] [blame] | 1953 | current = ALIGN_UP(current, 64); |
Elyes Haouas | 3141fbad | 2022-11-18 15:22:32 +0100 | [diff] [blame] | 1954 | facs = (acpi_facs_t *)current; |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1955 | current += sizeof(acpi_facs_t); |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame] | 1956 | current = acpi_align_current(current); |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1957 | acpi_create_facs(facs); |
| 1958 | |
| 1959 | printk(BIOS_DEBUG, "ACPI: * DSDT\n"); |
Elyes Haouas | 3141fbad | 2022-11-18 15:22:32 +0100 | [diff] [blame] | 1960 | dsdt = (acpi_header_t *)current; |
Vladimir Serbinenko | 36f8d27 | 2015-05-31 12:31:59 +0200 | [diff] [blame] | 1961 | memcpy(dsdt, dsdt_file, sizeof(acpi_header_t)); |
Vladimir Serbinenko | 334fd8e | 2014-10-05 11:10:35 +0200 | [diff] [blame] | 1962 | if (dsdt->length >= sizeof(acpi_header_t)) { |
| 1963 | current += sizeof(acpi_header_t); |
| 1964 | |
Elyes Haouas | 3141fbad | 2022-11-18 15:22:32 +0100 | [diff] [blame] | 1965 | acpigen_set_current((char *)current); |
Kyösti Mälkki | 2ab4a96 | 2020-06-30 11:41:47 +0300 | [diff] [blame] | 1966 | |
Kyösti Mälkki | 37eb24b | 2021-01-11 18:40:37 +0200 | [diff] [blame] | 1967 | if (CONFIG(ACPI_SOC_NVS)) |
| 1968 | acpi_fill_gnvs(); |
Kyösti Mälkki | 3dc1792 | 2021-03-16 19:01:48 +0200 | [diff] [blame] | 1969 | if (CONFIG(CHROMEOS_NVS)) |
| 1970 | acpi_fill_cnvs(); |
Kyösti Mälkki | 2ab4a96 | 2020-06-30 11:41:47 +0300 | [diff] [blame] | 1971 | |
Vladimir Serbinenko | 334fd8e | 2014-10-05 11:10:35 +0200 | [diff] [blame] | 1972 | for (dev = all_devices; dev; dev = dev->next) |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame] | 1973 | if (dev->ops && dev->ops->acpi_inject_dsdt) |
| 1974 | dev->ops->acpi_inject_dsdt(dev); |
Elyes Haouas | 3141fbad | 2022-11-18 15:22:32 +0100 | [diff] [blame] | 1975 | current = (unsigned long)acpigen_get_current(); |
Vladimir Serbinenko | 334fd8e | 2014-10-05 11:10:35 +0200 | [diff] [blame] | 1976 | memcpy((char *)current, |
Vladimir Serbinenko | 36f8d27 | 2015-05-31 12:31:59 +0200 | [diff] [blame] | 1977 | (char *)dsdt_file + sizeof(acpi_header_t), |
Vladimir Serbinenko | 334fd8e | 2014-10-05 11:10:35 +0200 | [diff] [blame] | 1978 | dsdt->length - sizeof(acpi_header_t)); |
| 1979 | current += dsdt->length - sizeof(acpi_header_t); |
| 1980 | |
| 1981 | /* (Re)calculate length and checksum. */ |
| 1982 | dsdt->length = current - (unsigned long)dsdt; |
| 1983 | dsdt->checksum = 0; |
| 1984 | dsdt->checksum = acpi_checksum((void *)dsdt, dsdt->length); |
| 1985 | } |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1986 | |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame] | 1987 | current = acpi_align_current(current); |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1988 | |
| 1989 | printk(BIOS_DEBUG, "ACPI: * FADT\n"); |
Elyes Haouas | 3141fbad | 2022-11-18 15:22:32 +0100 | [diff] [blame] | 1990 | fadt = (acpi_fadt_t *)current; |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1991 | current += sizeof(acpi_fadt_t); |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame] | 1992 | current = acpi_align_current(current); |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 1993 | |
| 1994 | acpi_create_fadt(fadt, facs, dsdt); |
| 1995 | acpi_add_table(rsdp, fadt); |
| 1996 | |
Vladimir Serbinenko | 351fefc | 2014-10-26 20:42:08 +0100 | [diff] [blame] | 1997 | if (slic_file) { |
| 1998 | printk(BIOS_DEBUG, "ACPI: * SLIC\n"); |
| 1999 | slic = (acpi_header_t *)current; |
| 2000 | memcpy(slic, slic_file, slic_file->length); |
| 2001 | current += slic_file->length; |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame] | 2002 | current = acpi_align_current(current); |
Vladimir Serbinenko | 351fefc | 2014-10-26 20:42:08 +0100 | [diff] [blame] | 2003 | acpi_add_table(rsdp, slic); |
Grzegorz Bernacki | 042ac35 | 2023-04-21 13:19:58 +0000 | [diff] [blame] | 2004 | cbfs_unmap(slic_file); |
Vladimir Serbinenko | 351fefc | 2014-10-26 20:42:08 +0100 | [diff] [blame] | 2005 | } |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 2006 | |
Grzegorz Bernacki | 042ac35 | 2023-04-21 13:19:58 +0000 | [diff] [blame] | 2007 | /* |
| 2008 | * cbfs_unmap() uses mem_pool_free() which works correctly only |
| 2009 | * if freeing is done in reverse order than memory allocation. |
| 2010 | * This is why unmapping of dsdt_file must be done after |
| 2011 | * unmapping slic file. |
| 2012 | */ |
| 2013 | cbfs_unmap(dsdt_file); |
| 2014 | |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 2015 | printk(BIOS_DEBUG, "ACPI: * SSDT\n"); |
| 2016 | ssdt = (acpi_header_t *)current; |
| 2017 | acpi_create_ssdt_generator(ssdt, ACPI_TABLE_CREATOR); |
Vladimir Serbinenko | 9310df8 | 2014-10-10 20:40:41 +0200 | [diff] [blame] | 2018 | if (ssdt->length > sizeof(acpi_header_t)) { |
| 2019 | current += ssdt->length; |
| 2020 | acpi_add_table(rsdp, ssdt); |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame] | 2021 | current = acpi_align_current(current); |
Vladimir Serbinenko | 9310df8 | 2014-10-10 20:40:41 +0200 | [diff] [blame] | 2022 | } |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 2023 | |
| 2024 | printk(BIOS_DEBUG, "ACPI: * MCFG\n"); |
Elyes Haouas | 3141fbad | 2022-11-18 15:22:32 +0100 | [diff] [blame] | 2025 | mcfg = (acpi_mcfg_t *)current; |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 2026 | acpi_create_mcfg(mcfg); |
| 2027 | if (mcfg->header.length > sizeof(acpi_mcfg_t)) { |
| 2028 | current += mcfg->header.length; |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame] | 2029 | current = acpi_align_current(current); |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 2030 | acpi_add_table(rsdp, mcfg); |
| 2031 | } |
| 2032 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 2033 | if (CONFIG(TPM1)) { |
Philipp Deppenwiese | 296164e0 | 2018-10-18 15:39:34 +0200 | [diff] [blame] | 2034 | printk(BIOS_DEBUG, "ACPI: * TCPA\n"); |
Elyes Haouas | 3141fbad | 2022-11-18 15:22:32 +0100 | [diff] [blame] | 2035 | tcpa = (acpi_tcpa_t *)current; |
Philipp Deppenwiese | 296164e0 | 2018-10-18 15:39:34 +0200 | [diff] [blame] | 2036 | acpi_create_tcpa(tcpa); |
| 2037 | if (tcpa->header.length >= sizeof(acpi_tcpa_t)) { |
| 2038 | current += tcpa->header.length; |
| 2039 | current = acpi_align_current(current); |
| 2040 | acpi_add_table(rsdp, tcpa); |
| 2041 | } |
| 2042 | } |
| 2043 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 2044 | if (CONFIG(TPM2)) { |
Philipp Deppenwiese | 296164e0 | 2018-10-18 15:39:34 +0200 | [diff] [blame] | 2045 | printk(BIOS_DEBUG, "ACPI: * TPM2\n"); |
Elyes Haouas | 3141fbad | 2022-11-18 15:22:32 +0100 | [diff] [blame] | 2046 | tpm2 = (acpi_tpm2_t *)current; |
Philipp Deppenwiese | 296164e0 | 2018-10-18 15:39:34 +0200 | [diff] [blame] | 2047 | acpi_create_tpm2(tpm2); |
| 2048 | if (tpm2->header.length >= sizeof(acpi_tpm2_t)) { |
| 2049 | current += tpm2->header.length; |
| 2050 | current = acpi_align_current(current); |
| 2051 | acpi_add_table(rsdp, tpm2); |
| 2052 | } |
Vladimir Serbinenko | f44ac13 | 2015-05-20 19:52:01 +0200 | [diff] [blame] | 2053 | } |
| 2054 | |
Michael Niewöhner | f0a44ae | 2021-01-01 21:04:09 +0100 | [diff] [blame] | 2055 | if (CONFIG(ACPI_LPIT)) { |
| 2056 | printk(BIOS_DEBUG, "ACPI: * LPIT\n"); |
| 2057 | |
| 2058 | lpit = (acpi_lpit_t *)current; |
| 2059 | acpi_create_lpit(lpit); |
| 2060 | if (lpit->header.length >= sizeof(acpi_lpit_t)) { |
| 2061 | current += lpit->header.length; |
| 2062 | current = acpi_align_current(current); |
| 2063 | acpi_add_table(rsdp, lpit); |
| 2064 | } |
| 2065 | } |
| 2066 | |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 2067 | printk(BIOS_DEBUG, "ACPI: * MADT\n"); |
| 2068 | |
Elyes Haouas | 3141fbad | 2022-11-18 15:22:32 +0100 | [diff] [blame] | 2069 | madt = (acpi_madt_t *)current; |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 2070 | acpi_create_madt(madt); |
| 2071 | if (madt->header.length > sizeof(acpi_madt_t)) { |
Lee Leahy | 024b13d | 2017-03-16 13:41:11 -0700 | [diff] [blame] | 2072 | current += madt->header.length; |
| 2073 | acpi_add_table(rsdp, madt); |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 2074 | } |
Michael Niewöhner | f0a44ae | 2021-01-01 21:04:09 +0100 | [diff] [blame] | 2075 | |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame] | 2076 | current = acpi_align_current(current); |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 2077 | |
Felix Held | fba47926 | 2021-05-28 16:11:43 +0200 | [diff] [blame] | 2078 | if (CONFIG(ACPI_BERT)) { |
Francois Toguo | 522e0db | 2021-01-21 09:55:19 -0800 | [diff] [blame] | 2079 | void *region; |
| 2080 | size_t size; |
Elyes Haouas | 3141fbad | 2022-11-18 15:22:32 +0100 | [diff] [blame] | 2081 | bert = (acpi_bert_t *)current; |
Felix Held | fba47926 | 2021-05-28 16:11:43 +0200 | [diff] [blame] | 2082 | if (acpi_soc_get_bert_region(®ion, &size) == CB_SUCCESS) { |
| 2083 | printk(BIOS_DEBUG, "ACPI: * BERT\n"); |
| 2084 | acpi_write_bert(bert, (uintptr_t)region, size); |
| 2085 | if (bert->header.length >= sizeof(acpi_bert_t)) { |
| 2086 | current += bert->header.length; |
| 2087 | acpi_add_table(rsdp, bert); |
| 2088 | } |
| 2089 | current = acpi_align_current(current); |
Francois Toguo | 522e0db | 2021-01-21 09:55:19 -0800 | [diff] [blame] | 2090 | } |
Francois Toguo | 522e0db | 2021-01-21 09:55:19 -0800 | [diff] [blame] | 2091 | } |
| 2092 | |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 2093 | printk(BIOS_DEBUG, "current = %lx\n", current); |
| 2094 | |
| 2095 | for (dev = all_devices; dev; dev = dev->next) { |
| 2096 | if (dev->ops && dev->ops->write_acpi_tables) { |
Lee Leahy | 6f80ccc | 2017-03-16 15:18:22 -0700 | [diff] [blame] | 2097 | current = dev->ops->write_acpi_tables(dev, current, |
| 2098 | rsdp); |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame] | 2099 | current = acpi_align_current(current); |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 2100 | } |
| 2101 | } |
| 2102 | |
| 2103 | printk(BIOS_INFO, "ACPI: done.\n"); |
| 2104 | return current; |
| 2105 | } |
Vladimir Serbinenko | 2d7bd8a | 2014-08-30 19:28:05 +0200 | [diff] [blame] | 2106 | |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 2107 | static acpi_rsdp_t *valid_rsdp(acpi_rsdp_t *rsdp) |
| 2108 | { |
| 2109 | if (strncmp((char *)rsdp, RSDP_SIG, sizeof(RSDP_SIG) - 1) != 0) |
| 2110 | return NULL; |
| 2111 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 2112 | printk(BIOS_DEBUG, "Looking on %p for valid checksum\n", rsdp); |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 2113 | |
| 2114 | if (acpi_checksum((void *)rsdp, 20) != 0) |
| 2115 | return NULL; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 2116 | printk(BIOS_DEBUG, "Checksum 1 passed\n"); |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 2117 | |
| 2118 | if ((rsdp->revision > 1) && (acpi_checksum((void *)rsdp, |
| 2119 | rsdp->length) != 0)) |
| 2120 | return NULL; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 2121 | printk(BIOS_DEBUG, "Checksum 2 passed all OK\n"); |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 2122 | |
| 2123 | return rsdp; |
| 2124 | } |
| 2125 | |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 2126 | void *acpi_find_wakeup_vector(void) |
| 2127 | { |
| 2128 | char *p, *end; |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 2129 | acpi_rsdt_t *rsdt; |
| 2130 | acpi_facs_t *facs; |
Martin Roth | c5f4926 | 2012-12-14 19:17:55 -0700 | [diff] [blame] | 2131 | acpi_fadt_t *fadt = NULL; |
Kyösti Mälkki | 072d436b | 2016-06-17 08:44:40 +0300 | [diff] [blame] | 2132 | acpi_rsdp_t *rsdp = NULL; |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 2133 | void *wake_vec; |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 2134 | int i; |
| 2135 | |
Kyösti Mälkki | b8c7ea0 | 2020-11-17 16:41:38 +0200 | [diff] [blame] | 2136 | if (!acpi_is_wakeup_s3()) |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 2137 | return NULL; |
| 2138 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 2139 | printk(BIOS_DEBUG, "Trying to find the wakeup vector...\n"); |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 2140 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 2141 | /* Find RSDP. */ |
| 2142 | for (p = (char *)0xe0000; p < (char *)0xfffff; p += 16) { |
Lee Leahy | 0b5678f | 2017-03-16 16:01:40 -0700 | [diff] [blame] | 2143 | rsdp = valid_rsdp((acpi_rsdp_t *)p); |
| 2144 | if (rsdp) |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 2145 | break; |
| 2146 | } |
| 2147 | |
Angel Pons | 98a68ad | 2018-11-04 12:25:25 +0100 | [diff] [blame] | 2148 | if (rsdp == NULL) { |
| 2149 | printk(BIOS_ALERT, |
| 2150 | "No RSDP found, wake up from S3 not possible.\n"); |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 2151 | return NULL; |
Angel Pons | 98a68ad | 2018-11-04 12:25:25 +0100 | [diff] [blame] | 2152 | } |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 2153 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 2154 | printk(BIOS_DEBUG, "RSDP found at %p\n", rsdp); |
Stefan Reinauer | 71a3018 | 2015-07-30 16:28:13 -0700 | [diff] [blame] | 2155 | rsdt = (acpi_rsdt_t *)(uintptr_t)rsdp->rsdt_address; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 2156 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 2157 | end = (char *)rsdt + rsdt->header.length; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 2158 | 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] | 2159 | |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 2160 | for (i = 0; ((char *)&rsdt->entry[i]) < end; i++) { |
Stefan Reinauer | 71a3018 | 2015-07-30 16:28:13 -0700 | [diff] [blame] | 2161 | fadt = (acpi_fadt_t *)(uintptr_t)rsdt->entry[i]; |
Stefan Reinauer | cdfe376 | 2009-07-21 22:15:43 +0000 | [diff] [blame] | 2162 | if (strncmp((char *)fadt, "FACP", 4) == 0) |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 2163 | break; |
| 2164 | fadt = NULL; |
| 2165 | } |
| 2166 | |
Angel Pons | 98a68ad | 2018-11-04 12:25:25 +0100 | [diff] [blame] | 2167 | if (fadt == NULL) { |
| 2168 | printk(BIOS_ALERT, |
| 2169 | "No FADT found, wake up from S3 not possible.\n"); |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 2170 | return NULL; |
Angel Pons | 98a68ad | 2018-11-04 12:25:25 +0100 | [diff] [blame] | 2171 | } |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 2172 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 2173 | printk(BIOS_DEBUG, "FADT found at %p\n", fadt); |
Stefan Reinauer | 71a3018 | 2015-07-30 16:28:13 -0700 | [diff] [blame] | 2174 | facs = (acpi_facs_t *)(uintptr_t)fadt->firmware_ctrl; |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 2175 | |
Stefan Reinauer | 7e9771c | 2009-04-22 08:17:38 +0000 | [diff] [blame] | 2176 | if (facs == NULL) { |
Angel Pons | 98a68ad | 2018-11-04 12:25:25 +0100 | [diff] [blame] | 2177 | printk(BIOS_ALERT, |
| 2178 | "No FACS found, wake up from S3 not possible.\n"); |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 2179 | return NULL; |
Stefan Reinauer | 7e9771c | 2009-04-22 08:17:38 +0000 | [diff] [blame] | 2180 | } |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 2181 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 2182 | printk(BIOS_DEBUG, "FACS found at %p\n", facs); |
Stefan Reinauer | 71a3018 | 2015-07-30 16:28:13 -0700 | [diff] [blame] | 2183 | wake_vec = (void *)(uintptr_t)facs->firmware_waking_vector; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 2184 | printk(BIOS_DEBUG, "OS waking vector is %p\n", wake_vec); |
Uwe Hermann | 622824c | 2010-11-19 15:14:42 +0000 | [diff] [blame] | 2185 | |
Rudolf Marek | 33cafe5 | 2009-04-13 18:07:02 +0000 | [diff] [blame] | 2186 | return wake_vec; |
| 2187 | } |
| 2188 | |
Aaron Durbin | 6403167 | 2018-04-21 14:45:32 -0600 | [diff] [blame] | 2189 | __weak int acpi_get_gpe(int gpe) |
Duncan Laurie | 1f6e681 | 2016-09-19 12:04:19 -0700 | [diff] [blame] | 2190 | { |
| 2191 | return -1; /* implemented by SOC */ |
| 2192 | } |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 2193 | |
Elyes Haouas | 8b950f4 | 2022-02-16 12:08:16 +0100 | [diff] [blame] | 2194 | u8 get_acpi_fadt_minor_version(void) |
| 2195 | { |
| 2196 | return ACPI_FADT_MINOR_VERSION_0; |
| 2197 | } |
| 2198 | |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 2199 | int get_acpi_table_revision(enum acpi_tables table) |
| 2200 | { |
| 2201 | switch (table) { |
| 2202 | case FADT: |
Elyes Haouas | 8b950f4 | 2022-02-16 12:08:16 +0100 | [diff] [blame] | 2203 | return ACPI_FADT_REV_ACPI_6; |
Elyes HAOUAS | f288b39 | 2018-11-11 15:22:30 +0100 | [diff] [blame] | 2204 | case MADT: /* ACPI 3.0: 2, ACPI 4.0/5.0: 3, ACPI 6.2b/6.3: 5 */ |
Patrick Rudolph | 56a3ef2 | 2020-03-24 17:29:49 +0100 | [diff] [blame] | 2205 | return 3; |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 2206 | case MCFG: |
| 2207 | return 1; |
| 2208 | case TCPA: |
| 2209 | return 2; |
Philipp Deppenwiese | 296164e0 | 2018-10-18 15:39:34 +0200 | [diff] [blame] | 2210 | case TPM2: |
| 2211 | return 4; |
Martin Roth | 0949e73 | 2021-10-01 14:28:22 -0600 | [diff] [blame] | 2212 | case SSDT: /* ACPI 3.0 up to 6.3: 2 */ |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 2213 | return 2; |
Jonathan Zhang | a3311b9 | 2022-12-01 17:13:41 -0800 | [diff] [blame] | 2214 | case SRAT: /* ACPI 2.0: 1, ACPI 3.0: 2, ACPI 4.0 up to 6.4: 3 */ |
| 2215 | return 3; |
Jonathan Zhang | 2a4e1f4 | 2021-04-01 11:43:37 -0700 | [diff] [blame] | 2216 | case HMAT: /* ACPI 6.4: 2 */ |
| 2217 | return 2; |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 2218 | case DMAR: |
| 2219 | return 1; |
Martin Roth | 0949e73 | 2021-10-01 14:28:22 -0600 | [diff] [blame] | 2220 | case SLIT: /* ACPI 2.0 up to 6.3: 1 */ |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 2221 | return 1; |
Patrick Rudolph | 9d98e5a | 2019-06-14 19:00:04 +0200 | [diff] [blame] | 2222 | case SPMI: /* IMPI 2.0 */ |
| 2223 | return 5; |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 2224 | case HPET: /* Currently 1. Table added in ACPI 2.0. */ |
| 2225 | return 1; |
Elyes HAOUAS | f288b39 | 2018-11-11 15:22:30 +0100 | [diff] [blame] | 2226 | case VFCT: /* ACPI 2.0/3.0/4.0: 1 */ |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 2227 | return 1; |
| 2228 | case IVRS: |
Jason Glenesk | 1916f89 | 2020-07-24 02:51:30 -0700 | [diff] [blame] | 2229 | return IVRS_FORMAT_MIXED; |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 2230 | case DBG2: |
| 2231 | return 0; |
Martin Roth | 0949e73 | 2021-10-01 14:28:22 -0600 | [diff] [blame] | 2232 | case FACS: /* ACPI 2.0/3.0: 1, ACPI 4.0 up to 6.3: 2 */ |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 2233 | return 1; |
Martin Roth | 0949e73 | 2021-10-01 14:28:22 -0600 | [diff] [blame] | 2234 | case RSDT: /* ACPI 1.0 up to 6.3: 1 */ |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 2235 | return 1; |
Martin Roth | 0949e73 | 2021-10-01 14:28:22 -0600 | [diff] [blame] | 2236 | case XSDT: /* ACPI 2.0 up to 6.3: 1 */ |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 2237 | return 1; |
Martin Roth | 0949e73 | 2021-10-01 14:28:22 -0600 | [diff] [blame] | 2238 | case RSDP: /* ACPI 2.0 up to 6.3: 2 */ |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 2239 | return 2; |
Rocky Phagura | eff0713 | 2021-01-10 15:42:50 -0800 | [diff] [blame] | 2240 | case EINJ: |
| 2241 | return 1; |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 2242 | case HEST: |
| 2243 | return 1; |
| 2244 | case NHLT: |
| 2245 | return 5; |
Marshall Dawson | 44705c6 | 2018-09-04 13:47:15 -0600 | [diff] [blame] | 2246 | case BERT: |
| 2247 | return 1; |
Jonathan Zhang | a3311b9 | 2022-12-01 17:13:41 -0800 | [diff] [blame] | 2248 | case CEDT: /* CXL 3.0 section 9.17.1 */ |
| 2249 | return 1; |
Jason Glenesk | 61624b2 | 2020-11-02 20:06:23 -0800 | [diff] [blame] | 2250 | case CRAT: |
| 2251 | return 1; |
Michael Niewöhner | f0a44ae | 2021-01-01 21:04:09 +0100 | [diff] [blame] | 2252 | case LPIT: /* ACPI 5.1 up to 6.3: 0 */ |
| 2253 | return 0; |
Marc Jones | 93a5176 | 2018-08-22 18:57:24 -0600 | [diff] [blame] | 2254 | default: |
| 2255 | return -1; |
| 2256 | } |
| 2257 | return -1; |
| 2258 | } |