Home | History | Annotate | Line # | Download | only in dispatcher
dswload2.c revision 1.1.1.16
      1 /******************************************************************************
      2  *
      3  * Module Name: dswload2 - Dispatcher second pass namespace load callbacks
      4  *
      5  *****************************************************************************/
      6 
      7 /*
      8  * Copyright (C) 2000 - 2020, 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 #include "acpi.h"
     45 #include "accommon.h"
     46 #include "acparser.h"
     47 #include "amlcode.h"
     48 #include "acdispat.h"
     49 #include "acinterp.h"
     50 #include "acnamesp.h"
     51 #include "acevents.h"
     52 #ifdef ACPI_EXEC_APP
     53 #include "aecommon.h"
     54 #endif
     55 
     56 #define _COMPONENT          ACPI_DISPATCHER
     57         ACPI_MODULE_NAME    ("dswload2")
     58 
     59 
     60 /*******************************************************************************
     61  *
     62  * FUNCTION:    AcpiDsLoad2BeginOp
     63  *
     64  * PARAMETERS:  WalkState       - Current state of the parse tree walk
     65  *              OutOp           - Where to return op if a new one is created
     66  *
     67  * RETURN:      Status
     68  *
     69  * DESCRIPTION: Descending callback used during the loading of ACPI tables.
     70  *
     71  ******************************************************************************/
     72 
     73 ACPI_STATUS
     74 AcpiDsLoad2BeginOp (
     75     ACPI_WALK_STATE         *WalkState,
     76     ACPI_PARSE_OBJECT       **OutOp)
     77 {
     78     ACPI_PARSE_OBJECT       *Op;
     79     ACPI_NAMESPACE_NODE     *Node;
     80     ACPI_STATUS             Status;
     81     ACPI_OBJECT_TYPE        ObjectType;
     82     char                    *BufferPtr;
     83     UINT32                  Flags;
     84 
     85 
     86     ACPI_FUNCTION_TRACE (DsLoad2BeginOp);
     87 
     88 
     89     Op = WalkState->Op;
     90     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState));
     91 
     92     if (Op)
     93     {
     94         if ((WalkState->ControlState) &&
     95             (WalkState->ControlState->Common.State ==
     96                 ACPI_CONTROL_CONDITIONAL_EXECUTING))
     97         {
     98             /* We are executing a while loop outside of a method */
     99 
    100             Status = AcpiDsExecBeginOp (WalkState, OutOp);
    101             return_ACPI_STATUS (Status);
    102         }
    103 
    104         /* We only care about Namespace opcodes here */
    105 
    106         if ((!(WalkState->OpInfo->Flags & AML_NSOPCODE)   &&
    107               (WalkState->Opcode != AML_INT_NAMEPATH_OP)) ||
    108             (!(WalkState->OpInfo->Flags & AML_NAMED)))
    109         {
    110             return_ACPI_STATUS (AE_OK);
    111         }
    112 
    113         /* Get the name we are going to enter or lookup in the namespace */
    114 
    115         if (WalkState->Opcode == AML_INT_NAMEPATH_OP)
    116         {
    117             /* For Namepath op, get the path string */
    118 
    119             BufferPtr = Op->Common.Value.String;
    120             if (!BufferPtr)
    121             {
    122                 /* No name, just exit */
    123 
    124                 return_ACPI_STATUS (AE_OK);
    125             }
    126         }
    127         else
    128         {
    129             /* Get name from the op */
    130 
    131             BufferPtr = ACPI_CAST_PTR (char, &Op->Named.Name);
    132         }
    133     }
    134     else
    135     {
    136         /* Get the namestring from the raw AML */
    137 
    138         BufferPtr = AcpiPsGetNextNamestring (&WalkState->ParserState);
    139     }
    140 
    141     /* Map the opcode into an internal object type */
    142 
    143     ObjectType = WalkState->OpInfo->ObjectType;
    144 
    145     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
    146         "State=%p Op=%p Type=%X\n", WalkState, Op, ObjectType));
    147 
    148     switch (WalkState->Opcode)
    149     {
    150     case AML_FIELD_OP:
    151     case AML_BANK_FIELD_OP:
    152     case AML_INDEX_FIELD_OP:
    153 
    154         Node = NULL;
    155         Status = AE_OK;
    156         break;
    157 
    158     case AML_INT_NAMEPATH_OP:
    159         /*
    160          * The NamePath is an object reference to an existing object.
    161          * Don't enter the name into the namespace, but look it up
    162          * for use later.
    163          */
    164         Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
    165             ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
    166             WalkState, &(Node));
    167         break;
    168 
    169     case AML_SCOPE_OP:
    170 
    171         /* Special case for Scope(\) -> refers to the Root node */
    172 
    173         if (Op && (Op->Named.Node == AcpiGbl_RootNode))
    174         {
    175             Node = Op->Named.Node;
    176 
    177             Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState);
    178             if (ACPI_FAILURE (Status))
    179             {
    180                 return_ACPI_STATUS (Status);
    181             }
    182         }
    183         else
    184         {
    185             /*
    186              * The Path is an object reference to an existing object.
    187              * Don't enter the name into the namespace, but look it up
    188              * for use later.
    189              */
    190             Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
    191                 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
    192                 WalkState, &(Node));
    193             if (ACPI_FAILURE (Status))
    194             {
    195 #ifdef ACPI_ASL_COMPILER
    196                 if (Status == AE_NOT_FOUND)
    197                 {
    198                     Status = AE_OK;
    199                 }
    200                 else
    201                 {
    202                     ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
    203                         BufferPtr, Status);
    204                 }
    205 #else
    206                 ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
    207                     BufferPtr, Status);
    208 #endif
    209                 return_ACPI_STATUS (Status);
    210             }
    211         }
    212 
    213         /*
    214          * We must check to make sure that the target is
    215          * one of the opcodes that actually opens a scope
    216          */
    217         switch (Node->Type)
    218         {
    219         case ACPI_TYPE_ANY:
    220         case ACPI_TYPE_LOCAL_SCOPE:         /* Scope */
    221         case ACPI_TYPE_DEVICE:
    222         case ACPI_TYPE_POWER:
    223         case ACPI_TYPE_PROCESSOR:
    224         case ACPI_TYPE_THERMAL:
    225 
    226             /* These are acceptable types */
    227             break;
    228 
    229         case ACPI_TYPE_INTEGER:
    230         case ACPI_TYPE_STRING:
    231         case ACPI_TYPE_BUFFER:
    232 
    233             /*
    234              * These types we will allow, but we will change the type.
    235              * This enables some existing code of the form:
    236              *
    237              *  Name (DEB, 0)
    238              *  Scope (DEB) { ... }
    239              */
    240             ACPI_WARNING ((AE_INFO,
    241                 "Type override - [%4.4s] had invalid type (%s) "
    242                 "for Scope operator, changed to type ANY",
    243                 AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type)));
    244 
    245             Node->Type = ACPI_TYPE_ANY;
    246             WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY;
    247             break;
    248 
    249         case ACPI_TYPE_METHOD:
    250 
    251             /*
    252              * Allow scope change to root during execution of module-level
    253              * code. Root is typed METHOD during this time.
    254              */
    255             if ((Node == AcpiGbl_RootNode) &&
    256                 (WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
    257             {
    258                 break;
    259             }
    260 
    261             /*lint -fallthrough */
    262 
    263         default:
    264 
    265             /* All other types are an error */
    266 
    267             ACPI_ERROR ((AE_INFO,
    268                 "Invalid type (%s) for target of "
    269                 "Scope operator [%4.4s] (Cannot override)",
    270                 AcpiUtGetTypeName (Node->Type), AcpiUtGetNodeName (Node)));
    271 
    272             return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
    273         }
    274         break;
    275 
    276     default:
    277 
    278         /* All other opcodes */
    279 
    280         if (Op && Op->Common.Node)
    281         {
    282             /* This op/node was previously entered into the namespace */
    283 
    284             Node = Op->Common.Node;
    285 
    286             if (AcpiNsOpensScope (ObjectType))
    287             {
    288                 Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState);
    289                 if (ACPI_FAILURE (Status))
    290                 {
    291                     return_ACPI_STATUS (Status);
    292                 }
    293             }
    294 
    295             return_ACPI_STATUS (AE_OK);
    296         }
    297 
    298         /*
    299          * Enter the named type into the internal namespace. We enter the name
    300          * as we go downward in the parse tree. Any necessary subobjects that
    301          * involve arguments to the opcode must be created as we go back up the
    302          * parse tree later.
    303          *
    304          * Note: Name may already exist if we are executing a deferred opcode.
    305          */
    306         if (WalkState->DeferredNode)
    307         {
    308             /* This name is already in the namespace, get the node */
    309 
    310             Node = WalkState->DeferredNode;
    311             Status = AE_OK;
    312             break;
    313         }
    314 
    315         Flags = ACPI_NS_NO_UPSEARCH;
    316         if (WalkState->PassNumber == ACPI_IMODE_EXECUTE)
    317         {
    318             /* Execution mode, node cannot already exist, node is temporary */
    319 
    320             Flags |= ACPI_NS_ERROR_IF_FOUND;
    321 
    322             if (!(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
    323             {
    324                 Flags |= ACPI_NS_TEMPORARY;
    325             }
    326         }
    327 
    328 #ifdef ACPI_ASL_COMPILER
    329 
    330         /*
    331          * Do not open a scope for AML_EXTERNAL_OP
    332          * AcpiNsLookup can open a new scope based on the object type
    333          * of this op. AML_EXTERNAL_OP is a declaration rather than a
    334          * definition. In the case that this external is a method object,
    335          * AcpiNsLookup will open a new scope. However, an AML_EXTERNAL_OP
    336          * associated with the ACPI_TYPE_METHOD is a declaration, rather than
    337          * a definition. Flags is set to avoid opening a scope for any
    338          * AML_EXTERNAL_OP.
    339          */
    340         if (WalkState->Opcode == AML_EXTERNAL_OP)
    341         {
    342             Flags |= ACPI_NS_DONT_OPEN_SCOPE;
    343         }
    344 #endif
    345 
    346         /*
    347          * For name creation opcodes, the full namepath prefix must
    348          * exist, except for the final (new) nameseg.
    349          */
    350         if (WalkState->OpInfo->Flags & AML_NAMED)
    351         {
    352             Flags |= ACPI_NS_PREFIX_MUST_EXIST;
    353         }
    354 
    355         /* Add new entry or lookup existing entry */
    356 
    357         Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
    358             ACPI_IMODE_LOAD_PASS2, Flags, WalkState, &Node);
    359 
    360         if (ACPI_SUCCESS (Status) && (Flags & ACPI_NS_TEMPORARY))
    361         {
    362             ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
    363                 "***New Node [%4.4s] %p is temporary\n",
    364                 AcpiUtGetNodeName (Node), Node));
    365         }
    366         break;
    367     }
    368 
    369     if (ACPI_FAILURE (Status))
    370     {
    371         ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
    372             BufferPtr, Status);
    373         return_ACPI_STATUS (Status);
    374     }
    375 
    376     if (!Op)
    377     {
    378         /* Create a new op */
    379 
    380         Op = AcpiPsAllocOp (WalkState->Opcode, WalkState->Aml);
    381         if (!Op)
    382         {
    383             return_ACPI_STATUS (AE_NO_MEMORY);
    384         }
    385 
    386         /* Initialize the new op */
    387 
    388         if (Node)
    389         {
    390             Op->Named.Name = Node->Name.Integer;
    391         }
    392         *OutOp = Op;
    393     }
    394 
    395     /*
    396      * Put the Node in the "op" object that the parser uses, so we
    397      * can get it again quickly when this scope is closed
    398      */
    399     Op->Common.Node = Node;
    400     return_ACPI_STATUS (Status);
    401 }
    402 
    403 
    404 /*******************************************************************************
    405  *
    406  * FUNCTION:    AcpiDsLoad2EndOp
    407  *
    408  * PARAMETERS:  WalkState       - Current state of the parse tree walk
    409  *
    410  * RETURN:      Status
    411  *
    412  * DESCRIPTION: Ascending callback used during the loading of the namespace,
    413  *              both control methods and everything else.
    414  *
    415  ******************************************************************************/
    416 
    417 ACPI_STATUS
    418 AcpiDsLoad2EndOp (
    419     ACPI_WALK_STATE         *WalkState)
    420 {
    421     ACPI_PARSE_OBJECT       *Op;
    422     ACPI_STATUS             Status = AE_OK;
    423     ACPI_OBJECT_TYPE        ObjectType;
    424     ACPI_NAMESPACE_NODE     *Node;
    425     ACPI_PARSE_OBJECT       *Arg;
    426     ACPI_NAMESPACE_NODE     *NewNode;
    427     UINT32                  i;
    428     UINT8                   RegionSpace;
    429 #ifdef ACPI_EXEC_APP
    430     ACPI_OPERAND_OBJECT     *ObjDesc;
    431     char                    *Namepath;
    432 #endif
    433 
    434 
    435     ACPI_FUNCTION_TRACE (DsLoad2EndOp);
    436 
    437     Op = WalkState->Op;
    438     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n",
    439         WalkState->OpInfo->Name, Op, WalkState));
    440 
    441     /* Check if opcode had an associated namespace object */
    442 
    443     if (!(WalkState->OpInfo->Flags & AML_NSOBJECT))
    444     {
    445         return_ACPI_STATUS (AE_OK);
    446     }
    447 
    448     if (Op->Common.AmlOpcode == AML_SCOPE_OP)
    449     {
    450         ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
    451             "Ending scope Op=%p State=%p\n", Op, WalkState));
    452     }
    453 
    454     ObjectType = WalkState->OpInfo->ObjectType;
    455 
    456     /*
    457      * Get the Node/name from the earlier lookup
    458      * (It was saved in the *op structure)
    459      */
    460     Node = Op->Common.Node;
    461 
    462     /*
    463      * Put the Node on the object stack (Contains the ACPI Name of
    464      * this object)
    465      */
    466     WalkState->Operands[0] = (void *) Node;
    467     WalkState->NumOperands = 1;
    468 
    469     /* Pop the scope stack */
    470 
    471     if (AcpiNsOpensScope (ObjectType) &&
    472        (Op->Common.AmlOpcode != AML_INT_METHODCALL_OP))
    473     {
    474         ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n",
    475             AcpiUtGetTypeName (ObjectType), Op));
    476 
    477         Status = AcpiDsScopeStackPop (WalkState);
    478         if (ACPI_FAILURE (Status))
    479         {
    480             goto Cleanup;
    481         }
    482     }
    483 
    484     /*
    485      * Named operations are as follows:
    486      *
    487      * AML_ALIAS
    488      * AML_BANKFIELD
    489      * AML_CREATEBITFIELD
    490      * AML_CREATEBYTEFIELD
    491      * AML_CREATEDWORDFIELD
    492      * AML_CREATEFIELD
    493      * AML_CREATEQWORDFIELD
    494      * AML_CREATEWORDFIELD
    495      * AML_DATA_REGION
    496      * AML_DEVICE
    497      * AML_EVENT
    498      * AML_FIELD
    499      * AML_INDEXFIELD
    500      * AML_METHOD
    501      * AML_METHODCALL
    502      * AML_MUTEX
    503      * AML_NAME
    504      * AML_NAMEDFIELD
    505      * AML_OPREGION
    506      * AML_POWERRES
    507      * AML_PROCESSOR
    508      * AML_SCOPE
    509      * AML_THERMALZONE
    510      */
    511 
    512     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
    513         "Create-Load [%s] State=%p Op=%p NamedObj=%p\n",
    514         AcpiPsGetOpcodeName (Op->Common.AmlOpcode), WalkState, Op, Node));
    515 
    516     /* Decode the opcode */
    517 
    518     Arg = Op->Common.Value.Arg;
    519 
    520     switch (WalkState->OpInfo->Type)
    521     {
    522 
    523     case AML_TYPE_CREATE_FIELD:
    524         /*
    525          * Create the field object, but the field buffer and index must
    526          * be evaluated later during the execution phase
    527          */
    528         Status = AcpiDsCreateBufferField (Op, WalkState);
    529         if ACPI_FAILURE (Status)
    530         {
    531             ACPI_EXCEPTION ((AE_INFO, Status, "CreateBufferField failure"));
    532             goto Cleanup;
    533         }
    534         break;
    535 
    536      case AML_TYPE_NAMED_FIELD:
    537         /*
    538          * If we are executing a method, initialize the field
    539          */
    540         if (WalkState->MethodNode)
    541         {
    542             Status = AcpiDsInitFieldObjects (Op, WalkState);
    543         }
    544 
    545         switch (Op->Common.AmlOpcode)
    546         {
    547         case AML_INDEX_FIELD_OP:
    548 
    549             Status = AcpiDsCreateIndexField (
    550                 Op, (ACPI_HANDLE) Arg->Common.Node, WalkState);
    551             break;
    552 
    553         case AML_BANK_FIELD_OP:
    554 
    555             Status = AcpiDsCreateBankField (Op, Arg->Common.Node, WalkState);
    556             break;
    557 
    558         case AML_FIELD_OP:
    559 
    560             Status = AcpiDsCreateField (Op, Arg->Common.Node, WalkState);
    561             break;
    562 
    563         default:
    564 
    565             /* All NAMED_FIELD opcodes must be handled above */
    566             break;
    567         }
    568         break;
    569 
    570      case AML_TYPE_NAMED_SIMPLE:
    571 
    572         Status = AcpiDsCreateOperands (WalkState, Arg);
    573         if (ACPI_FAILURE (Status))
    574         {
    575             goto Cleanup;
    576         }
    577 
    578         switch (Op->Common.AmlOpcode)
    579         {
    580         case AML_PROCESSOR_OP:
    581 
    582             Status = AcpiExCreateProcessor (WalkState);
    583             break;
    584 
    585         case AML_POWER_RESOURCE_OP:
    586 
    587             Status = AcpiExCreatePowerResource (WalkState);
    588             break;
    589 
    590         case AML_MUTEX_OP:
    591 
    592             Status = AcpiExCreateMutex (WalkState);
    593             break;
    594 
    595         case AML_EVENT_OP:
    596 
    597             Status = AcpiExCreateEvent (WalkState);
    598             break;
    599 
    600         case AML_ALIAS_OP:
    601 
    602             Status = AcpiExCreateAlias (WalkState);
    603             break;
    604 
    605         default:
    606 
    607             /* Unknown opcode */
    608 
    609             Status = AE_OK;
    610             goto Cleanup;
    611         }
    612 
    613         /* Delete operands */
    614 
    615         for (i = 1; i < WalkState->NumOperands; i++)
    616         {
    617             AcpiUtRemoveReference (WalkState->Operands[i]);
    618             WalkState->Operands[i] = NULL;
    619         }
    620 
    621         break;
    622 
    623     case AML_TYPE_NAMED_COMPLEX:
    624 
    625         switch (Op->Common.AmlOpcode)
    626         {
    627         case AML_REGION_OP:
    628         case AML_DATA_REGION_OP:
    629 
    630             if (Op->Common.AmlOpcode == AML_REGION_OP)
    631             {
    632                 RegionSpace = (ACPI_ADR_SPACE_TYPE)
    633                     ((Op->Common.Value.Arg)->Common.Value.Integer);
    634             }
    635             else
    636             {
    637                 RegionSpace = ACPI_ADR_SPACE_DATA_TABLE;
    638             }
    639 
    640             /*
    641              * The OpRegion is not fully parsed at this time. The only valid
    642              * argument is the SpaceId. (We must save the address of the
    643              * AML of the address and length operands)
    644              *
    645              * If we have a valid region, initialize it. The namespace is
    646              * unlocked at this point.
    647              *
    648              * Need to unlock interpreter if it is locked (if we are running
    649              * a control method), in order to allow _REG methods to be run
    650              * during AcpiEvInitializeRegion.
    651              */
    652             if (WalkState->MethodNode)
    653             {
    654                 /*
    655                  * Executing a method: initialize the region and unlock
    656                  * the interpreter
    657                  */
    658                 Status = AcpiExCreateRegion (Op->Named.Data,
    659                     Op->Named.Length, RegionSpace, WalkState);
    660                 if (ACPI_FAILURE (Status))
    661                 {
    662                     return_ACPI_STATUS (Status);
    663                 }
    664             }
    665 
    666             Status = AcpiEvInitializeRegion (
    667                 AcpiNsGetAttachedObject (Node));
    668             break;
    669 
    670         case AML_NAME_OP:
    671 
    672             Status = AcpiDsCreateNode (WalkState, Node, Op);
    673             if (ACPI_FAILURE (Status))
    674             {
    675                 goto Cleanup;
    676             }
    677 
    678 #ifdef ACPI_EXEC_APP
    679             /*
    680              * AcpiExec support for namespace initialization file (initialize
    681              * Name opcodes in this code.)
    682              */
    683             Namepath = AcpiNsGetExternalPathname (Node);
    684             Status = AeLookupInitFileEntry (Namepath, &ObjDesc);
    685             if (ACPI_SUCCESS (Status))
    686             {
    687                 /* Detach any existing object, attach new object */
    688 
    689                 if (Node->Object)
    690                 {
    691                     AcpiNsDetachObject (Node);
    692                 }
    693                 AcpiNsAttachObject (Node, ObjDesc, ObjDesc->Common.Type);
    694             }
    695             ACPI_FREE (Namepath);
    696             Status = AE_OK;
    697 #endif
    698             break;
    699 
    700         case AML_METHOD_OP:
    701             /*
    702              * MethodOp PkgLength NameString MethodFlags TermList
    703              *
    704              * Note: We must create the method node/object pair as soon as we
    705              * see the method declaration. This allows later pass1 parsing
    706              * of invocations of the method (need to know the number of
    707              * arguments.)
    708              */
    709             ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
    710                 "LOADING-Method: State=%p Op=%p NamedObj=%p\n",
    711                 WalkState, Op, Op->Named.Node));
    712 
    713             if (!AcpiNsGetAttachedObject (Op->Named.Node))
    714             {
    715                 WalkState->Operands[0] = ACPI_CAST_PTR (void, Op->Named.Node);
    716                 WalkState->NumOperands = 1;
    717 
    718                 Status = AcpiDsCreateOperands (
    719                     WalkState, Op->Common.Value.Arg);
    720                 if (ACPI_SUCCESS (Status))
    721                 {
    722                     Status = AcpiExCreateMethod (
    723                         Op->Named.Data, Op->Named.Length, WalkState);
    724                 }
    725 
    726                 WalkState->Operands[0] = NULL;
    727                 WalkState->NumOperands = 0;
    728 
    729                 if (ACPI_FAILURE (Status))
    730                 {
    731                     return_ACPI_STATUS (Status);
    732                 }
    733             }
    734             break;
    735 
    736 
    737         default:
    738 
    739             /* All NAMED_COMPLEX opcodes must be handled above */
    740             break;
    741         }
    742         break;
    743 
    744     case AML_CLASS_INTERNAL:
    745 
    746         /* case AML_INT_NAMEPATH_OP: */
    747         break;
    748 
    749     case AML_CLASS_METHOD_CALL:
    750 
    751         ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
    752             "RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n",
    753             WalkState, Op, Node));
    754 
    755         /*
    756          * Lookup the method name and save the Node
    757          */
    758         Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
    759             ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS2,
    760             ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
    761             WalkState, &(NewNode));
    762         if (ACPI_SUCCESS (Status))
    763         {
    764             /*
    765              * Make sure that what we found is indeed a method
    766              * We didn't search for a method on purpose, to see if the name
    767              * would resolve
    768              */
    769             if (NewNode->Type != ACPI_TYPE_METHOD)
    770             {
    771                 Status = AE_AML_OPERAND_TYPE;
    772             }
    773 
    774             /* We could put the returned object (Node) on the object stack for
    775              * later, but for now, we will put it in the "op" object that the
    776              * parser uses, so we can get it again at the end of this scope
    777              */
    778             Op->Common.Node = NewNode;
    779         }
    780         else
    781         {
    782             ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
    783                 Arg->Common.Value.String, Status);
    784         }
    785         break;
    786 
    787 
    788     default:
    789 
    790         break;
    791     }
    792 
    793 Cleanup:
    794 
    795     /* Remove the Node pushed at the very beginning */
    796 
    797     WalkState->Operands[0] = NULL;
    798     WalkState->NumOperands = 0;
    799     return_ACPI_STATUS (Status);
    800 }
    801