acpi.h 13 KB

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