acparser.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. /******************************************************************************
  2. *
  3. * Module Name: acparser.h - AML Parser subcomponent prototypes and defines
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2016, 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 u8 acpi_gbl_short_op_index[];
  63. extern const u8 acpi_gbl_long_op_index[];
  64. /*
  65. * psxface - Parser external interfaces
  66. */
  67. acpi_status acpi_ps_execute_method(struct acpi_evaluate_info *info);
  68. acpi_status acpi_ps_execute_table(struct acpi_evaluate_info *info);
  69. /*
  70. * psargs - Parse AML opcode arguments
  71. */
  72. u8 *acpi_ps_get_next_package_end(struct acpi_parse_state *parser_state);
  73. char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state);
  74. void
  75. acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state,
  76. u32 arg_type, union acpi_parse_object *arg);
  77. acpi_status
  78. acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state,
  79. struct acpi_parse_state *parser_state,
  80. union acpi_parse_object *arg,
  81. u8 possible_method_call);
  82. /* Values for u8 above */
  83. #define ACPI_NOT_METHOD_CALL FALSE
  84. #define ACPI_POSSIBLE_METHOD_CALL TRUE
  85. acpi_status
  86. acpi_ps_get_next_arg(struct acpi_walk_state *walk_state,
  87. struct acpi_parse_state *parser_state,
  88. u32 arg_type, union acpi_parse_object **return_arg);
  89. /*
  90. * psfind
  91. */
  92. union acpi_parse_object *acpi_ps_find_name(union acpi_parse_object *scope,
  93. u32 name, u32 opcode);
  94. union acpi_parse_object *acpi_ps_get_parent(union acpi_parse_object *op);
  95. /*
  96. * psobject - support for parse object processing
  97. */
  98. acpi_status
  99. acpi_ps_build_named_op(struct acpi_walk_state *walk_state,
  100. u8 *aml_op_start,
  101. union acpi_parse_object *unnamed_op,
  102. union acpi_parse_object **op);
  103. acpi_status
  104. acpi_ps_create_op(struct acpi_walk_state *walk_state,
  105. u8 *aml_op_start, union acpi_parse_object **new_op);
  106. acpi_status
  107. acpi_ps_complete_op(struct acpi_walk_state *walk_state,
  108. union acpi_parse_object **op, acpi_status status);
  109. acpi_status
  110. acpi_ps_complete_final_op(struct acpi_walk_state *walk_state,
  111. union acpi_parse_object *op, acpi_status status);
  112. /*
  113. * psopinfo - AML Opcode information
  114. */
  115. const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode);
  116. const char *acpi_ps_get_opcode_name(u16 opcode);
  117. u8 acpi_ps_get_argument_count(u32 op_type);
  118. /*
  119. * psparse - top level parsing routines
  120. */
  121. acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state);
  122. u32 acpi_ps_get_opcode_size(u32 opcode);
  123. u16 acpi_ps_peek_opcode(struct acpi_parse_state *state);
  124. acpi_status
  125. acpi_ps_complete_this_op(struct acpi_walk_state *walk_state,
  126. union acpi_parse_object *op);
  127. acpi_status
  128. acpi_ps_next_parse_state(struct acpi_walk_state *walk_state,
  129. union acpi_parse_object *op,
  130. acpi_status callback_status);
  131. /*
  132. * psloop - main parse loop
  133. */
  134. acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state);
  135. /*
  136. * psscope - Scope stack management routines
  137. */
  138. acpi_status
  139. acpi_ps_init_scope(struct acpi_parse_state *parser_state,
  140. union acpi_parse_object *root);
  141. union acpi_parse_object *acpi_ps_get_parent_scope(struct acpi_parse_state
  142. *state);
  143. u8 acpi_ps_has_completed_scope(struct acpi_parse_state *parser_state);
  144. void
  145. acpi_ps_pop_scope(struct acpi_parse_state *parser_state,
  146. union acpi_parse_object **op, u32 *arg_list, u32 *arg_count);
  147. acpi_status
  148. acpi_ps_push_scope(struct acpi_parse_state *parser_state,
  149. union acpi_parse_object *op,
  150. u32 remaining_args, u32 arg_count);
  151. void acpi_ps_cleanup_scope(struct acpi_parse_state *state);
  152. /*
  153. * pstree - parse tree manipulation routines
  154. */
  155. void
  156. acpi_ps_append_arg(union acpi_parse_object *op, union acpi_parse_object *arg);
  157. union acpi_parse_object *acpi_ps_find(union acpi_parse_object *scope,
  158. char *path, u16 opcode, u32 create);
  159. union acpi_parse_object *acpi_ps_get_arg(union acpi_parse_object *op, u32 argn);
  160. union acpi_parse_object *acpi_ps_get_depth_next(union acpi_parse_object *origin,
  161. union acpi_parse_object *op);
  162. /*
  163. * pswalk - parse tree walk routines
  164. */
  165. acpi_status
  166. acpi_ps_walk_parsed_aml(union acpi_parse_object *start_op,
  167. union acpi_parse_object *end_op,
  168. union acpi_operand_object *mth_desc,
  169. struct acpi_namespace_node *start_node,
  170. union acpi_operand_object **params,
  171. union acpi_operand_object **caller_return_desc,
  172. acpi_owner_id owner_id,
  173. acpi_parse_downwards descending_callback,
  174. acpi_parse_upwards ascending_callback);
  175. acpi_status
  176. acpi_ps_get_next_walk_op(struct acpi_walk_state *walk_state,
  177. union acpi_parse_object *op,
  178. acpi_parse_upwards ascending_callback);
  179. acpi_status acpi_ps_delete_completed_op(struct acpi_walk_state *walk_state);
  180. void acpi_ps_delete_parse_tree(union acpi_parse_object *root);
  181. /*
  182. * psutils - parser utilities
  183. */
  184. union acpi_parse_object *acpi_ps_create_scope_op(u8 *aml);
  185. void acpi_ps_init_op(union acpi_parse_object *op, u16 opcode);
  186. union acpi_parse_object *acpi_ps_alloc_op(u16 opcode, u8 *aml);
  187. void acpi_ps_free_op(union acpi_parse_object *op);
  188. u8 acpi_ps_is_leading_char(u32 c);
  189. u32 acpi_ps_get_name(union acpi_parse_object *op);
  190. void acpi_ps_set_name(union acpi_parse_object *op, u32 name);
  191. /*
  192. * psdump - display parser tree
  193. */
  194. u32
  195. acpi_ps_sprint_path(char *buffer_start,
  196. u32 buffer_size, union acpi_parse_object *op);
  197. u32
  198. acpi_ps_sprint_op(char *buffer_start,
  199. u32 buffer_size, union acpi_parse_object *op);
  200. void acpi_ps_show(union acpi_parse_object *op);
  201. #endif /* __ACPARSER_H__ */