Home | History | Annotate | Line # | Download | only in namespace
      1   1.1    jruoho /*******************************************************************************
      2   1.1    jruoho  *
      3   1.1    jruoho  * Module Name: nsaccess - Top-level functions for accessing ACPI namespace
      4   1.1    jruoho  *
      5   1.1    jruoho  ******************************************************************************/
      6   1.1    jruoho 
      7  1.24  christos /******************************************************************************
      8  1.24  christos  *
      9  1.24  christos  * 1. Copyright Notice
     10  1.24  christos  *
     11  1.25  christos  * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
     12   1.1    jruoho  * All rights reserved.
     13   1.1    jruoho  *
     14  1.24  christos  * 2. License
     15  1.24  christos  *
     16  1.24  christos  * 2.1. This is your license from Intel Corp. under its intellectual property
     17  1.24  christos  * rights. You may have additional license terms from the party that provided
     18  1.24  christos  * you this software, covering your right to use that party's intellectual
     19  1.24  christos  * property rights.
     20  1.24  christos  *
     21  1.24  christos  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
     22  1.24  christos  * copy of the source code appearing in this file ("Covered Code") an
     23  1.24  christos  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
     24  1.24  christos  * base code distributed originally by Intel ("Original Intel Code") to copy,
     25  1.24  christos  * make derivatives, distribute, use and display any portion of the Covered
     26  1.24  christos  * Code in any form, with the right to sublicense such rights; and
     27  1.24  christos  *
     28  1.24  christos  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
     29  1.24  christos  * license (with the right to sublicense), under only those claims of Intel
     30  1.24  christos  * patents that are infringed by the Original Intel Code, to make, use, sell,
     31  1.24  christos  * offer to sell, and import the Covered Code and derivative works thereof
     32  1.24  christos  * solely to the minimum extent necessary to exercise the above copyright
     33  1.24  christos  * license, and in no event shall the patent license extend to any additions
     34  1.24  christos  * to or modifications of the Original Intel Code. No other license or right
     35  1.24  christos  * is granted directly or by implication, estoppel or otherwise;
     36  1.24  christos  *
     37  1.24  christos  * The above copyright and patent license is granted only if the following
     38  1.24  christos  * conditions are met:
     39  1.24  christos  *
     40  1.24  christos  * 3. Conditions
     41  1.24  christos  *
     42  1.24  christos  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
     43  1.24  christos  * Redistribution of source code of any substantial portion of the Covered
     44  1.24  christos  * Code or modification with rights to further distribute source must include
     45  1.24  christos  * the above Copyright Notice, the above License, this list of Conditions,
     46  1.24  christos  * and the following Disclaimer and Export Compliance provision. In addition,
     47  1.24  christos  * Licensee must cause all Covered Code to which Licensee contributes to
     48  1.24  christos  * contain a file documenting the changes Licensee made to create that Covered
     49  1.24  christos  * Code and the date of any change. Licensee must include in that file the
     50  1.24  christos  * documentation of any changes made by any predecessor Licensee. Licensee
     51  1.24  christos  * must include a prominent statement that the modification is derived,
     52  1.24  christos  * directly or indirectly, from Original Intel Code.
     53  1.24  christos  *
     54  1.24  christos  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
     55  1.24  christos  * Redistribution of source code of any substantial portion of the Covered
     56  1.24  christos  * Code or modification without rights to further distribute source must
     57  1.24  christos  * include the following Disclaimer and Export Compliance provision in the
     58  1.24  christos  * documentation and/or other materials provided with distribution. In
     59  1.24  christos  * addition, Licensee may not authorize further sublicense of source of any
     60  1.24  christos  * portion of the Covered Code, and must include terms to the effect that the
     61  1.24  christos  * license from Licensee to its licensee is limited to the intellectual
     62  1.24  christos  * property embodied in the software Licensee provides to its licensee, and
     63  1.24  christos  * not to intellectual property embodied in modifications its licensee may
     64  1.24  christos  * make.
     65  1.24  christos  *
     66  1.24  christos  * 3.3. Redistribution of Executable. Redistribution in executable form of any
     67  1.24  christos  * substantial portion of the Covered Code or modification must reproduce the
     68  1.24  christos  * above Copyright Notice, and the following Disclaimer and Export Compliance
     69  1.24  christos  * provision in the documentation and/or other materials provided with the
     70  1.24  christos  * distribution.
     71  1.24  christos  *
     72  1.24  christos  * 3.4. Intel retains all right, title, and interest in and to the Original
     73  1.24  christos  * Intel Code.
     74  1.24  christos  *
     75  1.24  christos  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
     76  1.24  christos  * Intel shall be used in advertising or otherwise to promote the sale, use or
     77  1.24  christos  * other dealings in products derived from or relating to the Covered Code
     78  1.24  christos  * without prior written authorization from Intel.
     79  1.24  christos  *
     80  1.24  christos  * 4. Disclaimer and Export Compliance
     81  1.24  christos  *
     82  1.24  christos  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
     83  1.24  christos  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
     84  1.24  christos  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
     85  1.24  christos  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
     86  1.24  christos  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
     87  1.24  christos  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
     88  1.24  christos  * PARTICULAR PURPOSE.
     89  1.24  christos  *
     90  1.24  christos  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
     91  1.24  christos  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
     92  1.24  christos  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
     93  1.24  christos  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
     94  1.24  christos  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
     95  1.24  christos  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
     96  1.24  christos  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
     97  1.24  christos  * LIMITED REMEDY.
     98  1.24  christos  *
     99  1.24  christos  * 4.3. Licensee shall not export, either directly or indirectly, any of this
    100  1.24  christos  * software or system incorporating such software without first obtaining any
    101  1.24  christos  * required license or other approval from the U. S. Department of Commerce or
    102  1.24  christos  * any other agency or department of the United States Government. In the
    103  1.24  christos  * event Licensee exports any such software from the United States or
    104  1.24  christos  * re-exports any such software from a foreign destination, Licensee shall
    105  1.24  christos  * ensure that the distribution and export/re-export of the software is in
    106  1.24  christos  * compliance with all laws, regulations, orders, or other restrictions of the
    107  1.24  christos  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
    108  1.24  christos  * any of its subsidiaries will export/re-export any technical data, process,
    109  1.24  christos  * software, or service, directly or indirectly, to any country for which the
    110  1.24  christos  * United States government or any agency thereof requires an export license,
    111  1.24  christos  * other governmental approval, or letter of assurance, without first obtaining
    112  1.24  christos  * such license, approval or letter.
    113  1.24  christos  *
    114  1.24  christos  *****************************************************************************
    115  1.24  christos  *
    116  1.24  christos  * Alternatively, you may choose to be licensed under the terms of the
    117  1.24  christos  * following license:
    118  1.24  christos  *
    119   1.3    jruoho  * Redistribution and use in source and binary forms, with or without
    120   1.3    jruoho  * modification, are permitted provided that the following conditions
    121   1.3    jruoho  * are met:
    122   1.3    jruoho  * 1. Redistributions of source code must retain the above copyright
    123   1.3    jruoho  *    notice, this list of conditions, and the following disclaimer,
    124   1.3    jruoho  *    without modification.
    125   1.3    jruoho  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
    126   1.3    jruoho  *    substantially similar to the "NO WARRANTY" disclaimer below
    127   1.3    jruoho  *    ("Disclaimer") and any redistribution must be conditioned upon
    128   1.3    jruoho  *    including a substantially similar Disclaimer requirement for further
    129   1.3    jruoho  *    binary redistribution.
    130   1.3    jruoho  * 3. Neither the names of the above-listed copyright holders nor the names
    131   1.3    jruoho  *    of any contributors may be used to endorse or promote products derived
    132   1.3    jruoho  *    from this software without specific prior written permission.
    133   1.3    jruoho  *
    134   1.3    jruoho  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    135   1.3    jruoho  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    136  1.20  christos  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    137   1.3    jruoho  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    138  1.24  christos  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    139  1.24  christos  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    140  1.24  christos  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    141  1.24  christos  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    142  1.24  christos  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    143  1.24  christos  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    144  1.24  christos  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    145  1.24  christos  *
    146  1.24  christos  * Alternatively, you may choose to be licensed under the terms of the
    147  1.24  christos  * GNU General Public License ("GPL") version 2 as published by the Free
    148  1.24  christos  * Software Foundation.
    149  1.24  christos  *
    150  1.24  christos  *****************************************************************************/
    151   1.1    jruoho 
    152   1.1    jruoho #include "acpi.h"
    153   1.1    jruoho #include "accommon.h"
    154   1.1    jruoho #include "amlcode.h"
    155   1.1    jruoho #include "acnamesp.h"
    156   1.1    jruoho #include "acdispat.h"
    157   1.1    jruoho 
    158  1.12  christos #ifdef ACPI_ASL_COMPILER
    159  1.12  christos     #include "acdisasm.h"
    160  1.12  christos #endif
    161   1.1    jruoho 
    162   1.1    jruoho #define _COMPONENT          ACPI_NAMESPACE
    163   1.1    jruoho         ACPI_MODULE_NAME    ("nsaccess")
    164   1.1    jruoho 
    165   1.1    jruoho 
    166   1.1    jruoho /*******************************************************************************
    167   1.1    jruoho  *
    168   1.1    jruoho  * FUNCTION:    AcpiNsRootInitialize
    169   1.1    jruoho  *
    170   1.1    jruoho  * PARAMETERS:  None
    171   1.1    jruoho  *
    172   1.1    jruoho  * RETURN:      Status
    173   1.1    jruoho  *
    174   1.1    jruoho  * DESCRIPTION: Allocate and initialize the default root named objects
    175   1.1    jruoho  *
    176   1.1    jruoho  * MUTEX:       Locks namespace for entire execution
    177   1.1    jruoho  *
    178   1.1    jruoho  ******************************************************************************/
    179   1.1    jruoho 
    180   1.1    jruoho ACPI_STATUS
    181   1.1    jruoho AcpiNsRootInitialize (
    182   1.1    jruoho     void)
    183   1.1    jruoho {
    184   1.1    jruoho     ACPI_STATUS                 Status;
    185   1.1    jruoho     const ACPI_PREDEFINED_NAMES *InitVal = NULL;
    186   1.1    jruoho     ACPI_NAMESPACE_NODE         *NewNode;
    187  1.18  christos     ACPI_NAMESPACE_NODE         *PrevNode = NULL;
    188   1.1    jruoho     ACPI_OPERAND_OBJECT         *ObjDesc;
    189   1.1    jruoho     ACPI_STRING                 Val = NULL;
    190  1.21       chs     UINT32                      Name;
    191   1.1    jruoho 
    192   1.1    jruoho 
    193   1.1    jruoho     ACPI_FUNCTION_TRACE (NsRootInitialize);
    194   1.1    jruoho 
    195   1.1    jruoho 
    196   1.1    jruoho     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
    197   1.1    jruoho     if (ACPI_FAILURE (Status))
    198   1.1    jruoho     {
    199   1.1    jruoho         return_ACPI_STATUS (Status);
    200   1.1    jruoho     }
    201   1.1    jruoho 
    202   1.1    jruoho     /*
    203   1.1    jruoho      * The global root ptr is initially NULL, so a non-NULL value indicates
    204   1.1    jruoho      * that AcpiNsRootInitialize() has already been called; just return.
    205   1.1    jruoho      */
    206   1.1    jruoho     if (AcpiGbl_RootNode)
    207   1.1    jruoho     {
    208   1.1    jruoho         Status = AE_OK;
    209   1.1    jruoho         goto UnlockAndExit;
    210   1.1    jruoho     }
    211   1.1    jruoho 
    212   1.1    jruoho     /*
    213   1.1    jruoho      * Tell the rest of the subsystem that the root is initialized
    214   1.1    jruoho      * (This is OK because the namespace is locked)
    215   1.1    jruoho      */
    216   1.1    jruoho     AcpiGbl_RootNode = &AcpiGbl_RootNodeStruct;
    217   1.1    jruoho 
    218  1.18  christos     /* Enter the predefined names in the name table */
    219   1.1    jruoho 
    220   1.1    jruoho     ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
    221   1.1    jruoho         "Entering predefined entries into namespace\n"));
    222   1.1    jruoho 
    223  1.18  christos     /*
    224  1.18  christos      * Create the initial (default) namespace.
    225  1.18  christos      * This namespace looks like something similar to this:
    226  1.18  christos      *
    227  1.18  christos      *   ACPI Namespace (from Namespace Root):
    228  1.18  christos      *    0  _GPE Scope        00203160 00
    229  1.18  christos      *    0  _PR_ Scope        002031D0 00
    230  1.18  christos      *    0  _SB_ Device       00203240 00 Notify Object: 0020ADD8
    231  1.18  christos      *    0  _SI_ Scope        002032B0 00
    232  1.18  christos      *    0  _TZ_ Device       00203320 00
    233  1.18  christos      *    0  _REV Integer      00203390 00 = 0000000000000002
    234  1.18  christos      *    0  _OS_ String       00203488 00 Len 14 "Microsoft Windows NT"
    235  1.18  christos      *    0  _GL_ Mutex        00203580 00 Object 002035F0
    236  1.18  christos      *    0  _OSI Method       00203678 00 Args 1 Len 0000 Aml 00000000
    237  1.18  christos      */
    238   1.1    jruoho     for (InitVal = AcpiGbl_PreDefinedNames; InitVal->Name; InitVal++)
    239   1.1    jruoho     {
    240  1.18  christos         Status = AE_OK;
    241  1.18  christos 
    242   1.1    jruoho         /* _OSI is optional for now, will be permanent later */
    243   1.1    jruoho 
    244   1.7  christos         if (!strcmp (InitVal->Name, "_OSI") && !AcpiGbl_CreateOsiMethod)
    245   1.1    jruoho         {
    246   1.1    jruoho             continue;
    247   1.1    jruoho         }
    248   1.1    jruoho 
    249  1.18  christos         /*
    250  1.18  christos          * Create, init, and link the new predefined name
    251  1.18  christos          * Note: No need to use AcpiNsLookup here because all the
    252  1.18  christos          * predefined names are at the root level. It is much easier to
    253  1.18  christos          * just create and link the new node(s) here.
    254  1.18  christos          */
    255  1.21       chs         memcpy(&Name, InitVal->Name, sizeof(Name));
    256  1.21       chs         NewNode = AcpiNsCreateNode (Name);
    257  1.18  christos         if (!NewNode)
    258  1.18  christos         {
    259  1.18  christos             Status = AE_NO_MEMORY;
    260  1.18  christos             goto UnlockAndExit;
    261  1.18  christos         }
    262  1.18  christos 
    263  1.18  christos         NewNode->DescriptorType = ACPI_DESC_TYPE_NAMED;
    264  1.18  christos         NewNode->Type = InitVal->Type;
    265  1.18  christos 
    266  1.18  christos         if (!PrevNode)
    267  1.18  christos         {
    268  1.18  christos             AcpiGbl_RootNodeStruct.Child = NewNode;
    269  1.18  christos         }
    270  1.18  christos         else
    271   1.1    jruoho         {
    272  1.18  christos             PrevNode->Peer = NewNode;
    273   1.1    jruoho         }
    274   1.1    jruoho 
    275  1.18  christos         NewNode->Parent = &AcpiGbl_RootNodeStruct;
    276  1.18  christos         PrevNode = NewNode;
    277  1.18  christos 
    278   1.1    jruoho         /*
    279   1.1    jruoho          * Name entered successfully. If entry in PreDefinedNames[] specifies
    280   1.1    jruoho          * an initial value, create the initial value.
    281   1.1    jruoho          */
    282   1.1    jruoho         if (InitVal->Val)
    283   1.1    jruoho         {
    284   1.1    jruoho             Status = AcpiOsPredefinedOverride (InitVal, &Val);
    285   1.1    jruoho             if (ACPI_FAILURE (Status))
    286   1.1    jruoho             {
    287   1.1    jruoho                 ACPI_ERROR ((AE_INFO,
    288   1.1    jruoho                     "Could not override predefined %s",
    289   1.1    jruoho                     InitVal->Name));
    290   1.1    jruoho             }
    291   1.1    jruoho 
    292   1.1    jruoho             if (!Val)
    293   1.1    jruoho             {
    294   1.2    jruoho                 Val = __UNCONST(InitVal->Val);
    295   1.1    jruoho             }
    296   1.1    jruoho 
    297   1.1    jruoho             /*
    298   1.1    jruoho              * Entry requests an initial value, allocate a
    299   1.1    jruoho              * descriptor for it.
    300   1.1    jruoho              */
    301   1.1    jruoho             ObjDesc = AcpiUtCreateInternalObject (InitVal->Type);
    302   1.1    jruoho             if (!ObjDesc)
    303   1.1    jruoho             {
    304   1.1    jruoho                 Status = AE_NO_MEMORY;
    305   1.1    jruoho                 goto UnlockAndExit;
    306   1.1    jruoho             }
    307   1.1    jruoho 
    308   1.1    jruoho             /*
    309   1.1    jruoho              * Convert value string from table entry to
    310   1.1    jruoho              * internal representation. Only types actually
    311   1.1    jruoho              * used for initial values are implemented here.
    312   1.1    jruoho              */
    313   1.1    jruoho             switch (InitVal->Type)
    314   1.1    jruoho             {
    315   1.1    jruoho             case ACPI_TYPE_METHOD:
    316   1.4  christos 
    317   1.1    jruoho                 ObjDesc->Method.ParamCount = (UINT8) ACPI_TO_INTEGER (Val);
    318   1.1    jruoho                 ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID;
    319   1.1    jruoho 
    320   1.1    jruoho #if defined (ACPI_ASL_COMPILER)
    321   1.1    jruoho 
    322   1.1    jruoho                 /* Save the parameter count for the iASL compiler */
    323   1.1    jruoho 
    324   1.1    jruoho                 NewNode->Value = ObjDesc->Method.ParamCount;
    325   1.1    jruoho #else
    326  1.18  christos                 /* Mark this as a very SPECIAL method (_OSI) */
    327   1.1    jruoho 
    328   1.3    jruoho                 ObjDesc->Method.InfoFlags = ACPI_METHOD_INTERNAL_ONLY;
    329   1.3    jruoho                 ObjDesc->Method.Dispatch.Implementation = AcpiUtOsiImplementation;
    330   1.1    jruoho #endif
    331   1.1    jruoho                 break;
    332   1.1    jruoho 
    333   1.1    jruoho             case ACPI_TYPE_INTEGER:
    334   1.1    jruoho 
    335   1.1    jruoho                 ObjDesc->Integer.Value = ACPI_TO_INTEGER (Val);
    336   1.1    jruoho                 break;
    337   1.1    jruoho 
    338   1.1    jruoho             case ACPI_TYPE_STRING:
    339   1.1    jruoho 
    340   1.1    jruoho                 /* Build an object around the static string */
    341   1.1    jruoho 
    342   1.7  christos                 ObjDesc->String.Length = (UINT32) strlen (Val);
    343   1.1    jruoho                 ObjDesc->String.Pointer = Val;
    344   1.1    jruoho                 ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER;
    345   1.1    jruoho                 break;
    346   1.1    jruoho 
    347   1.1    jruoho             case ACPI_TYPE_MUTEX:
    348   1.1    jruoho 
    349   1.1    jruoho                 ObjDesc->Mutex.Node = NewNode;
    350   1.1    jruoho                 ObjDesc->Mutex.SyncLevel = (UINT8) (ACPI_TO_INTEGER (Val) - 1);
    351   1.1    jruoho 
    352   1.1    jruoho                 /* Create a mutex */
    353   1.1    jruoho 
    354   1.1    jruoho                 Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex);
    355   1.1    jruoho                 if (ACPI_FAILURE (Status))
    356   1.1    jruoho                 {
    357   1.1    jruoho                     AcpiUtRemoveReference (ObjDesc);
    358   1.1    jruoho                     goto UnlockAndExit;
    359   1.1    jruoho                 }
    360   1.1    jruoho 
    361   1.1    jruoho                 /* Special case for ACPI Global Lock */
    362   1.1    jruoho 
    363   1.7  christos                 if (strcmp (InitVal->Name, "_GL_") == 0)
    364   1.1    jruoho                 {
    365   1.1    jruoho                     AcpiGbl_GlobalLockMutex = ObjDesc;
    366   1.1    jruoho 
    367   1.1    jruoho                     /* Create additional counting semaphore for global lock */
    368   1.1    jruoho 
    369   1.1    jruoho                     Status = AcpiOsCreateSemaphore (
    370   1.8  christos                         1, 0, &AcpiGbl_GlobalLockSemaphore);
    371   1.1    jruoho                     if (ACPI_FAILURE (Status))
    372   1.1    jruoho                     {
    373   1.1    jruoho                         AcpiUtRemoveReference (ObjDesc);
    374   1.1    jruoho                         goto UnlockAndExit;
    375   1.1    jruoho                     }
    376   1.1    jruoho                 }
    377   1.1    jruoho                 break;
    378   1.1    jruoho 
    379   1.1    jruoho             default:
    380   1.1    jruoho 
    381   1.1    jruoho                 ACPI_ERROR ((AE_INFO, "Unsupported initial type value 0x%X",
    382   1.1    jruoho                     InitVal->Type));
    383   1.1    jruoho                 AcpiUtRemoveReference (ObjDesc);
    384   1.1    jruoho                 ObjDesc = NULL;
    385   1.1    jruoho                 continue;
    386   1.1    jruoho             }
    387   1.1    jruoho 
    388   1.1    jruoho             /* Store pointer to value descriptor in the Node */
    389   1.1    jruoho 
    390   1.1    jruoho             Status = AcpiNsAttachObject (NewNode, ObjDesc,
    391   1.8  christos                 ObjDesc->Common.Type);
    392   1.1    jruoho 
    393   1.1    jruoho             /* Remove local reference to the object */
    394   1.1    jruoho 
    395   1.1    jruoho             AcpiUtRemoveReference (ObjDesc);
    396   1.1    jruoho         }
    397   1.1    jruoho     }
    398   1.1    jruoho 
    399   1.1    jruoho UnlockAndExit:
    400   1.1    jruoho     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
    401   1.1    jruoho 
    402   1.1    jruoho     /* Save a handle to "_GPE", it is always present */
    403   1.1    jruoho 
    404   1.1    jruoho     if (ACPI_SUCCESS (Status))
    405   1.1    jruoho     {
    406   1.1    jruoho         Status = AcpiNsGetNode (NULL, "\\_GPE", ACPI_NS_NO_UPSEARCH,
    407   1.8  christos             &AcpiGbl_FadtGpeDevice);
    408   1.1    jruoho     }
    409   1.1    jruoho 
    410   1.1    jruoho     return_ACPI_STATUS (Status);
    411   1.1    jruoho }
    412   1.1    jruoho 
    413   1.1    jruoho 
    414   1.1    jruoho /*******************************************************************************
    415   1.1    jruoho  *
    416   1.1    jruoho  * FUNCTION:    AcpiNsLookup
    417   1.1    jruoho  *
    418   1.1    jruoho  * PARAMETERS:  ScopeInfo       - Current scope info block
    419   1.1    jruoho  *              Pathname        - Search pathname, in internal format
    420   1.1    jruoho  *                                (as represented in the AML stream)
    421   1.1    jruoho  *              Type            - Type associated with name
    422   1.1    jruoho  *              InterpreterMode - IMODE_LOAD_PASS2 => add name if not found
    423   1.1    jruoho  *              Flags           - Flags describing the search restrictions
    424   1.1    jruoho  *              WalkState       - Current state of the walk
    425   1.1    jruoho  *              ReturnNode      - Where the Node is placed (if found
    426   1.1    jruoho  *                                or created successfully)
    427   1.1    jruoho  *
    428   1.1    jruoho  * RETURN:      Status
    429   1.1    jruoho  *
    430   1.1    jruoho  * DESCRIPTION: Find or enter the passed name in the name space.
    431   1.1    jruoho  *              Log an error if name not found in Exec mode.
    432   1.1    jruoho  *
    433   1.1    jruoho  * MUTEX:       Assumes namespace is locked.
    434   1.1    jruoho  *
    435   1.1    jruoho  ******************************************************************************/
    436   1.1    jruoho 
    437   1.1    jruoho ACPI_STATUS
    438   1.1    jruoho AcpiNsLookup (
    439   1.1    jruoho     ACPI_GENERIC_STATE      *ScopeInfo,
    440   1.1    jruoho     char                    *Pathname,
    441   1.1    jruoho     ACPI_OBJECT_TYPE        Type,
    442   1.1    jruoho     ACPI_INTERPRETER_MODE   InterpreterMode,
    443   1.1    jruoho     UINT32                  Flags,
    444   1.1    jruoho     ACPI_WALK_STATE         *WalkState,
    445   1.1    jruoho     ACPI_NAMESPACE_NODE     **ReturnNode)
    446   1.1    jruoho {
    447   1.1    jruoho     ACPI_STATUS             Status;
    448   1.1    jruoho     char                    *Path = Pathname;
    449  1.12  christos     char                    *ExternalPath;
    450   1.1    jruoho     ACPI_NAMESPACE_NODE     *PrefixNode;
    451   1.1    jruoho     ACPI_NAMESPACE_NODE     *CurrentNode = NULL;
    452   1.1    jruoho     ACPI_NAMESPACE_NODE     *ThisNode = NULL;
    453   1.1    jruoho     UINT32                  NumSegments;
    454   1.1    jruoho     UINT32                  NumCarats;
    455   1.1    jruoho     ACPI_NAME               SimpleName;
    456   1.1    jruoho     ACPI_OBJECT_TYPE        TypeToCheckFor;
    457   1.1    jruoho     ACPI_OBJECT_TYPE        ThisSearchType;
    458   1.1    jruoho     UINT32                  SearchParentFlag = ACPI_NS_SEARCH_PARENT;
    459   1.1    jruoho     UINT32                  LocalFlags;
    460  1.16  christos     ACPI_INTERPRETER_MODE   LocalInterpreterMode;
    461   1.1    jruoho 
    462   1.1    jruoho 
    463   1.1    jruoho     ACPI_FUNCTION_TRACE (NsLookup);
    464   1.1    jruoho 
    465   1.1    jruoho 
    466   1.1    jruoho     if (!ReturnNode)
    467   1.1    jruoho     {
    468   1.1    jruoho         return_ACPI_STATUS (AE_BAD_PARAMETER);
    469   1.1    jruoho     }
    470   1.1    jruoho 
    471   1.7  christos     LocalFlags = Flags &
    472   1.7  christos         ~(ACPI_NS_ERROR_IF_FOUND | ACPI_NS_OVERRIDE_IF_FOUND |
    473   1.7  christos           ACPI_NS_SEARCH_PARENT);
    474   1.1    jruoho     *ReturnNode = ACPI_ENTRY_NOT_FOUND;
    475   1.1    jruoho     AcpiGbl_NsLookupCount++;
    476   1.1    jruoho 
    477   1.1    jruoho     if (!AcpiGbl_RootNode)
    478   1.1    jruoho     {
    479   1.1    jruoho         return_ACPI_STATUS (AE_NO_NAMESPACE);
    480   1.1    jruoho     }
    481   1.1    jruoho 
    482   1.1    jruoho     /* Get the prefix scope. A null scope means use the root scope */
    483   1.1    jruoho 
    484   1.1    jruoho     if ((!ScopeInfo) ||
    485   1.1    jruoho         (!ScopeInfo->Scope.Node))
    486   1.1    jruoho     {
    487   1.1    jruoho         ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
    488   1.1    jruoho             "Null scope prefix, using root node (%p)\n",
    489   1.1    jruoho             AcpiGbl_RootNode));
    490   1.1    jruoho 
    491   1.1    jruoho         PrefixNode = AcpiGbl_RootNode;
    492   1.1    jruoho     }
    493   1.1    jruoho     else
    494   1.1    jruoho     {
    495   1.1    jruoho         PrefixNode = ScopeInfo->Scope.Node;
    496   1.1    jruoho         if (ACPI_GET_DESCRIPTOR_TYPE (PrefixNode) != ACPI_DESC_TYPE_NAMED)
    497   1.1    jruoho         {
    498   1.1    jruoho             ACPI_ERROR ((AE_INFO, "%p is not a namespace node [%s]",
    499   1.1    jruoho                 PrefixNode, AcpiUtGetDescriptorName (PrefixNode)));
    500   1.1    jruoho             return_ACPI_STATUS (AE_AML_INTERNAL);
    501   1.1    jruoho         }
    502   1.1    jruoho 
    503   1.1    jruoho         if (!(Flags & ACPI_NS_PREFIX_IS_SCOPE))
    504   1.1    jruoho         {
    505   1.1    jruoho             /*
    506   1.1    jruoho              * This node might not be a actual "scope" node (such as a
    507   1.1    jruoho              * Device/Method, etc.)  It could be a Package or other object
    508   1.1    jruoho              * node. Backup up the tree to find the containing scope node.
    509   1.1    jruoho              */
    510   1.1    jruoho             while (!AcpiNsOpensScope (PrefixNode->Type) &&
    511   1.1    jruoho                     PrefixNode->Type != ACPI_TYPE_ANY)
    512   1.1    jruoho             {
    513   1.1    jruoho                 PrefixNode = PrefixNode->Parent;
    514   1.1    jruoho             }
    515   1.1    jruoho         }
    516   1.1    jruoho     }
    517   1.1    jruoho 
    518   1.1    jruoho     /* Save type. TBD: may be no longer necessary */
    519   1.1    jruoho 
    520   1.1    jruoho     TypeToCheckFor = Type;
    521   1.1    jruoho 
    522   1.1    jruoho     /*
    523   1.1    jruoho      * Begin examination of the actual pathname
    524   1.1    jruoho      */
    525   1.1    jruoho     if (!Pathname)
    526   1.1    jruoho     {
    527   1.1    jruoho         /* A Null NamePath is allowed and refers to the root */
    528   1.1    jruoho 
    529   1.1    jruoho         NumSegments = 0;
    530   1.1    jruoho         ThisNode = AcpiGbl_RootNode;
    531   1.2    jruoho         Path = __UNCONST("");
    532   1.1    jruoho 
    533   1.1    jruoho         ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
    534   1.1    jruoho             "Null Pathname (Zero segments), Flags=%X\n", Flags));
    535   1.1    jruoho     }
    536   1.1    jruoho     else
    537   1.1    jruoho     {
    538   1.1    jruoho         /*
    539   1.1    jruoho          * Name pointer is valid (and must be in internal name format)
    540   1.1    jruoho          *
    541   1.1    jruoho          * Check for scope prefixes:
    542   1.1    jruoho          *
    543   1.1    jruoho          * As represented in the AML stream, a namepath consists of an
    544   1.1    jruoho          * optional scope prefix followed by a name segment part.
    545   1.1    jruoho          *
    546   1.1    jruoho          * If present, the scope prefix is either a Root Prefix (in
    547   1.1    jruoho          * which case the name is fully qualified), or one or more
    548   1.1    jruoho          * Parent Prefixes (in which case the name's scope is relative
    549   1.1    jruoho          * to the current scope).
    550   1.1    jruoho          */
    551   1.1    jruoho         if (*Path == (UINT8) AML_ROOT_PREFIX)
    552   1.1    jruoho         {
    553   1.1    jruoho             /* Pathname is fully qualified, start from the root */
    554   1.1    jruoho 
    555   1.1    jruoho             ThisNode = AcpiGbl_RootNode;
    556   1.1    jruoho             SearchParentFlag = ACPI_NS_NO_UPSEARCH;
    557   1.1    jruoho 
    558   1.1    jruoho             /* Point to name segment part */
    559   1.1    jruoho 
    560   1.1    jruoho             Path++;
    561   1.1    jruoho 
    562   1.1    jruoho             ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
    563   1.1    jruoho                 "Path is absolute from root [%p]\n", ThisNode));
    564   1.1    jruoho         }
    565   1.1    jruoho         else
    566   1.1    jruoho         {
    567   1.1    jruoho             /* Pathname is relative to current scope, start there */
    568   1.1    jruoho 
    569   1.1    jruoho             ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
    570   1.1    jruoho                 "Searching relative to prefix scope [%4.4s] (%p)\n",
    571   1.1    jruoho                 AcpiUtGetNodeName (PrefixNode), PrefixNode));
    572   1.1    jruoho 
    573   1.1    jruoho             /*
    574   1.1    jruoho              * Handle multiple Parent Prefixes (carat) by just getting
    575   1.1    jruoho              * the parent node for each prefix instance.
    576   1.1    jruoho              */
    577   1.1    jruoho             ThisNode = PrefixNode;
    578   1.1    jruoho             NumCarats = 0;
    579   1.1    jruoho             while (*Path == (UINT8) AML_PARENT_PREFIX)
    580   1.1    jruoho             {
    581   1.1    jruoho                 /* Name is fully qualified, no search rules apply */
    582   1.1    jruoho 
    583   1.1    jruoho                 SearchParentFlag = ACPI_NS_NO_UPSEARCH;
    584   1.1    jruoho 
    585   1.1    jruoho                 /*
    586   1.1    jruoho                  * Point past this prefix to the name segment
    587   1.1    jruoho                  * part or the next Parent Prefix
    588   1.1    jruoho                  */
    589   1.1    jruoho                 Path++;
    590   1.1    jruoho 
    591   1.1    jruoho                 /* Backup to the parent node */
    592   1.1    jruoho 
    593   1.1    jruoho                 NumCarats++;
    594   1.1    jruoho                 ThisNode = ThisNode->Parent;
    595   1.1    jruoho                 if (!ThisNode)
    596   1.1    jruoho                 {
    597  1.12  christos                     /*
    598  1.12  christos                      * Current scope has no parent scope. Externalize
    599  1.12  christos                      * the internal path for error message.
    600  1.12  christos                      */
    601  1.12  christos                     Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, Pathname,
    602  1.12  christos                         NULL, &ExternalPath);
    603  1.12  christos                     if (ACPI_SUCCESS (Status))
    604  1.12  christos                     {
    605  1.12  christos                         ACPI_ERROR ((AE_INFO,
    606  1.12  christos                             "%s: Path has too many parent prefixes (^)",
    607  1.12  christos                             ExternalPath));
    608  1.12  christos 
    609  1.12  christos                         ACPI_FREE (ExternalPath);
    610  1.12  christos                     }
    611   1.1    jruoho 
    612   1.1    jruoho                     return_ACPI_STATUS (AE_NOT_FOUND);
    613   1.1    jruoho                 }
    614   1.1    jruoho             }
    615   1.1    jruoho 
    616   1.1    jruoho             if (SearchParentFlag == ACPI_NS_NO_UPSEARCH)
    617   1.1    jruoho             {
    618   1.1    jruoho                 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
    619   1.1    jruoho                     "Search scope is [%4.4s], path has %u carat(s)\n",
    620   1.1    jruoho                     AcpiUtGetNodeName (ThisNode), NumCarats));
    621   1.1    jruoho             }
    622   1.1    jruoho         }
    623   1.1    jruoho 
    624   1.1    jruoho         /*
    625   1.1    jruoho          * Determine the number of ACPI name segments in this pathname.
    626   1.1    jruoho          *
    627   1.1    jruoho          * The segment part consists of either:
    628   1.1    jruoho          *  - A Null name segment (0)
    629   1.1    jruoho          *  - A DualNamePrefix followed by two 4-byte name segments
    630   1.1    jruoho          *  - A MultiNamePrefix followed by a byte indicating the
    631   1.1    jruoho          *      number of segments and the segments themselves.
    632   1.1    jruoho          *  - A single 4-byte name segment
    633   1.1    jruoho          *
    634   1.1    jruoho          * Examine the name prefix opcode, if any, to determine the number of
    635   1.1    jruoho          * segments.
    636   1.1    jruoho          */
    637   1.1    jruoho         switch (*Path)
    638   1.1    jruoho         {
    639   1.1    jruoho         case 0:
    640   1.1    jruoho             /*
    641   1.1    jruoho              * Null name after a root or parent prefixes. We already
    642   1.1    jruoho              * have the correct target node and there are no name segments.
    643   1.1    jruoho              */
    644   1.1    jruoho             NumSegments  = 0;
    645   1.1    jruoho             Type = ThisNode->Type;
    646   1.1    jruoho 
    647   1.1    jruoho             ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
    648   1.1    jruoho                 "Prefix-only Pathname (Zero name segments), Flags=%X\n",
    649   1.1    jruoho                 Flags));
    650   1.1    jruoho             break;
    651   1.1    jruoho 
    652   1.1    jruoho         case AML_DUAL_NAME_PREFIX:
    653   1.1    jruoho 
    654   1.1    jruoho             /* More than one NameSeg, search rules do not apply */
    655   1.1    jruoho 
    656   1.1    jruoho             SearchParentFlag = ACPI_NS_NO_UPSEARCH;
    657   1.1    jruoho 
    658   1.1    jruoho             /* Two segments, point to first name segment */
    659   1.1    jruoho 
    660   1.1    jruoho             NumSegments = 2;
    661   1.1    jruoho             Path++;
    662   1.1    jruoho 
    663   1.1    jruoho             ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
    664   1.1    jruoho                 "Dual Pathname (2 segments, Flags=%X)\n", Flags));
    665   1.1    jruoho             break;
    666   1.1    jruoho 
    667  1.11  christos         case AML_MULTI_NAME_PREFIX:
    668   1.1    jruoho 
    669   1.1    jruoho             /* More than one NameSeg, search rules do not apply */
    670   1.1    jruoho 
    671   1.1    jruoho             SearchParentFlag = ACPI_NS_NO_UPSEARCH;
    672   1.1    jruoho 
    673   1.1    jruoho             /* Extract segment count, point to first name segment */
    674   1.1    jruoho 
    675   1.1    jruoho             Path++;
    676   1.1    jruoho             NumSegments = (UINT32) (UINT8) *Path;
    677   1.1    jruoho             Path++;
    678   1.1    jruoho 
    679   1.1    jruoho             ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
    680   1.1    jruoho                 "Multi Pathname (%u Segments, Flags=%X)\n",
    681   1.1    jruoho                 NumSegments, Flags));
    682   1.1    jruoho             break;
    683   1.1    jruoho 
    684   1.1    jruoho         default:
    685   1.1    jruoho             /*
    686   1.1    jruoho              * Not a Null name, no Dual or Multi prefix, hence there is
    687   1.1    jruoho              * only one name segment and Pathname is already pointing to it.
    688   1.1    jruoho              */
    689   1.1    jruoho             NumSegments = 1;
    690   1.1    jruoho 
    691   1.1    jruoho             ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
    692   1.1    jruoho                 "Simple Pathname (1 segment, Flags=%X)\n", Flags));
    693   1.1    jruoho             break;
    694   1.1    jruoho         }
    695   1.1    jruoho 
    696   1.1    jruoho         ACPI_DEBUG_EXEC (AcpiNsPrintPathname (NumSegments, Path));
    697   1.1    jruoho     }
    698   1.1    jruoho 
    699   1.1    jruoho 
    700   1.1    jruoho     /*
    701   1.1    jruoho      * Search namespace for each segment of the name. Loop through and
    702   1.1    jruoho      * verify (or add to the namespace) each name segment.
    703   1.1    jruoho      *
    704   1.1    jruoho      * The object type is significant only at the last name
    705   1.1    jruoho      * segment. (We don't care about the types along the path, only
    706   1.1    jruoho      * the type of the final target object.)
    707   1.1    jruoho      */
    708   1.1    jruoho     ThisSearchType = ACPI_TYPE_ANY;
    709   1.1    jruoho     CurrentNode = ThisNode;
    710  1.16  christos 
    711   1.1    jruoho     while (NumSegments && CurrentNode)
    712   1.1    jruoho     {
    713   1.1    jruoho         NumSegments--;
    714   1.1    jruoho         if (!NumSegments)
    715   1.1    jruoho         {
    716   1.1    jruoho             /* This is the last segment, enable typechecking */
    717   1.1    jruoho 
    718   1.1    jruoho             ThisSearchType = Type;
    719   1.1    jruoho 
    720   1.1    jruoho             /*
    721   1.1    jruoho              * Only allow automatic parent search (search rules) if the caller
    722   1.1    jruoho              * requested it AND we have a single, non-fully-qualified NameSeg
    723   1.1    jruoho              */
    724   1.1    jruoho             if ((SearchParentFlag != ACPI_NS_NO_UPSEARCH) &&
    725   1.1    jruoho                 (Flags & ACPI_NS_SEARCH_PARENT))
    726   1.1    jruoho             {
    727   1.1    jruoho                 LocalFlags |= ACPI_NS_SEARCH_PARENT;
    728   1.1    jruoho             }
    729   1.1    jruoho 
    730   1.1    jruoho             /* Set error flag according to caller */
    731   1.1    jruoho 
    732   1.1    jruoho             if (Flags & ACPI_NS_ERROR_IF_FOUND)
    733   1.1    jruoho             {
    734   1.1    jruoho                 LocalFlags |= ACPI_NS_ERROR_IF_FOUND;
    735   1.1    jruoho             }
    736   1.7  christos 
    737   1.7  christos             /* Set override flag according to caller */
    738   1.7  christos 
    739   1.7  christos             if (Flags & ACPI_NS_OVERRIDE_IF_FOUND)
    740   1.7  christos             {
    741   1.7  christos                 LocalFlags |= ACPI_NS_OVERRIDE_IF_FOUND;
    742   1.7  christos             }
    743   1.1    jruoho         }
    744   1.1    jruoho 
    745  1.16  christos         /* Handle opcodes that create a new NameSeg via a full NamePath */
    746  1.16  christos 
    747  1.16  christos         LocalInterpreterMode = InterpreterMode;
    748  1.16  christos         if ((Flags & ACPI_NS_PREFIX_MUST_EXIST) && (NumSegments > 0))
    749  1.16  christos         {
    750  1.16  christos             /* Every element of the path must exist (except for the final NameSeg) */
    751  1.16  christos 
    752  1.16  christos             LocalInterpreterMode = ACPI_IMODE_EXECUTE;
    753  1.16  christos         }
    754  1.16  christos 
    755   1.1    jruoho         /* Extract one ACPI name from the front of the pathname */
    756   1.1    jruoho 
    757   1.1    jruoho         ACPI_MOVE_32_TO_32 (&SimpleName, Path);
    758   1.1    jruoho 
    759   1.1    jruoho         /* Try to find the single (4 character) ACPI name */
    760   1.1    jruoho 
    761   1.1    jruoho         Status = AcpiNsSearchAndEnter (SimpleName, WalkState, CurrentNode,
    762  1.16  christos             LocalInterpreterMode, ThisSearchType, LocalFlags, &ThisNode);
    763   1.1    jruoho         if (ACPI_FAILURE (Status))
    764   1.1    jruoho         {
    765   1.1    jruoho             if (Status == AE_NOT_FOUND)
    766   1.1    jruoho             {
    767  1.16  christos #if !defined ACPI_ASL_COMPILER /* Note: iASL reports this error by itself, not needed here */
    768  1.16  christos                 if (Flags & ACPI_NS_PREFIX_MUST_EXIST)
    769  1.16  christos                 {
    770  1.16  christos                     AcpiOsPrintf (ACPI_MSG_BIOS_ERROR
    771  1.18  christos                         "Object does not exist: %4.4s\n", (char *) &SimpleName);
    772  1.16  christos                 }
    773  1.16  christos #endif
    774   1.1    jruoho                 /* Name not found in ACPI namespace */
    775   1.1    jruoho 
    776   1.1    jruoho                 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
    777   1.1    jruoho                     "Name [%4.4s] not found in scope [%4.4s] %p\n",
    778   1.1    jruoho                     (char *) &SimpleName, (char *) &CurrentNode->Name,
    779   1.1    jruoho                     CurrentNode));
    780   1.1    jruoho             }
    781   1.1    jruoho 
    782  1.15  christos #ifdef ACPI_EXEC_APP
    783  1.15  christos             if ((Status == AE_ALREADY_EXISTS) &&
    784  1.15  christos                 (ThisNode->Flags & ANOBJ_NODE_EARLY_INIT))
    785  1.15  christos             {
    786  1.15  christos                 ThisNode->Flags &= ~ANOBJ_NODE_EARLY_INIT;
    787  1.15  christos                 Status = AE_OK;
    788  1.15  christos             }
    789  1.15  christos #endif
    790  1.15  christos 
    791  1.12  christos #ifdef ACPI_ASL_COMPILER
    792  1.12  christos             /*
    793  1.12  christos              * If this ACPI name already exists within the namespace as an
    794  1.12  christos              * external declaration, then mark the external as a conflicting
    795  1.12  christos              * declaration and proceed to process the current node as if it did
    796  1.12  christos              * not exist in the namespace. If this node is not processed as
    797  1.12  christos              * normal, then it could cause improper namespace resolution
    798  1.12  christos              * by failing to open a new scope.
    799  1.12  christos              */
    800  1.12  christos             if (AcpiGbl_DisasmFlag &&
    801  1.12  christos                 (Status == AE_ALREADY_EXISTS) &&
    802  1.12  christos                 ((ThisNode->Flags & ANOBJ_IS_EXTERNAL) ||
    803  1.12  christos                     (WalkState && WalkState->Opcode == AML_EXTERNAL_OP)))
    804  1.12  christos             {
    805  1.12  christos                 ThisNode->Flags &= ~ANOBJ_IS_EXTERNAL;
    806  1.12  christos                 ThisNode->Type = (UINT8)ThisSearchType;
    807  1.12  christos                 if (WalkState->Opcode != AML_EXTERNAL_OP)
    808  1.12  christos                 {
    809  1.12  christos                     AcpiDmMarkExternalConflict (ThisNode);
    810  1.12  christos                 }
    811  1.12  christos                 break;
    812  1.12  christos             }
    813  1.12  christos #endif
    814  1.12  christos 
    815   1.1    jruoho             *ReturnNode = ThisNode;
    816   1.1    jruoho             return_ACPI_STATUS (Status);
    817   1.1    jruoho         }
    818   1.1    jruoho 
    819   1.1    jruoho         /* More segments to follow? */
    820   1.1    jruoho 
    821   1.1    jruoho         if (NumSegments > 0)
    822   1.1    jruoho         {
    823   1.1    jruoho             /*
    824   1.1    jruoho              * If we have an alias to an object that opens a scope (such as a
    825   1.1    jruoho              * device or processor), we need to dereference the alias here so
    826   1.1    jruoho              * that we can access any children of the original node (via the
    827   1.1    jruoho              * remaining segments).
    828   1.1    jruoho              */
    829   1.1    jruoho             if (ThisNode->Type == ACPI_TYPE_LOCAL_ALIAS)
    830   1.1    jruoho             {
    831   1.1    jruoho                 if (!ThisNode->Object)
    832   1.1    jruoho                 {
    833   1.1    jruoho                     return_ACPI_STATUS (AE_NOT_EXIST);
    834   1.1    jruoho                 }
    835   1.1    jruoho 
    836   1.1    jruoho                 if (AcpiNsOpensScope (((ACPI_NAMESPACE_NODE *)
    837   1.1    jruoho                         ThisNode->Object)->Type))
    838   1.1    jruoho                 {
    839   1.1    jruoho                     ThisNode = (ACPI_NAMESPACE_NODE *) ThisNode->Object;
    840   1.1    jruoho                 }
    841   1.1    jruoho             }
    842   1.1    jruoho         }
    843   1.1    jruoho 
    844   1.1    jruoho         /* Special handling for the last segment (NumSegments == 0) */
    845   1.1    jruoho 
    846   1.1    jruoho         else
    847   1.1    jruoho         {
    848   1.1    jruoho             /*
    849   1.1    jruoho              * Sanity typecheck of the target object:
    850   1.1    jruoho              *
    851   1.1    jruoho              * If 1) This is the last segment (NumSegments == 0)
    852   1.1    jruoho              *    2) And we are looking for a specific type
    853   1.1    jruoho              *       (Not checking for TYPE_ANY)
    854   1.1    jruoho              *    3) Which is not an alias
    855   1.1    jruoho              *    4) Which is not a local type (TYPE_SCOPE)
    856   1.1    jruoho              *    5) And the type of target object is known (not TYPE_ANY)
    857   1.1    jruoho              *    6) And target object does not match what we are looking for
    858   1.1    jruoho              *
    859   1.1    jruoho              * Then we have a type mismatch. Just warn and ignore it.
    860   1.1    jruoho              */
    861   1.1    jruoho             if ((TypeToCheckFor != ACPI_TYPE_ANY)                   &&
    862   1.1    jruoho                 (TypeToCheckFor != ACPI_TYPE_LOCAL_ALIAS)           &&
    863   1.1    jruoho                 (TypeToCheckFor != ACPI_TYPE_LOCAL_METHOD_ALIAS)    &&
    864   1.1    jruoho                 (TypeToCheckFor != ACPI_TYPE_LOCAL_SCOPE)           &&
    865   1.1    jruoho                 (ThisNode->Type != ACPI_TYPE_ANY)                   &&
    866   1.1    jruoho                 (ThisNode->Type != TypeToCheckFor))
    867   1.1    jruoho             {
    868   1.1    jruoho                 /* Complain about a type mismatch */
    869   1.1    jruoho 
    870   1.1    jruoho                 ACPI_WARNING ((AE_INFO,
    871   1.1    jruoho                     "NsLookup: Type mismatch on %4.4s (%s), searching for (%s)",
    872   1.1    jruoho                     ACPI_CAST_PTR (char, &SimpleName),
    873   1.1    jruoho                     AcpiUtGetTypeName (ThisNode->Type),
    874   1.1    jruoho                     AcpiUtGetTypeName (TypeToCheckFor)));
    875   1.1    jruoho             }
    876   1.1    jruoho 
    877   1.1    jruoho             /*
    878   1.1    jruoho              * If this is the last name segment and we are not looking for a
    879   1.1    jruoho              * specific type, but the type of found object is known, use that
    880   1.1    jruoho              * type to (later) see if it opens a scope.
    881   1.1    jruoho              */
    882   1.1    jruoho             if (Type == ACPI_TYPE_ANY)
    883   1.1    jruoho             {
    884   1.1    jruoho                 Type = ThisNode->Type;
    885   1.1    jruoho             }
    886   1.1    jruoho         }
    887   1.1    jruoho 
    888   1.1    jruoho         /* Point to next name segment and make this node current */
    889   1.1    jruoho 
    890  1.17  christos         Path += ACPI_NAMESEG_SIZE;
    891   1.1    jruoho         CurrentNode = ThisNode;
    892   1.1    jruoho     }
    893   1.1    jruoho 
    894   1.1    jruoho     /* Always check if we need to open a new scope */
    895   1.1    jruoho 
    896   1.1    jruoho     if (!(Flags & ACPI_NS_DONT_OPEN_SCOPE) && (WalkState))
    897   1.1    jruoho     {
    898   1.1    jruoho         /*
    899   1.1    jruoho          * If entry is a type which opens a scope, push the new scope on the
    900   1.1    jruoho          * scope stack.
    901   1.1    jruoho          */
    902   1.1    jruoho         if (AcpiNsOpensScope (Type))
    903   1.1    jruoho         {
    904   1.1    jruoho             Status = AcpiDsScopeStackPush (ThisNode, Type, WalkState);
    905   1.1    jruoho             if (ACPI_FAILURE (Status))
    906   1.1    jruoho             {
    907   1.1    jruoho                 return_ACPI_STATUS (Status);
    908   1.1    jruoho             }
    909   1.1    jruoho         }
    910   1.1    jruoho     }
    911   1.1    jruoho 
    912  1.15  christos #ifdef ACPI_EXEC_APP
    913  1.15  christos     if (Flags & ACPI_NS_EARLY_INIT)
    914  1.15  christos     {
    915  1.15  christos         ThisNode->Flags |= ANOBJ_NODE_EARLY_INIT;
    916  1.15  christos     }
    917  1.15  christos #endif
    918  1.15  christos 
    919   1.1    jruoho     *ReturnNode = ThisNode;
    920   1.1    jruoho     return_ACPI_STATUS (AE_OK);
    921   1.1    jruoho }
    922