1/****************************************************************************** 2 * 3 * Module Name: acparser.h - AML Parser subcomponent prototypes and defines 4 * $Revision: 1.1.1.1 $ 5 * 6 *****************************************************************************/ 7 8/* 9 * Copyright (C) 2000, 2001 R. Byron Moore 10 * 11 * This program is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 */ 25 26 27#ifndef __ACPARSER_H__ 28#define __ACPARSER_H__ 29 30 31#define OP_HAS_RETURN_VALUE 1 32 33/* variable # arguments */ 34 35#define ACPI_VAR_ARGS ACPI_UINT32_MAX 36 37/* maximum virtual address */ 38 39#define ACPI_MAX_AML ((u8 *)(~0UL)) 40 41 42#define ACPI_PARSE_DELETE_TREE 0x0001 43#define ACPI_PARSE_NO_TREE_DELETE 0x0000 44#define ACPI_PARSE_TREE_MASK 0x0001 45 46#define ACPI_PARSE_LOAD_PASS1 0x0010 47#define ACPI_PARSE_LOAD_PASS2 0x0020 48#define ACPI_PARSE_EXECUTE 0x0030 49#define ACPI_PARSE_MODE_MASK 0x0030 50 51/* psapi - Parser external interfaces */ 52 53acpi_status 54acpi_psx_load_table ( 55 u8 *pcode_addr, 56 u32 pcode_length); 57 58acpi_status 59acpi_psx_execute ( 60 acpi_namespace_node *method_node, 61 acpi_operand_object **params, 62 acpi_operand_object **return_obj_desc); 63 64/****************************************************************************** 65 * 66 * Parser interfaces 67 * 68 *****************************************************************************/ 69 70 71/* psargs - Parse AML opcode arguments */ 72 73u8 * 74acpi_ps_get_next_package_end ( 75 acpi_parse_state *parser_state); 76 77u32 78acpi_ps_get_next_package_length ( 79 acpi_parse_state *parser_state); 80 81NATIVE_CHAR * 82acpi_ps_get_next_namestring ( 83 acpi_parse_state *parser_state); 84 85void 86acpi_ps_get_next_simple_arg ( 87 acpi_parse_state *parser_state, 88 u32 arg_type, /* type of argument */ 89 acpi_parse_object *arg); /* (OUT) argument data */ 90 91void 92acpi_ps_get_next_namepath ( 93 acpi_parse_state *parser_state, 94 acpi_parse_object *arg, 95 u32 *arg_count, 96 u8 method_call); 97 98acpi_parse_object * 99acpi_ps_get_next_field ( 100 acpi_parse_state *parser_state); 101 102acpi_parse_object * 103acpi_ps_get_next_arg ( 104 acpi_parse_state *parser_state, 105 u32 arg_type, 106 u32 *arg_count); 107 108 109/* psopcode - AML Opcode information */ 110 111const acpi_opcode_info * 112acpi_ps_get_opcode_info ( 113 u16 opcode); 114 115NATIVE_CHAR * 116acpi_ps_get_opcode_name ( 117 u16 opcode); 118 119 120/* psparse - top level parsing routines */ 121 122acpi_status 123acpi_ps_find_object ( 124 acpi_walk_state *walk_state, 125 acpi_parse_object **out_op); 126 127void 128acpi_ps_delete_parse_tree ( 129 acpi_parse_object *root); 130 131acpi_status 132acpi_ps_parse_loop ( 133 acpi_walk_state *walk_state); 134 135acpi_status 136acpi_ps_parse_aml ( 137 acpi_walk_state *walk_state); 138 139acpi_status 140acpi_ps_parse_table ( 141 u8 *aml, 142 u32 aml_size, 143 acpi_parse_downwards descending_callback, 144 acpi_parse_upwards ascending_callback, 145 acpi_parse_object **root_object); 146 147u16 148acpi_ps_peek_opcode ( 149 acpi_parse_state *state); 150 151 152/* psscope - Scope stack management routines */ 153 154 155acpi_status 156acpi_ps_init_scope ( 157 acpi_parse_state *parser_state, 158 acpi_parse_object *root); 159 160acpi_parse_object * 161acpi_ps_get_parent_scope ( 162 acpi_parse_state *state); 163 164u8 165acpi_ps_has_completed_scope ( 166 acpi_parse_state *parser_state); 167 168void 169acpi_ps_pop_scope ( 170 acpi_parse_state *parser_state, 171 acpi_parse_object **op, 172 u32 *arg_list, 173 u32 *arg_count); 174 175acpi_status 176acpi_ps_push_scope ( 177 acpi_parse_state *parser_state, 178 acpi_parse_object *op, 179 u32 remaining_args, 180 u32 arg_count); 181 182void 183acpi_ps_cleanup_scope ( 184 acpi_parse_state *state); 185 186 187/* pstree - parse tree manipulation routines */ 188 189void 190acpi_ps_append_arg( 191 acpi_parse_object *op, 192 acpi_parse_object *arg); 193 194acpi_parse_object* 195acpi_ps_find ( 196 acpi_parse_object *scope, 197 NATIVE_CHAR *path, 198 u16 opcode, 199 u32 create); 200 201acpi_parse_object * 202acpi_ps_get_arg( 203 acpi_parse_object *op, 204 u32 argn); 205 206acpi_parse_object * 207acpi_ps_get_child ( 208 acpi_parse_object *op); 209 210acpi_parse_object * 211acpi_ps_get_depth_next ( 212 acpi_parse_object *origin, 213 acpi_parse_object *op); 214 215 216/* pswalk - parse tree walk routines */ 217 218acpi_status 219acpi_ps_walk_parsed_aml ( 220 acpi_parse_object *start_op, 221 acpi_parse_object *end_op, 222 acpi_operand_object *mth_desc, 223 acpi_namespace_node *start_node, 224 acpi_operand_object **params, 225 acpi_operand_object **caller_return_desc, 226 acpi_owner_id owner_id, 227 acpi_parse_downwards descending_callback, 228 acpi_parse_upwards ascending_callback); 229 230acpi_status 231acpi_ps_get_next_walk_op ( 232 acpi_walk_state *walk_state, 233 acpi_parse_object *op, 234 acpi_parse_upwards ascending_callback); 235 236 237/* psutils - parser utilities */ 238 239void 240acpi_ps_init_op ( 241 acpi_parse_object *op, 242 u16 opcode); 243 244acpi_parse_object * 245acpi_ps_alloc_op ( 246 u16 opcode); 247 248void 249acpi_ps_free_op ( 250 acpi_parse_object *op); 251 252void 253acpi_ps_delete_parse_cache ( 254 void); 255 256u8 257acpi_ps_is_leading_char ( 258 u32 c); 259 260u8 261acpi_ps_is_prefix_char ( 262 u32 c); 263 264u32 265acpi_ps_get_name( 266 acpi_parse_object *op); 267 268void 269acpi_ps_set_name( 270 acpi_parse_object *op, 271 u32 name); 272 273 274/* psdump - display parser tree */ 275 276u32 277acpi_ps_sprint_path ( 278 NATIVE_CHAR *buffer_start, 279 u32 buffer_size, 280 acpi_parse_object *op); 281 282u32 283acpi_ps_sprint_op ( 284 NATIVE_CHAR *buffer_start, 285 u32 buffer_size, 286 acpi_parse_object *op); 287 288void 289acpi_ps_show ( 290 acpi_parse_object *op); 291 292 293#endif /* __ACPARSER_H__ */ 294