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.
10 /* ACPI FADT & FACS added by Nick Barker <nick.barker9@btinternet.com>
11 * those parts (C) 2004 Nick Barker
18 #if HAVE_ACPI_TABLES==1
21 typedef unsigned long long u64;
23 #define RSDP_SIG "RSD PTR " /* RSDT Pointer signature */
24 #define RSDP_NAME "RSDP"
26 #define RSDT_NAME "RSDT"
27 #define HPET_NAME "HPET"
28 #define MADT_NAME "APIC"
29 #define MCFG_NAME "MCFG"
30 #define SRAT_NAME "SRAT"
31 #define SLIT_NAME "SLIT"
32 #define SSDT_NAME "SSDT"
34 #define RSDT_TABLE "RSDT "
35 #define HPET_TABLE "AMD64 "
36 #define MCFG_TABLE "MCFG "
37 #define MADT_TABLE "MADT "
38 #define SRAT_TABLE "SRAT "
39 #define SLIT_TABLE "SLIT "
41 #define OEM_ID "CORE "
44 /* ACPI 2.0 table RSDP */
46 typedef struct acpi_rsdp {
47 char signature[8]; /* RSDP signature "RSD PTR" */
48 u8 checksum; /* checksum of the first 20 bytes */
49 char oem_id[6]; /* OEM ID, "LXBIOS" */
50 u8 revision; /* 0 for APCI 1.0, 2 for ACPI 2.0 */
51 u32 rsdt_address; /* physical address of RSDT */
52 u32 length; /* total length of RSDP (including extended part) */
53 u64 xsdt_address; /* physical address of XSDT */
54 u8 ext_checksum; /* chechsum of whole table */
56 } __attribute__((packed)) acpi_rsdp_t;
58 /* Generic Address Container */
60 typedef struct acpi_gen_regaddr {
67 } __attribute__ ((packed)) acpi_addr_t;
69 /* Generic ACPI Header, provided by (almost) all tables */
71 typedef struct acpi_table_header /* ACPI common table header */
73 char signature [4]; /* ACPI signature (4 ASCII characters) */\
74 u32 length; /* Length of table, in bytes, including header */\
75 u8 revision; /* ACPI Specification minor version # */\
76 u8 checksum; /* To make sum of entire table == 0 */\
77 char oem_id [6]; /* OEM identification */\
78 char oem_table_id [8]; /* OEM table identification */\
79 u32 oem_revision; /* OEM revision number */\
80 char asl_compiler_id [4]; /* ASL compiler vendor ID */\
81 u32 asl_compiler_revision; /* ASL compiler revision number */
82 } __attribute__ ((packed)) acpi_header_t;
85 typedef struct acpi_rsdt {
86 struct acpi_table_header header;
87 u32 entry[7+ACPI_SSDTX_NUM+CONFIG_MAX_CPUS]; /* MCONFIG, HPET, FADT, SRAT, SLIT, MADT(APIC), SSDT, SSDTX, and SSDT for CPU pstate*/
88 } __attribute__ ((packed)) acpi_rsdt_t;
91 typedef struct acpi_xsdt {
92 struct acpi_table_header header;
93 u64 entry[6+ACPI_SSDTX_NUM];
94 } __attribute__ ((packed)) acpi_xsdt_t;
97 typedef struct acpi_hpet {
98 struct acpi_table_header header;
100 struct acpi_gen_regaddr addr;
104 } __attribute__ ((packed)) acpi_hpet_t;
106 /* MCFG taken from include/linux/acpi.h */
107 typedef struct acpi_mcfg {
108 struct acpi_table_header header;
110 } __attribute__ ((packed)) acpi_mcfg_t;
112 typedef struct acpi_mcfg_mmconfig {
115 u16 pci_segment_group_number;
119 } __attribute__ ((packed)) acpi_mcfg_mmconfig_t;
123 typedef struct acpi_srat {
124 struct acpi_table_header header;
127 /* followed by static resource allocation structure[n]*/
128 } __attribute__ ((packed)) acpi_srat_t;
131 typedef struct acpi_srat_lapic {
134 u8 proximity_domain_7_0;
136 u32 flags; /* enable bit 0 = 1, other bits reserved to 0 */
138 u8 proximity_domain_31_8[3];
140 } __attribute__ ((packed)) acpi_srat_lapic_t;
142 typedef struct acpi_srat_mem {
145 u32 proximity_domain;
147 u32 base_address_low;
148 u32 base_address_high;
152 u32 flags; /* enable bit 0, hot pluggable bit 1; Non Volatile bit 2, other bits reserved */
154 } __attribute__ ((packed)) acpi_srat_mem_t;
157 typedef struct acpi_slit {
158 struct acpi_table_header header;
159 /* followed by static resource allocation 8+byte[num*num]*/
160 } __attribute__ ((packed)) acpi_slit_t;
164 typedef struct acpi_madt {
165 struct acpi_table_header header;
168 } __attribute__ ((packed)) acpi_madt_t;
170 enum acpi_apic_types {
173 IRQSourceOverride = 2,
176 LApicAddressOverride = 5,
179 PlatformIRQSources = 8
182 typedef struct acpi_madt_lapic {
188 } __attribute__ ((packed)) acpi_madt_lapic_t;
190 typedef struct acpi_madt_lapic_nmi {
196 } __attribute__ ((packed)) acpi_madt_lapic_nmi_t;
199 typedef struct acpi_madt_ioapic {
206 } __attribute__ ((packed)) acpi_madt_ioapic_t;
208 typedef struct acpi_madt_irqoverride {
215 } __attribute__ ((packed)) acpi_madt_irqoverride_t;
219 typedef struct acpi_fadt {
220 struct acpi_table_header header;
224 u8 preferred_pm_profile;
259 struct acpi_gen_regaddr reset_reg;
264 u32 x_firmware_ctl_l;
265 u32 x_firmware_ctl_h;
268 struct acpi_gen_regaddr x_pm1a_evt_blk;
269 struct acpi_gen_regaddr x_pm1b_evt_blk;
270 struct acpi_gen_regaddr x_pm1a_cnt_blk;
271 struct acpi_gen_regaddr x_pm1b_cnt_blk;
272 struct acpi_gen_regaddr x_pm2_cnt_blk;
273 struct acpi_gen_regaddr x_pm_tmr_blk;
274 struct acpi_gen_regaddr x_gpe0_blk;
275 struct acpi_gen_regaddr x_gpe1_blk;
276 } __attribute__ ((packed)) acpi_fadt_t;
279 typedef struct acpi_facs {
282 u32 hardware_signature;
283 u32 firmware_waking_vector;
286 u32 x_firmware_waking_vector_l;
287 u32 x_firmware_waking_vector_h;
290 } __attribute__ ((packed)) acpi_facs_t;
292 /* These are implemented by the target port */
293 unsigned long write_acpi_tables(unsigned long addr);
294 unsigned long acpi_fill_madt(unsigned long current);
295 unsigned long acpi_fill_mcfg(unsigned long current);
296 unsigned long acpi_fill_srat(unsigned long current);
297 unsigned long acpi_fill_ssdt_generator(unsigned long current, char *oem_table_id);
298 void acpi_create_ssdt_generator(acpi_header_t *ssdt, char *oem_table_id);
299 void acpi_create_fadt(acpi_fadt_t *fadt,acpi_facs_t *facs,void *dsdt);
301 /* These can be used by the target port */
302 u8 acpi_checksum(u8 *table, u32 length);
304 void acpi_add_table(acpi_rsdt_t *rsdt, void *table);
306 int acpi_create_madt_lapic(acpi_madt_lapic_t *lapic, u8 cpu, u8 apic);
307 int acpi_create_madt_ioapic(acpi_madt_ioapic_t *ioapic, u8 id, u32 addr,u32 gsi_base);
308 int acpi_create_madt_irqoverride(acpi_madt_irqoverride_t *irqoverride,
309 u8 bus, u8 source, u32 gsirq, u16 flags);
310 int acpi_create_madt_lapic_nmi(acpi_madt_lapic_nmi_t *lapic_nmi, u8 cpu,
312 void acpi_create_madt(acpi_madt_t *madt);
313 unsigned long acpi_create_madt_lapics(unsigned long current);
314 unsigned long acpi_create_madt_lapic_nmis(unsigned long current, u16 flags, u8 lint);
317 int acpi_create_srat_lapic(acpi_srat_lapic_t *lapic, u8 node, u8 apic);
318 int acpi_create_srat_mem(acpi_srat_mem_t *mem, u8 node, u32 basek,u32 sizek, u32 flags);
319 int acpi_create_mcfg_mmconfig(acpi_mcfg_mmconfig_t *mmconfig, u32 base, u16 seg_nr, u8 start, u8 end);
320 unsigned long acpi_create_srat_lapics(unsigned long current);
321 void acpi_create_srat(acpi_srat_t *srat);
323 void acpi_create_slit(acpi_slit_t *slit);
325 void acpi_create_hpet(acpi_hpet_t *hpet);
327 void acpi_create_mcfg(acpi_mcfg_t *mcfg);
329 void acpi_create_facs(acpi_facs_t *facs);
331 void acpi_write_rsdt(acpi_rsdt_t *rsdt);
332 void acpi_write_rsdp(acpi_rsdp_t *rsdp, acpi_rsdt_t *rsdt);
334 #define ACPI_WRITE_MADT_IOAPIC(dev,id) \
336 struct resource *res; \
337 res = find_resource(dev, PCI_BASE_ADDRESS_0); \
339 current += acpi_create_madt_ioapic( \
340 (acpi_madt_ioapic_t *)current, \
341 id, res->base, gsi_base); \
345 #define IO_APIC_ADDR 0xfec00000UL
347 #else // HAVE_ACPI_TABLES
349 #define write_acpi_tables(start) (start)