2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
5 Desc: AROS Generic ACPI Definitions.
8 #ifndef __AROS_ACPI_H__
9 #define __AROS_ACPI_H__
11 #include <exec/libraries.h>
12 #include <exec/lists.h>
13 #include <exec/semaphores.h>
14 #include <exec/interrupts.h>
15 #include <utility/hooks.h>
17 /********** ACPI DEFINITIONS ****************/
20 * Actually a reverse of AROS_MAKE_ID().
21 * Reverse because ACPI signatures appear to be stored in bigendian format.
23 #define ACPI_MAKE_ID(a, b, c, d) (((ULONG) (d)<<24) | ((ULONG) (c)<<16) | \
24 ((ULONG) (b)<<8) | ((ULONG) (a)))
26 #define ACPI_ID_ALL 0xFFFFFFFF
28 /* ACPI 2.0 Generic Address Structure (GAS) */
30 struct GENERIC_ACPI_ADDR
32 unsigned char address_space_id
; /* Address space where struct or register exists. */
33 unsigned char register_bit_width
; /* Size in bits of given register */
34 unsigned char register_bit_offset
; /* Bit offset within the register */
35 unsigned char size
; /* Acces size (see below) */
36 UQUAD address
; /* 64-bit address of struct or register */
37 } __attribute__ ((packed
));
40 #define ACPI_SPACE_MEM 0
41 #define ACPI_SPACE_IO 1
42 #define ACPI_SPACE_PCI 2
43 #define ACPI_SPACE_EMBEDDED 3
44 #define ACPI_SPACE_SMBUS 4
45 #define ACPI_SPACE_FIXED 0x7F
46 #define ACPI_SPACE_OEM 0xC0
49 #define ACPI_SIZE_UNDEFINED 0 /* Specified by bit offset and width */
50 #define ACPI_SIZE_BYTE 1
51 #define ACPI_SIZE_WORD 2
52 #define ACPI_SIZE_DWORD 3
53 #define ACPI_SIZE_QUAD 4
55 #define ACPI_PCI_OFFSET(addr) (unsigned short)((addr) & 0x0FFFF)
56 #define ACPI_PCI_FUNC(addr) (unsigned short)(((addr) >> 16) & 0x0FFFF)
57 #define ACPI_PCI_DEV(addr) (unsigned short)(((addr) >> 32) & 0x0FFFF)
59 struct ACPI_TABLE_DEF_HEADER
/* ACPI common table header */
61 unsigned int signature
; /* ACPI signature (4 ASCII characters) */
62 unsigned int length
; /* Length of table, in bytes, including header */
63 unsigned char revision
; /* ACPI Specification minor version # */
64 unsigned char checksum
; /* To make sum of entire table == 0 */
65 char oem_id
[6]; /* OEM identification */
66 char oem_table_id
[8]; /* OEM table identification */
67 unsigned int oem_revision
; /* OEM revision number */
68 char asl_compiler_id
[4]; /* ASL compiler vendor ID */
69 unsigned int asl_compiler_revision
; /* ASL compiler revision number */
76 ACPI_IRQ_PIC_8259
= 0,
82 /* Root System Description Pointer "RSDP" structure */
83 struct ACPI_TABLE_TYPE_RSDP
86 unsigned char checksum
;
88 unsigned char revision
;
89 unsigned int rsdt_address
;
90 /* The following fields are present only if revision >= 2 */
93 unsigned char ext_checksum
;
94 unsigned char reserved
[3];
97 struct ACPI_TABLE_DEF_ENTRY_HEADER
100 unsigned char length
;
103 #define ACPI_ENTRY_TYPE_ALL -1
105 struct ACPI_TABLE_TYPE_RSDT
/* Root System Description Table "RSDT" structures */
107 struct ACPI_TABLE_DEF_HEADER header
;
108 unsigned int entry
[8];
111 struct ACPI_TABLE_TYPE_XSDT
/* Extended System Description Table "XSDT" structures */
113 struct ACPI_TABLE_DEF_HEADER header
;
115 } __attribute__ ((packed
));
117 struct ACPI_TABLE_TYPE_FADT
/* Fixed ACPI Description Table "FADT" structures */
119 struct ACPI_TABLE_DEF_HEADER header
;
120 unsigned int facs_addr
;
121 unsigned int dsdt_addr
;
122 unsigned char reserved0
; /* ACPI 1.0: interrupt model. Actually never used. */
123 unsigned char pm_profile
; /* ACPI >= 2.0: preferred system profile, see below */
124 unsigned short sci_int
;
125 unsigned int smi_cmd
;
126 unsigned char acpi_enable
;
127 unsigned char acpi_disable
;
128 unsigned char s4bios_req
;
129 unsigned char pstate_cnt
;
130 unsigned int pm1a_evt_blk
;
131 unsigned int pm1b_evt_blk
;
132 unsigned int pm1a_cnt_blk
;
133 unsigned int pm1b_cnt_blk
;
134 unsigned int pm2_cnt_blk
;
135 unsigned int pm_tmr_blk
;
136 unsigned int gpe0_blk
;
137 unsigned int gpe1_blk
;
138 unsigned char pm1_evt_len
;
139 unsigned char pm1_cnt_len
;
140 unsigned char pm2_cnt_len
;
141 unsigned char pm_tmr_len
;
142 unsigned char gpe0_blk_len
;
143 unsigned char gpe1_blk_len
;
144 unsigned char gpe1_base
;
145 unsigned char cst_cnt
;
146 unsigned short p_lvl2_lat
;
147 unsigned short p_lvl3_lat
;
148 unsigned short flush_size
; /* Obsolete leftover from ACPI v1.0 */
149 unsigned short flush_stride
; /* Obsolete leftover from ACPI v1.0 */
150 unsigned char duty_offset
;
151 unsigned char duty_width
;
152 unsigned char day_alarm
;
153 unsigned char mon_alarm
;
154 unsigned char century
;
155 unsigned short pc_arch
; /* ACPI >= 2.0: IA-PC architecture flags, see below */
156 unsigned char reserved1
;
157 unsigned int flags
; /* Fixed feature flags, see below */
158 /* The following is present in ACPI >= 2.0 */
159 struct GENERIC_ACPI_ADDR reset_reg
;
160 unsigned char reset_value
;
161 unsigned char reserved2
[3];
162 unsigned long long x_firmware_ctrl
;
163 unsigned long long x_dsdt
;
164 struct GENERIC_ACPI_ADDR x_pm1a_evt_blk
;
165 struct GENERIC_ACPI_ADDR x_pm1b_evt_blk
;
166 struct GENERIC_ACPI_ADDR x_pm1a_cnt_blk
;
167 struct GENERIC_ACPI_ADDR x_pm1b_cnt_blk
;
168 struct GENERIC_ACPI_ADDR x_pm2_cnt_blk
;
169 struct GENERIC_ACPI_ADDR x_pm_tmr_blk
;
170 struct GENERIC_ACPI_ADDR x_gpe0_blk
;
171 struct GENERIC_ACPI_ADDR x_gpe1_blk
;
172 } __attribute__ ((packed
));
174 /* Preferred system profiles */
175 #define FACP_PROFILE_UNSPECIFIED 0
176 #define FACP_PROFILE_DESKTOP 1
177 #define FACP_PROFILE_MOBILE 2
178 #define FACP_PROFILE_WORKSTATION 3
179 #define FACP_PROFILE_ENTERPRIZE 4
180 #define FACP_PROFILE_SOHO 5
181 #define FACP_PROFILE_APPLIANCE 6
182 #define FACP_PROFILE_PERFORMANCE 7
184 /* IA-PC architecture flags */
185 #define FACP_PC_LEGACY (1 << 0)
186 #define FACP_PC_8042 (1 << 1)
187 #define FACP_PC_NO_VGA (1 << 2)
188 #define FACP_PC_NO_MSI (1 << 3)
189 #define FACP_PCIE_ASPM (1 << 4)
191 /* Fixed feature flags */
192 #define FACP_FF_WBINVD (1 << 0)
193 #define FACP_FF_WBINVD_FLUSH (1 << 1)
194 #define FACP_FF_PROC_C1 (1 << 2)
195 #define FACP_FF_P_LVL2_UP (1 << 3)
196 #define FACP_FF_PWR_BUTTON (1 << 4)
197 #define FACP_FF_SLP_BUTTON (1 << 5)
198 #define FACP_FF_FIX_RTC (1 << 6)
199 #define FACP_FF_RTC_S4 (1 << 7)
200 #define FACP_FF_TMR_VAL_EXT (1 << 8)
201 #define FACP_FF_DCK_CAP (1 << 9)
202 #define FACP_FF_RESET_REG_SUP (1 << 10)
203 #define FACP_FF_SEALED_CASE (1 << 11)
204 #define FACP_FF_HEADLESS (1 << 12)
205 #define FACP_FF_CPU_SW_SLP (1 << 13)
206 #define FACP_FF_PCI_EXP_WAK (1 << 14)
207 #define FACP_FF_PLATFORM_CLOCK (1 << 15)
208 #define FACP_FF_S4_RTC_STS_VALID (1 << 16)
209 #define FACP_FF_REMOTE_PWRON (1 << 17)
210 #define FACP_FF_APIC_CLUSTER (1 << 18)
211 #define FACP_FF_APIC_PHYS_DEST (1 << 19)
213 struct ACPI_TABLE_TYPE_MADT
/* Multiple APIC Description Table "MADT" structures */
215 struct ACPI_TABLE_DEF_HEADER header
;
216 unsigned int lapic_address
;
219 unsigned int pcat_compat
:1;
220 unsigned int reserved
:31;
222 struct ACPI_TABLE_DEF_ENTRY_HEADER entries
[0];
229 ACPI_MADT_INT_SRC_OVR
,
232 ACPI_MADT_LAPIC_ADDR_OVR
,
235 ACPI_MADT_PLAT_INT_SRC
,
237 ACPI_MADT_X2APIC_NMI
,
238 ACPI_MADT_ENTRY_COUNT
243 UWORD polarity
:2; /* See below */
244 UWORD trigger
:2; /* See below */
248 /* Polarity and trigger mode values */
249 #define INTF_POLARITY_BUS 0 /* Bus default */
250 #define INTF_POLARITY_HIGH 1 /* Active high */
251 #define INTF_POLARITY_LOW 3 /* Active low */
252 #define INTF_TRIGGER_BUS 0 /* Bus default */
253 #define INTF_TRIGGER_EDGE 1
254 #define INTF_TRIGGER_LEVEL 3
256 struct ACPI_TABLE_TYPE_LAPIC
258 struct ACPI_TABLE_DEF_ENTRY_HEADER header
;
259 unsigned char acpi_id
;
263 unsigned int enabled
:1;
264 unsigned int reserved
:31;
268 struct ACPI_TABLE_TYPE_IOAPIC
270 struct ACPI_TABLE_DEF_ENTRY_HEADER header
;
272 unsigned char reserved
;
273 unsigned int address
;
274 unsigned int global_irq_base
;
277 struct ACPI_TABLE_TYPE_INT_SRCOVR
279 struct ACPI_TABLE_DEF_ENTRY_HEADER header
;
281 unsigned char bus_irq
;
282 unsigned int global_irq
;
283 ACPI_INT_FLAGS flags
;
286 struct ACPI_TABLE_TYPE_LAPIC_NMI_SRC
288 struct ACPI_TABLE_DEF_ENTRY_HEADER header
;
289 ACPI_INT_FLAGS flags
;
290 unsigned int global_irq
;
293 struct ACPI_TABLE_TYPE_LAPIC_NMI
295 struct ACPI_TABLE_DEF_ENTRY_HEADER header
;
296 unsigned char acpi_id
;
297 ACPI_INT_FLAGS flags
;
299 } __attribute__ ((packed
));
301 #define ACPI_ID_BROADCAST 0xFF
303 struct ACPI_TABLE_TYPE_LAPIC_ADDROVR
305 struct ACPI_TABLE_DEF_ENTRY_HEADER header
;
306 unsigned char reserved
[2];
308 } __attribute__ ((packed
));
310 struct ACPI_TABLE_TYPE_IOSAPIC
312 struct ACPI_TABLE_DEF_ENTRY_HEADER header
;
314 unsigned char reserved
;
315 unsigned int global_irq_base
;
319 struct ACPI_TABLE_TYPE_LSAPIC
321 struct ACPI_TABLE_DEF_ENTRY_HEADER header
;
322 unsigned char acpi_id
;
325 unsigned char reserved
[3];
327 unsigned int enabled
:1;
328 unsigned int reserved
:31;
332 struct ACPI_TABLE_TYPE_PLAT_INTSRC
334 struct ACPI_TABLE_DEF_ENTRY_HEADER header
;
335 ACPI_INT_FLAGS flags
;
336 unsigned char type
; /* See acpi_interrupt_type */
339 unsigned char iosapic_vector
;
340 unsigned int global_irq
;
341 unsigned int srcflags
; /* See below */
344 /* Interrupt types */
347 ACPI_INTERRUPT_PMI
= 1,
353 /* Interrupt source flags */
354 #define ACPI_CPEI_PROC_OVERRIDE (1 << 0)
356 struct ACPI_TABLE_TYPE_X2APIC
358 struct ACPI_TABLE_DEF_ENTRY_HEADER header
;
359 /* 2 bytes of padding here */
362 unsigned int acpi_uid
;
365 #define ACPI_X2APIC_ENABLED (1 << 0)
367 struct ACPI_TABLE_TYPE_X2APIC_NMI
369 struct ACPI_TABLE_DEF_ENTRY_HEADER header
;
370 ACPI_INT_FLAGS flags
;
371 unsigned int acpi_uid
;
375 #define ACPI_UID_BROADCAST 0xFFFFFFFF
377 struct ACPI_TABLE_TYPE_HPET
379 struct ACPI_TABLE_DEF_HEADER header
;
381 struct GENERIC_ACPI_ADDR addr
;
382 unsigned char number
;
384 unsigned char page_protect
;
385 } __attribute__ ((packed
));
388 #define HPET_HW_REV_MASK 0x000000FF
389 #define HPET_NUM_COMPARATORS_MASK 0x00001F00
390 #define HPET_NUM_COMPARATORS_SHIFT 8
391 #define HPET_COUNTER_SIZE 0x00002000
392 #define HPET_LEGACY_REPLACEMENT 0x00008000
393 #define HPET_PCI_VENDOR_MASK 0xFFFF0000
394 #define HPET_PCI_VENDOR_SHIFT 16
396 /* page_protect components */
397 #define HPET_PAGE_PROTECT_MASK 0x0F
398 #define HPET_OEM_ATTR_MASK 0xF0
399 #define HPET_OEM_ATTR_SHIFT 4
401 #define HPET_PAGE_NONE 0
402 #define HPET_PAGE_4K 1
403 #define HPET_PAGE_64K 2
406 System Resource Affinity Table (SRAT) [ see http://www.microsoft.com/hwdev/design/srat.htm ]
409 struct ACPI_TABLE_TYPE_SRAT
411 struct ACPI_TABLE_DEF_HEADER header
;
412 unsigned int table_revision
;
416 enum ACPI_SRAT_ENTRY_IDS
418 ACPI_SRAT_PROCESSOR_AFFINITY
= 0,
419 ACPI_SRAT_MEMORY_AFFINITY
,
420 ACPI_SRAT_ENTRY_COUNT
423 struct ACPI_TABLE_AFFIN_PROCESSOR
425 struct ACPI_TABLE_DEF_ENTRY_HEADER header
;
426 unsigned char proximity_domain
;
427 unsigned char apic_id
;
430 unsigned int enabled
:1;
431 unsigned int reserved
:31;
433 unsigned char lsapic_eid
;
434 unsigned char reserved
[7];
437 struct ACPI_TABLE_AFFIN_MEMORY
439 struct ACPI_TABLE_DEF_ENTRY_HEADER header
;
440 unsigned char proximity_domain
;
441 unsigned char reserved1
[5];
442 unsigned int base_addr_lo
;
443 unsigned int base_addr_hi
;
444 unsigned int length_lo
;
445 unsigned int length_hi
;
446 unsigned int memory_type
; /* See acpi_address_range_id */
449 unsigned int enabled
:1;
450 unsigned int hot_pluggable
:1;
451 unsigned int reserved
:30;
456 enum acpi_address_range_id
458 ACPI_ADDRESS_RANGE_MEMORY
= 1,
459 ACPI_ADDRESS_RANGE_RESERVED
= 2,
460 ACPI_ADDRESS_RANGE_ACPI
= 3,
461 ACPI_ADDRESS_RANGE_NVS
= 4,
462 ACPI_ADDRESS_RANGE_COUNT
466 System Locality Information Table (SLIT) [ see http://devresource.hp.com/devresource/docs/techpapers/ia64/slit.pdf ]
469 struct ACPI_TABLE_TYPE_SLIT
471 struct ACPI_TABLE_DEF_HEADER header
;
473 unsigned char entry
[1]; /* real size = localities^2 */
476 struct ACPI_TABLE_TYPE_SBST
/* Smart Battery Description Table (SBST) */
478 struct ACPI_TABLE_DEF_HEADER header
;
479 unsigned int warning
; /* Warn user */
480 unsigned int low
; /* Critical sleep */
481 unsigned int critical
; /* Critical shutdown */
484 struct ACPI_TABLE_TYPE_ECDT
/* Embedded Controller Boot Resources Table (ECDT) */
486 struct ACPI_TABLE_DEF_HEADER header
;
487 struct GENERIC_ACPI_ADDR ec_control
;
488 struct GENERIC_ACPI_ADDR ec_data
;
490 unsigned char gpe_bit
;
495 * acpi.resource base.
496 * For a casual user it's actually black box. Use API to access the data.
497 * These pointers are provided for diagnostics purposes only.
501 struct Library ACPIB_LibNode
;
503 struct Interrupt ACPIB_ResetHandler
;
505 struct ACPI_TABLE_TYPE_RSDP
*ACPIB_RSDP_Addr
; /* Supervisor-only!!! */
506 struct ACPI_TABLE_DEF_HEADER
*ACPIB_SDT_Addr
; /* Raw XSDT or RSDT pointer */
507 int ACPIB_SDT_Count
; /* These two are private. Do not use! */
508 struct ACPI_TABLE_DEF_HEADER
**ACPIB_SDT_Entry
;
509 char ACPI_OEM_ID
[6]; /* Cached from RSDP */
510 unsigned char ACPI_Revision
;
512 APTR ACPIB_ACPI_Data
; /* Base address of acpi data block */
513 APTR ACPIB_ACPI_Data_End
;
514 APTR ACPIB_ACPI_NVM
; /* Base address of acpi data block */
521 #endif /* __AROS_ACPI_H__ */