acpi.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  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. u32 reserved;
  176. } __attribute__ ((packed));
  177. enum acpi_interrupt_id {
  178. ACPI_INTERRUPT_PMI = 1,
  179. ACPI_INTERRUPT_INIT,
  180. ACPI_INTERRUPT_CPEI,
  181. ACPI_INTERRUPT_COUNT
  182. };
  183. #define ACPI_SPACE_MEM 0
  184. struct acpi_gen_regaddr {
  185. u8 space_id;
  186. u8 bit_width;
  187. u8 bit_offset;
  188. u8 resv;
  189. u32 addrl;
  190. u32 addrh;
  191. } __attribute__ ((packed));
  192. struct acpi_table_hpet {
  193. struct acpi_table_header header;
  194. u32 id;
  195. struct acpi_gen_regaddr addr;
  196. u8 number;
  197. u16 min_tick;
  198. u8 page_protect;
  199. } __attribute__ ((packed));
  200. /*
  201. * Simple Boot Flags
  202. * http://www.microsoft.com/whdc/hwdev/resources/specs/simp_bios.mspx
  203. */
  204. struct acpi_table_sbf
  205. {
  206. u8 sbf_signature[4];
  207. u32 sbf_len;
  208. u8 sbf_revision;
  209. u8 sbf_csum;
  210. u8 sbf_oemid[6];
  211. u8 sbf_oemtable[8];
  212. u8 sbf_revdata[4];
  213. u8 sbf_creator[4];
  214. u8 sbf_crearev[4];
  215. u8 sbf_cmos;
  216. u8 sbf_spare[3];
  217. } __attribute__ ((packed));
  218. /*
  219. * System Resource Affinity Table (SRAT)
  220. * http://www.microsoft.com/whdc/hwdev/platform/proc/SRAT.mspx
  221. */
  222. struct acpi_table_srat {
  223. struct acpi_table_header header;
  224. u32 table_revision;
  225. u64 reserved;
  226. } __attribute__ ((packed));
  227. enum acpi_srat_entry_id {
  228. ACPI_SRAT_PROCESSOR_AFFINITY = 0,
  229. ACPI_SRAT_MEMORY_AFFINITY,
  230. ACPI_SRAT_ENTRY_COUNT
  231. };
  232. struct acpi_table_processor_affinity {
  233. acpi_table_entry_header header;
  234. u8 proximity_domain;
  235. u8 apic_id;
  236. struct {
  237. u32 enabled:1;
  238. u32 reserved:31;
  239. } flags;
  240. u8 lsapic_eid;
  241. u8 reserved[7];
  242. } __attribute__ ((packed));
  243. struct acpi_table_memory_affinity {
  244. acpi_table_entry_header header;
  245. u8 proximity_domain;
  246. u8 reserved1[5];
  247. u32 base_addr_lo;
  248. u32 base_addr_hi;
  249. u32 length_lo;
  250. u32 length_hi;
  251. u32 memory_type; /* See acpi_address_range_id */
  252. struct {
  253. u32 enabled:1;
  254. u32 hot_pluggable:1;
  255. u32 reserved:30;
  256. } flags;
  257. u64 reserved2;
  258. } __attribute__ ((packed));
  259. enum acpi_address_range_id {
  260. ACPI_ADDRESS_RANGE_MEMORY = 1,
  261. ACPI_ADDRESS_RANGE_RESERVED = 2,
  262. ACPI_ADDRESS_RANGE_ACPI = 3,
  263. ACPI_ADDRESS_RANGE_NVS = 4,
  264. ACPI_ADDRESS_RANGE_COUNT
  265. };
  266. /*
  267. * System Locality Information Table (SLIT)
  268. * see http://devresource.hp.com/devresource/docs/techpapers/ia64/slit.pdf
  269. */
  270. struct acpi_table_slit {
  271. struct acpi_table_header header;
  272. u64 localities;
  273. u8 entry[1]; /* real size = localities^2 */
  274. } __attribute__ ((packed));
  275. /* Smart Battery Description Table (SBST) */
  276. struct acpi_table_sbst {
  277. struct acpi_table_header header;
  278. u32 warning; /* Warn user */
  279. u32 low; /* Critical sleep */
  280. u32 critical; /* Critical shutdown */
  281. } __attribute__ ((packed));
  282. /* Embedded Controller Boot Resources Table (ECDT) */
  283. struct acpi_table_ecdt {
  284. struct acpi_table_header header;
  285. struct acpi_generic_address ec_control;
  286. struct acpi_generic_address ec_data;
  287. u32 uid;
  288. u8 gpe_bit;
  289. char ec_id[0];
  290. } __attribute__ ((packed));
  291. /* PCI MMCONFIG */
  292. struct acpi_table_mcfg {
  293. struct acpi_table_header header;
  294. u8 reserved[8];
  295. u32 base_address;
  296. u32 base_reserved;
  297. } __attribute__ ((packed));
  298. /* Table Handlers */
  299. enum acpi_table_id {
  300. ACPI_TABLE_UNKNOWN = 0,
  301. ACPI_APIC,
  302. ACPI_BOOT,
  303. ACPI_DBGP,
  304. ACPI_DSDT,
  305. ACPI_ECDT,
  306. ACPI_ETDT,
  307. ACPI_FADT,
  308. ACPI_FACS,
  309. ACPI_OEMX,
  310. ACPI_PSDT,
  311. ACPI_SBST,
  312. ACPI_SLIT,
  313. ACPI_SPCR,
  314. ACPI_SRAT,
  315. ACPI_SSDT,
  316. ACPI_SPMI,
  317. ACPI_HPET,
  318. ACPI_MCFG,
  319. ACPI_TABLE_COUNT
  320. };
  321. typedef int (*acpi_table_handler) (unsigned long phys_addr, unsigned long size);
  322. extern acpi_table_handler acpi_table_ops[ACPI_TABLE_COUNT];
  323. typedef int (*acpi_madt_entry_handler) (acpi_table_entry_header *header, const unsigned long end);
  324. char * __acpi_map_table (unsigned long phys_addr, unsigned long size);
  325. unsigned long acpi_find_rsdp (void);
  326. int acpi_boot_init (void);
  327. int acpi_boot_table_init (void);
  328. int acpi_numa_init (void);
  329. int acpi_table_init (void);
  330. int acpi_table_parse (enum acpi_table_id id, acpi_table_handler handler);
  331. int acpi_get_table_header_early (enum acpi_table_id id, struct acpi_table_header **header);
  332. int acpi_table_parse_madt (enum acpi_madt_entry_id id, acpi_madt_entry_handler handler, unsigned int max_entries);
  333. int acpi_table_parse_srat (enum acpi_srat_entry_id id, acpi_madt_entry_handler handler, unsigned int max_entries);
  334. void acpi_table_print (struct acpi_table_header *header, unsigned long phys_addr);
  335. void acpi_table_print_madt_entry (acpi_table_entry_header *madt);
  336. void acpi_table_print_srat_entry (acpi_table_entry_header *srat);
  337. /* the following four functions are architecture-dependent */
  338. void acpi_numa_slit_init (struct acpi_table_slit *slit);
  339. void acpi_numa_processor_affinity_init (struct acpi_table_processor_affinity *pa);
  340. void acpi_numa_memory_affinity_init (struct acpi_table_memory_affinity *ma);
  341. void acpi_numa_arch_fixup(void);
  342. #ifdef CONFIG_ACPI_HOTPLUG_CPU
  343. /* Arch dependent functions for cpu hotplug support */
  344. int acpi_map_lsapic(acpi_handle handle, int *pcpu);
  345. int acpi_unmap_lsapic(int cpu);
  346. #endif /* CONFIG_ACPI_HOTPLUG_CPU */
  347. extern int acpi_mp_config;
  348. extern u32 pci_mmcfg_base_addr;
  349. extern int sbf_port ;
  350. #else /*!CONFIG_ACPI_BOOT*/
  351. #define acpi_mp_config 0
  352. static inline int acpi_boot_init(void)
  353. {
  354. return 0;
  355. }
  356. static inline int acpi_boot_table_init(void)
  357. {
  358. return 0;
  359. }
  360. #endif /*!CONFIG_ACPI_BOOT*/
  361. unsigned int acpi_register_gsi (u32 gsi, int edge_level, int active_high_low);
  362. int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
  363. /*
  364. * This function undoes the effect of one call to acpi_register_gsi().
  365. * If this matches the last registration, any IRQ resources for gsi
  366. * are freed.
  367. */
  368. #ifdef CONFIG_ACPI_DEALLOCATE_IRQ
  369. void acpi_unregister_gsi (u32 gsi);
  370. #endif
  371. #ifdef CONFIG_ACPI_PCI
  372. struct acpi_prt_entry {
  373. struct list_head node;
  374. struct acpi_pci_id id;
  375. u8 pin;
  376. struct {
  377. acpi_handle handle;
  378. u32 index;
  379. } link;
  380. u32 irq;
  381. };
  382. struct acpi_prt_list {
  383. int count;
  384. struct list_head entries;
  385. };
  386. struct pci_dev;
  387. int acpi_pci_irq_enable (struct pci_dev *dev);
  388. void acpi_penalize_isa_irq(int irq);
  389. #ifdef CONFIG_ACPI_DEALLOCATE_IRQ
  390. void acpi_pci_irq_disable (struct pci_dev *dev);
  391. #endif
  392. struct acpi_pci_driver {
  393. struct acpi_pci_driver *next;
  394. int (*add)(acpi_handle handle);
  395. void (*remove)(acpi_handle handle);
  396. };
  397. int acpi_pci_register_driver(struct acpi_pci_driver *driver);
  398. void acpi_pci_unregister_driver(struct acpi_pci_driver *driver);
  399. #endif /*CONFIG_ACPI_PCI*/
  400. #ifdef CONFIG_ACPI_EC
  401. extern int ec_read(u8 addr, u8 *val);
  402. extern int ec_write(u8 addr, u8 val);
  403. #endif /*CONFIG_ACPI_EC*/
  404. #ifdef CONFIG_ACPI_INTERPRETER
  405. extern int acpi_blacklisted(void);
  406. extern void acpi_bios_year(char *s);
  407. #else /*!CONFIG_ACPI_INTERPRETER*/
  408. static inline int acpi_blacklisted(void)
  409. {
  410. return 0;
  411. }
  412. #endif /*!CONFIG_ACPI_INTERPRETER*/
  413. #define ACPI_CSTATE_LIMIT_DEFINED /* for driver builds */
  414. #ifdef CONFIG_ACPI
  415. /*
  416. * Set highest legal C-state
  417. * 0: C0 okay, but not C1
  418. * 1: C1 okay, but not C2
  419. * 2: C2 okay, but not C3 etc.
  420. */
  421. extern unsigned int max_cstate;
  422. static inline unsigned int acpi_get_cstate_limit(void)
  423. {
  424. return max_cstate;
  425. }
  426. static inline void acpi_set_cstate_limit(unsigned int new_limit)
  427. {
  428. max_cstate = new_limit;
  429. return;
  430. }
  431. #else
  432. static inline unsigned int acpi_get_cstate_limit(void) { return 0; }
  433. static inline void acpi_set_cstate_limit(unsigned int new_limit) { return; }
  434. #endif
  435. #ifdef CONFIG_ACPI_NUMA
  436. int acpi_get_pxm(acpi_handle handle);
  437. #else
  438. static inline int acpi_get_pxm(acpi_handle handle)
  439. {
  440. return 0;
  441. }
  442. #endif
  443. extern int pnpacpi_disabled;
  444. #endif /* CONFIG_ACPI */
  445. #endif /*_LINUX_ACPI_H*/