1 /*
2  *  acpitable.h - x86-64-specific ACPI boot-time initialization
3  *
4  *  Copyright (C) 1999 Andrew Henroid
5  *  Copyright (C) 2001 Richard Schaal
6  *  Copyright (C) 2001 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
7  *  Copyright (C) 2001 Jun Nakajima <jun.nakajima@intel.com>
8  *  Copyright (C) 2001 Arjan van de Ven <arjanv@redhat.com>
9  *  Copyright (C) 2002 Vojtech Pavlik <vojtech@suse.cz>
10  */
11 
12 /*
13  * The following codes are cut&pasted from drivers/acpi. Part of the code
14  * there can be not updated or delivered yet.
15  * To avoid conflicts when CONFIG_ACPI is defined, the following codes are
16  * modified so that they are self-contained in this file.
17  * -- jun
18  */
19 
20 #ifndef _HEADER_ACPITABLE_H_
21 #define _HEADER_ACPITABLE_H_
22 
23 struct acpi_table_header {		/* ACPI common table header */
24 	char signature[4];		/* identifies type of table */
25 	u32 length;			/* length of table,
26 					   in bytes, * including header */
27 	u8 revision;			/* specification minor version # */
28 	u8 checksum;			/* to make sum of entire table == 0 */
29 	char oem_id[6];			/* OEM identification */
30 	char oem_table_id[8];		/* OEM table identification */
31 	u32 oem_revision;		/* OEM revision number */
32 	char asl_compiler_id[4];	/* ASL compiler vendor ID */
33 	u32 asl_compiler_revision;	/* ASL compiler revision number */
34 } __attribute__ ((packed));;
35 
36 enum {
37 	ACPI_APIC = 0,
38 	ACPI_FACP,
39 	ACPI_HPET,
40 	ACPI_TABLE_COUNT
41 };
42 
43 static char *acpi_table_signatures[ACPI_TABLE_COUNT] = {
44 	"APIC",
45 	"FACP",
46 	"HPET"
47 };
48 
49 struct acpi_table_madt {
50 	struct acpi_table_header header;
51 	u32 lapic_address;
52 	struct {
53 		u32 pcat_compat:1;
54 		u32 reserved:31;
55 	} flags __attribute__ ((packed));
56 } __attribute__ ((packed));;
57 
58 enum {
59 	ACPI_MADT_LAPIC = 0,
60 	ACPI_MADT_IOAPIC,
61 	ACPI_MADT_INT_SRC_OVR,
62 	ACPI_MADT_NMI_SRC,
63 	ACPI_MADT_LAPIC_NMI,
64 	ACPI_MADT_LAPIC_ADDR_OVR,
65 	ACPI_MADT_IOSAPIC,
66 	ACPI_MADT_LSAPIC,
67 	ACPI_MADT_PLAT_INT_SRC,
68 
69 };
70 
71 #define LO_RSDP_WINDOW_BASE		0	/* Physical Address */
72 #define HI_RSDP_WINDOW_BASE		0xE0000	/* Physical Address */
73 #define LO_RSDP_WINDOW_SIZE		0x400
74 #define HI_RSDP_WINDOW_SIZE		0x20000
75 #define RSDP_SCAN_STEP			16
76 #define RSDP_CHECKSUM_LENGTH		20
77 #define RSDP2_CHECKSUM_LENGTH		36
78 
79 typedef int (*acpi_table_handler) (struct acpi_table_header *header, unsigned long);
80 
81 struct acpi_table_rsdp {
82 	char signature[8];
83 	u8 checksum;
84 	char oem_id[6];
85 	u8 revision;
86 	u32 rsdt_address;
87 	u32 length;
88 	u64 xsdt_address;
89 	u8 checksum2;
90 	u8 reserved[3];
91 } __attribute__ ((packed));
92 
93 struct acpi_table_rsdt {
94 	struct acpi_table_header header;
95 	u32 entry[0];
96 } __attribute__ ((packed));
97 
98 struct acpi_table_xsdt {
99 	struct acpi_table_header header;
100 	u64 entry[0];
101 } __attribute__ ((packed));
102 
103 struct acpi_madt_entry_header {
104 	u8 type;
105 	u8 length;
106 }  __attribute__ ((packed));
107 
108 struct acpi_madt_int_flags {
109 	u16 polarity:2;
110 	u16 trigger:2;
111 	u16 reserved:12;
112 } __attribute__ ((packed));
113 
114 struct acpi_table_lapic {
115 	struct acpi_madt_entry_header header;
116 	u8 acpi_id;
117 	u8 id;
118 	struct {
119 		u32 enabled:1;
120 		u32 reserved:31;
121 	} flags __attribute__ ((packed));
122 } __attribute__ ((packed));
123 
124 struct acpi_table_ioapic {
125 	struct acpi_madt_entry_header header;
126 	u8 id;
127 	u8 reserved;
128 	u32 address;
129 	u32 global_irq_base;
130 } __attribute__ ((packed));
131 
132 struct acpi_table_int_src_ovr {
133 	struct acpi_madt_entry_header header;
134 	u8 bus;
135 	u8 bus_irq;
136 	u32 global_irq;
137 	struct acpi_madt_int_flags flags;
138 } __attribute__ ((packed));
139 
140 struct acpi_table_nmi_src {
141 	struct acpi_madt_entry_header header;
142 	struct acpi_madt_int_flags flags;
143 	u32 global_irq;
144 } __attribute__ ((packed));
145 
146 struct acpi_table_lapic_nmi {
147 	struct acpi_madt_entry_header header;
148 	u8 acpi_id;
149 	struct acpi_madt_int_flags flags;
150 	u8 lint;
151 } __attribute__ ((packed));
152 
153 struct acpi_table_lapic_addr_ovr {
154 	struct acpi_madt_entry_header header;
155 	u8 reserved[2];
156 	u64 address;
157 } __attribute__ ((packed));
158 
159 struct acpi_table_iosapic {
160 	struct acpi_madt_entry_header header;
161 	u8 id;
162 	u8 reserved;
163 	u32 global_irq_base;
164 	u64 address;
165 } __attribute__ ((packed));
166 
167 struct acpi_table_lsapic {
168 	struct acpi_madt_entry_header header;
169 	u8 acpi_id;
170 	u8 id;
171 	u8 eid;
172 	u8 reserved[3];
173 	struct {
174 		u32 enabled:1;
175 		u32 reserved:31;
176 	} flags;
177 } __attribute__ ((packed));
178 
179 struct acpi_table_plat_int_src {
180 	struct acpi_madt_entry_header header;
181 	struct acpi_madt_int_flags flags;
182 	u8 type;
183 	u8 id;
184 	u8 eid;
185 	u8 iosapic_vector;
186 	u32 global_irq;
187 	u32 reserved;
188 } __attribute__ ((packed));
189 
190 #define ACPI_SPACE_MEM		0
191 #define ACPI_SPACE_IO		1
192 #define ACPI_SPACE_PCICONF	2
193 
194 struct acpi_gen_regaddr {
195 	u8  space_id;
196 	u8  bit_width;
197 	u8  bit_offset;
198 	u8  resv;
199 	u32 addrl;
200 	u32 addrh;
201 } __attribute__ ((packed));
202 
203 struct acpi_table_hpet {
204 	struct acpi_table_header header;
205 	u32 id;
206 	struct acpi_gen_regaddr addr;
207 	u8 number;
208 	u16 min_tick;
209 	u8 page_protect;
210 } __attribute__ ((packed));
211 
212 #endif
213