1 /****************************************************************************** 2 * 3 * Module Name: acparser.h - AML Parser subcomponent prototypes and defines 4 * 5 *****************************************************************************/ 6 7 /* 8 * Copyright (C) 2000 - 2015, Intel Corp. 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 #ifndef __ACPARSER_H__ 45 #define __ACPARSER_H__ 46 47 48 #define OP_HAS_RETURN_VALUE 1 49 50 /* Variable number of arguments. This field must be 32 bits */ 51 52 #define ACPI_VAR_ARGS ACPI_UINT32_MAX 53 54 55 #define ACPI_PARSE_DELETE_TREE 0x0001 56 #define ACPI_PARSE_NO_TREE_DELETE 0x0000 57 #define ACPI_PARSE_TREE_MASK 0x0001 58 59 #define ACPI_PARSE_LOAD_PASS1 0x0010 60 #define ACPI_PARSE_LOAD_PASS2 0x0020 61 #define ACPI_PARSE_EXECUTE 0x0030 62 #define ACPI_PARSE_MODE_MASK 0x0030 63 64 #define ACPI_PARSE_DEFERRED_OP 0x0100 65 #define ACPI_PARSE_DISASSEMBLE 0x0200 66 67 #define ACPI_PARSE_MODULE_LEVEL 0x0400 68 69 /****************************************************************************** 70 * 71 * Parser interfaces 72 * 73 *****************************************************************************/ 74 75 76 /* 77 * psxface - Parser external interfaces 78 */ 79 ACPI_STATUS 80 AcpiPsExecuteMethod ( 81 ACPI_EVALUATE_INFO *Info); 82 83 84 /* 85 * psargs - Parse AML opcode arguments 86 */ 87 UINT8 * 88 AcpiPsGetNextPackageEnd ( 89 ACPI_PARSE_STATE *ParserState); 90 91 char * 92 AcpiPsGetNextNamestring ( 93 ACPI_PARSE_STATE *ParserState); 94 95 void 96 AcpiPsGetNextSimpleArg ( 97 ACPI_PARSE_STATE *ParserState, 98 UINT32 ArgType, 99 ACPI_PARSE_OBJECT *Arg); 100 101 ACPI_STATUS 102 AcpiPsGetNextNamepath ( 103 ACPI_WALK_STATE *WalkState, 104 ACPI_PARSE_STATE *ParserState, 105 ACPI_PARSE_OBJECT *Arg, 106 BOOLEAN MethodCall); 107 108 ACPI_STATUS 109 AcpiPsGetNextArg ( 110 ACPI_WALK_STATE *WalkState, 111 ACPI_PARSE_STATE *ParserState, 112 UINT32 ArgType, 113 ACPI_PARSE_OBJECT **ReturnArg); 114 115 116 /* 117 * psfind 118 */ 119 ACPI_PARSE_OBJECT * 120 AcpiPsFindName ( 121 ACPI_PARSE_OBJECT *Scope, 122 UINT32 Name, 123 UINT32 Opcode); 124 125 ACPI_PARSE_OBJECT* 126 AcpiPsGetParent ( 127 ACPI_PARSE_OBJECT *Op); 128 129 130 /* 131 * psobject - support for parse object processing 132 */ 133 ACPI_STATUS 134 AcpiPsBuildNamedOp ( 135 ACPI_WALK_STATE *WalkState, 136 UINT8 *AmlOpStart, 137 ACPI_PARSE_OBJECT *UnnamedOp, 138 ACPI_PARSE_OBJECT **Op); 139 140 ACPI_STATUS 141 AcpiPsCreateOp ( 142 ACPI_WALK_STATE *WalkState, 143 UINT8 *AmlOpStart, 144 ACPI_PARSE_OBJECT **NewOp); 145 146 ACPI_STATUS 147 AcpiPsCompleteOp ( 148 ACPI_WALK_STATE *WalkState, 149 ACPI_PARSE_OBJECT **Op, 150 ACPI_STATUS Status); 151 152 ACPI_STATUS 153 AcpiPsCompleteFinalOp ( 154 ACPI_WALK_STATE *WalkState, 155 ACPI_PARSE_OBJECT *Op, 156 ACPI_STATUS Status); 157 158 159 /* 160 * psopinfo - AML Opcode information 161 */ 162 const ACPI_OPCODE_INFO * 163 AcpiPsGetOpcodeInfo ( 164 UINT16 Opcode); 165 166 char * 167 AcpiPsGetOpcodeName ( 168 UINT16 Opcode); 169 170 UINT8 171 AcpiPsGetArgumentCount ( 172 UINT32 OpType); 173 174 175 /* 176 * psparse - top level parsing routines 177 */ 178 ACPI_STATUS 179 AcpiPsParseAml ( 180 ACPI_WALK_STATE *WalkState); 181 182 UINT32 183 AcpiPsGetOpcodeSize ( 184 UINT32 Opcode); 185 186 UINT16 187 AcpiPsPeekOpcode ( 188 ACPI_PARSE_STATE *state); 189 190 ACPI_STATUS 191 AcpiPsCompleteThisOp ( 192 ACPI_WALK_STATE *WalkState, 193 ACPI_PARSE_OBJECT *Op); 194 195 ACPI_STATUS 196 AcpiPsNextParseState ( 197 ACPI_WALK_STATE *WalkState, 198 ACPI_PARSE_OBJECT *Op, 199 ACPI_STATUS CallbackStatus); 200 201 202 /* 203 * psloop - main parse loop 204 */ 205 ACPI_STATUS 206 AcpiPsParseLoop ( 207 ACPI_WALK_STATE *WalkState); 208 209 210 /* 211 * psscope - Scope stack management routines 212 */ 213 ACPI_STATUS 214 AcpiPsInitScope ( 215 ACPI_PARSE_STATE *ParserState, 216 ACPI_PARSE_OBJECT *Root); 217 218 ACPI_PARSE_OBJECT * 219 AcpiPsGetParentScope ( 220 ACPI_PARSE_STATE *state); 221 222 BOOLEAN 223 AcpiPsHasCompletedScope ( 224 ACPI_PARSE_STATE *ParserState); 225 226 void 227 AcpiPsPopScope ( 228 ACPI_PARSE_STATE *ParserState, 229 ACPI_PARSE_OBJECT **Op, 230 UINT32 *ArgList, 231 UINT32 *ArgCount); 232 233 ACPI_STATUS 234 AcpiPsPushScope ( 235 ACPI_PARSE_STATE *ParserState, 236 ACPI_PARSE_OBJECT *Op, 237 UINT32 RemainingArgs, 238 UINT32 ArgCount); 239 240 void 241 AcpiPsCleanupScope ( 242 ACPI_PARSE_STATE *state); 243 244 245 /* 246 * pstree - parse tree manipulation routines 247 */ 248 void 249 AcpiPsAppendArg( 250 ACPI_PARSE_OBJECT *op, 251 ACPI_PARSE_OBJECT *arg); 252 253 ACPI_PARSE_OBJECT* 254 AcpiPsFind ( 255 ACPI_PARSE_OBJECT *Scope, 256 char *Path, 257 UINT16 Opcode, 258 UINT32 Create); 259 260 ACPI_PARSE_OBJECT * 261 AcpiPsGetArg( 262 ACPI_PARSE_OBJECT *op, 263 UINT32 argn); 264 265 ACPI_PARSE_OBJECT * 266 AcpiPsGetDepthNext ( 267 ACPI_PARSE_OBJECT *Origin, 268 ACPI_PARSE_OBJECT *Op); 269 270 271 /* 272 * pswalk - parse tree walk routines 273 */ 274 ACPI_STATUS 275 AcpiPsWalkParsedAml ( 276 ACPI_PARSE_OBJECT *StartOp, 277 ACPI_PARSE_OBJECT *EndOp, 278 ACPI_OPERAND_OBJECT *MthDesc, 279 ACPI_NAMESPACE_NODE *StartNode, 280 ACPI_OPERAND_OBJECT **Params, 281 ACPI_OPERAND_OBJECT **CallerReturnDesc, 282 ACPI_OWNER_ID OwnerId, 283 ACPI_PARSE_DOWNWARDS DescendingCallback, 284 ACPI_PARSE_UPWARDS AscendingCallback); 285 286 ACPI_STATUS 287 AcpiPsGetNextWalkOp ( 288 ACPI_WALK_STATE *WalkState, 289 ACPI_PARSE_OBJECT *Op, 290 ACPI_PARSE_UPWARDS AscendingCallback); 291 292 ACPI_STATUS 293 AcpiPsDeleteCompletedOp ( 294 ACPI_WALK_STATE *WalkState); 295 296 void 297 AcpiPsDeleteParseTree ( 298 ACPI_PARSE_OBJECT *root); 299 300 301 /* 302 * psutils - parser utilities 303 */ 304 ACPI_PARSE_OBJECT * 305 AcpiPsCreateScopeOp ( 306 void); 307 308 void 309 AcpiPsInitOp ( 310 ACPI_PARSE_OBJECT *op, 311 UINT16 opcode); 312 313 ACPI_PARSE_OBJECT * 314 AcpiPsAllocOp ( 315 UINT16 opcode); 316 317 void 318 AcpiPsFreeOp ( 319 ACPI_PARSE_OBJECT *Op); 320 321 BOOLEAN 322 AcpiPsIsLeadingChar ( 323 UINT32 c); 324 325 UINT32 326 AcpiPsGetName( 327 ACPI_PARSE_OBJECT *op); 328 329 void 330 AcpiPsSetName( 331 ACPI_PARSE_OBJECT *op, 332 UINT32 name); 333 334 335 /* 336 * psdump - display parser tree 337 */ 338 UINT32 339 AcpiPsSprintPath ( 340 char *BufferStart, 341 UINT32 BufferSize, 342 ACPI_PARSE_OBJECT *Op); 343 344 UINT32 345 AcpiPsSprintOp ( 346 char *BufferStart, 347 UINT32 BufferSize, 348 ACPI_PARSE_OBJECT *Op); 349 350 void 351 AcpiPsShow ( 352 ACPI_PARSE_OBJECT *op); 353 354 355 #endif /* __ACPARSER_H__ */ 356