acpi.h 12 KB

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