acpi.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  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. /* Defined in PCI Firmware Specification 3.0 */
  293. struct acpi_table_mcfg_config {
  294. u32 base_address;
  295. u32 base_reserved;
  296. u16 pci_segment_group_number;
  297. u8 start_bus_number;
  298. u8 end_bus_number;
  299. u8 reserved[4];
  300. } __attribute__ ((packed));
  301. struct acpi_table_mcfg {
  302. struct acpi_table_header header;
  303. u8 reserved[8];
  304. struct acpi_table_mcfg_config config[0];
  305. } __attribute__ ((packed));
  306. /* Table Handlers */
  307. enum acpi_table_id {
  308. ACPI_TABLE_UNKNOWN = 0,
  309. ACPI_APIC,
  310. ACPI_BOOT,
  311. ACPI_DBGP,
  312. ACPI_DSDT,
  313. ACPI_ECDT,
  314. ACPI_ETDT,
  315. ACPI_FADT,
  316. ACPI_FACS,
  317. ACPI_OEMX,
  318. ACPI_PSDT,
  319. ACPI_SBST,
  320. ACPI_SLIT,
  321. ACPI_SPCR,
  322. ACPI_SRAT,
  323. ACPI_SSDT,
  324. ACPI_SPMI,
  325. ACPI_HPET,
  326. ACPI_MCFG,
  327. ACPI_TABLE_COUNT
  328. };
  329. typedef int (*acpi_table_handler) (unsigned long phys_addr, unsigned long size);
  330. extern acpi_table_handler acpi_table_ops[ACPI_TABLE_COUNT];
  331. typedef int (*acpi_madt_entry_handler) (acpi_table_entry_header *header, const unsigned long end);
  332. char * __acpi_map_table (unsigned long phys_addr, unsigned long size);
  333. unsigned long acpi_find_rsdp (void);
  334. int acpi_boot_init (void);
  335. int acpi_boot_table_init (void);
  336. int acpi_numa_init (void);
  337. int acpi_table_init (void);
  338. int acpi_table_parse (enum acpi_table_id id, acpi_table_handler handler);
  339. int acpi_get_table_header_early (enum acpi_table_id id, struct acpi_table_header **header);
  340. int acpi_table_parse_madt (enum acpi_madt_entry_id id, acpi_madt_entry_handler handler, unsigned int max_entries);
  341. int acpi_table_parse_srat (enum acpi_srat_entry_id id, acpi_madt_entry_handler handler, unsigned int max_entries);
  342. int acpi_parse_mcfg (unsigned long phys_addr, unsigned long size);
  343. void acpi_table_print (struct acpi_table_header *header, unsigned long phys_addr);
  344. void acpi_table_print_madt_entry (acpi_table_entry_header *madt);
  345. void acpi_table_print_srat_entry (acpi_table_entry_header *srat);
  346. /* the following four functions are architecture-dependent */
  347. void acpi_numa_slit_init (struct acpi_table_slit *slit);
  348. void acpi_numa_processor_affinity_init (struct acpi_table_processor_affinity *pa);
  349. void acpi_numa_memory_affinity_init (struct acpi_table_memory_affinity *ma);
  350. void acpi_numa_arch_fixup(void);
  351. #ifdef CONFIG_ACPI_HOTPLUG_CPU
  352. /* Arch dependent functions for cpu hotplug support */
  353. int acpi_map_lsapic(acpi_handle handle, int *pcpu);
  354. int acpi_unmap_lsapic(int cpu);
  355. #endif /* CONFIG_ACPI_HOTPLUG_CPU */
  356. int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base);
  357. int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base);
  358. extern int acpi_mp_config;
  359. extern struct acpi_table_mcfg_config *pci_mmcfg_config;
  360. extern int pci_mmcfg_config_num;
  361. extern int sbf_port ;
  362. #else /*!CONFIG_ACPI_BOOT*/
  363. #define acpi_mp_config 0
  364. static inline int acpi_boot_init(void)
  365. {
  366. return 0;
  367. }
  368. static inline int acpi_boot_table_init(void)
  369. {
  370. return 0;
  371. }
  372. #endif /*!CONFIG_ACPI_BOOT*/
  373. unsigned int acpi_register_gsi (u32 gsi, int edge_level, int active_high_low);
  374. int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
  375. /*
  376. * This function undoes the effect of one call to acpi_register_gsi().
  377. * If this matches the last registration, any IRQ resources for gsi
  378. * are freed.
  379. */
  380. #ifdef CONFIG_ACPI_DEALLOCATE_IRQ
  381. void acpi_unregister_gsi (u32 gsi);
  382. #endif
  383. #ifdef CONFIG_ACPI_PCI
  384. struct acpi_prt_entry {
  385. struct list_head node;
  386. struct acpi_pci_id id;
  387. u8 pin;
  388. struct {
  389. acpi_handle handle;
  390. u32 index;
  391. } link;
  392. u32 irq;
  393. };
  394. struct acpi_prt_list {
  395. int count;
  396. struct list_head entries;
  397. };
  398. struct pci_dev;
  399. int acpi_pci_irq_enable (struct pci_dev *dev);
  400. void acpi_penalize_isa_irq(int irq);
  401. #ifdef CONFIG_ACPI_DEALLOCATE_IRQ
  402. void acpi_pci_irq_disable (struct pci_dev *dev);
  403. #endif
  404. struct acpi_pci_driver {
  405. struct acpi_pci_driver *next;
  406. int (*add)(acpi_handle handle);
  407. void (*remove)(acpi_handle handle);
  408. };
  409. int acpi_pci_register_driver(struct acpi_pci_driver *driver);
  410. void acpi_pci_unregister_driver(struct acpi_pci_driver *driver);
  411. #endif /*CONFIG_ACPI_PCI*/
  412. #ifdef CONFIG_ACPI_EC
  413. extern int ec_read(u8 addr, u8 *val);
  414. extern int ec_write(u8 addr, u8 val);
  415. #endif /*CONFIG_ACPI_EC*/
  416. #ifdef CONFIG_ACPI_INTERPRETER
  417. extern int acpi_blacklisted(void);
  418. extern void acpi_bios_year(char *s);
  419. #else /*!CONFIG_ACPI_INTERPRETER*/
  420. static inline int acpi_blacklisted(void)
  421. {
  422. return 0;
  423. }
  424. #endif /*!CONFIG_ACPI_INTERPRETER*/
  425. #define ACPI_CSTATE_LIMIT_DEFINED /* for driver builds */
  426. #ifdef CONFIG_ACPI
  427. /*
  428. * Set highest legal C-state
  429. * 0: C0 okay, but not C1
  430. * 1: C1 okay, but not C2
  431. * 2: C2 okay, but not C3 etc.
  432. */
  433. extern unsigned int max_cstate;
  434. static inline unsigned int acpi_get_cstate_limit(void)
  435. {
  436. return max_cstate;
  437. }
  438. static inline void acpi_set_cstate_limit(unsigned int new_limit)
  439. {
  440. max_cstate = new_limit;
  441. return;
  442. }
  443. #else
  444. static inline unsigned int acpi_get_cstate_limit(void) { return 0; }
  445. static inline void acpi_set_cstate_limit(unsigned int new_limit) { return; }
  446. #endif
  447. #ifdef CONFIG_ACPI_NUMA
  448. int acpi_get_pxm(acpi_handle handle);
  449. #else
  450. static inline int acpi_get_pxm(acpi_handle handle)
  451. {
  452. return 0;
  453. }
  454. #endif
  455. extern int pnpacpi_disabled;
  456. #endif /* CONFIG_ACPI */
  457. #endif /*_LINUX_ACPI_H*/