1*3446Smrj /******************************************************************************* 2*3446Smrj * 3*3446Smrj * Module Name: nssearch - Namespace search 4*3446Smrj * $Revision: 1.118 $ 5*3446Smrj * 6*3446Smrj ******************************************************************************/ 7*3446Smrj 8*3446Smrj /****************************************************************************** 9*3446Smrj * 10*3446Smrj * 1. Copyright Notice 11*3446Smrj * 12*3446Smrj * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. 13*3446Smrj * All rights reserved. 14*3446Smrj * 15*3446Smrj * 2. License 16*3446Smrj * 17*3446Smrj * 2.1. This is your license from Intel Corp. under its intellectual property 18*3446Smrj * rights. You may have additional license terms from the party that provided 19*3446Smrj * you this software, covering your right to use that party's intellectual 20*3446Smrj * property rights. 21*3446Smrj * 22*3446Smrj * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23*3446Smrj * copy of the source code appearing in this file ("Covered Code") an 24*3446Smrj * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25*3446Smrj * base code distributed originally by Intel ("Original Intel Code") to copy, 26*3446Smrj * make derivatives, distribute, use and display any portion of the Covered 27*3446Smrj * Code in any form, with the right to sublicense such rights; and 28*3446Smrj * 29*3446Smrj * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30*3446Smrj * license (with the right to sublicense), under only those claims of Intel 31*3446Smrj * patents that are infringed by the Original Intel Code, to make, use, sell, 32*3446Smrj * offer to sell, and import the Covered Code and derivative works thereof 33*3446Smrj * solely to the minimum extent necessary to exercise the above copyright 34*3446Smrj * license, and in no event shall the patent license extend to any additions 35*3446Smrj * to or modifications of the Original Intel Code. No other license or right 36*3446Smrj * is granted directly or by implication, estoppel or otherwise; 37*3446Smrj * 38*3446Smrj * The above copyright and patent license is granted only if the following 39*3446Smrj * conditions are met: 40*3446Smrj * 41*3446Smrj * 3. Conditions 42*3446Smrj * 43*3446Smrj * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44*3446Smrj * Redistribution of source code of any substantial portion of the Covered 45*3446Smrj * Code or modification with rights to further distribute source must include 46*3446Smrj * the above Copyright Notice, the above License, this list of Conditions, 47*3446Smrj * and the following Disclaimer and Export Compliance provision. In addition, 48*3446Smrj * Licensee must cause all Covered Code to which Licensee contributes to 49*3446Smrj * contain a file documenting the changes Licensee made to create that Covered 50*3446Smrj * Code and the date of any change. Licensee must include in that file the 51*3446Smrj * documentation of any changes made by any predecessor Licensee. Licensee 52*3446Smrj * must include a prominent statement that the modification is derived, 53*3446Smrj * directly or indirectly, from Original Intel Code. 54*3446Smrj * 55*3446Smrj * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56*3446Smrj * Redistribution of source code of any substantial portion of the Covered 57*3446Smrj * Code or modification without rights to further distribute source must 58*3446Smrj * include the following Disclaimer and Export Compliance provision in the 59*3446Smrj * documentation and/or other materials provided with distribution. In 60*3446Smrj * addition, Licensee may not authorize further sublicense of source of any 61*3446Smrj * portion of the Covered Code, and must include terms to the effect that the 62*3446Smrj * license from Licensee to its licensee is limited to the intellectual 63*3446Smrj * property embodied in the software Licensee provides to its licensee, and 64*3446Smrj * not to intellectual property embodied in modifications its licensee may 65*3446Smrj * make. 66*3446Smrj * 67*3446Smrj * 3.3. Redistribution of Executable. Redistribution in executable form of any 68*3446Smrj * substantial portion of the Covered Code or modification must reproduce the 69*3446Smrj * above Copyright Notice, and the following Disclaimer and Export Compliance 70*3446Smrj * provision in the documentation and/or other materials provided with the 71*3446Smrj * distribution. 72*3446Smrj * 73*3446Smrj * 3.4. Intel retains all right, title, and interest in and to the Original 74*3446Smrj * Intel Code. 75*3446Smrj * 76*3446Smrj * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77*3446Smrj * Intel shall be used in advertising or otherwise to promote the sale, use or 78*3446Smrj * other dealings in products derived from or relating to the Covered Code 79*3446Smrj * without prior written authorization from Intel. 80*3446Smrj * 81*3446Smrj * 4. Disclaimer and Export Compliance 82*3446Smrj * 83*3446Smrj * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84*3446Smrj * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85*3446Smrj * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86*3446Smrj * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87*3446Smrj * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88*3446Smrj * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89*3446Smrj * PARTICULAR PURPOSE. 90*3446Smrj * 91*3446Smrj * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92*3446Smrj * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93*3446Smrj * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94*3446Smrj * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95*3446Smrj * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96*3446Smrj * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97*3446Smrj * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98*3446Smrj * LIMITED REMEDY. 99*3446Smrj * 100*3446Smrj * 4.3. Licensee shall not export, either directly or indirectly, any of this 101*3446Smrj * software or system incorporating such software without first obtaining any 102*3446Smrj * required license or other approval from the U. S. Department of Commerce or 103*3446Smrj * any other agency or department of the United States Government. In the 104*3446Smrj * event Licensee exports any such software from the United States or 105*3446Smrj * re-exports any such software from a foreign destination, Licensee shall 106*3446Smrj * ensure that the distribution and export/re-export of the software is in 107*3446Smrj * compliance with all laws, regulations, orders, or other restrictions of the 108*3446Smrj * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109*3446Smrj * any of its subsidiaries will export/re-export any technical data, process, 110*3446Smrj * software, or service, directly or indirectly, to any country for which the 111*3446Smrj * United States government or any agency thereof requires an export license, 112*3446Smrj * other governmental approval, or letter of assurance, without first obtaining 113*3446Smrj * such license, approval or letter. 114*3446Smrj * 115*3446Smrj *****************************************************************************/ 116*3446Smrj 117*3446Smrj #define __NSSEARCH_C__ 118*3446Smrj 119*3446Smrj #include "acpi.h" 120*3446Smrj #include "acnamesp.h" 121*3446Smrj 122*3446Smrj 123*3446Smrj #define _COMPONENT ACPI_NAMESPACE 124*3446Smrj ACPI_MODULE_NAME ("nssearch") 125*3446Smrj 126*3446Smrj /* Local prototypes */ 127*3446Smrj 128*3446Smrj static ACPI_STATUS 129*3446Smrj AcpiNsSearchParentTree ( 130*3446Smrj UINT32 TargetName, 131*3446Smrj ACPI_NAMESPACE_NODE *Node, 132*3446Smrj ACPI_OBJECT_TYPE Type, 133*3446Smrj ACPI_NAMESPACE_NODE **ReturnNode); 134*3446Smrj 135*3446Smrj 136*3446Smrj /******************************************************************************* 137*3446Smrj * 138*3446Smrj * FUNCTION: AcpiNsSearchOneScope 139*3446Smrj * 140*3446Smrj * PARAMETERS: TargetName - Ascii ACPI name to search for 141*3446Smrj * ParentNode - Starting node where search will begin 142*3446Smrj * Type - Object type to match 143*3446Smrj * ReturnNode - Where the matched Named obj is returned 144*3446Smrj * 145*3446Smrj * RETURN: Status 146*3446Smrj * 147*3446Smrj * DESCRIPTION: Search a single level of the namespace. Performs a 148*3446Smrj * simple search of the specified level, and does not add 149*3446Smrj * entries or search parents. 150*3446Smrj * 151*3446Smrj * 152*3446Smrj * Named object lists are built (and subsequently dumped) in the 153*3446Smrj * order in which the names are encountered during the namespace load; 154*3446Smrj * 155*3446Smrj * All namespace searching is linear in this implementation, but 156*3446Smrj * could be easily modified to support any improved search 157*3446Smrj * algorithm. However, the linear search was chosen for simplicity 158*3446Smrj * and because the trees are small and the other interpreter 159*3446Smrj * execution overhead is relatively high. 160*3446Smrj * 161*3446Smrj * Note: CPU execution analysis has shown that the AML interpreter spends 162*3446Smrj * a very small percentage of its time searching the namespace. Therefore, 163*3446Smrj * the linear search seems to be sufficient, as there would seem to be 164*3446Smrj * little value in improving the search. 165*3446Smrj * 166*3446Smrj ******************************************************************************/ 167*3446Smrj 168*3446Smrj ACPI_STATUS 169*3446Smrj AcpiNsSearchOneScope ( 170*3446Smrj UINT32 TargetName, 171*3446Smrj ACPI_NAMESPACE_NODE *ParentNode, 172*3446Smrj ACPI_OBJECT_TYPE Type, 173*3446Smrj ACPI_NAMESPACE_NODE **ReturnNode) 174*3446Smrj { 175*3446Smrj ACPI_NAMESPACE_NODE *Node; 176*3446Smrj 177*3446Smrj 178*3446Smrj ACPI_FUNCTION_TRACE (NsSearchOneScope); 179*3446Smrj 180*3446Smrj 181*3446Smrj #ifdef ACPI_DEBUG_OUTPUT 182*3446Smrj if (ACPI_LV_NAMES & AcpiDbgLevel) 183*3446Smrj { 184*3446Smrj char *ScopeName; 185*3446Smrj 186*3446Smrj ScopeName = AcpiNsGetExternalPathname (ParentNode); 187*3446Smrj if (ScopeName) 188*3446Smrj { 189*3446Smrj ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 190*3446Smrj "Searching %s (%p) For [%4.4s] (%s)\n", 191*3446Smrj ScopeName, ParentNode, ACPI_CAST_PTR (char, &TargetName), 192*3446Smrj AcpiUtGetTypeName (Type))); 193*3446Smrj 194*3446Smrj ACPI_FREE (ScopeName); 195*3446Smrj } 196*3446Smrj } 197*3446Smrj #endif 198*3446Smrj 199*3446Smrj /* 200*3446Smrj * Search for name at this namespace level, which is to say that we 201*3446Smrj * must search for the name among the children of this object 202*3446Smrj */ 203*3446Smrj Node = ParentNode->Child; 204*3446Smrj while (Node) 205*3446Smrj { 206*3446Smrj /* Check for match against the name */ 207*3446Smrj 208*3446Smrj if (Node->Name.Integer == TargetName) 209*3446Smrj { 210*3446Smrj /* Resolve a control method alias if any */ 211*3446Smrj 212*3446Smrj if (AcpiNsGetType (Node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) 213*3446Smrj { 214*3446Smrj Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Node->Object); 215*3446Smrj } 216*3446Smrj 217*3446Smrj /* Found matching entry */ 218*3446Smrj 219*3446Smrj ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 220*3446Smrj "Name [%4.4s] (%s) %p found in scope [%4.4s] %p\n", 221*3446Smrj ACPI_CAST_PTR (char, &TargetName), 222*3446Smrj AcpiUtGetTypeName (Node->Type), 223*3446Smrj Node, AcpiUtGetNodeName (ParentNode), ParentNode)); 224*3446Smrj 225*3446Smrj *ReturnNode = Node; 226*3446Smrj return_ACPI_STATUS (AE_OK); 227*3446Smrj } 228*3446Smrj 229*3446Smrj /* 230*3446Smrj * The last entry in the list points back to the parent, 231*3446Smrj * so a flag is used to indicate the end-of-list 232*3446Smrj */ 233*3446Smrj if (Node->Flags & ANOBJ_END_OF_PEER_LIST) 234*3446Smrj { 235*3446Smrj /* Searched entire list, we are done */ 236*3446Smrj 237*3446Smrj break; 238*3446Smrj } 239*3446Smrj 240*3446Smrj /* Didn't match name, move on to the next peer object */ 241*3446Smrj 242*3446Smrj Node = Node->Peer; 243*3446Smrj } 244*3446Smrj 245*3446Smrj /* Searched entire namespace level, not found */ 246*3446Smrj 247*3446Smrj ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 248*3446Smrj "Name [%4.4s] (%s) not found in search in scope [%4.4s] %p first child %p\n", 249*3446Smrj ACPI_CAST_PTR (char, &TargetName), AcpiUtGetTypeName (Type), 250*3446Smrj AcpiUtGetNodeName (ParentNode), ParentNode, ParentNode->Child)); 251*3446Smrj 252*3446Smrj return_ACPI_STATUS (AE_NOT_FOUND); 253*3446Smrj } 254*3446Smrj 255*3446Smrj 256*3446Smrj /******************************************************************************* 257*3446Smrj * 258*3446Smrj * FUNCTION: AcpiNsSearchParentTree 259*3446Smrj * 260*3446Smrj * PARAMETERS: TargetName - Ascii ACPI name to search for 261*3446Smrj * Node - Starting node where search will begin 262*3446Smrj * Type - Object type to match 263*3446Smrj * ReturnNode - Where the matched Node is returned 264*3446Smrj * 265*3446Smrj * RETURN: Status 266*3446Smrj * 267*3446Smrj * DESCRIPTION: Called when a name has not been found in the current namespace 268*3446Smrj * level. Before adding it or giving up, ACPI scope rules require 269*3446Smrj * searching enclosing scopes in cases identified by AcpiNsLocal(). 270*3446Smrj * 271*3446Smrj * "A name is located by finding the matching name in the current 272*3446Smrj * name space, and then in the parent name space. If the parent 273*3446Smrj * name space does not contain the name, the search continues 274*3446Smrj * recursively until either the name is found or the name space 275*3446Smrj * does not have a parent (the root of the name space). This 276*3446Smrj * indicates that the name is not found" (From ACPI Specification, 277*3446Smrj * section 5.3) 278*3446Smrj * 279*3446Smrj ******************************************************************************/ 280*3446Smrj 281*3446Smrj static ACPI_STATUS 282*3446Smrj AcpiNsSearchParentTree ( 283*3446Smrj UINT32 TargetName, 284*3446Smrj ACPI_NAMESPACE_NODE *Node, 285*3446Smrj ACPI_OBJECT_TYPE Type, 286*3446Smrj ACPI_NAMESPACE_NODE **ReturnNode) 287*3446Smrj { 288*3446Smrj ACPI_STATUS Status; 289*3446Smrj ACPI_NAMESPACE_NODE *ParentNode; 290*3446Smrj 291*3446Smrj 292*3446Smrj ACPI_FUNCTION_TRACE (NsSearchParentTree); 293*3446Smrj 294*3446Smrj 295*3446Smrj ParentNode = AcpiNsGetParentNode (Node); 296*3446Smrj 297*3446Smrj /* 298*3446Smrj * If there is no parent (i.e., we are at the root) or type is "local", 299*3446Smrj * we won't be searching the parent tree. 300*3446Smrj */ 301*3446Smrj if (!ParentNode) 302*3446Smrj { 303*3446Smrj ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[%4.4s] has no parent\n", 304*3446Smrj ACPI_CAST_PTR (char, &TargetName))); 305*3446Smrj return_ACPI_STATUS (AE_NOT_FOUND); 306*3446Smrj } 307*3446Smrj 308*3446Smrj if (AcpiNsLocal (Type)) 309*3446Smrj { 310*3446Smrj ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 311*3446Smrj "[%4.4s] type [%s] must be local to this scope (no parent search)\n", 312*3446Smrj ACPI_CAST_PTR (char, &TargetName), AcpiUtGetTypeName (Type))); 313*3446Smrj return_ACPI_STATUS (AE_NOT_FOUND); 314*3446Smrj } 315*3446Smrj 316*3446Smrj /* Search the parent tree */ 317*3446Smrj 318*3446Smrj ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 319*3446Smrj "Searching parent [%4.4s] for [%4.4s]\n", 320*3446Smrj AcpiUtGetNodeName (ParentNode), ACPI_CAST_PTR (char, &TargetName))); 321*3446Smrj 322*3446Smrj /* 323*3446Smrj * Search parents until target is found or we have backed up to the root 324*3446Smrj */ 325*3446Smrj while (ParentNode) 326*3446Smrj { 327*3446Smrj /* 328*3446Smrj * Search parent scope. Use TYPE_ANY because we don't care about the 329*3446Smrj * object type at this point, we only care about the existence of 330*3446Smrj * the actual name we are searching for. Typechecking comes later. 331*3446Smrj */ 332*3446Smrj Status = AcpiNsSearchOneScope ( 333*3446Smrj TargetName, ParentNode, ACPI_TYPE_ANY, ReturnNode); 334*3446Smrj if (ACPI_SUCCESS (Status)) 335*3446Smrj { 336*3446Smrj return_ACPI_STATUS (Status); 337*3446Smrj } 338*3446Smrj 339*3446Smrj /* Not found here, go up another level (until we reach the root) */ 340*3446Smrj 341*3446Smrj ParentNode = AcpiNsGetParentNode (ParentNode); 342*3446Smrj } 343*3446Smrj 344*3446Smrj /* Not found in parent tree */ 345*3446Smrj 346*3446Smrj return_ACPI_STATUS (AE_NOT_FOUND); 347*3446Smrj } 348*3446Smrj 349*3446Smrj 350*3446Smrj /******************************************************************************* 351*3446Smrj * 352*3446Smrj * FUNCTION: AcpiNsSearchAndEnter 353*3446Smrj * 354*3446Smrj * PARAMETERS: TargetName - Ascii ACPI name to search for (4 chars) 355*3446Smrj * WalkState - Current state of the walk 356*3446Smrj * Node - Starting node where search will begin 357*3446Smrj * InterpreterMode - Add names only in ACPI_MODE_LOAD_PASS_x. 358*3446Smrj * Otherwise,search only. 359*3446Smrj * Type - Object type to match 360*3446Smrj * Flags - Flags describing the search restrictions 361*3446Smrj * ReturnNode - Where the Node is returned 362*3446Smrj * 363*3446Smrj * RETURN: Status 364*3446Smrj * 365*3446Smrj * DESCRIPTION: Search for a name segment in a single namespace level, 366*3446Smrj * optionally adding it if it is not found. If the passed 367*3446Smrj * Type is not Any and the type previously stored in the 368*3446Smrj * entry was Any (i.e. unknown), update the stored type. 369*3446Smrj * 370*3446Smrj * In ACPI_IMODE_EXECUTE, search only. 371*3446Smrj * In other modes, search and add if not found. 372*3446Smrj * 373*3446Smrj ******************************************************************************/ 374*3446Smrj 375*3446Smrj ACPI_STATUS 376*3446Smrj AcpiNsSearchAndEnter ( 377*3446Smrj UINT32 TargetName, 378*3446Smrj ACPI_WALK_STATE *WalkState, 379*3446Smrj ACPI_NAMESPACE_NODE *Node, 380*3446Smrj ACPI_INTERPRETER_MODE InterpreterMode, 381*3446Smrj ACPI_OBJECT_TYPE Type, 382*3446Smrj UINT32 Flags, 383*3446Smrj ACPI_NAMESPACE_NODE **ReturnNode) 384*3446Smrj { 385*3446Smrj ACPI_STATUS Status; 386*3446Smrj ACPI_NAMESPACE_NODE *NewNode; 387*3446Smrj 388*3446Smrj 389*3446Smrj ACPI_FUNCTION_TRACE (NsSearchAndEnter); 390*3446Smrj 391*3446Smrj 392*3446Smrj /* Parameter validation */ 393*3446Smrj 394*3446Smrj if (!Node || !TargetName || !ReturnNode) 395*3446Smrj { 396*3446Smrj ACPI_ERROR ((AE_INFO, 397*3446Smrj "Null parameter: Node %p Name %X ReturnNode %p", 398*3446Smrj Node, TargetName, ReturnNode)); 399*3446Smrj return_ACPI_STATUS (AE_BAD_PARAMETER); 400*3446Smrj } 401*3446Smrj 402*3446Smrj /* 403*3446Smrj * Name must consist of valid ACPI characters. We will repair the name if 404*3446Smrj * necessary because we don't want to abort because of this, but we want 405*3446Smrj * all namespace names to be printable. A warning message is appropriate. 406*3446Smrj * 407*3446Smrj * This issue came up because there are in fact machines that exhibit 408*3446Smrj * this problem, and we want to be able to enable ACPI support for them, 409*3446Smrj * even though there are a few bad names. 410*3446Smrj */ 411*3446Smrj if (!AcpiUtValidAcpiName (TargetName)) 412*3446Smrj { 413*3446Smrj TargetName = AcpiUtRepairName (TargetName); 414*3446Smrj 415*3446Smrj /* Report warning only if in strict mode or debug mode */ 416*3446Smrj 417*3446Smrj if (!AcpiGbl_EnableInterpreterSlack) 418*3446Smrj { 419*3446Smrj ACPI_WARNING ((AE_INFO, 420*3446Smrj "Found bad character(s) in name, repaired: [%4.4s]\n", 421*3446Smrj ACPI_CAST_PTR (char, &TargetName))); 422*3446Smrj } 423*3446Smrj else 424*3446Smrj { 425*3446Smrj ACPI_DEBUG_PRINT ((ACPI_DB_WARN, 426*3446Smrj "Found bad character(s) in name, repaired: [%4.4s]\n", 427*3446Smrj ACPI_CAST_PTR (char, &TargetName))); 428*3446Smrj } 429*3446Smrj } 430*3446Smrj 431*3446Smrj /* Try to find the name in the namespace level specified by the caller */ 432*3446Smrj 433*3446Smrj *ReturnNode = ACPI_ENTRY_NOT_FOUND; 434*3446Smrj Status = AcpiNsSearchOneScope (TargetName, Node, Type, ReturnNode); 435*3446Smrj if (Status != AE_NOT_FOUND) 436*3446Smrj { 437*3446Smrj /* 438*3446Smrj * If we found it AND the request specifies that a find is an error, 439*3446Smrj * return the error 440*3446Smrj */ 441*3446Smrj if ((Status == AE_OK) && 442*3446Smrj (Flags & ACPI_NS_ERROR_IF_FOUND)) 443*3446Smrj { 444*3446Smrj Status = AE_ALREADY_EXISTS; 445*3446Smrj } 446*3446Smrj 447*3446Smrj /* Either found it or there was an error: finished either way */ 448*3446Smrj 449*3446Smrj return_ACPI_STATUS (Status); 450*3446Smrj } 451*3446Smrj 452*3446Smrj /* 453*3446Smrj * The name was not found. If we are NOT performing the first pass 454*3446Smrj * (name entry) of loading the namespace, search the parent tree (all the 455*3446Smrj * way to the root if necessary.) We don't want to perform the parent 456*3446Smrj * search when the namespace is actually being loaded. We want to perform 457*3446Smrj * the search when namespace references are being resolved (load pass 2) 458*3446Smrj * and during the execution phase. 459*3446Smrj */ 460*3446Smrj if ((InterpreterMode != ACPI_IMODE_LOAD_PASS1) && 461*3446Smrj (Flags & ACPI_NS_SEARCH_PARENT)) 462*3446Smrj { 463*3446Smrj /* 464*3446Smrj * Not found at this level - search parent tree according to the 465*3446Smrj * ACPI specification 466*3446Smrj */ 467*3446Smrj Status = AcpiNsSearchParentTree (TargetName, Node, Type, ReturnNode); 468*3446Smrj if (ACPI_SUCCESS (Status)) 469*3446Smrj { 470*3446Smrj return_ACPI_STATUS (Status); 471*3446Smrj } 472*3446Smrj } 473*3446Smrj 474*3446Smrj /* In execute mode, just search, never add names. Exit now */ 475*3446Smrj 476*3446Smrj if (InterpreterMode == ACPI_IMODE_EXECUTE) 477*3446Smrj { 478*3446Smrj ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 479*3446Smrj "%4.4s Not found in %p [Not adding]\n", 480*3446Smrj ACPI_CAST_PTR (char, &TargetName), Node)); 481*3446Smrj 482*3446Smrj return_ACPI_STATUS (AE_NOT_FOUND); 483*3446Smrj } 484*3446Smrj 485*3446Smrj /* Create the new named object */ 486*3446Smrj 487*3446Smrj NewNode = AcpiNsCreateNode (TargetName); 488*3446Smrj if (!NewNode) 489*3446Smrj { 490*3446Smrj return_ACPI_STATUS (AE_NO_MEMORY); 491*3446Smrj } 492*3446Smrj 493*3446Smrj #ifdef ACPI_ASL_COMPILER 494*3446Smrj /* 495*3446Smrj * Node is an object defined by an External() statement 496*3446Smrj */ 497*3446Smrj if (Flags & ACPI_NS_EXTERNAL) 498*3446Smrj { 499*3446Smrj NewNode->Flags |= ANOBJ_IS_EXTERNAL; 500*3446Smrj } 501*3446Smrj #endif 502*3446Smrj 503*3446Smrj /* Install the new object into the parent's list of children */ 504*3446Smrj 505*3446Smrj AcpiNsInstallNode (WalkState, Node, NewNode, Type); 506*3446Smrj *ReturnNode = NewNode; 507*3446Smrj return_ACPI_STATUS (AE_OK); 508*3446Smrj } 509*3446Smrj 510