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