ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

psloop.c
Go to the documentation of this file.
00001 /******************************************************************************
00002  *
00003  * Module Name: psloop - Main AML parse loop
00004  *
00005  *****************************************************************************/
00006 
00007 /******************************************************************************
00008  *
00009  * 1. Copyright Notice
00010  *
00011  * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp.
00012  * All rights reserved.
00013  *
00014  * 2. License
00015  *
00016  * 2.1. This is your license from Intel Corp. under its intellectual property
00017  * rights.  You may have additional license terms from the party that provided
00018  * you this software, covering your right to use that party's intellectual
00019  * property rights.
00020  *
00021  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
00022  * copy of the source code appearing in this file ("Covered Code") an
00023  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
00024  * base code distributed originally by Intel ("Original Intel Code") to copy,
00025  * make derivatives, distribute, use and display any portion of the Covered
00026  * Code in any form, with the right to sublicense such rights; and
00027  *
00028  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
00029  * license (with the right to sublicense), under only those claims of Intel
00030  * patents that are infringed by the Original Intel Code, to make, use, sell,
00031  * offer to sell, and import the Covered Code and derivative works thereof
00032  * solely to the minimum extent necessary to exercise the above copyright
00033  * license, and in no event shall the patent license extend to any additions
00034  * to or modifications of the Original Intel Code.  No other license or right
00035  * is granted directly or by implication, estoppel or otherwise;
00036  *
00037  * The above copyright and patent license is granted only if the following
00038  * conditions are met:
00039  *
00040  * 3. Conditions
00041  *
00042  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
00043  * Redistribution of source code of any substantial portion of the Covered
00044  * Code or modification with rights to further distribute source must include
00045  * the above Copyright Notice, the above License, this list of Conditions,
00046  * and the following Disclaimer and Export Compliance provision.  In addition,
00047  * Licensee must cause all Covered Code to which Licensee contributes to
00048  * contain a file documenting the changes Licensee made to create that Covered
00049  * Code and the date of any change.  Licensee must include in that file the
00050  * documentation of any changes made by any predecessor Licensee.  Licensee
00051  * must include a prominent statement that the modification is derived,
00052  * directly or indirectly, from Original Intel Code.
00053  *
00054  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
00055  * Redistribution of source code of any substantial portion of the Covered
00056  * Code or modification without rights to further distribute source must
00057  * include the following Disclaimer and Export Compliance provision in the
00058  * documentation and/or other materials provided with distribution.  In
00059  * addition, Licensee may not authorize further sublicense of source of any
00060  * portion of the Covered Code, and must include terms to the effect that the
00061  * license from Licensee to its licensee is limited to the intellectual
00062  * property embodied in the software Licensee provides to its licensee, and
00063  * not to intellectual property embodied in modifications its licensee may
00064  * make.
00065  *
00066  * 3.3. Redistribution of Executable. Redistribution in executable form of any
00067  * substantial portion of the Covered Code or modification must reproduce the
00068  * above Copyright Notice, and the following Disclaimer and Export Compliance
00069  * provision in the documentation and/or other materials provided with the
00070  * distribution.
00071  *
00072  * 3.4. Intel retains all right, title, and interest in and to the Original
00073  * Intel Code.
00074  *
00075  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
00076  * Intel shall be used in advertising or otherwise to promote the sale, use or
00077  * other dealings in products derived from or relating to the Covered Code
00078  * without prior written authorization from Intel.
00079  *
00080  * 4. Disclaimer and Export Compliance
00081  *
00082  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
00083  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
00084  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
00085  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
00086  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
00087  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
00088  * PARTICULAR PURPOSE.
00089  *
00090  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
00091  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
00092  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
00093  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
00094  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
00095  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
00096  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
00097  * LIMITED REMEDY.
00098  *
00099  * 4.3. Licensee shall not export, either directly or indirectly, any of this
00100  * software or system incorporating such software without first obtaining any
00101  * required license or other approval from the U. S. Department of Commerce or
00102  * any other agency or department of the United States Government.  In the
00103  * event Licensee exports any such software from the United States or
00104  * re-exports any such software from a foreign destination, Licensee shall
00105  * ensure that the distribution and export/re-export of the software is in
00106  * compliance with all laws, regulations, orders, or other restrictions of the
00107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
00108  * any of its subsidiaries will export/re-export any technical data, process,
00109  * software, or service, directly or indirectly, to any country for which the
00110  * United States government or any agency thereof requires an export license,
00111  * other governmental approval, or letter of assurance, without first obtaining
00112  * such license, approval or letter.
00113  *
00114  *****************************************************************************/
00115 
00116 
00117 /*
00118  * Parse the AML and build an operation tree as most interpreters, (such as
00119  * Perl) do. Parsing is done by hand rather than with a YACC generated parser
00120  * to tightly constrain stack and dynamic memory usage. Parsing is kept
00121  * flexible and the code fairly compact by parsing based on a list of AML
00122  * opcode templates in AmlOpInfo[].
00123  */
00124 
00125 #include "acpi.h"
00126 #include "accommon.h"
00127 #include "acparser.h"
00128 #include "acdispat.h"
00129 #include "amlcode.h"
00130 
00131 #define _COMPONENT          ACPI_PARSER
00132         ACPI_MODULE_NAME    ("psloop")
00133 
00134 static UINT32               AcpiGbl_Depth = 0;
00135 
00136 
00137 /* Local prototypes */
00138 
00139 static ACPI_STATUS
00140 AcpiPsGetAmlOpcode (
00141     ACPI_WALK_STATE         *WalkState);
00142 
00143 static ACPI_STATUS
00144 AcpiPsBuildNamedOp (
00145     ACPI_WALK_STATE         *WalkState,
00146     UINT8                   *AmlOpStart,
00147     ACPI_PARSE_OBJECT       *UnnamedOp,
00148     ACPI_PARSE_OBJECT       **Op);
00149 
00150 static ACPI_STATUS
00151 AcpiPsCreateOp (
00152     ACPI_WALK_STATE         *WalkState,
00153     UINT8                   *AmlOpStart,
00154     ACPI_PARSE_OBJECT       **NewOp);
00155 
00156 static ACPI_STATUS
00157 AcpiPsGetArguments (
00158     ACPI_WALK_STATE         *WalkState,
00159     UINT8                   *AmlOpStart,
00160     ACPI_PARSE_OBJECT       *Op);
00161 
00162 static ACPI_STATUS
00163 AcpiPsCompleteOp (
00164     ACPI_WALK_STATE         *WalkState,
00165     ACPI_PARSE_OBJECT       **Op,
00166     ACPI_STATUS             Status);
00167 
00168 static ACPI_STATUS
00169 AcpiPsCompleteFinalOp (
00170     ACPI_WALK_STATE         *WalkState,
00171     ACPI_PARSE_OBJECT       *Op,
00172     ACPI_STATUS             Status);
00173 
00174 static void
00175 AcpiPsLinkModuleCode (
00176     ACPI_PARSE_OBJECT       *ParentOp,
00177     UINT8                   *AmlStart,
00178     UINT32                  AmlLength,
00179     ACPI_OWNER_ID           OwnerId);
00180 
00181 
00182 /*******************************************************************************
00183  *
00184  * FUNCTION:    AcpiPsGetAmlOpcode
00185  *
00186  * PARAMETERS:  WalkState           - Current state
00187  *
00188  * RETURN:      Status
00189  *
00190  * DESCRIPTION: Extract the next AML opcode from the input stream.
00191  *
00192  ******************************************************************************/
00193 
00194 static ACPI_STATUS
00195 AcpiPsGetAmlOpcode (
00196     ACPI_WALK_STATE         *WalkState)
00197 {
00198 
00199     ACPI_FUNCTION_TRACE_PTR (PsGetAmlOpcode, WalkState);
00200 
00201 
00202     WalkState->AmlOffset = (UINT32) ACPI_PTR_DIFF (WalkState->ParserState.Aml,
00203                                 WalkState->ParserState.AmlStart);
00204     WalkState->Opcode = AcpiPsPeekOpcode (&(WalkState->ParserState));
00205 
00206     /*
00207      * First cut to determine what we have found:
00208      * 1) A valid AML opcode
00209      * 2) A name string
00210      * 3) An unknown/invalid opcode
00211      */
00212     WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode);
00213 
00214     switch (WalkState->OpInfo->Class)
00215     {
00216     case AML_CLASS_ASCII:
00217     case AML_CLASS_PREFIX:
00218         /*
00219          * Starts with a valid prefix or ASCII char, this is a name
00220          * string. Convert the bare name string to a namepath.
00221          */
00222         WalkState->Opcode = AML_INT_NAMEPATH_OP;
00223         WalkState->ArgTypes = ARGP_NAMESTRING;
00224         break;
00225 
00226     case AML_CLASS_UNKNOWN:
00227 
00228         /* The opcode is unrecognized. Just skip unknown opcodes */
00229 
00230         ACPI_ERROR ((AE_INFO,
00231              "Found unknown opcode 0x%X at AML address %p offset 0x%X, ignoring",
00232               WalkState->Opcode, WalkState->ParserState.Aml, WalkState->AmlOffset));
00233 
00234         ACPI_DUMP_BUFFER (WalkState->ParserState.Aml, 128);
00235 
00236         /* Assume one-byte bad opcode */
00237 
00238         WalkState->ParserState.Aml++;
00239         return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE);
00240 
00241     default:
00242 
00243         /* Found opcode info, this is a normal opcode */
00244 
00245         WalkState->ParserState.Aml += AcpiPsGetOpcodeSize (WalkState->Opcode);
00246         WalkState->ArgTypes = WalkState->OpInfo->ParseArgs;
00247         break;
00248     }
00249 
00250     return_ACPI_STATUS (AE_OK);
00251 }
00252 
00253 
00254 /*******************************************************************************
00255  *
00256  * FUNCTION:    AcpiPsBuildNamedOp
00257  *
00258  * PARAMETERS:  WalkState           - Current state
00259  *              AmlOpStart          - Begin of named Op in AML
00260  *              UnnamedOp           - Early Op (not a named Op)
00261  *              Op                  - Returned Op
00262  *
00263  * RETURN:      Status
00264  *
00265  * DESCRIPTION: Parse a named Op
00266  *
00267  ******************************************************************************/
00268 
00269 static ACPI_STATUS
00270 AcpiPsBuildNamedOp (
00271     ACPI_WALK_STATE         *WalkState,
00272     UINT8                   *AmlOpStart,
00273     ACPI_PARSE_OBJECT       *UnnamedOp,
00274     ACPI_PARSE_OBJECT       **Op)
00275 {
00276     ACPI_STATUS             Status = AE_OK;
00277     ACPI_PARSE_OBJECT       *Arg = NULL;
00278 
00279 
00280     ACPI_FUNCTION_TRACE_PTR (PsBuildNamedOp, WalkState);
00281 
00282 
00283     UnnamedOp->Common.Value.Arg = NULL;
00284     UnnamedOp->Common.ArgListLength = 0;
00285     UnnamedOp->Common.AmlOpcode = WalkState->Opcode;
00286 
00287     /*
00288      * Get and append arguments until we find the node that contains
00289      * the name (the type ARGP_NAME).
00290      */
00291     while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) &&
00292           (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) != ARGP_NAME))
00293     {
00294         Status = AcpiPsGetNextArg (WalkState, &(WalkState->ParserState),
00295                     GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg);
00296         if (ACPI_FAILURE (Status))
00297         {
00298             return_ACPI_STATUS (Status);
00299         }
00300 
00301         AcpiPsAppendArg (UnnamedOp, Arg);
00302         INCREMENT_ARG_LIST (WalkState->ArgTypes);
00303     }
00304 
00305     /*
00306      * Make sure that we found a NAME and didn't run out of arguments
00307      */
00308     if (!GET_CURRENT_ARG_TYPE (WalkState->ArgTypes))
00309     {
00310         return_ACPI_STATUS (AE_AML_NO_OPERAND);
00311     }
00312 
00313     /* We know that this arg is a name, move to next arg */
00314 
00315     INCREMENT_ARG_LIST (WalkState->ArgTypes);
00316 
00317     /*
00318      * Find the object. This will either insert the object into
00319      * the namespace or simply look it up
00320      */
00321     WalkState->Op = NULL;
00322 
00323     Status = WalkState->DescendingCallback (WalkState, Op);
00324     if (ACPI_FAILURE (Status))
00325     {
00326         ACPI_EXCEPTION ((AE_INFO, Status, "During name lookup/catalog"));
00327         return_ACPI_STATUS (Status);
00328     }
00329 
00330     if (!*Op)
00331     {
00332         return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE);
00333     }
00334 
00335     Status = AcpiPsNextParseState (WalkState, *Op, Status);
00336     if (ACPI_FAILURE (Status))
00337     {
00338         if (Status == AE_CTRL_PENDING)
00339         {
00340             return_ACPI_STATUS (AE_CTRL_PARSE_PENDING);
00341         }
00342         return_ACPI_STATUS (Status);
00343     }
00344 
00345     AcpiPsAppendArg (*Op, UnnamedOp->Common.Value.Arg);
00346     AcpiGbl_Depth++;
00347 
00348     if ((*Op)->Common.AmlOpcode == AML_REGION_OP ||
00349         (*Op)->Common.AmlOpcode == AML_DATA_REGION_OP)
00350     {
00351         /*
00352          * Defer final parsing of an OperationRegion body, because we don't
00353          * have enough info in the first pass to parse it correctly (i.e.,
00354          * there may be method calls within the TermArg elements of the body.)
00355          *
00356          * However, we must continue parsing because the opregion is not a
00357          * standalone package -- we don't know where the end is at this point.
00358          *
00359          * (Length is unknown until parse of the body complete)
00360          */
00361         (*Op)->Named.Data = AmlOpStart;
00362         (*Op)->Named.Length = 0;
00363     }
00364 
00365     return_ACPI_STATUS (AE_OK);
00366 }
00367 
00368 
00369 /*******************************************************************************
00370  *
00371  * FUNCTION:    AcpiPsCreateOp
00372  *
00373  * PARAMETERS:  WalkState           - Current state
00374  *              AmlOpStart          - Op start in AML
00375  *              NewOp               - Returned Op
00376  *
00377  * RETURN:      Status
00378  *
00379  * DESCRIPTION: Get Op from AML
00380  *
00381  ******************************************************************************/
00382 
00383 static ACPI_STATUS
00384 AcpiPsCreateOp (
00385     ACPI_WALK_STATE         *WalkState,
00386     UINT8                   *AmlOpStart,
00387     ACPI_PARSE_OBJECT       **NewOp)
00388 {
00389     ACPI_STATUS             Status = AE_OK;
00390     ACPI_PARSE_OBJECT       *Op;
00391     ACPI_PARSE_OBJECT       *NamedOp = NULL;
00392     ACPI_PARSE_OBJECT       *ParentScope;
00393     UINT8                   ArgumentCount;
00394     const ACPI_OPCODE_INFO  *OpInfo;
00395 
00396 
00397     ACPI_FUNCTION_TRACE_PTR (PsCreateOp, WalkState);
00398 
00399 
00400     Status = AcpiPsGetAmlOpcode (WalkState);
00401     if (Status == AE_CTRL_PARSE_CONTINUE)
00402     {
00403         return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE);
00404     }
00405 
00406     /* Create Op structure and append to parent's argument list */
00407 
00408     WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode);
00409     Op = AcpiPsAllocOp (WalkState->Opcode);
00410     if (!Op)
00411     {
00412         return_ACPI_STATUS (AE_NO_MEMORY);
00413     }
00414 
00415     if (WalkState->OpInfo->Flags & AML_NAMED)
00416     {
00417         Status = AcpiPsBuildNamedOp (WalkState, AmlOpStart, Op, &NamedOp);
00418         AcpiPsFreeOp (Op);
00419         if (ACPI_FAILURE (Status))
00420         {
00421             return_ACPI_STATUS (Status);
00422         }
00423 
00424         *NewOp = NamedOp;
00425         return_ACPI_STATUS (AE_OK);
00426     }
00427 
00428     /* Not a named opcode, just allocate Op and append to parent */
00429 
00430     if (WalkState->OpInfo->Flags & AML_CREATE)
00431     {
00432         /*
00433          * Backup to beginning of CreateXXXfield declaration
00434          * BodyLength is unknown until we parse the body
00435          */
00436         Op->Named.Data = AmlOpStart;
00437         Op->Named.Length = 0;
00438     }
00439 
00440     if (WalkState->Opcode == AML_BANK_FIELD_OP)
00441     {
00442         /*
00443          * Backup to beginning of BankField declaration
00444          * BodyLength is unknown until we parse the body
00445          */
00446         Op->Named.Data = AmlOpStart;
00447         Op->Named.Length = 0;
00448     }
00449 
00450     ParentScope = AcpiPsGetParentScope (&(WalkState->ParserState));
00451     AcpiPsAppendArg (ParentScope, Op);
00452 
00453     if (ParentScope)
00454     {
00455         OpInfo = AcpiPsGetOpcodeInfo (ParentScope->Common.AmlOpcode);
00456         if (OpInfo->Flags & AML_HAS_TARGET)
00457         {
00458             ArgumentCount = AcpiPsGetArgumentCount (OpInfo->Type);
00459             if (ParentScope->Common.ArgListLength > ArgumentCount)
00460             {
00461                 Op->Common.Flags |= ACPI_PARSEOP_TARGET;
00462             }
00463         }
00464         else if (ParentScope->Common.AmlOpcode == AML_INCREMENT_OP)
00465         {
00466             Op->Common.Flags |= ACPI_PARSEOP_TARGET;
00467         }
00468     }
00469 
00470     if (WalkState->DescendingCallback != NULL)
00471     {
00472         /*
00473          * Find the object. This will either insert the object into
00474          * the namespace or simply look it up
00475          */
00476         WalkState->Op = *NewOp = Op;
00477 
00478         Status = WalkState->DescendingCallback (WalkState, &Op);
00479         Status = AcpiPsNextParseState (WalkState, Op, Status);
00480         if (Status == AE_CTRL_PENDING)
00481         {
00482             Status = AE_CTRL_PARSE_PENDING;
00483         }
00484     }
00485 
00486     return_ACPI_STATUS (Status);
00487 }
00488 
00489 
00490 /*******************************************************************************
00491  *
00492  * FUNCTION:    AcpiPsGetArguments
00493  *
00494  * PARAMETERS:  WalkState           - Current state
00495  *              AmlOpStart          - Op start in AML
00496  *              Op                  - Current Op
00497  *
00498  * RETURN:      Status
00499  *
00500  * DESCRIPTION: Get arguments for passed Op.
00501  *
00502  ******************************************************************************/
00503 
00504 static ACPI_STATUS
00505 AcpiPsGetArguments (
00506     ACPI_WALK_STATE         *WalkState,
00507     UINT8                   *AmlOpStart,
00508     ACPI_PARSE_OBJECT       *Op)
00509 {
00510     ACPI_STATUS             Status = AE_OK;
00511     ACPI_PARSE_OBJECT       *Arg = NULL;
00512     const ACPI_OPCODE_INFO  *OpInfo;
00513 
00514 
00515     ACPI_FUNCTION_TRACE_PTR (PsGetArguments, WalkState);
00516 
00517 
00518     switch (Op->Common.AmlOpcode)
00519     {
00520     case AML_BYTE_OP:       /* AML_BYTEDATA_ARG */
00521     case AML_WORD_OP:       /* AML_WORDDATA_ARG */
00522     case AML_DWORD_OP:      /* AML_DWORDATA_ARG */
00523     case AML_QWORD_OP:      /* AML_QWORDATA_ARG */
00524     case AML_STRING_OP:     /* AML_ASCIICHARLIST_ARG */
00525 
00526         /* Fill in constant or string argument directly */
00527 
00528         AcpiPsGetNextSimpleArg (&(WalkState->ParserState),
00529             GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), Op);
00530         break;
00531 
00532     case AML_INT_NAMEPATH_OP:   /* AML_NAMESTRING_ARG */
00533 
00534         Status = AcpiPsGetNextNamepath (WalkState, &(WalkState->ParserState), Op, 1);
00535         if (ACPI_FAILURE (Status))
00536         {
00537             return_ACPI_STATUS (Status);
00538         }
00539 
00540         WalkState->ArgTypes = 0;
00541         break;
00542 
00543     default:
00544         /*
00545          * Op is not a constant or string, append each argument to the Op
00546          */
00547         while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) && !WalkState->ArgCount)
00548         {
00549             WalkState->AmlOffset = (UINT32) ACPI_PTR_DIFF (WalkState->ParserState.Aml,
00550                 WalkState->ParserState.AmlStart);
00551 
00552             Status = AcpiPsGetNextArg (WalkState, &(WalkState->ParserState),
00553                         GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg);
00554             if (ACPI_FAILURE (Status))
00555             {
00556                 return_ACPI_STATUS (Status);
00557             }
00558 
00559             if (Arg)
00560             {
00561                 Arg->Common.AmlOffset = WalkState->AmlOffset;
00562                 AcpiPsAppendArg (Op, Arg);
00563             }
00564 
00565             INCREMENT_ARG_LIST (WalkState->ArgTypes);
00566         }
00567 
00568 
00569         /*
00570          * Handle executable code at "module-level". This refers to
00571          * executable opcodes that appear outside of any control method.
00572          */
00573         if ((WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2) &&
00574             ((WalkState->ParseFlags & ACPI_PARSE_DISASSEMBLE) == 0))
00575         {
00576             /*
00577              * We want to skip If/Else/While constructs during Pass1 because we
00578              * want to actually conditionally execute the code during Pass2.
00579              *
00580              * Except for disassembly, where we always want to walk the
00581              * If/Else/While packages
00582              */
00583             switch (Op->Common.AmlOpcode)
00584             {
00585             case AML_IF_OP:
00586             case AML_ELSE_OP:
00587             case AML_WHILE_OP:
00588 
00589                 /*
00590                  * Currently supported module-level opcodes are:
00591                  * IF/ELSE/WHILE. These appear to be the most common,
00592                  * and easiest to support since they open an AML
00593                  * package.
00594                  */
00595                 if (WalkState->PassNumber == ACPI_IMODE_LOAD_PASS1)
00596                 {
00597                     AcpiPsLinkModuleCode (Op->Common.Parent, AmlOpStart,
00598                         (UINT32) (WalkState->ParserState.PkgEnd - AmlOpStart),
00599                         WalkState->OwnerId);
00600                 }
00601 
00602                 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
00603                     "Pass1: Skipping an If/Else/While body\n"));
00604 
00605                 /* Skip body of if/else/while in pass 1 */
00606 
00607                 WalkState->ParserState.Aml = WalkState->ParserState.PkgEnd;
00608                 WalkState->ArgCount = 0;
00609                 break;
00610 
00611             default:
00612                 /*
00613                  * Check for an unsupported executable opcode at module
00614                  * level. We must be in PASS1, the parent must be a SCOPE,
00615                  * The opcode class must be EXECUTE, and the opcode must
00616                  * not be an argument to another opcode.
00617                  */
00618                 if ((WalkState->PassNumber == ACPI_IMODE_LOAD_PASS1) &&
00619                     (Op->Common.Parent->Common.AmlOpcode == AML_SCOPE_OP))
00620                 {
00621                     OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
00622                     if ((OpInfo->Class == AML_CLASS_EXECUTE) &&
00623                         (!Arg))
00624                     {
00625                         ACPI_WARNING ((AE_INFO,
00626                             "Detected an unsupported executable opcode "
00627                             "at module-level: [0x%.4X] at table offset 0x%.4X",
00628                             Op->Common.AmlOpcode,
00629                             (UINT32) (ACPI_PTR_DIFF (AmlOpStart,
00630                                 WalkState->ParserState.AmlStart) +
00631                                 sizeof (ACPI_TABLE_HEADER))));
00632                     }
00633                 }
00634                 break;
00635             }
00636         }
00637 
00638         /* Special processing for certain opcodes */
00639 
00640         switch (Op->Common.AmlOpcode)
00641         {
00642         case AML_METHOD_OP:
00643             /*
00644              * Skip parsing of control method because we don't have enough
00645              * info in the first pass to parse it correctly.
00646              *
00647              * Save the length and address of the body
00648              */
00649             Op->Named.Data = WalkState->ParserState.Aml;
00650             Op->Named.Length = (UINT32)
00651                 (WalkState->ParserState.PkgEnd - WalkState->ParserState.Aml);
00652 
00653             /* Skip body of method */
00654 
00655             WalkState->ParserState.Aml = WalkState->ParserState.PkgEnd;
00656             WalkState->ArgCount = 0;
00657             break;
00658 
00659         case AML_BUFFER_OP:
00660         case AML_PACKAGE_OP:
00661         case AML_VAR_PACKAGE_OP:
00662 
00663             if ((Op->Common.Parent) &&
00664                 (Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) &&
00665                 (WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2))
00666             {
00667                 /*
00668                  * Skip parsing of Buffers and Packages because we don't have
00669                  * enough info in the first pass to parse them correctly.
00670                  */
00671                 Op->Named.Data = AmlOpStart;
00672                 Op->Named.Length = (UINT32)
00673                     (WalkState->ParserState.PkgEnd - AmlOpStart);
00674 
00675                 /* Skip body */
00676 
00677                 WalkState->ParserState.Aml = WalkState->ParserState.PkgEnd;
00678                 WalkState->ArgCount = 0;
00679             }
00680             break;
00681 
00682         case AML_WHILE_OP:
00683 
00684             if (WalkState->ControlState)
00685             {
00686                 WalkState->ControlState->Control.PackageEnd =
00687                     WalkState->ParserState.PkgEnd;
00688             }
00689             break;
00690 
00691         default:
00692 
00693             /* No action for all other opcodes */
00694             break;
00695         }
00696 
00697         break;
00698     }
00699 
00700     return_ACPI_STATUS (AE_OK);
00701 }
00702 
00703 
00704 /*******************************************************************************
00705  *
00706  * FUNCTION:    AcpiPsLinkModuleCode
00707  *
00708  * PARAMETERS:  ParentOp            - Parent parser op
00709  *              AmlStart            - Pointer to the AML
00710  *              AmlLength           - Length of executable AML
00711  *              OwnerId             - OwnerId of module level code
00712  *
00713  * RETURN:      None.
00714  *
00715  * DESCRIPTION: Wrap the module-level code with a method object and link the
00716  *              object to the global list. Note, the mutex field of the method
00717  *              object is used to link multiple module-level code objects.
00718  *
00719  ******************************************************************************/
00720 
00721 static void
00722 AcpiPsLinkModuleCode (
00723     ACPI_PARSE_OBJECT       *ParentOp,
00724     UINT8                   *AmlStart,
00725     UINT32                  AmlLength,
00726     ACPI_OWNER_ID           OwnerId)
00727 {
00728     ACPI_OPERAND_OBJECT     *Prev;
00729     ACPI_OPERAND_OBJECT     *Next;
00730     ACPI_OPERAND_OBJECT     *MethodObj;
00731     ACPI_NAMESPACE_NODE     *ParentNode;
00732 
00733 
00734     /* Get the tail of the list */
00735 
00736     Prev = Next = AcpiGbl_ModuleCodeList;
00737     while (Next)
00738     {
00739         Prev = Next;
00740         Next = Next->Method.Mutex;
00741     }
00742 
00743     /*
00744      * Insert the module level code into the list. Merge it if it is
00745      * adjacent to the previous element.
00746      */
00747     if (!Prev ||
00748        ((Prev->Method.AmlStart + Prev->Method.AmlLength) != AmlStart))
00749     {
00750         /* Create, initialize, and link a new temporary method object */
00751 
00752         MethodObj = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD);
00753         if (!MethodObj)
00754         {
00755             return;
00756         }
00757 
00758         if (ParentOp->Common.Node)
00759         {
00760             ParentNode = ParentOp->Common.Node;
00761         }
00762         else
00763         {
00764             ParentNode = AcpiGbl_RootNode;
00765         }
00766 
00767         MethodObj->Method.AmlStart = AmlStart;
00768         MethodObj->Method.AmlLength = AmlLength;
00769         MethodObj->Method.OwnerId = OwnerId;
00770         MethodObj->Method.InfoFlags |= ACPI_METHOD_MODULE_LEVEL;
00771 
00772         /*
00773          * Save the parent node in NextObject. This is cheating, but we
00774          * don't want to expand the method object.
00775          */
00776         MethodObj->Method.NextObject =
00777             ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ParentNode);
00778 
00779         if (!Prev)
00780         {
00781             AcpiGbl_ModuleCodeList = MethodObj;
00782         }
00783         else
00784         {
00785             Prev->Method.Mutex = MethodObj;
00786         }
00787     }
00788     else
00789     {
00790         Prev->Method.AmlLength += AmlLength;
00791     }
00792 }
00793 
00794 
00795 /*******************************************************************************
00796  *
00797  * FUNCTION:    AcpiPsCompleteOp
00798  *
00799  * PARAMETERS:  WalkState           - Current state
00800  *              Op                  - Returned Op
00801  *              Status              - Parse status before complete Op
00802  *
00803  * RETURN:      Status
00804  *
00805  * DESCRIPTION: Complete Op
00806  *
00807  ******************************************************************************/
00808 
00809 static ACPI_STATUS
00810 AcpiPsCompleteOp (
00811     ACPI_WALK_STATE         *WalkState,
00812     ACPI_PARSE_OBJECT       **Op,
00813     ACPI_STATUS             Status)
00814 {
00815     ACPI_STATUS             Status2;
00816 
00817 
00818     ACPI_FUNCTION_TRACE_PTR (PsCompleteOp, WalkState);
00819 
00820 
00821     /*
00822      * Finished one argument of the containing scope
00823      */
00824     WalkState->ParserState.Scope->ParseScope.ArgCount--;
00825 
00826     /* Close this Op (will result in parse subtree deletion) */
00827 
00828     Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
00829     if (ACPI_FAILURE (Status2))
00830     {
00831         return_ACPI_STATUS (Status2);
00832     }
00833 
00834     *Op = NULL;
00835 
00836     switch (Status)
00837     {
00838     case AE_OK:
00839         break;
00840 
00841 
00842     case AE_CTRL_TRANSFER:
00843 
00844         /* We are about to transfer to a called method */
00845 
00846         WalkState->PrevOp = NULL;
00847         WalkState->PrevArgTypes = WalkState->ArgTypes;
00848         return_ACPI_STATUS (Status);
00849 
00850 
00851     case AE_CTRL_END:
00852 
00853         AcpiPsPopScope (&(WalkState->ParserState), Op,
00854             &WalkState->ArgTypes, &WalkState->ArgCount);
00855 
00856         if (*Op)
00857         {
00858             WalkState->Op = *Op;
00859             WalkState->OpInfo = AcpiPsGetOpcodeInfo ((*Op)->Common.AmlOpcode);
00860             WalkState->Opcode = (*Op)->Common.AmlOpcode;
00861 
00862             Status = WalkState->AscendingCallback (WalkState);
00863             Status = AcpiPsNextParseState (WalkState, *Op, Status);
00864 
00865             Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
00866             if (ACPI_FAILURE (Status2))
00867             {
00868                 return_ACPI_STATUS (Status2);
00869             }
00870         }
00871 
00872         Status = AE_OK;
00873         break;
00874 
00875 
00876     case AE_CTRL_BREAK:
00877     case AE_CTRL_CONTINUE:
00878 
00879         /* Pop off scopes until we find the While */
00880 
00881         while (!(*Op) || ((*Op)->Common.AmlOpcode != AML_WHILE_OP))
00882         {
00883             AcpiPsPopScope (&(WalkState->ParserState), Op,
00884                 &WalkState->ArgTypes, &WalkState->ArgCount);
00885         }
00886 
00887         /* Close this iteration of the While loop */
00888 
00889         WalkState->Op = *Op;
00890         WalkState->OpInfo = AcpiPsGetOpcodeInfo ((*Op)->Common.AmlOpcode);
00891         WalkState->Opcode = (*Op)->Common.AmlOpcode;
00892 
00893         Status = WalkState->AscendingCallback (WalkState);
00894         Status = AcpiPsNextParseState (WalkState, *Op, Status);
00895 
00896         Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
00897         if (ACPI_FAILURE (Status2))
00898         {
00899             return_ACPI_STATUS (Status2);
00900         }
00901 
00902         Status = AE_OK;
00903         break;
00904 
00905 
00906     case AE_CTRL_TERMINATE:
00907 
00908         /* Clean up */
00909         do
00910         {
00911             if (*Op)
00912             {
00913                 Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
00914                 if (ACPI_FAILURE (Status2))
00915                 {
00916                     return_ACPI_STATUS (Status2);
00917                 }
00918 
00919                 AcpiUtDeleteGenericState (
00920                     AcpiUtPopGenericState (&WalkState->ControlState));
00921             }
00922 
00923             AcpiPsPopScope (&(WalkState->ParserState), Op,
00924                 &WalkState->ArgTypes, &WalkState->ArgCount);
00925 
00926         } while (*Op);
00927 
00928         return_ACPI_STATUS (AE_OK);
00929 
00930 
00931     default:  /* All other non-AE_OK status */
00932 
00933         do
00934         {
00935             if (*Op)
00936             {
00937                 Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
00938                 if (ACPI_FAILURE (Status2))
00939                 {
00940                     return_ACPI_STATUS (Status2);
00941                 }
00942             }
00943 
00944             AcpiPsPopScope (&(WalkState->ParserState), Op,
00945                 &WalkState->ArgTypes, &WalkState->ArgCount);
00946 
00947         } while (*Op);
00948 
00949 
00950 #if 0
00951         /*
00952          * TBD: Cleanup parse ops on error
00953          */
00954         if (*Op == NULL)
00955         {
00956             AcpiPsPopScope (ParserState, Op,
00957                 &WalkState->ArgTypes, &WalkState->ArgCount);
00958         }
00959 #endif
00960         WalkState->PrevOp = NULL;
00961         WalkState->PrevArgTypes = WalkState->ArgTypes;
00962         return_ACPI_STATUS (Status);
00963     }
00964 
00965     /* This scope complete? */
00966 
00967     if (AcpiPsHasCompletedScope (&(WalkState->ParserState)))
00968     {
00969         AcpiPsPopScope (&(WalkState->ParserState), Op,
00970             &WalkState->ArgTypes, &WalkState->ArgCount);
00971         ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", *Op));
00972     }
00973     else
00974     {
00975         *Op = NULL;
00976     }
00977 
00978     return_ACPI_STATUS (AE_OK);
00979 }
00980 
00981 
00982 /*******************************************************************************
00983  *
00984  * FUNCTION:    AcpiPsCompleteFinalOp
00985  *
00986  * PARAMETERS:  WalkState           - Current state
00987  *              Op                  - Current Op
00988  *              Status              - Current parse status before complete last
00989  *                                    Op
00990  *
00991  * RETURN:      Status
00992  *
00993  * DESCRIPTION: Complete last Op.
00994  *
00995  ******************************************************************************/
00996 
00997 static ACPI_STATUS
00998 AcpiPsCompleteFinalOp (
00999     ACPI_WALK_STATE         *WalkState,
01000     ACPI_PARSE_OBJECT       *Op,
01001     ACPI_STATUS             Status)
01002 {
01003     ACPI_STATUS             Status2;
01004 
01005 
01006     ACPI_FUNCTION_TRACE_PTR (PsCompleteFinalOp, WalkState);
01007 
01008 
01009     /*
01010      * Complete the last Op (if not completed), and clear the scope stack.
01011      * It is easily possible to end an AML "package" with an unbounded number
01012      * of open scopes (such as when several ASL blocks are closed with
01013      * sequential closing braces). We want to terminate each one cleanly.
01014      */
01015     ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "AML package complete at Op %p\n", Op));
01016     do
01017     {
01018         if (Op)
01019         {
01020             if (WalkState->AscendingCallback != NULL)
01021             {
01022                 WalkState->Op = Op;
01023                 WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
01024                 WalkState->Opcode = Op->Common.AmlOpcode;
01025 
01026                 Status = WalkState->AscendingCallback (WalkState);
01027                 Status = AcpiPsNextParseState (WalkState, Op, Status);
01028                 if (Status == AE_CTRL_PENDING)
01029                 {
01030                     Status = AcpiPsCompleteOp (WalkState, &Op, AE_OK);
01031                     if (ACPI_FAILURE (Status))
01032                     {
01033                         return_ACPI_STATUS (Status);
01034                     }
01035                 }
01036 
01037                 if (Status == AE_CTRL_TERMINATE)
01038                 {
01039                     Status = AE_OK;
01040 
01041                     /* Clean up */
01042                     do
01043                     {
01044                         if (Op)
01045                         {
01046                             Status2 = AcpiPsCompleteThisOp (WalkState, Op);
01047                             if (ACPI_FAILURE (Status2))
01048                             {
01049                                 return_ACPI_STATUS (Status2);
01050                             }
01051                         }
01052 
01053                         AcpiPsPopScope (&(WalkState->ParserState), &Op,
01054                             &WalkState->ArgTypes, &WalkState->ArgCount);
01055 
01056                     } while (Op);
01057 
01058                     return_ACPI_STATUS (Status);
01059                 }
01060 
01061                 else if (ACPI_FAILURE (Status))
01062                 {
01063                     /* First error is most important */
01064 
01065                     (void) AcpiPsCompleteThisOp (WalkState, Op);
01066                     return_ACPI_STATUS (Status);
01067                 }
01068             }
01069 
01070             Status2 = AcpiPsCompleteThisOp (WalkState, Op);
01071             if (ACPI_FAILURE (Status2))
01072             {
01073                 return_ACPI_STATUS (Status2);
01074             }
01075         }
01076 
01077         AcpiPsPopScope (&(WalkState->ParserState), &Op, &WalkState->ArgTypes,
01078             &WalkState->ArgCount);
01079 
01080     } while (Op);
01081 
01082     return_ACPI_STATUS (Status);
01083 }
01084 
01085 
01086 /*******************************************************************************
01087  *
01088  * FUNCTION:    AcpiPsParseLoop
01089  *
01090  * PARAMETERS:  WalkState           - Current state
01091  *
01092  * RETURN:      Status
01093  *
01094  * DESCRIPTION: Parse AML (pointed to by the current parser state) and return
01095  *              a tree of ops.
01096  *
01097  ******************************************************************************/
01098 
01099 ACPI_STATUS
01100 AcpiPsParseLoop (
01101     ACPI_WALK_STATE         *WalkState)
01102 {
01103     ACPI_STATUS             Status = AE_OK;
01104     ACPI_PARSE_OBJECT       *Op = NULL;     /* current op */
01105     ACPI_PARSE_STATE        *ParserState;
01106     UINT8                   *AmlOpStart = NULL;
01107 
01108 
01109     ACPI_FUNCTION_TRACE_PTR (PsParseLoop, WalkState);
01110 
01111 
01112     if (WalkState->DescendingCallback == NULL)
01113     {
01114         return_ACPI_STATUS (AE_BAD_PARAMETER);
01115     }
01116 
01117     ParserState = &WalkState->ParserState;
01118     WalkState->ArgTypes = 0;
01119 
01120 #if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
01121 
01122     if (WalkState->WalkType & ACPI_WALK_METHOD_RESTART)
01123     {
01124         /* We are restarting a preempted control method */
01125 
01126         if (AcpiPsHasCompletedScope (ParserState))
01127         {
01128             /*
01129              * We must check if a predicate to an IF or WHILE statement
01130              * was just completed
01131              */
01132             if ((ParserState->Scope->ParseScope.Op) &&
01133                ((ParserState->Scope->ParseScope.Op->Common.AmlOpcode == AML_IF_OP) ||
01134                 (ParserState->Scope->ParseScope.Op->Common.AmlOpcode == AML_WHILE_OP)) &&
01135                 (WalkState->ControlState) &&
01136                 (WalkState->ControlState->Common.State ==
01137                     ACPI_CONTROL_PREDICATE_EXECUTING))
01138             {
01139                 /*
01140                  * A predicate was just completed, get the value of the
01141                  * predicate and branch based on that value
01142                  */
01143                 WalkState->Op = NULL;
01144                 Status = AcpiDsGetPredicateValue (WalkState, ACPI_TO_POINTER (TRUE));
01145                 if (ACPI_FAILURE (Status) &&
01146                     ((Status & AE_CODE_MASK) != AE_CODE_CONTROL))
01147                 {
01148                     if (Status == AE_AML_NO_RETURN_VALUE)
01149                     {
01150                         ACPI_EXCEPTION ((AE_INFO, Status,
01151                             "Invoked method did not return a value"));
01152                     }
01153 
01154                     ACPI_EXCEPTION ((AE_INFO, Status, "GetPredicate Failed"));
01155                     return_ACPI_STATUS (Status);
01156                 }
01157 
01158                 Status = AcpiPsNextParseState (WalkState, Op, Status);
01159             }
01160 
01161             AcpiPsPopScope (ParserState, &Op,
01162                 &WalkState->ArgTypes, &WalkState->ArgCount);
01163             ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", Op));
01164         }
01165         else if (WalkState->PrevOp)
01166         {
01167             /* We were in the middle of an op */
01168 
01169             Op = WalkState->PrevOp;
01170             WalkState->ArgTypes = WalkState->PrevArgTypes;
01171         }
01172     }
01173 #endif
01174 
01175     /* Iterative parsing loop, while there is more AML to process: */
01176 
01177     while ((ParserState->Aml < ParserState->AmlEnd) || (Op))
01178     {
01179         AmlOpStart = ParserState->Aml;
01180         if (!Op)
01181         {
01182             Status = AcpiPsCreateOp (WalkState, AmlOpStart, &Op);
01183             if (ACPI_FAILURE (Status))
01184             {
01185                 if (Status == AE_CTRL_PARSE_CONTINUE)
01186                 {
01187                     continue;
01188                 }
01189 
01190                 if (Status == AE_CTRL_PARSE_PENDING)
01191                 {
01192                     Status = AE_OK;
01193                 }
01194 
01195                 Status = AcpiPsCompleteOp (WalkState, &Op, Status);
01196                 if (ACPI_FAILURE (Status))
01197                 {
01198                     return_ACPI_STATUS (Status);
01199                 }
01200 
01201                 continue;
01202             }
01203 
01204             Op->Common.AmlOffset = WalkState->AmlOffset;
01205 
01206             if (WalkState->OpInfo)
01207             {
01208                 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
01209                     "Opcode %4.4X [%s] Op %p Aml %p AmlOffset %5.5X\n",
01210                      (UINT32) Op->Common.AmlOpcode, WalkState->OpInfo->Name,
01211                      Op, ParserState->Aml, Op->Common.AmlOffset));
01212             }
01213         }
01214 
01215 
01216         /*
01217          * Start ArgCount at zero because we don't know if there are
01218          * any args yet
01219          */
01220         WalkState->ArgCount  = 0;
01221 
01222         /* Are there any arguments that must be processed? */
01223 
01224         if (WalkState->ArgTypes)
01225         {
01226             /* Get arguments */
01227 
01228             Status = AcpiPsGetArguments (WalkState, AmlOpStart, Op);
01229             if (ACPI_FAILURE (Status))
01230             {
01231                 Status = AcpiPsCompleteOp (WalkState, &Op, Status);
01232                 if (ACPI_FAILURE (Status))
01233                 {
01234                     return_ACPI_STATUS (Status);
01235                 }
01236 
01237                 continue;
01238             }
01239         }
01240 
01241         /* Check for arguments that need to be processed */
01242 
01243         if (WalkState->ArgCount)
01244         {
01245             /*
01246              * There are arguments (complex ones), push Op and
01247              * prepare for argument
01248              */
01249             Status = AcpiPsPushScope (ParserState, Op,
01250                         WalkState->ArgTypes, WalkState->ArgCount);
01251             if (ACPI_FAILURE (Status))
01252             {
01253                 Status = AcpiPsCompleteOp (WalkState, &Op, Status);
01254                 if (ACPI_FAILURE (Status))
01255                 {
01256                     return_ACPI_STATUS (Status);
01257                 }
01258 
01259                 continue;
01260             }
01261 
01262             Op = NULL;
01263             continue;
01264         }
01265 
01266         /*
01267          * All arguments have been processed -- Op is complete,
01268          * prepare for next
01269          */
01270         WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
01271         if (WalkState->OpInfo->Flags & AML_NAMED)
01272         {
01273             if (AcpiGbl_Depth)
01274             {
01275                 AcpiGbl_Depth--;
01276             }
01277 
01278             if (Op->Common.AmlOpcode == AML_REGION_OP ||
01279                 Op->Common.AmlOpcode == AML_DATA_REGION_OP)
01280             {
01281                 /*
01282                  * Skip parsing of control method or opregion body,
01283                  * because we don't have enough info in the first pass
01284                  * to parse them correctly.
01285                  *
01286                  * Completed parsing an OpRegion declaration, we now
01287                  * know the length.
01288                  */
01289                 Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data);
01290             }
01291         }
01292 
01293         if (WalkState->OpInfo->Flags & AML_CREATE)
01294         {
01295             /*
01296              * Backup to beginning of CreateXXXfield declaration (1 for
01297              * Opcode)
01298              *
01299              * BodyLength is unknown until we parse the body
01300              */
01301             Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data);
01302         }
01303 
01304         if (Op->Common.AmlOpcode == AML_BANK_FIELD_OP)
01305         {
01306             /*
01307              * Backup to beginning of BankField declaration
01308              *
01309              * BodyLength is unknown until we parse the body
01310              */
01311             Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data);
01312         }
01313 
01314         /* This op complete, notify the dispatcher */
01315 
01316         if (WalkState->AscendingCallback != NULL)
01317         {
01318             WalkState->Op = Op;
01319             WalkState->Opcode = Op->Common.AmlOpcode;
01320 
01321             Status = WalkState->AscendingCallback (WalkState);
01322             Status = AcpiPsNextParseState (WalkState, Op, Status);
01323             if (Status == AE_CTRL_PENDING)
01324             {
01325                 Status = AE_OK;
01326             }
01327         }
01328 
01329         Status = AcpiPsCompleteOp (WalkState, &Op, Status);
01330         if (ACPI_FAILURE (Status))
01331         {
01332             return_ACPI_STATUS (Status);
01333         }
01334 
01335     } /* while ParserState->Aml */
01336 
01337     Status = AcpiPsCompleteFinalOp (WalkState, Op, Status);
01338     return_ACPI_STATUS (Status);
01339 }
01340 

Generated on Fri May 25 2012 04:25:38 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.