Rev 422 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
422 | giacomo | 1 | /* |
2 | * acpi.h - ACPI Interface |
||
3 | * |
||
4 | * Copyright (C) 2001 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> |
||
5 | * |
||
6 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||
7 | * |
||
8 | * This program is free software; you can redistribute it and/or modify |
||
9 | * it under the terms of the GNU General Public License as published by |
||
10 | * the Free Software Foundation; either version 2 of the License, or |
||
11 | * (at your option) any later version. |
||
12 | * |
||
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. |
||
17 | * |
||
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
21 | * |
||
22 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||
23 | */ |
||
24 | |||
25 | #ifndef _LINUX_ACPI_H |
||
26 | #define _LINUX_ACPI_H |
||
27 | |||
28 | #ifndef _LINUX |
||
29 | #define _LINUX |
||
30 | #endif |
||
31 | |||
32 | #include <linux/list.h> |
||
33 | |||
34 | #include <acpi/acpi.h> |
||
35 | #include <acpi/acpi_bus.h> |
||
36 | #include <acpi/acpi_drivers.h> |
||
37 | #include <asm/acpi.h> |
||
38 | |||
39 | |||
40 | #ifdef CONFIG_ACPI_BOOT |
||
41 | |||
42 | enum acpi_irq_model_id { |
||
43 | ACPI_IRQ_MODEL_PIC = 0, |
||
44 | ACPI_IRQ_MODEL_IOAPIC, |
||
45 | ACPI_IRQ_MODEL_IOSAPIC, |
||
46 | ACPI_IRQ_MODEL_COUNT |
||
47 | }; |
||
48 | |||
49 | extern enum acpi_irq_model_id acpi_irq_model; |
||
50 | |||
51 | |||
52 | /* Root System Description Pointer (RSDP) */ |
||
53 | |||
54 | struct acpi_table_rsdp { |
||
55 | char signature[8]; |
||
56 | u8 checksum; |
||
57 | char oem_id[6]; |
||
58 | u8 revision; |
||
59 | u32 rsdt_address; |
||
60 | } __attribute__ ((packed)); |
||
61 | |||
62 | struct acpi20_table_rsdp { |
||
63 | char signature[8]; |
||
64 | u8 checksum; |
||
65 | char oem_id[6]; |
||
66 | u8 revision; |
||
67 | u32 rsdt_address; |
||
68 | u32 length; |
||
69 | u64 xsdt_address; |
||
70 | u8 ext_checksum; |
||
71 | u8 reserved[3]; |
||
72 | } __attribute__ ((packed)); |
||
73 | |||
74 | typedef struct { |
||
75 | u8 type; |
||
76 | u8 length; |
||
77 | } __attribute__ ((packed)) acpi_table_entry_header; |
||
78 | |||
79 | /* Root System Description Table (RSDT) */ |
||
80 | |||
81 | struct acpi_table_rsdt { |
||
82 | struct acpi_table_header header; |
||
83 | u32 entry[8]; |
||
84 | } __attribute__ ((packed)); |
||
85 | |||
86 | /* Extended System Description Table (XSDT) */ |
||
87 | |||
88 | struct acpi_table_xsdt { |
||
89 | struct acpi_table_header header; |
||
90 | u64 entry[1]; |
||
91 | } __attribute__ ((packed)); |
||
92 | |||
93 | /* Fixed ACPI Description Table (FADT) */ |
||
94 | |||
95 | struct acpi_table_fadt { |
||
96 | struct acpi_table_header header; |
||
97 | u32 facs_addr; |
||
98 | u32 dsdt_addr; |
||
99 | /* ... */ |
||
100 | } __attribute__ ((packed)); |
||
101 | |||
102 | /* Multiple APIC Description Table (MADT) */ |
||
103 | |||
104 | struct acpi_table_madt { |
||
105 | struct acpi_table_header header; |
||
106 | u32 lapic_address; |
||
107 | struct { |
||
108 | u32 pcat_compat:1; |
||
109 | u32 reserved:31; |
||
110 | } flags; |
||
111 | } __attribute__ ((packed)); |
||
112 | |||
113 | enum acpi_madt_entry_id { |
||
114 | ACPI_MADT_LAPIC = 0, |
||
115 | ACPI_MADT_IOAPIC, |
||
116 | ACPI_MADT_INT_SRC_OVR, |
||
117 | ACPI_MADT_NMI_SRC, |
||
118 | ACPI_MADT_LAPIC_NMI, |
||
119 | ACPI_MADT_LAPIC_ADDR_OVR, |
||
120 | ACPI_MADT_IOSAPIC, |
||
121 | ACPI_MADT_LSAPIC, |
||
122 | ACPI_MADT_PLAT_INT_SRC, |
||
123 | ACPI_MADT_ENTRY_COUNT |
||
124 | }; |
||
125 | |||
126 | typedef struct { |
||
127 | u16 polarity:2; |
||
128 | u16 trigger:2; |
||
129 | u16 reserved:12; |
||
130 | } __attribute__ ((packed)) acpi_interrupt_flags; |
||
131 | |||
132 | struct acpi_table_lapic { |
||
133 | acpi_table_entry_header header; |
||
134 | u8 acpi_id; |
||
135 | u8 id; |
||
136 | struct { |
||
137 | u32 enabled:1; |
||
138 | u32 reserved:31; |
||
139 | } flags; |
||
140 | } __attribute__ ((packed)); |
||
141 | |||
142 | struct acpi_table_ioapic { |
||
143 | acpi_table_entry_header header; |
||
144 | u8 id; |
||
145 | u8 reserved; |
||
146 | u32 address; |
||
147 | u32 global_irq_base; |
||
148 | } __attribute__ ((packed)); |
||
149 | |||
150 | struct acpi_table_int_src_ovr { |
||
151 | acpi_table_entry_header header; |
||
152 | u8 bus; |
||
153 | u8 bus_irq; |
||
154 | u32 global_irq; |
||
155 | acpi_interrupt_flags flags; |
||
156 | } __attribute__ ((packed)); |
||
157 | |||
158 | struct acpi_table_nmi_src { |
||
159 | acpi_table_entry_header header; |
||
160 | acpi_interrupt_flags flags; |
||
161 | u32 global_irq; |
||
162 | } __attribute__ ((packed)); |
||
163 | |||
164 | struct acpi_table_lapic_nmi { |
||
165 | acpi_table_entry_header header; |
||
166 | u8 acpi_id; |
||
167 | acpi_interrupt_flags flags; |
||
168 | u8 lint; |
||
169 | } __attribute__ ((packed)); |
||
170 | |||
171 | struct acpi_table_lapic_addr_ovr { |
||
172 | acpi_table_entry_header header; |
||
173 | u8 reserved[2]; |
||
174 | u64 address; |
||
175 | } __attribute__ ((packed)); |
||
176 | |||
177 | struct acpi_table_iosapic { |
||
178 | acpi_table_entry_header header; |
||
179 | u8 id; |
||
180 | u8 reserved; |
||
181 | u32 global_irq_base; |
||
182 | u64 address; |
||
183 | } __attribute__ ((packed)); |
||
184 | |||
185 | struct acpi_table_lsapic { |
||
186 | acpi_table_entry_header header; |
||
187 | u8 acpi_id; |
||
188 | u8 id; |
||
189 | u8 eid; |
||
190 | u8 reserved[3]; |
||
191 | struct { |
||
192 | u32 enabled:1; |
||
193 | u32 reserved:31; |
||
194 | } flags; |
||
195 | } __attribute__ ((packed)); |
||
196 | |||
197 | struct acpi_table_plat_int_src { |
||
198 | acpi_table_entry_header header; |
||
199 | acpi_interrupt_flags flags; |
||
200 | u8 type; /* See acpi_interrupt_type */ |
||
201 | u8 id; |
||
202 | u8 eid; |
||
203 | u8 iosapic_vector; |
||
204 | u32 global_irq; |
||
205 | u32 reserved; |
||
206 | } __attribute__ ((packed)); |
||
207 | |||
208 | enum acpi_interrupt_id { |
||
209 | ACPI_INTERRUPT_PMI = 1, |
||
210 | ACPI_INTERRUPT_INIT, |
||
211 | ACPI_INTERRUPT_CPEI, |
||
212 | ACPI_INTERRUPT_COUNT |
||
213 | }; |
||
214 | |||
215 | #define ACPI_SPACE_MEM 0 |
||
216 | |||
217 | struct acpi_gen_regaddr { |
||
218 | u8 space_id; |
||
219 | u8 bit_width; |
||
220 | u8 bit_offset; |
||
221 | u8 resv; |
||
222 | u32 addrl; |
||
223 | u32 addrh; |
||
224 | } __attribute__ ((packed)); |
||
225 | |||
226 | struct acpi_table_hpet { |
||
227 | struct acpi_table_header header; |
||
228 | u32 id; |
||
229 | struct acpi_gen_regaddr addr; |
||
230 | u8 number; |
||
231 | u16 min_tick; |
||
232 | u8 page_protect; |
||
233 | } __attribute__ ((packed)); |
||
234 | |||
235 | /* |
||
236 | * System Resource Affinity Table (SRAT) |
||
237 | * see http://www.microsoft.com/hwdev/design/srat.htm |
||
238 | */ |
||
239 | |||
240 | struct acpi_table_srat { |
||
241 | struct acpi_table_header header; |
||
242 | u32 table_revision; |
||
243 | u64 reserved; |
||
244 | } __attribute__ ((packed)); |
||
245 | |||
246 | enum acpi_srat_entry_id { |
||
247 | ACPI_SRAT_PROCESSOR_AFFINITY = 0, |
||
248 | ACPI_SRAT_MEMORY_AFFINITY, |
||
249 | ACPI_SRAT_ENTRY_COUNT |
||
250 | }; |
||
251 | |||
252 | struct acpi_table_processor_affinity { |
||
253 | acpi_table_entry_header header; |
||
254 | u8 proximity_domain; |
||
255 | u8 apic_id; |
||
256 | struct { |
||
257 | u32 enabled:1; |
||
258 | u32 reserved:31; |
||
259 | } flags; |
||
260 | u8 lsapic_eid; |
||
261 | u8 reserved[7]; |
||
262 | } __attribute__ ((packed)); |
||
263 | |||
264 | struct acpi_table_memory_affinity { |
||
265 | acpi_table_entry_header header; |
||
266 | u8 proximity_domain; |
||
267 | u8 reserved1[5]; |
||
268 | u32 base_addr_lo; |
||
269 | u32 base_addr_hi; |
||
270 | u32 length_lo; |
||
271 | u32 length_hi; |
||
272 | u32 memory_type; /* See acpi_address_range_id */ |
||
273 | struct { |
||
274 | u32 enabled:1; |
||
275 | u32 hot_pluggable:1; |
||
276 | u32 reserved:30; |
||
277 | } flags; |
||
278 | u64 reserved2; |
||
279 | } __attribute__ ((packed)); |
||
280 | |||
281 | enum acpi_address_range_id { |
||
282 | ACPI_ADDRESS_RANGE_MEMORY = 1, |
||
283 | ACPI_ADDRESS_RANGE_RESERVED = 2, |
||
284 | ACPI_ADDRESS_RANGE_ACPI = 3, |
||
285 | ACPI_ADDRESS_RANGE_NVS = 4, |
||
286 | ACPI_ADDRESS_RANGE_COUNT |
||
287 | }; |
||
288 | |||
289 | /* |
||
290 | * System Locality Information Table (SLIT) |
||
291 | * see http://devresource.hp.com/devresource/docs/techpapers/ia64/slit.pdf |
||
292 | */ |
||
293 | |||
294 | struct acpi_table_slit { |
||
295 | struct acpi_table_header header; |
||
296 | u64 localities; |
||
297 | u8 entry[1]; /* real size = localities^2 */ |
||
298 | } __attribute__ ((packed)); |
||
299 | |||
300 | /* Smart Battery Description Table (SBST) */ |
||
301 | |||
302 | struct acpi_table_sbst { |
||
303 | struct acpi_table_header header; |
||
304 | u32 warning; /* Warn user */ |
||
305 | u32 low; /* Critical sleep */ |
||
306 | u32 critical; /* Critical shutdown */ |
||
307 | } __attribute__ ((packed)); |
||
308 | |||
309 | /* Embedded Controller Boot Resources Table (ECDT) */ |
||
310 | |||
311 | struct acpi_table_ecdt { |
||
312 | struct acpi_table_header header; |
||
313 | struct acpi_generic_address ec_control; |
||
314 | struct acpi_generic_address ec_data; |
||
315 | u32 uid; |
||
316 | u8 gpe_bit; |
||
317 | char ec_id[0]; |
||
318 | } __attribute__ ((packed)); |
||
319 | |||
320 | /* Table Handlers */ |
||
321 | |||
322 | enum acpi_table_id { |
||
323 | ACPI_TABLE_UNKNOWN = 0, |
||
324 | ACPI_APIC, |
||
325 | ACPI_BOOT, |
||
326 | ACPI_DBGP, |
||
327 | ACPI_DSDT, |
||
328 | ACPI_ECDT, |
||
329 | ACPI_ETDT, |
||
330 | ACPI_FADT, |
||
331 | ACPI_FACS, |
||
332 | ACPI_OEMX, |
||
333 | ACPI_PSDT, |
||
334 | ACPI_SBST, |
||
335 | ACPI_SLIT, |
||
336 | ACPI_SPCR, |
||
337 | ACPI_SRAT, |
||
338 | ACPI_SSDT, |
||
339 | ACPI_SPMI, |
||
340 | ACPI_HPET, |
||
341 | ACPI_TABLE_COUNT |
||
342 | }; |
||
343 | |||
344 | typedef int (*acpi_table_handler) (unsigned long phys_addr, unsigned long size); |
||
345 | |||
346 | extern acpi_table_handler acpi_table_ops[ACPI_TABLE_COUNT]; |
||
347 | |||
348 | typedef int (*acpi_madt_entry_handler) (acpi_table_entry_header *header); |
||
349 | |||
350 | char * __acpi_map_table (unsigned long phys_addr, unsigned long size); |
||
351 | unsigned long acpi_find_rsdp (void); |
||
352 | int acpi_boot_init (void); |
||
353 | int acpi_numa_init (void); |
||
354 | |||
355 | int acpi_table_init (void); |
||
356 | int acpi_table_parse (enum acpi_table_id id, acpi_table_handler handler); |
||
357 | int acpi_get_table_header_early (enum acpi_table_id id, struct acpi_table_header **header); |
||
358 | int acpi_table_parse_madt (enum acpi_madt_entry_id id, acpi_madt_entry_handler handler); |
||
359 | int acpi_table_parse_srat (enum acpi_srat_entry_id id, acpi_madt_entry_handler handler); |
||
360 | void acpi_table_print (struct acpi_table_header *header, unsigned long phys_addr); |
||
361 | void acpi_table_print_madt_entry (acpi_table_entry_header *madt); |
||
362 | void acpi_table_print_srat_entry (acpi_table_entry_header *srat); |
||
363 | |||
364 | /* the following four functions are architecture-dependent */ |
||
365 | void acpi_numa_slit_init (struct acpi_table_slit *slit); |
||
366 | void acpi_numa_processor_affinity_init (struct acpi_table_processor_affinity *pa); |
||
367 | void acpi_numa_memory_affinity_init (struct acpi_table_memory_affinity *ma); |
||
368 | void acpi_numa_arch_fixup(void); |
||
369 | |||
370 | extern int acpi_mp_config; |
||
371 | |||
372 | #else /*!CONFIG_ACPI_BOOT*/ |
||
373 | |||
374 | #define acpi_mp_config 0 |
||
375 | |||
376 | static inline int acpi_boot_init(void) |
||
377 | { |
||
378 | return 0; |
||
379 | } |
||
380 | |||
381 | #endif /*!CONFIG_ACPI_BOOT*/ |
||
382 | |||
383 | |||
384 | #ifdef CONFIG_ACPI_PCI |
||
385 | |||
386 | struct acpi_prt_entry { |
||
387 | struct list_head node; |
||
388 | struct acpi_pci_id id; |
||
389 | u8 pin; |
||
390 | struct { |
||
391 | acpi_handle handle; |
||
392 | u32 index; |
||
393 | } link; |
||
394 | u32 irq; |
||
395 | }; |
||
396 | |||
397 | struct acpi_prt_list { |
||
398 | int count; |
||
399 | struct list_head entries; |
||
400 | }; |
||
401 | |||
402 | extern struct acpi_prt_list acpi_prt; |
||
403 | |||
404 | struct pci_dev; |
||
405 | |||
406 | int acpi_pci_irq_enable (struct pci_dev *dev); |
||
407 | int acpi_pci_irq_init (void); |
||
408 | |||
409 | struct acpi_pci_driver { |
||
410 | struct acpi_pci_driver *next; |
||
411 | int (*add)(acpi_handle handle); |
||
412 | void (*remove)(acpi_handle handle); |
||
413 | }; |
||
414 | |||
415 | int acpi_pci_register_driver(struct acpi_pci_driver *driver); |
||
416 | void acpi_pci_unregister_driver(struct acpi_pci_driver *driver); |
||
417 | |||
418 | #endif /*CONFIG_ACPI_PCI*/ |
||
419 | |||
420 | #ifdef CONFIG_ACPI_EC |
||
421 | |||
422 | int ec_read(u8 addr, u8 *val); |
||
423 | int ec_write(u8 addr, u8 val); |
||
424 | |||
425 | #endif /*CONFIG_ACPI_EC*/ |
||
426 | |||
427 | #ifdef CONFIG_ACPI_INTERPRETER |
||
428 | |||
429 | int acpi_blacklisted(void); |
||
430 | |||
431 | #else /*!CONFIG_ACPI_INTERPRETER*/ |
||
432 | |||
433 | static inline int acpi_blacklisted(void) |
||
434 | { |
||
435 | return 0; |
||
436 | } |
||
437 | |||
438 | #endif /*!CONFIG_ACPI_INTERPRETER*/ |
||
439 | |||
440 | #endif /*_LINUX_ACPI_H*/ |