acparser.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. /******************************************************************************
  2. *
  3. * Module Name: acparser.h - AML Parser subcomponent prototypes and defines
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2015, Intel Corp.
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions, and the following disclaimer,
  15. * without modification.
  16. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  17. * substantially similar to the "NO WARRANTY" disclaimer below
  18. * ("Disclaimer") and any redistribution must be conditioned upon
  19. * including a substantially similar Disclaimer requirement for further
  20. * binary redistribution.
  21. * 3. Neither the names of the above-listed copyright holders nor the names
  22. * of any contributors may be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * Alternatively, this software may be distributed under the terms of the
  26. * GNU General Public License ("GPL") version 2 as published by the Free
  27. * Software Foundation.
  28. *
  29. * NO WARRANTY
  30. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  31. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  32. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  33. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  34. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  35. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  36. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  37. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  38. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  39. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  40. * POSSIBILITY OF SUCH DAMAGES.
  41. */
  42. #ifndef __ACPARSER_H__
  43. #define __ACPARSER_H__
  44. #define OP_HAS_RETURN_VALUE 1
  45. /* Variable number of arguments. This field must be 32 bits */
  46. #define ACPI_VAR_ARGS ACPI_UINT32_MAX
  47. #define ACPI_PARSE_DELETE_TREE 0x0001
  48. #define ACPI_PARSE_NO_TREE_DELETE 0x0000
  49. #define ACPI_PARSE_TREE_MASK 0x0001
  50. #define ACPI_PARSE_LOAD_PASS1 0x0010
  51. #define ACPI_PARSE_LOAD_PASS2 0x0020
  52. #define ACPI_PARSE_EXECUTE 0x0030
  53. #define ACPI_PARSE_MODE_MASK 0x0030
  54. #define ACPI_PARSE_DEFERRED_OP 0x0100
  55. #define ACPI_PARSE_DISASSEMBLE 0x0200
  56. #define ACPI_PARSE_MODULE_LEVEL 0x0400
  57. /******************************************************************************
  58. *
  59. * Parser interfaces
  60. *
  61. *****************************************************************************/
  62. extern const UINT8 AcpiGbl_ShortOpIndex[];
  63. extern const UINT8 AcpiGbl_LongOpIndex[];
  64. /*
  65. * psxface - Parser external interfaces
  66. */
  67. ACPI_STATUS
  68. AcpiPsExecuteMethod (
  69. ACPI_EVALUATE_INFO *Info);
  70. /*
  71. * psargs - Parse AML opcode arguments
  72. */
  73. UINT8 *
  74. AcpiPsGetNextPackageEnd (
  75. ACPI_PARSE_STATE *ParserState);
  76. char *
  77. AcpiPsGetNextNamestring (
  78. ACPI_PARSE_STATE *ParserState);
  79. void
  80. AcpiPsGetNextSimpleArg (
  81. ACPI_PARSE_STATE *ParserState,
  82. UINT32 ArgType,
  83. ACPI_PARSE_OBJECT *Arg);
  84. ACPI_STATUS
  85. AcpiPsGetNextNamepath (
  86. ACPI_WALK_STATE *WalkState,
  87. ACPI_PARSE_STATE *ParserState,
  88. ACPI_PARSE_OBJECT *Arg,
  89. BOOLEAN PossibleMethodCall);
  90. /* Values for BOOLEAN above */
  91. #define ACPI_NOT_METHOD_CALL FALSE
  92. #define ACPI_POSSIBLE_METHOD_CALL TRUE
  93. ACPI_STATUS
  94. AcpiPsGetNextArg (
  95. ACPI_WALK_STATE *WalkState,
  96. ACPI_PARSE_STATE *ParserState,
  97. UINT32 ArgType,
  98. ACPI_PARSE_OBJECT **ReturnArg);
  99. /*
  100. * psfind
  101. */
  102. ACPI_PARSE_OBJECT *
  103. AcpiPsFindName (
  104. ACPI_PARSE_OBJECT *Scope,
  105. UINT32 Name,
  106. UINT32 Opcode);
  107. ACPI_PARSE_OBJECT*
  108. AcpiPsGetParent (
  109. ACPI_PARSE_OBJECT *Op);
  110. /*
  111. * psobject - support for parse object processing
  112. */
  113. ACPI_STATUS
  114. AcpiPsBuildNamedOp (
  115. ACPI_WALK_STATE *WalkState,
  116. UINT8 *AmlOpStart,
  117. ACPI_PARSE_OBJECT *UnnamedOp,
  118. ACPI_PARSE_OBJECT **Op);
  119. ACPI_STATUS
  120. AcpiPsCreateOp (
  121. ACPI_WALK_STATE *WalkState,
  122. UINT8 *AmlOpStart,
  123. ACPI_PARSE_OBJECT **NewOp);
  124. ACPI_STATUS
  125. AcpiPsCompleteOp (
  126. ACPI_WALK_STATE *WalkState,
  127. ACPI_PARSE_OBJECT **Op,
  128. ACPI_STATUS Status);
  129. ACPI_STATUS
  130. AcpiPsCompleteFinalOp (
  131. ACPI_WALK_STATE *WalkState,
  132. ACPI_PARSE_OBJECT *Op,
  133. ACPI_STATUS Status);
  134. /*
  135. * psopinfo - AML Opcode information
  136. */
  137. const ACPI_OPCODE_INFO *
  138. AcpiPsGetOpcodeInfo (
  139. UINT16 Opcode);
  140. char *
  141. AcpiPsGetOpcodeName (
  142. UINT16 Opcode);
  143. UINT8
  144. AcpiPsGetArgumentCount (
  145. UINT32 OpType);
  146. /*
  147. * psparse - top level parsing routines
  148. */
  149. ACPI_STATUS
  150. AcpiPsParseAml (
  151. ACPI_WALK_STATE *WalkState);
  152. UINT32
  153. AcpiPsGetOpcodeSize (
  154. UINT32 Opcode);
  155. UINT16
  156. AcpiPsPeekOpcode (
  157. ACPI_PARSE_STATE *state);
  158. ACPI_STATUS
  159. AcpiPsCompleteThisOp (
  160. ACPI_WALK_STATE *WalkState,
  161. ACPI_PARSE_OBJECT *Op);
  162. ACPI_STATUS
  163. AcpiPsNextParseState (
  164. ACPI_WALK_STATE *WalkState,
  165. ACPI_PARSE_OBJECT *Op,
  166. ACPI_STATUS CallbackStatus);
  167. /*
  168. * psloop - main parse loop
  169. */
  170. ACPI_STATUS
  171. AcpiPsParseLoop (
  172. ACPI_WALK_STATE *WalkState);
  173. /*
  174. * psscope - Scope stack management routines
  175. */
  176. ACPI_STATUS
  177. AcpiPsInitScope (
  178. ACPI_PARSE_STATE *ParserState,
  179. ACPI_PARSE_OBJECT *Root);
  180. ACPI_PARSE_OBJECT *
  181. AcpiPsGetParentScope (
  182. ACPI_PARSE_STATE *state);
  183. BOOLEAN
  184. AcpiPsHasCompletedScope (
  185. ACPI_PARSE_STATE *ParserState);
  186. void
  187. AcpiPsPopScope (
  188. ACPI_PARSE_STATE *ParserState,
  189. ACPI_PARSE_OBJECT **Op,
  190. UINT32 *ArgList,
  191. UINT32 *ArgCount);
  192. ACPI_STATUS
  193. AcpiPsPushScope (
  194. ACPI_PARSE_STATE *ParserState,
  195. ACPI_PARSE_OBJECT *Op,
  196. UINT32 RemainingArgs,
  197. UINT32 ArgCount);
  198. void
  199. AcpiPsCleanupScope (
  200. ACPI_PARSE_STATE *state);
  201. /*
  202. * pstree - parse tree manipulation routines
  203. */
  204. void
  205. AcpiPsAppendArg(
  206. ACPI_PARSE_OBJECT *op,
  207. ACPI_PARSE_OBJECT *arg);
  208. ACPI_PARSE_OBJECT*
  209. AcpiPsFind (
  210. ACPI_PARSE_OBJECT *Scope,
  211. char *Path,
  212. UINT16 Opcode,
  213. UINT32 Create);
  214. ACPI_PARSE_OBJECT *
  215. AcpiPsGetArg(
  216. ACPI_PARSE_OBJECT *op,
  217. UINT32 argn);
  218. ACPI_PARSE_OBJECT *
  219. AcpiPsGetDepthNext (
  220. ACPI_PARSE_OBJECT *Origin,
  221. ACPI_PARSE_OBJECT *Op);
  222. /*
  223. * pswalk - parse tree walk routines
  224. */
  225. ACPI_STATUS
  226. AcpiPsWalkParsedAml (
  227. ACPI_PARSE_OBJECT *StartOp,
  228. ACPI_PARSE_OBJECT *EndOp,
  229. ACPI_OPERAND_OBJECT *MthDesc,
  230. ACPI_NAMESPACE_NODE *StartNode,
  231. ACPI_OPERAND_OBJECT **Params,
  232. ACPI_OPERAND_OBJECT **CallerReturnDesc,
  233. ACPI_OWNER_ID OwnerId,
  234. ACPI_PARSE_DOWNWARDS DescendingCallback,
  235. ACPI_PARSE_UPWARDS AscendingCallback);
  236. ACPI_STATUS
  237. AcpiPsGetNextWalkOp (
  238. ACPI_WALK_STATE *WalkState,
  239. ACPI_PARSE_OBJECT *Op,
  240. ACPI_PARSE_UPWARDS AscendingCallback);
  241. ACPI_STATUS
  242. AcpiPsDeleteCompletedOp (
  243. ACPI_WALK_STATE *WalkState);
  244. void
  245. AcpiPsDeleteParseTree (
  246. ACPI_PARSE_OBJECT *root);
  247. /*
  248. * psutils - parser utilities
  249. */
  250. ACPI_PARSE_OBJECT *
  251. AcpiPsCreateScopeOp (
  252. UINT8 *Aml);
  253. void
  254. AcpiPsInitOp (
  255. ACPI_PARSE_OBJECT *op,
  256. UINT16 opcode);
  257. ACPI_PARSE_OBJECT *
  258. AcpiPsAllocOp (
  259. UINT16 Opcode,
  260. UINT8 *Aml);
  261. void
  262. AcpiPsFreeOp (
  263. ACPI_PARSE_OBJECT *Op);
  264. BOOLEAN
  265. AcpiPsIsLeadingChar (
  266. UINT32 c);
  267. UINT32
  268. AcpiPsGetName(
  269. ACPI_PARSE_OBJECT *op);
  270. void
  271. AcpiPsSetName(
  272. ACPI_PARSE_OBJECT *op,
  273. UINT32 name);
  274. /*
  275. * psdump - display parser tree
  276. */
  277. UINT32
  278. AcpiPsSprintPath (
  279. char *BufferStart,
  280. UINT32 BufferSize,
  281. ACPI_PARSE_OBJECT *Op);
  282. UINT32
  283. AcpiPsSprintOp (
  284. char *BufferStart,
  285. UINT32 BufferSize,
  286. ACPI_PARSE_OBJECT *Op);
  287. void
  288. AcpiPsShow (
  289. ACPI_PARSE_OBJECT *op);
  290. #endif /* __ACPARSER_H__ */