2 * coreboot ACPI Support - headers and defines.
4 * written by Stefan Reinauer <stepan@openbios.org>
5 * (C) 2004 SUSE LINUX AG
7 * The ACPI table structs are based on the Linux kernel sources.
8 * ACPI FADT & FACS added by Nick Barker <nick.barker9@btinternet.com>
9 * those parts (C) 2004 Nick Barker
16 #if HAVE_ACPI_TABLES==1
21 /* 0 = S0, 1 = S1 ...*/
22 extern u8 acpi_slp_type;
25 #define RSDP_SIG "RSD PTR " /* RSDT Pointer signature */
26 #define RSDP_NAME "RSDP"
28 #define RSDT_NAME "RSDT"
29 #define HPET_NAME "HPET"
30 #define MADT_NAME "APIC"
31 #define MCFG_NAME "MCFG"
32 #define SRAT_NAME "SRAT"
33 #define SLIT_NAME "SLIT"
34 #define SSDT_NAME "SSDT"
35 #define FACS_NAME "FACS"
36 #define FADT_NAME "FACP"
38 #define RSDT_TABLE "RSDT "
39 #define HPET_TABLE "AMD64 "
40 #define MCFG_TABLE "MCFG "
41 #define MADT_TABLE "MADT "
42 #define SRAT_TABLE "SRAT "
43 #define SLIT_TABLE "SLIT "
45 #define OEM_ID "CORE "
48 /* ACPI 2.0 table RSDP */
50 typedef struct acpi_rsdp {
51 char signature[8]; /* RSDP signature "RSD PTR" */
52 u8 checksum; /* checksum of the first 20 bytes */
53 char oem_id[6]; /* OEM ID, "LXBIOS" */
54 u8 revision; /* 0 for APCI 1.0, 2 for ACPI 2.0 */
55 u32 rsdt_address; /* physical address of RSDT */
56 u32 length; /* total length of RSDP (including extended part) */
57 u64 xsdt_address; /* physical address of XSDT */
58 u8 ext_checksum; /* chechsum of whole table */
60 } __attribute__((packed)) acpi_rsdp_t;
62 /* Generic Address Container */
64 typedef struct acpi_gen_regaddr {
71 } __attribute__ ((packed)) acpi_addr_t;
73 /* Generic ACPI Header, provided by (almost) all tables */
75 typedef struct acpi_table_header /* ACPI common table header */
77 char signature [4]; /* ACPI signature (4 ASCII characters) */\
78 u32 length; /* Length of table, in bytes, including header */\
79 u8 revision; /* ACPI Specification minor version # */\
80 u8 checksum; /* To make sum of entire table == 0 */\
81 char oem_id [6]; /* OEM identification */\
82 char oem_table_id [8]; /* OEM table identification */\
83 u32 oem_revision; /* OEM revision number */\
84 char asl_compiler_id [4]; /* ASL compiler vendor ID */\
85 u32 asl_compiler_revision; /* ASL compiler revision number */
86 } __attribute__ ((packed)) acpi_header_t;
89 typedef struct acpi_rsdt {
90 struct acpi_table_header header;
91 u32 entry[7+ACPI_SSDTX_NUM+CONFIG_MAX_CPUS]; /* MCONFIG, HPET, FADT, SRAT, SLIT, MADT(APIC), SSDT, SSDTX, and SSDT for CPU pstate*/
92 } __attribute__ ((packed)) acpi_rsdt_t;
95 typedef struct acpi_xsdt {
96 struct acpi_table_header header;
97 u64 entry[6+ACPI_SSDTX_NUM];
98 } __attribute__ ((packed)) acpi_xsdt_t;
101 typedef struct acpi_hpet {
102 struct acpi_table_header header;
104 struct acpi_gen_regaddr addr;
108 } __attribute__ ((packed)) acpi_hpet_t;
110 /* MCFG taken from include/linux/acpi.h */
111 typedef struct acpi_mcfg {
112 struct acpi_table_header header;
114 } __attribute__ ((packed)) acpi_mcfg_t;
116 typedef struct acpi_mcfg_mmconfig {
119 u16 pci_segment_group_number;
123 } __attribute__ ((packed)) acpi_mcfg_mmconfig_t;
127 typedef struct acpi_srat {
128 struct acpi_table_header header;
131 /* followed by static resource allocation structure[n]*/
132 } __attribute__ ((packed)) acpi_srat_t;
135 typedef struct acpi_srat_lapic {
138 u8 proximity_domain_7_0;
140 u32 flags; /* enable bit 0 = 1, other bits reserved to 0 */
142 u8 proximity_domain_31_8[3];
144 } __attribute__ ((packed)) acpi_srat_lapic_t;
146 typedef struct acpi_srat_mem {
149 u32 proximity_domain;
151 u32 base_address_low;
152 u32 base_address_high;
156 u32 flags; /* enable bit 0, hot pluggable bit 1; Non Volatile bit 2, other bits reserved */
158 } __attribute__ ((packed)) acpi_srat_mem_t;
161 typedef struct acpi_slit {
162 struct acpi_table_header header;
163 /* followed by static resource allocation 8+byte[num*num]*/
164 } __attribute__ ((packed)) acpi_slit_t;
168 typedef struct acpi_madt {
169 struct acpi_table_header header;
172 } __attribute__ ((packed)) acpi_madt_t;
174 enum acpi_apic_types {
177 IRQSourceOverride = 2,
180 LApicAddressOverride = 5,
183 PlatformIRQSources = 8
186 typedef struct acpi_madt_lapic {
192 } __attribute__ ((packed)) acpi_madt_lapic_t;
194 typedef struct acpi_madt_lapic_nmi {
200 } __attribute__ ((packed)) acpi_madt_lapic_nmi_t;
203 typedef struct acpi_madt_ioapic {
210 } __attribute__ ((packed)) acpi_madt_ioapic_t;
212 typedef struct acpi_madt_irqoverride {
219 } __attribute__ ((packed)) acpi_madt_irqoverride_t;
223 typedef struct acpi_fadt {
224 struct acpi_table_header header;
228 u8 preferred_pm_profile;
263 struct acpi_gen_regaddr reset_reg;
268 u32 x_firmware_ctl_l;
269 u32 x_firmware_ctl_h;
272 struct acpi_gen_regaddr x_pm1a_evt_blk;
273 struct acpi_gen_regaddr x_pm1b_evt_blk;
274 struct acpi_gen_regaddr x_pm1a_cnt_blk;
275 struct acpi_gen_regaddr x_pm1b_cnt_blk;
276 struct acpi_gen_regaddr x_pm2_cnt_blk;
277 struct acpi_gen_regaddr x_pm_tmr_blk;
278 struct acpi_gen_regaddr x_gpe0_blk;
279 struct acpi_gen_regaddr x_gpe1_blk;
280 } __attribute__ ((packed)) acpi_fadt_t;
282 #define ACPI_FADT_WBINVD (1 << 0)
283 #define ACPI_FADT_WBINVD_FLUSH (1 << 1)
284 #define ACPI_FADT_C1_SUPPORTED (1 << 2)
285 #define ACPI_FADT_C2_MP_SUPPORTED (1 << 3)
286 #define ACPI_FADT_POWER_BUTTON (1 << 4)
287 #define ACPI_FADT_SLEEP_BUTTON (1 << 5)
288 #define ACPI_FADT_FIXED_RTC (1 << 6)
289 #define ACPI_FADT_S4_RTC_WAKE (1 << 7)
290 #define ACPI_FADT_32BIT_TIMER (1 << 8)
291 #define ACPI_FADT_DOCKING_SUPPORTED (1 << 9)
292 #define ACPI_FADT_RESET_REGISTER (1 << 10)
293 #define ACPI_FADT_SEALED_CASE (1 << 11)
294 #define ACPI_FADT_HEADLESS (1 << 12)
295 #define ACPI_FADT_SLEEP_TYPE (1 << 13)
296 #define ACPI_FADT_PCI_EXPRESS_WAKE (1 << 14)
297 #define ACPI_FADT_PLATFORM_CLOCK (1 << 15)
298 #define ACPI_FADT_S4_RTC_VALID (1 << 16)
299 #define ACPI_FADT_REMOTE_POWER_ON (1 << 17)
300 #define ACPI_FADT_APIC_CLUSTER (1 << 18)
301 #define ACPI_FADT_APIC_PHYSICAL (1 << 19)
303 enum acpi_preferred_pm_profiles {
314 typedef struct acpi_facs {
317 u32 hardware_signature;
318 u32 firmware_waking_vector;
321 u32 x_firmware_waking_vector_l;
322 u32 x_firmware_waking_vector_h;
325 } __attribute__ ((packed)) acpi_facs_t;
327 /* These are implemented by the target port */
328 unsigned long write_acpi_tables(unsigned long addr);
329 unsigned long acpi_fill_madt(unsigned long current);
330 unsigned long acpi_fill_mcfg(unsigned long current);
331 unsigned long acpi_fill_srat(unsigned long current);
332 unsigned long acpi_fill_slit(unsigned long current);
333 unsigned long acpi_fill_ssdt_generator(unsigned long current, char *oem_table_id);
334 void acpi_create_ssdt_generator(acpi_header_t *ssdt, char *oem_table_id);
335 void acpi_create_fadt(acpi_fadt_t *fadt,acpi_facs_t *facs,void *dsdt);
337 /* These can be used by the target port */
338 u8 acpi_checksum(u8 *table, u32 length);
340 void acpi_add_table(acpi_rsdt_t *rsdt, void *table);
342 int acpi_create_madt_lapic(acpi_madt_lapic_t *lapic, u8 cpu, u8 apic);
343 int acpi_create_madt_ioapic(acpi_madt_ioapic_t *ioapic, u8 id, u32 addr,u32 gsi_base);
344 int acpi_create_madt_irqoverride(acpi_madt_irqoverride_t *irqoverride,
345 u8 bus, u8 source, u32 gsirq, u16 flags);
346 int acpi_create_madt_lapic_nmi(acpi_madt_lapic_nmi_t *lapic_nmi, u8 cpu,
348 void acpi_create_madt(acpi_madt_t *madt);
349 unsigned long acpi_create_madt_lapics(unsigned long current);
350 unsigned long acpi_create_madt_lapic_nmis(unsigned long current, u16 flags, u8 lint);
353 int acpi_create_srat_lapic(acpi_srat_lapic_t *lapic, u8 node, u8 apic);
354 int acpi_create_srat_mem(acpi_srat_mem_t *mem, u8 node, u32 basek,u32 sizek, u32 flags);
355 int acpi_create_mcfg_mmconfig(acpi_mcfg_mmconfig_t *mmconfig, u32 base, u16 seg_nr, u8 start, u8 end);
356 unsigned long acpi_create_srat_lapics(unsigned long current);
357 void acpi_create_srat(acpi_srat_t *srat);
359 void acpi_create_slit(acpi_slit_t *slit);
361 void acpi_create_hpet(acpi_hpet_t *hpet);
363 void acpi_create_mcfg(acpi_mcfg_t *mcfg);
365 void acpi_create_facs(acpi_facs_t *facs);
367 void acpi_write_rsdt(acpi_rsdt_t *rsdt);
368 void acpi_write_rsdp(acpi_rsdp_t *rsdp, acpi_rsdt_t *rsdt);
371 void suspend_resume(void);
372 void *acpi_find_wakeup_vector(void);
373 void *acpi_get_wakeup_rsdp(void);
374 void acpi_jmp_to_realm_wakeup(u32 linear_addr);
375 void acpi_jump_to_wakeup(void *wakeup_addr);
378 unsigned long acpi_add_ssdt_pstates(acpi_rsdt_t *rsdt, unsigned long current);
380 #define ACPI_WRITE_MADT_IOAPIC(dev,id) \
382 struct resource *res; \
383 res = find_resource(dev, PCI_BASE_ADDRESS_0); \
385 current += acpi_create_madt_ioapic( \
386 (acpi_madt_ioapic_t *)current, \
387 id, res->base, gsi_base); \
391 #define IO_APIC_ADDR 0xfec00000UL
393 #else // HAVE_ACPI_TABLES
395 #define write_acpi_tables(start) (start)