acparser.h 8.1 KB

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