acpiosxf.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
  2. /******************************************************************************
  3. *
  4. * Name: acpiosxf.h - All interfaces to the OS Services Layer (OSL). These
  5. * interfaces must be implemented by OSL to interface the
  6. * ACPI components to the host operating system.
  7. *
  8. * Copyright (C) 2000 - 2020, Intel Corp.
  9. *
  10. *****************************************************************************/
  11. #ifndef __ACPIOSXF_H__
  12. #define __ACPIOSXF_H__
  13. #include <acpi/platform/acenv.h>
  14. #include <acpi/actypes.h>
  15. /* Types for acpi_os_execute */
  16. typedef enum {
  17. OSL_GLOBAL_LOCK_HANDLER,
  18. OSL_NOTIFY_HANDLER,
  19. OSL_GPE_HANDLER,
  20. OSL_DEBUGGER_MAIN_THREAD,
  21. OSL_DEBUGGER_EXEC_THREAD,
  22. OSL_EC_POLL_HANDLER,
  23. OSL_EC_BURST_HANDLER
  24. } acpi_execute_type;
  25. #define ACPI_NO_UNIT_LIMIT ((u32) -1)
  26. #define ACPI_MUTEX_SEM 1
  27. /* Functions for acpi_os_signal */
  28. #define ACPI_SIGNAL_FATAL 0
  29. #define ACPI_SIGNAL_BREAKPOINT 1
  30. struct acpi_signal_fatal_info {
  31. u32 type;
  32. u32 code;
  33. u32 argument;
  34. };
  35. /*
  36. * OSL Initialization and shutdown primitives
  37. */
  38. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize
  39. acpi_status acpi_os_initialize(void);
  40. #endif
  41. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate
  42. acpi_status acpi_os_terminate(void);
  43. #endif
  44. /*
  45. * ACPI Table interfaces
  46. */
  47. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_root_pointer
  48. acpi_physical_address acpi_os_get_root_pointer(void);
  49. #endif
  50. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_predefined_override
  51. acpi_status
  52. acpi_os_predefined_override(const struct acpi_predefined_names *init_val,
  53. acpi_string *new_val);
  54. #endif
  55. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_table_override
  56. acpi_status
  57. acpi_os_table_override(struct acpi_table_header *existing_table,
  58. struct acpi_table_header **new_table);
  59. #endif
  60. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_physical_table_override
  61. acpi_status
  62. acpi_os_physical_table_override(struct acpi_table_header *existing_table,
  63. acpi_physical_address *new_address,
  64. u32 *new_table_length);
  65. #endif
  66. /*
  67. * Spinlock primitives
  68. */
  69. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_lock
  70. acpi_status acpi_os_create_lock(acpi_spinlock * out_handle);
  71. #endif
  72. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_delete_lock
  73. void acpi_os_delete_lock(acpi_spinlock handle);
  74. #endif
  75. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_lock
  76. acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock handle);
  77. #endif
  78. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_release_lock
  79. void acpi_os_release_lock(acpi_spinlock handle, acpi_cpu_flags flags);
  80. #endif
  81. /*
  82. * RAW spinlock primitives. If the OS does not provide them, fallback to
  83. * spinlock primitives
  84. */
  85. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_raw_lock
  86. # define acpi_os_create_raw_lock(out_handle) acpi_os_create_lock(out_handle)
  87. #endif
  88. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_delete_raw_lock
  89. # define acpi_os_delete_raw_lock(handle) acpi_os_delete_lock(handle)
  90. #endif
  91. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_raw_lock
  92. # define acpi_os_acquire_raw_lock(handle) acpi_os_acquire_lock(handle)
  93. #endif
  94. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_release_raw_lock
  95. # define acpi_os_release_raw_lock(handle, flags) \
  96. acpi_os_release_lock(handle, flags)
  97. #endif
  98. /*
  99. * Semaphore primitives
  100. */
  101. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_semaphore
  102. acpi_status
  103. acpi_os_create_semaphore(u32 max_units,
  104. u32 initial_units, acpi_semaphore * out_handle);
  105. #endif
  106. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_delete_semaphore
  107. acpi_status acpi_os_delete_semaphore(acpi_semaphore handle);
  108. #endif
  109. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_wait_semaphore
  110. acpi_status
  111. acpi_os_wait_semaphore(acpi_semaphore handle, u32 units, u16 timeout);
  112. #endif
  113. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_signal_semaphore
  114. acpi_status acpi_os_signal_semaphore(acpi_semaphore handle, u32 units);
  115. #endif
  116. /*
  117. * Mutex primitives. May be configured to use semaphores instead via
  118. * ACPI_MUTEX_TYPE (see platform/acenv.h)
  119. */
  120. #if (ACPI_MUTEX_TYPE != ACPI_BINARY_SEMAPHORE)
  121. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_mutex
  122. acpi_status acpi_os_create_mutex(acpi_mutex * out_handle);
  123. #endif
  124. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_delete_mutex
  125. void acpi_os_delete_mutex(acpi_mutex handle);
  126. #endif
  127. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_mutex
  128. acpi_status acpi_os_acquire_mutex(acpi_mutex handle, u16 timeout);
  129. #endif
  130. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_release_mutex
  131. void acpi_os_release_mutex(acpi_mutex handle);
  132. #endif
  133. #endif
  134. /*
  135. * Memory allocation and mapping
  136. */
  137. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate
  138. void *acpi_os_allocate(acpi_size size);
  139. #endif
  140. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate_zeroed
  141. void *acpi_os_allocate_zeroed(acpi_size size);
  142. #endif
  143. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_free
  144. void acpi_os_free(void *memory);
  145. #endif
  146. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_map_memory
  147. void *acpi_os_map_memory(acpi_physical_address where, acpi_size length);
  148. #endif
  149. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_unmap_memory
  150. void acpi_os_unmap_memory(void *logical_address, acpi_size size);
  151. #endif
  152. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_physical_address
  153. acpi_status
  154. acpi_os_get_physical_address(void *logical_address,
  155. acpi_physical_address *physical_address);
  156. #endif
  157. /*
  158. * Memory/Object Cache
  159. */
  160. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_cache
  161. acpi_status
  162. acpi_os_create_cache(char *cache_name,
  163. u16 object_size,
  164. u16 max_depth, acpi_cache_t ** return_cache);
  165. #endif
  166. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_delete_cache
  167. acpi_status acpi_os_delete_cache(acpi_cache_t * cache);
  168. #endif
  169. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_purge_cache
  170. acpi_status acpi_os_purge_cache(acpi_cache_t * cache);
  171. #endif
  172. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_object
  173. void *acpi_os_acquire_object(acpi_cache_t * cache);
  174. #endif
  175. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_release_object
  176. acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object);
  177. #endif
  178. /*
  179. * Interrupt handlers
  180. */
  181. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_install_interrupt_handler
  182. acpi_status
  183. acpi_os_install_interrupt_handler(u32 interrupt_number,
  184. acpi_osd_handler service_routine,
  185. void *context);
  186. #endif
  187. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_remove_interrupt_handler
  188. acpi_status
  189. acpi_os_remove_interrupt_handler(u32 interrupt_number,
  190. acpi_osd_handler service_routine);
  191. #endif
  192. /*
  193. * Threads and Scheduling
  194. */
  195. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_thread_id
  196. acpi_thread_id acpi_os_get_thread_id(void);
  197. #endif
  198. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_execute
  199. acpi_status
  200. acpi_os_execute(acpi_execute_type type,
  201. acpi_osd_exec_callback function, void *context);
  202. #endif
  203. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_wait_events_complete
  204. void acpi_os_wait_events_complete(void);
  205. #endif
  206. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_sleep
  207. void acpi_os_sleep(u64 milliseconds);
  208. #endif
  209. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_stall
  210. void acpi_os_stall(u32 microseconds);
  211. #endif
  212. /*
  213. * Platform and hardware-independent I/O interfaces
  214. */
  215. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_read_port
  216. acpi_status acpi_os_read_port(acpi_io_address address, u32 *value, u32 width);
  217. #endif
  218. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_write_port
  219. acpi_status acpi_os_write_port(acpi_io_address address, u32 value, u32 width);
  220. #endif
  221. /*
  222. * Platform and hardware-independent physical memory interfaces
  223. */
  224. int acpi_os_read_iomem(void __iomem *virt_addr, u64 *value, u32 width);
  225. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_read_memory
  226. acpi_status
  227. acpi_os_read_memory(acpi_physical_address address, u64 *value, u32 width);
  228. #endif
  229. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_write_memory
  230. acpi_status
  231. acpi_os_write_memory(acpi_physical_address address, u64 value, u32 width);
  232. #endif
  233. /*
  234. * Platform and hardware-independent PCI configuration space access
  235. * Note: Can't use "Register" as a parameter, changed to "Reg" --
  236. * certain compilers complain.
  237. */
  238. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_read_pci_configuration
  239. acpi_status
  240. acpi_os_read_pci_configuration(struct acpi_pci_id *pci_id,
  241. u32 reg, u64 *value, u32 width);
  242. #endif
  243. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_write_pci_configuration
  244. acpi_status
  245. acpi_os_write_pci_configuration(struct acpi_pci_id *pci_id,
  246. u32 reg, u64 value, u32 width);
  247. #endif
  248. /*
  249. * Miscellaneous
  250. */
  251. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_readable
  252. u8 acpi_os_readable(void *pointer, acpi_size length);
  253. #endif
  254. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_writable
  255. u8 acpi_os_writable(void *pointer, acpi_size length);
  256. #endif
  257. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_timer
  258. u64 acpi_os_get_timer(void);
  259. #endif
  260. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_signal
  261. acpi_status acpi_os_signal(u32 function, void *info);
  262. #endif
  263. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_enter_sleep
  264. acpi_status acpi_os_enter_sleep(u8 sleep_state, u32 rega_value, u32 regb_value);
  265. #endif
  266. /*
  267. * Debug print routines
  268. */
  269. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_printf
  270. ACPI_PRINTF_LIKE(1)
  271. void ACPI_INTERNAL_VAR_XFACE acpi_os_printf(const char *format, ...);
  272. #endif
  273. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_vprintf
  274. void acpi_os_vprintf(const char *format, va_list args);
  275. #endif
  276. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_redirect_output
  277. void acpi_os_redirect_output(void *destination);
  278. #endif
  279. /*
  280. * Debug IO
  281. */
  282. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_line
  283. acpi_status acpi_os_get_line(char *buffer, u32 buffer_length, u32 *bytes_read);
  284. #endif
  285. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize_debugger
  286. acpi_status acpi_os_initialize_debugger(void);
  287. #endif
  288. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate_debugger
  289. void acpi_os_terminate_debugger(void);
  290. #endif
  291. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_wait_command_ready
  292. acpi_status acpi_os_wait_command_ready(void);
  293. #endif
  294. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_notify_command_complete
  295. acpi_status acpi_os_notify_command_complete(void);
  296. #endif
  297. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_trace_point
  298. void
  299. acpi_os_trace_point(acpi_trace_event_type type,
  300. u8 begin, u8 *aml, char *pathname);
  301. #endif
  302. /*
  303. * Obtain ACPI table(s)
  304. */
  305. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_name
  306. acpi_status
  307. acpi_os_get_table_by_name(char *signature,
  308. u32 instance,
  309. struct acpi_table_header **table,
  310. acpi_physical_address *address);
  311. #endif
  312. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_index
  313. acpi_status
  314. acpi_os_get_table_by_index(u32 index,
  315. struct acpi_table_header **table,
  316. u32 *instance, acpi_physical_address *address);
  317. #endif
  318. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_address
  319. acpi_status
  320. acpi_os_get_table_by_address(acpi_physical_address address,
  321. struct acpi_table_header **table);
  322. #endif
  323. /*
  324. * Directory manipulation
  325. */
  326. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_open_directory
  327. void *acpi_os_open_directory(char *pathname,
  328. char *wildcard_spec, char requested_file_type);
  329. #endif
  330. /* requeste_file_type values */
  331. #define REQUEST_FILE_ONLY 0
  332. #define REQUEST_DIR_ONLY 1
  333. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_next_filename
  334. char *acpi_os_get_next_filename(void *dir_handle);
  335. #endif
  336. #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_close_directory
  337. void acpi_os_close_directory(void *dir_handle);
  338. #endif
  339. #endif /* __ACPIOSXF_H__ */