blob: 5893461f438f99b4293864bb81fea61dc87b0c4a [file] [log] [blame]
Stefan Reinauer688b3852004-01-28 16:56:14 +00001/*
Uwe Hermannc70e9fc2010-02-15 23:10:19 +00002 * This file is part of the coreboot project.
3 *
Stefan Reinauerf8ee1802008-01-18 15:08:58 +00004 * coreboot ACPI Table support
Stefan Reinauer688b3852004-01-28 16:56:14 +00005 * written by Stefan Reinauer <stepan@openbios.org>
Uwe Hermannc70e9fc2010-02-15 23:10:19 +00006 *
7 * Copyright (C) 2004 SUSE LINUX AG
8 * Copyright (C) 2005-2009 coresystems GmbH
Timothy Pearsonff8ccf02015-08-11 17:48:32 -05009 * Copyright (C) 2015 Timothy Pearson <tpearson@raptorengineeringinc.com>, Raptor Engineering
Werner Zehd4d76952016-07-27 06:56:36 +020010 * Copyright (C) 2016 Siemens AG
Stefan Reinauer777224c2005-01-19 14:06:41 +000011 *
Stefan Reinauer14e22772010-04-27 06:56:47 +000012 * ACPI FADT, FACS, and DSDT table support added by
Ronald G. Minnich02fa3b22004-10-06 17:33:54 +000013 * Nick Barker <nick.barker9@btinternet.com>, and those portions
Uwe Hermannc70e9fc2010-02-15 23:10:19 +000014 * Copyright (C) 2004 Nick Barker
Stefan Reinauerf622d592005-11-26 16:56:05 +000015 *
Uwe Hermannc70e9fc2010-02-15 23:10:19 +000016 * Copyright (C) 2005 ADVANCED MICRO DEVICES, INC. All Rights Reserved.
Stefan Reinauerd6edf7a2006-01-05 00:19:52 +000017 * 2005.9 yhlu add SRAT table generation
Martin Roth9df9e9392016-01-12 15:55:28 -070018 *
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; version 2 of the License.
22 *
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
Stefan Reinauer777224c2005-01-19 14:06:41 +000027 */
28
Stefan Reinauer14e22772010-04-27 06:56:47 +000029/*
Stefan Reinauer777224c2005-01-19 14:06:41 +000030 * Each system port implementing ACPI has to provide two functions:
Stefan Reinauer14e22772010-04-27 06:56:47 +000031 *
Stefan Reinauer777224c2005-01-19 14:06:41 +000032 * write_acpi_tables()
33 * acpi_dump_apics()
Stefan Reinauer14e22772010-04-27 06:56:47 +000034 *
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +000035 * See Kontron 986LCD-M port for a good example of an ACPI implementation
36 * in coreboot.
Ronald G. Minnich02fa3b22004-10-06 17:33:54 +000037 */
Stefan Reinauer688b3852004-01-28 16:56:14 +000038
39#include <console/console.h>
40#include <string.h>
41#include <arch/acpi.h>
Rudolf Marek293b5f52009-02-01 18:35:15 +000042#include <arch/acpigen.h>
Stefan Reinauer777224c2005-01-19 14:06:41 +000043#include <device/pci.h>
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +000044#include <cbmem.h>
Patrick Georgic8feedd2012-02-16 18:43:25 +010045#include <cpu/x86/lapic_def.h>
Duncan Laurie11290c42012-10-03 19:07:05 -070046#include <cpu/cpu.h>
Vladimir Serbinenko351fefc2014-10-26 20:42:08 +010047#include <cbfs.h>
Ronald G. Minnich02fa3b22004-10-06 17:33:54 +000048
49u8 acpi_checksum(u8 *table, u32 length)
Stefan Reinauer688b3852004-01-28 16:56:14 +000050{
Uwe Hermann622824c2010-11-19 15:14:42 +000051 u8 ret = 0;
Stefan Reinauer688b3852004-01-28 16:56:14 +000052 while (length--) {
53 ret += *table;
54 table++;
55 }
Stefan Reinauera7648c22004-01-29 17:31:34 +000056 return -ret;
Stefan Reinauer688b3852004-01-28 16:56:14 +000057}
58
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +000059/**
Uwe Hermann622824c2010-11-19 15:14:42 +000060 * Add an ACPI table to the RSDT (and XSDT) structure, recalculate length
61 * and checksum.
Stefan Reinauer06feb882004-02-03 16:11:35 +000062 */
Stefan Reinauerb657a3c2009-07-21 21:38:33 +000063void acpi_add_table(acpi_rsdp_t *rsdp, void *table)
Stefan Reinauer688b3852004-01-28 16:56:14 +000064{
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +000065 int i, entries_num;
Stefan Reinauerb657a3c2009-07-21 21:38:33 +000066 acpi_rsdt_t *rsdt;
67 acpi_xsdt_t *xsdt = NULL;
68
Uwe Hermann622824c2010-11-19 15:14:42 +000069 /* The RSDT is mandatory... */
Stefan Reinauerdefee172015-06-18 01:11:19 -070070 rsdt = (acpi_rsdt_t *)(uintptr_t)rsdp->rsdt_address;
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +000071
Uwe Hermann622824c2010-11-19 15:14:42 +000072 /* ...while the XSDT is not. */
73 if (rsdp->xsdt_address)
Stefan Reinauerdefee172015-06-18 01:11:19 -070074 xsdt = (acpi_xsdt_t *)((uintptr_t)rsdp->xsdt_address);
Stefan Reinauer14e22772010-04-27 06:56:47 +000075
Uwe Hermann622824c2010-11-19 15:14:42 +000076 /* This should always be MAX_ACPI_TABLES. */
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +000077 entries_num = ARRAY_SIZE(rsdt->entry);
Stefan Reinauer14e22772010-04-27 06:56:47 +000078
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +000079 for (i = 0; i < entries_num; i++) {
Uwe Hermann622824c2010-11-19 15:14:42 +000080 if (rsdt->entry[i] == 0)
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +000081 break;
Stefan Reinauer688b3852004-01-28 16:56:14 +000082 }
83
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +000084 if (i >= entries_num) {
Uwe Hermann622824c2010-11-19 15:14:42 +000085 printk(BIOS_ERR, "ACPI: Error: Could not add ACPI table, "
Cristian Măgherușan-Stanciuba482812011-07-02 00:57:07 +030086 "too many tables.\n");
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +000087 return;
88 }
89
Uwe Hermann622824c2010-11-19 15:14:42 +000090 /* Add table to the RSDT. */
Stefan Reinauerdefee172015-06-18 01:11:19 -070091 rsdt->entry[i] = (uintptr_t)table;
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +000092
Uwe Hermann622824c2010-11-19 15:14:42 +000093 /* Fix RSDT length or the kernel will assume invalid entries. */
94 rsdt->header.length = sizeof(acpi_header_t) + (sizeof(u32) * (i + 1));
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +000095
Uwe Hermann622824c2010-11-19 15:14:42 +000096 /* Re-calculate checksum. */
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +000097 rsdt->header.checksum = 0; /* Hope this won't get optimized away */
Uwe Hermann622824c2010-11-19 15:14:42 +000098 rsdt->header.checksum = acpi_checksum((u8 *)rsdt, rsdt->header.length);
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +000099
Uwe Hermann622824c2010-11-19 15:14:42 +0000100 /*
101 * And now the same thing for the XSDT. We use the same index as for
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +0000102 * now we want the XSDT and RSDT to always be in sync in coreboot.
103 */
104 if (xsdt) {
Uwe Hermann622824c2010-11-19 15:14:42 +0000105 /* Add table to the XSDT. */
Stefan Reinauerdefee172015-06-18 01:11:19 -0700106 xsdt->entry[i] = (u64)(uintptr_t)table;
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +0000107
Uwe Hermann622824c2010-11-19 15:14:42 +0000108 /* Fix XSDT length. */
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +0000109 xsdt->header.length = sizeof(acpi_header_t) +
Cristian Măgherușan-Stanciuba482812011-07-02 00:57:07 +0300110 (sizeof(u64) * (i + 1));
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +0000111
Uwe Hermann622824c2010-11-19 15:14:42 +0000112 /* Re-calculate checksum. */
113 xsdt->header.checksum = 0;
114 xsdt->header.checksum = acpi_checksum((u8 *)xsdt,
Cristian Măgherușan-Stanciuba482812011-07-02 00:57:07 +0300115 xsdt->header.length);
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +0000116 }
117
Uwe Hermann622824c2010-11-19 15:14:42 +0000118 printk(BIOS_DEBUG, "ACPI: added table %d/%d, length now %d\n",
Cristian Măgherușan-Stanciuba482812011-07-02 00:57:07 +0300119 i + 1, entries_num, rsdt->header.length);
Stefan Reinauer688b3852004-01-28 16:56:14 +0000120}
121
Uwe Hermann622824c2010-11-19 15:14:42 +0000122int acpi_create_mcfg_mmconfig(acpi_mcfg_mmconfig_t *mmconfig, u32 base,
Cristian Măgherușan-Stanciuba482812011-07-02 00:57:07 +0300123 u16 seg_nr, u8 start, u8 end)
Stefan Reinauer26d431a2009-01-20 19:17:51 +0000124{
Vladimir Serbinenko60fccdc2014-10-05 11:05:16 +0200125 memset(mmconfig, 0, sizeof(*mmconfig));
Rudolf Mareke6409f22007-11-03 12:50:26 +0000126 mmconfig->base_address = base;
127 mmconfig->base_reserved = 0;
128 mmconfig->pci_segment_group_number = seg_nr;
129 mmconfig->start_bus_number = start;
130 mmconfig->end_bus_number = end;
Uwe Hermann622824c2010-11-19 15:14:42 +0000131
132 return sizeof(acpi_mcfg_mmconfig_t);
Rudolf Mareke6409f22007-11-03 12:50:26 +0000133}
134
Stefan Reinauer777224c2005-01-19 14:06:41 +0000135int acpi_create_madt_lapic(acpi_madt_lapic_t *lapic, u8 cpu, u8 apic)
Stefan Reinauer06feb882004-02-03 16:11:35 +0000136{
Uwe Hermann622824c2010-11-19 15:14:42 +0000137 lapic->type = 0; /* Local APIC structure */
138 lapic->length = sizeof(acpi_madt_lapic_t);
139 lapic->flags = (1 << 0); /* Processor/LAPIC enabled */
140 lapic->processor_id = cpu;
141 lapic->apic_id = apic;
Stefan Reinauer14e22772010-04-27 06:56:47 +0000142
Uwe Hermann622824c2010-11-19 15:14:42 +0000143 return lapic->length;
Stefan Reinauer06feb882004-02-03 16:11:35 +0000144}
145
Stefan Reinauerda65fbf2009-04-22 08:18:37 +0000146unsigned long acpi_create_madt_lapics(unsigned long current)
147{
Edward O'Callaghan2c9d2cf2014-10-27 23:29:29 +1100148 struct device *cpu;
Duncan Laurie11290c42012-10-03 19:07:05 -0700149 int index = 0;
Stefan Reinauerda65fbf2009-04-22 08:18:37 +0000150
Uwe Hermann622824c2010-11-19 15:14:42 +0000151 for (cpu = all_devices; cpu; cpu = cpu->next) {
Stefan Reinauerda65fbf2009-04-22 08:18:37 +0000152 if ((cpu->path.type != DEVICE_PATH_APIC) ||
Stefan Reinauer0aa37c42013-02-12 15:20:54 -0800153 (cpu->bus->dev->path.type != DEVICE_PATH_CPU_CLUSTER)) {
Stefan Reinauerda65fbf2009-04-22 08:18:37 +0000154 continue;
155 }
Uwe Hermann622824c2010-11-19 15:14:42 +0000156 if (!cpu->enabled)
Stefan Reinauerda65fbf2009-04-22 08:18:37 +0000157 continue;
Uwe Hermann622824c2010-11-19 15:14:42 +0000158 current += acpi_create_madt_lapic((acpi_madt_lapic_t *)current,
Duncan Laurie11290c42012-10-03 19:07:05 -0700159 index, cpu->path.apic.apic_id);
160 index++;
Stefan Reinauerda65fbf2009-04-22 08:18:37 +0000161 }
Uwe Hermann622824c2010-11-19 15:14:42 +0000162
Stefan Reinauerda65fbf2009-04-22 08:18:37 +0000163 return current;
164}
165
Uwe Hermann622824c2010-11-19 15:14:42 +0000166int acpi_create_madt_ioapic(acpi_madt_ioapic_t *ioapic, u8 id, u32 addr,
Cristian Măgherușan-Stanciuba482812011-07-02 00:57:07 +0300167 u32 gsi_base)
Stefan Reinauer06feb882004-02-03 16:11:35 +0000168{
Uwe Hermann622824c2010-11-19 15:14:42 +0000169 ioapic->type = 1; /* I/O APIC structure */
170 ioapic->length = sizeof(acpi_madt_ioapic_t);
171 ioapic->reserved = 0x00;
172 ioapic->gsi_base = gsi_base;
173 ioapic->ioapic_id = id;
174 ioapic->ioapic_addr = addr;
Stefan Reinauer14e22772010-04-27 06:56:47 +0000175
Uwe Hermann622824c2010-11-19 15:14:42 +0000176 return ioapic->length;
Stefan Reinauer06feb882004-02-03 16:11:35 +0000177}
178
Stefan Reinauer777224c2005-01-19 14:06:41 +0000179int acpi_create_madt_irqoverride(acpi_madt_irqoverride_t *irqoverride,
Stefan Reinauer06feb882004-02-03 16:11:35 +0000180 u8 bus, u8 source, u32 gsirq, u16 flags)
181{
Uwe Hermann622824c2010-11-19 15:14:42 +0000182 irqoverride->type = 2; /* Interrupt source override */
183 irqoverride->length = sizeof(acpi_madt_irqoverride_t);
184 irqoverride->bus = bus;
185 irqoverride->source = source;
186 irqoverride->gsirq = gsirq;
187 irqoverride->flags = flags;
Stefan Reinauer14e22772010-04-27 06:56:47 +0000188
Uwe Hermann622824c2010-11-19 15:14:42 +0000189 return irqoverride->length;
Stefan Reinauer06feb882004-02-03 16:11:35 +0000190}
191
Stefan Reinauer777224c2005-01-19 14:06:41 +0000192int acpi_create_madt_lapic_nmi(acpi_madt_lapic_nmi_t *lapic_nmi, u8 cpu,
Cristian Măgherușan-Stanciuba482812011-07-02 00:57:07 +0300193 u16 flags, u8 lint)
Stefan Reinauer06feb882004-02-03 16:11:35 +0000194{
Uwe Hermann622824c2010-11-19 15:14:42 +0000195 lapic_nmi->type = 4; /* Local APIC NMI structure */
196 lapic_nmi->length = sizeof(acpi_madt_lapic_nmi_t);
197 lapic_nmi->flags = flags;
198 lapic_nmi->processor_id = cpu;
199 lapic_nmi->lint = lint;
Stefan Reinauer14e22772010-04-27 06:56:47 +0000200
Uwe Hermann622824c2010-11-19 15:14:42 +0000201 return lapic_nmi->length;
Stefan Reinauer06feb882004-02-03 16:11:35 +0000202}
203
Stefan Reinauer777224c2005-01-19 14:06:41 +0000204void acpi_create_madt(acpi_madt_t *madt)
Stefan Reinauer06feb882004-02-03 16:11:35 +0000205{
Uwe Hermann622824c2010-11-19 15:14:42 +0000206 acpi_header_t *header = &(madt->header);
207 unsigned long current = (unsigned long)madt + sizeof(acpi_madt_t);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000208
Stefan Reinauer06feb882004-02-03 16:11:35 +0000209 memset((void *)madt, 0, sizeof(acpi_madt_t));
Stefan Reinauer14e22772010-04-27 06:56:47 +0000210
Uwe Hermann622824c2010-11-19 15:14:42 +0000211 /* Fill out header fields. */
Stefan Reinauercdfe3762009-07-21 22:15:43 +0000212 memcpy(header->signature, "APIC", 4);
Stefan Reinauer06feb882004-02-03 16:11:35 +0000213 memcpy(header->oem_id, OEM_ID, 6);
Stefan Reinauercdfe3762009-07-21 22:15:43 +0000214 memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
Stefan Reinauer06feb882004-02-03 16:11:35 +0000215 memcpy(header->asl_compiler_id, ASLC, 4);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000216
Stefan Reinauer06feb882004-02-03 16:11:35 +0000217 header->length = sizeof(acpi_madt_t);
Uwe Hermann622824c2010-11-19 15:14:42 +0000218 header->revision = 1; /* ACPI 1.0/2.0: 1, ACPI 3.0: 2, ACPI 4.0: 3 */
Stefan Reinauer06feb882004-02-03 16:11:35 +0000219
Uwe Hermann622824c2010-11-19 15:14:42 +0000220 madt->lapic_addr = LOCAL_APIC_ADDR;
221 madt->flags = 0x1; /* PCAT_COMPAT */
Stefan Reinauer06feb882004-02-03 16:11:35 +0000222
Stefan Reinauerf622d592005-11-26 16:56:05 +0000223 current = acpi_fill_madt(current);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000224
Uwe Hermann622824c2010-11-19 15:14:42 +0000225 /* (Re)calculate length and checksum. */
226 header->length = current - (unsigned long)madt;
Stefan Reinauer14e22772010-04-27 06:56:47 +0000227
Uwe Hermann622824c2010-11-19 15:14:42 +0000228 header->checksum = acpi_checksum((void *)madt, header->length);
Stefan Reinauer06feb882004-02-03 16:11:35 +0000229}
230
Uwe Hermann622824c2010-11-19 15:14:42 +0000231/* MCFG is defined in the PCI Firmware Specification 3.0. */
Rudolf Mareke6409f22007-11-03 12:50:26 +0000232void acpi_create_mcfg(acpi_mcfg_t *mcfg)
233{
Uwe Hermann622824c2010-11-19 15:14:42 +0000234 acpi_header_t *header = &(mcfg->header);
235 unsigned long current = (unsigned long)mcfg + sizeof(acpi_mcfg_t);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000236
Rudolf Mareke6409f22007-11-03 12:50:26 +0000237 memset((void *)mcfg, 0, sizeof(acpi_mcfg_t));
Stefan Reinauer14e22772010-04-27 06:56:47 +0000238
Uwe Hermann622824c2010-11-19 15:14:42 +0000239 /* Fill out header fields. */
Stefan Reinauercdfe3762009-07-21 22:15:43 +0000240 memcpy(header->signature, "MCFG", 4);
Rudolf Mareke6409f22007-11-03 12:50:26 +0000241 memcpy(header->oem_id, OEM_ID, 6);
Stefan Reinauercdfe3762009-07-21 22:15:43 +0000242 memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
Rudolf Mareke6409f22007-11-03 12:50:26 +0000243 memcpy(header->asl_compiler_id, ASLC, 4);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000244
Rudolf Mareke6409f22007-11-03 12:50:26 +0000245 header->length = sizeof(acpi_mcfg_t);
246 header->revision = 1;
247
248 current = acpi_fill_mcfg(current);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000249
Uwe Hermann622824c2010-11-19 15:14:42 +0000250 /* (Re)calculate length and checksum. */
251 header->length = current - (unsigned long)mcfg;
252 header->checksum = acpi_checksum((void *)mcfg, header->length);
Rudolf Mareke6409f22007-11-03 12:50:26 +0000253}
254
Vladimir Serbinenkof44ac132015-05-20 19:52:01 +0200255static void *get_tcpa_log(u32 *size)
256{
257 const struct cbmem_entry *ce;
258 const u32 tcpa_default_log_len = 0x10000;
259 void *lasa;
260 ce = cbmem_entry_find(CBMEM_ID_TCPA_LOG);
261 if (ce) {
262 lasa = cbmem_entry_start(ce);
263 *size = cbmem_entry_size(ce);
264 printk(BIOS_DEBUG, "TCPA log found at %p\n", lasa);
265 return lasa;
266 }
267 lasa = cbmem_add(CBMEM_ID_TCPA_LOG, tcpa_default_log_len);
268 if (!lasa) {
269 printk(BIOS_ERR, "TCPA log creation failed\n");
270 return NULL;
271 }
272
273 printk(BIOS_DEBUG, "TCPA log created at %p\n", lasa);
274 memset (lasa, 0, tcpa_default_log_len);
275
276 *size = tcpa_default_log_len;
277 return lasa;
278}
279
280static void acpi_create_tcpa(acpi_tcpa_t *tcpa)
281{
282 acpi_header_t *header = &(tcpa->header);
283 u32 tcpa_log_len;
284 void *lasa;
285
286 memset((void *)tcpa, 0, sizeof(acpi_tcpa_t));
287
288 lasa = get_tcpa_log(&tcpa_log_len);
289 if (!lasa) {
290 return;
291 }
292
293 /* Fill out header fields. */
294 memcpy(header->signature, "TCPA", 4);
295 memcpy(header->oem_id, OEM_ID, 6);
296 memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
297 memcpy(header->asl_compiler_id, ASLC, 4);
298
299 header->length = sizeof(acpi_tcpa_t);
300 header->revision = 2;
301
302 tcpa->platform_class = 0;
303 tcpa->laml = tcpa_log_len;
Stefan Reinauerdefee172015-06-18 01:11:19 -0700304 tcpa->lasa = (uintptr_t) lasa;
Vladimir Serbinenkof44ac132015-05-20 19:52:01 +0200305
306 /* Calculate checksum. */
307 header->checksum = acpi_checksum((void *)tcpa, header->length);
308}
309
Myles Watson3fe6b702009-10-09 20:13:43 +0000310void acpi_create_ssdt_generator(acpi_header_t *ssdt, const char *oem_table_id)
Rudolf Marek293b5f52009-02-01 18:35:15 +0000311{
Uwe Hermann622824c2010-11-19 15:14:42 +0000312 unsigned long current = (unsigned long)ssdt + sizeof(acpi_header_t);
313
Rudolf Marek293b5f52009-02-01 18:35:15 +0000314 memset((void *)ssdt, 0, sizeof(acpi_header_t));
Uwe Hermann622824c2010-11-19 15:14:42 +0000315
Stefan Reinauercdfe3762009-07-21 22:15:43 +0000316 memcpy(&ssdt->signature, "SSDT", 4);
Uwe Hermann622824c2010-11-19 15:14:42 +0000317 ssdt->revision = 2; /* ACPI 1.0/2.0: ?, ACPI 3.0/4.0: 2 */
Rudolf Marek293b5f52009-02-01 18:35:15 +0000318 memcpy(&ssdt->oem_id, OEM_ID, 6);
319 memcpy(&ssdt->oem_table_id, oem_table_id, 8);
320 ssdt->oem_revision = 42;
Uwe Hermann622824c2010-11-19 15:14:42 +0000321 memcpy(&ssdt->asl_compiler_id, ASLC, 4);
Rudolf Marek293b5f52009-02-01 18:35:15 +0000322 ssdt->asl_compiler_revision = 42;
323 ssdt->length = sizeof(acpi_header_t);
324
Stefan Reinauer8dcd50b2009-03-06 17:24:29 +0000325 acpigen_set_current((char *) current);
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200326 {
Edward O'Callaghan2c9d2cf2014-10-27 23:29:29 +1100327 struct device *dev;
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200328 for (dev = all_devices; dev; dev = dev->next)
329 if (dev->ops && dev->ops->acpi_fill_ssdt_generator) {
Alexander Couzens5eea4582015-04-12 22:18:55 +0200330 dev->ops->acpi_fill_ssdt_generator(dev);
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200331 }
Vladimir Serbinenko0a669912014-10-05 14:34:17 +0200332 current = (unsigned long) acpigen_get_current();
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200333 }
Rudolf Marek293b5f52009-02-01 18:35:15 +0000334
Uwe Hermann622824c2010-11-19 15:14:42 +0000335 /* (Re)calculate length and checksum. */
Rudolf Marek293b5f52009-02-01 18:35:15 +0000336 ssdt->length = current - (unsigned long)ssdt;
337 ssdt->checksum = acpi_checksum((void *)ssdt, ssdt->length);
338}
339
Stefan Reinauerf622d592005-11-26 16:56:05 +0000340int acpi_create_srat_lapic(acpi_srat_lapic_t *lapic, u8 node, u8 apic)
341{
Myles Watson0b4c9f02009-03-10 18:06:47 +0000342 memset((void *)lapic, 0, sizeof(acpi_srat_lapic_t));
Stefan Reinauerf622d592005-11-26 16:56:05 +0000343
Uwe Hermann622824c2010-11-19 15:14:42 +0000344 lapic->type = 0; /* Processor local APIC/SAPIC affinity structure */
345 lapic->length = sizeof(acpi_srat_lapic_t);
346 lapic->flags = (1 << 0); /* Enabled (the use of this structure). */
347 lapic->proximity_domain_7_0 = node;
348 /* TODO: proximity_domain_31_8, local SAPIC EID, clock domain. */
349 lapic->apic_id = apic;
Stefan Reinauerf622d592005-11-26 16:56:05 +0000350
Uwe Hermann622824c2010-11-19 15:14:42 +0000351 return lapic->length;
Stefan Reinauerf622d592005-11-26 16:56:05 +0000352}
353
Uwe Hermann622824c2010-11-19 15:14:42 +0000354int acpi_create_srat_mem(acpi_srat_mem_t *mem, u8 node, u32 basek, u32 sizek,
Cristian Măgherușan-Stanciuba482812011-07-02 00:57:07 +0300355 u32 flags)
Stefan Reinauerf622d592005-11-26 16:56:05 +0000356{
Uwe Hermann622824c2010-11-19 15:14:42 +0000357 mem->type = 1; /* Memory affinity structure */
358 mem->length = sizeof(acpi_srat_mem_t);
359 mem->base_address_low = (basek << 10);
360 mem->base_address_high = (basek >> (32 - 10));
361 mem->length_low = (sizek << 10);
362 mem->length_high = (sizek >> (32 - 10));
363 mem->proximity_domain = node;
Stefan Reinauer14e22772010-04-27 06:56:47 +0000364 mem->flags = flags;
Stefan Reinauerf622d592005-11-26 16:56:05 +0000365
Uwe Hermann622824c2010-11-19 15:14:42 +0000366 return mem->length;
Stefan Reinauerf622d592005-11-26 16:56:05 +0000367}
368
Uwe Hermann622824c2010-11-19 15:14:42 +0000369/* http://www.microsoft.com/whdc/system/sysinternals/sratdwn.mspx */
Vladimir Serbinenko5e597572014-10-11 23:45:40 +0200370void acpi_create_srat(acpi_srat_t *srat,
371 unsigned long (*acpi_fill_srat)(unsigned long current))
Stefan Reinauerf622d592005-11-26 16:56:05 +0000372{
Uwe Hermann622824c2010-11-19 15:14:42 +0000373 acpi_header_t *header = &(srat->header);
374 unsigned long current = (unsigned long)srat + sizeof(acpi_srat_t);
Stefan Reinauerf622d592005-11-26 16:56:05 +0000375
Uwe Hermann622824c2010-11-19 15:14:42 +0000376 memset((void *)srat, 0, sizeof(acpi_srat_t));
Stefan Reinauerf622d592005-11-26 16:56:05 +0000377
Uwe Hermann622824c2010-11-19 15:14:42 +0000378 /* Fill out header fields. */
379 memcpy(header->signature, "SRAT", 4);
380 memcpy(header->oem_id, OEM_ID, 6);
381 memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
382 memcpy(header->asl_compiler_id, ASLC, 4);
Stefan Reinauerf622d592005-11-26 16:56:05 +0000383
Uwe Hermann622824c2010-11-19 15:14:42 +0000384 header->length = sizeof(acpi_srat_t);
385 header->revision = 1; /* ACPI 1.0: N/A, 2.0: 1, 3.0: 2, 4.0: 3 */
Stefan Reinauerf622d592005-11-26 16:56:05 +0000386
Uwe Hermann622824c2010-11-19 15:14:42 +0000387 srat->resv = 1; /* Spec: Reserved to 1 for backwards compatibility. */
Stefan Reinauerf622d592005-11-26 16:56:05 +0000388
Uwe Hermann622824c2010-11-19 15:14:42 +0000389 current = acpi_fill_srat(current);
Stefan Reinauerf622d592005-11-26 16:56:05 +0000390
Uwe Hermann622824c2010-11-19 15:14:42 +0000391 /* (Re)calculate length and checksum. */
392 header->length = current - (unsigned long)srat;
393 header->checksum = acpi_checksum((void *)srat, header->length);
Stefan Reinauerf622d592005-11-26 16:56:05 +0000394}
395
Nico Hubere561f352015-10-26 11:51:25 +0100396void acpi_create_dmar(acpi_dmar_t *dmar, enum dmar_flags flags,
Vladimir Serbinenko8d70e942014-11-09 13:22:27 +0100397 unsigned long (*acpi_fill_dmar) (unsigned long))
Patrick Georgi3b590ff2012-09-11 15:21:01 +0200398{
399 acpi_header_t *header = &(dmar->header);
400 unsigned long current = (unsigned long)dmar + sizeof(acpi_dmar_t);
401
402 memset((void *)dmar, 0, sizeof(acpi_dmar_t));
403
404 /* Fill out header fields. */
405 memcpy(header->signature, "DMAR", 4);
406 memcpy(header->oem_id, OEM_ID, 6);
407 memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
408 memcpy(header->asl_compiler_id, ASLC, 4);
409
410 header->length = sizeof(acpi_dmar_t);
411 header->revision = 1;
412
Jacob Laskaf3f654d2016-03-15 21:53:27 -0500413 dmar->host_address_width = cpu_phys_address_size() - 1;
Nico Hubere561f352015-10-26 11:51:25 +0100414 dmar->flags = flags;
Patrick Georgi3b590ff2012-09-11 15:21:01 +0200415
416 current = acpi_fill_dmar(current);
417
418 /* (Re)calculate length and checksum. */
419 header->length = current - (unsigned long)dmar;
420 header->checksum = acpi_checksum((void *)dmar, header->length);
421}
422
423unsigned long acpi_create_dmar_drhd(unsigned long current, u8 flags,
424 u16 segment, u32 bar)
425{
426 dmar_entry_t *drhd = (dmar_entry_t *)current;
427 memset(drhd, 0, sizeof(*drhd));
428 drhd->type = DMAR_DRHD;
429 drhd->length = sizeof(*drhd); /* will be fixed up later */
430 drhd->flags = flags;
431 drhd->segment = segment;
432 drhd->bar = bar;
433
434 return drhd->length;
435}
436
Werner Zehd4d76952016-07-27 06:56:36 +0200437unsigned long acpi_create_dmar_atsr(unsigned long current, u8 flags,
438 u16 segment)
439{
440 dmar_atsr_entry_t *atsr = (dmar_atsr_entry_t *)current;
441 memset(atsr, 0, sizeof(*atsr));
442 atsr->type = DMAR_ATSR;
443 atsr->length = sizeof(*atsr); /* will be fixed up later */
444 atsr->flags = flags;
445 atsr->segment = segment;
446
447 return atsr->length;
448}
449
Patrick Georgi3b590ff2012-09-11 15:21:01 +0200450void acpi_dmar_drhd_fixup(unsigned long base, unsigned long current)
451{
452 dmar_entry_t *drhd = (dmar_entry_t *)base;
453 drhd->length = current - base;
454}
455
Werner Zehd4d76952016-07-27 06:56:36 +0200456void acpi_dmar_atsr_fixup(unsigned long base, unsigned long current)
457{
458 dmar_atsr_entry_t *atsr = (dmar_atsr_entry_t *)base;
459 atsr->length = current - base;
460}
461
Nico Huber6c4751d2015-10-26 12:03:54 +0100462static unsigned long acpi_create_dmar_drhd_ds(unsigned long current,
463 enum dev_scope_type type, u8 enumeration_id, u8 bus, u8 dev, u8 fn)
Patrick Georgi3b590ff2012-09-11 15:21:01 +0200464{
Nico Huber6c4751d2015-10-26 12:03:54 +0100465 /* we don't support longer paths yet */
466 const size_t dev_scope_length = sizeof(dev_scope_t) + 2;
467
Patrick Georgi3b590ff2012-09-11 15:21:01 +0200468 dev_scope_t *ds = (dev_scope_t *)current;
Nico Huber6c4751d2015-10-26 12:03:54 +0100469 memset(ds, 0, dev_scope_length);
470 ds->type = type;
471 ds->length = dev_scope_length;
472 ds->enumeration = enumeration_id;
473 ds->start_bus = bus;
474 ds->path[0].dev = dev;
475 ds->path[0].fn = fn;
Patrick Georgi3b590ff2012-09-11 15:21:01 +0200476
477 return ds->length;
478}
479
Werner Zeh21a5bff2016-07-27 07:07:20 +0200480unsigned long acpi_create_dmar_drhd_ds_pci_br(unsigned long current, u8 bus,
481 u8 dev, u8 fn)
482{
483 return acpi_create_dmar_drhd_ds(current,
484 SCOPE_PCI_SUB, 0, bus, dev, fn);
485}
486
Nico Huber6c4751d2015-10-26 12:03:54 +0100487unsigned long acpi_create_dmar_drhd_ds_pci(unsigned long current, u8 bus,
488 u8 dev, u8 fn)
489{
490 return acpi_create_dmar_drhd_ds(current,
491 SCOPE_PCI_ENDPOINT, 0, bus, dev, fn);
492}
493
494unsigned long acpi_create_dmar_drhd_ds_ioapic(unsigned long current,
495 u8 enumeration_id, u8 bus, u8 dev, u8 fn)
496{
497 return acpi_create_dmar_drhd_ds(current,
498 SCOPE_IOAPIC, enumeration_id, bus, dev, fn);
499}
500
501unsigned long acpi_create_dmar_drhd_ds_msi_hpet(unsigned long current,
502 u8 enumeration_id, u8 bus, u8 dev, u8 fn)
503{
504 return acpi_create_dmar_drhd_ds(current,
505 SCOPE_MSI_HPET, enumeration_id, bus, dev, fn);
506}
507
Uwe Hermann622824c2010-11-19 15:14:42 +0000508/* http://h21007.www2.hp.com/portal/download/files/unprot/Itanium/slit.pdf */
Vladimir Serbinenko5e597572014-10-11 23:45:40 +0200509void acpi_create_slit(acpi_slit_t *slit,
510 unsigned long (*acpi_fill_slit)(unsigned long current))
Yinghai Lud4b278c2006-10-04 20:46:15 +0000511{
Uwe Hermann622824c2010-11-19 15:14:42 +0000512 acpi_header_t *header = &(slit->header);
513 unsigned long current = (unsigned long)slit + sizeof(acpi_slit_t);
Yinghai Lud4b278c2006-10-04 20:46:15 +0000514
Uwe Hermann622824c2010-11-19 15:14:42 +0000515 memset((void *)slit, 0, sizeof(acpi_slit_t));
Yinghai Lud4b278c2006-10-04 20:46:15 +0000516
Uwe Hermann622824c2010-11-19 15:14:42 +0000517 /* Fill out header fields. */
518 memcpy(header->signature, "SLIT", 4);
519 memcpy(header->oem_id, OEM_ID, 6);
520 memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
521 memcpy(header->asl_compiler_id, ASLC, 4);
Yinghai Lud4b278c2006-10-04 20:46:15 +0000522
Uwe Hermann622824c2010-11-19 15:14:42 +0000523 header->length = sizeof(acpi_slit_t);
524 header->revision = 1; /* ACPI 1.0: N/A, ACPI 2.0/3.0/4.0: 1 */
Yinghai Lud4b278c2006-10-04 20:46:15 +0000525
Uwe Hermann622824c2010-11-19 15:14:42 +0000526 current = acpi_fill_slit(current);
Yinghai Lud4b278c2006-10-04 20:46:15 +0000527
Uwe Hermann622824c2010-11-19 15:14:42 +0000528 /* (Re)calculate length and checksum. */
529 header->length = current - (unsigned long)slit;
530 header->checksum = acpi_checksum((void *)slit, header->length);
Yinghai Lud4b278c2006-10-04 20:46:15 +0000531}
532
Uwe Hermann622824c2010-11-19 15:14:42 +0000533/* http://www.intel.com/hardwaredesign/hpetspec_1.pdf */
Stefan Reinauer777224c2005-01-19 14:06:41 +0000534void acpi_create_hpet(acpi_hpet_t *hpet)
Stefan Reinauer688b3852004-01-28 16:56:14 +0000535{
Uwe Hermann622824c2010-11-19 15:14:42 +0000536 acpi_header_t *header = &(hpet->header);
537 acpi_addr_t *addr = &(hpet->addr);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000538
Stefan Reinauera7648c22004-01-29 17:31:34 +0000539 memset((void *)hpet, 0, sizeof(acpi_hpet_t));
Stefan Reinauer14e22772010-04-27 06:56:47 +0000540
Uwe Hermann622824c2010-11-19 15:14:42 +0000541 /* Fill out header fields. */
Stefan Reinauer4704dc52009-07-22 01:11:37 +0000542 memcpy(header->signature, "HPET", 4);
Stefan Reinauer688b3852004-01-28 16:56:14 +0000543 memcpy(header->oem_id, OEM_ID, 6);
Stefan Reinauercdfe3762009-07-21 22:15:43 +0000544 memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
Stefan Reinauer688b3852004-01-28 16:56:14 +0000545 memcpy(header->asl_compiler_id, ASLC, 4);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000546
Stefan Reinauer688b3852004-01-28 16:56:14 +0000547 header->length = sizeof(acpi_hpet_t);
Uwe Hermann622824c2010-11-19 15:14:42 +0000548 header->revision = 1; /* Currently 1. Table added in ACPI 2.0. */
Stefan Reinauer688b3852004-01-28 16:56:14 +0000549
Uwe Hermann622824c2010-11-19 15:14:42 +0000550 /* Fill out HPET address. */
551 addr->space_id = 0; /* Memory */
552 addr->bit_width = 64;
553 addr->bit_offset = 0;
Patrick Georgi9aeb6942012-10-05 21:54:38 +0200554 addr->addrl = CONFIG_HPET_ADDRESS & 0xffffffff;
555 addr->addrh = ((unsigned long long)CONFIG_HPET_ADDRESS) >> 32;
Stefan Reinauer688b3852004-01-28 16:56:14 +0000556
Patrick Georgi9aeb6942012-10-05 21:54:38 +0200557 hpet->id = *(unsigned int*)CONFIG_HPET_ADDRESS;
Uwe Hermann622824c2010-11-19 15:14:42 +0000558 hpet->number = 0;
Patrick Georgi9aeb6942012-10-05 21:54:38 +0200559 hpet->min_tick = CONFIG_HPET_MIN_TICKS;
Stefan Reinauer14e22772010-04-27 06:56:47 +0000560
Uwe Hermann622824c2010-11-19 15:14:42 +0000561 header->checksum = acpi_checksum((void *)hpet, sizeof(acpi_hpet_t));
Stefan Reinauer688b3852004-01-28 16:56:14 +0000562}
Uwe Hermann622824c2010-11-19 15:14:42 +0000563
Timothy Pearsonff8ccf02015-08-11 17:48:32 -0500564void acpi_create_ivrs(acpi_ivrs_t *ivrs,
565 unsigned long (*acpi_fill_ivrs)(acpi_ivrs_t* ivrs_struct, unsigned long current))
566{
567 acpi_header_t *header = &(ivrs->header);
568 unsigned long current = (unsigned long)ivrs + sizeof(acpi_ivrs_t);
569
570 memset((void *)ivrs, 0, sizeof(acpi_ivrs_t));
571
572 /* Fill out header fields. */
573 memcpy(header->signature, "IVRS", 4);
574 memcpy(header->oem_id, OEM_ID, 6);
575 memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
576 memcpy(header->asl_compiler_id, ASLC, 4);
577
578 header->length = sizeof(acpi_ivrs_t);
579 header->revision = 1; /* ACPI 1.0: N/A, ACPI 2.0/3.0/4.0: 1 */
580
581 current = acpi_fill_ivrs(ivrs, current);
582
583 /* (Re)calculate length and checksum. */
584 header->length = current - (unsigned long)ivrs;
585 header->checksum = acpi_checksum((void *)ivrs, header->length);
586}
587
Alexander Couzens83fc32f2015-04-12 22:28:37 +0200588unsigned long acpi_write_hpet(device_t device, unsigned long current, acpi_rsdp_t *rsdp)
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200589{
590 acpi_hpet_t *hpet;
591
592 /*
593 * We explicitly add these tables later on:
594 */
595 printk(BIOS_DEBUG, "ACPI: * HPET\n");
596
597 hpet = (acpi_hpet_t *) current;
598 current += sizeof(acpi_hpet_t);
599 current = ALIGN(current, 16);
600 acpi_create_hpet(hpet);
601 acpi_add_table(rsdp, hpet);
602
603 return current;
604}
605
Stefan Reinauer777224c2005-01-19 14:06:41 +0000606void acpi_create_facs(acpi_facs_t *facs)
Ronald G. Minnich02fa3b22004-10-06 17:33:54 +0000607{
Uwe Hermann622824c2010-11-19 15:14:42 +0000608 memset((void *)facs, 0, sizeof(acpi_facs_t));
Ronald G. Minnich02fa3b22004-10-06 17:33:54 +0000609
Stefan Reinauercdfe3762009-07-21 22:15:43 +0000610 memcpy(facs->signature, "FACS", 4);
Ronald G. Minnich02fa3b22004-10-06 17:33:54 +0000611 facs->length = sizeof(acpi_facs_t);
612 facs->hardware_signature = 0;
613 facs->firmware_waking_vector = 0;
614 facs->global_lock = 0;
615 facs->flags = 0;
616 facs->x_firmware_waking_vector_l = 0;
617 facs->x_firmware_waking_vector_h = 0;
Uwe Hermann622824c2010-11-19 15:14:42 +0000618 facs->version = 1; /* ACPI 1.0: 0, ACPI 2.0/3.0: 1, ACPI 4.0: 2 */
Ronald G. Minnich02fa3b22004-10-06 17:33:54 +0000619}
Stefan Reinauer777224c2005-01-19 14:06:41 +0000620
Vladimir Serbinenko351fefc2014-10-26 20:42:08 +0100621static void acpi_write_rsdt(acpi_rsdt_t *rsdt, char *oem_id, char *oem_table_id)
Stefan Reinauer14e22772010-04-27 06:56:47 +0000622{
Uwe Hermann622824c2010-11-19 15:14:42 +0000623 acpi_header_t *header = &(rsdt->header);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000624
Uwe Hermann622824c2010-11-19 15:14:42 +0000625 /* Fill out header fields. */
Stefan Reinauercdfe3762009-07-21 22:15:43 +0000626 memcpy(header->signature, "RSDT", 4);
Vladimir Serbinenko351fefc2014-10-26 20:42:08 +0100627 memcpy(header->oem_id, oem_id, 6);
628 memcpy(header->oem_table_id, oem_table_id, 8);
Stefan Reinauer688b3852004-01-28 16:56:14 +0000629 memcpy(header->asl_compiler_id, ASLC, 4);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000630
Stefan Reinauer688b3852004-01-28 16:56:14 +0000631 header->length = sizeof(acpi_rsdt_t);
Uwe Hermann622824c2010-11-19 15:14:42 +0000632 header->revision = 1; /* ACPI 1.0/2.0/3.0/4.0: 1 */
Stefan Reinauer14e22772010-04-27 06:56:47 +0000633
Uwe Hermann622824c2010-11-19 15:14:42 +0000634 /* Entries are filled in later, we come with an empty set. */
Stefan Reinauer688b3852004-01-28 16:56:14 +0000635
Uwe Hermann622824c2010-11-19 15:14:42 +0000636 /* Fix checksum. */
Stefan Reinauerb657a3c2009-07-21 21:38:33 +0000637 header->checksum = acpi_checksum((void *)rsdt, sizeof(acpi_rsdt_t));
Stefan Reinauer688b3852004-01-28 16:56:14 +0000638}
639
Vladimir Serbinenko351fefc2014-10-26 20:42:08 +0100640static void acpi_write_xsdt(acpi_xsdt_t *xsdt, char *oem_id, char *oem_table_id)
Stefan Reinauer14e22772010-04-27 06:56:47 +0000641{
Uwe Hermann622824c2010-11-19 15:14:42 +0000642 acpi_header_t *header = &(xsdt->header);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000643
Uwe Hermann622824c2010-11-19 15:14:42 +0000644 /* Fill out header fields. */
Stefan Reinauercdfe3762009-07-21 22:15:43 +0000645 memcpy(header->signature, "XSDT", 4);
Vladimir Serbinenko351fefc2014-10-26 20:42:08 +0100646 memcpy(header->oem_id, oem_id, 6);
647 memcpy(header->oem_table_id, oem_table_id, 8);
Stefan Reinauerb657a3c2009-07-21 21:38:33 +0000648 memcpy(header->asl_compiler_id, ASLC, 4);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000649
Stefan Reinauerb657a3c2009-07-21 21:38:33 +0000650 header->length = sizeof(acpi_xsdt_t);
Uwe Hermann622824c2010-11-19 15:14:42 +0000651 header->revision = 1; /* ACPI 1.0: N/A, 2.0/3.0/4.0: 1 */
Stefan Reinauer14e22772010-04-27 06:56:47 +0000652
Uwe Hermann622824c2010-11-19 15:14:42 +0000653 /* Entries are filled in later, we come with an empty set. */
Stefan Reinauerb657a3c2009-07-21 21:38:33 +0000654
Uwe Hermann622824c2010-11-19 15:14:42 +0000655 /* Fix checksum. */
Stefan Reinauerb657a3c2009-07-21 21:38:33 +0000656 header->checksum = acpi_checksum((void *)xsdt, sizeof(acpi_xsdt_t));
657}
658
Vladimir Serbinenko351fefc2014-10-26 20:42:08 +0100659static void acpi_write_rsdp(acpi_rsdp_t *rsdp, acpi_rsdt_t *rsdt,
660 acpi_xsdt_t *xsdt, char *oem_id)
Stefan Reinauer688b3852004-01-28 16:56:14 +0000661{
Stefan Reinauerd18faac2009-11-05 18:06:43 +0000662 memset(rsdp, 0, sizeof(acpi_rsdp_t));
Uwe Hermann622824c2010-11-19 15:14:42 +0000663
Stefan Reinauer688b3852004-01-28 16:56:14 +0000664 memcpy(rsdp->signature, RSDP_SIG, 8);
Vladimir Serbinenko351fefc2014-10-26 20:42:08 +0100665 memcpy(rsdp->oem_id, oem_id, 6);
Uwe Hermann622824c2010-11-19 15:14:42 +0000666
667 rsdp->length = sizeof(acpi_rsdp_t);
Stefan Reinauerdefee172015-06-18 01:11:19 -0700668 rsdp->rsdt_address = (uintptr_t)rsdt;
Uwe Hermann622824c2010-11-19 15:14:42 +0000669
670 /*
671 * Revision: ACPI 1.0: 0, ACPI 2.0/3.0/4.0: 2.
672 *
673 * Some OSes expect an XSDT to be present for RSD PTR revisions >= 2.
674 * If we don't have an ACPI XSDT, force ACPI 1.0 (and thus RSD PTR
675 * revision 0).
Stefan Reinauerb657a3c2009-07-21 21:38:33 +0000676 */
677 if (xsdt == NULL) {
Uwe Hermann622824c2010-11-19 15:14:42 +0000678 rsdp->revision = 0;
Stefan Reinauerb657a3c2009-07-21 21:38:33 +0000679 } else {
Stefan Reinauerdefee172015-06-18 01:11:19 -0700680 rsdp->xsdt_address = (u64)(uintptr_t)xsdt;
Uwe Hermann622824c2010-11-19 15:14:42 +0000681 rsdp->revision = 2;
Stefan Reinauerb657a3c2009-07-21 21:38:33 +0000682 }
Uwe Hermann622824c2010-11-19 15:14:42 +0000683
684 /* Calculate checksums. */
685 rsdp->checksum = acpi_checksum((void *)rsdp, 20);
686 rsdp->ext_checksum = acpi_checksum((void *)rsdp, sizeof(acpi_rsdp_t));
Stefan Reinauer688b3852004-01-28 16:56:14 +0000687}
688
zbaocaf494c82012-04-13 13:57:14 +0800689unsigned long acpi_create_hest_error_source(acpi_hest_t *hest, acpi_hest_esd_t *esd, u16 type, void *data, u16 data_len)
690{
691 acpi_header_t *header = &(hest->header);
692 acpi_hest_hen_t *hen;
693 void *pos;
694 u16 len;
695
696 pos = esd;
697 memset(pos, 0, sizeof(acpi_hest_esd_t));
698 len = 0;
699 esd->type = type; /* MCE */
700 esd->source_id = hest->error_source_count;
701 esd->flags = 0; /* FIRMWARE_FIRST */
702 esd->enabled = 1;
703 esd->prealloc_erecords = 1;
704 esd->max_section_per_record = 0x1;
705
706 len += sizeof(acpi_hest_esd_t);
707 pos = esd + 1;
708
709 switch (type) {
710 case 0: /* MCE */
711 break;
712 case 1: /* CMC */
713 hen = (acpi_hest_hen_t *) (pos);
714 memset(pos, 0, sizeof(acpi_hest_hen_t));
715 hen->type = 3; /* SCI? */
716 hen->length = sizeof(acpi_hest_hen_t);
717 hen->conf_we = 0; /* Configuration Write Enable. */
718 hen->poll_interval = 0;
719 hen->vector = 0;
720 hen->sw2poll_threshold_val = 0;
721 hen->sw2poll_threshold_win = 0;
722 hen->error_threshold_val = 0;
723 hen->error_threshold_win = 0;
724 len += sizeof(acpi_hest_hen_t);
725 pos = hen + 1;
726 break;
727 case 2: /* NMI */
728 case 6: /* AER Root Port */
729 case 7: /* AER Endpoint */
730 case 8: /* AER Bridge */
731 case 9: /* Generic Hardware Error Source. */
732 /* TODO: */
733 break;
734 default:
735 printk(BIOS_DEBUG, "Invalid type of Error Source.");
736 break;
737 }
738 hest->error_source_count ++;
739
740 memcpy(pos, data, data_len);
741 len += data_len;
742 header->length += len;
743
744 return len;
745}
746
747/* ACPI 4.0 */
Vladimir Serbinenko807127f2014-11-09 13:36:18 +0100748void acpi_write_hest(acpi_hest_t *hest,
749 unsigned long (*acpi_fill_hest)(acpi_hest_t *hest))
zbaocaf494c82012-04-13 13:57:14 +0800750{
751 acpi_header_t *header = &(hest->header);
752
753 memset(hest, 0, sizeof(acpi_hest_t));
754
755 memcpy(header->signature, "HEST", 4);
756 memcpy(header->oem_id, OEM_ID, 6);
757 memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
758 memcpy(header->asl_compiler_id, ASLC, 4);
759 header->length += sizeof(acpi_hest_t);
760 header->revision = 1;
761
762 acpi_fill_hest(hest);
763
764 /* Calculate checksums. */
765 header->checksum = acpi_checksum((void *)hest, header->length);
766}
767
Vladimir Serbinenkoc21e0732014-10-16 12:48:19 +0200768#if IS_ENABLED(CONFIG_COMMON_FADT)
769void acpi_create_fadt(acpi_fadt_t *fadt,acpi_facs_t *facs, void *dsdt)
770{
771 acpi_header_t *header = &(fadt->header);
772
773 memset((void *) fadt, 0, sizeof(acpi_fadt_t));
774 memcpy(header->signature, "FACP", 4);
775 header->length = sizeof(acpi_fadt_t);
Vladimir Serbinenkoab83ef02014-10-25 15:18:25 +0200776 header->revision = 4;
Vladimir Serbinenkoc21e0732014-10-16 12:48:19 +0200777 memcpy(header->oem_id, OEM_ID, 6);
778 memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
779 memcpy(header->asl_compiler_id, ASLC, 4);
780 header->asl_compiler_revision = 0;
781
782 fadt->firmware_ctrl = (unsigned long) facs;
783 fadt->dsdt = (unsigned long) dsdt;
784
785 fadt->x_firmware_ctl_l = (unsigned long)facs;
786 fadt->x_firmware_ctl_h = 0;
787 fadt->x_dsdt_l = (unsigned long)dsdt;
788 fadt->x_dsdt_h = 0;
789
790 if(IS_ENABLED(CONFIG_SYSTEM_TYPE_LAPTOP)) {
791 fadt->preferred_pm_profile = PM_MOBILE;
792 } else {
793 fadt->preferred_pm_profile = PM_DESKTOP;
794 }
795
Vladimir Serbinenkoab83ef02014-10-25 15:18:25 +0200796 acpi_fill_fadt(fadt);
Vladimir Serbinenkoc21e0732014-10-16 12:48:19 +0200797
798 header->checksum =
799 acpi_checksum((void *) fadt, header->length);
800}
801#endif
802
Vladimir Serbinenko41877d82014-09-01 22:18:01 +0200803unsigned long __attribute__ ((weak)) fw_cfg_acpi_tables(unsigned long start)
804{
805 return 0;
806}
807
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200808unsigned long write_acpi_tables(unsigned long start)
809{
810 unsigned long current;
811 acpi_rsdp_t *rsdp;
812 acpi_rsdt_t *rsdt;
813 acpi_xsdt_t *xsdt;
814 acpi_fadt_t *fadt;
815 acpi_facs_t *facs;
Vladimir Serbinenko351fefc2014-10-26 20:42:08 +0100816 acpi_header_t *slic_file, *slic;
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200817 acpi_header_t *ssdt;
Vladimir Serbinenko36f8d272015-05-31 12:31:59 +0200818 acpi_header_t *dsdt_file, *dsdt;
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200819 acpi_mcfg_t *mcfg;
Vladimir Serbinenkof44ac132015-05-20 19:52:01 +0200820 acpi_tcpa_t *tcpa;
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200821 acpi_madt_t *madt;
Edward O'Callaghan2c9d2cf2014-10-27 23:29:29 +1100822 struct device *dev;
Vladimir Serbinenko41877d82014-09-01 22:18:01 +0200823 unsigned long fw;
Vladimir Serbinenko36f8d272015-05-31 12:31:59 +0200824 size_t slic_size, dsdt_size;
Vladimir Serbinenko351fefc2014-10-26 20:42:08 +0100825 char oem_id[6], oem_table_id[8];
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200826
827 current = start;
828
829 /* Align ACPI tables to 16byte */
Aaron Durbin07a1b282015-12-10 17:07:38 -0600830 current = acpi_align_current(current);
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200831
Vladimir Serbinenko41877d82014-09-01 22:18:01 +0200832 fw = fw_cfg_acpi_tables(current);
833 if (fw)
834 return fw;
835
Vladimir Serbinenkoa4cf83d2015-06-02 21:40:29 +0200836 dsdt_file = cbfs_boot_map_with_leak(
Vladimir Serbinenko36f8d272015-05-31 12:31:59 +0200837 CONFIG_CBFS_PREFIX "/dsdt.aml",
838 CBFS_TYPE_RAW, &dsdt_size);
839 if (!dsdt_file) {
840 printk(BIOS_ERR, "No DSDT file, skipping ACPI tables\n");
841 return current;
842 }
843
844 if (dsdt_file->length > dsdt_size
845 || dsdt_file->length < sizeof (acpi_header_t)
846 || memcmp(dsdt_file->signature, "DSDT", 4) != 0) {
847 printk(BIOS_ERR, "Invalid DSDT file, skipping ACPI tables\n");
848 return current;
849 }
850
Aaron Durbin899d13d2015-05-15 23:39:23 -0500851 slic_file = cbfs_boot_map_with_leak(CONFIG_CBFS_PREFIX "/slic",
Vladimir Serbinenko351fefc2014-10-26 20:42:08 +0100852 CBFS_TYPE_RAW, &slic_size);
Vladimir Serbinenko2cb29782015-05-31 11:32:09 +0200853 if (slic_file
854 && (slic_file->length > slic_size
855 || slic_file->length < sizeof (acpi_header_t)
856 || memcmp(slic_file->signature, "SLIC", 4) != 0)) {
Vladimir Serbinenko351fefc2014-10-26 20:42:08 +0100857 slic_file = 0;
858 }
859
860 if (slic_file) {
861 memcpy(oem_id, slic_file->oem_id, 6);
862 memcpy(oem_table_id, slic_file->oem_table_id, 8);
863 } else {
864 memcpy(oem_id, OEM_ID, 6);
865 memcpy(oem_table_id, ACPI_TABLE_CREATOR, 8);
866 }
867
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200868 printk(BIOS_INFO, "ACPI: Writing ACPI tables at %lx.\n", start);
869
870 /* We need at least an RSDP and an RSDT Table */
871 rsdp = (acpi_rsdp_t *) current;
872 current += sizeof(acpi_rsdp_t);
Aaron Durbin07a1b282015-12-10 17:07:38 -0600873 current = acpi_align_current(current);
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200874 rsdt = (acpi_rsdt_t *) current;
875 current += sizeof(acpi_rsdt_t);
Aaron Durbin07a1b282015-12-10 17:07:38 -0600876 current = acpi_align_current(current);
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200877 xsdt = (acpi_xsdt_t *) current;
878 current += sizeof(acpi_xsdt_t);
Aaron Durbin07a1b282015-12-10 17:07:38 -0600879 current = acpi_align_current(current);
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200880
881 /* clear all table memory */
882 memset((void *) start, 0, current - start);
883
Vladimir Serbinenko351fefc2014-10-26 20:42:08 +0100884 acpi_write_rsdp(rsdp, rsdt, xsdt, oem_id);
885 acpi_write_rsdt(rsdt, oem_id, oem_table_id);
886 acpi_write_xsdt(xsdt, oem_id, oem_table_id);
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200887
888 printk(BIOS_DEBUG, "ACPI: * FACS\n");
Patrick Georgi133108a2015-08-08 23:20:58 +0200889 current = (ALIGN(current, 64));
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200890 facs = (acpi_facs_t *) current;
891 current += sizeof(acpi_facs_t);
Aaron Durbin07a1b282015-12-10 17:07:38 -0600892 current = acpi_align_current(current);
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200893 acpi_create_facs(facs);
894
895 printk(BIOS_DEBUG, "ACPI: * DSDT\n");
896 dsdt = (acpi_header_t *) current;
Vladimir Serbinenko36f8d272015-05-31 12:31:59 +0200897 memcpy(dsdt, dsdt_file, sizeof(acpi_header_t));
Vladimir Serbinenko334fd8e2014-10-05 11:10:35 +0200898 if (dsdt->length >= sizeof(acpi_header_t)) {
899 current += sizeof(acpi_header_t);
900
901 acpigen_set_current((char *) current);
902 for (dev = all_devices; dev; dev = dev->next)
903 if (dev->ops && dev->ops->acpi_inject_dsdt_generator) {
Alexander Couzensa90dad12015-04-12 21:49:46 +0200904 dev->ops->acpi_inject_dsdt_generator(dev);
Vladimir Serbinenko334fd8e2014-10-05 11:10:35 +0200905 }
906 current = (unsigned long) acpigen_get_current();
907 memcpy((char *)current,
Vladimir Serbinenko36f8d272015-05-31 12:31:59 +0200908 (char *)dsdt_file + sizeof(acpi_header_t),
Vladimir Serbinenko334fd8e2014-10-05 11:10:35 +0200909 dsdt->length - sizeof(acpi_header_t));
910 current += dsdt->length - sizeof(acpi_header_t);
911
912 /* (Re)calculate length and checksum. */
913 dsdt->length = current - (unsigned long)dsdt;
914 dsdt->checksum = 0;
915 dsdt->checksum = acpi_checksum((void *)dsdt, dsdt->length);
916 }
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200917
Aaron Durbin07a1b282015-12-10 17:07:38 -0600918 current = acpi_align_current(current);
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200919
920 printk(BIOS_DEBUG, "ACPI: * FADT\n");
921 fadt = (acpi_fadt_t *) current;
922 current += sizeof(acpi_fadt_t);
Aaron Durbin07a1b282015-12-10 17:07:38 -0600923 current = acpi_align_current(current);
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200924
925 acpi_create_fadt(fadt, facs, dsdt);
926 acpi_add_table(rsdp, fadt);
927
Vladimir Serbinenko351fefc2014-10-26 20:42:08 +0100928 if (slic_file) {
929 printk(BIOS_DEBUG, "ACPI: * SLIC\n");
930 slic = (acpi_header_t *)current;
931 memcpy(slic, slic_file, slic_file->length);
932 current += slic_file->length;
Aaron Durbin07a1b282015-12-10 17:07:38 -0600933 current = acpi_align_current(current);
Vladimir Serbinenko351fefc2014-10-26 20:42:08 +0100934 acpi_add_table(rsdp, slic);
935 }
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200936
937 printk(BIOS_DEBUG, "ACPI: * SSDT\n");
938 ssdt = (acpi_header_t *)current;
939 acpi_create_ssdt_generator(ssdt, ACPI_TABLE_CREATOR);
Vladimir Serbinenko9310df82014-10-10 20:40:41 +0200940 if (ssdt->length > sizeof(acpi_header_t)) {
941 current += ssdt->length;
942 acpi_add_table(rsdp, ssdt);
Aaron Durbin07a1b282015-12-10 17:07:38 -0600943 current = acpi_align_current(current);
Vladimir Serbinenko9310df82014-10-10 20:40:41 +0200944 }
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200945
946 printk(BIOS_DEBUG, "ACPI: * MCFG\n");
947 mcfg = (acpi_mcfg_t *) current;
948 acpi_create_mcfg(mcfg);
949 if (mcfg->header.length > sizeof(acpi_mcfg_t)) {
950 current += mcfg->header.length;
Aaron Durbin07a1b282015-12-10 17:07:38 -0600951 current = acpi_align_current(current);
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200952 acpi_add_table(rsdp, mcfg);
953 }
954
Vladimir Serbinenkof44ac132015-05-20 19:52:01 +0200955 printk(BIOS_DEBUG, "ACPI: * TCPA\n");
956 tcpa = (acpi_tcpa_t *) current;
957 acpi_create_tcpa(tcpa);
958 if (tcpa->header.length >= sizeof(acpi_tcpa_t)) {
959 current += tcpa->header.length;
Aaron Durbin07a1b282015-12-10 17:07:38 -0600960 current = acpi_align_current(current);
Vladimir Serbinenkof44ac132015-05-20 19:52:01 +0200961 acpi_add_table(rsdp, tcpa);
962 }
963
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200964 printk(BIOS_DEBUG, "ACPI: * MADT\n");
965
966 madt = (acpi_madt_t *) current;
967 acpi_create_madt(madt);
968 if (madt->header.length > sizeof(acpi_madt_t)) {
969 current+=madt->header.length;
970 acpi_add_table(rsdp,madt);
971 }
Aaron Durbin07a1b282015-12-10 17:07:38 -0600972 current = acpi_align_current(current);
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200973
974 printk(BIOS_DEBUG, "current = %lx\n", current);
975
976 for (dev = all_devices; dev; dev = dev->next) {
977 if (dev->ops && dev->ops->write_acpi_tables) {
Alexander Couzens83fc32f2015-04-12 22:28:37 +0200978 current = dev->ops->write_acpi_tables(dev, current, rsdp);
Aaron Durbin07a1b282015-12-10 17:07:38 -0600979 current = acpi_align_current(current);
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200980 }
981 }
982
983 printk(BIOS_INFO, "ACPI: done.\n");
984 return current;
985}
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200986
Rudolf Marek33cafe52009-04-13 18:07:02 +0000987static acpi_rsdp_t *valid_rsdp(acpi_rsdp_t *rsdp)
988{
989 if (strncmp((char *)rsdp, RSDP_SIG, sizeof(RSDP_SIG) - 1) != 0)
990 return NULL;
991
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000992 printk(BIOS_DEBUG, "Looking on %p for valid checksum\n", rsdp);
Rudolf Marek33cafe52009-04-13 18:07:02 +0000993
994 if (acpi_checksum((void *)rsdp, 20) != 0)
995 return NULL;
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000996 printk(BIOS_DEBUG, "Checksum 1 passed\n");
Rudolf Marek33cafe52009-04-13 18:07:02 +0000997
998 if ((rsdp->revision > 1) && (acpi_checksum((void *)rsdp,
999 rsdp->length) != 0))
1000 return NULL;
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +00001001 printk(BIOS_DEBUG, "Checksum 2 passed all OK\n");
Rudolf Marek33cafe52009-04-13 18:07:02 +00001002
1003 return rsdp;
1004}
1005
Rudolf Marek33cafe52009-04-13 18:07:02 +00001006void *acpi_find_wakeup_vector(void)
1007{
1008 char *p, *end;
Rudolf Marek33cafe52009-04-13 18:07:02 +00001009 acpi_rsdt_t *rsdt;
1010 acpi_facs_t *facs;
Martin Rothc5f49262012-12-14 19:17:55 -07001011 acpi_fadt_t *fadt = NULL;
Kyösti Mälkki072d436b2016-06-17 08:44:40 +03001012 acpi_rsdp_t *rsdp = NULL;
Uwe Hermann622824c2010-11-19 15:14:42 +00001013 void *wake_vec;
Rudolf Marek33cafe52009-04-13 18:07:02 +00001014 int i;
1015
Rudolf Marek33cafe52009-04-13 18:07:02 +00001016 if (!acpi_is_wakeup())
1017 return NULL;
1018
Uwe Hermann622824c2010-11-19 15:14:42 +00001019 printk(BIOS_DEBUG, "Trying to find the wakeup vector...\n");
Rudolf Marek33cafe52009-04-13 18:07:02 +00001020
Uwe Hermann622824c2010-11-19 15:14:42 +00001021 /* Find RSDP. */
1022 for (p = (char *)0xe0000; p < (char *)0xfffff; p += 16) {
1023 if ((rsdp = valid_rsdp((acpi_rsdp_t *)p)))
Rudolf Marek33cafe52009-04-13 18:07:02 +00001024 break;
1025 }
1026
1027 if (rsdp == NULL)
1028 return NULL;
1029
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +00001030 printk(BIOS_DEBUG, "RSDP found at %p\n", rsdp);
Stefan Reinauer71a30182015-07-30 16:28:13 -07001031 rsdt = (acpi_rsdt_t *)(uintptr_t)rsdp->rsdt_address;
Stefan Reinauer14e22772010-04-27 06:56:47 +00001032
Uwe Hermann622824c2010-11-19 15:14:42 +00001033 end = (char *)rsdt + rsdt->header.length;
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +00001034 printk(BIOS_DEBUG, "RSDT found at %p ends at %p\n", rsdt, end);
Rudolf Marek33cafe52009-04-13 18:07:02 +00001035
Uwe Hermann622824c2010-11-19 15:14:42 +00001036 for (i = 0; ((char *)&rsdt->entry[i]) < end; i++) {
Stefan Reinauer71a30182015-07-30 16:28:13 -07001037 fadt = (acpi_fadt_t *)(uintptr_t)rsdt->entry[i];
Stefan Reinauercdfe3762009-07-21 22:15:43 +00001038 if (strncmp((char *)fadt, "FACP", 4) == 0)
Rudolf Marek33cafe52009-04-13 18:07:02 +00001039 break;
1040 fadt = NULL;
1041 }
1042
1043 if (fadt == NULL)
1044 return NULL;
1045
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +00001046 printk(BIOS_DEBUG, "FADT found at %p\n", fadt);
Stefan Reinauer71a30182015-07-30 16:28:13 -07001047 facs = (acpi_facs_t *)(uintptr_t)fadt->firmware_ctrl;
Rudolf Marek33cafe52009-04-13 18:07:02 +00001048
Stefan Reinauer7e9771c2009-04-22 08:17:38 +00001049 if (facs == NULL) {
Uwe Hermann622824c2010-11-19 15:14:42 +00001050 printk(BIOS_DEBUG, "No FACS found, wake up from S3 not "
1051 "possible.\n");
Rudolf Marek33cafe52009-04-13 18:07:02 +00001052 return NULL;
Stefan Reinauer7e9771c2009-04-22 08:17:38 +00001053 }
Rudolf Marek33cafe52009-04-13 18:07:02 +00001054
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +00001055 printk(BIOS_DEBUG, "FACS found at %p\n", facs);
Stefan Reinauer71a30182015-07-30 16:28:13 -07001056 wake_vec = (void *)(uintptr_t)facs->firmware_waking_vector;
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +00001057 printk(BIOS_DEBUG, "OS waking vector is %p\n", wake_vec);
Uwe Hermann622824c2010-11-19 15:14:42 +00001058
Rudolf Marek33cafe52009-04-13 18:07:02 +00001059 return wake_vec;
1060}
1061
Duncan Laurie11290c42012-10-03 19:07:05 -07001062void acpi_save_gnvs(u32 gnvs_address)
1063{
Duncan Laurie9c07c8f2013-03-22 11:08:39 -07001064 u32 *gnvs = cbmem_add(CBMEM_ID_ACPI_GNVS_PTR, sizeof(*gnvs));
Duncan Laurie11290c42012-10-03 19:07:05 -07001065 if (gnvs)
1066 *gnvs = gnvs_address;
1067}