1433d6423SLionel Sambuc /****************************************************************************** 2433d6423SLionel Sambuc * 3433d6423SLionel Sambuc * Module Name: acparser.h - AML Parser subcomponent prototypes and defines 4433d6423SLionel Sambuc * 5433d6423SLionel Sambuc *****************************************************************************/ 6433d6423SLionel Sambuc 7*29492bb7SDavid van Moolenbroek /* 8*29492bb7SDavid van Moolenbroek * Copyright (C) 2000 - 2014, Intel Corp. 9433d6423SLionel Sambuc * All rights reserved. 10433d6423SLionel Sambuc * 11*29492bb7SDavid van Moolenbroek * Redistribution and use in source and binary forms, with or without 12*29492bb7SDavid van Moolenbroek * modification, are permitted provided that the following conditions 13*29492bb7SDavid van Moolenbroek * are met: 14*29492bb7SDavid van Moolenbroek * 1. Redistributions of source code must retain the above copyright 15*29492bb7SDavid van Moolenbroek * notice, this list of conditions, and the following disclaimer, 16*29492bb7SDavid van Moolenbroek * without modification. 17*29492bb7SDavid van Moolenbroek * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18*29492bb7SDavid van Moolenbroek * substantially similar to the "NO WARRANTY" disclaimer below 19*29492bb7SDavid van Moolenbroek * ("Disclaimer") and any redistribution must be conditioned upon 20*29492bb7SDavid van Moolenbroek * including a substantially similar Disclaimer requirement for further 21*29492bb7SDavid van Moolenbroek * binary redistribution. 22*29492bb7SDavid van Moolenbroek * 3. Neither the names of the above-listed copyright holders nor the names 23*29492bb7SDavid van Moolenbroek * of any contributors may be used to endorse or promote products derived 24*29492bb7SDavid van Moolenbroek * from this software without specific prior written permission. 25433d6423SLionel Sambuc * 26*29492bb7SDavid van Moolenbroek * Alternatively, this software may be distributed under the terms of the 27*29492bb7SDavid van Moolenbroek * GNU General Public License ("GPL") version 2 as published by the Free 28*29492bb7SDavid van Moolenbroek * Software Foundation. 29433d6423SLionel Sambuc * 30*29492bb7SDavid van Moolenbroek * NO WARRANTY 31*29492bb7SDavid van Moolenbroek * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32*29492bb7SDavid van Moolenbroek * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33*29492bb7SDavid van Moolenbroek * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34*29492bb7SDavid van Moolenbroek * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35*29492bb7SDavid van Moolenbroek * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36*29492bb7SDavid van Moolenbroek * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37*29492bb7SDavid van Moolenbroek * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38*29492bb7SDavid van Moolenbroek * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39*29492bb7SDavid van Moolenbroek * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40*29492bb7SDavid van Moolenbroek * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41*29492bb7SDavid van Moolenbroek * POSSIBILITY OF SUCH DAMAGES. 42*29492bb7SDavid van Moolenbroek */ 43433d6423SLionel Sambuc 44433d6423SLionel Sambuc #ifndef __ACPARSER_H__ 45433d6423SLionel Sambuc #define __ACPARSER_H__ 46433d6423SLionel Sambuc 47433d6423SLionel Sambuc 48433d6423SLionel Sambuc #define OP_HAS_RETURN_VALUE 1 49433d6423SLionel Sambuc 50433d6423SLionel Sambuc /* Variable number of arguments. This field must be 32 bits */ 51433d6423SLionel Sambuc 52433d6423SLionel Sambuc #define ACPI_VAR_ARGS ACPI_UINT32_MAX 53433d6423SLionel Sambuc 54433d6423SLionel Sambuc 55433d6423SLionel Sambuc #define ACPI_PARSE_DELETE_TREE 0x0001 56433d6423SLionel Sambuc #define ACPI_PARSE_NO_TREE_DELETE 0x0000 57433d6423SLionel Sambuc #define ACPI_PARSE_TREE_MASK 0x0001 58433d6423SLionel Sambuc 59433d6423SLionel Sambuc #define ACPI_PARSE_LOAD_PASS1 0x0010 60433d6423SLionel Sambuc #define ACPI_PARSE_LOAD_PASS2 0x0020 61433d6423SLionel Sambuc #define ACPI_PARSE_EXECUTE 0x0030 62433d6423SLionel Sambuc #define ACPI_PARSE_MODE_MASK 0x0030 63433d6423SLionel Sambuc 64433d6423SLionel Sambuc #define ACPI_PARSE_DEFERRED_OP 0x0100 65433d6423SLionel Sambuc #define ACPI_PARSE_DISASSEMBLE 0x0200 66433d6423SLionel Sambuc 67433d6423SLionel Sambuc #define ACPI_PARSE_MODULE_LEVEL 0x0400 68433d6423SLionel Sambuc 69433d6423SLionel Sambuc /****************************************************************************** 70433d6423SLionel Sambuc * 71433d6423SLionel Sambuc * Parser interfaces 72433d6423SLionel Sambuc * 73433d6423SLionel Sambuc *****************************************************************************/ 74433d6423SLionel Sambuc 75433d6423SLionel Sambuc 76433d6423SLionel Sambuc /* 77433d6423SLionel Sambuc * psxface - Parser external interfaces 78433d6423SLionel Sambuc */ 79433d6423SLionel Sambuc ACPI_STATUS 80433d6423SLionel Sambuc AcpiPsExecuteMethod ( 81433d6423SLionel Sambuc ACPI_EVALUATE_INFO *Info); 82433d6423SLionel Sambuc 83433d6423SLionel Sambuc 84433d6423SLionel Sambuc /* 85433d6423SLionel Sambuc * psargs - Parse AML opcode arguments 86433d6423SLionel Sambuc */ 87433d6423SLionel Sambuc UINT8 * 88433d6423SLionel Sambuc AcpiPsGetNextPackageEnd ( 89433d6423SLionel Sambuc ACPI_PARSE_STATE *ParserState); 90433d6423SLionel Sambuc 91433d6423SLionel Sambuc char * 92433d6423SLionel Sambuc AcpiPsGetNextNamestring ( 93433d6423SLionel Sambuc ACPI_PARSE_STATE *ParserState); 94433d6423SLionel Sambuc 95433d6423SLionel Sambuc void 96433d6423SLionel Sambuc AcpiPsGetNextSimpleArg ( 97433d6423SLionel Sambuc ACPI_PARSE_STATE *ParserState, 98433d6423SLionel Sambuc UINT32 ArgType, 99433d6423SLionel Sambuc ACPI_PARSE_OBJECT *Arg); 100433d6423SLionel Sambuc 101433d6423SLionel Sambuc ACPI_STATUS 102433d6423SLionel Sambuc AcpiPsGetNextNamepath ( 103433d6423SLionel Sambuc ACPI_WALK_STATE *WalkState, 104433d6423SLionel Sambuc ACPI_PARSE_STATE *ParserState, 105433d6423SLionel Sambuc ACPI_PARSE_OBJECT *Arg, 106433d6423SLionel Sambuc BOOLEAN MethodCall); 107433d6423SLionel Sambuc 108433d6423SLionel Sambuc ACPI_STATUS 109433d6423SLionel Sambuc AcpiPsGetNextArg ( 110433d6423SLionel Sambuc ACPI_WALK_STATE *WalkState, 111433d6423SLionel Sambuc ACPI_PARSE_STATE *ParserState, 112433d6423SLionel Sambuc UINT32 ArgType, 113433d6423SLionel Sambuc ACPI_PARSE_OBJECT **ReturnArg); 114433d6423SLionel Sambuc 115433d6423SLionel Sambuc 116433d6423SLionel Sambuc /* 117433d6423SLionel Sambuc * psfind 118433d6423SLionel Sambuc */ 119433d6423SLionel Sambuc ACPI_PARSE_OBJECT * 120433d6423SLionel Sambuc AcpiPsFindName ( 121433d6423SLionel Sambuc ACPI_PARSE_OBJECT *Scope, 122433d6423SLionel Sambuc UINT32 Name, 123433d6423SLionel Sambuc UINT32 Opcode); 124433d6423SLionel Sambuc 125433d6423SLionel Sambuc ACPI_PARSE_OBJECT* 126433d6423SLionel Sambuc AcpiPsGetParent ( 127433d6423SLionel Sambuc ACPI_PARSE_OBJECT *Op); 128433d6423SLionel Sambuc 129433d6423SLionel Sambuc 130433d6423SLionel Sambuc /* 131*29492bb7SDavid van Moolenbroek * psobject - support for parse object processing 132*29492bb7SDavid van Moolenbroek */ 133*29492bb7SDavid van Moolenbroek ACPI_STATUS 134*29492bb7SDavid van Moolenbroek AcpiPsBuildNamedOp ( 135*29492bb7SDavid van Moolenbroek ACPI_WALK_STATE *WalkState, 136*29492bb7SDavid van Moolenbroek UINT8 *AmlOpStart, 137*29492bb7SDavid van Moolenbroek ACPI_PARSE_OBJECT *UnnamedOp, 138*29492bb7SDavid van Moolenbroek ACPI_PARSE_OBJECT **Op); 139*29492bb7SDavid van Moolenbroek 140*29492bb7SDavid van Moolenbroek ACPI_STATUS 141*29492bb7SDavid van Moolenbroek AcpiPsCreateOp ( 142*29492bb7SDavid van Moolenbroek ACPI_WALK_STATE *WalkState, 143*29492bb7SDavid van Moolenbroek UINT8 *AmlOpStart, 144*29492bb7SDavid van Moolenbroek ACPI_PARSE_OBJECT **NewOp); 145*29492bb7SDavid van Moolenbroek 146*29492bb7SDavid van Moolenbroek ACPI_STATUS 147*29492bb7SDavid van Moolenbroek AcpiPsCompleteOp ( 148*29492bb7SDavid van Moolenbroek ACPI_WALK_STATE *WalkState, 149*29492bb7SDavid van Moolenbroek ACPI_PARSE_OBJECT **Op, 150*29492bb7SDavid van Moolenbroek ACPI_STATUS Status); 151*29492bb7SDavid van Moolenbroek 152*29492bb7SDavid van Moolenbroek ACPI_STATUS 153*29492bb7SDavid van Moolenbroek AcpiPsCompleteFinalOp ( 154*29492bb7SDavid van Moolenbroek ACPI_WALK_STATE *WalkState, 155*29492bb7SDavid van Moolenbroek ACPI_PARSE_OBJECT *Op, 156*29492bb7SDavid van Moolenbroek ACPI_STATUS Status); 157*29492bb7SDavid van Moolenbroek 158*29492bb7SDavid van Moolenbroek 159*29492bb7SDavid van Moolenbroek /* 160*29492bb7SDavid van Moolenbroek * psopinfo - AML Opcode information 161433d6423SLionel Sambuc */ 162433d6423SLionel Sambuc const ACPI_OPCODE_INFO * 163433d6423SLionel Sambuc AcpiPsGetOpcodeInfo ( 164433d6423SLionel Sambuc UINT16 Opcode); 165433d6423SLionel Sambuc 166433d6423SLionel Sambuc char * 167433d6423SLionel Sambuc AcpiPsGetOpcodeName ( 168433d6423SLionel Sambuc UINT16 Opcode); 169433d6423SLionel Sambuc 170433d6423SLionel Sambuc UINT8 171433d6423SLionel Sambuc AcpiPsGetArgumentCount ( 172433d6423SLionel Sambuc UINT32 OpType); 173433d6423SLionel Sambuc 174433d6423SLionel Sambuc 175433d6423SLionel Sambuc /* 176433d6423SLionel Sambuc * psparse - top level parsing routines 177433d6423SLionel Sambuc */ 178433d6423SLionel Sambuc ACPI_STATUS 179433d6423SLionel Sambuc AcpiPsParseAml ( 180433d6423SLionel Sambuc ACPI_WALK_STATE *WalkState); 181433d6423SLionel Sambuc 182433d6423SLionel Sambuc UINT32 183433d6423SLionel Sambuc AcpiPsGetOpcodeSize ( 184433d6423SLionel Sambuc UINT32 Opcode); 185433d6423SLionel Sambuc 186433d6423SLionel Sambuc UINT16 187433d6423SLionel Sambuc AcpiPsPeekOpcode ( 188433d6423SLionel Sambuc ACPI_PARSE_STATE *state); 189433d6423SLionel Sambuc 190433d6423SLionel Sambuc ACPI_STATUS 191433d6423SLionel Sambuc AcpiPsCompleteThisOp ( 192433d6423SLionel Sambuc ACPI_WALK_STATE *WalkState, 193433d6423SLionel Sambuc ACPI_PARSE_OBJECT *Op); 194433d6423SLionel Sambuc 195433d6423SLionel Sambuc ACPI_STATUS 196433d6423SLionel Sambuc AcpiPsNextParseState ( 197433d6423SLionel Sambuc ACPI_WALK_STATE *WalkState, 198433d6423SLionel Sambuc ACPI_PARSE_OBJECT *Op, 199433d6423SLionel Sambuc ACPI_STATUS CallbackStatus); 200433d6423SLionel Sambuc 201433d6423SLionel Sambuc 202433d6423SLionel Sambuc /* 203433d6423SLionel Sambuc * psloop - main parse loop 204433d6423SLionel Sambuc */ 205433d6423SLionel Sambuc ACPI_STATUS 206433d6423SLionel Sambuc AcpiPsParseLoop ( 207433d6423SLionel Sambuc ACPI_WALK_STATE *WalkState); 208433d6423SLionel Sambuc 209433d6423SLionel Sambuc 210433d6423SLionel Sambuc /* 211433d6423SLionel Sambuc * psscope - Scope stack management routines 212433d6423SLionel Sambuc */ 213433d6423SLionel Sambuc ACPI_STATUS 214433d6423SLionel Sambuc AcpiPsInitScope ( 215433d6423SLionel Sambuc ACPI_PARSE_STATE *ParserState, 216433d6423SLionel Sambuc ACPI_PARSE_OBJECT *Root); 217433d6423SLionel Sambuc 218433d6423SLionel Sambuc ACPI_PARSE_OBJECT * 219433d6423SLionel Sambuc AcpiPsGetParentScope ( 220433d6423SLionel Sambuc ACPI_PARSE_STATE *state); 221433d6423SLionel Sambuc 222433d6423SLionel Sambuc BOOLEAN 223433d6423SLionel Sambuc AcpiPsHasCompletedScope ( 224433d6423SLionel Sambuc ACPI_PARSE_STATE *ParserState); 225433d6423SLionel Sambuc 226433d6423SLionel Sambuc void 227433d6423SLionel Sambuc AcpiPsPopScope ( 228433d6423SLionel Sambuc ACPI_PARSE_STATE *ParserState, 229433d6423SLionel Sambuc ACPI_PARSE_OBJECT **Op, 230433d6423SLionel Sambuc UINT32 *ArgList, 231433d6423SLionel Sambuc UINT32 *ArgCount); 232433d6423SLionel Sambuc 233433d6423SLionel Sambuc ACPI_STATUS 234433d6423SLionel Sambuc AcpiPsPushScope ( 235433d6423SLionel Sambuc ACPI_PARSE_STATE *ParserState, 236433d6423SLionel Sambuc ACPI_PARSE_OBJECT *Op, 237433d6423SLionel Sambuc UINT32 RemainingArgs, 238433d6423SLionel Sambuc UINT32 ArgCount); 239433d6423SLionel Sambuc 240433d6423SLionel Sambuc void 241433d6423SLionel Sambuc AcpiPsCleanupScope ( 242433d6423SLionel Sambuc ACPI_PARSE_STATE *state); 243433d6423SLionel Sambuc 244433d6423SLionel Sambuc 245433d6423SLionel Sambuc /* 246433d6423SLionel Sambuc * pstree - parse tree manipulation routines 247433d6423SLionel Sambuc */ 248433d6423SLionel Sambuc void 249433d6423SLionel Sambuc AcpiPsAppendArg( 250433d6423SLionel Sambuc ACPI_PARSE_OBJECT *op, 251433d6423SLionel Sambuc ACPI_PARSE_OBJECT *arg); 252433d6423SLionel Sambuc 253433d6423SLionel Sambuc ACPI_PARSE_OBJECT* 254433d6423SLionel Sambuc AcpiPsFind ( 255433d6423SLionel Sambuc ACPI_PARSE_OBJECT *Scope, 256433d6423SLionel Sambuc char *Path, 257433d6423SLionel Sambuc UINT16 Opcode, 258433d6423SLionel Sambuc UINT32 Create); 259433d6423SLionel Sambuc 260433d6423SLionel Sambuc ACPI_PARSE_OBJECT * 261433d6423SLionel Sambuc AcpiPsGetArg( 262433d6423SLionel Sambuc ACPI_PARSE_OBJECT *op, 263433d6423SLionel Sambuc UINT32 argn); 264433d6423SLionel Sambuc 265433d6423SLionel Sambuc ACPI_PARSE_OBJECT * 266433d6423SLionel Sambuc AcpiPsGetDepthNext ( 267433d6423SLionel Sambuc ACPI_PARSE_OBJECT *Origin, 268433d6423SLionel Sambuc ACPI_PARSE_OBJECT *Op); 269433d6423SLionel Sambuc 270433d6423SLionel Sambuc 271433d6423SLionel Sambuc /* 272433d6423SLionel Sambuc * pswalk - parse tree walk routines 273433d6423SLionel Sambuc */ 274433d6423SLionel Sambuc ACPI_STATUS 275433d6423SLionel Sambuc AcpiPsWalkParsedAml ( 276433d6423SLionel Sambuc ACPI_PARSE_OBJECT *StartOp, 277433d6423SLionel Sambuc ACPI_PARSE_OBJECT *EndOp, 278433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *MthDesc, 279433d6423SLionel Sambuc ACPI_NAMESPACE_NODE *StartNode, 280433d6423SLionel Sambuc ACPI_OPERAND_OBJECT **Params, 281433d6423SLionel Sambuc ACPI_OPERAND_OBJECT **CallerReturnDesc, 282433d6423SLionel Sambuc ACPI_OWNER_ID OwnerId, 283433d6423SLionel Sambuc ACPI_PARSE_DOWNWARDS DescendingCallback, 284433d6423SLionel Sambuc ACPI_PARSE_UPWARDS AscendingCallback); 285433d6423SLionel Sambuc 286433d6423SLionel Sambuc ACPI_STATUS 287433d6423SLionel Sambuc AcpiPsGetNextWalkOp ( 288433d6423SLionel Sambuc ACPI_WALK_STATE *WalkState, 289433d6423SLionel Sambuc ACPI_PARSE_OBJECT *Op, 290433d6423SLionel Sambuc ACPI_PARSE_UPWARDS AscendingCallback); 291433d6423SLionel Sambuc 292433d6423SLionel Sambuc ACPI_STATUS 293433d6423SLionel Sambuc AcpiPsDeleteCompletedOp ( 294433d6423SLionel Sambuc ACPI_WALK_STATE *WalkState); 295433d6423SLionel Sambuc 296433d6423SLionel Sambuc void 297433d6423SLionel Sambuc AcpiPsDeleteParseTree ( 298433d6423SLionel Sambuc ACPI_PARSE_OBJECT *root); 299433d6423SLionel Sambuc 300433d6423SLionel Sambuc 301433d6423SLionel Sambuc /* 302433d6423SLionel Sambuc * psutils - parser utilities 303433d6423SLionel Sambuc */ 304433d6423SLionel Sambuc ACPI_PARSE_OBJECT * 305433d6423SLionel Sambuc AcpiPsCreateScopeOp ( 306433d6423SLionel Sambuc void); 307433d6423SLionel Sambuc 308433d6423SLionel Sambuc void 309433d6423SLionel Sambuc AcpiPsInitOp ( 310433d6423SLionel Sambuc ACPI_PARSE_OBJECT *op, 311433d6423SLionel Sambuc UINT16 opcode); 312433d6423SLionel Sambuc 313433d6423SLionel Sambuc ACPI_PARSE_OBJECT * 314433d6423SLionel Sambuc AcpiPsAllocOp ( 315433d6423SLionel Sambuc UINT16 opcode); 316433d6423SLionel Sambuc 317433d6423SLionel Sambuc void 318433d6423SLionel Sambuc AcpiPsFreeOp ( 319433d6423SLionel Sambuc ACPI_PARSE_OBJECT *Op); 320433d6423SLionel Sambuc 321433d6423SLionel Sambuc BOOLEAN 322433d6423SLionel Sambuc AcpiPsIsLeadingChar ( 323433d6423SLionel Sambuc UINT32 c); 324433d6423SLionel Sambuc 325433d6423SLionel Sambuc UINT32 326433d6423SLionel Sambuc AcpiPsGetName( 327433d6423SLionel Sambuc ACPI_PARSE_OBJECT *op); 328433d6423SLionel Sambuc 329433d6423SLionel Sambuc void 330433d6423SLionel Sambuc AcpiPsSetName( 331433d6423SLionel Sambuc ACPI_PARSE_OBJECT *op, 332433d6423SLionel Sambuc UINT32 name); 333433d6423SLionel Sambuc 334433d6423SLionel Sambuc 335433d6423SLionel Sambuc /* 336433d6423SLionel Sambuc * psdump - display parser tree 337433d6423SLionel Sambuc */ 338433d6423SLionel Sambuc UINT32 339433d6423SLionel Sambuc AcpiPsSprintPath ( 340433d6423SLionel Sambuc char *BufferStart, 341433d6423SLionel Sambuc UINT32 BufferSize, 342433d6423SLionel Sambuc ACPI_PARSE_OBJECT *Op); 343433d6423SLionel Sambuc 344433d6423SLionel Sambuc UINT32 345433d6423SLionel Sambuc AcpiPsSprintOp ( 346433d6423SLionel Sambuc char *BufferStart, 347433d6423SLionel Sambuc UINT32 BufferSize, 348433d6423SLionel Sambuc ACPI_PARSE_OBJECT *Op); 349433d6423SLionel Sambuc 350433d6423SLionel Sambuc void 351433d6423SLionel Sambuc AcpiPsShow ( 352433d6423SLionel Sambuc ACPI_PARSE_OBJECT *op); 353433d6423SLionel Sambuc 354433d6423SLionel Sambuc 355433d6423SLionel Sambuc #endif /* __ACPARSER_H__ */ 356