acpi.h 12 KB

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