xref: /minix3/minix/kernel/arch/i386/acpi.h (revision 433d6423c39e34ec4b79c950597bb2d236f886be)
1*433d6423SLionel Sambuc #ifndef __ACPI_H__
2*433d6423SLionel Sambuc #define __ACPI_H__
3*433d6423SLionel Sambuc 
4*433d6423SLionel Sambuc #include "kernel/kernel.h"
5*433d6423SLionel Sambuc 
6*433d6423SLionel Sambuc /* ACPI root system description pointer */
7*433d6423SLionel Sambuc struct acpi_rsdp {
8*433d6423SLionel Sambuc 	char	signature[8]; /* must be "RSD PTR " */
9*433d6423SLionel Sambuc 	u8_t	checksum;
10*433d6423SLionel Sambuc 	char	oemid[6];
11*433d6423SLionel Sambuc 	u8_t	revision;
12*433d6423SLionel Sambuc 	u32_t	rsdt_addr;
13*433d6423SLionel Sambuc 	u32_t	length;
14*433d6423SLionel Sambuc };
15*433d6423SLionel Sambuc 
16*433d6423SLionel Sambuc #define ACPI_SDT_SIGNATURE_LEN	4
17*433d6423SLionel Sambuc 
18*433d6423SLionel Sambuc #define ACPI_SDT_SIGNATURE(name)	#name
19*433d6423SLionel Sambuc 
20*433d6423SLionel Sambuc /* header common to all system description tables */
21*433d6423SLionel Sambuc struct acpi_sdt_header {
22*433d6423SLionel Sambuc 	char	signature[ACPI_SDT_SIGNATURE_LEN];
23*433d6423SLionel Sambuc 	u32_t	length;
24*433d6423SLionel Sambuc 	u8_t	revision;
25*433d6423SLionel Sambuc 	u8_t	checksum;
26*433d6423SLionel Sambuc 	char	oemid[6];
27*433d6423SLionel Sambuc 	char	oem_table_id[8];
28*433d6423SLionel Sambuc 	u32_t	oem_revision;
29*433d6423SLionel Sambuc 	u32_t	creator_id;
30*433d6423SLionel Sambuc 	u32_t	creator_revision;
31*433d6423SLionel Sambuc };
32*433d6423SLionel Sambuc 
33*433d6423SLionel Sambuc struct acpi_generic_address {
34*433d6423SLionel Sambuc 	u8_t address_space_id;
35*433d6423SLionel Sambuc 	u8_t register_bit_width;
36*433d6423SLionel Sambuc 	u8_t register_bit_offset;
37*433d6423SLionel Sambuc 	u8_t access_size;
38*433d6423SLionel Sambuc 	u64_t address;
39*433d6423SLionel Sambuc };
40*433d6423SLionel Sambuc 
41*433d6423SLionel Sambuc struct acpi_fadt_header
42*433d6423SLionel Sambuc {
43*433d6423SLionel Sambuc 	struct acpi_sdt_header hdr;
44*433d6423SLionel Sambuc 	u32_t facs;
45*433d6423SLionel Sambuc 	u32_t dsdt;
46*433d6423SLionel Sambuc 	u8_t model;
47*433d6423SLionel Sambuc 	u8_t preferred_pm_profile;
48*433d6423SLionel Sambuc 	u16_t sci_int;
49*433d6423SLionel Sambuc 	u32_t smi_cmd;
50*433d6423SLionel Sambuc 	u8_t acpi_enable;
51*433d6423SLionel Sambuc 	u8_t acpi_disable;
52*433d6423SLionel Sambuc 	u8_t s4bios_req;
53*433d6423SLionel Sambuc 	u8_t pstate_cnt;
54*433d6423SLionel Sambuc 	u32_t pm1a_evt_blk;
55*433d6423SLionel Sambuc 	u32_t pm1b_evt_blk;
56*433d6423SLionel Sambuc 	u32_t pm1a_cnt_blk;
57*433d6423SLionel Sambuc 	u32_t pm1b_cnt_blk;
58*433d6423SLionel Sambuc 	u32_t pm2_cnt_blk;
59*433d6423SLionel Sambuc 	u32_t pm_tmr_blk;
60*433d6423SLionel Sambuc 	u32_t gpe0_blk;
61*433d6423SLionel Sambuc 	u32_t gpe1_blk;
62*433d6423SLionel Sambuc 	u8_t pm1_evt_len;
63*433d6423SLionel Sambuc 	u8_t pm1_cnt_len;
64*433d6423SLionel Sambuc 	u8_t pm2_cnt_len;
65*433d6423SLionel Sambuc 	u8_t pm_tmr_len;
66*433d6423SLionel Sambuc 	u8_t gpe0_blk_len;
67*433d6423SLionel Sambuc 	u8_t gpe1_blk_len;
68*433d6423SLionel Sambuc 	u8_t gpe1_base;
69*433d6423SLionel Sambuc 	u8_t cst_cnt;
70*433d6423SLionel Sambuc 	u16_t p_lvl2_lat;
71*433d6423SLionel Sambuc 	u16_t p_lvl3_lat;
72*433d6423SLionel Sambuc 	u16_t flush_size;
73*433d6423SLionel Sambuc 	u16_t flush_stride;
74*433d6423SLionel Sambuc 	u8_t duty_offset;
75*433d6423SLionel Sambuc 	u8_t duty_width;
76*433d6423SLionel Sambuc 	u8_t day_alrm;
77*433d6423SLionel Sambuc 	u8_t mon_alrm;
78*433d6423SLionel Sambuc 	u8_t century;
79*433d6423SLionel Sambuc 	u16_t iapc_boot_arch;
80*433d6423SLionel Sambuc 	u8_t reserved1;
81*433d6423SLionel Sambuc 	u32_t flags;
82*433d6423SLionel Sambuc 	struct acpi_generic_address reset_reg;
83*433d6423SLionel Sambuc 	u8_t reset_value;
84*433d6423SLionel Sambuc 	u8_t reserved2[3];
85*433d6423SLionel Sambuc 	u64_t xfacs;
86*433d6423SLionel Sambuc 	u64_t xdsdt;
87*433d6423SLionel Sambuc 	struct acpi_generic_address xpm1a_evt_blk;
88*433d6423SLionel Sambuc 	struct acpi_generic_address xpm1b_evt_blk;
89*433d6423SLionel Sambuc 	struct acpi_generic_address xpm1a_cnt_blk;
90*433d6423SLionel Sambuc 	struct acpi_generic_address xpm1b_cnt_blk;
91*433d6423SLionel Sambuc 	struct acpi_generic_address xpm2_cnt_blk;
92*433d6423SLionel Sambuc 	struct acpi_generic_address xpm_tmr_blk;
93*433d6423SLionel Sambuc 	struct acpi_generic_address xgpe0_blk;
94*433d6423SLionel Sambuc 	struct acpi_generic_address xgpe1_blk;
95*433d6423SLionel Sambuc };
96*433d6423SLionel Sambuc 
97*433d6423SLionel Sambuc struct acpi_madt_hdr {
98*433d6423SLionel Sambuc 	struct acpi_sdt_header	hdr;
99*433d6423SLionel Sambuc 	u32_t			local_apic_address;
100*433d6423SLionel Sambuc 	u32_t			flags;
101*433d6423SLionel Sambuc };
102*433d6423SLionel Sambuc 
103*433d6423SLionel Sambuc #define ACPI_MADT_TYPE_LAPIC		0
104*433d6423SLionel Sambuc #define ACPI_MADT_TYPE_IOAPIC		1
105*433d6423SLionel Sambuc #define ACPI_MADT_TYPE_INT_SRC		2
106*433d6423SLionel Sambuc #define ACPI_MADT_TYPE_NMI_SRC		3
107*433d6423SLionel Sambuc #define ACPI_MADT_TYPE_LAPIC_NMI	4
108*433d6423SLionel Sambuc #define ACPI_MADT_TYPE_LAPIC_ADRESS	5
109*433d6423SLionel Sambuc #define ACPI_MADT_TYPE_IOSAPIC		6
110*433d6423SLionel Sambuc #define ACPI_MADT_TYPE_LSAPIC		7
111*433d6423SLionel Sambuc #define ACPI_MADT_TYPE_PLATFORM_INT_SRC	8
112*433d6423SLionel Sambuc #define ACPI_MADT_TYPE_Lx2APIC		9
113*433d6423SLionel Sambuc #define ACPI_MADT_TYPE_Lx2APIC_NMI	10
114*433d6423SLionel Sambuc 
115*433d6423SLionel Sambuc struct acpi_madt_item_hdr{
116*433d6423SLionel Sambuc 	u8_t	type;
117*433d6423SLionel Sambuc 	u8_t	length;
118*433d6423SLionel Sambuc };
119*433d6423SLionel Sambuc 
120*433d6423SLionel Sambuc struct acpi_madt_lapic {
121*433d6423SLionel Sambuc 	struct acpi_madt_item_hdr hdr;
122*433d6423SLionel Sambuc 	u8_t	acpi_cpu_id;
123*433d6423SLionel Sambuc 	u8_t	apic_id;
124*433d6423SLionel Sambuc 	u32_t	flags;
125*433d6423SLionel Sambuc };
126*433d6423SLionel Sambuc 
127*433d6423SLionel Sambuc struct acpi_madt_ioapic {
128*433d6423SLionel Sambuc 	struct acpi_madt_item_hdr hdr;
129*433d6423SLionel Sambuc 	u8_t	id;
130*433d6423SLionel Sambuc 	u8_t	__reserved;
131*433d6423SLionel Sambuc 	u32_t	address;
132*433d6423SLionel Sambuc 	u32_t	global_int_base;
133*433d6423SLionel Sambuc };
134*433d6423SLionel Sambuc 
135*433d6423SLionel Sambuc struct acpi_madt_int_src {
136*433d6423SLionel Sambuc 	struct acpi_madt_item_hdr hdr;
137*433d6423SLionel Sambuc 	u8_t	bus;
138*433d6423SLionel Sambuc 	u8_t	bus_int;
139*433d6423SLionel Sambuc 	u32_t	global_int;
140*433d6423SLionel Sambuc 	u16_t	mps_flags;
141*433d6423SLionel Sambuc };
142*433d6423SLionel Sambuc 
143*433d6423SLionel Sambuc struct acpi_madt_nmi {
144*433d6423SLionel Sambuc 	struct acpi_madt_item_hdr hdr;
145*433d6423SLionel Sambuc 	u16_t	flags;
146*433d6423SLionel Sambuc 	u32_t	global_int;
147*433d6423SLionel Sambuc };
148*433d6423SLionel Sambuc 
149*433d6423SLionel Sambuc void acpi_init(void);
150*433d6423SLionel Sambuc 
151*433d6423SLionel Sambuc void acpi_poweroff(void);
152*433d6423SLionel Sambuc 
153*433d6423SLionel Sambuc /*
154*433d6423SLionel Sambuc  * Returns a pointer to the io acpi structure in the MADT table in ACPI. The
155*433d6423SLionel Sambuc  * pointer is valid only until paging is turned off. No memory is allocated in
156*433d6423SLionel Sambuc  * this function thus no memory needs to be freed
157*433d6423SLionel Sambuc  */
158*433d6423SLionel Sambuc struct acpi_madt_ioapic * acpi_get_ioapic_next(void);
159*433d6423SLionel Sambuc /* same as above for local APICs */
160*433d6423SLionel Sambuc struct acpi_madt_lapic * acpi_get_lapic_next(void);
161*433d6423SLionel Sambuc 
162*433d6423SLionel Sambuc #endif /* __ACPI_H__ */
163