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