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