blob: a7a638ffa4e00bf778268006c1318bc94b3e81d3 [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
Stefan Reinauer777224c2005-01-19 14:06:41 +00009 *
Stefan Reinauer14e22772010-04-27 06:56:47 +000010 * ACPI FADT, FACS, and DSDT table support added by
Ronald G. Minnich02fa3b22004-10-06 17:33:54 +000011 * Nick Barker <nick.barker9@btinternet.com>, and those portions
Uwe Hermannc70e9fc2010-02-15 23:10:19 +000012 * Copyright (C) 2004 Nick Barker
Stefan Reinauerf622d592005-11-26 16:56:05 +000013 *
Uwe Hermannc70e9fc2010-02-15 23:10:19 +000014 * Copyright (C) 2005 ADVANCED MICRO DEVICES, INC. All Rights Reserved.
Stefan Reinauerd6edf7a2006-01-05 00:19:52 +000015 * 2005.9 yhlu add SRAT table generation
Stefan Reinauer777224c2005-01-19 14:06:41 +000016 */
17
Stefan Reinauer14e22772010-04-27 06:56:47 +000018/*
Stefan Reinauer777224c2005-01-19 14:06:41 +000019 * Each system port implementing ACPI has to provide two functions:
Stefan Reinauer14e22772010-04-27 06:56:47 +000020 *
Stefan Reinauer777224c2005-01-19 14:06:41 +000021 * write_acpi_tables()
22 * acpi_dump_apics()
Stefan Reinauer14e22772010-04-27 06:56:47 +000023 *
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +000024 * See Kontron 986LCD-M port for a good example of an ACPI implementation
25 * in coreboot.
Ronald G. Minnich02fa3b22004-10-06 17:33:54 +000026 */
Stefan Reinauer688b3852004-01-28 16:56:14 +000027
28#include <console/console.h>
29#include <string.h>
30#include <arch/acpi.h>
Rudolf Marek293b5f52009-02-01 18:35:15 +000031#include <arch/acpigen.h>
Stefan Reinauer777224c2005-01-19 14:06:41 +000032#include <device/pci.h>
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +000033#include <cbmem.h>
Patrick Georgic8feedd2012-02-16 18:43:25 +010034#include <cpu/x86/lapic_def.h>
Duncan Laurie11290c42012-10-03 19:07:05 -070035#include <cpu/cpu.h>
Vladimir Serbinenko351fefc2014-10-26 20:42:08 +010036#include <cbfs.h>
Duncan Lauriecde78012011-10-19 15:32:39 -070037#if CONFIG_COLLECT_TIMESTAMPS
38#include <timestamp.h>
39#endif
Kyösti Mälkki9e94dbf2015-01-08 20:03:18 +020040#include <romstage_handoff.h>
Ronald G. Minnich02fa3b22004-10-06 17:33:54 +000041
Patrick Georgi9aeb6942012-10-05 21:54:38 +020042/* FIXME: Kconfig doesn't support overridable defaults :-( */
43#ifndef CONFIG_HPET_MIN_TICKS
44#define CONFIG_HPET_MIN_TICKS 0x1000
45#endif
46
Ronald G. Minnich02fa3b22004-10-06 17:33:54 +000047u8 acpi_checksum(u8 *table, u32 length)
Stefan Reinauer688b3852004-01-28 16:56:14 +000048{
Uwe Hermann622824c2010-11-19 15:14:42 +000049 u8 ret = 0;
Stefan Reinauer688b3852004-01-28 16:56:14 +000050 while (length--) {
51 ret += *table;
52 table++;
53 }
Stefan Reinauera7648c22004-01-29 17:31:34 +000054 return -ret;
Stefan Reinauer688b3852004-01-28 16:56:14 +000055}
56
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +000057/**
Uwe Hermann622824c2010-11-19 15:14:42 +000058 * Add an ACPI table to the RSDT (and XSDT) structure, recalculate length
59 * and checksum.
Stefan Reinauer06feb882004-02-03 16:11:35 +000060 */
Stefan Reinauerb657a3c2009-07-21 21:38:33 +000061void acpi_add_table(acpi_rsdp_t *rsdp, void *table)
Stefan Reinauer688b3852004-01-28 16:56:14 +000062{
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +000063 int i, entries_num;
Stefan Reinauerb657a3c2009-07-21 21:38:33 +000064 acpi_rsdt_t *rsdt;
65 acpi_xsdt_t *xsdt = NULL;
66
Uwe Hermann622824c2010-11-19 15:14:42 +000067 /* The RSDT is mandatory... */
Stefan Reinauerb657a3c2009-07-21 21:38:33 +000068 rsdt = (acpi_rsdt_t *)rsdp->rsdt_address;
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +000069
Uwe Hermann622824c2010-11-19 15:14:42 +000070 /* ...while the XSDT is not. */
71 if (rsdp->xsdt_address)
Stefan Reinauerb657a3c2009-07-21 21:38:33 +000072 xsdt = (acpi_xsdt_t *)((u32)rsdp->xsdt_address);
Stefan Reinauer14e22772010-04-27 06:56:47 +000073
Uwe Hermann622824c2010-11-19 15:14:42 +000074 /* This should always be MAX_ACPI_TABLES. */
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +000075 entries_num = ARRAY_SIZE(rsdt->entry);
Stefan Reinauer14e22772010-04-27 06:56:47 +000076
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +000077 for (i = 0; i < entries_num; i++) {
Uwe Hermann622824c2010-11-19 15:14:42 +000078 if (rsdt->entry[i] == 0)
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +000079 break;
Stefan Reinauer688b3852004-01-28 16:56:14 +000080 }
81
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +000082 if (i >= entries_num) {
Uwe Hermann622824c2010-11-19 15:14:42 +000083 printk(BIOS_ERR, "ACPI: Error: Could not add ACPI table, "
Cristian Măgherușan-Stanciuba482812011-07-02 00:57:07 +030084 "too many tables.\n");
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +000085 return;
86 }
87
Uwe Hermann622824c2010-11-19 15:14:42 +000088 /* Add table to the RSDT. */
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +000089 rsdt->entry[i] = (u32)table;
90
Uwe Hermann622824c2010-11-19 15:14:42 +000091 /* Fix RSDT length or the kernel will assume invalid entries. */
92 rsdt->header.length = sizeof(acpi_header_t) + (sizeof(u32) * (i + 1));
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +000093
Uwe Hermann622824c2010-11-19 15:14:42 +000094 /* Re-calculate checksum. */
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +000095 rsdt->header.checksum = 0; /* Hope this won't get optimized away */
Uwe Hermann622824c2010-11-19 15:14:42 +000096 rsdt->header.checksum = acpi_checksum((u8 *)rsdt, rsdt->header.length);
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +000097
Uwe Hermann622824c2010-11-19 15:14:42 +000098 /*
99 * And now the same thing for the XSDT. We use the same index as for
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +0000100 * now we want the XSDT and RSDT to always be in sync in coreboot.
101 */
102 if (xsdt) {
Uwe Hermann622824c2010-11-19 15:14:42 +0000103 /* Add table to the XSDT. */
104 xsdt->entry[i] = (u64)(u32)table;
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +0000105
Uwe Hermann622824c2010-11-19 15:14:42 +0000106 /* Fix XSDT length. */
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +0000107 xsdt->header.length = sizeof(acpi_header_t) +
Cristian Măgherușan-Stanciuba482812011-07-02 00:57:07 +0300108 (sizeof(u64) * (i + 1));
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +0000109
Uwe Hermann622824c2010-11-19 15:14:42 +0000110 /* Re-calculate checksum. */
111 xsdt->header.checksum = 0;
112 xsdt->header.checksum = acpi_checksum((u8 *)xsdt,
Cristian Măgherușan-Stanciuba482812011-07-02 00:57:07 +0300113 xsdt->header.length);
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +0000114 }
115
Uwe Hermann622824c2010-11-19 15:14:42 +0000116 printk(BIOS_DEBUG, "ACPI: added table %d/%d, length now %d\n",
Cristian Măgherușan-Stanciuba482812011-07-02 00:57:07 +0300117 i + 1, entries_num, rsdt->header.length);
Stefan Reinauer688b3852004-01-28 16:56:14 +0000118}
119
Uwe Hermann622824c2010-11-19 15:14:42 +0000120int acpi_create_mcfg_mmconfig(acpi_mcfg_mmconfig_t *mmconfig, u32 base,
Cristian Măgherușan-Stanciuba482812011-07-02 00:57:07 +0300121 u16 seg_nr, u8 start, u8 end)
Stefan Reinauer26d431a2009-01-20 19:17:51 +0000122{
Vladimir Serbinenko60fccdc2014-10-05 11:05:16 +0200123 memset(mmconfig, 0, sizeof(*mmconfig));
Rudolf Mareke6409f22007-11-03 12:50:26 +0000124 mmconfig->base_address = base;
125 mmconfig->base_reserved = 0;
126 mmconfig->pci_segment_group_number = seg_nr;
127 mmconfig->start_bus_number = start;
128 mmconfig->end_bus_number = end;
Uwe Hermann622824c2010-11-19 15:14:42 +0000129
130 return sizeof(acpi_mcfg_mmconfig_t);
Rudolf Mareke6409f22007-11-03 12:50:26 +0000131}
132
Stefan Reinauer777224c2005-01-19 14:06:41 +0000133int acpi_create_madt_lapic(acpi_madt_lapic_t *lapic, u8 cpu, u8 apic)
Stefan Reinauer06feb882004-02-03 16:11:35 +0000134{
Uwe Hermann622824c2010-11-19 15:14:42 +0000135 lapic->type = 0; /* Local APIC structure */
136 lapic->length = sizeof(acpi_madt_lapic_t);
137 lapic->flags = (1 << 0); /* Processor/LAPIC enabled */
138 lapic->processor_id = cpu;
139 lapic->apic_id = apic;
Stefan Reinauer14e22772010-04-27 06:56:47 +0000140
Uwe Hermann622824c2010-11-19 15:14:42 +0000141 return lapic->length;
Stefan Reinauer06feb882004-02-03 16:11:35 +0000142}
143
Stefan Reinauerda65fbf2009-04-22 08:18:37 +0000144unsigned long acpi_create_madt_lapics(unsigned long current)
145{
Edward O'Callaghan2c9d2cf2014-10-27 23:29:29 +1100146 struct device *cpu;
Duncan Laurie11290c42012-10-03 19:07:05 -0700147 int index = 0;
Stefan Reinauerda65fbf2009-04-22 08:18:37 +0000148
Uwe Hermann622824c2010-11-19 15:14:42 +0000149 for (cpu = all_devices; cpu; cpu = cpu->next) {
Stefan Reinauerda65fbf2009-04-22 08:18:37 +0000150 if ((cpu->path.type != DEVICE_PATH_APIC) ||
Stefan Reinauer0aa37c42013-02-12 15:20:54 -0800151 (cpu->bus->dev->path.type != DEVICE_PATH_CPU_CLUSTER)) {
Stefan Reinauerda65fbf2009-04-22 08:18:37 +0000152 continue;
153 }
Uwe Hermann622824c2010-11-19 15:14:42 +0000154 if (!cpu->enabled)
Stefan Reinauerda65fbf2009-04-22 08:18:37 +0000155 continue;
Uwe Hermann622824c2010-11-19 15:14:42 +0000156 current += acpi_create_madt_lapic((acpi_madt_lapic_t *)current,
Duncan Laurie11290c42012-10-03 19:07:05 -0700157 index, cpu->path.apic.apic_id);
158 index++;
Stefan Reinauerda65fbf2009-04-22 08:18:37 +0000159 }
Uwe Hermann622824c2010-11-19 15:14:42 +0000160
Stefan Reinauerda65fbf2009-04-22 08:18:37 +0000161 return current;
162}
163
Uwe Hermann622824c2010-11-19 15:14:42 +0000164int acpi_create_madt_ioapic(acpi_madt_ioapic_t *ioapic, u8 id, u32 addr,
Cristian Măgherușan-Stanciuba482812011-07-02 00:57:07 +0300165 u32 gsi_base)
Stefan Reinauer06feb882004-02-03 16:11:35 +0000166{
Uwe Hermann622824c2010-11-19 15:14:42 +0000167 ioapic->type = 1; /* I/O APIC structure */
168 ioapic->length = sizeof(acpi_madt_ioapic_t);
169 ioapic->reserved = 0x00;
170 ioapic->gsi_base = gsi_base;
171 ioapic->ioapic_id = id;
172 ioapic->ioapic_addr = addr;
Stefan Reinauer14e22772010-04-27 06:56:47 +0000173
Uwe Hermann622824c2010-11-19 15:14:42 +0000174 return ioapic->length;
Stefan Reinauer06feb882004-02-03 16:11:35 +0000175}
176
Stefan Reinauer777224c2005-01-19 14:06:41 +0000177int acpi_create_madt_irqoverride(acpi_madt_irqoverride_t *irqoverride,
Stefan Reinauer06feb882004-02-03 16:11:35 +0000178 u8 bus, u8 source, u32 gsirq, u16 flags)
179{
Uwe Hermann622824c2010-11-19 15:14:42 +0000180 irqoverride->type = 2; /* Interrupt source override */
181 irqoverride->length = sizeof(acpi_madt_irqoverride_t);
182 irqoverride->bus = bus;
183 irqoverride->source = source;
184 irqoverride->gsirq = gsirq;
185 irqoverride->flags = flags;
Stefan Reinauer14e22772010-04-27 06:56:47 +0000186
Uwe Hermann622824c2010-11-19 15:14:42 +0000187 return irqoverride->length;
Stefan Reinauer06feb882004-02-03 16:11:35 +0000188}
189
Stefan Reinauer777224c2005-01-19 14:06:41 +0000190int acpi_create_madt_lapic_nmi(acpi_madt_lapic_nmi_t *lapic_nmi, u8 cpu,
Cristian Măgherușan-Stanciuba482812011-07-02 00:57:07 +0300191 u16 flags, u8 lint)
Stefan Reinauer06feb882004-02-03 16:11:35 +0000192{
Uwe Hermann622824c2010-11-19 15:14:42 +0000193 lapic_nmi->type = 4; /* Local APIC NMI structure */
194 lapic_nmi->length = sizeof(acpi_madt_lapic_nmi_t);
195 lapic_nmi->flags = flags;
196 lapic_nmi->processor_id = cpu;
197 lapic_nmi->lint = lint;
Stefan Reinauer14e22772010-04-27 06:56:47 +0000198
Uwe Hermann622824c2010-11-19 15:14:42 +0000199 return lapic_nmi->length;
Stefan Reinauer06feb882004-02-03 16:11:35 +0000200}
201
Stefan Reinauer777224c2005-01-19 14:06:41 +0000202void acpi_create_madt(acpi_madt_t *madt)
Stefan Reinauer06feb882004-02-03 16:11:35 +0000203{
Uwe Hermann622824c2010-11-19 15:14:42 +0000204 acpi_header_t *header = &(madt->header);
205 unsigned long current = (unsigned long)madt + sizeof(acpi_madt_t);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000206
Stefan Reinauer06feb882004-02-03 16:11:35 +0000207 memset((void *)madt, 0, sizeof(acpi_madt_t));
Stefan Reinauer14e22772010-04-27 06:56:47 +0000208
Uwe Hermann622824c2010-11-19 15:14:42 +0000209 /* Fill out header fields. */
Stefan Reinauercdfe3762009-07-21 22:15:43 +0000210 memcpy(header->signature, "APIC", 4);
Stefan Reinauer06feb882004-02-03 16:11:35 +0000211 memcpy(header->oem_id, OEM_ID, 6);
Stefan Reinauercdfe3762009-07-21 22:15:43 +0000212 memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
Stefan Reinauer06feb882004-02-03 16:11:35 +0000213 memcpy(header->asl_compiler_id, ASLC, 4);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000214
Stefan Reinauer06feb882004-02-03 16:11:35 +0000215 header->length = sizeof(acpi_madt_t);
Uwe Hermann622824c2010-11-19 15:14:42 +0000216 header->revision = 1; /* ACPI 1.0/2.0: 1, ACPI 3.0: 2, ACPI 4.0: 3 */
Stefan Reinauer06feb882004-02-03 16:11:35 +0000217
Uwe Hermann622824c2010-11-19 15:14:42 +0000218 madt->lapic_addr = LOCAL_APIC_ADDR;
219 madt->flags = 0x1; /* PCAT_COMPAT */
Stefan Reinauer06feb882004-02-03 16:11:35 +0000220
Stefan Reinauerf622d592005-11-26 16:56:05 +0000221 current = acpi_fill_madt(current);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000222
Uwe Hermann622824c2010-11-19 15:14:42 +0000223 /* (Re)calculate length and checksum. */
224 header->length = current - (unsigned long)madt;
Stefan Reinauer14e22772010-04-27 06:56:47 +0000225
Uwe Hermann622824c2010-11-19 15:14:42 +0000226 header->checksum = acpi_checksum((void *)madt, header->length);
Stefan Reinauer06feb882004-02-03 16:11:35 +0000227}
228
Uwe Hermann622824c2010-11-19 15:14:42 +0000229/* MCFG is defined in the PCI Firmware Specification 3.0. */
Rudolf Mareke6409f22007-11-03 12:50:26 +0000230void acpi_create_mcfg(acpi_mcfg_t *mcfg)
231{
Uwe Hermann622824c2010-11-19 15:14:42 +0000232 acpi_header_t *header = &(mcfg->header);
233 unsigned long current = (unsigned long)mcfg + sizeof(acpi_mcfg_t);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000234
Rudolf Mareke6409f22007-11-03 12:50:26 +0000235 memset((void *)mcfg, 0, sizeof(acpi_mcfg_t));
Stefan Reinauer14e22772010-04-27 06:56:47 +0000236
Uwe Hermann622824c2010-11-19 15:14:42 +0000237 /* Fill out header fields. */
Stefan Reinauercdfe3762009-07-21 22:15:43 +0000238 memcpy(header->signature, "MCFG", 4);
Rudolf Mareke6409f22007-11-03 12:50:26 +0000239 memcpy(header->oem_id, OEM_ID, 6);
Stefan Reinauercdfe3762009-07-21 22:15:43 +0000240 memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
Rudolf Mareke6409f22007-11-03 12:50:26 +0000241 memcpy(header->asl_compiler_id, ASLC, 4);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000242
Rudolf Mareke6409f22007-11-03 12:50:26 +0000243 header->length = sizeof(acpi_mcfg_t);
244 header->revision = 1;
245
246 current = acpi_fill_mcfg(current);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000247
Uwe Hermann622824c2010-11-19 15:14:42 +0000248 /* (Re)calculate length and checksum. */
249 header->length = current - (unsigned long)mcfg;
250 header->checksum = acpi_checksum((void *)mcfg, header->length);
Rudolf Mareke6409f22007-11-03 12:50:26 +0000251}
252
Vladimir Serbinenkof44ac132015-05-20 19:52:01 +0200253static void *get_tcpa_log(u32 *size)
254{
255 const struct cbmem_entry *ce;
256 const u32 tcpa_default_log_len = 0x10000;
257 void *lasa;
258 ce = cbmem_entry_find(CBMEM_ID_TCPA_LOG);
259 if (ce) {
260 lasa = cbmem_entry_start(ce);
261 *size = cbmem_entry_size(ce);
262 printk(BIOS_DEBUG, "TCPA log found at %p\n", lasa);
263 return lasa;
264 }
265 lasa = cbmem_add(CBMEM_ID_TCPA_LOG, tcpa_default_log_len);
266 if (!lasa) {
267 printk(BIOS_ERR, "TCPA log creation failed\n");
268 return NULL;
269 }
270
271 printk(BIOS_DEBUG, "TCPA log created at %p\n", lasa);
272 memset (lasa, 0, tcpa_default_log_len);
273
274 *size = tcpa_default_log_len;
275 return lasa;
276}
277
278static void acpi_create_tcpa(acpi_tcpa_t *tcpa)
279{
280 acpi_header_t *header = &(tcpa->header);
281 u32 tcpa_log_len;
282 void *lasa;
283
284 memset((void *)tcpa, 0, sizeof(acpi_tcpa_t));
285
286 lasa = get_tcpa_log(&tcpa_log_len);
287 if (!lasa) {
288 return;
289 }
290
291 /* Fill out header fields. */
292 memcpy(header->signature, "TCPA", 4);
293 memcpy(header->oem_id, OEM_ID, 6);
294 memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
295 memcpy(header->asl_compiler_id, ASLC, 4);
296
297 header->length = sizeof(acpi_tcpa_t);
298 header->revision = 2;
299
300 tcpa->platform_class = 0;
301 tcpa->laml = tcpa_log_len;
302 tcpa->lasa = (u32) lasa;
303
304 /* Calculate checksum. */
305 header->checksum = acpi_checksum((void *)tcpa, header->length);
306}
307
Myles Watson3fe6b702009-10-09 20:13:43 +0000308void acpi_create_ssdt_generator(acpi_header_t *ssdt, const char *oem_table_id)
Rudolf Marek293b5f52009-02-01 18:35:15 +0000309{
Uwe Hermann622824c2010-11-19 15:14:42 +0000310 unsigned long current = (unsigned long)ssdt + sizeof(acpi_header_t);
311
Rudolf Marek293b5f52009-02-01 18:35:15 +0000312 memset((void *)ssdt, 0, sizeof(acpi_header_t));
Uwe Hermann622824c2010-11-19 15:14:42 +0000313
Stefan Reinauercdfe3762009-07-21 22:15:43 +0000314 memcpy(&ssdt->signature, "SSDT", 4);
Uwe Hermann622824c2010-11-19 15:14:42 +0000315 ssdt->revision = 2; /* ACPI 1.0/2.0: ?, ACPI 3.0/4.0: 2 */
Rudolf Marek293b5f52009-02-01 18:35:15 +0000316 memcpy(&ssdt->oem_id, OEM_ID, 6);
317 memcpy(&ssdt->oem_table_id, oem_table_id, 8);
318 ssdt->oem_revision = 42;
Uwe Hermann622824c2010-11-19 15:14:42 +0000319 memcpy(&ssdt->asl_compiler_id, ASLC, 4);
Rudolf Marek293b5f52009-02-01 18:35:15 +0000320 ssdt->asl_compiler_revision = 42;
321 ssdt->length = sizeof(acpi_header_t);
322
Stefan Reinauer8dcd50b2009-03-06 17:24:29 +0000323 acpigen_set_current((char *) current);
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200324 {
Edward O'Callaghan2c9d2cf2014-10-27 23:29:29 +1100325 struct device *dev;
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200326 for (dev = all_devices; dev; dev = dev->next)
327 if (dev->ops && dev->ops->acpi_fill_ssdt_generator) {
Vladimir Serbinenko0a669912014-10-05 14:34:17 +0200328 dev->ops->acpi_fill_ssdt_generator();
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200329 }
Vladimir Serbinenko0a669912014-10-05 14:34:17 +0200330 current = (unsigned long) acpigen_get_current();
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200331 }
Rudolf Marek293b5f52009-02-01 18:35:15 +0000332
Uwe Hermann622824c2010-11-19 15:14:42 +0000333 /* (Re)calculate length and checksum. */
Rudolf Marek293b5f52009-02-01 18:35:15 +0000334 ssdt->length = current - (unsigned long)ssdt;
335 ssdt->checksum = acpi_checksum((void *)ssdt, ssdt->length);
336}
337
Stefan Reinauerf622d592005-11-26 16:56:05 +0000338int acpi_create_srat_lapic(acpi_srat_lapic_t *lapic, u8 node, u8 apic)
339{
Myles Watson0b4c9f02009-03-10 18:06:47 +0000340 memset((void *)lapic, 0, sizeof(acpi_srat_lapic_t));
Stefan Reinauerf622d592005-11-26 16:56:05 +0000341
Uwe Hermann622824c2010-11-19 15:14:42 +0000342 lapic->type = 0; /* Processor local APIC/SAPIC affinity structure */
343 lapic->length = sizeof(acpi_srat_lapic_t);
344 lapic->flags = (1 << 0); /* Enabled (the use of this structure). */
345 lapic->proximity_domain_7_0 = node;
346 /* TODO: proximity_domain_31_8, local SAPIC EID, clock domain. */
347 lapic->apic_id = apic;
Stefan Reinauerf622d592005-11-26 16:56:05 +0000348
Uwe Hermann622824c2010-11-19 15:14:42 +0000349 return lapic->length;
Stefan Reinauerf622d592005-11-26 16:56:05 +0000350}
351
Uwe Hermann622824c2010-11-19 15:14:42 +0000352int 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 +0300353 u32 flags)
Stefan Reinauerf622d592005-11-26 16:56:05 +0000354{
Uwe Hermann622824c2010-11-19 15:14:42 +0000355 mem->type = 1; /* Memory affinity structure */
356 mem->length = sizeof(acpi_srat_mem_t);
357 mem->base_address_low = (basek << 10);
358 mem->base_address_high = (basek >> (32 - 10));
359 mem->length_low = (sizek << 10);
360 mem->length_high = (sizek >> (32 - 10));
361 mem->proximity_domain = node;
Stefan Reinauer14e22772010-04-27 06:56:47 +0000362 mem->flags = flags;
Stefan Reinauerf622d592005-11-26 16:56:05 +0000363
Uwe Hermann622824c2010-11-19 15:14:42 +0000364 return mem->length;
Stefan Reinauerf622d592005-11-26 16:56:05 +0000365}
366
Uwe Hermann622824c2010-11-19 15:14:42 +0000367/* http://www.microsoft.com/whdc/system/sysinternals/sratdwn.mspx */
Vladimir Serbinenko5e597572014-10-11 23:45:40 +0200368void acpi_create_srat(acpi_srat_t *srat,
369 unsigned long (*acpi_fill_srat)(unsigned long current))
Stefan Reinauerf622d592005-11-26 16:56:05 +0000370{
Uwe Hermann622824c2010-11-19 15:14:42 +0000371 acpi_header_t *header = &(srat->header);
372 unsigned long current = (unsigned long)srat + sizeof(acpi_srat_t);
Stefan Reinauerf622d592005-11-26 16:56:05 +0000373
Uwe Hermann622824c2010-11-19 15:14:42 +0000374 memset((void *)srat, 0, sizeof(acpi_srat_t));
Stefan Reinauerf622d592005-11-26 16:56:05 +0000375
Uwe Hermann622824c2010-11-19 15:14:42 +0000376 /* Fill out header fields. */
377 memcpy(header->signature, "SRAT", 4);
378 memcpy(header->oem_id, OEM_ID, 6);
379 memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
380 memcpy(header->asl_compiler_id, ASLC, 4);
Stefan Reinauerf622d592005-11-26 16:56:05 +0000381
Uwe Hermann622824c2010-11-19 15:14:42 +0000382 header->length = sizeof(acpi_srat_t);
383 header->revision = 1; /* ACPI 1.0: N/A, 2.0: 1, 3.0: 2, 4.0: 3 */
Stefan Reinauerf622d592005-11-26 16:56:05 +0000384
Uwe Hermann622824c2010-11-19 15:14:42 +0000385 srat->resv = 1; /* Spec: Reserved to 1 for backwards compatibility. */
Stefan Reinauerf622d592005-11-26 16:56:05 +0000386
Uwe Hermann622824c2010-11-19 15:14:42 +0000387 current = acpi_fill_srat(current);
Stefan Reinauerf622d592005-11-26 16:56:05 +0000388
Uwe Hermann622824c2010-11-19 15:14:42 +0000389 /* (Re)calculate length and checksum. */
390 header->length = current - (unsigned long)srat;
391 header->checksum = acpi_checksum((void *)srat, header->length);
Stefan Reinauerf622d592005-11-26 16:56:05 +0000392}
393
Vladimir Serbinenko8d70e942014-11-09 13:22:27 +0100394void acpi_create_dmar(acpi_dmar_t *dmar,
395 unsigned long (*acpi_fill_dmar) (unsigned long))
Patrick Georgi3b590ff2012-09-11 15:21:01 +0200396{
397 acpi_header_t *header = &(dmar->header);
398 unsigned long current = (unsigned long)dmar + sizeof(acpi_dmar_t);
399
400 memset((void *)dmar, 0, sizeof(acpi_dmar_t));
401
402 /* Fill out header fields. */
403 memcpy(header->signature, "DMAR", 4);
404 memcpy(header->oem_id, OEM_ID, 6);
405 memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
406 memcpy(header->asl_compiler_id, ASLC, 4);
407
408 header->length = sizeof(acpi_dmar_t);
409 header->revision = 1;
410
411 dmar->host_address_width = 40 - 1; /* FIXME: == MTRR size? */
412 dmar->flags = 0;
413
414 current = acpi_fill_dmar(current);
415
416 /* (Re)calculate length and checksum. */
417 header->length = current - (unsigned long)dmar;
418 header->checksum = acpi_checksum((void *)dmar, header->length);
419}
420
421unsigned long acpi_create_dmar_drhd(unsigned long current, u8 flags,
422 u16 segment, u32 bar)
423{
424 dmar_entry_t *drhd = (dmar_entry_t *)current;
425 memset(drhd, 0, sizeof(*drhd));
426 drhd->type = DMAR_DRHD;
427 drhd->length = sizeof(*drhd); /* will be fixed up later */
428 drhd->flags = flags;
429 drhd->segment = segment;
430 drhd->bar = bar;
431
432 return drhd->length;
433}
434
435void acpi_dmar_drhd_fixup(unsigned long base, unsigned long current)
436{
437 dmar_entry_t *drhd = (dmar_entry_t *)base;
438 drhd->length = current - base;
439}
440
441unsigned long acpi_create_dmar_drhd_ds_pci(unsigned long current, u8 segment,
442 u8 dev, u8 fn)
443{
444 dev_scope_t *ds = (dev_scope_t *)current;
445 memset(ds, 0, sizeof(*ds));
446 ds->type = SCOPE_PCI_ENDPOINT;
447 ds->length = sizeof(*ds) + 2; /* we don't support longer paths yet */
448 ds->start_bus = segment;
449 ds->path[0].dev = dev;
450 ds->path[0].fn = fn;
451
452 return ds->length;
453}
454
Uwe Hermann622824c2010-11-19 15:14:42 +0000455/* http://h21007.www2.hp.com/portal/download/files/unprot/Itanium/slit.pdf */
Vladimir Serbinenko5e597572014-10-11 23:45:40 +0200456void acpi_create_slit(acpi_slit_t *slit,
457 unsigned long (*acpi_fill_slit)(unsigned long current))
Yinghai Lud4b278c2006-10-04 20:46:15 +0000458{
Uwe Hermann622824c2010-11-19 15:14:42 +0000459 acpi_header_t *header = &(slit->header);
460 unsigned long current = (unsigned long)slit + sizeof(acpi_slit_t);
Yinghai Lud4b278c2006-10-04 20:46:15 +0000461
Uwe Hermann622824c2010-11-19 15:14:42 +0000462 memset((void *)slit, 0, sizeof(acpi_slit_t));
Yinghai Lud4b278c2006-10-04 20:46:15 +0000463
Uwe Hermann622824c2010-11-19 15:14:42 +0000464 /* Fill out header fields. */
465 memcpy(header->signature, "SLIT", 4);
466 memcpy(header->oem_id, OEM_ID, 6);
467 memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
468 memcpy(header->asl_compiler_id, ASLC, 4);
Yinghai Lud4b278c2006-10-04 20:46:15 +0000469
Uwe Hermann622824c2010-11-19 15:14:42 +0000470 header->length = sizeof(acpi_slit_t);
471 header->revision = 1; /* ACPI 1.0: N/A, ACPI 2.0/3.0/4.0: 1 */
Yinghai Lud4b278c2006-10-04 20:46:15 +0000472
Uwe Hermann622824c2010-11-19 15:14:42 +0000473 current = acpi_fill_slit(current);
Yinghai Lud4b278c2006-10-04 20:46:15 +0000474
Uwe Hermann622824c2010-11-19 15:14:42 +0000475 /* (Re)calculate length and checksum. */
476 header->length = current - (unsigned long)slit;
477 header->checksum = acpi_checksum((void *)slit, header->length);
Yinghai Lud4b278c2006-10-04 20:46:15 +0000478}
479
Uwe Hermann622824c2010-11-19 15:14:42 +0000480/* http://www.intel.com/hardwaredesign/hpetspec_1.pdf */
Stefan Reinauer777224c2005-01-19 14:06:41 +0000481void acpi_create_hpet(acpi_hpet_t *hpet)
Stefan Reinauer688b3852004-01-28 16:56:14 +0000482{
Uwe Hermann622824c2010-11-19 15:14:42 +0000483 acpi_header_t *header = &(hpet->header);
484 acpi_addr_t *addr = &(hpet->addr);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000485
Stefan Reinauera7648c22004-01-29 17:31:34 +0000486 memset((void *)hpet, 0, sizeof(acpi_hpet_t));
Stefan Reinauer14e22772010-04-27 06:56:47 +0000487
Uwe Hermann622824c2010-11-19 15:14:42 +0000488 /* Fill out header fields. */
Stefan Reinauer4704dc52009-07-22 01:11:37 +0000489 memcpy(header->signature, "HPET", 4);
Stefan Reinauer688b3852004-01-28 16:56:14 +0000490 memcpy(header->oem_id, OEM_ID, 6);
Stefan Reinauercdfe3762009-07-21 22:15:43 +0000491 memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
Stefan Reinauer688b3852004-01-28 16:56:14 +0000492 memcpy(header->asl_compiler_id, ASLC, 4);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000493
Stefan Reinauer688b3852004-01-28 16:56:14 +0000494 header->length = sizeof(acpi_hpet_t);
Uwe Hermann622824c2010-11-19 15:14:42 +0000495 header->revision = 1; /* Currently 1. Table added in ACPI 2.0. */
Stefan Reinauer688b3852004-01-28 16:56:14 +0000496
Uwe Hermann622824c2010-11-19 15:14:42 +0000497 /* Fill out HPET address. */
498 addr->space_id = 0; /* Memory */
499 addr->bit_width = 64;
500 addr->bit_offset = 0;
Patrick Georgi9aeb6942012-10-05 21:54:38 +0200501 addr->addrl = CONFIG_HPET_ADDRESS & 0xffffffff;
502 addr->addrh = ((unsigned long long)CONFIG_HPET_ADDRESS) >> 32;
Stefan Reinauer688b3852004-01-28 16:56:14 +0000503
Patrick Georgi9aeb6942012-10-05 21:54:38 +0200504 hpet->id = *(unsigned int*)CONFIG_HPET_ADDRESS;
Uwe Hermann622824c2010-11-19 15:14:42 +0000505 hpet->number = 0;
Patrick Georgi9aeb6942012-10-05 21:54:38 +0200506 hpet->min_tick = CONFIG_HPET_MIN_TICKS;
Stefan Reinauer14e22772010-04-27 06:56:47 +0000507
Uwe Hermann622824c2010-11-19 15:14:42 +0000508 header->checksum = acpi_checksum((void *)hpet, sizeof(acpi_hpet_t));
Stefan Reinauer688b3852004-01-28 16:56:14 +0000509}
Uwe Hermann622824c2010-11-19 15:14:42 +0000510
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200511unsigned long acpi_write_hpet(unsigned long current, acpi_rsdp_t *rsdp)
512{
513 acpi_hpet_t *hpet;
514
515 /*
516 * We explicitly add these tables later on:
517 */
518 printk(BIOS_DEBUG, "ACPI: * HPET\n");
519
520 hpet = (acpi_hpet_t *) current;
521 current += sizeof(acpi_hpet_t);
522 current = ALIGN(current, 16);
523 acpi_create_hpet(hpet);
524 acpi_add_table(rsdp, hpet);
525
526 return current;
527}
528
Stefan Reinauer777224c2005-01-19 14:06:41 +0000529void acpi_create_facs(acpi_facs_t *facs)
Ronald G. Minnich02fa3b22004-10-06 17:33:54 +0000530{
Uwe Hermann622824c2010-11-19 15:14:42 +0000531 memset((void *)facs, 0, sizeof(acpi_facs_t));
Ronald G. Minnich02fa3b22004-10-06 17:33:54 +0000532
Stefan Reinauercdfe3762009-07-21 22:15:43 +0000533 memcpy(facs->signature, "FACS", 4);
Ronald G. Minnich02fa3b22004-10-06 17:33:54 +0000534 facs->length = sizeof(acpi_facs_t);
535 facs->hardware_signature = 0;
536 facs->firmware_waking_vector = 0;
537 facs->global_lock = 0;
538 facs->flags = 0;
539 facs->x_firmware_waking_vector_l = 0;
540 facs->x_firmware_waking_vector_h = 0;
Uwe Hermann622824c2010-11-19 15:14:42 +0000541 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 +0000542}
Stefan Reinauer777224c2005-01-19 14:06:41 +0000543
Vladimir Serbinenko351fefc2014-10-26 20:42:08 +0100544static void acpi_write_rsdt(acpi_rsdt_t *rsdt, char *oem_id, char *oem_table_id)
Stefan Reinauer14e22772010-04-27 06:56:47 +0000545{
Uwe Hermann622824c2010-11-19 15:14:42 +0000546 acpi_header_t *header = &(rsdt->header);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000547
Uwe Hermann622824c2010-11-19 15:14:42 +0000548 /* Fill out header fields. */
Stefan Reinauercdfe3762009-07-21 22:15:43 +0000549 memcpy(header->signature, "RSDT", 4);
Vladimir Serbinenko351fefc2014-10-26 20:42:08 +0100550 memcpy(header->oem_id, oem_id, 6);
551 memcpy(header->oem_table_id, oem_table_id, 8);
Stefan Reinauer688b3852004-01-28 16:56:14 +0000552 memcpy(header->asl_compiler_id, ASLC, 4);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000553
Stefan Reinauer688b3852004-01-28 16:56:14 +0000554 header->length = sizeof(acpi_rsdt_t);
Uwe Hermann622824c2010-11-19 15:14:42 +0000555 header->revision = 1; /* ACPI 1.0/2.0/3.0/4.0: 1 */
Stefan Reinauer14e22772010-04-27 06:56:47 +0000556
Uwe Hermann622824c2010-11-19 15:14:42 +0000557 /* Entries are filled in later, we come with an empty set. */
Stefan Reinauer688b3852004-01-28 16:56:14 +0000558
Uwe Hermann622824c2010-11-19 15:14:42 +0000559 /* Fix checksum. */
Stefan Reinauerb657a3c2009-07-21 21:38:33 +0000560 header->checksum = acpi_checksum((void *)rsdt, sizeof(acpi_rsdt_t));
Stefan Reinauer688b3852004-01-28 16:56:14 +0000561}
562
Vladimir Serbinenko351fefc2014-10-26 20:42:08 +0100563static void acpi_write_xsdt(acpi_xsdt_t *xsdt, char *oem_id, char *oem_table_id)
Stefan Reinauer14e22772010-04-27 06:56:47 +0000564{
Uwe Hermann622824c2010-11-19 15:14:42 +0000565 acpi_header_t *header = &(xsdt->header);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000566
Uwe Hermann622824c2010-11-19 15:14:42 +0000567 /* Fill out header fields. */
Stefan Reinauercdfe3762009-07-21 22:15:43 +0000568 memcpy(header->signature, "XSDT", 4);
Vladimir Serbinenko351fefc2014-10-26 20:42:08 +0100569 memcpy(header->oem_id, oem_id, 6);
570 memcpy(header->oem_table_id, oem_table_id, 8);
Stefan Reinauerb657a3c2009-07-21 21:38:33 +0000571 memcpy(header->asl_compiler_id, ASLC, 4);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000572
Stefan Reinauerb657a3c2009-07-21 21:38:33 +0000573 header->length = sizeof(acpi_xsdt_t);
Uwe Hermann622824c2010-11-19 15:14:42 +0000574 header->revision = 1; /* ACPI 1.0: N/A, 2.0/3.0/4.0: 1 */
Stefan Reinauer14e22772010-04-27 06:56:47 +0000575
Uwe Hermann622824c2010-11-19 15:14:42 +0000576 /* Entries are filled in later, we come with an empty set. */
Stefan Reinauerb657a3c2009-07-21 21:38:33 +0000577
Uwe Hermann622824c2010-11-19 15:14:42 +0000578 /* Fix checksum. */
Stefan Reinauerb657a3c2009-07-21 21:38:33 +0000579 header->checksum = acpi_checksum((void *)xsdt, sizeof(acpi_xsdt_t));
580}
581
Vladimir Serbinenko351fefc2014-10-26 20:42:08 +0100582static void acpi_write_rsdp(acpi_rsdp_t *rsdp, acpi_rsdt_t *rsdt,
583 acpi_xsdt_t *xsdt, char *oem_id)
Stefan Reinauer688b3852004-01-28 16:56:14 +0000584{
Stefan Reinauerd18faac2009-11-05 18:06:43 +0000585 memset(rsdp, 0, sizeof(acpi_rsdp_t));
Uwe Hermann622824c2010-11-19 15:14:42 +0000586
Stefan Reinauer688b3852004-01-28 16:56:14 +0000587 memcpy(rsdp->signature, RSDP_SIG, 8);
Vladimir Serbinenko351fefc2014-10-26 20:42:08 +0100588 memcpy(rsdp->oem_id, oem_id, 6);
Uwe Hermann622824c2010-11-19 15:14:42 +0000589
590 rsdp->length = sizeof(acpi_rsdp_t);
591 rsdp->rsdt_address = (u32)rsdt;
592
593 /*
594 * Revision: ACPI 1.0: 0, ACPI 2.0/3.0/4.0: 2.
595 *
596 * Some OSes expect an XSDT to be present for RSD PTR revisions >= 2.
597 * If we don't have an ACPI XSDT, force ACPI 1.0 (and thus RSD PTR
598 * revision 0).
Stefan Reinauerb657a3c2009-07-21 21:38:33 +0000599 */
600 if (xsdt == NULL) {
Uwe Hermann622824c2010-11-19 15:14:42 +0000601 rsdp->revision = 0;
Stefan Reinauerb657a3c2009-07-21 21:38:33 +0000602 } else {
Uwe Hermann622824c2010-11-19 15:14:42 +0000603 rsdp->xsdt_address = (u64)(u32)xsdt;
604 rsdp->revision = 2;
Stefan Reinauerb657a3c2009-07-21 21:38:33 +0000605 }
Uwe Hermann622824c2010-11-19 15:14:42 +0000606
607 /* Calculate checksums. */
608 rsdp->checksum = acpi_checksum((void *)rsdp, 20);
609 rsdp->ext_checksum = acpi_checksum((void *)rsdp, sizeof(acpi_rsdp_t));
Stefan Reinauer688b3852004-01-28 16:56:14 +0000610}
611
zbaocaf494c82012-04-13 13:57:14 +0800612unsigned long acpi_create_hest_error_source(acpi_hest_t *hest, acpi_hest_esd_t *esd, u16 type, void *data, u16 data_len)
613{
614 acpi_header_t *header = &(hest->header);
615 acpi_hest_hen_t *hen;
616 void *pos;
617 u16 len;
618
619 pos = esd;
620 memset(pos, 0, sizeof(acpi_hest_esd_t));
621 len = 0;
622 esd->type = type; /* MCE */
623 esd->source_id = hest->error_source_count;
624 esd->flags = 0; /* FIRMWARE_FIRST */
625 esd->enabled = 1;
626 esd->prealloc_erecords = 1;
627 esd->max_section_per_record = 0x1;
628
629 len += sizeof(acpi_hest_esd_t);
630 pos = esd + 1;
631
632 switch (type) {
633 case 0: /* MCE */
634 break;
635 case 1: /* CMC */
636 hen = (acpi_hest_hen_t *) (pos);
637 memset(pos, 0, sizeof(acpi_hest_hen_t));
638 hen->type = 3; /* SCI? */
639 hen->length = sizeof(acpi_hest_hen_t);
640 hen->conf_we = 0; /* Configuration Write Enable. */
641 hen->poll_interval = 0;
642 hen->vector = 0;
643 hen->sw2poll_threshold_val = 0;
644 hen->sw2poll_threshold_win = 0;
645 hen->error_threshold_val = 0;
646 hen->error_threshold_win = 0;
647 len += sizeof(acpi_hest_hen_t);
648 pos = hen + 1;
649 break;
650 case 2: /* NMI */
651 case 6: /* AER Root Port */
652 case 7: /* AER Endpoint */
653 case 8: /* AER Bridge */
654 case 9: /* Generic Hardware Error Source. */
655 /* TODO: */
656 break;
657 default:
658 printk(BIOS_DEBUG, "Invalid type of Error Source.");
659 break;
660 }
661 hest->error_source_count ++;
662
663 memcpy(pos, data, data_len);
664 len += data_len;
665 header->length += len;
666
667 return len;
668}
669
670/* ACPI 4.0 */
Vladimir Serbinenko807127f2014-11-09 13:36:18 +0100671void acpi_write_hest(acpi_hest_t *hest,
672 unsigned long (*acpi_fill_hest)(acpi_hest_t *hest))
zbaocaf494c82012-04-13 13:57:14 +0800673{
674 acpi_header_t *header = &(hest->header);
675
676 memset(hest, 0, sizeof(acpi_hest_t));
677
678 memcpy(header->signature, "HEST", 4);
679 memcpy(header->oem_id, OEM_ID, 6);
680 memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
681 memcpy(header->asl_compiler_id, ASLC, 4);
682 header->length += sizeof(acpi_hest_t);
683 header->revision = 1;
684
685 acpi_fill_hest(hest);
686
687 /* Calculate checksums. */
688 header->checksum = acpi_checksum((void *)hest, header->length);
689}
690
Vladimir Serbinenkoc21e0732014-10-16 12:48:19 +0200691#if IS_ENABLED(CONFIG_COMMON_FADT)
692void acpi_create_fadt(acpi_fadt_t *fadt,acpi_facs_t *facs, void *dsdt)
693{
694 acpi_header_t *header = &(fadt->header);
695
696 memset((void *) fadt, 0, sizeof(acpi_fadt_t));
697 memcpy(header->signature, "FACP", 4);
698 header->length = sizeof(acpi_fadt_t);
Vladimir Serbinenkoab83ef02014-10-25 15:18:25 +0200699 header->revision = 4;
Vladimir Serbinenkoc21e0732014-10-16 12:48:19 +0200700 memcpy(header->oem_id, OEM_ID, 6);
701 memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
702 memcpy(header->asl_compiler_id, ASLC, 4);
703 header->asl_compiler_revision = 0;
704
705 fadt->firmware_ctrl = (unsigned long) facs;
706 fadt->dsdt = (unsigned long) dsdt;
707
708 fadt->x_firmware_ctl_l = (unsigned long)facs;
709 fadt->x_firmware_ctl_h = 0;
710 fadt->x_dsdt_l = (unsigned long)dsdt;
711 fadt->x_dsdt_h = 0;
712
713 if(IS_ENABLED(CONFIG_SYSTEM_TYPE_LAPTOP)) {
714 fadt->preferred_pm_profile = PM_MOBILE;
715 } else {
716 fadt->preferred_pm_profile = PM_DESKTOP;
717 }
718
Vladimir Serbinenkoab83ef02014-10-25 15:18:25 +0200719 acpi_fill_fadt(fadt);
Vladimir Serbinenkoc21e0732014-10-16 12:48:19 +0200720
721 header->checksum =
722 acpi_checksum((void *) fadt, header->length);
723}
724#endif
725
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200726extern const unsigned char AmlCode[];
727
Vladimir Serbinenko41877d82014-09-01 22:18:01 +0200728unsigned long __attribute__ ((weak)) fw_cfg_acpi_tables(unsigned long start)
729{
730 return 0;
731}
732
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200733#define ALIGN_CURRENT current = (ALIGN(current, 16))
734unsigned long write_acpi_tables(unsigned long start)
735{
736 unsigned long current;
737 acpi_rsdp_t *rsdp;
738 acpi_rsdt_t *rsdt;
739 acpi_xsdt_t *xsdt;
740 acpi_fadt_t *fadt;
741 acpi_facs_t *facs;
Vladimir Serbinenko351fefc2014-10-26 20:42:08 +0100742 acpi_header_t *slic_file, *slic;
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200743 acpi_header_t *ssdt;
744 acpi_header_t *dsdt;
745 acpi_mcfg_t *mcfg;
Vladimir Serbinenkof44ac132015-05-20 19:52:01 +0200746 acpi_tcpa_t *tcpa;
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200747 acpi_madt_t *madt;
Edward O'Callaghan2c9d2cf2014-10-27 23:29:29 +1100748 struct device *dev;
Vladimir Serbinenko41877d82014-09-01 22:18:01 +0200749 unsigned long fw;
Vladimir Serbinenko351fefc2014-10-26 20:42:08 +0100750 size_t slic_size;
751 char oem_id[6], oem_table_id[8];
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200752
753 current = start;
754
755 /* Align ACPI tables to 16byte */
756 ALIGN_CURRENT;
757
Vladimir Serbinenko41877d82014-09-01 22:18:01 +0200758 fw = fw_cfg_acpi_tables(current);
759 if (fw)
760 return fw;
761
Vladimir Serbinenko351fefc2014-10-26 20:42:08 +0100762 slic_file = cbfs_get_file_content(CBFS_DEFAULT_MEDIA,
763 CONFIG_CBFS_PREFIX "/slic",
764 CBFS_TYPE_RAW, &slic_size);
765 if (slic_file && (slic_file->length > slic_size
766 || slic_file->length < sizeof (acpi_header_t))) {
767 slic_file = 0;
768 }
769
770 if (slic_file) {
771 memcpy(oem_id, slic_file->oem_id, 6);
772 memcpy(oem_table_id, slic_file->oem_table_id, 8);
773 } else {
774 memcpy(oem_id, OEM_ID, 6);
775 memcpy(oem_table_id, ACPI_TABLE_CREATOR, 8);
776 }
777
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200778 printk(BIOS_INFO, "ACPI: Writing ACPI tables at %lx.\n", start);
779
780 /* We need at least an RSDP and an RSDT Table */
781 rsdp = (acpi_rsdp_t *) current;
782 current += sizeof(acpi_rsdp_t);
783 ALIGN_CURRENT;
784 rsdt = (acpi_rsdt_t *) current;
785 current += sizeof(acpi_rsdt_t);
786 ALIGN_CURRENT;
787 xsdt = (acpi_xsdt_t *) current;
788 current += sizeof(acpi_xsdt_t);
789 ALIGN_CURRENT;
790
791 /* clear all table memory */
792 memset((void *) start, 0, current - start);
793
Vladimir Serbinenko351fefc2014-10-26 20:42:08 +0100794 acpi_write_rsdp(rsdp, rsdt, xsdt, oem_id);
795 acpi_write_rsdt(rsdt, oem_id, oem_table_id);
796 acpi_write_xsdt(xsdt, oem_id, oem_table_id);
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200797
798 printk(BIOS_DEBUG, "ACPI: * FACS\n");
799 facs = (acpi_facs_t *) current;
800 current += sizeof(acpi_facs_t);
801 ALIGN_CURRENT;
802 acpi_create_facs(facs);
803
804 printk(BIOS_DEBUG, "ACPI: * DSDT\n");
805 dsdt = (acpi_header_t *) current;
806 memcpy(dsdt, &AmlCode, sizeof(acpi_header_t));
Vladimir Serbinenko334fd8e2014-10-05 11:10:35 +0200807 if (dsdt->length >= sizeof(acpi_header_t)) {
808 current += sizeof(acpi_header_t);
809
810 acpigen_set_current((char *) current);
811 for (dev = all_devices; dev; dev = dev->next)
812 if (dev->ops && dev->ops->acpi_inject_dsdt_generator) {
813 dev->ops->acpi_inject_dsdt_generator();
814 }
815 current = (unsigned long) acpigen_get_current();
816 memcpy((char *)current,
817 (char *)&AmlCode + sizeof(acpi_header_t),
818 dsdt->length - sizeof(acpi_header_t));
819 current += dsdt->length - sizeof(acpi_header_t);
820
821 /* (Re)calculate length and checksum. */
822 dsdt->length = current - (unsigned long)dsdt;
823 dsdt->checksum = 0;
824 dsdt->checksum = acpi_checksum((void *)dsdt, dsdt->length);
825 }
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200826
827 ALIGN_CURRENT;
828
829 printk(BIOS_DEBUG, "ACPI: * FADT\n");
830 fadt = (acpi_fadt_t *) current;
831 current += sizeof(acpi_fadt_t);
832 ALIGN_CURRENT;
833
834 acpi_create_fadt(fadt, facs, dsdt);
835 acpi_add_table(rsdp, fadt);
836
Vladimir Serbinenko351fefc2014-10-26 20:42:08 +0100837 if (slic_file) {
838 printk(BIOS_DEBUG, "ACPI: * SLIC\n");
839 slic = (acpi_header_t *)current;
840 memcpy(slic, slic_file, slic_file->length);
841 current += slic_file->length;
842 ALIGN_CURRENT;
843 acpi_add_table(rsdp, slic);
844 }
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200845
846 printk(BIOS_DEBUG, "ACPI: * SSDT\n");
847 ssdt = (acpi_header_t *)current;
848 acpi_create_ssdt_generator(ssdt, ACPI_TABLE_CREATOR);
Vladimir Serbinenko9310df82014-10-10 20:40:41 +0200849 if (ssdt->length > sizeof(acpi_header_t)) {
850 current += ssdt->length;
851 acpi_add_table(rsdp, ssdt);
852 ALIGN_CURRENT;
853 }
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200854
855 printk(BIOS_DEBUG, "ACPI: * MCFG\n");
856 mcfg = (acpi_mcfg_t *) current;
857 acpi_create_mcfg(mcfg);
858 if (mcfg->header.length > sizeof(acpi_mcfg_t)) {
859 current += mcfg->header.length;
860 ALIGN_CURRENT;
861 acpi_add_table(rsdp, mcfg);
862 }
863
Vladimir Serbinenkof44ac132015-05-20 19:52:01 +0200864 printk(BIOS_DEBUG, "ACPI: * TCPA\n");
865 tcpa = (acpi_tcpa_t *) current;
866 acpi_create_tcpa(tcpa);
867 if (tcpa->header.length >= sizeof(acpi_tcpa_t)) {
868 current += tcpa->header.length;
869 ALIGN_CURRENT;
870 acpi_add_table(rsdp, tcpa);
871 }
872
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200873 printk(BIOS_DEBUG, "ACPI: * MADT\n");
874
875 madt = (acpi_madt_t *) current;
876 acpi_create_madt(madt);
877 if (madt->header.length > sizeof(acpi_madt_t)) {
878 current+=madt->header.length;
879 acpi_add_table(rsdp,madt);
880 }
881 ALIGN_CURRENT;
882
883 printk(BIOS_DEBUG, "current = %lx\n", current);
884
885 for (dev = all_devices; dev; dev = dev->next) {
886 if (dev->ops && dev->ops->write_acpi_tables) {
887 current = dev->ops->write_acpi_tables(current, rsdp);
888 ALIGN_CURRENT;
889 }
890 }
891
892 printk(BIOS_INFO, "ACPI: done.\n");
893 return current;
894}
Vladimir Serbinenko2d7bd8a2014-08-30 19:28:05 +0200895
Patrick Georgie1667822012-05-05 15:29:32 +0200896#if CONFIG_HAVE_ACPI_RESUME
Kyösti Mälkki134f5042014-12-26 13:29:09 +0200897void __attribute__((weak)) mainboard_suspend_resume(void)
898{
899}
900
Aaron Durbin0a6c20a2013-04-24 22:33:08 -0500901void acpi_resume(void *wake_vec)
Stefan Reinauer7e9771c2009-04-22 08:17:38 +0000902{
Duncan Laurie11290c42012-10-03 19:07:05 -0700903#if CONFIG_HAVE_SMI_HANDLER
Aaron Durbin0a6c20a2013-04-24 22:33:08 -0500904 u32 *gnvs_address = cbmem_find(CBMEM_ID_ACPI_GNVS_PTR);
Duncan Laurie11290c42012-10-03 19:07:05 -0700905
Aaron Durbin0a6c20a2013-04-24 22:33:08 -0500906 /* Restore GNVS pointer in SMM if found */
907 if (gnvs_address && *gnvs_address) {
908 printk(BIOS_DEBUG, "Restore GNVS pointer to 0x%08x\n",
909 *gnvs_address);
910 smm_setup_structures((void *)*gnvs_address, NULL, NULL);
Stefan Reinauercb91e152012-04-03 23:28:22 +0200911 }
Aaron Durbin0a6c20a2013-04-24 22:33:08 -0500912#endif
913
914 /* Call mainboard resume handler first, if defined. */
Kyösti Mälkki134f5042014-12-26 13:29:09 +0200915 mainboard_suspend_resume();
Aaron Durbin0a6c20a2013-04-24 22:33:08 -0500916
917 post_code(POST_OS_RESUME);
918 acpi_jump_to_wakeup(wake_vec);
Stefan Reinauer7e9771c2009-04-22 08:17:38 +0000919}
920
Kyösti Mälkki7a846e72015-01-09 23:55:09 +0200921/* This is filled with acpi_is_wakeup() call early in ramstage. */
922int acpi_slp_type = -1;
Stefan Reinauer688b3852004-01-28 16:56:14 +0000923
Kyösti Mälkki9e94dbf2015-01-08 20:03:18 +0200924#if IS_ENABLED(CONFIG_EARLY_CBMEM_INIT)
925int acpi_get_sleep_type(void)
Kyösti Mälkki134f5042014-12-26 13:29:09 +0200926{
Kyösti Mälkki9e94dbf2015-01-08 20:03:18 +0200927 struct romstage_handoff *handoff;
928
929 handoff = cbmem_find(CBMEM_ID_ROMSTAGE_INFO);
930
931 if (handoff == NULL) {
932 printk(BIOS_DEBUG, "Unknown boot method, assuming normal.\n");
933 return 0;
934 } else if (handoff->s3_resume) {
935 printk(BIOS_DEBUG, "S3 Resume.\n");
936 return 3;
937 } else {
938 printk(BIOS_DEBUG, "Normal boot.\n");
939 return 0;
940 }
Kyösti Mälkki134f5042014-12-26 13:29:09 +0200941}
Kyösti Mälkki9e94dbf2015-01-08 20:03:18 +0200942#endif
Kyösti Mälkki134f5042014-12-26 13:29:09 +0200943
Kyösti Mälkkidb8693b2014-06-19 23:29:07 +0300944static void acpi_handoff_wakeup(void)
945{
Kyösti Mälkki7a846e72015-01-09 23:55:09 +0200946 if (acpi_slp_type < 0)
947 acpi_slp_type = acpi_get_sleep_type();
Kyösti Mälkkidb8693b2014-06-19 23:29:07 +0300948}
949
Kyösti Mälkkicb28f3f2014-01-03 15:15:22 +0200950int acpi_is_wakeup(void)
Rudolf Marek33cafe52009-04-13 18:07:02 +0000951{
Kyösti Mälkkidb8693b2014-06-19 23:29:07 +0300952 acpi_handoff_wakeup();
Tobias Diedrich4e22a3b2010-12-13 22:39:46 +0100953 /* Both resume from S2 and resume from S3 restart at CPU reset */
954 return (acpi_slp_type == 3 || acpi_slp_type == 2);
Rudolf Marek33cafe52009-04-13 18:07:02 +0000955}
956
Kyösti Mälkki4d9b7722014-06-19 19:45:40 +0300957int acpi_is_wakeup_s3(void)
958{
Kyösti Mälkkidb8693b2014-06-19 23:29:07 +0300959 acpi_handoff_wakeup();
Kyösti Mälkki4d9b7722014-06-19 19:45:40 +0300960 return (acpi_slp_type == 3);
961}
962
Kyösti Mälkkicb28f3f2014-01-03 15:15:22 +0200963void acpi_fail_wakeup(void)
964{
965 if (acpi_slp_type == 3 || acpi_slp_type == 2)
966 acpi_slp_type = 0;
967}
968
Kyösti Mälkki7b14f082014-10-16 20:58:47 +0300969void acpi_prepare_resume_backup(void)
970{
971 if (!acpi_s3_resume_allowed())
972 return;
973
974 /* Let's prepare the ACPI S3 Resume area now already, so we can rely on
975 * it being there during reboot time. We don't need the pointer, nor
976 * the result right now. If it fails, ACPI resume will be disabled.
977 */
978
979 if (HIGH_MEMORY_SAVE)
980 cbmem_add(CBMEM_ID_RESUME, HIGH_MEMORY_SAVE);
Kyösti Mälkki7b14f082014-10-16 20:58:47 +0300981}
982
Rudolf Marek33cafe52009-04-13 18:07:02 +0000983static acpi_rsdp_t *valid_rsdp(acpi_rsdp_t *rsdp)
984{
985 if (strncmp((char *)rsdp, RSDP_SIG, sizeof(RSDP_SIG) - 1) != 0)
986 return NULL;
987
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000988 printk(BIOS_DEBUG, "Looking on %p for valid checksum\n", rsdp);
Rudolf Marek33cafe52009-04-13 18:07:02 +0000989
990 if (acpi_checksum((void *)rsdp, 20) != 0)
991 return NULL;
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000992 printk(BIOS_DEBUG, "Checksum 1 passed\n");
Rudolf Marek33cafe52009-04-13 18:07:02 +0000993
994 if ((rsdp->revision > 1) && (acpi_checksum((void *)rsdp,
995 rsdp->length) != 0))
996 return NULL;
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000997 printk(BIOS_DEBUG, "Checksum 2 passed all OK\n");
Rudolf Marek33cafe52009-04-13 18:07:02 +0000998
999 return rsdp;
1000}
1001
1002static acpi_rsdp_t *rsdp;
1003
1004void *acpi_get_wakeup_rsdp(void)
1005{
1006 return rsdp;
1007}
1008
1009void *acpi_find_wakeup_vector(void)
1010{
1011 char *p, *end;
Rudolf Marek33cafe52009-04-13 18:07:02 +00001012 acpi_rsdt_t *rsdt;
1013 acpi_facs_t *facs;
Martin Rothc5f49262012-12-14 19:17:55 -07001014 acpi_fadt_t *fadt = NULL;
Uwe Hermann622824c2010-11-19 15:14:42 +00001015 void *wake_vec;
Rudolf Marek33cafe52009-04-13 18:07:02 +00001016 int i;
1017
1018 rsdp = NULL;
1019
1020 if (!acpi_is_wakeup())
1021 return NULL;
1022
Uwe Hermann622824c2010-11-19 15:14:42 +00001023 printk(BIOS_DEBUG, "Trying to find the wakeup vector...\n");
Rudolf Marek33cafe52009-04-13 18:07:02 +00001024
Uwe Hermann622824c2010-11-19 15:14:42 +00001025 /* Find RSDP. */
1026 for (p = (char *)0xe0000; p < (char *)0xfffff; p += 16) {
1027 if ((rsdp = valid_rsdp((acpi_rsdp_t *)p)))
Rudolf Marek33cafe52009-04-13 18:07:02 +00001028 break;
1029 }
1030
1031 if (rsdp == NULL)
1032 return NULL;
1033
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +00001034 printk(BIOS_DEBUG, "RSDP found at %p\n", rsdp);
Rudolf Marek33cafe52009-04-13 18:07:02 +00001035 rsdt = (acpi_rsdt_t *) rsdp->rsdt_address;
Stefan Reinauer14e22772010-04-27 06:56:47 +00001036
Uwe Hermann622824c2010-11-19 15:14:42 +00001037 end = (char *)rsdt + rsdt->header.length;
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +00001038 printk(BIOS_DEBUG, "RSDT found at %p ends at %p\n", rsdt, end);
Rudolf Marek33cafe52009-04-13 18:07:02 +00001039
Uwe Hermann622824c2010-11-19 15:14:42 +00001040 for (i = 0; ((char *)&rsdt->entry[i]) < end; i++) {
1041 fadt = (acpi_fadt_t *)rsdt->entry[i];
Stefan Reinauercdfe3762009-07-21 22:15:43 +00001042 if (strncmp((char *)fadt, "FACP", 4) == 0)
Rudolf Marek33cafe52009-04-13 18:07:02 +00001043 break;
1044 fadt = NULL;
1045 }
1046
1047 if (fadt == NULL)
1048 return NULL;
1049
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +00001050 printk(BIOS_DEBUG, "FADT found at %p\n", fadt);
Stefan Reinauer69390db2009-05-26 12:33:52 +00001051 facs = (acpi_facs_t *)fadt->firmware_ctrl;
Rudolf Marek33cafe52009-04-13 18:07:02 +00001052
Stefan Reinauer7e9771c2009-04-22 08:17:38 +00001053 if (facs == NULL) {
Uwe Hermann622824c2010-11-19 15:14:42 +00001054 printk(BIOS_DEBUG, "No FACS found, wake up from S3 not "
1055 "possible.\n");
Rudolf Marek33cafe52009-04-13 18:07:02 +00001056 return NULL;
Stefan Reinauer7e9771c2009-04-22 08:17:38 +00001057 }
Rudolf Marek33cafe52009-04-13 18:07:02 +00001058
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +00001059 printk(BIOS_DEBUG, "FACS found at %p\n", facs);
Uwe Hermann622824c2010-11-19 15:14:42 +00001060 wake_vec = (void *)facs->firmware_waking_vector;
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +00001061 printk(BIOS_DEBUG, "OS waking vector is %p\n", wake_vec);
Uwe Hermann622824c2010-11-19 15:14:42 +00001062
Rudolf Marek33cafe52009-04-13 18:07:02 +00001063 return wake_vec;
1064}
1065
Tobias Diedrich4e22a3b2010-12-13 22:39:46 +01001066#if CONFIG_SMP
Rudolf Marek33cafe52009-04-13 18:07:02 +00001067extern char *lowmem_backup;
1068extern char *lowmem_backup_ptr;
1069extern int lowmem_backup_size;
Tobias Diedrich4e22a3b2010-12-13 22:39:46 +01001070#endif
Rudolf Marek33cafe52009-04-13 18:07:02 +00001071
Uwe Hermann622824c2010-11-19 15:14:42 +00001072#define WAKEUP_BASE 0x600
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +00001073
Uwe Hermann622824c2010-11-19 15:14:42 +00001074void (*acpi_do_wakeup)(u32 vector, u32 backup_source, u32 backup_target,
Stefan Reinauer399486e2012-12-06 13:54:29 -08001075 u32 backup_size) asmlinkage = (void *)WAKEUP_BASE;
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +00001076
Aaron Durbina146d582013-02-08 16:56:51 -06001077extern unsigned char __wakeup;
1078extern unsigned int __wakeup_size;
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +00001079
Rudolf Marek33cafe52009-04-13 18:07:02 +00001080void acpi_jump_to_wakeup(void *vector)
1081{
Aaron Durbin8e4a3552013-02-08 17:28:04 -06001082 u32 acpi_backup_memory = 0;
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +00001083
Kyösti Mälkki2ca2afe2014-06-17 15:41:37 +03001084 if (HIGH_MEMORY_SAVE && acpi_s3_resume_allowed()) {
1085 acpi_backup_memory = (u32)cbmem_find(CBMEM_ID_RESUME);
1086
1087 if (!acpi_backup_memory) {
1088 printk(BIOS_WARNING, "ACPI: Backup memory missing. "
1089 "No S3 resume.\n");
1090 return;
1091 }
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +00001092 }
1093
Tobias Diedrich4e22a3b2010-12-13 22:39:46 +01001094#if CONFIG_SMP
Martin Roth7b5f8ef2013-07-08 16:22:10 -06001095 // FIXME: This should go into the ACPI backup memory, too. No pork sausages.
Uwe Hermann622824c2010-11-19 15:14:42 +00001096 /*
1097 * Just restore the SMP trampoline and continue with wakeup on
1098 * assembly level.
1099 */
Rudolf Marek33cafe52009-04-13 18:07:02 +00001100 memcpy(lowmem_backup_ptr, lowmem_backup, lowmem_backup_size);
Tobias Diedrich4e22a3b2010-12-13 22:39:46 +01001101#endif
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +00001102
Uwe Hermann622824c2010-11-19 15:14:42 +00001103 /* Copy wakeup trampoline in place. */
Aaron Durbina146d582013-02-08 16:56:51 -06001104 memcpy((void *)WAKEUP_BASE, &__wakeup, __wakeup_size);
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +00001105
Duncan Lauriecde78012011-10-19 15:32:39 -07001106#if CONFIG_COLLECT_TIMESTAMPS
1107 timestamp_add_now(TS_ACPI_WAKE_JUMP);
1108#endif
1109
Uwe Hermann622824c2010-11-19 15:14:42 +00001110 acpi_do_wakeup((u32)vector, acpi_backup_memory, CONFIG_RAMBASE,
1111 HIGH_MEMORY_SAVE);
Rudolf Marek33cafe52009-04-13 18:07:02 +00001112}
1113#endif
Duncan Laurie11290c42012-10-03 19:07:05 -07001114
1115void acpi_save_gnvs(u32 gnvs_address)
1116{
Duncan Laurie9c07c8f2013-03-22 11:08:39 -07001117 u32 *gnvs = cbmem_add(CBMEM_ID_ACPI_GNVS_PTR, sizeof(*gnvs));
Duncan Laurie11290c42012-10-03 19:07:05 -07001118 if (gnvs)
1119 *gnvs = gnvs_address;
1120}