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