2 * acpi.h - ACPI Interface
4 * Copyright (C) 2001 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
6 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
35 #include <linux/list.h>
37 #include <acpi/acpi.h>
38 #include <acpi/acpi_bus.h>
39 #include <acpi/acpi_drivers.h>
45 enum acpi_irq_model_id {
46 ACPI_IRQ_MODEL_PIC = 0,
47 ACPI_IRQ_MODEL_IOAPIC,
48 ACPI_IRQ_MODEL_IOSAPIC,
52 extern enum acpi_irq_model_id acpi_irq_model;
55 /* Root System Description Pointer (RSDP) */
57 struct acpi_table_rsdp {
63 } __attribute__ ((packed));
65 struct acpi20_table_rsdp {
75 } __attribute__ ((packed));
80 } __attribute__ ((packed)) acpi_table_entry_header;
82 /* Root System Description Table (RSDT) */
84 struct acpi_table_rsdt {
85 struct acpi_table_header header;
87 } __attribute__ ((packed));
89 /* Extended System Description Table (XSDT) */
91 struct acpi_table_xsdt {
92 struct acpi_table_header header;
94 } __attribute__ ((packed));
96 /* Fixed ACPI Description Table (FADT) */
98 struct acpi_table_fadt {
99 struct acpi_table_header header;
103 } __attribute__ ((packed));
105 /* Multiple APIC Description Table (MADT) */
107 struct acpi_table_madt {
108 struct acpi_table_header header;
114 } __attribute__ ((packed));
116 enum acpi_madt_entry_id {
119 ACPI_MADT_INT_SRC_OVR,
122 ACPI_MADT_LAPIC_ADDR_OVR,
125 ACPI_MADT_PLAT_INT_SRC,
126 ACPI_MADT_ENTRY_COUNT
133 } __attribute__ ((packed)) acpi_interrupt_flags;
135 struct acpi_table_lapic {
136 acpi_table_entry_header header;
143 } __attribute__ ((packed));
145 struct acpi_table_ioapic {
146 acpi_table_entry_header header;
151 } __attribute__ ((packed));
153 struct acpi_table_int_src_ovr {
154 acpi_table_entry_header header;
158 acpi_interrupt_flags flags;
159 } __attribute__ ((packed));
161 struct acpi_table_nmi_src {
162 acpi_table_entry_header header;
163 acpi_interrupt_flags flags;
165 } __attribute__ ((packed));
167 struct acpi_table_lapic_nmi {
168 acpi_table_entry_header header;
170 acpi_interrupt_flags flags;
172 } __attribute__ ((packed));
174 struct acpi_table_lapic_addr_ovr {
175 acpi_table_entry_header header;
178 } __attribute__ ((packed));
180 struct acpi_table_iosapic {
181 acpi_table_entry_header header;
186 } __attribute__ ((packed));
188 struct acpi_table_lsapic {
189 acpi_table_entry_header header;
198 } __attribute__ ((packed));
200 struct acpi_table_plat_int_src {
201 acpi_table_entry_header header;
202 acpi_interrupt_flags flags;
203 u8 type; /* See acpi_interrupt_type */
209 u32 cpei_override_flag:1;
212 } __attribute__ ((packed));
214 enum acpi_interrupt_id {
215 ACPI_INTERRUPT_PMI = 1,
221 #define ACPI_SPACE_MEM 0
223 struct acpi_gen_regaddr {
230 } __attribute__ ((packed));
232 struct acpi_table_hpet {
233 struct acpi_table_header header;
235 struct acpi_gen_regaddr addr;
239 } __attribute__ ((packed));
243 * http://www.microsoft.com/whdc/hwdev/resources/specs/simp_bios.mspx
245 struct acpi_table_sbf
258 } __attribute__ ((packed));
261 * System Resource Affinity Table (SRAT)
262 * http://www.microsoft.com/whdc/hwdev/platform/proc/SRAT.mspx
265 struct acpi_table_srat {
266 struct acpi_table_header header;
269 } __attribute__ ((packed));
271 enum acpi_srat_entry_id {
272 ACPI_SRAT_PROCESSOR_AFFINITY = 0,
273 ACPI_SRAT_MEMORY_AFFINITY,
274 ACPI_SRAT_ENTRY_COUNT
277 struct acpi_table_processor_affinity {
278 acpi_table_entry_header header;
287 } __attribute__ ((packed));
289 struct acpi_table_memory_affinity {
290 acpi_table_entry_header header;
297 u32 memory_type; /* See acpi_address_range_id */
304 } __attribute__ ((packed));
306 enum acpi_address_range_id {
307 ACPI_ADDRESS_RANGE_MEMORY = 1,
308 ACPI_ADDRESS_RANGE_RESERVED = 2,
309 ACPI_ADDRESS_RANGE_ACPI = 3,
310 ACPI_ADDRESS_RANGE_NVS = 4,
311 ACPI_ADDRESS_RANGE_COUNT
315 * System Locality Information Table (SLIT)
316 * see http://devresource.hp.com/devresource/docs/techpapers/ia64/slit.pdf
319 struct acpi_table_slit {
320 struct acpi_table_header header;
322 u8 entry[1]; /* real size = localities^2 */
323 } __attribute__ ((packed));
325 /* Smart Battery Description Table (SBST) */
327 struct acpi_table_sbst {
328 struct acpi_table_header header;
329 u32 warning; /* Warn user */
330 u32 low; /* Critical sleep */
331 u32 critical; /* Critical shutdown */
332 } __attribute__ ((packed));
334 /* Embedded Controller Boot Resources Table (ECDT) */
336 struct acpi_table_ecdt {
337 struct acpi_table_header header;
338 struct acpi_generic_address ec_control;
339 struct acpi_generic_address ec_data;
343 } __attribute__ ((packed));
347 /* Defined in PCI Firmware Specification 3.0 */
348 struct acpi_table_mcfg_config {
351 u16 pci_segment_group_number;
355 } __attribute__ ((packed));
356 struct acpi_table_mcfg {
357 struct acpi_table_header header;
359 struct acpi_table_mcfg_config config[0];
360 } __attribute__ ((packed));
365 ACPI_TABLE_UNKNOWN = 0,
387 typedef int (*acpi_table_handler) (unsigned long phys_addr, unsigned long size);
389 extern acpi_table_handler acpi_table_ops[ACPI_TABLE_COUNT];
391 typedef int (*acpi_madt_entry_handler) (acpi_table_entry_header *header, const unsigned long end);
393 char * __acpi_map_table (unsigned long phys_addr, unsigned long size);
394 unsigned long acpi_find_rsdp (void);
395 int acpi_boot_init (void);
396 int acpi_boot_table_init (void);
397 int acpi_numa_init (void);
399 int acpi_table_init (void);
400 int acpi_table_parse (enum acpi_table_id id, acpi_table_handler handler);
401 int acpi_get_table_header_early (enum acpi_table_id id, struct acpi_table_header **header);
402 int acpi_table_parse_madt (enum acpi_madt_entry_id id, acpi_madt_entry_handler handler, unsigned int max_entries);
403 int acpi_table_parse_srat (enum acpi_srat_entry_id id, acpi_madt_entry_handler handler, unsigned int max_entries);
404 int acpi_parse_mcfg (unsigned long phys_addr, unsigned long size);
405 void acpi_table_print (struct acpi_table_header *header, unsigned long phys_addr);
406 void acpi_table_print_madt_entry (acpi_table_entry_header *madt);
407 void acpi_table_print_srat_entry (acpi_table_entry_header *srat);
409 /* the following four functions are architecture-dependent */
410 void acpi_numa_slit_init (struct acpi_table_slit *slit);
411 void acpi_numa_processor_affinity_init (struct acpi_table_processor_affinity *pa);
412 void acpi_numa_memory_affinity_init (struct acpi_table_memory_affinity *ma);
413 void acpi_numa_arch_fixup(void);
415 #ifdef CONFIG_ACPI_HOTPLUG_CPU
416 /* Arch dependent functions for cpu hotplug support */
417 int acpi_map_lsapic(acpi_handle handle, int *pcpu);
418 int acpi_unmap_lsapic(int cpu);
419 #endif /* CONFIG_ACPI_HOTPLUG_CPU */
421 int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base);
422 int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base);
424 extern int acpi_mp_config;
426 extern struct acpi_table_mcfg_config *pci_mmcfg_config;
427 extern int pci_mmcfg_config_num;
430 extern unsigned long acpi_video_flags;
432 #else /* !CONFIG_ACPI */
434 #define acpi_mp_config 0
436 #endif /* !CONFIG_ACPI */
438 int acpi_register_gsi (u32 gsi, int triggering, int polarity);
439 int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
442 * This function undoes the effect of one call to acpi_register_gsi().
443 * If this matches the last registration, any IRQ resources for gsi
446 void acpi_unregister_gsi (u32 gsi);
450 struct acpi_prt_entry {
451 struct list_head node;
452 struct acpi_pci_id id;
461 struct acpi_prt_list {
463 struct list_head entries;
468 int acpi_pci_irq_enable (struct pci_dev *dev);
469 void acpi_penalize_isa_irq(int irq, int active);
471 void acpi_pci_irq_disable (struct pci_dev *dev);
473 struct acpi_pci_driver {
474 struct acpi_pci_driver *next;
475 int (*add)(acpi_handle handle);
476 void (*remove)(acpi_handle handle);
479 int acpi_pci_register_driver(struct acpi_pci_driver *driver);
480 void acpi_pci_unregister_driver(struct acpi_pci_driver *driver);
482 #endif /* CONFIG_ACPI */
484 #ifdef CONFIG_ACPI_EC
486 extern int ec_read(u8 addr, u8 *val);
487 extern int ec_write(u8 addr, u8 val);
489 #endif /*CONFIG_ACPI_EC*/
491 extern int acpi_blacklisted(void);
492 extern void acpi_bios_year(char *s);
494 #define ACPI_CSTATE_LIMIT_DEFINED /* for driver builds */
498 * Set highest legal C-state
499 * 0: C0 okay, but not C1
500 * 1: C1 okay, but not C2
501 * 2: C2 okay, but not C3 etc.
504 extern unsigned int max_cstate;
506 static inline unsigned int acpi_get_cstate_limit(void)
510 static inline void acpi_set_cstate_limit(unsigned int new_limit)
512 max_cstate = new_limit;
516 static inline unsigned int acpi_get_cstate_limit(void) { return 0; }
517 static inline void acpi_set_cstate_limit(unsigned int new_limit) { return; }
520 #ifdef CONFIG_ACPI_NUMA
521 int acpi_get_pxm(acpi_handle handle);
523 static inline int acpi_get_pxm(acpi_handle handle)
529 extern int pnpacpi_disabled;
531 #else /* CONFIG_ACPI */
533 static inline int acpi_boot_init(void)
538 static inline int acpi_boot_table_init(void)
543 #endif /* CONFIG_ACPI */
544 #endif /*_LINUX_ACPI_H*/