1 /****************************************************************************** 2 * 3 * Module Name: acparser.h - AML Parser subcomponent prototypes and defines 4 * 5 *****************************************************************************/ 6 7 /* 8 * Copyright (C) 2000 - 2004, R. Byron Moore 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions, and the following disclaimer, 16 * without modification. 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18 * substantially similar to the "NO WARRANTY" disclaimer below 19 * ("Disclaimer") and any redistribution must be conditioned upon 20 * including a substantially similar Disclaimer requirement for further 21 * binary redistribution. 22 * 3. Neither the names of the above-listed copyright holders nor the names 23 * of any contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * Alternatively, this software may be distributed under the terms of the 27 * GNU General Public License ("GPL") version 2 as published by the Free 28 * Software Foundation. 29 * 30 * NO WARRANTY 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41 * POSSIBILITY OF SUCH DAMAGES. 42 */ 43 44 45 #ifndef __ACPARSER_H__ 46 #define __ACPARSER_H__ 47 48 49 #define OP_HAS_RETURN_VALUE 1 50 51 /* variable # arguments */ 52 53 #define ACPI_VAR_ARGS ACPI_UINT32_MAX 54 55 56 #define ACPI_PARSE_DELETE_TREE 0x0001 57 #define ACPI_PARSE_NO_TREE_DELETE 0x0000 58 #define ACPI_PARSE_TREE_MASK 0x0001 59 60 #define ACPI_PARSE_LOAD_PASS1 0x0010 61 #define ACPI_PARSE_LOAD_PASS2 0x0020 62 #define ACPI_PARSE_EXECUTE 0x0030 63 #define ACPI_PARSE_MODE_MASK 0x0030 64 65 #define ACPI_PARSE_DEFERRED_OP 0x0100 66 67 /* Parser external interfaces */ 68 69 acpi_status 70 acpi_psx_load_table ( 71 u8 *pcode_addr, 72 u32 pcode_length); 73 74 acpi_status 75 acpi_psx_execute ( 76 struct acpi_namespace_node *method_node, 77 union acpi_operand_object **params, 78 union acpi_operand_object **return_obj_desc); 79 80 81 /****************************************************************************** 82 * 83 * Parser interfaces 84 * 85 *****************************************************************************/ 86 87 88 /* psargs - Parse AML opcode arguments */ 89 90 u8 * 91 acpi_ps_get_next_package_end ( 92 struct acpi_parse_state *parser_state); 93 94 u32 95 acpi_ps_get_next_package_length ( 96 struct acpi_parse_state *parser_state); 97 98 char * 99 acpi_ps_get_next_namestring ( 100 struct acpi_parse_state *parser_state); 101 102 void 103 acpi_ps_get_next_simple_arg ( 104 struct acpi_parse_state *parser_state, 105 u32 arg_type, 106 union acpi_parse_object *arg); 107 108 acpi_status 109 acpi_ps_get_next_namepath ( 110 struct acpi_walk_state *walk_state, 111 struct acpi_parse_state *parser_state, 112 union acpi_parse_object *arg, 113 u8 method_call); 114 115 union acpi_parse_object * 116 acpi_ps_get_next_field ( 117 struct acpi_parse_state *parser_state); 118 119 acpi_status 120 acpi_ps_get_next_arg ( 121 struct acpi_walk_state *walk_state, 122 struct acpi_parse_state *parser_state, 123 u32 arg_type, 124 union acpi_parse_object **return_arg); 125 126 127 /* psfind */ 128 129 union acpi_parse_object * 130 acpi_ps_find_name ( 131 union acpi_parse_object *scope, 132 u32 name, 133 u32 opcode); 134 135 union acpi_parse_object* 136 acpi_ps_get_parent ( 137 union acpi_parse_object *op); 138 139 140 /* psopcode - AML Opcode information */ 141 142 const struct acpi_opcode_info * 143 acpi_ps_get_opcode_info ( 144 u16 opcode); 145 146 char * 147 acpi_ps_get_opcode_name ( 148 u16 opcode); 149 150 151 /* psparse - top level parsing routines */ 152 153 u32 154 acpi_ps_get_opcode_size ( 155 u32 opcode); 156 157 void 158 acpi_ps_complete_this_op ( 159 struct acpi_walk_state *walk_state, 160 union acpi_parse_object *op); 161 162 acpi_status 163 acpi_ps_next_parse_state ( 164 struct acpi_walk_state *walk_state, 165 union acpi_parse_object *op, 166 acpi_status callback_status); 167 168 acpi_status 169 acpi_ps_find_object ( 170 struct acpi_walk_state *walk_state, 171 union acpi_parse_object **out_op); 172 173 void 174 acpi_ps_delete_parse_tree ( 175 union acpi_parse_object *root); 176 177 acpi_status 178 acpi_ps_parse_loop ( 179 struct acpi_walk_state *walk_state); 180 181 acpi_status 182 acpi_ps_parse_aml ( 183 struct acpi_walk_state *walk_state); 184 185 acpi_status 186 acpi_ps_parse_table ( 187 u8 *aml, 188 u32 aml_size, 189 acpi_parse_downwards descending_callback, 190 acpi_parse_upwards ascending_callback, 191 union acpi_parse_object **root_object); 192 193 u16 194 acpi_ps_peek_opcode ( 195 struct acpi_parse_state *state); 196 197 198 /* psscope - Scope stack management routines */ 199 200 201 acpi_status 202 acpi_ps_init_scope ( 203 struct acpi_parse_state *parser_state, 204 union acpi_parse_object *root); 205 206 union acpi_parse_object * 207 acpi_ps_get_parent_scope ( 208 struct acpi_parse_state *state); 209 210 u8 211 acpi_ps_has_completed_scope ( 212 struct acpi_parse_state *parser_state); 213 214 void 215 acpi_ps_pop_scope ( 216 struct acpi_parse_state *parser_state, 217 union acpi_parse_object **op, 218 u32 *arg_list, 219 u32 *arg_count); 220 221 acpi_status 222 acpi_ps_push_scope ( 223 struct acpi_parse_state *parser_state, 224 union acpi_parse_object *op, 225 u32 remaining_args, 226 u32 arg_count); 227 228 void 229 acpi_ps_cleanup_scope ( 230 struct acpi_parse_state *state); 231 232 233 /* pstree - parse tree manipulation routines */ 234 235 void 236 acpi_ps_append_arg( 237 union acpi_parse_object *op, 238 union acpi_parse_object *arg); 239 240 union acpi_parse_object* 241 acpi_ps_find ( 242 union acpi_parse_object *scope, 243 char *path, 244 u16 opcode, 245 u32 create); 246 247 union acpi_parse_object * 248 acpi_ps_get_arg( 249 union acpi_parse_object *op, 250 u32 argn); 251 252 union acpi_parse_object * 253 acpi_ps_get_child ( 254 union acpi_parse_object *op); 255 256 union acpi_parse_object * 257 acpi_ps_get_depth_next ( 258 union acpi_parse_object *origin, 259 union acpi_parse_object *op); 260 261 262 /* pswalk - parse tree walk routines */ 263 264 acpi_status 265 acpi_ps_walk_parsed_aml ( 266 union acpi_parse_object *start_op, 267 union acpi_parse_object *end_op, 268 union acpi_operand_object *mth_desc, 269 struct acpi_namespace_node *start_node, 270 union acpi_operand_object **params, 271 union acpi_operand_object **caller_return_desc, 272 acpi_owner_id owner_id, 273 acpi_parse_downwards descending_callback, 274 acpi_parse_upwards ascending_callback); 275 276 acpi_status 277 acpi_ps_get_next_walk_op ( 278 struct acpi_walk_state *walk_state, 279 union acpi_parse_object *op, 280 acpi_parse_upwards ascending_callback); 281 282 acpi_status 283 acpi_ps_delete_completed_op ( 284 struct acpi_walk_state *walk_state); 285 286 287 /* psutils - parser utilities */ 288 289 union acpi_parse_object * 290 acpi_ps_create_scope_op ( 291 void); 292 293 void 294 acpi_ps_init_op ( 295 union acpi_parse_object *op, 296 u16 opcode); 297 298 union acpi_parse_object * 299 acpi_ps_alloc_op ( 300 u16 opcode); 301 302 void 303 acpi_ps_free_op ( 304 union acpi_parse_object *op); 305 306 void 307 acpi_ps_delete_parse_cache ( 308 void); 309 310 u8 311 acpi_ps_is_leading_char ( 312 u32 c); 313 314 u8 315 acpi_ps_is_prefix_char ( 316 u32 c); 317 318 u32 319 acpi_ps_get_name( 320 union acpi_parse_object *op); 321 322 void 323 acpi_ps_set_name( 324 union acpi_parse_object *op, 325 u32 name); 326 327 328 /* psdump - display parser tree */ 329 330 u32 331 acpi_ps_sprint_path ( 332 char *buffer_start, 333 u32 buffer_size, 334 union acpi_parse_object *op); 335 336 u32 337 acpi_ps_sprint_op ( 338 char *buffer_start, 339 u32 buffer_size, 340 union acpi_parse_object *op); 341 342 void 343 acpi_ps_show ( 344 union acpi_parse_object *op); 345 346 347 #endif /* __ACPARSER_H__ */ 348