namespce.h 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. /*++
  2. Copyright (c) 2012 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. namespce.h
  5. Abstract:
  6. This header contains definitions for the ACPI namespace.
  7. Author:
  8. Evan Green 13-Nov-2012
  9. --*/
  10. //
  11. // ------------------------------------------------------------------- Includes
  12. //
  13. //
  14. // ---------------------------------------------------------------- Definitions
  15. //
  16. //
  17. // Define special character to the namespace.
  18. //
  19. #define ACPI_NAMESPACE_ROOT_CHARACTER '\\'
  20. #define ACPI_NAMESPACE_PARENT_CHARACTER '^'
  21. //
  22. // Define the maximum length of an ACPI name.
  23. //
  24. #define ACPI_MAX_NAME_LENGTH 4
  25. //
  26. // Define the length of an EISA ID string after being decoded, including the
  27. // NULL terminator.
  28. //
  29. #define EISA_ID_STRING_LENGTH 8
  30. //
  31. // Define the device ID that processor objects are converted to.
  32. //
  33. #define ACPI_PROCESSOR_DEVICE_ID "ACPI0007"
  34. //
  35. // ------------------------------------------------------ Data Type Definitions
  36. //
  37. //
  38. // -------------------------------------------------------------------- Globals
  39. //
  40. //
  41. // -------------------------------------------------------- Function Prototypes
  42. //
  43. KSTATUS
  44. AcpipInitializeNamespace (
  45. VOID
  46. );
  47. /*++
  48. Routine Description:
  49. This routine initializes the ACPI global namespace.
  50. Arguments:
  51. None.
  52. Return Value:
  53. Status code.
  54. --*/
  55. PACPI_OBJECT
  56. AcpipGetNamespaceRoot (
  57. VOID
  58. );
  59. /*++
  60. Routine Description:
  61. This routine returns the namespace root object. This routine does not
  62. modify the reference count of the object.
  63. Arguments:
  64. None.
  65. Return Value:
  66. Returns a pointer to the ACPI object on success.
  67. NULL on failure.
  68. --*/
  69. PACPI_OBJECT
  70. AcpipGetSystemBusRoot (
  71. VOID
  72. );
  73. /*++
  74. Routine Description:
  75. This routine returns the system bus namespace object at \_SB. This routine
  76. does not modify the reference count of the object.
  77. Arguments:
  78. None.
  79. Return Value:
  80. Returns a pointer to the ACPI object on success.
  81. NULL on failure.
  82. --*/
  83. PACPI_OBJECT
  84. AcpipGetProcessorRoot (
  85. VOID
  86. );
  87. /*++
  88. Routine Description:
  89. This routine returns the processor namespace directory at \_PR. This
  90. routine does not modify the reference count of the object.
  91. Arguments:
  92. None.
  93. Return Value:
  94. Returns a pointer to the ACPI object on success.
  95. NULL on failure.
  96. --*/
  97. PACPI_OBJECT
  98. AcpipFindNamedObject (
  99. PACPI_OBJECT ParentObject,
  100. ULONG Name
  101. );
  102. /*++
  103. Routine Description:
  104. This routine attempts to find and return an object of the given name under
  105. a given namespace object.
  106. Arguments:
  107. ParentObject - Supplies a pointer to the namespace object whose children
  108. should be searched.
  109. Name - Supplies the name of the object to search for.
  110. Return Value:
  111. Returns a pointer to the ACPI object on success. Its reference count is not
  112. incremented.
  113. NULL on failure.
  114. --*/
  115. PACPI_OBJECT
  116. AcpipCreateNamespaceObject (
  117. PAML_EXECUTION_CONTEXT Context,
  118. ACPI_OBJECT_TYPE Type,
  119. PSTR Name,
  120. PVOID Buffer,
  121. ULONG BufferSize
  122. );
  123. /*++
  124. Routine Description:
  125. This routine creates an ACPI namespace object.
  126. Arguments:
  127. Context - Supplies a pointer to the ACPI execution context. If the name
  128. parameter is supplied, this parameter is required. Otherwise, it is
  129. optional.
  130. Type - Supplies the type of namespace object to create.
  131. Name - Supplies the name string of the object. Supply NULL to create a
  132. nameless object.
  133. Buffer - Supplies a pointer to a buffer that is used in different ways
  134. depending on the type being created.
  135. BufferSize - Supplies a buffer size that is used in different ways depending
  136. on the type of object being created. If NULL is passed in but a non-zero
  137. buffer size is supplied, a zero-filled buffer of the given size will be
  138. created. For string buffers, the size includes the null terminator.
  139. Return Value:
  140. Returns a pointer to the ACPI object on success.
  141. NULL on failure.
  142. --*/
  143. VOID
  144. AcpipObjectAddReference (
  145. PACPI_OBJECT Object
  146. );
  147. /*++
  148. Routine Description:
  149. This routine adds one to the reference count of a given ACPI object.
  150. Arguments:
  151. Object - Supplies a pointer to the object.
  152. Return Value:
  153. None.
  154. --*/
  155. VOID
  156. AcpipObjectReleaseReference (
  157. PACPI_OBJECT Object
  158. );
  159. /*++
  160. Routine Description:
  161. This routine subtracts one from the reference count of the given object. If
  162. this causes the reference count to hit zero, the object will be destroyed.
  163. Arguments:
  164. Object - Supplies a pointer to the object.
  165. Return Value:
  166. None.
  167. --*/
  168. PACPI_OBJECT
  169. AcpipGetNamespaceObject (
  170. PSTR Name,
  171. PACPI_OBJECT CurrentScope
  172. );
  173. /*++
  174. Routine Description:
  175. This routine looks up an ACPI object in the namespace based on a location
  176. string.
  177. Arguments:
  178. Name - Supplies a pointer to a string containing the namespace path.
  179. CurrentScope - Supplies a pointer to the current namespace scope. If NULL
  180. is supplied, the global root namespace will be used.
  181. Return Value:
  182. Returns a pointer to the ACPI object on success.
  183. NULL if the object could not be found.
  184. --*/
  185. PACPI_OBJECT *
  186. AcpipEnumerateChildObjects (
  187. PACPI_OBJECT ParentObject,
  188. ACPI_OBJECT_TYPE ObjectType,
  189. PULONG ObjectCount
  190. );
  191. /*++
  192. Routine Description:
  193. This routine allocates and initializes an array containing pointers to the
  194. children of the given namespace object, optionally filtering out only
  195. objects of a given type.
  196. Arguments:
  197. ParentObject - Supplies a pointer to the parent whose children should be
  198. enumerated.
  199. ObjectType - Supplies an object type. If a valid object type is supplied,
  200. then only objects of that type will be returned. Supply
  201. AcpiObjectTypeCount to return all objects.
  202. ObjectCount - Supplies a pointer where the number of elements in the return
  203. array will be returned.
  204. Return Value:
  205. Returns a pointer to an array of pointers to the child object. The caller
  206. must call the corresponding release enumeration list to free the memory
  207. allocated by this routine.
  208. NULL if there are no objects or there was an error.
  209. --*/
  210. VOID
  211. AcpipReleaseChildEnumerationArray (
  212. PACPI_OBJECT *Objects,
  213. ULONG ObjectCount
  214. );
  215. /*++
  216. Routine Description:
  217. This routine releases a list returned as a result of calling the enumerate
  218. child objects routine.
  219. Arguments:
  220. Objects - Supplies a pointer to the array of objects, as returned from
  221. the enumerate child objects routine.
  222. ObjectCount - Supplies the number of elements in the array, as returned
  223. from the enumerate child objects routine.
  224. Return Value:
  225. None.
  226. --*/
  227. VOID
  228. AcpipConvertEisaIdToString (
  229. ULONG EisaId,
  230. PSTR ResultIdString
  231. );
  232. /*++
  233. Routine Description:
  234. This routine converts an EISA encoded ID into a device ID string.
  235. Arguments:
  236. EisaId - Supplies the encoded EISA ID to get.
  237. ResultIdString - Supplies a pointer where the decoded result string will
  238. be returned. This buffer must be allocated by the caller, and must be
  239. at least 8 bytes long.
  240. Return Value:
  241. Returns a pointer to a string, allocated using the AML interpreter
  242. allocation routines. The caller is responsible for freeing this memory.
  243. --*/
  244. KSTATUS
  245. AcpipPerformStoreOperation (
  246. PAML_EXECUTION_CONTEXT Context,
  247. PACPI_OBJECT Source,
  248. PACPI_OBJECT Destination
  249. );
  250. /*++
  251. Routine Description:
  252. This routine performs a store operation from one object into the value of
  253. another.
  254. Arguments:
  255. Context - Supplies a pointer to the current AML execution context.
  256. Source - Supplies a pointer to the source object for the store.
  257. Destination - Supplies a pointer to the object to store the value into.
  258. Return Value:
  259. Status code.
  260. --*/
  261. PACPI_OBJECT
  262. AcpipCopyObject (
  263. PACPI_OBJECT Object
  264. );
  265. /*++
  266. Routine Description:
  267. This routine creates an unnamed and unlinked copy of the given object.
  268. Arguments:
  269. Object - Supplies a pointer to the object whose contents should be copied.
  270. Return Value:
  271. Returns a pointer to the new copy on success.
  272. NULL on failure.
  273. --*/
  274. KSTATUS
  275. AcpipReplaceObjectContents (
  276. PAML_EXECUTION_CONTEXT Context,
  277. PACPI_OBJECT ObjectToReplace,
  278. PACPI_OBJECT ObjectWithContents
  279. );
  280. /*++
  281. Routine Description:
  282. This routine replaces the inner contents of an object with a copy of those
  283. from a different object.
  284. Arguments:
  285. Context - Supplies a pointer to the AML execution context.
  286. ObjectToReplace - Supplies a pointer to an object whose contents should be
  287. replaced.
  288. ObjectWithContents - Supplies a pointer to the object that has the contents
  289. to use for replacement.
  290. Return Value:
  291. STATUS_SUCCESS if the object to replace successfully became a copy of the
  292. object with contents (on everything except its name, position in the
  293. namespace, and actual pointer).
  294. STATUS_INSUFFICIENT_RESOURCES if the space needed to replace the contents
  295. could not be allocated. In this case, the object to be replaced will
  296. remain unchanged.
  297. Other error codes on other failures. On failure, the object to replace will
  298. remain unchanged.
  299. --*/
  300. PACPI_OBJECT
  301. AcpipGetPackageObject (
  302. PACPI_OBJECT Package,
  303. ULONG Index
  304. );
  305. /*++
  306. Routine Description:
  307. This routine returns the object at a given index in a package.
  308. Arguments:
  309. Package - Supplies a pointer to the package to read from.
  310. Index - Supplies the index of the element to get.
  311. Return Value:
  312. Returns a pointer to the element in the package at the given index.
  313. NULL on error, either if too large of an index was specified, or there is
  314. no value at that index.
  315. --*/
  316. VOID
  317. AcpipSetPackageObject (
  318. PACPI_OBJECT Package,
  319. ULONG Index,
  320. PACPI_OBJECT Object
  321. );
  322. /*++
  323. Routine Description:
  324. This routine sets the object in a package at a given index.
  325. Arguments:
  326. Package - Supplies a pointer to the package to modify.
  327. Index - Supplies the index of the element to set.
  328. Object - Supplies the object to set at Package[Index]. This can be NULL.
  329. Return Value:
  330. None.
  331. --*/