acpi.h 12 KB

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