xref: /onnv-gate/usr/src/uts/intel/io/acpica/namespace/nssearch.c (revision 9980:13d7f3eec672)
13446Smrj /*******************************************************************************
23446Smrj  *
33446Smrj  * Module Name: nssearch - Namespace search
43446Smrj  *
53446Smrj  ******************************************************************************/
63446Smrj 
73446Smrj /******************************************************************************
83446Smrj  *
93446Smrj  * 1. Copyright Notice
103446Smrj  *
11*9980SDana.Myers@Sun.COM  * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
123446Smrj  * All rights reserved.
133446Smrj  *
143446Smrj  * 2. License
153446Smrj  *
163446Smrj  * 2.1. This is your license from Intel Corp. under its intellectual property
173446Smrj  * rights.  You may have additional license terms from the party that provided
183446Smrj  * you this software, covering your right to use that party's intellectual
193446Smrj  * property rights.
203446Smrj  *
213446Smrj  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
223446Smrj  * copy of the source code appearing in this file ("Covered Code") an
233446Smrj  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
243446Smrj  * base code distributed originally by Intel ("Original Intel Code") to copy,
253446Smrj  * make derivatives, distribute, use and display any portion of the Covered
263446Smrj  * Code in any form, with the right to sublicense such rights; and
273446Smrj  *
283446Smrj  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
293446Smrj  * license (with the right to sublicense), under only those claims of Intel
303446Smrj  * patents that are infringed by the Original Intel Code, to make, use, sell,
313446Smrj  * offer to sell, and import the Covered Code and derivative works thereof
323446Smrj  * solely to the minimum extent necessary to exercise the above copyright
333446Smrj  * license, and in no event shall the patent license extend to any additions
343446Smrj  * to or modifications of the Original Intel Code.  No other license or right
353446Smrj  * is granted directly or by implication, estoppel or otherwise;
363446Smrj  *
373446Smrj  * The above copyright and patent license is granted only if the following
383446Smrj  * conditions are met:
393446Smrj  *
403446Smrj  * 3. Conditions
413446Smrj  *
423446Smrj  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
433446Smrj  * Redistribution of source code of any substantial portion of the Covered
443446Smrj  * Code or modification with rights to further distribute source must include
453446Smrj  * the above Copyright Notice, the above License, this list of Conditions,
463446Smrj  * and the following Disclaimer and Export Compliance provision.  In addition,
473446Smrj  * Licensee must cause all Covered Code to which Licensee contributes to
483446Smrj  * contain a file documenting the changes Licensee made to create that Covered
493446Smrj  * Code and the date of any change.  Licensee must include in that file the
503446Smrj  * documentation of any changes made by any predecessor Licensee.  Licensee
513446Smrj  * must include a prominent statement that the modification is derived,
523446Smrj  * directly or indirectly, from Original Intel Code.
533446Smrj  *
543446Smrj  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
553446Smrj  * Redistribution of source code of any substantial portion of the Covered
563446Smrj  * Code or modification without rights to further distribute source must
573446Smrj  * include the following Disclaimer and Export Compliance provision in the
583446Smrj  * documentation and/or other materials provided with distribution.  In
593446Smrj  * addition, Licensee may not authorize further sublicense of source of any
603446Smrj  * portion of the Covered Code, and must include terms to the effect that the
613446Smrj  * license from Licensee to its licensee is limited to the intellectual
623446Smrj  * property embodied in the software Licensee provides to its licensee, and
633446Smrj  * not to intellectual property embodied in modifications its licensee may
643446Smrj  * make.
653446Smrj  *
663446Smrj  * 3.3. Redistribution of Executable. Redistribution in executable form of any
673446Smrj  * substantial portion of the Covered Code or modification must reproduce the
683446Smrj  * above Copyright Notice, and the following Disclaimer and Export Compliance
693446Smrj  * provision in the documentation and/or other materials provided with the
703446Smrj  * distribution.
713446Smrj  *
723446Smrj  * 3.4. Intel retains all right, title, and interest in and to the Original
733446Smrj  * Intel Code.
743446Smrj  *
753446Smrj  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
763446Smrj  * Intel shall be used in advertising or otherwise to promote the sale, use or
773446Smrj  * other dealings in products derived from or relating to the Covered Code
783446Smrj  * without prior written authorization from Intel.
793446Smrj  *
803446Smrj  * 4. Disclaimer and Export Compliance
813446Smrj  *
823446Smrj  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
833446Smrj  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
843446Smrj  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
853446Smrj  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
863446Smrj  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
873446Smrj  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
883446Smrj  * PARTICULAR PURPOSE.
893446Smrj  *
903446Smrj  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
913446Smrj  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
923446Smrj  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
933446Smrj  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
943446Smrj  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
953446Smrj  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
963446Smrj  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
973446Smrj  * LIMITED REMEDY.
983446Smrj  *
993446Smrj  * 4.3. Licensee shall not export, either directly or indirectly, any of this
1003446Smrj  * software or system incorporating such software without first obtaining any
1013446Smrj  * required license or other approval from the U. S. Department of Commerce or
1023446Smrj  * any other agency or department of the United States Government.  In the
1033446Smrj  * event Licensee exports any such software from the United States or
1043446Smrj  * re-exports any such software from a foreign destination, Licensee shall
1053446Smrj  * ensure that the distribution and export/re-export of the software is in
1063446Smrj  * compliance with all laws, regulations, orders, or other restrictions of the
1073446Smrj  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1083446Smrj  * any of its subsidiaries will export/re-export any technical data, process,
1093446Smrj  * software, or service, directly or indirectly, to any country for which the
1103446Smrj  * United States government or any agency thereof requires an export license,
1113446Smrj  * other governmental approval, or letter of assurance, without first obtaining
1123446Smrj  * such license, approval or letter.
1133446Smrj  *
1143446Smrj  *****************************************************************************/
1153446Smrj 
1163446Smrj #define __NSSEARCH_C__
1173446Smrj 
1183446Smrj #include "acpi.h"
119*9980SDana.Myers@Sun.COM #include "accommon.h"
1203446Smrj #include "acnamesp.h"
1213446Smrj 
122*9980SDana.Myers@Sun.COM #ifdef ACPI_ASL_COMPILER
123*9980SDana.Myers@Sun.COM #include "amlcode.h"
124*9980SDana.Myers@Sun.COM #endif
1253446Smrj 
1263446Smrj #define _COMPONENT          ACPI_NAMESPACE
1273446Smrj         ACPI_MODULE_NAME    ("nssearch")
1283446Smrj 
1293446Smrj /* Local prototypes */
1303446Smrj 
1313446Smrj static ACPI_STATUS
1323446Smrj AcpiNsSearchParentTree (
1333446Smrj     UINT32                  TargetName,
1343446Smrj     ACPI_NAMESPACE_NODE     *Node,
1353446Smrj     ACPI_OBJECT_TYPE        Type,
1363446Smrj     ACPI_NAMESPACE_NODE     **ReturnNode);
1373446Smrj 
1383446Smrj 
1393446Smrj /*******************************************************************************
1403446Smrj  *
1413446Smrj  * FUNCTION:    AcpiNsSearchOneScope
1423446Smrj  *
1433446Smrj  * PARAMETERS:  TargetName      - Ascii ACPI name to search for
1443446Smrj  *              ParentNode      - Starting node where search will begin
1453446Smrj  *              Type            - Object type to match
1463446Smrj  *              ReturnNode      - Where the matched Named obj is returned
1473446Smrj  *
1483446Smrj  * RETURN:      Status
1493446Smrj  *
1503446Smrj  * DESCRIPTION: Search a single level of the namespace. Performs a
1513446Smrj  *              simple search of the specified level, and does not add
1523446Smrj  *              entries or search parents.
1533446Smrj  *
1543446Smrj  *
1553446Smrj  *      Named object lists are built (and subsequently dumped) in the
1563446Smrj  *      order in which the names are encountered during the namespace load;
1573446Smrj  *
1583446Smrj  *      All namespace searching is linear in this implementation, but
1593446Smrj  *      could be easily modified to support any improved search
1603446Smrj  *      algorithm. However, the linear search was chosen for simplicity
1613446Smrj  *      and because the trees are small and the other interpreter
1623446Smrj  *      execution overhead is relatively high.
1633446Smrj  *
1643446Smrj  *      Note: CPU execution analysis has shown that the AML interpreter spends
1653446Smrj  *      a very small percentage of its time searching the namespace. Therefore,
1663446Smrj  *      the linear search seems to be sufficient, as there would seem to be
1673446Smrj  *      little value in improving the search.
1683446Smrj  *
1693446Smrj  ******************************************************************************/
1703446Smrj 
1713446Smrj ACPI_STATUS
AcpiNsSearchOneScope(UINT32 TargetName,ACPI_NAMESPACE_NODE * ParentNode,ACPI_OBJECT_TYPE Type,ACPI_NAMESPACE_NODE ** ReturnNode)1723446Smrj AcpiNsSearchOneScope (
1733446Smrj     UINT32                  TargetName,
1743446Smrj     ACPI_NAMESPACE_NODE     *ParentNode,
1753446Smrj     ACPI_OBJECT_TYPE        Type,
1763446Smrj     ACPI_NAMESPACE_NODE     **ReturnNode)
1773446Smrj {
1783446Smrj     ACPI_NAMESPACE_NODE     *Node;
1793446Smrj 
1803446Smrj 
1813446Smrj     ACPI_FUNCTION_TRACE (NsSearchOneScope);
1823446Smrj 
1833446Smrj 
1843446Smrj #ifdef ACPI_DEBUG_OUTPUT
1853446Smrj     if (ACPI_LV_NAMES & AcpiDbgLevel)
1863446Smrj     {
1873446Smrj         char                *ScopeName;
1883446Smrj 
1893446Smrj         ScopeName = AcpiNsGetExternalPathname (ParentNode);
1903446Smrj         if (ScopeName)
1913446Smrj         {
1923446Smrj             ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
1933446Smrj                 "Searching %s (%p) For [%4.4s] (%s)\n",
1943446Smrj                 ScopeName, ParentNode, ACPI_CAST_PTR (char, &TargetName),
1953446Smrj                 AcpiUtGetTypeName (Type)));
1963446Smrj 
1973446Smrj             ACPI_FREE (ScopeName);
1983446Smrj         }
1993446Smrj     }
2003446Smrj #endif
2013446Smrj 
2023446Smrj     /*
2033446Smrj      * Search for name at this namespace level, which is to say that we
2043446Smrj      * must search for the name among the children of this object
2053446Smrj      */
2063446Smrj     Node = ParentNode->Child;
2073446Smrj     while (Node)
2083446Smrj     {
2093446Smrj         /* Check for match against the name */
2103446Smrj 
2113446Smrj         if (Node->Name.Integer == TargetName)
2123446Smrj         {
2133446Smrj             /* Resolve a control method alias if any */
2143446Smrj 
2153446Smrj             if (AcpiNsGetType (Node) == ACPI_TYPE_LOCAL_METHOD_ALIAS)
2163446Smrj             {
2173446Smrj                 Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Node->Object);
2183446Smrj             }
2193446Smrj 
2203446Smrj             /* Found matching entry */
2213446Smrj 
2223446Smrj             ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
2233446Smrj                 "Name [%4.4s] (%s) %p found in scope [%4.4s] %p\n",
2243446Smrj                 ACPI_CAST_PTR (char, &TargetName),
2253446Smrj                 AcpiUtGetTypeName (Node->Type),
2263446Smrj                 Node, AcpiUtGetNodeName (ParentNode), ParentNode));
2273446Smrj 
2283446Smrj             *ReturnNode = Node;
2293446Smrj             return_ACPI_STATUS (AE_OK);
2303446Smrj         }
2313446Smrj 
2323446Smrj         /*
2333446Smrj          * The last entry in the list points back to the parent,
2343446Smrj          * so a flag is used to indicate the end-of-list
2353446Smrj          */
2363446Smrj         if (Node->Flags & ANOBJ_END_OF_PEER_LIST)
2373446Smrj         {
2383446Smrj             /* Searched entire list, we are done */
2393446Smrj 
2403446Smrj             break;
2413446Smrj         }
2423446Smrj 
2433446Smrj         /* Didn't match name, move on to the next peer object */
2443446Smrj 
2453446Smrj         Node = Node->Peer;
2463446Smrj     }
2473446Smrj 
2483446Smrj     /* Searched entire namespace level, not found */
2493446Smrj 
2503446Smrj     ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
251*9980SDana.Myers@Sun.COM         "Name [%4.4s] (%s) not found in search in scope [%4.4s] "
252*9980SDana.Myers@Sun.COM         "%p first child %p\n",
2533446Smrj         ACPI_CAST_PTR (char, &TargetName), AcpiUtGetTypeName (Type),
2543446Smrj         AcpiUtGetNodeName (ParentNode), ParentNode, ParentNode->Child));
2553446Smrj 
2563446Smrj     return_ACPI_STATUS (AE_NOT_FOUND);
2573446Smrj }
2583446Smrj 
2593446Smrj 
2603446Smrj /*******************************************************************************
2613446Smrj  *
2623446Smrj  * FUNCTION:    AcpiNsSearchParentTree
2633446Smrj  *
2643446Smrj  * PARAMETERS:  TargetName      - Ascii ACPI name to search for
2653446Smrj  *              Node            - Starting node where search will begin
2663446Smrj  *              Type            - Object type to match
2673446Smrj  *              ReturnNode      - Where the matched Node is returned
2683446Smrj  *
2693446Smrj  * RETURN:      Status
2703446Smrj  *
2713446Smrj  * DESCRIPTION: Called when a name has not been found in the current namespace
2723446Smrj  *              level. Before adding it or giving up, ACPI scope rules require
2733446Smrj  *              searching enclosing scopes in cases identified by AcpiNsLocal().
2743446Smrj  *
2753446Smrj  *              "A name is located by finding the matching name in the current
2763446Smrj  *              name space, and then in the parent name space. If the parent
2773446Smrj  *              name space does not contain the name, the search continues
2783446Smrj  *              recursively until either the name is found or the name space
2793446Smrj  *              does not have a parent (the root of the name space). This
2803446Smrj  *              indicates that the name is not found" (From ACPI Specification,
2813446Smrj  *              section 5.3)
2823446Smrj  *
2833446Smrj  ******************************************************************************/
2843446Smrj 
2853446Smrj static ACPI_STATUS
AcpiNsSearchParentTree(UINT32 TargetName,ACPI_NAMESPACE_NODE * Node,ACPI_OBJECT_TYPE Type,ACPI_NAMESPACE_NODE ** ReturnNode)2863446Smrj AcpiNsSearchParentTree (
2873446Smrj     UINT32                  TargetName,
2883446Smrj     ACPI_NAMESPACE_NODE     *Node,
2893446Smrj     ACPI_OBJECT_TYPE        Type,
2903446Smrj     ACPI_NAMESPACE_NODE     **ReturnNode)
2913446Smrj {
2923446Smrj     ACPI_STATUS             Status;
2933446Smrj     ACPI_NAMESPACE_NODE     *ParentNode;
2943446Smrj 
2953446Smrj 
2963446Smrj     ACPI_FUNCTION_TRACE (NsSearchParentTree);
2973446Smrj 
2983446Smrj 
2993446Smrj     ParentNode = AcpiNsGetParentNode (Node);
3003446Smrj 
3013446Smrj     /*
3023446Smrj      * If there is no parent (i.e., we are at the root) or type is "local",
3033446Smrj      * we won't be searching the parent tree.
3043446Smrj      */
3053446Smrj     if (!ParentNode)
3063446Smrj     {
3073446Smrj         ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[%4.4s] has no parent\n",
3083446Smrj             ACPI_CAST_PTR (char, &TargetName)));
3093446Smrj         return_ACPI_STATUS (AE_NOT_FOUND);
3103446Smrj     }
3113446Smrj 
3123446Smrj     if (AcpiNsLocal (Type))
3133446Smrj     {
3143446Smrj         ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
3153446Smrj             "[%4.4s] type [%s] must be local to this scope (no parent search)\n",
3163446Smrj             ACPI_CAST_PTR (char, &TargetName), AcpiUtGetTypeName (Type)));
3173446Smrj         return_ACPI_STATUS (AE_NOT_FOUND);
3183446Smrj     }
3193446Smrj 
3203446Smrj     /* Search the parent tree */
3213446Smrj 
3223446Smrj     ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
3233446Smrj         "Searching parent [%4.4s] for [%4.4s]\n",
3243446Smrj         AcpiUtGetNodeName (ParentNode), ACPI_CAST_PTR (char, &TargetName)));
3253446Smrj 
326*9980SDana.Myers@Sun.COM     /* Search parents until target is found or we have backed up to the root */
327*9980SDana.Myers@Sun.COM 
3283446Smrj     while (ParentNode)
3293446Smrj     {
3303446Smrj         /*
3313446Smrj          * Search parent scope. Use TYPE_ANY because we don't care about the
3323446Smrj          * object type at this point, we only care about the existence of
3333446Smrj          * the actual name we are searching for. Typechecking comes later.
3343446Smrj          */
3353446Smrj         Status = AcpiNsSearchOneScope (
3363446Smrj                     TargetName, ParentNode, ACPI_TYPE_ANY, ReturnNode);
3373446Smrj         if (ACPI_SUCCESS (Status))
3383446Smrj         {
3393446Smrj             return_ACPI_STATUS (Status);
3403446Smrj         }
3413446Smrj 
3423446Smrj         /* Not found here, go up another level (until we reach the root) */
3433446Smrj 
3443446Smrj         ParentNode = AcpiNsGetParentNode (ParentNode);
3453446Smrj     }
3463446Smrj 
3473446Smrj     /* Not found in parent tree */
3483446Smrj 
3493446Smrj     return_ACPI_STATUS (AE_NOT_FOUND);
3503446Smrj }
3513446Smrj 
3523446Smrj 
3533446Smrj /*******************************************************************************
3543446Smrj  *
3553446Smrj  * FUNCTION:    AcpiNsSearchAndEnter
3563446Smrj  *
3573446Smrj  * PARAMETERS:  TargetName          - Ascii ACPI name to search for (4 chars)
3583446Smrj  *              WalkState           - Current state of the walk
3593446Smrj  *              Node                - Starting node where search will begin
3603446Smrj  *              InterpreterMode     - Add names only in ACPI_MODE_LOAD_PASS_x.
3613446Smrj  *                                    Otherwise,search only.
3623446Smrj  *              Type                - Object type to match
3633446Smrj  *              Flags               - Flags describing the search restrictions
3643446Smrj  *              ReturnNode          - Where the Node is returned
3653446Smrj  *
3663446Smrj  * RETURN:      Status
3673446Smrj  *
3683446Smrj  * DESCRIPTION: Search for a name segment in a single namespace level,
3693446Smrj  *              optionally adding it if it is not found. If the passed
3703446Smrj  *              Type is not Any and the type previously stored in the
3713446Smrj  *              entry was Any (i.e. unknown), update the stored type.
3723446Smrj  *
3733446Smrj  *              In ACPI_IMODE_EXECUTE, search only.
3743446Smrj  *              In other modes, search and add if not found.
3753446Smrj  *
3763446Smrj  ******************************************************************************/
3773446Smrj 
3783446Smrj ACPI_STATUS
AcpiNsSearchAndEnter(UINT32 TargetName,ACPI_WALK_STATE * WalkState,ACPI_NAMESPACE_NODE * Node,ACPI_INTERPRETER_MODE InterpreterMode,ACPI_OBJECT_TYPE Type,UINT32 Flags,ACPI_NAMESPACE_NODE ** ReturnNode)3793446Smrj AcpiNsSearchAndEnter (
3803446Smrj     UINT32                  TargetName,
3813446Smrj     ACPI_WALK_STATE         *WalkState,
3823446Smrj     ACPI_NAMESPACE_NODE     *Node,
3833446Smrj     ACPI_INTERPRETER_MODE   InterpreterMode,
3843446Smrj     ACPI_OBJECT_TYPE        Type,
3853446Smrj     UINT32                  Flags,
3863446Smrj     ACPI_NAMESPACE_NODE     **ReturnNode)
3873446Smrj {
3883446Smrj     ACPI_STATUS             Status;
3893446Smrj     ACPI_NAMESPACE_NODE     *NewNode;
3903446Smrj 
3913446Smrj 
3923446Smrj     ACPI_FUNCTION_TRACE (NsSearchAndEnter);
3933446Smrj 
3943446Smrj 
3953446Smrj     /* Parameter validation */
3963446Smrj 
3973446Smrj     if (!Node || !TargetName || !ReturnNode)
3983446Smrj     {
3993446Smrj         ACPI_ERROR ((AE_INFO,
4003446Smrj             "Null parameter: Node %p Name %X ReturnNode %p",
4013446Smrj             Node, TargetName, ReturnNode));
4023446Smrj         return_ACPI_STATUS (AE_BAD_PARAMETER);
4033446Smrj     }
4043446Smrj 
4053446Smrj     /*
4063446Smrj      * Name must consist of valid ACPI characters. We will repair the name if
4073446Smrj      * necessary because we don't want to abort because of this, but we want
4083446Smrj      * all namespace names to be printable. A warning message is appropriate.
4093446Smrj      *
4103446Smrj      * This issue came up because there are in fact machines that exhibit
4113446Smrj      * this problem, and we want to be able to enable ACPI support for them,
4123446Smrj      * even though there are a few bad names.
4133446Smrj      */
4147851SDana.Myers@Sun.COM     AcpiUtRepairName (ACPI_CAST_PTR (char, &TargetName));
4153446Smrj 
4163446Smrj     /* Try to find the name in the namespace level specified by the caller */
4173446Smrj 
4183446Smrj     *ReturnNode = ACPI_ENTRY_NOT_FOUND;
4193446Smrj     Status = AcpiNsSearchOneScope (TargetName, Node, Type, ReturnNode);
4203446Smrj     if (Status != AE_NOT_FOUND)
4213446Smrj     {
4223446Smrj         /*
4233446Smrj          * If we found it AND the request specifies that a find is an error,
4243446Smrj          * return the error
4253446Smrj          */
4263446Smrj         if ((Status == AE_OK) &&
4273446Smrj             (Flags & ACPI_NS_ERROR_IF_FOUND))
4283446Smrj         {
4293446Smrj             Status = AE_ALREADY_EXISTS;
4303446Smrj         }
4313446Smrj 
432*9980SDana.Myers@Sun.COM #ifdef ACPI_ASL_COMPILER
433*9980SDana.Myers@Sun.COM         if (*ReturnNode && (*ReturnNode)->Type == ACPI_TYPE_ANY)
434*9980SDana.Myers@Sun.COM         {
435*9980SDana.Myers@Sun.COM             (*ReturnNode)->Flags |= ANOBJ_IS_EXTERNAL;
436*9980SDana.Myers@Sun.COM         }
437*9980SDana.Myers@Sun.COM #endif
438*9980SDana.Myers@Sun.COM 
4393446Smrj         /* Either found it or there was an error: finished either way */
4403446Smrj 
4413446Smrj         return_ACPI_STATUS (Status);
4423446Smrj     }
4433446Smrj 
4443446Smrj     /*
4453446Smrj      * The name was not found. If we are NOT performing the first pass
4463446Smrj      * (name entry) of loading the namespace, search the parent tree (all the
4473446Smrj      * way to the root if necessary.) We don't want to perform the parent
4483446Smrj      * search when the namespace is actually being loaded. We want to perform
4493446Smrj      * the search when namespace references are being resolved (load pass 2)
4503446Smrj      * and during the execution phase.
4513446Smrj      */
4523446Smrj     if ((InterpreterMode != ACPI_IMODE_LOAD_PASS1) &&
4533446Smrj         (Flags & ACPI_NS_SEARCH_PARENT))
4543446Smrj     {
4553446Smrj         /*
4563446Smrj          * Not found at this level - search parent tree according to the
4573446Smrj          * ACPI specification
4583446Smrj          */
4593446Smrj         Status = AcpiNsSearchParentTree (TargetName, Node, Type, ReturnNode);
4603446Smrj         if (ACPI_SUCCESS (Status))
4613446Smrj         {
4623446Smrj             return_ACPI_STATUS (Status);
4633446Smrj         }
4643446Smrj     }
4653446Smrj 
4663446Smrj     /* In execute mode, just search, never add names. Exit now */
4673446Smrj 
4683446Smrj     if (InterpreterMode == ACPI_IMODE_EXECUTE)
4693446Smrj     {
4703446Smrj         ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
4713446Smrj             "%4.4s Not found in %p [Not adding]\n",
4723446Smrj             ACPI_CAST_PTR (char, &TargetName), Node));
4733446Smrj 
4743446Smrj         return_ACPI_STATUS (AE_NOT_FOUND);
4753446Smrj     }
4763446Smrj 
4773446Smrj     /* Create the new named object */
4783446Smrj 
4793446Smrj     NewNode = AcpiNsCreateNode (TargetName);
4803446Smrj     if (!NewNode)
4813446Smrj     {
4823446Smrj         return_ACPI_STATUS (AE_NO_MEMORY);
4833446Smrj     }
4843446Smrj 
4853446Smrj #ifdef ACPI_ASL_COMPILER
486*9980SDana.Myers@Sun.COM 
487*9980SDana.Myers@Sun.COM     /* Node is an object defined by an External() statement */
488*9980SDana.Myers@Sun.COM 
489*9980SDana.Myers@Sun.COM     if (Flags & ACPI_NS_EXTERNAL ||
490*9980SDana.Myers@Sun.COM         (WalkState && WalkState->Opcode == AML_SCOPE_OP))
4913446Smrj     {
4923446Smrj         NewNode->Flags |= ANOBJ_IS_EXTERNAL;
4933446Smrj     }
4943446Smrj #endif
4953446Smrj 
4967851SDana.Myers@Sun.COM     if (Flags & ACPI_NS_TEMPORARY)
4977851SDana.Myers@Sun.COM     {
4987851SDana.Myers@Sun.COM         NewNode->Flags |= ANOBJ_TEMPORARY;
4997851SDana.Myers@Sun.COM     }
5007851SDana.Myers@Sun.COM 
5013446Smrj     /* Install the new object into the parent's list of children */
5023446Smrj 
5033446Smrj     AcpiNsInstallNode (WalkState, Node, NewNode, Type);
5043446Smrj     *ReturnNode = NewNode;
5053446Smrj     return_ACPI_STATUS (AE_OK);
5063446Smrj }
5073446Smrj 
508