acparser.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. /******************************************************************************
  2. *
  3. * Module Name: acparser.h - AML Parser subcomponent prototypes and defines
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2005, R. Byron Moore
  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 # arguments */
  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. /* Parser external interfaces */
  56. acpi_status
  57. acpi_psx_load_table (
  58. u8 *pcode_addr,
  59. u32 pcode_length);
  60. acpi_status
  61. acpi_psx_execute (
  62. struct acpi_parameter_info *info);
  63. /******************************************************************************
  64. *
  65. * Parser interfaces
  66. *
  67. *****************************************************************************/
  68. /* psargs - Parse AML opcode arguments */
  69. u8 *
  70. acpi_ps_get_next_package_end (
  71. struct acpi_parse_state *parser_state);
  72. u32
  73. acpi_ps_get_next_package_length (
  74. struct acpi_parse_state *parser_state);
  75. char *
  76. acpi_ps_get_next_namestring (
  77. struct acpi_parse_state *parser_state);
  78. void
  79. acpi_ps_get_next_simple_arg (
  80. struct acpi_parse_state *parser_state,
  81. u32 arg_type,
  82. union acpi_parse_object *arg);
  83. acpi_status
  84. acpi_ps_get_next_namepath (
  85. struct acpi_walk_state *walk_state,
  86. struct acpi_parse_state *parser_state,
  87. union acpi_parse_object *arg,
  88. u8 method_call);
  89. union acpi_parse_object *
  90. acpi_ps_get_next_field (
  91. struct acpi_parse_state *parser_state);
  92. acpi_status
  93. acpi_ps_get_next_arg (
  94. struct acpi_walk_state *walk_state,
  95. struct acpi_parse_state *parser_state,
  96. u32 arg_type,
  97. union acpi_parse_object **return_arg);
  98. /* psfind */
  99. union acpi_parse_object *
  100. acpi_ps_find_name (
  101. union acpi_parse_object *scope,
  102. u32 name,
  103. u32 opcode);
  104. union acpi_parse_object*
  105. acpi_ps_get_parent (
  106. union acpi_parse_object *op);
  107. /* psopcode - AML Opcode information */
  108. const struct acpi_opcode_info *
  109. acpi_ps_get_opcode_info (
  110. u16 opcode);
  111. char *
  112. acpi_ps_get_opcode_name (
  113. u16 opcode);
  114. /* psparse - top level parsing routines */
  115. u32
  116. acpi_ps_get_opcode_size (
  117. u32 opcode);
  118. void
  119. acpi_ps_complete_this_op (
  120. struct acpi_walk_state *walk_state,
  121. union acpi_parse_object *op);
  122. acpi_status
  123. acpi_ps_next_parse_state (
  124. struct acpi_walk_state *walk_state,
  125. union acpi_parse_object *op,
  126. acpi_status callback_status);
  127. acpi_status
  128. acpi_ps_find_object (
  129. struct acpi_walk_state *walk_state,
  130. union acpi_parse_object **out_op);
  131. void
  132. acpi_ps_delete_parse_tree (
  133. union acpi_parse_object *root);
  134. acpi_status
  135. acpi_ps_parse_loop (
  136. struct acpi_walk_state *walk_state);
  137. acpi_status
  138. acpi_ps_parse_aml (
  139. struct acpi_walk_state *walk_state);
  140. acpi_status
  141. acpi_ps_parse_table (
  142. u8 *aml,
  143. u32 aml_size,
  144. acpi_parse_downwards descending_callback,
  145. acpi_parse_upwards ascending_callback,
  146. union acpi_parse_object **root_object);
  147. u16
  148. acpi_ps_peek_opcode (
  149. struct acpi_parse_state *state);
  150. /* psscope - Scope stack management routines */
  151. acpi_status
  152. acpi_ps_init_scope (
  153. struct acpi_parse_state *parser_state,
  154. union acpi_parse_object *root);
  155. union acpi_parse_object *
  156. acpi_ps_get_parent_scope (
  157. struct acpi_parse_state *state);
  158. u8
  159. acpi_ps_has_completed_scope (
  160. struct acpi_parse_state *parser_state);
  161. void
  162. acpi_ps_pop_scope (
  163. struct acpi_parse_state *parser_state,
  164. union acpi_parse_object **op,
  165. u32 *arg_list,
  166. u32 *arg_count);
  167. acpi_status
  168. acpi_ps_push_scope (
  169. struct acpi_parse_state *parser_state,
  170. union acpi_parse_object *op,
  171. u32 remaining_args,
  172. u32 arg_count);
  173. void
  174. acpi_ps_cleanup_scope (
  175. struct acpi_parse_state *state);
  176. /* pstree - parse tree manipulation routines */
  177. void
  178. acpi_ps_append_arg(
  179. union acpi_parse_object *op,
  180. union acpi_parse_object *arg);
  181. union acpi_parse_object*
  182. acpi_ps_find (
  183. union acpi_parse_object *scope,
  184. char *path,
  185. u16 opcode,
  186. u32 create);
  187. union acpi_parse_object *
  188. acpi_ps_get_arg(
  189. union acpi_parse_object *op,
  190. u32 argn);
  191. #ifdef ACPI_FUTURE_USAGE
  192. union acpi_parse_object *
  193. acpi_ps_get_child (
  194. union acpi_parse_object *op);
  195. union acpi_parse_object *
  196. acpi_ps_get_depth_next (
  197. union acpi_parse_object *origin,
  198. union acpi_parse_object *op);
  199. #endif /* ACPI_FUTURE_USAGE */
  200. /* pswalk - parse tree walk routines */
  201. acpi_status
  202. acpi_ps_walk_parsed_aml (
  203. union acpi_parse_object *start_op,
  204. union acpi_parse_object *end_op,
  205. union acpi_operand_object *mth_desc,
  206. struct acpi_namespace_node *start_node,
  207. union acpi_operand_object **params,
  208. union acpi_operand_object **caller_return_desc,
  209. acpi_owner_id owner_id,
  210. acpi_parse_downwards descending_callback,
  211. acpi_parse_upwards ascending_callback);
  212. acpi_status
  213. acpi_ps_get_next_walk_op (
  214. struct acpi_walk_state *walk_state,
  215. union acpi_parse_object *op,
  216. acpi_parse_upwards ascending_callback);
  217. acpi_status
  218. acpi_ps_delete_completed_op (
  219. struct acpi_walk_state *walk_state);
  220. /* psutils - parser utilities */
  221. union acpi_parse_object *
  222. acpi_ps_create_scope_op (
  223. void);
  224. void
  225. acpi_ps_init_op (
  226. union acpi_parse_object *op,
  227. u16 opcode);
  228. union acpi_parse_object *
  229. acpi_ps_alloc_op (
  230. u16 opcode);
  231. void
  232. acpi_ps_free_op (
  233. union acpi_parse_object *op);
  234. #ifdef ACPI_ENABLE_OBJECT_CACHE
  235. void
  236. acpi_ps_delete_parse_cache (
  237. void);
  238. #endif
  239. u8
  240. acpi_ps_is_leading_char (
  241. u32 c);
  242. u8
  243. acpi_ps_is_prefix_char (
  244. u32 c);
  245. #ifdef ACPI_FUTURE_USAGE
  246. u32
  247. acpi_ps_get_name(
  248. union acpi_parse_object *op);
  249. #endif
  250. void
  251. acpi_ps_set_name(
  252. union acpi_parse_object *op,
  253. u32 name);
  254. /* psdump - display parser tree */
  255. u32
  256. acpi_ps_sprint_path (
  257. char *buffer_start,
  258. u32 buffer_size,
  259. union acpi_parse_object *op);
  260. u32
  261. acpi_ps_sprint_op (
  262. char *buffer_start,
  263. u32 buffer_size,
  264. union acpi_parse_object *op);
  265. void
  266. acpi_ps_show (
  267. union acpi_parse_object *op);
  268. #endif /* __ACPARSER_H__ */