2 * coreboot ACPI Support - headers and defines.
4 * written by Stefan Reinauer <stepan@coresystems.de>
5 * Copyright (C) 2004 SUSE LINUX AG
6 * Copyright (C) 2004 Nick Barker
7 * Copyright (C) 2008-2009 coresystems GmbH
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; version 2 of
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
28 #if CONFIG_GENERATE_ACPI_TABLES==1
32 #define RSDP_SIG "RSD PTR " /* RSDT Pointer signature */
33 #define ACPI_TABLE_CREATOR "COREBOOT"
34 #define OEM_ID "CORE "
37 /* ACPI 3.0 table RSDP */
39 typedef struct acpi_rsdp {
40 char signature[8]; /* RSDP signature "RSD PTR" */
41 u8 checksum; /* checksum of the first 20 bytes */
42 char oem_id[6]; /* OEM ID, "LXBIOS" */
43 u8 revision; /* 0 for APCI 1.0, 2 for ACPI 2.0/3.0 */
44 u32 rsdt_address; /* physical address of RSDT */
45 u32 length; /* total length of RSDP (including extended part) */
46 u64 xsdt_address; /* physical address of XSDT */
47 u8 ext_checksum; /* chechsum of whole table */
49 } __attribute__((packed)) acpi_rsdp_t;
51 /* Generic Address Container */
53 typedef struct acpi_gen_regaddr {
60 } __attribute__ ((packed)) acpi_addr_t;
62 #define ACPI_ADDRESS_SPACE_MEMORY 0
63 #define ACPI_ADDRESS_SPACE_IO 1
64 #define ACPI_ADDRESS_SPACE_PCI 2
65 #define ACPI_ADDRESS_SPACE_FIXED 0x7f
68 /* Generic ACPI Header, provided by (almost) all tables */
70 typedef struct acpi_table_header /* ACPI common table header */
72 char signature [4]; /* ACPI signature (4 ASCII characters) */\
73 u32 length; /* Length of table, in bytes, including header */\
74 u8 revision; /* ACPI Specification minor version # */\
75 u8 checksum; /* To make sum of entire table == 0 */\
76 char oem_id [6]; /* OEM identification */\
77 char oem_table_id [8]; /* OEM table identification */\
78 u32 oem_revision; /* OEM revision number */\
79 char asl_compiler_id [4]; /* ASL compiler vendor ID */\
80 u32 asl_compiler_revision; /* ASL compiler revision number */
81 } __attribute__ ((packed)) acpi_header_t;
83 /* A maximum number of 32 ACPI tables ought to be enough for now */
84 #define MAX_ACPI_TABLES 32
87 typedef struct acpi_rsdt {
88 struct acpi_table_header header;
89 u32 entry[MAX_ACPI_TABLES];
90 } __attribute__ ((packed)) acpi_rsdt_t;
93 typedef struct acpi_xsdt {
94 struct acpi_table_header header;
95 u64 entry[MAX_ACPI_TABLES];
96 } __attribute__ ((packed)) acpi_xsdt_t;
99 typedef struct acpi_hpet {
100 struct acpi_table_header header;
102 struct acpi_gen_regaddr addr;
106 } __attribute__ ((packed)) acpi_hpet_t;
109 typedef struct acpi_mcfg {
110 struct acpi_table_header header;
112 } __attribute__ ((packed)) acpi_mcfg_t;
114 typedef struct acpi_mcfg_mmconfig {
117 u16 pci_segment_group_number;
121 } __attribute__ ((packed)) acpi_mcfg_mmconfig_t;
125 typedef struct acpi_srat {
126 struct acpi_table_header header;
129 /* followed by static resource allocation structure[n]*/
130 } __attribute__ ((packed)) acpi_srat_t;
133 typedef struct acpi_srat_lapic {
136 u8 proximity_domain_7_0;
138 u32 flags; /* enable bit 0 = 1, other bits reserved to 0 */
140 u8 proximity_domain_31_8[3];
142 } __attribute__ ((packed)) acpi_srat_lapic_t;
144 typedef struct acpi_srat_mem {
147 u32 proximity_domain;
149 u32 base_address_low;
150 u32 base_address_high;
154 u32 flags; /* enable bit 0, hot pluggable bit 1; Non Volatile bit 2, other bits reserved */
156 } __attribute__ ((packed)) acpi_srat_mem_t;
159 typedef struct acpi_slit {
160 struct acpi_table_header header;
161 /* followed by static resource allocation 8+byte[num*num]*/
162 } __attribute__ ((packed)) acpi_slit_t;
166 typedef struct acpi_madt {
167 struct acpi_table_header header;
170 } __attribute__ ((packed)) acpi_madt_t;
172 enum acpi_apic_types {
175 IRQSourceOverride = 2,
178 LApicAddressOverride = 5,
181 PlatformIRQSources = 8
184 typedef struct acpi_madt_lapic {
190 } __attribute__ ((packed)) acpi_madt_lapic_t;
192 typedef struct acpi_madt_lapic_nmi {
198 } __attribute__ ((packed)) acpi_madt_lapic_nmi_t;
201 typedef struct acpi_madt_ioapic {
208 } __attribute__ ((packed)) acpi_madt_ioapic_t;
210 typedef struct acpi_madt_irqoverride {
217 } __attribute__ ((packed)) acpi_madt_irqoverride_t;
221 typedef struct acpi_fadt {
222 struct acpi_table_header header;
226 u8 preferred_pm_profile;
261 struct acpi_gen_regaddr reset_reg;
266 u32 x_firmware_ctl_l;
267 u32 x_firmware_ctl_h;
270 struct acpi_gen_regaddr x_pm1a_evt_blk;
271 struct acpi_gen_regaddr x_pm1b_evt_blk;
272 struct acpi_gen_regaddr x_pm1a_cnt_blk;
273 struct acpi_gen_regaddr x_pm1b_cnt_blk;
274 struct acpi_gen_regaddr x_pm2_cnt_blk;
275 struct acpi_gen_regaddr x_pm_tmr_blk;
276 struct acpi_gen_regaddr x_gpe0_blk;
277 struct acpi_gen_regaddr x_gpe1_blk;
278 } __attribute__ ((packed)) acpi_fadt_t;
281 // FADT Feature Flags
283 #define ACPI_FADT_WBINVD (1 << 0)
284 #define ACPI_FADT_WBINVD_FLUSH (1 << 1)
285 #define ACPI_FADT_C1_SUPPORTED (1 << 2)
286 #define ACPI_FADT_C2_MP_SUPPORTED (1 << 3)
287 #define ACPI_FADT_POWER_BUTTON (1 << 4)
288 #define ACPI_FADT_SLEEP_BUTTON (1 << 5)
289 #define ACPI_FADT_FIXED_RTC (1 << 6)
290 #define ACPI_FADT_S4_RTC_WAKE (1 << 7)
291 #define ACPI_FADT_32BIT_TIMER (1 << 8)
292 #define ACPI_FADT_DOCKING_SUPPORTED (1 << 9)
293 #define ACPI_FADT_RESET_REGISTER (1 << 10)
294 #define ACPI_FADT_SEALED_CASE (1 << 11)
295 #define ACPI_FADT_HEADLESS (1 << 12)
296 #define ACPI_FADT_SLEEP_TYPE (1 << 13)
297 #define ACPI_FADT_PCI_EXPRESS_WAKE (1 << 14)
298 #define ACPI_FADT_PLATFORM_CLOCK (1 << 15)
299 #define ACPI_FADT_S4_RTC_VALID (1 << 16)
300 #define ACPI_FADT_REMOTE_POWER_ON (1 << 17)
301 #define ACPI_FADT_APIC_CLUSTER (1 << 18)
302 #define ACPI_FADT_APIC_PHYSICAL (1 << 19)
305 // FADT Boot Architecture Flags
307 #define ACPI_FADT_LEGACY_DEVICES (1 << 0)
308 #define ACPI_FADT_8042 (1 << 1)
309 #define ACPI_FADT_VGA_NOT_PRESENT (1 << 2)
310 #define ACPI_FADT_MSI_NOT_SUPPORTED (1 << 3)
311 #define ACPI_FADT_NO_PCIE_ASPM_CONTROL (1 << 4)
314 // FADT Preferred Power Management Profile
316 enum acpi_preferred_pm_profiles {
321 PM_ENTERPRISE_SERVER = 4,
324 PM_PERFORMANCE_SERVER = 7
328 typedef struct acpi_facs {
331 u32 hardware_signature;
332 u32 firmware_waking_vector;
335 u32 x_firmware_waking_vector_l;
336 u32 x_firmware_waking_vector_h;
339 } __attribute__ ((packed)) acpi_facs_t;
344 #define ACPI_FACS_S4BIOS_F (1 << 0)
346 typedef struct acpi_ecdt {
347 struct acpi_table_header header;
348 struct acpi_gen_regaddr ec_control;
349 struct acpi_gen_regaddr ec_data;
353 } __attribute__ ((packed)) acpi_ecdt_t;
356 /* These are implemented by the target port */
357 unsigned long write_acpi_tables(unsigned long addr);
358 unsigned long acpi_fill_madt(unsigned long current);
359 unsigned long acpi_fill_mcfg(unsigned long current);
360 unsigned long acpi_fill_srat(unsigned long current);
361 unsigned long acpi_fill_slit(unsigned long current);
362 unsigned long acpi_fill_ssdt_generator(unsigned long current, const char *oem_table_id);
363 void acpi_create_ssdt_generator(acpi_header_t *ssdt, const char *oem_table_id);
364 void acpi_create_fadt(acpi_fadt_t *fadt,acpi_facs_t *facs, void *dsdt);
366 /* These can be used by the target port */
367 u8 acpi_checksum(u8 *table, u32 length);
369 void acpi_add_table(acpi_rsdp_t *rsdp, void *table);
372 int acpi_create_madt_lapic(acpi_madt_lapic_t *lapic, u8 cpu, u8 apic);
373 int acpi_create_madt_ioapic(acpi_madt_ioapic_t *ioapic, u8 id, u32 addr,u32 gsi_base);
374 int acpi_create_madt_irqoverride(acpi_madt_irqoverride_t *irqoverride,
375 u8 bus, u8 source, u32 gsirq, u16 flags);
376 int acpi_create_madt_lapic_nmi(acpi_madt_lapic_nmi_t *lapic_nmi, u8 cpu,
378 void acpi_create_madt(acpi_madt_t *madt);
379 unsigned long acpi_create_madt_lapics(unsigned long current);
380 unsigned long acpi_create_madt_lapic_nmis(unsigned long current, u16 flags, u8 lint);
383 int acpi_create_srat_lapic(acpi_srat_lapic_t *lapic, u8 node, u8 apic);
384 int acpi_create_srat_mem(acpi_srat_mem_t *mem, u8 node, u32 basek,u32 sizek, u32 flags);
385 int acpi_create_mcfg_mmconfig(acpi_mcfg_mmconfig_t *mmconfig, u32 base, u16 seg_nr, u8 start, u8 end);
386 unsigned long acpi_create_srat_lapics(unsigned long current);
387 void acpi_create_srat(acpi_srat_t *srat);
389 void acpi_create_slit(acpi_slit_t *slit);
391 void acpi_create_hpet(acpi_hpet_t *hpet);
393 void acpi_create_mcfg(acpi_mcfg_t *mcfg);
395 void acpi_create_facs(acpi_facs_t *facs);
397 void acpi_write_rsdt(acpi_rsdt_t *rsdt);
398 void acpi_write_xsdt(acpi_xsdt_t *xsdt);
399 void acpi_write_rsdp(acpi_rsdp_t *rsdp, acpi_rsdt_t *rsdt, acpi_xsdt_t *xsdt);
401 #if CONFIG_HAVE_ACPI_RESUME
402 /* 0 = S0, 1 = S1 ...*/
403 extern u8 acpi_slp_type;
405 void suspend_resume(void);
406 void *acpi_find_wakeup_vector(void);
407 void *acpi_get_wakeup_rsdp(void);
408 void acpi_jmp_to_realm_wakeup(u32 linear_addr) __attribute__((regparm(0)));
409 void acpi_jump_to_wakeup(void *wakeup_addr);
411 int acpi_get_sleep_type(void);
415 unsigned long acpi_add_ssdt_pstates(acpi_rsdp_t *rsdp, unsigned long current);
417 #define ACPI_WRITE_MADT_IOAPIC(dev,id) \
419 struct resource *res; \
420 res = find_resource(dev, PCI_BASE_ADDRESS_0); \
422 current += acpi_create_madt_ioapic( \
423 (acpi_madt_ioapic_t *)current, \
424 id, res->base, gsi_base); \
428 #else // CONFIG_GENERATE_ACPI_TABLES
430 #define write_acpi_tables(start) (start)