1*433d6423SLionel Sambuc /****************************************************************************** 2*433d6423SLionel Sambuc * 3*433d6423SLionel Sambuc * Module Name: dswload - Dispatcher namespace load callbacks 4*433d6423SLionel Sambuc * 5*433d6423SLionel Sambuc *****************************************************************************/ 6*433d6423SLionel Sambuc 7*433d6423SLionel Sambuc /****************************************************************************** 8*433d6423SLionel Sambuc * 9*433d6423SLionel Sambuc * 1. Copyright Notice 10*433d6423SLionel Sambuc * 11*433d6423SLionel Sambuc * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. 12*433d6423SLionel Sambuc * All rights reserved. 13*433d6423SLionel Sambuc * 14*433d6423SLionel Sambuc * 2. License 15*433d6423SLionel Sambuc * 16*433d6423SLionel Sambuc * 2.1. This is your license from Intel Corp. under its intellectual property 17*433d6423SLionel Sambuc * rights. You may have additional license terms from the party that provided 18*433d6423SLionel Sambuc * you this software, covering your right to use that party's intellectual 19*433d6423SLionel Sambuc * property rights. 20*433d6423SLionel Sambuc * 21*433d6423SLionel Sambuc * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22*433d6423SLionel Sambuc * copy of the source code appearing in this file ("Covered Code") an 23*433d6423SLionel Sambuc * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24*433d6423SLionel Sambuc * base code distributed originally by Intel ("Original Intel Code") to copy, 25*433d6423SLionel Sambuc * make derivatives, distribute, use and display any portion of the Covered 26*433d6423SLionel Sambuc * Code in any form, with the right to sublicense such rights; and 27*433d6423SLionel Sambuc * 28*433d6423SLionel Sambuc * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29*433d6423SLionel Sambuc * license (with the right to sublicense), under only those claims of Intel 30*433d6423SLionel Sambuc * patents that are infringed by the Original Intel Code, to make, use, sell, 31*433d6423SLionel Sambuc * offer to sell, and import the Covered Code and derivative works thereof 32*433d6423SLionel Sambuc * solely to the minimum extent necessary to exercise the above copyright 33*433d6423SLionel Sambuc * license, and in no event shall the patent license extend to any additions 34*433d6423SLionel Sambuc * to or modifications of the Original Intel Code. No other license or right 35*433d6423SLionel Sambuc * is granted directly or by implication, estoppel or otherwise; 36*433d6423SLionel Sambuc * 37*433d6423SLionel Sambuc * The above copyright and patent license is granted only if the following 38*433d6423SLionel Sambuc * conditions are met: 39*433d6423SLionel Sambuc * 40*433d6423SLionel Sambuc * 3. Conditions 41*433d6423SLionel Sambuc * 42*433d6423SLionel Sambuc * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43*433d6423SLionel Sambuc * Redistribution of source code of any substantial portion of the Covered 44*433d6423SLionel Sambuc * Code or modification with rights to further distribute source must include 45*433d6423SLionel Sambuc * the above Copyright Notice, the above License, this list of Conditions, 46*433d6423SLionel Sambuc * and the following Disclaimer and Export Compliance provision. In addition, 47*433d6423SLionel Sambuc * Licensee must cause all Covered Code to which Licensee contributes to 48*433d6423SLionel Sambuc * contain a file documenting the changes Licensee made to create that Covered 49*433d6423SLionel Sambuc * Code and the date of any change. Licensee must include in that file the 50*433d6423SLionel Sambuc * documentation of any changes made by any predecessor Licensee. Licensee 51*433d6423SLionel Sambuc * must include a prominent statement that the modification is derived, 52*433d6423SLionel Sambuc * directly or indirectly, from Original Intel Code. 53*433d6423SLionel Sambuc * 54*433d6423SLionel Sambuc * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55*433d6423SLionel Sambuc * Redistribution of source code of any substantial portion of the Covered 56*433d6423SLionel Sambuc * Code or modification without rights to further distribute source must 57*433d6423SLionel Sambuc * include the following Disclaimer and Export Compliance provision in the 58*433d6423SLionel Sambuc * documentation and/or other materials provided with distribution. In 59*433d6423SLionel Sambuc * addition, Licensee may not authorize further sublicense of source of any 60*433d6423SLionel Sambuc * portion of the Covered Code, and must include terms to the effect that the 61*433d6423SLionel Sambuc * license from Licensee to its licensee is limited to the intellectual 62*433d6423SLionel Sambuc * property embodied in the software Licensee provides to its licensee, and 63*433d6423SLionel Sambuc * not to intellectual property embodied in modifications its licensee may 64*433d6423SLionel Sambuc * make. 65*433d6423SLionel Sambuc * 66*433d6423SLionel Sambuc * 3.3. Redistribution of Executable. Redistribution in executable form of any 67*433d6423SLionel Sambuc * substantial portion of the Covered Code or modification must reproduce the 68*433d6423SLionel Sambuc * above Copyright Notice, and the following Disclaimer and Export Compliance 69*433d6423SLionel Sambuc * provision in the documentation and/or other materials provided with the 70*433d6423SLionel Sambuc * distribution. 71*433d6423SLionel Sambuc * 72*433d6423SLionel Sambuc * 3.4. Intel retains all right, title, and interest in and to the Original 73*433d6423SLionel Sambuc * Intel Code. 74*433d6423SLionel Sambuc * 75*433d6423SLionel Sambuc * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76*433d6423SLionel Sambuc * Intel shall be used in advertising or otherwise to promote the sale, use or 77*433d6423SLionel Sambuc * other dealings in products derived from or relating to the Covered Code 78*433d6423SLionel Sambuc * without prior written authorization from Intel. 79*433d6423SLionel Sambuc * 80*433d6423SLionel Sambuc * 4. Disclaimer and Export Compliance 81*433d6423SLionel Sambuc * 82*433d6423SLionel Sambuc * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83*433d6423SLionel Sambuc * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84*433d6423SLionel Sambuc * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85*433d6423SLionel Sambuc * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86*433d6423SLionel Sambuc * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87*433d6423SLionel Sambuc * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88*433d6423SLionel Sambuc * PARTICULAR PURPOSE. 89*433d6423SLionel Sambuc * 90*433d6423SLionel Sambuc * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91*433d6423SLionel Sambuc * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92*433d6423SLionel Sambuc * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93*433d6423SLionel Sambuc * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94*433d6423SLionel Sambuc * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95*433d6423SLionel Sambuc * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96*433d6423SLionel Sambuc * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97*433d6423SLionel Sambuc * LIMITED REMEDY. 98*433d6423SLionel Sambuc * 99*433d6423SLionel Sambuc * 4.3. Licensee shall not export, either directly or indirectly, any of this 100*433d6423SLionel Sambuc * software or system incorporating such software without first obtaining any 101*433d6423SLionel Sambuc * required license or other approval from the U. S. Department of Commerce or 102*433d6423SLionel Sambuc * any other agency or department of the United States Government. In the 103*433d6423SLionel Sambuc * event Licensee exports any such software from the United States or 104*433d6423SLionel Sambuc * re-exports any such software from a foreign destination, Licensee shall 105*433d6423SLionel Sambuc * ensure that the distribution and export/re-export of the software is in 106*433d6423SLionel Sambuc * compliance with all laws, regulations, orders, or other restrictions of the 107*433d6423SLionel Sambuc * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108*433d6423SLionel Sambuc * any of its subsidiaries will export/re-export any technical data, process, 109*433d6423SLionel Sambuc * software, or service, directly or indirectly, to any country for which the 110*433d6423SLionel Sambuc * United States government or any agency thereof requires an export license, 111*433d6423SLionel Sambuc * other governmental approval, or letter of assurance, without first obtaining 112*433d6423SLionel Sambuc * such license, approval or letter. 113*433d6423SLionel Sambuc * 114*433d6423SLionel Sambuc *****************************************************************************/ 115*433d6423SLionel Sambuc 116*433d6423SLionel Sambuc #define __DSWLOAD_C__ 117*433d6423SLionel Sambuc 118*433d6423SLionel Sambuc #include "acpi.h" 119*433d6423SLionel Sambuc #include "accommon.h" 120*433d6423SLionel Sambuc #include "acparser.h" 121*433d6423SLionel Sambuc #include "amlcode.h" 122*433d6423SLionel Sambuc #include "acdispat.h" 123*433d6423SLionel Sambuc #include "acinterp.h" 124*433d6423SLionel Sambuc #include "acnamesp.h" 125*433d6423SLionel Sambuc #include "acevents.h" 126*433d6423SLionel Sambuc 127*433d6423SLionel Sambuc #ifdef ACPI_ASL_COMPILER 128*433d6423SLionel Sambuc #include "acdisasm.h" 129*433d6423SLionel Sambuc #endif 130*433d6423SLionel Sambuc 131*433d6423SLionel Sambuc #define _COMPONENT ACPI_DISPATCHER 132*433d6423SLionel Sambuc ACPI_MODULE_NAME ("dswload") 133*433d6423SLionel Sambuc 134*433d6423SLionel Sambuc 135*433d6423SLionel Sambuc /******************************************************************************* 136*433d6423SLionel Sambuc * 137*433d6423SLionel Sambuc * FUNCTION: AcpiDsInitCallbacks 138*433d6423SLionel Sambuc * 139*433d6423SLionel Sambuc * PARAMETERS: WalkState - Current state of the parse tree walk 140*433d6423SLionel Sambuc * PassNumber - 1, 2, or 3 141*433d6423SLionel Sambuc * 142*433d6423SLionel Sambuc * RETURN: Status 143*433d6423SLionel Sambuc * 144*433d6423SLionel Sambuc * DESCRIPTION: Init walk state callbacks 145*433d6423SLionel Sambuc * 146*433d6423SLionel Sambuc ******************************************************************************/ 147*433d6423SLionel Sambuc 148*433d6423SLionel Sambuc ACPI_STATUS 149*433d6423SLionel Sambuc AcpiDsInitCallbacks ( 150*433d6423SLionel Sambuc ACPI_WALK_STATE *WalkState, 151*433d6423SLionel Sambuc UINT32 PassNumber) 152*433d6423SLionel Sambuc { 153*433d6423SLionel Sambuc 154*433d6423SLionel Sambuc switch (PassNumber) 155*433d6423SLionel Sambuc { 156*433d6423SLionel Sambuc case 1: 157*433d6423SLionel Sambuc WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | 158*433d6423SLionel Sambuc ACPI_PARSE_DELETE_TREE; 159*433d6423SLionel Sambuc WalkState->DescendingCallback = AcpiDsLoad1BeginOp; 160*433d6423SLionel Sambuc WalkState->AscendingCallback = AcpiDsLoad1EndOp; 161*433d6423SLionel Sambuc break; 162*433d6423SLionel Sambuc 163*433d6423SLionel Sambuc case 2: 164*433d6423SLionel Sambuc WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | 165*433d6423SLionel Sambuc ACPI_PARSE_DELETE_TREE; 166*433d6423SLionel Sambuc WalkState->DescendingCallback = AcpiDsLoad2BeginOp; 167*433d6423SLionel Sambuc WalkState->AscendingCallback = AcpiDsLoad2EndOp; 168*433d6423SLionel Sambuc break; 169*433d6423SLionel Sambuc 170*433d6423SLionel Sambuc case 3: 171*433d6423SLionel Sambuc #ifndef ACPI_NO_METHOD_EXECUTION 172*433d6423SLionel Sambuc WalkState->ParseFlags |= ACPI_PARSE_EXECUTE | 173*433d6423SLionel Sambuc ACPI_PARSE_DELETE_TREE; 174*433d6423SLionel Sambuc WalkState->DescendingCallback = AcpiDsExecBeginOp; 175*433d6423SLionel Sambuc WalkState->AscendingCallback = AcpiDsExecEndOp; 176*433d6423SLionel Sambuc #endif 177*433d6423SLionel Sambuc break; 178*433d6423SLionel Sambuc 179*433d6423SLionel Sambuc default: 180*433d6423SLionel Sambuc return (AE_BAD_PARAMETER); 181*433d6423SLionel Sambuc } 182*433d6423SLionel Sambuc 183*433d6423SLionel Sambuc return (AE_OK); 184*433d6423SLionel Sambuc } 185*433d6423SLionel Sambuc 186*433d6423SLionel Sambuc 187*433d6423SLionel Sambuc /******************************************************************************* 188*433d6423SLionel Sambuc * 189*433d6423SLionel Sambuc * FUNCTION: AcpiDsLoad1BeginOp 190*433d6423SLionel Sambuc * 191*433d6423SLionel Sambuc * PARAMETERS: WalkState - Current state of the parse tree walk 192*433d6423SLionel Sambuc * OutOp - Where to return op if a new one is created 193*433d6423SLionel Sambuc * 194*433d6423SLionel Sambuc * RETURN: Status 195*433d6423SLionel Sambuc * 196*433d6423SLionel Sambuc * DESCRIPTION: Descending callback used during the loading of ACPI tables. 197*433d6423SLionel Sambuc * 198*433d6423SLionel Sambuc ******************************************************************************/ 199*433d6423SLionel Sambuc 200*433d6423SLionel Sambuc ACPI_STATUS 201*433d6423SLionel Sambuc AcpiDsLoad1BeginOp ( 202*433d6423SLionel Sambuc ACPI_WALK_STATE *WalkState, 203*433d6423SLionel Sambuc ACPI_PARSE_OBJECT **OutOp) 204*433d6423SLionel Sambuc { 205*433d6423SLionel Sambuc ACPI_PARSE_OBJECT *Op; 206*433d6423SLionel Sambuc ACPI_NAMESPACE_NODE *Node; 207*433d6423SLionel Sambuc ACPI_STATUS Status; 208*433d6423SLionel Sambuc ACPI_OBJECT_TYPE ObjectType; 209*433d6423SLionel Sambuc char *Path; 210*433d6423SLionel Sambuc UINT32 Flags; 211*433d6423SLionel Sambuc 212*433d6423SLionel Sambuc 213*433d6423SLionel Sambuc ACPI_FUNCTION_TRACE (DsLoad1BeginOp); 214*433d6423SLionel Sambuc 215*433d6423SLionel Sambuc 216*433d6423SLionel Sambuc Op = WalkState->Op; 217*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); 218*433d6423SLionel Sambuc 219*433d6423SLionel Sambuc /* We are only interested in opcodes that have an associated name */ 220*433d6423SLionel Sambuc 221*433d6423SLionel Sambuc if (Op) 222*433d6423SLionel Sambuc { 223*433d6423SLionel Sambuc if (!(WalkState->OpInfo->Flags & AML_NAMED)) 224*433d6423SLionel Sambuc { 225*433d6423SLionel Sambuc *OutOp = Op; 226*433d6423SLionel Sambuc return_ACPI_STATUS (AE_OK); 227*433d6423SLionel Sambuc } 228*433d6423SLionel Sambuc 229*433d6423SLionel Sambuc /* Check if this object has already been installed in the namespace */ 230*433d6423SLionel Sambuc 231*433d6423SLionel Sambuc if (Op->Common.Node) 232*433d6423SLionel Sambuc { 233*433d6423SLionel Sambuc *OutOp = Op; 234*433d6423SLionel Sambuc return_ACPI_STATUS (AE_OK); 235*433d6423SLionel Sambuc } 236*433d6423SLionel Sambuc } 237*433d6423SLionel Sambuc 238*433d6423SLionel Sambuc Path = AcpiPsGetNextNamestring (&WalkState->ParserState); 239*433d6423SLionel Sambuc 240*433d6423SLionel Sambuc /* Map the raw opcode into an internal object type */ 241*433d6423SLionel Sambuc 242*433d6423SLionel Sambuc ObjectType = WalkState->OpInfo->ObjectType; 243*433d6423SLionel Sambuc 244*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 245*433d6423SLionel Sambuc "State=%p Op=%p [%s]\n", WalkState, Op, AcpiUtGetTypeName (ObjectType))); 246*433d6423SLionel Sambuc 247*433d6423SLionel Sambuc switch (WalkState->Opcode) 248*433d6423SLionel Sambuc { 249*433d6423SLionel Sambuc case AML_SCOPE_OP: 250*433d6423SLionel Sambuc 251*433d6423SLionel Sambuc /* 252*433d6423SLionel Sambuc * The target name of the Scope() operator must exist at this point so 253*433d6423SLionel Sambuc * that we can actually open the scope to enter new names underneath it. 254*433d6423SLionel Sambuc * Allow search-to-root for single namesegs. 255*433d6423SLionel Sambuc */ 256*433d6423SLionel Sambuc Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, 257*433d6423SLionel Sambuc ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node)); 258*433d6423SLionel Sambuc #ifdef ACPI_ASL_COMPILER 259*433d6423SLionel Sambuc if (Status == AE_NOT_FOUND) 260*433d6423SLionel Sambuc { 261*433d6423SLionel Sambuc /* 262*433d6423SLionel Sambuc * Table disassembly: 263*433d6423SLionel Sambuc * Target of Scope() not found. Generate an External for it, and 264*433d6423SLionel Sambuc * insert the name into the namespace. 265*433d6423SLionel Sambuc */ 266*433d6423SLionel Sambuc AcpiDmAddToExternalList (Op, Path, ACPI_TYPE_DEVICE, 0); 267*433d6423SLionel Sambuc Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, 268*433d6423SLionel Sambuc ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, 269*433d6423SLionel Sambuc WalkState, &Node); 270*433d6423SLionel Sambuc } 271*433d6423SLionel Sambuc #endif 272*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 273*433d6423SLionel Sambuc { 274*433d6423SLionel Sambuc ACPI_ERROR_NAMESPACE (Path, Status); 275*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 276*433d6423SLionel Sambuc } 277*433d6423SLionel Sambuc 278*433d6423SLionel Sambuc /* 279*433d6423SLionel Sambuc * Check to make sure that the target is 280*433d6423SLionel Sambuc * one of the opcodes that actually opens a scope 281*433d6423SLionel Sambuc */ 282*433d6423SLionel Sambuc switch (Node->Type) 283*433d6423SLionel Sambuc { 284*433d6423SLionel Sambuc case ACPI_TYPE_ANY: 285*433d6423SLionel Sambuc case ACPI_TYPE_LOCAL_SCOPE: /* Scope */ 286*433d6423SLionel Sambuc case ACPI_TYPE_DEVICE: 287*433d6423SLionel Sambuc case ACPI_TYPE_POWER: 288*433d6423SLionel Sambuc case ACPI_TYPE_PROCESSOR: 289*433d6423SLionel Sambuc case ACPI_TYPE_THERMAL: 290*433d6423SLionel Sambuc 291*433d6423SLionel Sambuc /* These are acceptable types */ 292*433d6423SLionel Sambuc break; 293*433d6423SLionel Sambuc 294*433d6423SLionel Sambuc case ACPI_TYPE_INTEGER: 295*433d6423SLionel Sambuc case ACPI_TYPE_STRING: 296*433d6423SLionel Sambuc case ACPI_TYPE_BUFFER: 297*433d6423SLionel Sambuc 298*433d6423SLionel Sambuc /* 299*433d6423SLionel Sambuc * These types we will allow, but we will change the type. 300*433d6423SLionel Sambuc * This enables some existing code of the form: 301*433d6423SLionel Sambuc * 302*433d6423SLionel Sambuc * Name (DEB, 0) 303*433d6423SLionel Sambuc * Scope (DEB) { ... } 304*433d6423SLionel Sambuc * 305*433d6423SLionel Sambuc * Note: silently change the type here. On the second pass, 306*433d6423SLionel Sambuc * we will report a warning 307*433d6423SLionel Sambuc */ 308*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 309*433d6423SLionel Sambuc "Type override - [%4.4s] had invalid type (%s) " 310*433d6423SLionel Sambuc "for Scope operator, changed to type ANY\n", 311*433d6423SLionel Sambuc AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type))); 312*433d6423SLionel Sambuc 313*433d6423SLionel Sambuc Node->Type = ACPI_TYPE_ANY; 314*433d6423SLionel Sambuc WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY; 315*433d6423SLionel Sambuc break; 316*433d6423SLionel Sambuc 317*433d6423SLionel Sambuc default: 318*433d6423SLionel Sambuc 319*433d6423SLionel Sambuc /* All other types are an error */ 320*433d6423SLionel Sambuc 321*433d6423SLionel Sambuc ACPI_ERROR ((AE_INFO, 322*433d6423SLionel Sambuc "Invalid type (%s) for target of " 323*433d6423SLionel Sambuc "Scope operator [%4.4s] (Cannot override)", 324*433d6423SLionel Sambuc AcpiUtGetTypeName (Node->Type), AcpiUtGetNodeName (Node))); 325*433d6423SLionel Sambuc 326*433d6423SLionel Sambuc return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 327*433d6423SLionel Sambuc } 328*433d6423SLionel Sambuc break; 329*433d6423SLionel Sambuc 330*433d6423SLionel Sambuc 331*433d6423SLionel Sambuc default: 332*433d6423SLionel Sambuc /* 333*433d6423SLionel Sambuc * For all other named opcodes, we will enter the name into 334*433d6423SLionel Sambuc * the namespace. 335*433d6423SLionel Sambuc * 336*433d6423SLionel Sambuc * Setup the search flags. 337*433d6423SLionel Sambuc * Since we are entering a name into the namespace, we do not want to 338*433d6423SLionel Sambuc * enable the search-to-root upsearch. 339*433d6423SLionel Sambuc * 340*433d6423SLionel Sambuc * There are only two conditions where it is acceptable that the name 341*433d6423SLionel Sambuc * already exists: 342*433d6423SLionel Sambuc * 1) the Scope() operator can reopen a scoping object that was 343*433d6423SLionel Sambuc * previously defined (Scope, Method, Device, etc.) 344*433d6423SLionel Sambuc * 2) Whenever we are parsing a deferred opcode (OpRegion, Buffer, 345*433d6423SLionel Sambuc * BufferField, or Package), the name of the object is already 346*433d6423SLionel Sambuc * in the namespace. 347*433d6423SLionel Sambuc */ 348*433d6423SLionel Sambuc if (WalkState->DeferredNode) 349*433d6423SLionel Sambuc { 350*433d6423SLionel Sambuc /* This name is already in the namespace, get the node */ 351*433d6423SLionel Sambuc 352*433d6423SLionel Sambuc Node = WalkState->DeferredNode; 353*433d6423SLionel Sambuc Status = AE_OK; 354*433d6423SLionel Sambuc break; 355*433d6423SLionel Sambuc } 356*433d6423SLionel Sambuc 357*433d6423SLionel Sambuc /* 358*433d6423SLionel Sambuc * If we are executing a method, do not create any namespace objects 359*433d6423SLionel Sambuc * during the load phase, only during execution. 360*433d6423SLionel Sambuc */ 361*433d6423SLionel Sambuc if (WalkState->MethodNode) 362*433d6423SLionel Sambuc { 363*433d6423SLionel Sambuc Node = NULL; 364*433d6423SLionel Sambuc Status = AE_OK; 365*433d6423SLionel Sambuc break; 366*433d6423SLionel Sambuc } 367*433d6423SLionel Sambuc 368*433d6423SLionel Sambuc Flags = ACPI_NS_NO_UPSEARCH; 369*433d6423SLionel Sambuc if ((WalkState->Opcode != AML_SCOPE_OP) && 370*433d6423SLionel Sambuc (!(WalkState->ParseFlags & ACPI_PARSE_DEFERRED_OP))) 371*433d6423SLionel Sambuc { 372*433d6423SLionel Sambuc Flags |= ACPI_NS_ERROR_IF_FOUND; 373*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Cannot already exist\n", 374*433d6423SLionel Sambuc AcpiUtGetTypeName (ObjectType))); 375*433d6423SLionel Sambuc } 376*433d6423SLionel Sambuc else 377*433d6423SLionel Sambuc { 378*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 379*433d6423SLionel Sambuc "[%s] Both Find or Create allowed\n", 380*433d6423SLionel Sambuc AcpiUtGetTypeName (ObjectType))); 381*433d6423SLionel Sambuc } 382*433d6423SLionel Sambuc 383*433d6423SLionel Sambuc /* 384*433d6423SLionel Sambuc * Enter the named type into the internal namespace. We enter the name 385*433d6423SLionel Sambuc * as we go downward in the parse tree. Any necessary subobjects that 386*433d6423SLionel Sambuc * involve arguments to the opcode must be created as we go back up the 387*433d6423SLionel Sambuc * parse tree later. 388*433d6423SLionel Sambuc */ 389*433d6423SLionel Sambuc Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, 390*433d6423SLionel Sambuc ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node); 391*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 392*433d6423SLionel Sambuc { 393*433d6423SLionel Sambuc if (Status == AE_ALREADY_EXISTS) 394*433d6423SLionel Sambuc { 395*433d6423SLionel Sambuc /* The name already exists in this scope */ 396*433d6423SLionel Sambuc 397*433d6423SLionel Sambuc if (Node->Flags & ANOBJ_IS_EXTERNAL) 398*433d6423SLionel Sambuc { 399*433d6423SLionel Sambuc /* 400*433d6423SLionel Sambuc * Allow one create on an object or segment that was 401*433d6423SLionel Sambuc * previously declared External 402*433d6423SLionel Sambuc */ 403*433d6423SLionel Sambuc Node->Flags &= ~ANOBJ_IS_EXTERNAL; 404*433d6423SLionel Sambuc Node->Type = (UINT8) ObjectType; 405*433d6423SLionel Sambuc 406*433d6423SLionel Sambuc /* Just retyped a node, probably will need to open a scope */ 407*433d6423SLionel Sambuc 408*433d6423SLionel Sambuc if (AcpiNsOpensScope (ObjectType)) 409*433d6423SLionel Sambuc { 410*433d6423SLionel Sambuc Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); 411*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 412*433d6423SLionel Sambuc { 413*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 414*433d6423SLionel Sambuc } 415*433d6423SLionel Sambuc } 416*433d6423SLionel Sambuc 417*433d6423SLionel Sambuc Status = AE_OK; 418*433d6423SLionel Sambuc } 419*433d6423SLionel Sambuc } 420*433d6423SLionel Sambuc 421*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 422*433d6423SLionel Sambuc { 423*433d6423SLionel Sambuc ACPI_ERROR_NAMESPACE (Path, Status); 424*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 425*433d6423SLionel Sambuc } 426*433d6423SLionel Sambuc } 427*433d6423SLionel Sambuc break; 428*433d6423SLionel Sambuc } 429*433d6423SLionel Sambuc 430*433d6423SLionel Sambuc /* Common exit */ 431*433d6423SLionel Sambuc 432*433d6423SLionel Sambuc if (!Op) 433*433d6423SLionel Sambuc { 434*433d6423SLionel Sambuc /* Create a new op */ 435*433d6423SLionel Sambuc 436*433d6423SLionel Sambuc Op = AcpiPsAllocOp (WalkState->Opcode); 437*433d6423SLionel Sambuc if (!Op) 438*433d6423SLionel Sambuc { 439*433d6423SLionel Sambuc return_ACPI_STATUS (AE_NO_MEMORY); 440*433d6423SLionel Sambuc } 441*433d6423SLionel Sambuc } 442*433d6423SLionel Sambuc 443*433d6423SLionel Sambuc /* Initialize the op */ 444*433d6423SLionel Sambuc 445*433d6423SLionel Sambuc #if (defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)) 446*433d6423SLionel Sambuc Op->Named.Path = ACPI_CAST_PTR (UINT8, Path); 447*433d6423SLionel Sambuc #endif 448*433d6423SLionel Sambuc 449*433d6423SLionel Sambuc if (Node) 450*433d6423SLionel Sambuc { 451*433d6423SLionel Sambuc /* 452*433d6423SLionel Sambuc * Put the Node in the "op" object that the parser uses, so we 453*433d6423SLionel Sambuc * can get it again quickly when this scope is closed 454*433d6423SLionel Sambuc */ 455*433d6423SLionel Sambuc Op->Common.Node = Node; 456*433d6423SLionel Sambuc Op->Named.Name = Node->Name.Integer; 457*433d6423SLionel Sambuc } 458*433d6423SLionel Sambuc 459*433d6423SLionel Sambuc AcpiPsAppendArg (AcpiPsGetParentScope (&WalkState->ParserState), Op); 460*433d6423SLionel Sambuc *OutOp = Op; 461*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 462*433d6423SLionel Sambuc } 463*433d6423SLionel Sambuc 464*433d6423SLionel Sambuc 465*433d6423SLionel Sambuc /******************************************************************************* 466*433d6423SLionel Sambuc * 467*433d6423SLionel Sambuc * FUNCTION: AcpiDsLoad1EndOp 468*433d6423SLionel Sambuc * 469*433d6423SLionel Sambuc * PARAMETERS: WalkState - Current state of the parse tree walk 470*433d6423SLionel Sambuc * 471*433d6423SLionel Sambuc * RETURN: Status 472*433d6423SLionel Sambuc * 473*433d6423SLionel Sambuc * DESCRIPTION: Ascending callback used during the loading of the namespace, 474*433d6423SLionel Sambuc * both control methods and everything else. 475*433d6423SLionel Sambuc * 476*433d6423SLionel Sambuc ******************************************************************************/ 477*433d6423SLionel Sambuc 478*433d6423SLionel Sambuc ACPI_STATUS 479*433d6423SLionel Sambuc AcpiDsLoad1EndOp ( 480*433d6423SLionel Sambuc ACPI_WALK_STATE *WalkState) 481*433d6423SLionel Sambuc { 482*433d6423SLionel Sambuc ACPI_PARSE_OBJECT *Op; 483*433d6423SLionel Sambuc ACPI_OBJECT_TYPE ObjectType; 484*433d6423SLionel Sambuc ACPI_STATUS Status = AE_OK; 485*433d6423SLionel Sambuc 486*433d6423SLionel Sambuc 487*433d6423SLionel Sambuc ACPI_FUNCTION_TRACE (DsLoad1EndOp); 488*433d6423SLionel Sambuc 489*433d6423SLionel Sambuc 490*433d6423SLionel Sambuc Op = WalkState->Op; 491*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); 492*433d6423SLionel Sambuc 493*433d6423SLionel Sambuc /* We are only interested in opcodes that have an associated name */ 494*433d6423SLionel Sambuc 495*433d6423SLionel Sambuc if (!(WalkState->OpInfo->Flags & (AML_NAMED | AML_FIELD))) 496*433d6423SLionel Sambuc { 497*433d6423SLionel Sambuc return_ACPI_STATUS (AE_OK); 498*433d6423SLionel Sambuc } 499*433d6423SLionel Sambuc 500*433d6423SLionel Sambuc /* Get the object type to determine if we should pop the scope */ 501*433d6423SLionel Sambuc 502*433d6423SLionel Sambuc ObjectType = WalkState->OpInfo->ObjectType; 503*433d6423SLionel Sambuc 504*433d6423SLionel Sambuc #ifndef ACPI_NO_METHOD_EXECUTION 505*433d6423SLionel Sambuc if (WalkState->OpInfo->Flags & AML_FIELD) 506*433d6423SLionel Sambuc { 507*433d6423SLionel Sambuc /* 508*433d6423SLionel Sambuc * If we are executing a method, do not create any namespace objects 509*433d6423SLionel Sambuc * during the load phase, only during execution. 510*433d6423SLionel Sambuc */ 511*433d6423SLionel Sambuc if (!WalkState->MethodNode) 512*433d6423SLionel Sambuc { 513*433d6423SLionel Sambuc if (WalkState->Opcode == AML_FIELD_OP || 514*433d6423SLionel Sambuc WalkState->Opcode == AML_BANK_FIELD_OP || 515*433d6423SLionel Sambuc WalkState->Opcode == AML_INDEX_FIELD_OP) 516*433d6423SLionel Sambuc { 517*433d6423SLionel Sambuc Status = AcpiDsInitFieldObjects (Op, WalkState); 518*433d6423SLionel Sambuc } 519*433d6423SLionel Sambuc } 520*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 521*433d6423SLionel Sambuc } 522*433d6423SLionel Sambuc 523*433d6423SLionel Sambuc /* 524*433d6423SLionel Sambuc * If we are executing a method, do not create any namespace objects 525*433d6423SLionel Sambuc * during the load phase, only during execution. 526*433d6423SLionel Sambuc */ 527*433d6423SLionel Sambuc if (!WalkState->MethodNode) 528*433d6423SLionel Sambuc { 529*433d6423SLionel Sambuc if (Op->Common.AmlOpcode == AML_REGION_OP) 530*433d6423SLionel Sambuc { 531*433d6423SLionel Sambuc Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length, 532*433d6423SLionel Sambuc (ACPI_ADR_SPACE_TYPE) ((Op->Common.Value.Arg)->Common.Value.Integer), 533*433d6423SLionel Sambuc WalkState); 534*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 535*433d6423SLionel Sambuc { 536*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 537*433d6423SLionel Sambuc } 538*433d6423SLionel Sambuc } 539*433d6423SLionel Sambuc else if (Op->Common.AmlOpcode == AML_DATA_REGION_OP) 540*433d6423SLionel Sambuc { 541*433d6423SLionel Sambuc Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length, 542*433d6423SLionel Sambuc REGION_DATA_TABLE, WalkState); 543*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 544*433d6423SLionel Sambuc { 545*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 546*433d6423SLionel Sambuc } 547*433d6423SLionel Sambuc } 548*433d6423SLionel Sambuc } 549*433d6423SLionel Sambuc #endif 550*433d6423SLionel Sambuc 551*433d6423SLionel Sambuc if (Op->Common.AmlOpcode == AML_NAME_OP) 552*433d6423SLionel Sambuc { 553*433d6423SLionel Sambuc /* For Name opcode, get the object type from the argument */ 554*433d6423SLionel Sambuc 555*433d6423SLionel Sambuc if (Op->Common.Value.Arg) 556*433d6423SLionel Sambuc { 557*433d6423SLionel Sambuc ObjectType = (AcpiPsGetOpcodeInfo ( 558*433d6423SLionel Sambuc (Op->Common.Value.Arg)->Common.AmlOpcode))->ObjectType; 559*433d6423SLionel Sambuc 560*433d6423SLionel Sambuc /* Set node type if we have a namespace node */ 561*433d6423SLionel Sambuc 562*433d6423SLionel Sambuc if (Op->Common.Node) 563*433d6423SLionel Sambuc { 564*433d6423SLionel Sambuc Op->Common.Node->Type = (UINT8) ObjectType; 565*433d6423SLionel Sambuc } 566*433d6423SLionel Sambuc } 567*433d6423SLionel Sambuc } 568*433d6423SLionel Sambuc 569*433d6423SLionel Sambuc /* 570*433d6423SLionel Sambuc * If we are executing a method, do not create any namespace objects 571*433d6423SLionel Sambuc * during the load phase, only during execution. 572*433d6423SLionel Sambuc */ 573*433d6423SLionel Sambuc if (!WalkState->MethodNode) 574*433d6423SLionel Sambuc { 575*433d6423SLionel Sambuc if (Op->Common.AmlOpcode == AML_METHOD_OP) 576*433d6423SLionel Sambuc { 577*433d6423SLionel Sambuc /* 578*433d6423SLionel Sambuc * MethodOp PkgLength NameString MethodFlags TermList 579*433d6423SLionel Sambuc * 580*433d6423SLionel Sambuc * Note: We must create the method node/object pair as soon as we 581*433d6423SLionel Sambuc * see the method declaration. This allows later pass1 parsing 582*433d6423SLionel Sambuc * of invocations of the method (need to know the number of 583*433d6423SLionel Sambuc * arguments.) 584*433d6423SLionel Sambuc */ 585*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 586*433d6423SLionel Sambuc "LOADING-Method: State=%p Op=%p NamedObj=%p\n", 587*433d6423SLionel Sambuc WalkState, Op, Op->Named.Node)); 588*433d6423SLionel Sambuc 589*433d6423SLionel Sambuc if (!AcpiNsGetAttachedObject (Op->Named.Node)) 590*433d6423SLionel Sambuc { 591*433d6423SLionel Sambuc WalkState->Operands[0] = ACPI_CAST_PTR (void, Op->Named.Node); 592*433d6423SLionel Sambuc WalkState->NumOperands = 1; 593*433d6423SLionel Sambuc 594*433d6423SLionel Sambuc Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg); 595*433d6423SLionel Sambuc if (ACPI_SUCCESS (Status)) 596*433d6423SLionel Sambuc { 597*433d6423SLionel Sambuc Status = AcpiExCreateMethod (Op->Named.Data, 598*433d6423SLionel Sambuc Op->Named.Length, WalkState); 599*433d6423SLionel Sambuc } 600*433d6423SLionel Sambuc 601*433d6423SLionel Sambuc WalkState->Operands[0] = NULL; 602*433d6423SLionel Sambuc WalkState->NumOperands = 0; 603*433d6423SLionel Sambuc 604*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 605*433d6423SLionel Sambuc { 606*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 607*433d6423SLionel Sambuc } 608*433d6423SLionel Sambuc } 609*433d6423SLionel Sambuc } 610*433d6423SLionel Sambuc } 611*433d6423SLionel Sambuc 612*433d6423SLionel Sambuc /* Pop the scope stack (only if loading a table) */ 613*433d6423SLionel Sambuc 614*433d6423SLionel Sambuc if (!WalkState->MethodNode && 615*433d6423SLionel Sambuc AcpiNsOpensScope (ObjectType)) 616*433d6423SLionel Sambuc { 617*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s): Popping scope for Op %p\n", 618*433d6423SLionel Sambuc AcpiUtGetTypeName (ObjectType), Op)); 619*433d6423SLionel Sambuc 620*433d6423SLionel Sambuc Status = AcpiDsScopeStackPop (WalkState); 621*433d6423SLionel Sambuc } 622*433d6423SLionel Sambuc 623*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 624*433d6423SLionel Sambuc } 625*433d6423SLionel Sambuc 626*433d6423SLionel Sambuc 627*433d6423SLionel Sambuc /******************************************************************************* 628*433d6423SLionel Sambuc * 629*433d6423SLionel Sambuc * FUNCTION: AcpiDsLoad2BeginOp 630*433d6423SLionel Sambuc * 631*433d6423SLionel Sambuc * PARAMETERS: WalkState - Current state of the parse tree walk 632*433d6423SLionel Sambuc * OutOp - Wher to return op if a new one is created 633*433d6423SLionel Sambuc * 634*433d6423SLionel Sambuc * RETURN: Status 635*433d6423SLionel Sambuc * 636*433d6423SLionel Sambuc * DESCRIPTION: Descending callback used during the loading of ACPI tables. 637*433d6423SLionel Sambuc * 638*433d6423SLionel Sambuc ******************************************************************************/ 639*433d6423SLionel Sambuc 640*433d6423SLionel Sambuc ACPI_STATUS 641*433d6423SLionel Sambuc AcpiDsLoad2BeginOp ( 642*433d6423SLionel Sambuc ACPI_WALK_STATE *WalkState, 643*433d6423SLionel Sambuc ACPI_PARSE_OBJECT **OutOp) 644*433d6423SLionel Sambuc { 645*433d6423SLionel Sambuc ACPI_PARSE_OBJECT *Op; 646*433d6423SLionel Sambuc ACPI_NAMESPACE_NODE *Node; 647*433d6423SLionel Sambuc ACPI_STATUS Status; 648*433d6423SLionel Sambuc ACPI_OBJECT_TYPE ObjectType; 649*433d6423SLionel Sambuc char *BufferPtr; 650*433d6423SLionel Sambuc UINT32 Flags; 651*433d6423SLionel Sambuc 652*433d6423SLionel Sambuc 653*433d6423SLionel Sambuc ACPI_FUNCTION_TRACE (DsLoad2BeginOp); 654*433d6423SLionel Sambuc 655*433d6423SLionel Sambuc 656*433d6423SLionel Sambuc Op = WalkState->Op; 657*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); 658*433d6423SLionel Sambuc 659*433d6423SLionel Sambuc if (Op) 660*433d6423SLionel Sambuc { 661*433d6423SLionel Sambuc if ((WalkState->ControlState) && 662*433d6423SLionel Sambuc (WalkState->ControlState->Common.State == 663*433d6423SLionel Sambuc ACPI_CONTROL_CONDITIONAL_EXECUTING)) 664*433d6423SLionel Sambuc { 665*433d6423SLionel Sambuc /* We are executing a while loop outside of a method */ 666*433d6423SLionel Sambuc 667*433d6423SLionel Sambuc Status = AcpiDsExecBeginOp (WalkState, OutOp); 668*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 669*433d6423SLionel Sambuc } 670*433d6423SLionel Sambuc 671*433d6423SLionel Sambuc /* We only care about Namespace opcodes here */ 672*433d6423SLionel Sambuc 673*433d6423SLionel Sambuc if ((!(WalkState->OpInfo->Flags & AML_NSOPCODE) && 674*433d6423SLionel Sambuc (WalkState->Opcode != AML_INT_NAMEPATH_OP)) || 675*433d6423SLionel Sambuc (!(WalkState->OpInfo->Flags & AML_NAMED))) 676*433d6423SLionel Sambuc { 677*433d6423SLionel Sambuc return_ACPI_STATUS (AE_OK); 678*433d6423SLionel Sambuc } 679*433d6423SLionel Sambuc 680*433d6423SLionel Sambuc /* Get the name we are going to enter or lookup in the namespace */ 681*433d6423SLionel Sambuc 682*433d6423SLionel Sambuc if (WalkState->Opcode == AML_INT_NAMEPATH_OP) 683*433d6423SLionel Sambuc { 684*433d6423SLionel Sambuc /* For Namepath op, get the path string */ 685*433d6423SLionel Sambuc 686*433d6423SLionel Sambuc BufferPtr = Op->Common.Value.String; 687*433d6423SLionel Sambuc if (!BufferPtr) 688*433d6423SLionel Sambuc { 689*433d6423SLionel Sambuc /* No name, just exit */ 690*433d6423SLionel Sambuc 691*433d6423SLionel Sambuc return_ACPI_STATUS (AE_OK); 692*433d6423SLionel Sambuc } 693*433d6423SLionel Sambuc } 694*433d6423SLionel Sambuc else 695*433d6423SLionel Sambuc { 696*433d6423SLionel Sambuc /* Get name from the op */ 697*433d6423SLionel Sambuc 698*433d6423SLionel Sambuc BufferPtr = ACPI_CAST_PTR (char, &Op->Named.Name); 699*433d6423SLionel Sambuc } 700*433d6423SLionel Sambuc } 701*433d6423SLionel Sambuc else 702*433d6423SLionel Sambuc { 703*433d6423SLionel Sambuc /* Get the namestring from the raw AML */ 704*433d6423SLionel Sambuc 705*433d6423SLionel Sambuc BufferPtr = AcpiPsGetNextNamestring (&WalkState->ParserState); 706*433d6423SLionel Sambuc } 707*433d6423SLionel Sambuc 708*433d6423SLionel Sambuc /* Map the opcode into an internal object type */ 709*433d6423SLionel Sambuc 710*433d6423SLionel Sambuc ObjectType = WalkState->OpInfo->ObjectType; 711*433d6423SLionel Sambuc 712*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 713*433d6423SLionel Sambuc "State=%p Op=%p Type=%X\n", WalkState, Op, ObjectType)); 714*433d6423SLionel Sambuc 715*433d6423SLionel Sambuc switch (WalkState->Opcode) 716*433d6423SLionel Sambuc { 717*433d6423SLionel Sambuc case AML_FIELD_OP: 718*433d6423SLionel Sambuc case AML_BANK_FIELD_OP: 719*433d6423SLionel Sambuc case AML_INDEX_FIELD_OP: 720*433d6423SLionel Sambuc 721*433d6423SLionel Sambuc Node = NULL; 722*433d6423SLionel Sambuc Status = AE_OK; 723*433d6423SLionel Sambuc break; 724*433d6423SLionel Sambuc 725*433d6423SLionel Sambuc case AML_INT_NAMEPATH_OP: 726*433d6423SLionel Sambuc /* 727*433d6423SLionel Sambuc * The NamePath is an object reference to an existing object. 728*433d6423SLionel Sambuc * Don't enter the name into the namespace, but look it up 729*433d6423SLionel Sambuc * for use later. 730*433d6423SLionel Sambuc */ 731*433d6423SLionel Sambuc Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, 732*433d6423SLionel Sambuc ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, 733*433d6423SLionel Sambuc WalkState, &(Node)); 734*433d6423SLionel Sambuc break; 735*433d6423SLionel Sambuc 736*433d6423SLionel Sambuc case AML_SCOPE_OP: 737*433d6423SLionel Sambuc 738*433d6423SLionel Sambuc /* Special case for Scope(\) -> refers to the Root node */ 739*433d6423SLionel Sambuc 740*433d6423SLionel Sambuc if (Op && (Op->Named.Node == AcpiGbl_RootNode)) 741*433d6423SLionel Sambuc { 742*433d6423SLionel Sambuc Node = Op->Named.Node; 743*433d6423SLionel Sambuc 744*433d6423SLionel Sambuc Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); 745*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 746*433d6423SLionel Sambuc { 747*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 748*433d6423SLionel Sambuc } 749*433d6423SLionel Sambuc } 750*433d6423SLionel Sambuc else 751*433d6423SLionel Sambuc { 752*433d6423SLionel Sambuc /* 753*433d6423SLionel Sambuc * The Path is an object reference to an existing object. 754*433d6423SLionel Sambuc * Don't enter the name into the namespace, but look it up 755*433d6423SLionel Sambuc * for use later. 756*433d6423SLionel Sambuc */ 757*433d6423SLionel Sambuc Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, 758*433d6423SLionel Sambuc ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, 759*433d6423SLionel Sambuc WalkState, &(Node)); 760*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 761*433d6423SLionel Sambuc { 762*433d6423SLionel Sambuc #ifdef ACPI_ASL_COMPILER 763*433d6423SLionel Sambuc if (Status == AE_NOT_FOUND) 764*433d6423SLionel Sambuc { 765*433d6423SLionel Sambuc Status = AE_OK; 766*433d6423SLionel Sambuc } 767*433d6423SLionel Sambuc else 768*433d6423SLionel Sambuc { 769*433d6423SLionel Sambuc ACPI_ERROR_NAMESPACE (BufferPtr, Status); 770*433d6423SLionel Sambuc } 771*433d6423SLionel Sambuc #else 772*433d6423SLionel Sambuc ACPI_ERROR_NAMESPACE (BufferPtr, Status); 773*433d6423SLionel Sambuc #endif 774*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 775*433d6423SLionel Sambuc } 776*433d6423SLionel Sambuc } 777*433d6423SLionel Sambuc 778*433d6423SLionel Sambuc /* 779*433d6423SLionel Sambuc * We must check to make sure that the target is 780*433d6423SLionel Sambuc * one of the opcodes that actually opens a scope 781*433d6423SLionel Sambuc */ 782*433d6423SLionel Sambuc switch (Node->Type) 783*433d6423SLionel Sambuc { 784*433d6423SLionel Sambuc case ACPI_TYPE_ANY: 785*433d6423SLionel Sambuc case ACPI_TYPE_LOCAL_SCOPE: /* Scope */ 786*433d6423SLionel Sambuc case ACPI_TYPE_DEVICE: 787*433d6423SLionel Sambuc case ACPI_TYPE_POWER: 788*433d6423SLionel Sambuc case ACPI_TYPE_PROCESSOR: 789*433d6423SLionel Sambuc case ACPI_TYPE_THERMAL: 790*433d6423SLionel Sambuc 791*433d6423SLionel Sambuc /* These are acceptable types */ 792*433d6423SLionel Sambuc break; 793*433d6423SLionel Sambuc 794*433d6423SLionel Sambuc case ACPI_TYPE_INTEGER: 795*433d6423SLionel Sambuc case ACPI_TYPE_STRING: 796*433d6423SLionel Sambuc case ACPI_TYPE_BUFFER: 797*433d6423SLionel Sambuc 798*433d6423SLionel Sambuc /* 799*433d6423SLionel Sambuc * These types we will allow, but we will change the type. 800*433d6423SLionel Sambuc * This enables some existing code of the form: 801*433d6423SLionel Sambuc * 802*433d6423SLionel Sambuc * Name (DEB, 0) 803*433d6423SLionel Sambuc * Scope (DEB) { ... } 804*433d6423SLionel Sambuc */ 805*433d6423SLionel Sambuc ACPI_WARNING ((AE_INFO, 806*433d6423SLionel Sambuc "Type override - [%4.4s] had invalid type (%s) " 807*433d6423SLionel Sambuc "for Scope operator, changed to type ANY\n", 808*433d6423SLionel Sambuc AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type))); 809*433d6423SLionel Sambuc 810*433d6423SLionel Sambuc Node->Type = ACPI_TYPE_ANY; 811*433d6423SLionel Sambuc WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY; 812*433d6423SLionel Sambuc break; 813*433d6423SLionel Sambuc 814*433d6423SLionel Sambuc default: 815*433d6423SLionel Sambuc 816*433d6423SLionel Sambuc /* All other types are an error */ 817*433d6423SLionel Sambuc 818*433d6423SLionel Sambuc ACPI_ERROR ((AE_INFO, 819*433d6423SLionel Sambuc "Invalid type (%s) for target of " 820*433d6423SLionel Sambuc "Scope operator [%4.4s] (Cannot override)", 821*433d6423SLionel Sambuc AcpiUtGetTypeName (Node->Type), AcpiUtGetNodeName (Node))); 822*433d6423SLionel Sambuc 823*433d6423SLionel Sambuc return (AE_AML_OPERAND_TYPE); 824*433d6423SLionel Sambuc } 825*433d6423SLionel Sambuc break; 826*433d6423SLionel Sambuc 827*433d6423SLionel Sambuc default: 828*433d6423SLionel Sambuc 829*433d6423SLionel Sambuc /* All other opcodes */ 830*433d6423SLionel Sambuc 831*433d6423SLionel Sambuc if (Op && Op->Common.Node) 832*433d6423SLionel Sambuc { 833*433d6423SLionel Sambuc /* This op/node was previously entered into the namespace */ 834*433d6423SLionel Sambuc 835*433d6423SLionel Sambuc Node = Op->Common.Node; 836*433d6423SLionel Sambuc 837*433d6423SLionel Sambuc if (AcpiNsOpensScope (ObjectType)) 838*433d6423SLionel Sambuc { 839*433d6423SLionel Sambuc Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); 840*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 841*433d6423SLionel Sambuc { 842*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 843*433d6423SLionel Sambuc } 844*433d6423SLionel Sambuc } 845*433d6423SLionel Sambuc 846*433d6423SLionel Sambuc return_ACPI_STATUS (AE_OK); 847*433d6423SLionel Sambuc } 848*433d6423SLionel Sambuc 849*433d6423SLionel Sambuc /* 850*433d6423SLionel Sambuc * Enter the named type into the internal namespace. We enter the name 851*433d6423SLionel Sambuc * as we go downward in the parse tree. Any necessary subobjects that 852*433d6423SLionel Sambuc * involve arguments to the opcode must be created as we go back up the 853*433d6423SLionel Sambuc * parse tree later. 854*433d6423SLionel Sambuc * 855*433d6423SLionel Sambuc * Note: Name may already exist if we are executing a deferred opcode. 856*433d6423SLionel Sambuc */ 857*433d6423SLionel Sambuc if (WalkState->DeferredNode) 858*433d6423SLionel Sambuc { 859*433d6423SLionel Sambuc /* This name is already in the namespace, get the node */ 860*433d6423SLionel Sambuc 861*433d6423SLionel Sambuc Node = WalkState->DeferredNode; 862*433d6423SLionel Sambuc Status = AE_OK; 863*433d6423SLionel Sambuc break; 864*433d6423SLionel Sambuc } 865*433d6423SLionel Sambuc 866*433d6423SLionel Sambuc Flags = ACPI_NS_NO_UPSEARCH; 867*433d6423SLionel Sambuc if (WalkState->PassNumber == ACPI_IMODE_EXECUTE) 868*433d6423SLionel Sambuc { 869*433d6423SLionel Sambuc /* Execution mode, node cannot already exist, node is temporary */ 870*433d6423SLionel Sambuc 871*433d6423SLionel Sambuc Flags |= ACPI_NS_ERROR_IF_FOUND; 872*433d6423SLionel Sambuc 873*433d6423SLionel Sambuc if (!(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL)) 874*433d6423SLionel Sambuc { 875*433d6423SLionel Sambuc Flags |= ACPI_NS_TEMPORARY; 876*433d6423SLionel Sambuc } 877*433d6423SLionel Sambuc } 878*433d6423SLionel Sambuc 879*433d6423SLionel Sambuc /* Add new entry or lookup existing entry */ 880*433d6423SLionel Sambuc 881*433d6423SLionel Sambuc Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, 882*433d6423SLionel Sambuc ACPI_IMODE_LOAD_PASS2, Flags, WalkState, &Node); 883*433d6423SLionel Sambuc 884*433d6423SLionel Sambuc if (ACPI_SUCCESS (Status) && (Flags & ACPI_NS_TEMPORARY)) 885*433d6423SLionel Sambuc { 886*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 887*433d6423SLionel Sambuc "***New Node [%4.4s] %p is temporary\n", 888*433d6423SLionel Sambuc AcpiUtGetNodeName (Node), Node)); 889*433d6423SLionel Sambuc } 890*433d6423SLionel Sambuc break; 891*433d6423SLionel Sambuc } 892*433d6423SLionel Sambuc 893*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 894*433d6423SLionel Sambuc { 895*433d6423SLionel Sambuc ACPI_ERROR_NAMESPACE (BufferPtr, Status); 896*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 897*433d6423SLionel Sambuc } 898*433d6423SLionel Sambuc 899*433d6423SLionel Sambuc if (!Op) 900*433d6423SLionel Sambuc { 901*433d6423SLionel Sambuc /* Create a new op */ 902*433d6423SLionel Sambuc 903*433d6423SLionel Sambuc Op = AcpiPsAllocOp (WalkState->Opcode); 904*433d6423SLionel Sambuc if (!Op) 905*433d6423SLionel Sambuc { 906*433d6423SLionel Sambuc return_ACPI_STATUS (AE_NO_MEMORY); 907*433d6423SLionel Sambuc } 908*433d6423SLionel Sambuc 909*433d6423SLionel Sambuc /* Initialize the new op */ 910*433d6423SLionel Sambuc 911*433d6423SLionel Sambuc if (Node) 912*433d6423SLionel Sambuc { 913*433d6423SLionel Sambuc Op->Named.Name = Node->Name.Integer; 914*433d6423SLionel Sambuc } 915*433d6423SLionel Sambuc *OutOp = Op; 916*433d6423SLionel Sambuc } 917*433d6423SLionel Sambuc 918*433d6423SLionel Sambuc /* 919*433d6423SLionel Sambuc * Put the Node in the "op" object that the parser uses, so we 920*433d6423SLionel Sambuc * can get it again quickly when this scope is closed 921*433d6423SLionel Sambuc */ 922*433d6423SLionel Sambuc Op->Common.Node = Node; 923*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 924*433d6423SLionel Sambuc } 925*433d6423SLionel Sambuc 926*433d6423SLionel Sambuc 927*433d6423SLionel Sambuc /******************************************************************************* 928*433d6423SLionel Sambuc * 929*433d6423SLionel Sambuc * FUNCTION: AcpiDsLoad2EndOp 930*433d6423SLionel Sambuc * 931*433d6423SLionel Sambuc * PARAMETERS: WalkState - Current state of the parse tree walk 932*433d6423SLionel Sambuc * 933*433d6423SLionel Sambuc * RETURN: Status 934*433d6423SLionel Sambuc * 935*433d6423SLionel Sambuc * DESCRIPTION: Ascending callback used during the loading of the namespace, 936*433d6423SLionel Sambuc * both control methods and everything else. 937*433d6423SLionel Sambuc * 938*433d6423SLionel Sambuc ******************************************************************************/ 939*433d6423SLionel Sambuc 940*433d6423SLionel Sambuc ACPI_STATUS 941*433d6423SLionel Sambuc AcpiDsLoad2EndOp ( 942*433d6423SLionel Sambuc ACPI_WALK_STATE *WalkState) 943*433d6423SLionel Sambuc { 944*433d6423SLionel Sambuc ACPI_PARSE_OBJECT *Op; 945*433d6423SLionel Sambuc ACPI_STATUS Status = AE_OK; 946*433d6423SLionel Sambuc ACPI_OBJECT_TYPE ObjectType; 947*433d6423SLionel Sambuc ACPI_NAMESPACE_NODE *Node; 948*433d6423SLionel Sambuc ACPI_PARSE_OBJECT *Arg; 949*433d6423SLionel Sambuc ACPI_NAMESPACE_NODE *NewNode; 950*433d6423SLionel Sambuc #ifndef ACPI_NO_METHOD_EXECUTION 951*433d6423SLionel Sambuc UINT32 i; 952*433d6423SLionel Sambuc UINT8 RegionSpace; 953*433d6423SLionel Sambuc #endif 954*433d6423SLionel Sambuc 955*433d6423SLionel Sambuc 956*433d6423SLionel Sambuc ACPI_FUNCTION_TRACE (DsLoad2EndOp); 957*433d6423SLionel Sambuc 958*433d6423SLionel Sambuc Op = WalkState->Op; 959*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n", 960*433d6423SLionel Sambuc WalkState->OpInfo->Name, Op, WalkState)); 961*433d6423SLionel Sambuc 962*433d6423SLionel Sambuc /* Check if opcode had an associated namespace object */ 963*433d6423SLionel Sambuc 964*433d6423SLionel Sambuc if (!(WalkState->OpInfo->Flags & AML_NSOBJECT)) 965*433d6423SLionel Sambuc { 966*433d6423SLionel Sambuc return_ACPI_STATUS (AE_OK); 967*433d6423SLionel Sambuc } 968*433d6423SLionel Sambuc 969*433d6423SLionel Sambuc if (Op->Common.AmlOpcode == AML_SCOPE_OP) 970*433d6423SLionel Sambuc { 971*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 972*433d6423SLionel Sambuc "Ending scope Op=%p State=%p\n", Op, WalkState)); 973*433d6423SLionel Sambuc } 974*433d6423SLionel Sambuc 975*433d6423SLionel Sambuc ObjectType = WalkState->OpInfo->ObjectType; 976*433d6423SLionel Sambuc 977*433d6423SLionel Sambuc /* 978*433d6423SLionel Sambuc * Get the Node/name from the earlier lookup 979*433d6423SLionel Sambuc * (It was saved in the *op structure) 980*433d6423SLionel Sambuc */ 981*433d6423SLionel Sambuc Node = Op->Common.Node; 982*433d6423SLionel Sambuc 983*433d6423SLionel Sambuc /* 984*433d6423SLionel Sambuc * Put the Node on the object stack (Contains the ACPI Name of 985*433d6423SLionel Sambuc * this object) 986*433d6423SLionel Sambuc */ 987*433d6423SLionel Sambuc WalkState->Operands[0] = (void *) Node; 988*433d6423SLionel Sambuc WalkState->NumOperands = 1; 989*433d6423SLionel Sambuc 990*433d6423SLionel Sambuc /* Pop the scope stack */ 991*433d6423SLionel Sambuc 992*433d6423SLionel Sambuc if (AcpiNsOpensScope (ObjectType) && 993*433d6423SLionel Sambuc (Op->Common.AmlOpcode != AML_INT_METHODCALL_OP)) 994*433d6423SLionel Sambuc { 995*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n", 996*433d6423SLionel Sambuc AcpiUtGetTypeName (ObjectType), Op)); 997*433d6423SLionel Sambuc 998*433d6423SLionel Sambuc Status = AcpiDsScopeStackPop (WalkState); 999*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 1000*433d6423SLionel Sambuc { 1001*433d6423SLionel Sambuc goto Cleanup; 1002*433d6423SLionel Sambuc } 1003*433d6423SLionel Sambuc } 1004*433d6423SLionel Sambuc 1005*433d6423SLionel Sambuc /* 1006*433d6423SLionel Sambuc * Named operations are as follows: 1007*433d6423SLionel Sambuc * 1008*433d6423SLionel Sambuc * AML_ALIAS 1009*433d6423SLionel Sambuc * AML_BANKFIELD 1010*433d6423SLionel Sambuc * AML_CREATEBITFIELD 1011*433d6423SLionel Sambuc * AML_CREATEBYTEFIELD 1012*433d6423SLionel Sambuc * AML_CREATEDWORDFIELD 1013*433d6423SLionel Sambuc * AML_CREATEFIELD 1014*433d6423SLionel Sambuc * AML_CREATEQWORDFIELD 1015*433d6423SLionel Sambuc * AML_CREATEWORDFIELD 1016*433d6423SLionel Sambuc * AML_DATA_REGION 1017*433d6423SLionel Sambuc * AML_DEVICE 1018*433d6423SLionel Sambuc * AML_EVENT 1019*433d6423SLionel Sambuc * AML_FIELD 1020*433d6423SLionel Sambuc * AML_INDEXFIELD 1021*433d6423SLionel Sambuc * AML_METHOD 1022*433d6423SLionel Sambuc * AML_METHODCALL 1023*433d6423SLionel Sambuc * AML_MUTEX 1024*433d6423SLionel Sambuc * AML_NAME 1025*433d6423SLionel Sambuc * AML_NAMEDFIELD 1026*433d6423SLionel Sambuc * AML_OPREGION 1027*433d6423SLionel Sambuc * AML_POWERRES 1028*433d6423SLionel Sambuc * AML_PROCESSOR 1029*433d6423SLionel Sambuc * AML_SCOPE 1030*433d6423SLionel Sambuc * AML_THERMALZONE 1031*433d6423SLionel Sambuc */ 1032*433d6423SLionel Sambuc 1033*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 1034*433d6423SLionel Sambuc "Create-Load [%s] State=%p Op=%p NamedObj=%p\n", 1035*433d6423SLionel Sambuc AcpiPsGetOpcodeName (Op->Common.AmlOpcode), WalkState, Op, Node)); 1036*433d6423SLionel Sambuc 1037*433d6423SLionel Sambuc /* Decode the opcode */ 1038*433d6423SLionel Sambuc 1039*433d6423SLionel Sambuc Arg = Op->Common.Value.Arg; 1040*433d6423SLionel Sambuc 1041*433d6423SLionel Sambuc switch (WalkState->OpInfo->Type) 1042*433d6423SLionel Sambuc { 1043*433d6423SLionel Sambuc #ifndef ACPI_NO_METHOD_EXECUTION 1044*433d6423SLionel Sambuc 1045*433d6423SLionel Sambuc case AML_TYPE_CREATE_FIELD: 1046*433d6423SLionel Sambuc /* 1047*433d6423SLionel Sambuc * Create the field object, but the field buffer and index must 1048*433d6423SLionel Sambuc * be evaluated later during the execution phase 1049*433d6423SLionel Sambuc */ 1050*433d6423SLionel Sambuc Status = AcpiDsCreateBufferField (Op, WalkState); 1051*433d6423SLionel Sambuc break; 1052*433d6423SLionel Sambuc 1053*433d6423SLionel Sambuc 1054*433d6423SLionel Sambuc case AML_TYPE_NAMED_FIELD: 1055*433d6423SLionel Sambuc /* 1056*433d6423SLionel Sambuc * If we are executing a method, initialize the field 1057*433d6423SLionel Sambuc */ 1058*433d6423SLionel Sambuc if (WalkState->MethodNode) 1059*433d6423SLionel Sambuc { 1060*433d6423SLionel Sambuc Status = AcpiDsInitFieldObjects (Op, WalkState); 1061*433d6423SLionel Sambuc } 1062*433d6423SLionel Sambuc 1063*433d6423SLionel Sambuc switch (Op->Common.AmlOpcode) 1064*433d6423SLionel Sambuc { 1065*433d6423SLionel Sambuc case AML_INDEX_FIELD_OP: 1066*433d6423SLionel Sambuc 1067*433d6423SLionel Sambuc Status = AcpiDsCreateIndexField (Op, (ACPI_HANDLE) Arg->Common.Node, 1068*433d6423SLionel Sambuc WalkState); 1069*433d6423SLionel Sambuc break; 1070*433d6423SLionel Sambuc 1071*433d6423SLionel Sambuc case AML_BANK_FIELD_OP: 1072*433d6423SLionel Sambuc 1073*433d6423SLionel Sambuc Status = AcpiDsCreateBankField (Op, Arg->Common.Node, WalkState); 1074*433d6423SLionel Sambuc break; 1075*433d6423SLionel Sambuc 1076*433d6423SLionel Sambuc case AML_FIELD_OP: 1077*433d6423SLionel Sambuc 1078*433d6423SLionel Sambuc Status = AcpiDsCreateField (Op, Arg->Common.Node, WalkState); 1079*433d6423SLionel Sambuc break; 1080*433d6423SLionel Sambuc 1081*433d6423SLionel Sambuc default: 1082*433d6423SLionel Sambuc /* All NAMED_FIELD opcodes must be handled above */ 1083*433d6423SLionel Sambuc break; 1084*433d6423SLionel Sambuc } 1085*433d6423SLionel Sambuc break; 1086*433d6423SLionel Sambuc 1087*433d6423SLionel Sambuc 1088*433d6423SLionel Sambuc case AML_TYPE_NAMED_SIMPLE: 1089*433d6423SLionel Sambuc 1090*433d6423SLionel Sambuc Status = AcpiDsCreateOperands (WalkState, Arg); 1091*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 1092*433d6423SLionel Sambuc { 1093*433d6423SLionel Sambuc goto Cleanup; 1094*433d6423SLionel Sambuc } 1095*433d6423SLionel Sambuc 1096*433d6423SLionel Sambuc switch (Op->Common.AmlOpcode) 1097*433d6423SLionel Sambuc { 1098*433d6423SLionel Sambuc case AML_PROCESSOR_OP: 1099*433d6423SLionel Sambuc 1100*433d6423SLionel Sambuc Status = AcpiExCreateProcessor (WalkState); 1101*433d6423SLionel Sambuc break; 1102*433d6423SLionel Sambuc 1103*433d6423SLionel Sambuc case AML_POWER_RES_OP: 1104*433d6423SLionel Sambuc 1105*433d6423SLionel Sambuc Status = AcpiExCreatePowerResource (WalkState); 1106*433d6423SLionel Sambuc break; 1107*433d6423SLionel Sambuc 1108*433d6423SLionel Sambuc case AML_MUTEX_OP: 1109*433d6423SLionel Sambuc 1110*433d6423SLionel Sambuc Status = AcpiExCreateMutex (WalkState); 1111*433d6423SLionel Sambuc break; 1112*433d6423SLionel Sambuc 1113*433d6423SLionel Sambuc case AML_EVENT_OP: 1114*433d6423SLionel Sambuc 1115*433d6423SLionel Sambuc Status = AcpiExCreateEvent (WalkState); 1116*433d6423SLionel Sambuc break; 1117*433d6423SLionel Sambuc 1118*433d6423SLionel Sambuc 1119*433d6423SLionel Sambuc case AML_ALIAS_OP: 1120*433d6423SLionel Sambuc 1121*433d6423SLionel Sambuc Status = AcpiExCreateAlias (WalkState); 1122*433d6423SLionel Sambuc break; 1123*433d6423SLionel Sambuc 1124*433d6423SLionel Sambuc default: 1125*433d6423SLionel Sambuc /* Unknown opcode */ 1126*433d6423SLionel Sambuc 1127*433d6423SLionel Sambuc Status = AE_OK; 1128*433d6423SLionel Sambuc goto Cleanup; 1129*433d6423SLionel Sambuc } 1130*433d6423SLionel Sambuc 1131*433d6423SLionel Sambuc /* Delete operands */ 1132*433d6423SLionel Sambuc 1133*433d6423SLionel Sambuc for (i = 1; i < WalkState->NumOperands; i++) 1134*433d6423SLionel Sambuc { 1135*433d6423SLionel Sambuc AcpiUtRemoveReference (WalkState->Operands[i]); 1136*433d6423SLionel Sambuc WalkState->Operands[i] = NULL; 1137*433d6423SLionel Sambuc } 1138*433d6423SLionel Sambuc 1139*433d6423SLionel Sambuc break; 1140*433d6423SLionel Sambuc #endif /* ACPI_NO_METHOD_EXECUTION */ 1141*433d6423SLionel Sambuc 1142*433d6423SLionel Sambuc case AML_TYPE_NAMED_COMPLEX: 1143*433d6423SLionel Sambuc 1144*433d6423SLionel Sambuc switch (Op->Common.AmlOpcode) 1145*433d6423SLionel Sambuc { 1146*433d6423SLionel Sambuc #ifndef ACPI_NO_METHOD_EXECUTION 1147*433d6423SLionel Sambuc case AML_REGION_OP: 1148*433d6423SLionel Sambuc case AML_DATA_REGION_OP: 1149*433d6423SLionel Sambuc 1150*433d6423SLionel Sambuc if (Op->Common.AmlOpcode == AML_REGION_OP) 1151*433d6423SLionel Sambuc { 1152*433d6423SLionel Sambuc RegionSpace = (ACPI_ADR_SPACE_TYPE) 1153*433d6423SLionel Sambuc ((Op->Common.Value.Arg)->Common.Value.Integer); 1154*433d6423SLionel Sambuc } 1155*433d6423SLionel Sambuc else 1156*433d6423SLionel Sambuc { 1157*433d6423SLionel Sambuc RegionSpace = REGION_DATA_TABLE; 1158*433d6423SLionel Sambuc } 1159*433d6423SLionel Sambuc 1160*433d6423SLionel Sambuc /* 1161*433d6423SLionel Sambuc * The OpRegion is not fully parsed at this time. The only valid 1162*433d6423SLionel Sambuc * argument is the SpaceId. (We must save the address of the 1163*433d6423SLionel Sambuc * AML of the address and length operands) 1164*433d6423SLionel Sambuc * 1165*433d6423SLionel Sambuc * If we have a valid region, initialize it. The namespace is 1166*433d6423SLionel Sambuc * unlocked at this point. 1167*433d6423SLionel Sambuc * 1168*433d6423SLionel Sambuc * Need to unlock interpreter if it is locked (if we are running 1169*433d6423SLionel Sambuc * a control method), in order to allow _REG methods to be run 1170*433d6423SLionel Sambuc * during AcpiEvInitializeRegion. 1171*433d6423SLionel Sambuc */ 1172*433d6423SLionel Sambuc if (WalkState->MethodNode) 1173*433d6423SLionel Sambuc { 1174*433d6423SLionel Sambuc /* 1175*433d6423SLionel Sambuc * Executing a method: initialize the region and unlock 1176*433d6423SLionel Sambuc * the interpreter 1177*433d6423SLionel Sambuc */ 1178*433d6423SLionel Sambuc Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length, 1179*433d6423SLionel Sambuc RegionSpace, WalkState); 1180*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 1181*433d6423SLionel Sambuc { 1182*433d6423SLionel Sambuc return (Status); 1183*433d6423SLionel Sambuc } 1184*433d6423SLionel Sambuc 1185*433d6423SLionel Sambuc AcpiExExitInterpreter (); 1186*433d6423SLionel Sambuc } 1187*433d6423SLionel Sambuc 1188*433d6423SLionel Sambuc Status = AcpiEvInitializeRegion (AcpiNsGetAttachedObject (Node), 1189*433d6423SLionel Sambuc FALSE); 1190*433d6423SLionel Sambuc if (WalkState->MethodNode) 1191*433d6423SLionel Sambuc { 1192*433d6423SLionel Sambuc AcpiExEnterInterpreter (); 1193*433d6423SLionel Sambuc } 1194*433d6423SLionel Sambuc 1195*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 1196*433d6423SLionel Sambuc { 1197*433d6423SLionel Sambuc /* 1198*433d6423SLionel Sambuc * If AE_NOT_EXIST is returned, it is not fatal 1199*433d6423SLionel Sambuc * because many regions get created before a handler 1200*433d6423SLionel Sambuc * is installed for said region. 1201*433d6423SLionel Sambuc */ 1202*433d6423SLionel Sambuc if (AE_NOT_EXIST == Status) 1203*433d6423SLionel Sambuc { 1204*433d6423SLionel Sambuc Status = AE_OK; 1205*433d6423SLionel Sambuc } 1206*433d6423SLionel Sambuc } 1207*433d6423SLionel Sambuc break; 1208*433d6423SLionel Sambuc 1209*433d6423SLionel Sambuc 1210*433d6423SLionel Sambuc case AML_NAME_OP: 1211*433d6423SLionel Sambuc 1212*433d6423SLionel Sambuc Status = AcpiDsCreateNode (WalkState, Node, Op); 1213*433d6423SLionel Sambuc break; 1214*433d6423SLionel Sambuc 1215*433d6423SLionel Sambuc 1216*433d6423SLionel Sambuc case AML_METHOD_OP: 1217*433d6423SLionel Sambuc /* 1218*433d6423SLionel Sambuc * MethodOp PkgLength NameString MethodFlags TermList 1219*433d6423SLionel Sambuc * 1220*433d6423SLionel Sambuc * Note: We must create the method node/object pair as soon as we 1221*433d6423SLionel Sambuc * see the method declaration. This allows later pass1 parsing 1222*433d6423SLionel Sambuc * of invocations of the method (need to know the number of 1223*433d6423SLionel Sambuc * arguments.) 1224*433d6423SLionel Sambuc */ 1225*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 1226*433d6423SLionel Sambuc "LOADING-Method: State=%p Op=%p NamedObj=%p\n", 1227*433d6423SLionel Sambuc WalkState, Op, Op->Named.Node)); 1228*433d6423SLionel Sambuc 1229*433d6423SLionel Sambuc if (!AcpiNsGetAttachedObject (Op->Named.Node)) 1230*433d6423SLionel Sambuc { 1231*433d6423SLionel Sambuc WalkState->Operands[0] = ACPI_CAST_PTR (void, Op->Named.Node); 1232*433d6423SLionel Sambuc WalkState->NumOperands = 1; 1233*433d6423SLionel Sambuc 1234*433d6423SLionel Sambuc Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg); 1235*433d6423SLionel Sambuc if (ACPI_SUCCESS (Status)) 1236*433d6423SLionel Sambuc { 1237*433d6423SLionel Sambuc Status = AcpiExCreateMethod (Op->Named.Data, 1238*433d6423SLionel Sambuc Op->Named.Length, WalkState); 1239*433d6423SLionel Sambuc } 1240*433d6423SLionel Sambuc WalkState->Operands[0] = NULL; 1241*433d6423SLionel Sambuc WalkState->NumOperands = 0; 1242*433d6423SLionel Sambuc 1243*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 1244*433d6423SLionel Sambuc { 1245*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 1246*433d6423SLionel Sambuc } 1247*433d6423SLionel Sambuc } 1248*433d6423SLionel Sambuc break; 1249*433d6423SLionel Sambuc 1250*433d6423SLionel Sambuc #endif /* ACPI_NO_METHOD_EXECUTION */ 1251*433d6423SLionel Sambuc 1252*433d6423SLionel Sambuc default: 1253*433d6423SLionel Sambuc /* All NAMED_COMPLEX opcodes must be handled above */ 1254*433d6423SLionel Sambuc break; 1255*433d6423SLionel Sambuc } 1256*433d6423SLionel Sambuc break; 1257*433d6423SLionel Sambuc 1258*433d6423SLionel Sambuc 1259*433d6423SLionel Sambuc case AML_CLASS_INTERNAL: 1260*433d6423SLionel Sambuc 1261*433d6423SLionel Sambuc /* case AML_INT_NAMEPATH_OP: */ 1262*433d6423SLionel Sambuc break; 1263*433d6423SLionel Sambuc 1264*433d6423SLionel Sambuc 1265*433d6423SLionel Sambuc case AML_CLASS_METHOD_CALL: 1266*433d6423SLionel Sambuc 1267*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 1268*433d6423SLionel Sambuc "RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n", 1269*433d6423SLionel Sambuc WalkState, Op, Node)); 1270*433d6423SLionel Sambuc 1271*433d6423SLionel Sambuc /* 1272*433d6423SLionel Sambuc * Lookup the method name and save the Node 1273*433d6423SLionel Sambuc */ 1274*433d6423SLionel Sambuc Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, 1275*433d6423SLionel Sambuc ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS2, 1276*433d6423SLionel Sambuc ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, 1277*433d6423SLionel Sambuc WalkState, &(NewNode)); 1278*433d6423SLionel Sambuc if (ACPI_SUCCESS (Status)) 1279*433d6423SLionel Sambuc { 1280*433d6423SLionel Sambuc /* 1281*433d6423SLionel Sambuc * Make sure that what we found is indeed a method 1282*433d6423SLionel Sambuc * We didn't search for a method on purpose, to see if the name 1283*433d6423SLionel Sambuc * would resolve 1284*433d6423SLionel Sambuc */ 1285*433d6423SLionel Sambuc if (NewNode->Type != ACPI_TYPE_METHOD) 1286*433d6423SLionel Sambuc { 1287*433d6423SLionel Sambuc Status = AE_AML_OPERAND_TYPE; 1288*433d6423SLionel Sambuc } 1289*433d6423SLionel Sambuc 1290*433d6423SLionel Sambuc /* We could put the returned object (Node) on the object stack for 1291*433d6423SLionel Sambuc * later, but for now, we will put it in the "op" object that the 1292*433d6423SLionel Sambuc * parser uses, so we can get it again at the end of this scope 1293*433d6423SLionel Sambuc */ 1294*433d6423SLionel Sambuc Op->Common.Node = NewNode; 1295*433d6423SLionel Sambuc } 1296*433d6423SLionel Sambuc else 1297*433d6423SLionel Sambuc { 1298*433d6423SLionel Sambuc ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); 1299*433d6423SLionel Sambuc } 1300*433d6423SLionel Sambuc break; 1301*433d6423SLionel Sambuc 1302*433d6423SLionel Sambuc 1303*433d6423SLionel Sambuc default: 1304*433d6423SLionel Sambuc break; 1305*433d6423SLionel Sambuc } 1306*433d6423SLionel Sambuc 1307*433d6423SLionel Sambuc Cleanup: 1308*433d6423SLionel Sambuc 1309*433d6423SLionel Sambuc /* Remove the Node pushed at the very beginning */ 1310*433d6423SLionel Sambuc 1311*433d6423SLionel Sambuc WalkState->Operands[0] = NULL; 1312*433d6423SLionel Sambuc WalkState->NumOperands = 0; 1313*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 1314*433d6423SLionel Sambuc } 1315*433d6423SLionel Sambuc 1316*433d6423SLionel Sambuc 1317