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;
59 } __attribute__ ((packed)) acpi_table_entry_header;
61 /* Multiple APIC Description Table (MADT) */
63 struct acpi_table_madt {
64 struct acpi_table_header header;
70 } __attribute__ ((packed));
72 enum acpi_madt_entry_id {
75 ACPI_MADT_INT_SRC_OVR,
78 ACPI_MADT_LAPIC_ADDR_OVR,
81 ACPI_MADT_PLAT_INT_SRC,
89 } __attribute__ ((packed)) acpi_interrupt_flags;
91 struct acpi_table_lapic {
92 acpi_table_entry_header header;
99 } __attribute__ ((packed));
101 struct acpi_table_ioapic {
102 acpi_table_entry_header header;
107 } __attribute__ ((packed));
109 struct acpi_table_int_src_ovr {
110 acpi_table_entry_header header;
114 acpi_interrupt_flags flags;
115 } __attribute__ ((packed));
117 struct acpi_table_nmi_src {
118 acpi_table_entry_header header;
119 acpi_interrupt_flags flags;
121 } __attribute__ ((packed));
123 struct acpi_table_lapic_nmi {
124 acpi_table_entry_header header;
126 acpi_interrupt_flags flags;
128 } __attribute__ ((packed));
130 struct acpi_table_lapic_addr_ovr {
131 acpi_table_entry_header header;
134 } __attribute__ ((packed));
136 struct acpi_table_iosapic {
137 acpi_table_entry_header header;
142 } __attribute__ ((packed));
144 struct acpi_table_lsapic {
145 acpi_table_entry_header header;
154 } __attribute__ ((packed));
156 struct acpi_table_plat_int_src {
157 acpi_table_entry_header header;
158 acpi_interrupt_flags flags;
159 u8 type; /* See acpi_interrupt_type */
165 u32 cpei_override_flag:1;
168 } __attribute__ ((packed));
170 enum acpi_interrupt_id {
171 ACPI_INTERRUPT_PMI = 1,
177 #define ACPI_SPACE_MEM 0
179 struct acpi_gen_regaddr {
186 } __attribute__ ((packed));
188 struct acpi_table_hpet {
189 struct acpi_table_header header;
191 struct acpi_gen_regaddr addr;
195 } __attribute__ ((packed));
199 * http://www.microsoft.com/whdc/hwdev/resources/specs/simp_bios.mspx
201 struct acpi_table_sbf
214 } __attribute__ ((packed));
217 * System Resource Affinity Table (SRAT)
218 * http://www.microsoft.com/whdc/hwdev/platform/proc/SRAT.mspx
221 struct acpi_table_srat {
222 struct acpi_table_header header;
225 } __attribute__ ((packed));
227 enum acpi_srat_entry_id {
228 ACPI_SRAT_PROCESSOR_AFFINITY = 0,
229 ACPI_SRAT_MEMORY_AFFINITY,
230 ACPI_SRAT_ENTRY_COUNT
233 struct acpi_table_processor_affinity {
234 acpi_table_entry_header header;
243 } __attribute__ ((packed));
245 struct acpi_table_memory_affinity {
246 acpi_table_entry_header header;
253 u32 memory_type; /* See acpi_address_range_id */
260 } __attribute__ ((packed));
262 enum acpi_address_range_id {
263 ACPI_ADDRESS_RANGE_MEMORY = 1,
264 ACPI_ADDRESS_RANGE_RESERVED = 2,
265 ACPI_ADDRESS_RANGE_ACPI = 3,
266 ACPI_ADDRESS_RANGE_NVS = 4,
267 ACPI_ADDRESS_RANGE_COUNT
271 * System Locality Information Table (SLIT)
272 * see http://devresource.hp.com/devresource/docs/techpapers/ia64/slit.pdf
275 struct acpi_table_slit {
276 struct acpi_table_header header;
278 u8 entry[1]; /* real size = localities^2 */
279 } __attribute__ ((packed));
281 /* Smart Battery Description Table (SBST) */
283 struct acpi_table_sbst {
284 struct acpi_table_header header;
285 u32 warning; /* Warn user */
286 u32 low; /* Critical sleep */
287 u32 critical; /* Critical shutdown */
288 } __attribute__ ((packed));
290 /* Embedded Controller Boot Resources Table (ECDT) */
292 struct acpi_table_ecdt {
293 struct acpi_table_header header;
294 struct acpi_generic_address ec_control;
295 struct acpi_generic_address ec_data;
299 } __attribute__ ((packed));
303 /* Defined in PCI Firmware Specification 3.0 */
304 struct acpi_table_mcfg_config {
307 u16 pci_segment_group_number;
311 } __attribute__ ((packed));
312 struct acpi_table_mcfg {
313 struct acpi_table_header header;
315 struct acpi_table_mcfg_config config[0];
316 } __attribute__ ((packed));
321 ACPI_TABLE_UNKNOWN = 0,
343 typedef int (*acpi_table_handler) (unsigned long phys_addr, unsigned long size);
345 extern acpi_table_handler acpi_table_ops[ACPI_TABLE_COUNT];
347 typedef int (*acpi_madt_entry_handler) (acpi_table_entry_header *header, const unsigned long end);
349 char * __acpi_map_table (unsigned long phys_addr, unsigned long size);
350 unsigned long acpi_find_rsdp (void);
351 int acpi_boot_init (void);
352 int acpi_boot_table_init (void);
353 int acpi_numa_init (void);
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, unsigned int max_entries);
359 int acpi_table_parse_srat (enum acpi_srat_entry_id id, acpi_madt_entry_handler handler, unsigned int max_entries);
360 int acpi_parse_mcfg (unsigned long phys_addr, unsigned long size);
361 void acpi_table_print (struct acpi_table_header *header, unsigned long phys_addr);
362 void acpi_table_print_madt_entry (acpi_table_entry_header *madt);
363 void acpi_table_print_srat_entry (acpi_table_entry_header *srat);
365 /* the following four functions are architecture-dependent */
366 #ifdef CONFIG_HAVE_ARCH_PARSE_SRAT
367 #define NR_NODE_MEMBLKS MAX_NUMNODES
368 #define acpi_numa_slit_init(slit) do {} while (0)
369 #define acpi_numa_processor_affinity_init(pa) do {} while (0)
370 #define acpi_numa_memory_affinity_init(ma) do {} while (0)
371 #define acpi_numa_arch_fixup() do {} while (0)
373 void acpi_numa_slit_init (struct acpi_table_slit *slit);
374 void acpi_numa_processor_affinity_init (struct acpi_table_processor_affinity *pa);
375 void acpi_numa_memory_affinity_init (struct acpi_table_memory_affinity *ma);
376 void acpi_numa_arch_fixup(void);
379 #ifdef CONFIG_ACPI_HOTPLUG_CPU
380 /* Arch dependent functions for cpu hotplug support */
381 int acpi_map_lsapic(acpi_handle handle, int *pcpu);
382 int acpi_unmap_lsapic(int cpu);
383 #endif /* CONFIG_ACPI_HOTPLUG_CPU */
385 int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base);
386 int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base);
388 extern int acpi_mp_config;
390 extern struct acpi_table_mcfg_config *pci_mmcfg_config;
391 extern int pci_mmcfg_config_num;
394 extern unsigned long acpi_video_flags;
396 #else /* !CONFIG_ACPI */
398 #define acpi_mp_config 0
400 #endif /* !CONFIG_ACPI */
402 int acpi_register_gsi (u32 gsi, int triggering, int polarity);
403 int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
406 * This function undoes the effect of one call to acpi_register_gsi().
407 * If this matches the last registration, any IRQ resources for gsi
410 void acpi_unregister_gsi (u32 gsi);
414 struct acpi_prt_entry {
415 struct list_head node;
416 struct acpi_pci_id id;
425 struct acpi_prt_list {
427 struct list_head entries;
432 int acpi_pci_irq_enable (struct pci_dev *dev);
433 void acpi_penalize_isa_irq(int irq, int active);
435 void acpi_pci_irq_disable (struct pci_dev *dev);
437 struct acpi_pci_driver {
438 struct acpi_pci_driver *next;
439 int (*add)(acpi_handle handle);
440 void (*remove)(acpi_handle handle);
443 int acpi_pci_register_driver(struct acpi_pci_driver *driver);
444 void acpi_pci_unregister_driver(struct acpi_pci_driver *driver);
446 #endif /* CONFIG_ACPI */
448 #ifdef CONFIG_ACPI_EC
450 extern int ec_read(u8 addr, u8 *val);
451 extern int ec_write(u8 addr, u8 val);
452 extern int ec_transaction(u8 command,
453 const u8 *wdata, unsigned wdata_len,
454 u8 *rdata, unsigned rdata_len);
456 #endif /*CONFIG_ACPI_EC*/
458 extern int acpi_blacklisted(void);
459 extern void acpi_bios_year(char *s);
461 #define ACPI_CSTATE_LIMIT_DEFINED /* for driver builds */
465 * Set highest legal C-state
466 * 0: C0 okay, but not C1
467 * 1: C1 okay, but not C2
468 * 2: C2 okay, but not C3 etc.
471 extern unsigned int max_cstate;
473 static inline unsigned int acpi_get_cstate_limit(void)
477 static inline void acpi_set_cstate_limit(unsigned int new_limit)
479 max_cstate = new_limit;
483 static inline unsigned int acpi_get_cstate_limit(void) { return 0; }
484 static inline void acpi_set_cstate_limit(unsigned int new_limit) { return; }
487 #ifdef CONFIG_ACPI_NUMA
488 int acpi_get_pxm(acpi_handle handle);
489 int acpi_get_node(acpi_handle *handle);
491 static inline int acpi_get_pxm(acpi_handle handle)
495 static inline int acpi_get_node(acpi_handle *handle)
500 extern int acpi_paddr_to_node(u64 start_addr, u64 size);
502 extern int pnpacpi_disabled;
504 #else /* CONFIG_ACPI */
506 static inline int acpi_boot_init(void)
511 static inline int acpi_boot_table_init(void)
516 #endif /* CONFIG_ACPI */
517 #endif /*_LINUX_ACPI_H*/