acpi.h 10 KB

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