2 * This file is part of the coreboot project.
4 * Copyright (C) 2004 SUSE LINUX AG
5 * Copyright (C) 2004 Nick Barker
6 * Copyright (C) 2008-2009 coresystems GmbH
7 * (Written by Stefan Reinauer <stepan@coresystems.de>)
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 2 of the License.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 * coreboot ACPI Support - headers and defines.
30 #if CONFIG_GENERATE_ACPI_TABLES==1
34 #define RSDP_SIG "RSD PTR " /* RSDT Pointer signature */
35 #define ACPI_TABLE_CREATOR "COREBOOT"
36 #define OEM_ID "CORE "
39 /* ACPI 3.0 table RSDP */
41 typedef struct acpi_rsdp {
42 char signature[8]; /* RSDP signature "RSD PTR" */
43 u8 checksum; /* checksum of the first 20 bytes */
44 char oem_id[6]; /* OEM ID, "LXBIOS" */
45 u8 revision; /* 0 for ACPI 1.0, 2 for ACPI 2.0/3.0 */
46 u32 rsdt_address; /* physical address of RSDT */
47 u32 length; /* total length of RSDP (including extended part) */
48 u64 xsdt_address; /* physical address of XSDT */
49 u8 ext_checksum; /* chechsum of whole table */
51 } __attribute__((packed)) acpi_rsdp_t;
53 /* Generic Address Container */
55 typedef struct acpi_gen_regaddr {
62 } __attribute__ ((packed)) acpi_addr_t;
64 #define ACPI_ADDRESS_SPACE_MEMORY 0
65 #define ACPI_ADDRESS_SPACE_IO 1
66 #define ACPI_ADDRESS_SPACE_PCI 2
67 #define ACPI_ADDRESS_SPACE_FIXED 0x7f
70 /* Generic ACPI Header, provided by (almost) all tables */
72 typedef struct acpi_table_header /* ACPI common table header */
74 char signature [4]; /* ACPI signature (4 ASCII characters) */\
75 u32 length; /* Length of table, in bytes, including header */\
76 u8 revision; /* ACPI Specification minor version # */\
77 u8 checksum; /* To make sum of entire table == 0 */\
78 char oem_id [6]; /* OEM identification */\
79 char oem_table_id [8]; /* OEM table identification */\
80 u32 oem_revision; /* OEM revision number */\
81 char asl_compiler_id [4]; /* ASL compiler vendor ID */\
82 u32 asl_compiler_revision; /* ASL compiler revision number */
83 } __attribute__ ((packed)) acpi_header_t;
85 /* A maximum number of 32 ACPI tables ought to be enough for now */
86 #define MAX_ACPI_TABLES 32
89 typedef struct acpi_rsdt {
90 struct acpi_table_header header;
91 u32 entry[MAX_ACPI_TABLES];
92 } __attribute__ ((packed)) acpi_rsdt_t;
95 typedef struct acpi_xsdt {
96 struct acpi_table_header header;
97 u64 entry[MAX_ACPI_TABLES];
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;
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;
283 // FADT Feature Flags
285 #define ACPI_FADT_WBINVD (1 << 0)
286 #define ACPI_FADT_WBINVD_FLUSH (1 << 1)
287 #define ACPI_FADT_C1_SUPPORTED (1 << 2)
288 #define ACPI_FADT_C2_MP_SUPPORTED (1 << 3)
289 #define ACPI_FADT_POWER_BUTTON (1 << 4)
290 #define ACPI_FADT_SLEEP_BUTTON (1 << 5)
291 #define ACPI_FADT_FIXED_RTC (1 << 6)
292 #define ACPI_FADT_S4_RTC_WAKE (1 << 7)
293 #define ACPI_FADT_32BIT_TIMER (1 << 8)
294 #define ACPI_FADT_DOCKING_SUPPORTED (1 << 9)
295 #define ACPI_FADT_RESET_REGISTER (1 << 10)
296 #define ACPI_FADT_SEALED_CASE (1 << 11)
297 #define ACPI_FADT_HEADLESS (1 << 12)
298 #define ACPI_FADT_SLEEP_TYPE (1 << 13)
299 #define ACPI_FADT_PCI_EXPRESS_WAKE (1 << 14)
300 #define ACPI_FADT_PLATFORM_CLOCK (1 << 15)
301 #define ACPI_FADT_S4_RTC_VALID (1 << 16)
302 #define ACPI_FADT_REMOTE_POWER_ON (1 << 17)
303 #define ACPI_FADT_APIC_CLUSTER (1 << 18)
304 #define ACPI_FADT_APIC_PHYSICAL (1 << 19)
307 // FADT Boot Architecture Flags
309 #define ACPI_FADT_LEGACY_DEVICES (1 << 0)
310 #define ACPI_FADT_8042 (1 << 1)
311 #define ACPI_FADT_VGA_NOT_PRESENT (1 << 2)
312 #define ACPI_FADT_MSI_NOT_SUPPORTED (1 << 3)
313 #define ACPI_FADT_NO_PCIE_ASPM_CONTROL (1 << 4)
316 // FADT Preferred Power Management Profile
318 enum acpi_preferred_pm_profiles {
323 PM_ENTERPRISE_SERVER = 4,
326 PM_PERFORMANCE_SERVER = 7
330 typedef struct acpi_facs {
333 u32 hardware_signature;
334 u32 firmware_waking_vector;
337 u32 x_firmware_waking_vector_l;
338 u32 x_firmware_waking_vector_h;
341 } __attribute__ ((packed)) acpi_facs_t;
346 #define ACPI_FACS_S4BIOS_F (1 << 0)
348 typedef struct acpi_ecdt {
349 struct acpi_table_header header;
350 struct acpi_gen_regaddr ec_control;
351 struct acpi_gen_regaddr ec_data;
355 } __attribute__ ((packed)) acpi_ecdt_t;
358 /* These are implemented by the target port or north/southbridge*/
359 unsigned long write_acpi_tables(unsigned long addr);
360 unsigned long acpi_fill_madt(unsigned long current);
361 unsigned long acpi_fill_mcfg(unsigned long current);
362 unsigned long acpi_fill_srat(unsigned long current);
363 unsigned long acpi_fill_slit(unsigned long current);
364 unsigned long acpi_fill_ssdt_generator(unsigned long current, const char *oem_table_id);
365 void acpi_create_ssdt_generator(acpi_header_t *ssdt, const char *oem_table_id);
366 void acpi_create_fadt(acpi_fadt_t *fadt,acpi_facs_t *facs, void *dsdt);
368 void update_ssdt(void* ssdt);
369 void update_ssdtx(void* ssdtx, int i);
371 /* These can be used by the target port */
372 u8 acpi_checksum(u8 *table, u32 length);
374 void acpi_add_table(acpi_rsdp_t *rsdp, void *table);
377 int acpi_create_madt_lapic(acpi_madt_lapic_t *lapic, u8 cpu, u8 apic);
378 int acpi_create_madt_ioapic(acpi_madt_ioapic_t *ioapic, u8 id, u32 addr,u32 gsi_base);
379 int acpi_create_madt_irqoverride(acpi_madt_irqoverride_t *irqoverride,
380 u8 bus, u8 source, u32 gsirq, u16 flags);
381 int acpi_create_madt_lapic_nmi(acpi_madt_lapic_nmi_t *lapic_nmi, u8 cpu,
383 void acpi_create_madt(acpi_madt_t *madt);
384 unsigned long acpi_create_madt_lapics(unsigned long current);
385 unsigned long acpi_create_madt_lapic_nmis(unsigned long current, u16 flags, u8 lint);
388 int acpi_create_srat_lapic(acpi_srat_lapic_t *lapic, u8 node, u8 apic);
389 int acpi_create_srat_mem(acpi_srat_mem_t *mem, u8 node, u32 basek,u32 sizek, u32 flags);
390 int acpi_create_mcfg_mmconfig(acpi_mcfg_mmconfig_t *mmconfig, u32 base, u16 seg_nr, u8 start, u8 end);
391 unsigned long acpi_create_srat_lapics(unsigned long current);
392 void acpi_create_srat(acpi_srat_t *srat);
394 void acpi_create_slit(acpi_slit_t *slit);
396 void acpi_create_hpet(acpi_hpet_t *hpet);
398 void acpi_create_mcfg(acpi_mcfg_t *mcfg);
400 void acpi_create_facs(acpi_facs_t *facs);
402 #if CONFIG_HAVE_ACPI_SLIC
403 unsigned long acpi_create_slic(unsigned long current);
406 void acpi_write_rsdt(acpi_rsdt_t *rsdt);
407 void acpi_write_xsdt(acpi_xsdt_t *xsdt);
408 void acpi_write_rsdp(acpi_rsdp_t *rsdp, acpi_rsdt_t *rsdt, acpi_xsdt_t *xsdt);
410 #if CONFIG_HAVE_ACPI_RESUME
411 /* 0 = S0, 1 = S1 ...*/
412 extern u8 acpi_slp_type;
414 void suspend_resume(void);
415 void *acpi_find_wakeup_vector(void);
416 void *acpi_get_wakeup_rsdp(void);
417 void acpi_jump_to_wakeup(void *wakeup_addr);
419 int acpi_get_sleep_type(void);
423 /* northbridge/amd/amdfam10/amdfam10_acpi.c */
424 unsigned long acpi_add_ssdt_pstates(acpi_rsdp_t *rsdp, unsigned long current);
425 /* cpu/intel/speedstep/acpi.c */
426 void generate_cpu_entries(void);
428 #define ACPI_WRITE_MADT_IOAPIC(dev,id) \
430 struct resource *res; \
431 res = find_resource(dev, PCI_BASE_ADDRESS_0); \
433 current += acpi_create_madt_ioapic( \
434 (acpi_madt_ioapic_t *)current, \
435 id, res->base, gsi_base); \
439 #else // CONFIG_GENERATE_ACPI_TABLES
441 #define write_acpi_tables(start) (start)