Path: blob/main/sys/contrib/dev/acpica/components/dispatcher/dswload2.c
48521 views
/******************************************************************************1*2* Module Name: dswload2 - Dispatcher second pass namespace load callbacks3*4*****************************************************************************/56/******************************************************************************7*8* 1. Copyright Notice9*10* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.11* All rights reserved.12*13* 2. License14*15* 2.1. This is your license from Intel Corp. under its intellectual property16* rights. You may have additional license terms from the party that provided17* you this software, covering your right to use that party's intellectual18* property rights.19*20* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a21* copy of the source code appearing in this file ("Covered Code") an22* irrevocable, perpetual, worldwide license under Intel's copyrights in the23* base code distributed originally by Intel ("Original Intel Code") to copy,24* make derivatives, distribute, use and display any portion of the Covered25* Code in any form, with the right to sublicense such rights; and26*27* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent28* license (with the right to sublicense), under only those claims of Intel29* patents that are infringed by the Original Intel Code, to make, use, sell,30* offer to sell, and import the Covered Code and derivative works thereof31* solely to the minimum extent necessary to exercise the above copyright32* license, and in no event shall the patent license extend to any additions33* to or modifications of the Original Intel Code. No other license or right34* is granted directly or by implication, estoppel or otherwise;35*36* The above copyright and patent license is granted only if the following37* conditions are met:38*39* 3. Conditions40*41* 3.1. Redistribution of Source with Rights to Further Distribute Source.42* Redistribution of source code of any substantial portion of the Covered43* Code or modification with rights to further distribute source must include44* the above Copyright Notice, the above License, this list of Conditions,45* and the following Disclaimer and Export Compliance provision. In addition,46* Licensee must cause all Covered Code to which Licensee contributes to47* contain a file documenting the changes Licensee made to create that Covered48* Code and the date of any change. Licensee must include in that file the49* documentation of any changes made by any predecessor Licensee. Licensee50* must include a prominent statement that the modification is derived,51* directly or indirectly, from Original Intel Code.52*53* 3.2. Redistribution of Source with no Rights to Further Distribute Source.54* Redistribution of source code of any substantial portion of the Covered55* Code or modification without rights to further distribute source must56* include the following Disclaimer and Export Compliance provision in the57* documentation and/or other materials provided with distribution. In58* addition, Licensee may not authorize further sublicense of source of any59* portion of the Covered Code, and must include terms to the effect that the60* license from Licensee to its licensee is limited to the intellectual61* property embodied in the software Licensee provides to its licensee, and62* not to intellectual property embodied in modifications its licensee may63* make.64*65* 3.3. Redistribution of Executable. Redistribution in executable form of any66* substantial portion of the Covered Code or modification must reproduce the67* above Copyright Notice, and the following Disclaimer and Export Compliance68* provision in the documentation and/or other materials provided with the69* distribution.70*71* 3.4. Intel retains all right, title, and interest in and to the Original72* Intel Code.73*74* 3.5. Neither the name Intel nor any other trademark owned or controlled by75* Intel shall be used in advertising or otherwise to promote the sale, use or76* other dealings in products derived from or relating to the Covered Code77* without prior written authorization from Intel.78*79* 4. Disclaimer and Export Compliance80*81* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED82* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE83* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,84* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY85* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY86* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A87* PARTICULAR PURPOSE.88*89* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES90* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR91* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,92* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY93* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL94* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS95* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY96* LIMITED REMEDY.97*98* 4.3. Licensee shall not export, either directly or indirectly, any of this99* software or system incorporating such software without first obtaining any100* required license or other approval from the U. S. Department of Commerce or101* any other agency or department of the United States Government. In the102* event Licensee exports any such software from the United States or103* re-exports any such software from a foreign destination, Licensee shall104* ensure that the distribution and export/re-export of the software is in105* compliance with all laws, regulations, orders, or other restrictions of the106* U.S. Export Administration Regulations. Licensee agrees that neither it nor107* any of its subsidiaries will export/re-export any technical data, process,108* software, or service, directly or indirectly, to any country for which the109* United States government or any agency thereof requires an export license,110* other governmental approval, or letter of assurance, without first obtaining111* such license, approval or letter.112*113*****************************************************************************114*115* Alternatively, you may choose to be licensed under the terms of the116* following license:117*118* Redistribution and use in source and binary forms, with or without119* modification, are permitted provided that the following conditions120* are met:121* 1. Redistributions of source code must retain the above copyright122* notice, this list of conditions, and the following disclaimer,123* without modification.124* 2. Redistributions in binary form must reproduce at minimum a disclaimer125* substantially similar to the "NO WARRANTY" disclaimer below126* ("Disclaimer") and any redistribution must be conditioned upon127* including a substantially similar Disclaimer requirement for further128* binary redistribution.129* 3. Neither the names of the above-listed copyright holders nor the names130* of any contributors may be used to endorse or promote products derived131* from this software without specific prior written permission.132*133* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS134* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT135* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR136* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT137* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,138* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT139* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,140* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY141* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT142* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE143* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.144*145* Alternatively, you may choose to be licensed under the terms of the146* GNU General Public License ("GPL") version 2 as published by the Free147* Software Foundation.148*149*****************************************************************************/150151#include <contrib/dev/acpica/include/acpi.h>152#include <contrib/dev/acpica/include/accommon.h>153#include <contrib/dev/acpica/include/acparser.h>154#include <contrib/dev/acpica/include/amlcode.h>155#include <contrib/dev/acpica/include/acdispat.h>156#include <contrib/dev/acpica/include/acinterp.h>157#include <contrib/dev/acpica/include/acnamesp.h>158#include <contrib/dev/acpica/include/acevents.h>159#if !defined(ACPI_DB_APP) && defined(ACPI_EXEC_APP)160#include "aecommon.h"161#endif162163#define _COMPONENT ACPI_DISPATCHER164ACPI_MODULE_NAME ("dswload2")165166167/*******************************************************************************168*169* FUNCTION: AcpiDsLoad2BeginOp170*171* PARAMETERS: WalkState - Current state of the parse tree walk172* OutOp - Where to return op if a new one is created173*174* RETURN: Status175*176* DESCRIPTION: Descending callback used during the loading of ACPI tables.177*178******************************************************************************/179180ACPI_STATUS181AcpiDsLoad2BeginOp (182ACPI_WALK_STATE *WalkState,183ACPI_PARSE_OBJECT **OutOp)184{185ACPI_PARSE_OBJECT *Op;186ACPI_NAMESPACE_NODE *Node;187ACPI_STATUS Status;188ACPI_OBJECT_TYPE ObjectType;189char *BufferPtr;190UINT32 Flags;191192193ACPI_FUNCTION_TRACE (DsLoad2BeginOp);194195196Op = WalkState->Op;197ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState));198199if (Op)200{201if ((WalkState->ControlState) &&202(WalkState->ControlState->Common.State ==203ACPI_CONTROL_CONDITIONAL_EXECUTING))204{205/* We are executing a while loop outside of a method */206207Status = AcpiDsExecBeginOp (WalkState, OutOp);208return_ACPI_STATUS (Status);209}210211/* We only care about Namespace opcodes here */212213if ((!(WalkState->OpInfo->Flags & AML_NSOPCODE) &&214(WalkState->Opcode != AML_INT_NAMEPATH_OP)) ||215(!(WalkState->OpInfo->Flags & AML_NAMED)))216{217return_ACPI_STATUS (AE_OK);218}219220/* Get the name we are going to enter or lookup in the namespace */221222if (WalkState->Opcode == AML_INT_NAMEPATH_OP)223{224/* For Namepath op, get the path string */225226BufferPtr = Op->Common.Value.String;227if (!BufferPtr)228{229/* No name, just exit */230231return_ACPI_STATUS (AE_OK);232}233}234else235{236/* Get name from the op */237238BufferPtr = ACPI_CAST_PTR (char, &Op->Named.Name);239}240}241else242{243/* Get the namestring from the raw AML */244245BufferPtr = AcpiPsGetNextNamestring (&WalkState->ParserState);246}247248/* Map the opcode into an internal object type */249250ObjectType = WalkState->OpInfo->ObjectType;251252ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,253"State=%p Op=%p Type=%X\n", WalkState, Op, ObjectType));254255switch (WalkState->Opcode)256{257case AML_FIELD_OP:258case AML_BANK_FIELD_OP:259case AML_INDEX_FIELD_OP:260261Node = NULL;262Status = AE_OK;263break;264265case AML_INT_NAMEPATH_OP:266/*267* The NamePath is an object reference to an existing object.268* Don't enter the name into the namespace, but look it up269* for use later.270*/271Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,272ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,273WalkState, &(Node));274break;275276case AML_SCOPE_OP:277278/* Special case for Scope(\) -> refers to the Root node */279280if (Op && (Op->Named.Node == AcpiGbl_RootNode))281{282Node = Op->Named.Node;283284Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState);285if (ACPI_FAILURE (Status))286{287return_ACPI_STATUS (Status);288}289}290else291{292/*293* The Path is an object reference to an existing object.294* Don't enter the name into the namespace, but look it up295* for use later.296*/297Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,298ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,299WalkState, &(Node));300if (ACPI_FAILURE (Status))301{302#ifdef ACPI_ASL_COMPILER303if (Status == AE_NOT_FOUND)304{305Status = AE_OK;306}307else308{309ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,310BufferPtr, Status);311}312#else313ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,314BufferPtr, Status);315#endif316return_ACPI_STATUS (Status);317}318}319320/*321* We must check to make sure that the target is322* one of the opcodes that actually opens a scope323*/324switch (Node->Type)325{326case ACPI_TYPE_ANY:327case ACPI_TYPE_LOCAL_SCOPE: /* Scope */328case ACPI_TYPE_DEVICE:329case ACPI_TYPE_POWER:330case ACPI_TYPE_PROCESSOR:331case ACPI_TYPE_THERMAL:332333/* These are acceptable types */334break;335336case ACPI_TYPE_INTEGER:337case ACPI_TYPE_STRING:338case ACPI_TYPE_BUFFER:339340/*341* These types we will allow, but we will change the type.342* This enables some existing code of the form:343*344* Name (DEB, 0)345* Scope (DEB) { ... }346*/347ACPI_WARNING ((AE_INFO,348"Type override - [%4.4s] had invalid type (%s) "349"for Scope operator, changed to type ANY",350AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type)));351352Node->Type = ACPI_TYPE_ANY;353WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY;354break;355356case ACPI_TYPE_METHOD:357358/*359* Allow scope change to root during execution of module-level360* code. Root is typed METHOD during this time.361*/362if ((Node == AcpiGbl_RootNode) &&363(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))364{365break;366}367368ACPI_FALLTHROUGH;369370default:371372/* All other types are an error */373374ACPI_ERROR ((AE_INFO,375"Invalid type (%s) for target of "376"Scope operator [%4.4s] (Cannot override)",377AcpiUtGetTypeName (Node->Type), AcpiUtGetNodeName (Node)));378379return_ACPI_STATUS (AE_AML_OPERAND_TYPE);380}381break;382383default:384385/* All other opcodes */386387if (Op && Op->Common.Node)388{389/* This op/node was previously entered into the namespace */390391Node = Op->Common.Node;392393if (AcpiNsOpensScope (ObjectType))394{395Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState);396if (ACPI_FAILURE (Status))397{398return_ACPI_STATUS (Status);399}400}401402return_ACPI_STATUS (AE_OK);403}404405/*406* Enter the named type into the internal namespace. We enter the name407* as we go downward in the parse tree. Any necessary subobjects that408* involve arguments to the opcode must be created as we go back up the409* parse tree later.410*411* Note: Name may already exist if we are executing a deferred opcode.412*/413if (WalkState->DeferredNode)414{415/* This name is already in the namespace, get the node */416417Node = WalkState->DeferredNode;418Status = AE_OK;419break;420}421422Flags = ACPI_NS_NO_UPSEARCH;423if (WalkState->PassNumber == ACPI_IMODE_EXECUTE)424{425/* Execution mode, node cannot already exist, node is temporary */426427Flags |= ACPI_NS_ERROR_IF_FOUND;428429if (!(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))430{431Flags |= ACPI_NS_TEMPORARY;432}433}434435#ifdef ACPI_ASL_COMPILER436437/*438* Do not open a scope for AML_EXTERNAL_OP439* AcpiNsLookup can open a new scope based on the object type440* of this op. AML_EXTERNAL_OP is a declaration rather than a441* definition. In the case that this external is a method object,442* AcpiNsLookup will open a new scope. However, an AML_EXTERNAL_OP443* associated with the ACPI_TYPE_METHOD is a declaration, rather than444* a definition. Flags is set to avoid opening a scope for any445* AML_EXTERNAL_OP.446*/447if (WalkState->Opcode == AML_EXTERNAL_OP)448{449Flags |= ACPI_NS_DONT_OPEN_SCOPE;450}451#endif452453/*454* For name creation opcodes, the full namepath prefix must455* exist, except for the final (new) nameseg.456*/457if (WalkState->OpInfo->Flags & AML_NAMED)458{459Flags |= ACPI_NS_PREFIX_MUST_EXIST;460}461462/* Add new entry or lookup existing entry */463464Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,465ACPI_IMODE_LOAD_PASS2, Flags, WalkState, &Node);466467if (ACPI_SUCCESS (Status) && (Flags & ACPI_NS_TEMPORARY))468{469ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,470"***New Node [%4.4s] %p is temporary\n",471AcpiUtGetNodeName (Node), Node));472}473break;474}475476if (ACPI_FAILURE (Status))477{478ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,479BufferPtr, Status);480return_ACPI_STATUS (Status);481}482483if (!Op)484{485/* Create a new op */486487Op = AcpiPsAllocOp (WalkState->Opcode, WalkState->Aml);488if (!Op)489{490return_ACPI_STATUS (AE_NO_MEMORY);491}492493/* Initialize the new op */494495if (Node)496{497Op->Named.Name = Node->Name.Integer;498}499*OutOp = Op;500}501502/*503* Put the Node in the "op" object that the parser uses, so we504* can get it again quickly when this scope is closed505*/506Op->Common.Node = Node;507return_ACPI_STATUS (Status);508}509510511/*******************************************************************************512*513* FUNCTION: AcpiDsLoad2EndOp514*515* PARAMETERS: WalkState - Current state of the parse tree walk516*517* RETURN: Status518*519* DESCRIPTION: Ascending callback used during the loading of the namespace,520* both control methods and everything else.521*522******************************************************************************/523524ACPI_STATUS525AcpiDsLoad2EndOp (526ACPI_WALK_STATE *WalkState)527{528ACPI_PARSE_OBJECT *Op;529ACPI_STATUS Status = AE_OK;530ACPI_OBJECT_TYPE ObjectType;531ACPI_NAMESPACE_NODE *Node;532ACPI_PARSE_OBJECT *Arg;533ACPI_NAMESPACE_NODE *NewNode;534UINT32 i;535UINT8 RegionSpace;536#if !defined(ACPI_DB_APP) && defined(ACPI_EXEC_APP)537ACPI_OPERAND_OBJECT *ObjDesc;538char *Namepath;539#endif540541542ACPI_FUNCTION_TRACE (DsLoad2EndOp);543544Op = WalkState->Op;545ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n",546WalkState->OpInfo->Name, Op, WalkState));547548/* Check if opcode had an associated namespace object */549550if (!(WalkState->OpInfo->Flags & AML_NSOBJECT))551{552return_ACPI_STATUS (AE_OK);553}554555if (Op->Common.AmlOpcode == AML_SCOPE_OP)556{557ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,558"Ending scope Op=%p State=%p\n", Op, WalkState));559}560561ObjectType = WalkState->OpInfo->ObjectType;562563/*564* Get the Node/name from the earlier lookup565* (It was saved in the *op structure)566*/567Node = Op->Common.Node;568569/*570* Put the Node on the object stack (Contains the ACPI Name of571* this object)572*/573WalkState->Operands[0] = (void *) Node;574WalkState->NumOperands = 1;575576/* Pop the scope stack */577578if (AcpiNsOpensScope (ObjectType) &&579(Op->Common.AmlOpcode != AML_INT_METHODCALL_OP))580{581ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n",582AcpiUtGetTypeName (ObjectType), Op));583584Status = AcpiDsScopeStackPop (WalkState);585if (ACPI_FAILURE (Status))586{587goto Cleanup;588}589}590591/*592* Named operations are as follows:593*594* AML_ALIAS595* AML_BANKFIELD596* AML_CREATEBITFIELD597* AML_CREATEBYTEFIELD598* AML_CREATEDWORDFIELD599* AML_CREATEFIELD600* AML_CREATEQWORDFIELD601* AML_CREATEWORDFIELD602* AML_DATA_REGION603* AML_DEVICE604* AML_EVENT605* AML_FIELD606* AML_INDEXFIELD607* AML_METHOD608* AML_METHODCALL609* AML_MUTEX610* AML_NAME611* AML_NAMEDFIELD612* AML_OPREGION613* AML_POWERRES614* AML_PROCESSOR615* AML_SCOPE616* AML_THERMALZONE617*/618619ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,620"Create-Load [%s] State=%p Op=%p NamedObj=%p\n",621AcpiPsGetOpcodeName (Op->Common.AmlOpcode), WalkState, Op, Node));622623/* Decode the opcode */624625Arg = Op->Common.Value.Arg;626627switch (WalkState->OpInfo->Type)628{629630case AML_TYPE_CREATE_FIELD:631/*632* Create the field object, but the field buffer and index must633* be evaluated later during the execution phase634*/635Status = AcpiDsCreateBufferField (Op, WalkState);636if ACPI_FAILURE (Status)637{638ACPI_EXCEPTION ((AE_INFO, Status, "CreateBufferField failure"));639goto Cleanup;640}641break;642643case AML_TYPE_NAMED_FIELD:644/*645* If we are executing a method, initialize the field646*/647if (WalkState->MethodNode)648{649Status = AcpiDsInitFieldObjects (Op, WalkState);650}651652switch (Op->Common.AmlOpcode)653{654case AML_INDEX_FIELD_OP:655656Status = AcpiDsCreateIndexField (657Op, (ACPI_HANDLE) Arg->Common.Node, WalkState);658break;659660case AML_BANK_FIELD_OP:661662Status = AcpiDsCreateBankField (Op, Arg->Common.Node, WalkState);663break;664665case AML_FIELD_OP:666667Status = AcpiDsCreateField (Op, Arg->Common.Node, WalkState);668break;669670default:671672/* All NAMED_FIELD opcodes must be handled above */673break;674}675break;676677case AML_TYPE_NAMED_SIMPLE:678679Status = AcpiDsCreateOperands (WalkState, Arg);680if (ACPI_FAILURE (Status))681{682goto Cleanup;683}684685switch (Op->Common.AmlOpcode)686{687case AML_PROCESSOR_OP:688689Status = AcpiExCreateProcessor (WalkState);690break;691692case AML_POWER_RESOURCE_OP:693694Status = AcpiExCreatePowerResource (WalkState);695break;696697case AML_MUTEX_OP:698699Status = AcpiExCreateMutex (WalkState);700break;701702case AML_EVENT_OP:703704Status = AcpiExCreateEvent (WalkState);705break;706707case AML_ALIAS_OP:708709Status = AcpiExCreateAlias (WalkState);710break;711712default:713714/* Unknown opcode */715716Status = AE_OK;717goto Cleanup;718}719720/* Delete operands */721722for (i = 1; i < WalkState->NumOperands; i++)723{724AcpiUtRemoveReference (WalkState->Operands[i]);725WalkState->Operands[i] = NULL;726}727728break;729730case AML_TYPE_NAMED_COMPLEX:731732switch (Op->Common.AmlOpcode)733{734case AML_REGION_OP:735case AML_DATA_REGION_OP:736737if (Op->Common.AmlOpcode == AML_REGION_OP)738{739RegionSpace = (ACPI_ADR_SPACE_TYPE)740((Op->Common.Value.Arg)->Common.Value.Integer);741}742else743{744RegionSpace = ACPI_ADR_SPACE_DATA_TABLE;745}746747/*748* The OpRegion is not fully parsed at this time. The only valid749* argument is the SpaceId. (We must save the address of the750* AML of the address and length operands)751*752* If we have a valid region, initialize it. The namespace is753* unlocked at this point.754*755* Need to unlock interpreter if it is locked (if we are running756* a control method), in order to allow _REG methods to be run757* during AcpiEvInitializeRegion.758*/759if (WalkState->MethodNode)760{761/*762* Executing a method: initialize the region and unlock763* the interpreter764*/765Status = AcpiExCreateRegion (Op->Named.Data,766Op->Named.Length, RegionSpace, WalkState);767if (ACPI_FAILURE (Status))768{769return_ACPI_STATUS (Status);770}771}772773Status = AcpiEvInitializeRegion (774AcpiNsGetAttachedObject (Node));775break;776777case AML_NAME_OP:778779Status = AcpiDsCreateNode (WalkState, Node, Op);780if (ACPI_FAILURE (Status))781{782goto Cleanup;783}784785#if !defined(ACPI_DB_APP) && defined(ACPI_EXEC_APP)786/*787* AcpiExec support for namespace initialization file (initialize788* Name opcodes in this code.)789*/790Namepath = AcpiNsGetExternalPathname (Node);791Status = AeLookupInitFileEntry (Namepath, &ObjDesc);792if (ACPI_SUCCESS (Status))793{794/* Detach any existing object, attach new object */795796if (Node->Object)797{798AcpiNsDetachObject (Node);799}800AcpiNsAttachObject (Node, ObjDesc, ObjDesc->Common.Type);801}802ACPI_FREE (Namepath);803Status = AE_OK;804#endif805break;806807case AML_METHOD_OP:808/*809* MethodOp PkgLength NameString MethodFlags TermList810*811* Note: We must create the method node/object pair as soon as we812* see the method declaration. This allows later pass1 parsing813* of invocations of the method (need to know the number of814* arguments.)815*/816ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,817"LOADING-Method: State=%p Op=%p NamedObj=%p\n",818WalkState, Op, Op->Named.Node));819820if (!AcpiNsGetAttachedObject (Op->Named.Node))821{822WalkState->Operands[0] = ACPI_CAST_PTR (void, Op->Named.Node);823WalkState->NumOperands = 1;824825Status = AcpiDsCreateOperands (826WalkState, Op->Common.Value.Arg);827if (ACPI_SUCCESS (Status))828{829Status = AcpiExCreateMethod (830Op->Named.Data, Op->Named.Length, WalkState);831}832833WalkState->Operands[0] = NULL;834WalkState->NumOperands = 0;835836if (ACPI_FAILURE (Status))837{838return_ACPI_STATUS (Status);839}840}841break;842843844default:845846/* All NAMED_COMPLEX opcodes must be handled above */847break;848}849break;850851case AML_CLASS_INTERNAL:852853/* case AML_INT_NAMEPATH_OP: */854break;855856case AML_CLASS_METHOD_CALL:857858ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,859"RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n",860WalkState, Op, Node));861862/*863* Lookup the method name and save the Node864*/865Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,866ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS2,867ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,868WalkState, &(NewNode));869if (ACPI_SUCCESS (Status))870{871/*872* Make sure that what we found is indeed a method873* We didn't search for a method on purpose, to see if the name874* would resolve875*/876if (NewNode->Type != ACPI_TYPE_METHOD)877{878Status = AE_AML_OPERAND_TYPE;879}880881/* We could put the returned object (Node) on the object stack for882* later, but for now, we will put it in the "op" object that the883* parser uses, so we can get it again at the end of this scope884*/885Op->Common.Node = NewNode;886}887else888{889ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,890Arg->Common.Value.String, Status);891}892break;893894895default:896897break;898}899900Cleanup:901902/* Remove the Node pushed at the very beginning */903904WalkState->Operands[0] = NULL;905WalkState->NumOperands = 0;906return_ACPI_STATUS (Status);907}908909910