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
20 #define RSDP_SIG "RSD PTR " /* RSDT Pointer signature */
21 #define RSDP_NAME "RSDP"
23 #define RSDT_NAME "RSDT"
24 #define HPET_NAME "HPET"
25 #define MADT_NAME "APIC"
26 #define MCFG_NAME "MCFG"
27 #define SRAT_NAME "SRAT"
28 #define SLIT_NAME "SLIT"
29 #define SSDT_NAME "SSDT"
31 #define RSDT_TABLE "RSDT "
32 #define HPET_TABLE "AMD64 "
33 #define MCFG_TABLE "MCFG "
34 #define MADT_TABLE "MADT "
35 #define SRAT_TABLE "SRAT "
36 #define SLIT_TABLE "SLIT "
38 #define OEM_ID "CORE "
41 /* ACPI 2.0 table RSDP */
43 typedef struct acpi_rsdp {
44 char signature[8]; /* RSDP signature "RSD PTR" */
45 u8 checksum; /* checksum of the first 20 bytes */
46 char oem_id[6]; /* OEM ID, "LXBIOS" */
47 u8 revision; /* 0 for APCI 1.0, 2 for ACPI 2.0 */
48 u32 rsdt_address; /* physical address of RSDT */
49 u32 length; /* total length of RSDP (including extended part) */
50 u64 xsdt_address; /* physical address of XSDT */
51 u8 ext_checksum; /* chechsum of whole table */
53 } __attribute__((packed)) acpi_rsdp_t;
55 /* Generic Address Container */
57 typedef struct acpi_gen_regaddr {
64 } __attribute__ ((packed)) acpi_addr_t;
66 /* Generic ACPI Header, provided by (almost) all tables */
68 typedef struct acpi_table_header /* ACPI common table header */
70 char signature [4]; /* ACPI signature (4 ASCII characters) */\
71 u32 length; /* Length of table, in bytes, including header */\
72 u8 revision; /* ACPI Specification minor version # */\
73 u8 checksum; /* To make sum of entire table == 0 */\
74 char oem_id [6]; /* OEM identification */\
75 char oem_table_id [8]; /* OEM table identification */\
76 u32 oem_revision; /* OEM revision number */\
77 char asl_compiler_id [4]; /* ASL compiler vendor ID */\
78 u32 asl_compiler_revision; /* ASL compiler revision number */
79 } __attribute__ ((packed)) acpi_header_t;
82 typedef struct acpi_rsdt {
83 struct acpi_table_header header;
84 u32 entry[7+ACPI_SSDTX_NUM+CONFIG_MAX_CPUS]; /* MCONFIG, HPET, FADT, SRAT, SLIT, MADT(APIC), SSDT, SSDTX, and SSDT for CPU pstate*/
85 } __attribute__ ((packed)) acpi_rsdt_t;
88 typedef struct acpi_xsdt {
89 struct acpi_table_header header;
90 u64 entry[6+ACPI_SSDTX_NUM];
91 } __attribute__ ((packed)) acpi_xsdt_t;
94 typedef struct acpi_hpet {
95 struct acpi_table_header header;
97 struct acpi_gen_regaddr addr;
101 } __attribute__ ((packed)) acpi_hpet_t;
103 /* MCFG taken from include/linux/acpi.h */
104 typedef struct acpi_mcfg {
105 struct acpi_table_header header;
107 } __attribute__ ((packed)) acpi_mcfg_t;
109 typedef struct acpi_mcfg_mmconfig {
112 u16 pci_segment_group_number;
116 } __attribute__ ((packed)) acpi_mcfg_mmconfig_t;
120 typedef struct acpi_srat {
121 struct acpi_table_header header;
124 /* followed by static resource allocation structure[n]*/
125 } __attribute__ ((packed)) acpi_srat_t;
128 typedef struct acpi_srat_lapic {
131 u8 proximity_domain_7_0;
133 u32 flags; /* enable bit 0 = 1, other bits reserved to 0 */
135 u8 proximity_domain_31_8[3];
137 } __attribute__ ((packed)) acpi_srat_lapic_t;
139 typedef struct acpi_srat_mem {
142 u32 proximity_domain;
144 u32 base_address_low;
145 u32 base_address_high;
149 u32 flags; /* enable bit 0, hot pluggable bit 1; Non Volatile bit 2, other bits reserved */
151 } __attribute__ ((packed)) acpi_srat_mem_t;
154 typedef struct acpi_slit {
155 struct acpi_table_header header;
156 /* followed by static resource allocation 8+byte[num*num]*/
157 } __attribute__ ((packed)) acpi_slit_t;
161 typedef struct acpi_madt {
162 struct acpi_table_header header;
165 } __attribute__ ((packed)) acpi_madt_t;
167 enum acpi_apic_types {
170 IRQSourceOverride = 2,
173 LApicAddressOverride = 5,
176 PlatformIRQSources = 8
179 typedef struct acpi_madt_lapic {
185 } __attribute__ ((packed)) acpi_madt_lapic_t;
187 typedef struct acpi_madt_lapic_nmi {
193 } __attribute__ ((packed)) acpi_madt_lapic_nmi_t;
196 typedef struct acpi_madt_ioapic {
203 } __attribute__ ((packed)) acpi_madt_ioapic_t;
205 typedef struct acpi_madt_irqoverride {
212 } __attribute__ ((packed)) acpi_madt_irqoverride_t;
216 typedef struct acpi_fadt {
217 struct acpi_table_header header;
221 u8 preferred_pm_profile;
256 struct acpi_gen_regaddr reset_reg;
261 u32 x_firmware_ctl_l;
262 u32 x_firmware_ctl_h;
265 struct acpi_gen_regaddr x_pm1a_evt_blk;
266 struct acpi_gen_regaddr x_pm1b_evt_blk;
267 struct acpi_gen_regaddr x_pm1a_cnt_blk;
268 struct acpi_gen_regaddr x_pm1b_cnt_blk;
269 struct acpi_gen_regaddr x_pm2_cnt_blk;
270 struct acpi_gen_regaddr x_pm_tmr_blk;
271 struct acpi_gen_regaddr x_gpe0_blk;
272 struct acpi_gen_regaddr x_gpe1_blk;
273 } __attribute__ ((packed)) acpi_fadt_t;
276 typedef struct acpi_facs {
279 u32 hardware_signature;
280 u32 firmware_waking_vector;
283 u32 x_firmware_waking_vector_l;
284 u32 x_firmware_waking_vector_h;
287 } __attribute__ ((packed)) acpi_facs_t;
289 /* These are implemented by the target port */
290 unsigned long write_acpi_tables(unsigned long addr);
291 unsigned long acpi_fill_madt(unsigned long current);
292 unsigned long acpi_fill_mcfg(unsigned long current);
293 unsigned long acpi_fill_srat(unsigned long current);
294 unsigned long acpi_fill_slit(unsigned long current);
295 unsigned long acpi_fill_ssdt_generator(unsigned long current, char *oem_table_id);
296 void acpi_create_ssdt_generator(acpi_header_t *ssdt, char *oem_table_id);
297 void acpi_create_fadt(acpi_fadt_t *fadt,acpi_facs_t *facs,void *dsdt);
299 /* These can be used by the target port */
300 u8 acpi_checksum(u8 *table, u32 length);
302 void acpi_add_table(acpi_rsdt_t *rsdt, void *table);
304 int acpi_create_madt_lapic(acpi_madt_lapic_t *lapic, u8 cpu, u8 apic);
305 int acpi_create_madt_ioapic(acpi_madt_ioapic_t *ioapic, u8 id, u32 addr,u32 gsi_base);
306 int acpi_create_madt_irqoverride(acpi_madt_irqoverride_t *irqoverride,
307 u8 bus, u8 source, u32 gsirq, u16 flags);
308 int acpi_create_madt_lapic_nmi(acpi_madt_lapic_nmi_t *lapic_nmi, u8 cpu,
310 void acpi_create_madt(acpi_madt_t *madt);
311 unsigned long acpi_create_madt_lapics(unsigned long current);
312 unsigned long acpi_create_madt_lapic_nmis(unsigned long current, u16 flags, u8 lint);
315 int acpi_create_srat_lapic(acpi_srat_lapic_t *lapic, u8 node, u8 apic);
316 int acpi_create_srat_mem(acpi_srat_mem_t *mem, u8 node, u32 basek,u32 sizek, u32 flags);
317 int acpi_create_mcfg_mmconfig(acpi_mcfg_mmconfig_t *mmconfig, u32 base, u16 seg_nr, u8 start, u8 end);
318 unsigned long acpi_create_srat_lapics(unsigned long current);
319 void acpi_create_srat(acpi_srat_t *srat);
321 void acpi_create_slit(acpi_slit_t *slit);
323 void acpi_create_hpet(acpi_hpet_t *hpet);
325 void acpi_create_mcfg(acpi_mcfg_t *mcfg);
327 void acpi_create_facs(acpi_facs_t *facs);
329 void acpi_write_rsdt(acpi_rsdt_t *rsdt);
330 void acpi_write_rsdp(acpi_rsdp_t *rsdp, acpi_rsdt_t *rsdt);
332 unsigned long acpi_add_ssdt_pstates(acpi_rsdt_t *rsdt, unsigned long current);
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)