1*433d6423SLionel Sambuc /******************************************************************************* 2*433d6423SLionel Sambuc * 3*433d6423SLionel Sambuc * Module Name: nsaccess - Top-level functions for accessing ACPI namespace 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 __NSACCESS_C__ 117*433d6423SLionel Sambuc 118*433d6423SLionel Sambuc #include "acpi.h" 119*433d6423SLionel Sambuc #include "accommon.h" 120*433d6423SLionel Sambuc #include "amlcode.h" 121*433d6423SLionel Sambuc #include "acnamesp.h" 122*433d6423SLionel Sambuc #include "acdispat.h" 123*433d6423SLionel Sambuc 124*433d6423SLionel Sambuc 125*433d6423SLionel Sambuc #define _COMPONENT ACPI_NAMESPACE 126*433d6423SLionel Sambuc ACPI_MODULE_NAME ("nsaccess") 127*433d6423SLionel Sambuc 128*433d6423SLionel Sambuc 129*433d6423SLionel Sambuc /******************************************************************************* 130*433d6423SLionel Sambuc * 131*433d6423SLionel Sambuc * FUNCTION: AcpiNsRootInitialize 132*433d6423SLionel Sambuc * 133*433d6423SLionel Sambuc * PARAMETERS: None 134*433d6423SLionel Sambuc * 135*433d6423SLionel Sambuc * RETURN: Status 136*433d6423SLionel Sambuc * 137*433d6423SLionel Sambuc * DESCRIPTION: Allocate and initialize the default root named objects 138*433d6423SLionel Sambuc * 139*433d6423SLionel Sambuc * MUTEX: Locks namespace for entire execution 140*433d6423SLionel Sambuc * 141*433d6423SLionel Sambuc ******************************************************************************/ 142*433d6423SLionel Sambuc 143*433d6423SLionel Sambuc ACPI_STATUS 144*433d6423SLionel Sambuc AcpiNsRootInitialize ( 145*433d6423SLionel Sambuc void) 146*433d6423SLionel Sambuc { 147*433d6423SLionel Sambuc ACPI_STATUS Status; 148*433d6423SLionel Sambuc const ACPI_PREDEFINED_NAMES *InitVal = NULL; 149*433d6423SLionel Sambuc ACPI_NAMESPACE_NODE *NewNode; 150*433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *ObjDesc; 151*433d6423SLionel Sambuc ACPI_STRING Val = NULL; 152*433d6423SLionel Sambuc 153*433d6423SLionel Sambuc 154*433d6423SLionel Sambuc ACPI_FUNCTION_TRACE (NsRootInitialize); 155*433d6423SLionel Sambuc 156*433d6423SLionel Sambuc 157*433d6423SLionel Sambuc Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 158*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 159*433d6423SLionel Sambuc { 160*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 161*433d6423SLionel Sambuc } 162*433d6423SLionel Sambuc 163*433d6423SLionel Sambuc /* 164*433d6423SLionel Sambuc * The global root ptr is initially NULL, so a non-NULL value indicates 165*433d6423SLionel Sambuc * that AcpiNsRootInitialize() has already been called; just return. 166*433d6423SLionel Sambuc */ 167*433d6423SLionel Sambuc if (AcpiGbl_RootNode) 168*433d6423SLionel Sambuc { 169*433d6423SLionel Sambuc Status = AE_OK; 170*433d6423SLionel Sambuc goto UnlockAndExit; 171*433d6423SLionel Sambuc } 172*433d6423SLionel Sambuc 173*433d6423SLionel Sambuc /* 174*433d6423SLionel Sambuc * Tell the rest of the subsystem that the root is initialized 175*433d6423SLionel Sambuc * (This is OK because the namespace is locked) 176*433d6423SLionel Sambuc */ 177*433d6423SLionel Sambuc AcpiGbl_RootNode = &AcpiGbl_RootNodeStruct; 178*433d6423SLionel Sambuc 179*433d6423SLionel Sambuc /* Enter the pre-defined names in the name table */ 180*433d6423SLionel Sambuc 181*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 182*433d6423SLionel Sambuc "Entering predefined entries into namespace\n")); 183*433d6423SLionel Sambuc 184*433d6423SLionel Sambuc for (InitVal = AcpiGbl_PreDefinedNames; InitVal->Name; InitVal++) 185*433d6423SLionel Sambuc { 186*433d6423SLionel Sambuc /* _OSI is optional for now, will be permanent later */ 187*433d6423SLionel Sambuc 188*433d6423SLionel Sambuc if (!ACPI_STRCMP (InitVal->Name, "_OSI") && !AcpiGbl_CreateOsiMethod) 189*433d6423SLionel Sambuc { 190*433d6423SLionel Sambuc continue; 191*433d6423SLionel Sambuc } 192*433d6423SLionel Sambuc 193*433d6423SLionel Sambuc Status = AcpiNsLookup (NULL, InitVal->Name, InitVal->Type, 194*433d6423SLionel Sambuc ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, 195*433d6423SLionel Sambuc NULL, &NewNode); 196*433d6423SLionel Sambuc 197*433d6423SLionel Sambuc if (ACPI_FAILURE (Status) || (!NewNode)) /* Must be on same line for code converter */ 198*433d6423SLionel Sambuc { 199*433d6423SLionel Sambuc ACPI_EXCEPTION ((AE_INFO, Status, 200*433d6423SLionel Sambuc "Could not create predefined name %s", 201*433d6423SLionel Sambuc InitVal->Name)); 202*433d6423SLionel Sambuc } 203*433d6423SLionel Sambuc 204*433d6423SLionel Sambuc /* 205*433d6423SLionel Sambuc * Name entered successfully. If entry in PreDefinedNames[] specifies 206*433d6423SLionel Sambuc * an initial value, create the initial value. 207*433d6423SLionel Sambuc */ 208*433d6423SLionel Sambuc if (InitVal->Val) 209*433d6423SLionel Sambuc { 210*433d6423SLionel Sambuc Status = AcpiOsPredefinedOverride (InitVal, &Val); 211*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 212*433d6423SLionel Sambuc { 213*433d6423SLionel Sambuc ACPI_ERROR ((AE_INFO, 214*433d6423SLionel Sambuc "Could not override predefined %s", 215*433d6423SLionel Sambuc InitVal->Name)); 216*433d6423SLionel Sambuc } 217*433d6423SLionel Sambuc 218*433d6423SLionel Sambuc if (!Val) 219*433d6423SLionel Sambuc { 220*433d6423SLionel Sambuc Val = InitVal->Val; 221*433d6423SLionel Sambuc } 222*433d6423SLionel Sambuc 223*433d6423SLionel Sambuc /* 224*433d6423SLionel Sambuc * Entry requests an initial value, allocate a 225*433d6423SLionel Sambuc * descriptor for it. 226*433d6423SLionel Sambuc */ 227*433d6423SLionel Sambuc ObjDesc = AcpiUtCreateInternalObject (InitVal->Type); 228*433d6423SLionel Sambuc if (!ObjDesc) 229*433d6423SLionel Sambuc { 230*433d6423SLionel Sambuc Status = AE_NO_MEMORY; 231*433d6423SLionel Sambuc goto UnlockAndExit; 232*433d6423SLionel Sambuc } 233*433d6423SLionel Sambuc 234*433d6423SLionel Sambuc /* 235*433d6423SLionel Sambuc * Convert value string from table entry to 236*433d6423SLionel Sambuc * internal representation. Only types actually 237*433d6423SLionel Sambuc * used for initial values are implemented here. 238*433d6423SLionel Sambuc */ 239*433d6423SLionel Sambuc switch (InitVal->Type) 240*433d6423SLionel Sambuc { 241*433d6423SLionel Sambuc case ACPI_TYPE_METHOD: 242*433d6423SLionel Sambuc ObjDesc->Method.ParamCount = (UINT8) ACPI_TO_INTEGER (Val); 243*433d6423SLionel Sambuc ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID; 244*433d6423SLionel Sambuc 245*433d6423SLionel Sambuc #if defined (ACPI_ASL_COMPILER) 246*433d6423SLionel Sambuc 247*433d6423SLionel Sambuc /* Save the parameter count for the iASL compiler */ 248*433d6423SLionel Sambuc 249*433d6423SLionel Sambuc NewNode->Value = ObjDesc->Method.ParamCount; 250*433d6423SLionel Sambuc #else 251*433d6423SLionel Sambuc /* Mark this as a very SPECIAL method */ 252*433d6423SLionel Sambuc 253*433d6423SLionel Sambuc ObjDesc->Method.MethodFlags = AML_METHOD_INTERNAL_ONLY; 254*433d6423SLionel Sambuc ObjDesc->Method.Extra.Implementation = AcpiUtOsiImplementation; 255*433d6423SLionel Sambuc #endif 256*433d6423SLionel Sambuc break; 257*433d6423SLionel Sambuc 258*433d6423SLionel Sambuc case ACPI_TYPE_INTEGER: 259*433d6423SLionel Sambuc 260*433d6423SLionel Sambuc ObjDesc->Integer.Value = ACPI_TO_INTEGER (Val); 261*433d6423SLionel Sambuc break; 262*433d6423SLionel Sambuc 263*433d6423SLionel Sambuc 264*433d6423SLionel Sambuc case ACPI_TYPE_STRING: 265*433d6423SLionel Sambuc 266*433d6423SLionel Sambuc /* Build an object around the static string */ 267*433d6423SLionel Sambuc 268*433d6423SLionel Sambuc ObjDesc->String.Length = (UINT32) ACPI_STRLEN (Val); 269*433d6423SLionel Sambuc ObjDesc->String.Pointer = Val; 270*433d6423SLionel Sambuc ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER; 271*433d6423SLionel Sambuc break; 272*433d6423SLionel Sambuc 273*433d6423SLionel Sambuc 274*433d6423SLionel Sambuc case ACPI_TYPE_MUTEX: 275*433d6423SLionel Sambuc 276*433d6423SLionel Sambuc ObjDesc->Mutex.Node = NewNode; 277*433d6423SLionel Sambuc ObjDesc->Mutex.SyncLevel = (UINT8) (ACPI_TO_INTEGER (Val) - 1); 278*433d6423SLionel Sambuc 279*433d6423SLionel Sambuc /* Create a mutex */ 280*433d6423SLionel Sambuc 281*433d6423SLionel Sambuc Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex); 282*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 283*433d6423SLionel Sambuc { 284*433d6423SLionel Sambuc AcpiUtRemoveReference (ObjDesc); 285*433d6423SLionel Sambuc goto UnlockAndExit; 286*433d6423SLionel Sambuc } 287*433d6423SLionel Sambuc 288*433d6423SLionel Sambuc /* Special case for ACPI Global Lock */ 289*433d6423SLionel Sambuc 290*433d6423SLionel Sambuc if (ACPI_STRCMP (InitVal->Name, "_GL_") == 0) 291*433d6423SLionel Sambuc { 292*433d6423SLionel Sambuc AcpiGbl_GlobalLockMutex = ObjDesc; 293*433d6423SLionel Sambuc 294*433d6423SLionel Sambuc /* Create additional counting semaphore for global lock */ 295*433d6423SLionel Sambuc 296*433d6423SLionel Sambuc Status = AcpiOsCreateSemaphore ( 297*433d6423SLionel Sambuc 1, 0, &AcpiGbl_GlobalLockSemaphore); 298*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 299*433d6423SLionel Sambuc { 300*433d6423SLionel Sambuc AcpiUtRemoveReference (ObjDesc); 301*433d6423SLionel Sambuc goto UnlockAndExit; 302*433d6423SLionel Sambuc } 303*433d6423SLionel Sambuc } 304*433d6423SLionel Sambuc break; 305*433d6423SLionel Sambuc 306*433d6423SLionel Sambuc 307*433d6423SLionel Sambuc default: 308*433d6423SLionel Sambuc 309*433d6423SLionel Sambuc ACPI_ERROR ((AE_INFO, "Unsupported initial type value 0x%X", 310*433d6423SLionel Sambuc InitVal->Type)); 311*433d6423SLionel Sambuc AcpiUtRemoveReference (ObjDesc); 312*433d6423SLionel Sambuc ObjDesc = NULL; 313*433d6423SLionel Sambuc continue; 314*433d6423SLionel Sambuc } 315*433d6423SLionel Sambuc 316*433d6423SLionel Sambuc /* Store pointer to value descriptor in the Node */ 317*433d6423SLionel Sambuc 318*433d6423SLionel Sambuc Status = AcpiNsAttachObject (NewNode, ObjDesc, 319*433d6423SLionel Sambuc ObjDesc->Common.Type); 320*433d6423SLionel Sambuc 321*433d6423SLionel Sambuc /* Remove local reference to the object */ 322*433d6423SLionel Sambuc 323*433d6423SLionel Sambuc AcpiUtRemoveReference (ObjDesc); 324*433d6423SLionel Sambuc } 325*433d6423SLionel Sambuc } 326*433d6423SLionel Sambuc 327*433d6423SLionel Sambuc 328*433d6423SLionel Sambuc UnlockAndExit: 329*433d6423SLionel Sambuc (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 330*433d6423SLionel Sambuc 331*433d6423SLionel Sambuc /* Save a handle to "_GPE", it is always present */ 332*433d6423SLionel Sambuc 333*433d6423SLionel Sambuc if (ACPI_SUCCESS (Status)) 334*433d6423SLionel Sambuc { 335*433d6423SLionel Sambuc Status = AcpiNsGetNode (NULL, "\\_GPE", ACPI_NS_NO_UPSEARCH, 336*433d6423SLionel Sambuc &AcpiGbl_FadtGpeDevice); 337*433d6423SLionel Sambuc } 338*433d6423SLionel Sambuc 339*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 340*433d6423SLionel Sambuc } 341*433d6423SLionel Sambuc 342*433d6423SLionel Sambuc 343*433d6423SLionel Sambuc /******************************************************************************* 344*433d6423SLionel Sambuc * 345*433d6423SLionel Sambuc * FUNCTION: AcpiNsLookup 346*433d6423SLionel Sambuc * 347*433d6423SLionel Sambuc * PARAMETERS: ScopeInfo - Current scope info block 348*433d6423SLionel Sambuc * Pathname - Search pathname, in internal format 349*433d6423SLionel Sambuc * (as represented in the AML stream) 350*433d6423SLionel Sambuc * Type - Type associated with name 351*433d6423SLionel Sambuc * InterpreterMode - IMODE_LOAD_PASS2 => add name if not found 352*433d6423SLionel Sambuc * Flags - Flags describing the search restrictions 353*433d6423SLionel Sambuc * WalkState - Current state of the walk 354*433d6423SLionel Sambuc * ReturnNode - Where the Node is placed (if found 355*433d6423SLionel Sambuc * or created successfully) 356*433d6423SLionel Sambuc * 357*433d6423SLionel Sambuc * RETURN: Status 358*433d6423SLionel Sambuc * 359*433d6423SLionel Sambuc * DESCRIPTION: Find or enter the passed name in the name space. 360*433d6423SLionel Sambuc * Log an error if name not found in Exec mode. 361*433d6423SLionel Sambuc * 362*433d6423SLionel Sambuc * MUTEX: Assumes namespace is locked. 363*433d6423SLionel Sambuc * 364*433d6423SLionel Sambuc ******************************************************************************/ 365*433d6423SLionel Sambuc 366*433d6423SLionel Sambuc ACPI_STATUS 367*433d6423SLionel Sambuc AcpiNsLookup ( 368*433d6423SLionel Sambuc ACPI_GENERIC_STATE *ScopeInfo, 369*433d6423SLionel Sambuc char *Pathname, 370*433d6423SLionel Sambuc ACPI_OBJECT_TYPE Type, 371*433d6423SLionel Sambuc ACPI_INTERPRETER_MODE InterpreterMode, 372*433d6423SLionel Sambuc UINT32 Flags, 373*433d6423SLionel Sambuc ACPI_WALK_STATE *WalkState, 374*433d6423SLionel Sambuc ACPI_NAMESPACE_NODE **ReturnNode) 375*433d6423SLionel Sambuc { 376*433d6423SLionel Sambuc ACPI_STATUS Status; 377*433d6423SLionel Sambuc char *Path = Pathname; 378*433d6423SLionel Sambuc ACPI_NAMESPACE_NODE *PrefixNode; 379*433d6423SLionel Sambuc ACPI_NAMESPACE_NODE *CurrentNode = NULL; 380*433d6423SLionel Sambuc ACPI_NAMESPACE_NODE *ThisNode = NULL; 381*433d6423SLionel Sambuc UINT32 NumSegments; 382*433d6423SLionel Sambuc UINT32 NumCarats; 383*433d6423SLionel Sambuc ACPI_NAME SimpleName; 384*433d6423SLionel Sambuc ACPI_OBJECT_TYPE TypeToCheckFor; 385*433d6423SLionel Sambuc ACPI_OBJECT_TYPE ThisSearchType; 386*433d6423SLionel Sambuc UINT32 SearchParentFlag = ACPI_NS_SEARCH_PARENT; 387*433d6423SLionel Sambuc UINT32 LocalFlags; 388*433d6423SLionel Sambuc 389*433d6423SLionel Sambuc 390*433d6423SLionel Sambuc ACPI_FUNCTION_TRACE (NsLookup); 391*433d6423SLionel Sambuc 392*433d6423SLionel Sambuc 393*433d6423SLionel Sambuc if (!ReturnNode) 394*433d6423SLionel Sambuc { 395*433d6423SLionel Sambuc return_ACPI_STATUS (AE_BAD_PARAMETER); 396*433d6423SLionel Sambuc } 397*433d6423SLionel Sambuc 398*433d6423SLionel Sambuc LocalFlags = Flags & ~(ACPI_NS_ERROR_IF_FOUND | ACPI_NS_SEARCH_PARENT); 399*433d6423SLionel Sambuc *ReturnNode = ACPI_ENTRY_NOT_FOUND; 400*433d6423SLionel Sambuc AcpiGbl_NsLookupCount++; 401*433d6423SLionel Sambuc 402*433d6423SLionel Sambuc if (!AcpiGbl_RootNode) 403*433d6423SLionel Sambuc { 404*433d6423SLionel Sambuc return_ACPI_STATUS (AE_NO_NAMESPACE); 405*433d6423SLionel Sambuc } 406*433d6423SLionel Sambuc 407*433d6423SLionel Sambuc /* Get the prefix scope. A null scope means use the root scope */ 408*433d6423SLionel Sambuc 409*433d6423SLionel Sambuc if ((!ScopeInfo) || 410*433d6423SLionel Sambuc (!ScopeInfo->Scope.Node)) 411*433d6423SLionel Sambuc { 412*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 413*433d6423SLionel Sambuc "Null scope prefix, using root node (%p)\n", 414*433d6423SLionel Sambuc AcpiGbl_RootNode)); 415*433d6423SLionel Sambuc 416*433d6423SLionel Sambuc PrefixNode = AcpiGbl_RootNode; 417*433d6423SLionel Sambuc } 418*433d6423SLionel Sambuc else 419*433d6423SLionel Sambuc { 420*433d6423SLionel Sambuc PrefixNode = ScopeInfo->Scope.Node; 421*433d6423SLionel Sambuc if (ACPI_GET_DESCRIPTOR_TYPE (PrefixNode) != ACPI_DESC_TYPE_NAMED) 422*433d6423SLionel Sambuc { 423*433d6423SLionel Sambuc ACPI_ERROR ((AE_INFO, "%p is not a namespace node [%s]", 424*433d6423SLionel Sambuc PrefixNode, AcpiUtGetDescriptorName (PrefixNode))); 425*433d6423SLionel Sambuc return_ACPI_STATUS (AE_AML_INTERNAL); 426*433d6423SLionel Sambuc } 427*433d6423SLionel Sambuc 428*433d6423SLionel Sambuc if (!(Flags & ACPI_NS_PREFIX_IS_SCOPE)) 429*433d6423SLionel Sambuc { 430*433d6423SLionel Sambuc /* 431*433d6423SLionel Sambuc * This node might not be a actual "scope" node (such as a 432*433d6423SLionel Sambuc * Device/Method, etc.) It could be a Package or other object 433*433d6423SLionel Sambuc * node. Backup up the tree to find the containing scope node. 434*433d6423SLionel Sambuc */ 435*433d6423SLionel Sambuc while (!AcpiNsOpensScope (PrefixNode->Type) && 436*433d6423SLionel Sambuc PrefixNode->Type != ACPI_TYPE_ANY) 437*433d6423SLionel Sambuc { 438*433d6423SLionel Sambuc PrefixNode = PrefixNode->Parent; 439*433d6423SLionel Sambuc } 440*433d6423SLionel Sambuc } 441*433d6423SLionel Sambuc } 442*433d6423SLionel Sambuc 443*433d6423SLionel Sambuc /* Save type. TBD: may be no longer necessary */ 444*433d6423SLionel Sambuc 445*433d6423SLionel Sambuc TypeToCheckFor = Type; 446*433d6423SLionel Sambuc 447*433d6423SLionel Sambuc /* 448*433d6423SLionel Sambuc * Begin examination of the actual pathname 449*433d6423SLionel Sambuc */ 450*433d6423SLionel Sambuc if (!Pathname) 451*433d6423SLionel Sambuc { 452*433d6423SLionel Sambuc /* A Null NamePath is allowed and refers to the root */ 453*433d6423SLionel Sambuc 454*433d6423SLionel Sambuc NumSegments = 0; 455*433d6423SLionel Sambuc ThisNode = AcpiGbl_RootNode; 456*433d6423SLionel Sambuc Path = ""; 457*433d6423SLionel Sambuc 458*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 459*433d6423SLionel Sambuc "Null Pathname (Zero segments), Flags=%X\n", Flags)); 460*433d6423SLionel Sambuc } 461*433d6423SLionel Sambuc else 462*433d6423SLionel Sambuc { 463*433d6423SLionel Sambuc /* 464*433d6423SLionel Sambuc * Name pointer is valid (and must be in internal name format) 465*433d6423SLionel Sambuc * 466*433d6423SLionel Sambuc * Check for scope prefixes: 467*433d6423SLionel Sambuc * 468*433d6423SLionel Sambuc * As represented in the AML stream, a namepath consists of an 469*433d6423SLionel Sambuc * optional scope prefix followed by a name segment part. 470*433d6423SLionel Sambuc * 471*433d6423SLionel Sambuc * If present, the scope prefix is either a Root Prefix (in 472*433d6423SLionel Sambuc * which case the name is fully qualified), or one or more 473*433d6423SLionel Sambuc * Parent Prefixes (in which case the name's scope is relative 474*433d6423SLionel Sambuc * to the current scope). 475*433d6423SLionel Sambuc */ 476*433d6423SLionel Sambuc if (*Path == (UINT8) AML_ROOT_PREFIX) 477*433d6423SLionel Sambuc { 478*433d6423SLionel Sambuc /* Pathname is fully qualified, start from the root */ 479*433d6423SLionel Sambuc 480*433d6423SLionel Sambuc ThisNode = AcpiGbl_RootNode; 481*433d6423SLionel Sambuc SearchParentFlag = ACPI_NS_NO_UPSEARCH; 482*433d6423SLionel Sambuc 483*433d6423SLionel Sambuc /* Point to name segment part */ 484*433d6423SLionel Sambuc 485*433d6423SLionel Sambuc Path++; 486*433d6423SLionel Sambuc 487*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 488*433d6423SLionel Sambuc "Path is absolute from root [%p]\n", ThisNode)); 489*433d6423SLionel Sambuc } 490*433d6423SLionel Sambuc else 491*433d6423SLionel Sambuc { 492*433d6423SLionel Sambuc /* Pathname is relative to current scope, start there */ 493*433d6423SLionel Sambuc 494*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 495*433d6423SLionel Sambuc "Searching relative to prefix scope [%4.4s] (%p)\n", 496*433d6423SLionel Sambuc AcpiUtGetNodeName (PrefixNode), PrefixNode)); 497*433d6423SLionel Sambuc 498*433d6423SLionel Sambuc /* 499*433d6423SLionel Sambuc * Handle multiple Parent Prefixes (carat) by just getting 500*433d6423SLionel Sambuc * the parent node for each prefix instance. 501*433d6423SLionel Sambuc */ 502*433d6423SLionel Sambuc ThisNode = PrefixNode; 503*433d6423SLionel Sambuc NumCarats = 0; 504*433d6423SLionel Sambuc while (*Path == (UINT8) AML_PARENT_PREFIX) 505*433d6423SLionel Sambuc { 506*433d6423SLionel Sambuc /* Name is fully qualified, no search rules apply */ 507*433d6423SLionel Sambuc 508*433d6423SLionel Sambuc SearchParentFlag = ACPI_NS_NO_UPSEARCH; 509*433d6423SLionel Sambuc 510*433d6423SLionel Sambuc /* 511*433d6423SLionel Sambuc * Point past this prefix to the name segment 512*433d6423SLionel Sambuc * part or the next Parent Prefix 513*433d6423SLionel Sambuc */ 514*433d6423SLionel Sambuc Path++; 515*433d6423SLionel Sambuc 516*433d6423SLionel Sambuc /* Backup to the parent node */ 517*433d6423SLionel Sambuc 518*433d6423SLionel Sambuc NumCarats++; 519*433d6423SLionel Sambuc ThisNode = ThisNode->Parent; 520*433d6423SLionel Sambuc if (!ThisNode) 521*433d6423SLionel Sambuc { 522*433d6423SLionel Sambuc /* Current scope has no parent scope */ 523*433d6423SLionel Sambuc 524*433d6423SLionel Sambuc ACPI_ERROR ((AE_INFO, 525*433d6423SLionel Sambuc "ACPI path has too many parent prefixes (^) " 526*433d6423SLionel Sambuc "- reached beyond root node")); 527*433d6423SLionel Sambuc return_ACPI_STATUS (AE_NOT_FOUND); 528*433d6423SLionel Sambuc } 529*433d6423SLionel Sambuc } 530*433d6423SLionel Sambuc 531*433d6423SLionel Sambuc if (SearchParentFlag == ACPI_NS_NO_UPSEARCH) 532*433d6423SLionel Sambuc { 533*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 534*433d6423SLionel Sambuc "Search scope is [%4.4s], path has %u carat(s)\n", 535*433d6423SLionel Sambuc AcpiUtGetNodeName (ThisNode), NumCarats)); 536*433d6423SLionel Sambuc } 537*433d6423SLionel Sambuc } 538*433d6423SLionel Sambuc 539*433d6423SLionel Sambuc /* 540*433d6423SLionel Sambuc * Determine the number of ACPI name segments in this pathname. 541*433d6423SLionel Sambuc * 542*433d6423SLionel Sambuc * The segment part consists of either: 543*433d6423SLionel Sambuc * - A Null name segment (0) 544*433d6423SLionel Sambuc * - A DualNamePrefix followed by two 4-byte name segments 545*433d6423SLionel Sambuc * - A MultiNamePrefix followed by a byte indicating the 546*433d6423SLionel Sambuc * number of segments and the segments themselves. 547*433d6423SLionel Sambuc * - A single 4-byte name segment 548*433d6423SLionel Sambuc * 549*433d6423SLionel Sambuc * Examine the name prefix opcode, if any, to determine the number of 550*433d6423SLionel Sambuc * segments. 551*433d6423SLionel Sambuc */ 552*433d6423SLionel Sambuc switch (*Path) 553*433d6423SLionel Sambuc { 554*433d6423SLionel Sambuc case 0: 555*433d6423SLionel Sambuc /* 556*433d6423SLionel Sambuc * Null name after a root or parent prefixes. We already 557*433d6423SLionel Sambuc * have the correct target node and there are no name segments. 558*433d6423SLionel Sambuc */ 559*433d6423SLionel Sambuc NumSegments = 0; 560*433d6423SLionel Sambuc Type = ThisNode->Type; 561*433d6423SLionel Sambuc 562*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 563*433d6423SLionel Sambuc "Prefix-only Pathname (Zero name segments), Flags=%X\n", 564*433d6423SLionel Sambuc Flags)); 565*433d6423SLionel Sambuc break; 566*433d6423SLionel Sambuc 567*433d6423SLionel Sambuc case AML_DUAL_NAME_PREFIX: 568*433d6423SLionel Sambuc 569*433d6423SLionel Sambuc /* More than one NameSeg, search rules do not apply */ 570*433d6423SLionel Sambuc 571*433d6423SLionel Sambuc SearchParentFlag = ACPI_NS_NO_UPSEARCH; 572*433d6423SLionel Sambuc 573*433d6423SLionel Sambuc /* Two segments, point to first name segment */ 574*433d6423SLionel Sambuc 575*433d6423SLionel Sambuc NumSegments = 2; 576*433d6423SLionel Sambuc Path++; 577*433d6423SLionel Sambuc 578*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 579*433d6423SLionel Sambuc "Dual Pathname (2 segments, Flags=%X)\n", Flags)); 580*433d6423SLionel Sambuc break; 581*433d6423SLionel Sambuc 582*433d6423SLionel Sambuc case AML_MULTI_NAME_PREFIX_OP: 583*433d6423SLionel Sambuc 584*433d6423SLionel Sambuc /* More than one NameSeg, search rules do not apply */ 585*433d6423SLionel Sambuc 586*433d6423SLionel Sambuc SearchParentFlag = ACPI_NS_NO_UPSEARCH; 587*433d6423SLionel Sambuc 588*433d6423SLionel Sambuc /* Extract segment count, point to first name segment */ 589*433d6423SLionel Sambuc 590*433d6423SLionel Sambuc Path++; 591*433d6423SLionel Sambuc NumSegments = (UINT32) (UINT8) *Path; 592*433d6423SLionel Sambuc Path++; 593*433d6423SLionel Sambuc 594*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 595*433d6423SLionel Sambuc "Multi Pathname (%u Segments, Flags=%X)\n", 596*433d6423SLionel Sambuc NumSegments, Flags)); 597*433d6423SLionel Sambuc break; 598*433d6423SLionel Sambuc 599*433d6423SLionel Sambuc default: 600*433d6423SLionel Sambuc /* 601*433d6423SLionel Sambuc * Not a Null name, no Dual or Multi prefix, hence there is 602*433d6423SLionel Sambuc * only one name segment and Pathname is already pointing to it. 603*433d6423SLionel Sambuc */ 604*433d6423SLionel Sambuc NumSegments = 1; 605*433d6423SLionel Sambuc 606*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 607*433d6423SLionel Sambuc "Simple Pathname (1 segment, Flags=%X)\n", Flags)); 608*433d6423SLionel Sambuc break; 609*433d6423SLionel Sambuc } 610*433d6423SLionel Sambuc 611*433d6423SLionel Sambuc ACPI_DEBUG_EXEC (AcpiNsPrintPathname (NumSegments, Path)); 612*433d6423SLionel Sambuc } 613*433d6423SLionel Sambuc 614*433d6423SLionel Sambuc 615*433d6423SLionel Sambuc /* 616*433d6423SLionel Sambuc * Search namespace for each segment of the name. Loop through and 617*433d6423SLionel Sambuc * verify (or add to the namespace) each name segment. 618*433d6423SLionel Sambuc * 619*433d6423SLionel Sambuc * The object type is significant only at the last name 620*433d6423SLionel Sambuc * segment. (We don't care about the types along the path, only 621*433d6423SLionel Sambuc * the type of the final target object.) 622*433d6423SLionel Sambuc */ 623*433d6423SLionel Sambuc ThisSearchType = ACPI_TYPE_ANY; 624*433d6423SLionel Sambuc CurrentNode = ThisNode; 625*433d6423SLionel Sambuc while (NumSegments && CurrentNode) 626*433d6423SLionel Sambuc { 627*433d6423SLionel Sambuc NumSegments--; 628*433d6423SLionel Sambuc if (!NumSegments) 629*433d6423SLionel Sambuc { 630*433d6423SLionel Sambuc /* This is the last segment, enable typechecking */ 631*433d6423SLionel Sambuc 632*433d6423SLionel Sambuc ThisSearchType = Type; 633*433d6423SLionel Sambuc 634*433d6423SLionel Sambuc /* 635*433d6423SLionel Sambuc * Only allow automatic parent search (search rules) if the caller 636*433d6423SLionel Sambuc * requested it AND we have a single, non-fully-qualified NameSeg 637*433d6423SLionel Sambuc */ 638*433d6423SLionel Sambuc if ((SearchParentFlag != ACPI_NS_NO_UPSEARCH) && 639*433d6423SLionel Sambuc (Flags & ACPI_NS_SEARCH_PARENT)) 640*433d6423SLionel Sambuc { 641*433d6423SLionel Sambuc LocalFlags |= ACPI_NS_SEARCH_PARENT; 642*433d6423SLionel Sambuc } 643*433d6423SLionel Sambuc 644*433d6423SLionel Sambuc /* Set error flag according to caller */ 645*433d6423SLionel Sambuc 646*433d6423SLionel Sambuc if (Flags & ACPI_NS_ERROR_IF_FOUND) 647*433d6423SLionel Sambuc { 648*433d6423SLionel Sambuc LocalFlags |= ACPI_NS_ERROR_IF_FOUND; 649*433d6423SLionel Sambuc } 650*433d6423SLionel Sambuc } 651*433d6423SLionel Sambuc 652*433d6423SLionel Sambuc /* Extract one ACPI name from the front of the pathname */ 653*433d6423SLionel Sambuc 654*433d6423SLionel Sambuc ACPI_MOVE_32_TO_32 (&SimpleName, Path); 655*433d6423SLionel Sambuc 656*433d6423SLionel Sambuc /* Try to find the single (4 character) ACPI name */ 657*433d6423SLionel Sambuc 658*433d6423SLionel Sambuc Status = AcpiNsSearchAndEnter (SimpleName, WalkState, CurrentNode, 659*433d6423SLionel Sambuc InterpreterMode, ThisSearchType, LocalFlags, &ThisNode); 660*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 661*433d6423SLionel Sambuc { 662*433d6423SLionel Sambuc if (Status == AE_NOT_FOUND) 663*433d6423SLionel Sambuc { 664*433d6423SLionel Sambuc /* Name not found in ACPI namespace */ 665*433d6423SLionel Sambuc 666*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 667*433d6423SLionel Sambuc "Name [%4.4s] not found in scope [%4.4s] %p\n", 668*433d6423SLionel Sambuc (char *) &SimpleName, (char *) &CurrentNode->Name, 669*433d6423SLionel Sambuc CurrentNode)); 670*433d6423SLionel Sambuc } 671*433d6423SLionel Sambuc 672*433d6423SLionel Sambuc *ReturnNode = ThisNode; 673*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 674*433d6423SLionel Sambuc } 675*433d6423SLionel Sambuc 676*433d6423SLionel Sambuc /* More segments to follow? */ 677*433d6423SLionel Sambuc 678*433d6423SLionel Sambuc if (NumSegments > 0) 679*433d6423SLionel Sambuc { 680*433d6423SLionel Sambuc /* 681*433d6423SLionel Sambuc * If we have an alias to an object that opens a scope (such as a 682*433d6423SLionel Sambuc * device or processor), we need to dereference the alias here so 683*433d6423SLionel Sambuc * that we can access any children of the original node (via the 684*433d6423SLionel Sambuc * remaining segments). 685*433d6423SLionel Sambuc */ 686*433d6423SLionel Sambuc if (ThisNode->Type == ACPI_TYPE_LOCAL_ALIAS) 687*433d6423SLionel Sambuc { 688*433d6423SLionel Sambuc if (!ThisNode->Object) 689*433d6423SLionel Sambuc { 690*433d6423SLionel Sambuc return_ACPI_STATUS (AE_NOT_EXIST); 691*433d6423SLionel Sambuc } 692*433d6423SLionel Sambuc 693*433d6423SLionel Sambuc if (AcpiNsOpensScope (((ACPI_NAMESPACE_NODE *) 694*433d6423SLionel Sambuc ThisNode->Object)->Type)) 695*433d6423SLionel Sambuc { 696*433d6423SLionel Sambuc ThisNode = (ACPI_NAMESPACE_NODE *) ThisNode->Object; 697*433d6423SLionel Sambuc } 698*433d6423SLionel Sambuc } 699*433d6423SLionel Sambuc } 700*433d6423SLionel Sambuc 701*433d6423SLionel Sambuc /* Special handling for the last segment (NumSegments == 0) */ 702*433d6423SLionel Sambuc 703*433d6423SLionel Sambuc else 704*433d6423SLionel Sambuc { 705*433d6423SLionel Sambuc /* 706*433d6423SLionel Sambuc * Sanity typecheck of the target object: 707*433d6423SLionel Sambuc * 708*433d6423SLionel Sambuc * If 1) This is the last segment (NumSegments == 0) 709*433d6423SLionel Sambuc * 2) And we are looking for a specific type 710*433d6423SLionel Sambuc * (Not checking for TYPE_ANY) 711*433d6423SLionel Sambuc * 3) Which is not an alias 712*433d6423SLionel Sambuc * 4) Which is not a local type (TYPE_SCOPE) 713*433d6423SLionel Sambuc * 5) And the type of target object is known (not TYPE_ANY) 714*433d6423SLionel Sambuc * 6) And target object does not match what we are looking for 715*433d6423SLionel Sambuc * 716*433d6423SLionel Sambuc * Then we have a type mismatch. Just warn and ignore it. 717*433d6423SLionel Sambuc */ 718*433d6423SLionel Sambuc if ((TypeToCheckFor != ACPI_TYPE_ANY) && 719*433d6423SLionel Sambuc (TypeToCheckFor != ACPI_TYPE_LOCAL_ALIAS) && 720*433d6423SLionel Sambuc (TypeToCheckFor != ACPI_TYPE_LOCAL_METHOD_ALIAS) && 721*433d6423SLionel Sambuc (TypeToCheckFor != ACPI_TYPE_LOCAL_SCOPE) && 722*433d6423SLionel Sambuc (ThisNode->Type != ACPI_TYPE_ANY) && 723*433d6423SLionel Sambuc (ThisNode->Type != TypeToCheckFor)) 724*433d6423SLionel Sambuc { 725*433d6423SLionel Sambuc /* Complain about a type mismatch */ 726*433d6423SLionel Sambuc 727*433d6423SLionel Sambuc ACPI_WARNING ((AE_INFO, 728*433d6423SLionel Sambuc "NsLookup: Type mismatch on %4.4s (%s), searching for (%s)", 729*433d6423SLionel Sambuc ACPI_CAST_PTR (char, &SimpleName), 730*433d6423SLionel Sambuc AcpiUtGetTypeName (ThisNode->Type), 731*433d6423SLionel Sambuc AcpiUtGetTypeName (TypeToCheckFor))); 732*433d6423SLionel Sambuc } 733*433d6423SLionel Sambuc 734*433d6423SLionel Sambuc /* 735*433d6423SLionel Sambuc * If this is the last name segment and we are not looking for a 736*433d6423SLionel Sambuc * specific type, but the type of found object is known, use that 737*433d6423SLionel Sambuc * type to (later) see if it opens a scope. 738*433d6423SLionel Sambuc */ 739*433d6423SLionel Sambuc if (Type == ACPI_TYPE_ANY) 740*433d6423SLionel Sambuc { 741*433d6423SLionel Sambuc Type = ThisNode->Type; 742*433d6423SLionel Sambuc } 743*433d6423SLionel Sambuc } 744*433d6423SLionel Sambuc 745*433d6423SLionel Sambuc /* Point to next name segment and make this node current */ 746*433d6423SLionel Sambuc 747*433d6423SLionel Sambuc Path += ACPI_NAME_SIZE; 748*433d6423SLionel Sambuc CurrentNode = ThisNode; 749*433d6423SLionel Sambuc } 750*433d6423SLionel Sambuc 751*433d6423SLionel Sambuc /* Always check if we need to open a new scope */ 752*433d6423SLionel Sambuc 753*433d6423SLionel Sambuc if (!(Flags & ACPI_NS_DONT_OPEN_SCOPE) && (WalkState)) 754*433d6423SLionel Sambuc { 755*433d6423SLionel Sambuc /* 756*433d6423SLionel Sambuc * If entry is a type which opens a scope, push the new scope on the 757*433d6423SLionel Sambuc * scope stack. 758*433d6423SLionel Sambuc */ 759*433d6423SLionel Sambuc if (AcpiNsOpensScope (Type)) 760*433d6423SLionel Sambuc { 761*433d6423SLionel Sambuc Status = AcpiDsScopeStackPush (ThisNode, Type, WalkState); 762*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 763*433d6423SLionel Sambuc { 764*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 765*433d6423SLionel Sambuc } 766*433d6423SLionel Sambuc } 767*433d6423SLionel Sambuc } 768*433d6423SLionel Sambuc 769*433d6423SLionel Sambuc *ReturnNode = ThisNode; 770*433d6423SLionel Sambuc return_ACPI_STATUS (AE_OK); 771*433d6423SLionel Sambuc } 772*433d6423SLionel Sambuc 773