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