acparser.h 8.4 KB

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