amlos.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. /*++
  2. Copyright (c) 2012 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. amlos.h
  5. Abstract:
  6. This header contains definitions for operating system support functions
  7. provided to the ACPI AML interpreter and namespace.
  8. Author:
  9. Evan Green 13-Nov-2012
  10. --*/
  11. //
  12. // ------------------------------------------------------------------- Includes
  13. //
  14. //
  15. // ---------------------------------------------------------------- Definitions
  16. //
  17. //
  18. // Define ACPI parameter 1 crash codes.
  19. //
  20. #define ACPI_CRASH_FATAL_INSTRUCTION 0x00000001
  21. #define ACPI_CRASH_GLOBAL_LOCK_FAILURE 0x00000002
  22. //
  23. // Define the acquire mutex wait value that specifies to wait indefinitely.
  24. //
  25. #define ACPI_MUTEX_WAIT_INDEFINITELY 0xFFFF
  26. //
  27. // ------------------------------------------------------ Data Type Definitions
  28. //
  29. //
  30. // -------------------------------------------------------------------- Globals
  31. //
  32. //
  33. // -------------------------------------------------------- Function Prototypes
  34. //
  35. KSTATUS
  36. AcpipInitializeOperatingSystemAmlSupport (
  37. VOID
  38. );
  39. /*++
  40. Routine Description:
  41. This routine initializes operating system specific support for the AML
  42. interpreter.
  43. Arguments:
  44. None.
  45. Return Value:
  46. Status code.
  47. --*/
  48. PVOID
  49. AcpipAllocateMemory (
  50. ULONG Size
  51. );
  52. /*++
  53. Routine Description:
  54. This routine allocates memory from the operating system for the ACPI
  55. interpreter and namespace.
  56. Arguments:
  57. Size - Supplies the size of the allocation, in bytes.
  58. Return Value:
  59. Returns a pointer to the allocated memory on success.
  60. NULL on failure.
  61. --*/
  62. VOID
  63. AcpipFreeMemory (
  64. PVOID Allocation
  65. );
  66. /*++
  67. Routine Description:
  68. This routine frees memory allocated for the ACPI AML interpreter and
  69. namespace.
  70. Arguments:
  71. Allocation - Supplies a pointer to the allocated memory.
  72. Return Value:
  73. None.
  74. --*/
  75. VOID
  76. AcpipFatalError (
  77. ULONGLONG Parameter1,
  78. ULONGLONG Parameter2,
  79. ULONGLONG Parameter3,
  80. ULONGLONG Parameter4
  81. );
  82. /*++
  83. Routine Description:
  84. This routine takes the system down as gracefully as possible.
  85. Arguments:
  86. Parameter1 - Supplies an optional parameter.
  87. Parameter2 - Supplies an optional parameter.
  88. Parameter3 - Supplies an optional parameter.
  89. Parameter4 - Supplies an optional parameter.
  90. Return Value:
  91. This function does not return.
  92. --*/
  93. VOID
  94. AcpipSleep (
  95. ULONG Milliseconds
  96. );
  97. /*++
  98. Routine Description:
  99. This routine delays the current thread's execution by at least the given
  100. number of milliseconds (the delays can be significantly longer). During this
  101. time, other threads will run.
  102. Arguments:
  103. Milliseconds - Supplies the minimum number of milliseconds to delay.
  104. Return Value:
  105. None.
  106. --*/
  107. VOID
  108. AcpipBusySpin (
  109. ULONG Microseconds
  110. );
  111. /*++
  112. Routine Description:
  113. This routine stalls the current processor by the given number of
  114. microseconds. This routine busy spins, unless preemption occurs no other
  115. threads will run during this delay.
  116. Arguments:
  117. Microseconds - Supplies the minimum number of microseconds to delay.
  118. Return Value:
  119. None.
  120. --*/
  121. ULONGLONG
  122. AcpipGetTimerValue (
  123. );
  124. /*++
  125. Routine Description:
  126. This routine returns a monotomically non-decreasing value representing the
  127. number of hundred nanosecond units that have elapsed since some epoch in
  128. the past (could be system boot).
  129. Arguments:
  130. None.
  131. Return Value:
  132. Returns the number of hundred nanosecond units (10^-7 seconds) that have
  133. elapsed.
  134. --*/
  135. PVOID
  136. AcpipCreateMutex (
  137. ULONG SyncLevel
  138. );
  139. /*++
  140. Routine Description:
  141. This routine creates an operating system mutex object to back an ACPI mutex
  142. used in the AML interpreter.
  143. Arguments:
  144. SyncLevel - Supplies the ACPI-defined sync level of the mutex.
  145. Return Value:
  146. Returns a pointer to the mutex object on success.
  147. NULL on failure.
  148. --*/
  149. VOID
  150. AcpipDestroyMutex (
  151. PVOID Mutex
  152. );
  153. /*++
  154. Routine Description:
  155. This routine destroys an operating system mutex object.
  156. Arguments:
  157. Mutex - Supplies a pointer to the OS mutex object returned during the
  158. create mutex routine.
  159. Return Value:
  160. None.
  161. --*/
  162. BOOL
  163. AcpipAcquireMutex (
  164. PAML_EXECUTION_CONTEXT Context,
  165. PVOID Mutex,
  166. ULONG TimeoutInMilliseconds
  167. );
  168. /*++
  169. Routine Description:
  170. This routine attempts to acquire a mutex object.
  171. Arguments:
  172. Context - Supplies a pointer to the execution context.
  173. Mutex - Supplies a pointer to the mutex to acquire.
  174. TimeoutInMilliseconds - Supplies the number of milliseconds to wait before
  175. returning anyway and timing out (failing the acquire).
  176. Return Value:
  177. TRUE if the timeout occurred and the mutex was not acquired.
  178. FALSE if the mutex was successfully acquired.
  179. --*/
  180. VOID
  181. AcpipReleaseMutex (
  182. PAML_EXECUTION_CONTEXT Context,
  183. PVOID Mutex
  184. );
  185. /*++
  186. Routine Description:
  187. This routine releases an acquired mutex object. This object must have been
  188. successfully acquired using the acquire routine.
  189. Arguments:
  190. Context - Supplies a pointer to the execution context.
  191. Mutex - Supplies a pointer to the mutex to release.
  192. Return Value:
  193. None.
  194. --*/
  195. PVOID
  196. AcpipCreateEvent (
  197. );
  198. /*++
  199. Routine Description:
  200. This routine creates an operating system event object to back an ACPI Event
  201. used in the AML interpreter.
  202. Arguments:
  203. None.
  204. Return Value:
  205. Returns a pointer to the event object on success.
  206. NULL on failure.
  207. --*/
  208. VOID
  209. AcpipDestroyEvent (
  210. PVOID Event
  211. );
  212. /*++
  213. Routine Description:
  214. This routine destroys an operating system event object.
  215. Arguments:
  216. Event - Supplies a pointer to the OS event object returned during the
  217. create event routine.
  218. Return Value:
  219. None.
  220. --*/
  221. BOOL
  222. AcpipWaitForEvent (
  223. PVOID Event,
  224. ULONG TimeoutInMilliseconds
  225. );
  226. /*++
  227. Routine Description:
  228. This routine waits at least the specified number of milliseconds for the
  229. given event object.
  230. Arguments:
  231. Event - Supplies a pointer to the event to wait for.
  232. TimeoutInMilliseconds - Supplies the number of milliseconds to wait before
  233. returning anyway and timing out (failing the wait).
  234. Return Value:
  235. TRUE if the timeout occurred and the event was not acquired.
  236. FALSE if execution continued because the event was signaled.
  237. --*/
  238. VOID
  239. AcpipSignalEvent (
  240. PVOID Event
  241. );
  242. /*++
  243. Routine Description:
  244. This routine signals an event, releasing all parties waiting on it.
  245. Arguments:
  246. Event - Supplies a pointer to the event to signal.
  247. Return Value:
  248. None.
  249. --*/
  250. VOID
  251. AcpipResetEvent (
  252. PVOID Event
  253. );
  254. /*++
  255. Routine Description:
  256. This routine resets an event back to its unsignaled state, causing any
  257. party who subsequently waits on this event to block.
  258. Arguments:
  259. Event - Supplies a pointer to the event to unsignal.
  260. Return Value:
  261. None.
  262. --*/
  263. KSTATUS
  264. AcpipNotifyOperatingSystem (
  265. PACPI_OBJECT Object,
  266. ULONGLONG NotificationValue
  267. );
  268. /*++
  269. Routine Description:
  270. This routine is called by executing AML code to notify the operating system
  271. of something.
  272. Arguments:
  273. Object - Supplies the object generating the notification. This object will
  274. be of type Processor, Thermal Zone, or Device.
  275. NotificationValue - Supplies the type of notification being sent.
  276. Return Value:
  277. Status code.
  278. --*/
  279. VOID
  280. AcpipAcquirePciLock (
  281. );
  282. /*++
  283. Routine Description:
  284. This routine acquires the PCI lock, used to synchronize early access to
  285. PCI configuration space with the PCI driver actually coming online.
  286. Arguments:
  287. None.
  288. Return Value:
  289. None.
  290. --*/
  291. VOID
  292. AcpipReleasePciLock (
  293. );
  294. /*++
  295. Routine Description:
  296. This routine releases the PCI lock, used to synchronize early access to
  297. PCI configuration space with the PCI driver actually coming online.
  298. Arguments:
  299. None.
  300. Return Value:
  301. None.
  302. --*/