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>
40 #include <acpi/acpi_numa.h>
46 enum acpi_irq_model_id {
47 ACPI_IRQ_MODEL_PIC = 0,
48 ACPI_IRQ_MODEL_IOAPIC,
49 ACPI_IRQ_MODEL_IOSAPIC,
50 ACPI_IRQ_MODEL_PLATFORM,
54 extern enum acpi_irq_model_id acpi_irq_model;
57 /* Root System Description Pointer (RSDP) */
59 struct acpi_table_rsdp {
65 } __attribute__ ((packed));
67 struct acpi20_table_rsdp {
77 } __attribute__ ((packed));
82 } __attribute__ ((packed)) acpi_table_entry_header;
84 /* Root System Description Table (RSDT) */
86 struct acpi_table_rsdt {
87 struct acpi_table_header header;
89 } __attribute__ ((packed));
91 /* Extended System Description Table (XSDT) */
93 struct acpi_table_xsdt {
94 struct acpi_table_header header;
96 } __attribute__ ((packed));
98 /* Fixed ACPI Description Table (FADT) */
100 struct acpi_table_fadt {
101 struct acpi_table_header header;
105 } __attribute__ ((packed));
107 /* Multiple APIC Description Table (MADT) */
109 struct acpi_table_madt {
110 struct acpi_table_header header;
116 } __attribute__ ((packed));
118 enum acpi_madt_entry_id {
121 ACPI_MADT_INT_SRC_OVR,
124 ACPI_MADT_LAPIC_ADDR_OVR,
127 ACPI_MADT_PLAT_INT_SRC,
128 ACPI_MADT_ENTRY_COUNT
135 } __attribute__ ((packed)) acpi_interrupt_flags;
137 struct acpi_table_lapic {
138 acpi_table_entry_header header;
145 } __attribute__ ((packed));
147 struct acpi_table_ioapic {
148 acpi_table_entry_header header;
153 } __attribute__ ((packed));
155 struct acpi_table_int_src_ovr {
156 acpi_table_entry_header header;
160 acpi_interrupt_flags flags;
161 } __attribute__ ((packed));
163 struct acpi_table_nmi_src {
164 acpi_table_entry_header header;
165 acpi_interrupt_flags flags;
167 } __attribute__ ((packed));
169 struct acpi_table_lapic_nmi {
170 acpi_table_entry_header header;
172 acpi_interrupt_flags flags;
174 } __attribute__ ((packed));
176 struct acpi_table_lapic_addr_ovr {
177 acpi_table_entry_header header;
180 } __attribute__ ((packed));
182 struct acpi_table_iosapic {
183 acpi_table_entry_header header;
188 } __attribute__ ((packed));
190 struct acpi_table_lsapic {
191 acpi_table_entry_header header;
200 } __attribute__ ((packed));
202 struct acpi_table_plat_int_src {
203 acpi_table_entry_header header;
204 acpi_interrupt_flags flags;
205 u8 type; /* See acpi_interrupt_type */
211 u32 cpei_override_flag:1;
214 } __attribute__ ((packed));
216 enum acpi_interrupt_id {
217 ACPI_INTERRUPT_PMI = 1,
223 #define ACPI_SPACE_MEM 0
225 struct acpi_gen_regaddr {
232 } __attribute__ ((packed));
234 struct acpi_table_hpet {
235 struct acpi_table_header header;
237 struct acpi_gen_regaddr addr;
241 } __attribute__ ((packed));
245 * http://www.microsoft.com/whdc/hwdev/resources/specs/simp_bios.mspx
247 struct acpi_table_sbf
260 } __attribute__ ((packed));
263 * System Resource Affinity Table (SRAT)
264 * http://www.microsoft.com/whdc/hwdev/platform/proc/SRAT.mspx
267 struct acpi_table_srat {
268 struct acpi_table_header header;
271 } __attribute__ ((packed));
273 enum acpi_srat_entry_id {
274 ACPI_SRAT_PROCESSOR_AFFINITY = 0,
275 ACPI_SRAT_MEMORY_AFFINITY,
276 ACPI_SRAT_ENTRY_COUNT
279 struct acpi_table_processor_affinity {
280 acpi_table_entry_header header;
289 } __attribute__ ((packed));
291 struct acpi_table_memory_affinity {
292 acpi_table_entry_header header;
299 u32 memory_type; /* See acpi_address_range_id */
306 } __attribute__ ((packed));
308 enum acpi_address_range_id {
309 ACPI_ADDRESS_RANGE_MEMORY = 1,
310 ACPI_ADDRESS_RANGE_RESERVED = 2,
311 ACPI_ADDRESS_RANGE_ACPI = 3,
312 ACPI_ADDRESS_RANGE_NVS = 4,
313 ACPI_ADDRESS_RANGE_COUNT
317 * System Locality Information Table (SLIT)
318 * see http://devresource.hp.com/devresource/docs/techpapers/ia64/slit.pdf
321 struct acpi_table_slit {
322 struct acpi_table_header header;
324 u8 entry[1]; /* real size = localities^2 */
325 } __attribute__ ((packed));
327 /* Smart Battery Description Table (SBST) */
329 struct acpi_table_sbst {
330 struct acpi_table_header header;
331 u32 warning; /* Warn user */
332 u32 low; /* Critical sleep */
333 u32 critical; /* Critical shutdown */
334 } __attribute__ ((packed));
336 /* Embedded Controller Boot Resources Table (ECDT) */
338 struct acpi_table_ecdt {
339 struct acpi_table_header header;
340 struct acpi_generic_address ec_control;
341 struct acpi_generic_address ec_data;
345 } __attribute__ ((packed));
349 /* Defined in PCI Firmware Specification 3.0 */
350 struct acpi_table_mcfg_config {
353 u16 pci_segment_group_number;
357 } __attribute__ ((packed));
358 struct acpi_table_mcfg {
359 struct acpi_table_header header;
361 struct acpi_table_mcfg_config config[0];
362 } __attribute__ ((packed));
367 ACPI_TABLE_UNKNOWN = 0,
389 typedef int (*acpi_table_handler) (unsigned long phys_addr, unsigned long size);
391 extern acpi_table_handler acpi_table_ops[ACPI_TABLE_COUNT];
393 typedef int (*acpi_madt_entry_handler) (acpi_table_entry_header *header, const unsigned long end);
395 char * __acpi_map_table (unsigned long phys_addr, unsigned long size);
396 unsigned long acpi_find_rsdp (void);
397 int acpi_boot_init (void);
398 int acpi_boot_table_init (void);
399 int acpi_numa_init (void);
401 int acpi_table_init (void);
402 int acpi_table_parse (enum acpi_table_id id, acpi_table_handler handler);
403 int acpi_get_table_header_early (enum acpi_table_id id, struct acpi_table_header **header);
404 int acpi_table_parse_madt (enum acpi_madt_entry_id id, acpi_madt_entry_handler handler, unsigned int max_entries);
405 int acpi_table_parse_srat (enum acpi_srat_entry_id id, acpi_madt_entry_handler handler, unsigned int max_entries);
406 int acpi_parse_mcfg (unsigned long phys_addr, unsigned long size);
407 void acpi_table_print (struct acpi_table_header *header, unsigned long phys_addr);
408 void acpi_table_print_madt_entry (acpi_table_entry_header *madt);
409 void acpi_table_print_srat_entry (acpi_table_entry_header *srat);
411 /* the following four functions are architecture-dependent */
412 #ifdef CONFIG_HAVE_ARCH_PARSE_SRAT
413 #define NR_NODE_MEMBLKS MAX_NUMNODES
414 #define acpi_numa_slit_init(slit) do {} while (0)
415 #define acpi_numa_processor_affinity_init(pa) do {} while (0)
416 #define acpi_numa_memory_affinity_init(ma) do {} while (0)
417 #define acpi_numa_arch_fixup() do {} while (0)
419 void acpi_numa_slit_init (struct acpi_table_slit *slit);
420 void acpi_numa_processor_affinity_init (struct acpi_table_processor_affinity *pa);
421 void acpi_numa_memory_affinity_init (struct acpi_table_memory_affinity *ma);
422 void acpi_numa_arch_fixup(void);
425 #ifdef CONFIG_ACPI_HOTPLUG_CPU
426 /* Arch dependent functions for cpu hotplug support */
427 int acpi_map_lsapic(acpi_handle handle, int *pcpu);
428 int acpi_unmap_lsapic(int cpu);
429 #endif /* CONFIG_ACPI_HOTPLUG_CPU */
431 int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base);
432 int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base);
434 extern int acpi_mp_config;
436 extern struct acpi_table_mcfg_config *pci_mmcfg_config;
437 extern int pci_mmcfg_config_num;
440 extern unsigned long acpi_video_flags;
442 #else /* !CONFIG_ACPI */
444 #define acpi_mp_config 0
446 #endif /* !CONFIG_ACPI */
448 int acpi_register_gsi (u32 gsi, int triggering, int polarity);
449 int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
452 * This function undoes the effect of one call to acpi_register_gsi().
453 * If this matches the last registration, any IRQ resources for gsi
456 void acpi_unregister_gsi (u32 gsi);
460 struct acpi_prt_entry {
461 struct list_head node;
462 struct acpi_pci_id id;
471 struct acpi_prt_list {
473 struct list_head entries;
478 int acpi_pci_irq_enable (struct pci_dev *dev);
479 void acpi_penalize_isa_irq(int irq, int active);
481 void acpi_pci_irq_disable (struct pci_dev *dev);
483 struct acpi_pci_driver {
484 struct acpi_pci_driver *next;
485 int (*add)(acpi_handle handle);
486 void (*remove)(acpi_handle handle);
489 int acpi_pci_register_driver(struct acpi_pci_driver *driver);
490 void acpi_pci_unregister_driver(struct acpi_pci_driver *driver);
492 #endif /* CONFIG_ACPI */
494 #ifdef CONFIG_ACPI_EC
496 extern int ec_read(u8 addr, u8 *val);
497 extern int ec_write(u8 addr, u8 val);
498 extern int ec_transaction(u8 command,
499 const u8 *wdata, unsigned wdata_len,
500 u8 *rdata, unsigned rdata_len);
502 #endif /*CONFIG_ACPI_EC*/
504 extern int acpi_blacklisted(void);
505 extern void acpi_bios_year(char *s);
507 #define ACPI_CSTATE_LIMIT_DEFINED /* for driver builds */
511 * Set highest legal C-state
512 * 0: C0 okay, but not C1
513 * 1: C1 okay, but not C2
514 * 2: C2 okay, but not C3 etc.
517 extern unsigned int max_cstate;
519 static inline unsigned int acpi_get_cstate_limit(void)
523 static inline void acpi_set_cstate_limit(unsigned int new_limit)
525 max_cstate = new_limit;
529 static inline unsigned int acpi_get_cstate_limit(void) { return 0; }
530 static inline void acpi_set_cstate_limit(unsigned int new_limit) { return; }
533 #ifdef CONFIG_ACPI_NUMA
534 int acpi_get_pxm(acpi_handle handle);
535 int acpi_get_node(acpi_handle *handle);
537 static inline int acpi_get_pxm(acpi_handle handle)
541 static inline int acpi_get_node(acpi_handle *handle)
546 extern int acpi_paddr_to_node(u64 start_addr, u64 size);
548 extern int pnpacpi_disabled;
550 #else /* CONFIG_ACPI */
552 static inline int acpi_boot_init(void)
557 static inline int acpi_boot_table_init(void)
562 #endif /* CONFIG_ACPI */
563 #endif /*_LINUX_ACPI_H*/