2 * Initial LinuxBIOS 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.
9 * ACPI FADT & FACS added by Nick Barker <nick.barker9@btinternet.com>
10 * those parts (C) 2004 Nick Barker
12 * ACPI SRAT support added in 2005.9 by yhlu
13 * Copyright 2005 ADVANCED MICRO DEVICES, INC. All Rights Reserved.
21 #if HAVE_ACPI_TABLES==1
23 typedef unsigned char u8;
24 typedef unsigned short u16;
25 typedef unsigned int u32;
26 typedef unsigned long long u64;
28 #define RSDP_SIG "RSD PTR " /* RSDT Pointer signature */
29 #define RSDP_NAME "RSDP"
31 #define RSDT_NAME "RSDT"
32 #define HPET_NAME "HPET"
33 #define MADT_NAME "APIC"
34 #define SRAT_NAME "SRAT"
36 #define RSDT_TABLE "RSDT "
37 #define HPET_TABLE "AMD64 "
38 #define MADT_TABLE "MADT "
39 #define SRAT_TABLE "SRAT "
41 #define OEM_ID "LXBIOS"
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 (incl. 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[5+ACPI_SSDTX_NUM]; /* HPET, FADT, SRAT, MADT(APIC), SSDT, SSDTX */
88 } __attribute__ ((packed)) acpi_rsdt_t;
91 typedef struct acpi_xsdt {
92 struct acpi_table_header header;
93 u64 entry[5+ACPI_SSDTX_NUM];
94 } __attribute__ ((packed)) acpi_xsdt_t;
98 typedef struct acpi_hpet {
99 struct acpi_table_header header;
101 struct acpi_gen_regaddr addr;
105 } __attribute__ ((packed)) acpi_hpet_t;
108 typedef struct acpi_srat {
109 struct acpi_table_header header;
112 /* followed by static resource allocation structure[n]*/
113 } __attribute__ ((packed)) acpi_srat_t;
116 typedef struct acpi_srat_lapic {
119 u8 proximity_domain_7_0;
121 u32 flags; /* enable bit 0 = 1, other bits reserved to 0 */
123 u8 proximity_domain_31_8[3];
125 } __attribute__ ((packed)) acpi_srat_lapic_t;
127 typedef struct acpi_srat_mem {
130 u32 proximity_domain;
132 u32 base_address_low;
133 u32 base_address_high;
137 u32 flags; /* enable bit 0, hot pluggable bit 1; Non Volatile bit 2, other bits reserved */
139 } __attribute__ ((packed)) acpi_srat_mem_t;
144 typedef struct acpi_madt {
145 struct acpi_table_header header;
148 } __attribute__ ((packed)) acpi_madt_t;
150 enum acpi_apic_types {
153 IRQSourceOverride = 2,
156 LApicAddressOverride = 5,
159 PlatformIRQSources = 8
162 typedef struct acpi_madt_lapic {
168 } __attribute__ ((packed)) acpi_madt_lapic_t;
170 typedef struct acpi_madt_lapic_nmi {
176 } __attribute__ ((packed)) acpi_madt_lapic_nmi_t;
179 typedef struct acpi_madt_ioapic {
186 } __attribute__ ((packed)) acpi_madt_ioapic_t;
188 typedef struct acpi_madt_irqoverride {
195 } __attribute__ ((packed)) acpi_madt_irqoverride_t;
199 typedef struct acpi_fadt {
200 struct acpi_table_header header;
204 u8 preferred_pm_profile;
239 struct acpi_gen_regaddr reset_reg;
244 u32 x_firmware_ctl_l;
245 u32 x_firmware_ctl_h;
248 struct acpi_gen_regaddr x_pm1a_evt_blk;
249 struct acpi_gen_regaddr x_pm1b_evt_blk;
250 struct acpi_gen_regaddr x_pm1a_cnt_blk;
251 struct acpi_gen_regaddr x_pm1b_cnt_blk;
252 struct acpi_gen_regaddr x_pm2_cnt_blk;
253 struct acpi_gen_regaddr x_pm_tmr_blk;
254 struct acpi_gen_regaddr x_gpe0_blk;
255 struct acpi_gen_regaddr x_gpe1_blk;
256 } __attribute__ ((packed)) acpi_fadt_t;
259 typedef struct acpi_facs {
262 u32 hardware_signature;
263 u32 firmware_waking_vector;
266 u32 x_firmware_waking_vector_l;
267 u32 x_firmware_waking_vector_h;
270 } __attribute__ ((packed)) acpi_facs_t;
272 /* These are implemented by the target port */
273 unsigned long write_acpi_tables(unsigned long addr);
274 unsigned long acpi_fill_madt(unsigned long current);
275 unsigned long acpi_fill_srat(unsigned long current);
276 void acpi_create_fadt(acpi_fadt_t *fadt,acpi_facs_t *facs,void *dsdt);
278 /* These can be used by the target port */
279 u8 acpi_checksum(u8 *table, u32 length);
281 void acpi_add_table(acpi_rsdt_t *rsdt, void *table);
283 int acpi_create_madt_lapic(acpi_madt_lapic_t *lapic, u8 cpu, u8 apic);
284 int acpi_create_madt_ioapic(acpi_madt_ioapic_t *ioapic, u8 id, u32 addr,u32 gsi_base);
285 int acpi_create_madt_irqoverride(acpi_madt_irqoverride_t *irqoverride,
286 u8 bus, u8 source, u32 gsirq, u16 flags);
287 int acpi_create_madt_lapic_nmi(acpi_madt_lapic_nmi_t *lapic_nmi, u8 cpu,
289 void acpi_create_madt(acpi_madt_t *madt);
290 unsigned long acpi_create_madt_lapics(unsigned long current);
291 unsigned long acpi_create_madt_lapic_nmis(unsigned long current, u16 flags, u8 lint);
294 int acpi_create_srat_lapic(acpi_srat_lapic_t *lapic, u8 node, u8 apic);
295 int acpi_create_srat_mem(acpi_srat_mem_t *mem, u8 node, u32 basek,u32 sizek, u32 flags);
296 unsigned long acpi_create_srat_lapics(unsigned long current);
297 void acpi_create_srat(acpi_srat_t *srat);
299 void acpi_create_hpet(acpi_hpet_t *hpet);
301 void acpi_create_facs(acpi_facs_t *facs);
303 void acpi_write_rsdt(acpi_rsdt_t *rsdt);
304 void acpi_write_rsdp(acpi_rsdp_t *rsdp, acpi_rsdt_t *rsdt);
306 #define ACPI_WRITE_MADT_IOAPIC(dev,id) \
308 struct resource *res; \
309 res = find_resource(dev, PCI_BASE_ADDRESS_0); \
311 current += acpi_create_madt_ioapic( \
312 (acpi_madt_ioapic_t *)current, \
313 id, res->base, gsi_base); \
317 #define IO_APIC_ADDR 0xfec00000UL
319 #else // HAVE_ACPI_TABLES
321 #define write_acpi_tables(start) (start)