nsaccess.c revision 102550
1/*******************************************************************************
2 *
3 * Module Name: nsaccess - Top-level functions for accessing ACPI namespace
4 *              $Revision: 161 $
5 *
6 ******************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
13 * All rights reserved.
14 *
15 * 2. License
16 *
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights.  You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
20 * property rights.
21 *
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
28 *
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code.  No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
37 *
38 * The above copyright and patent license is granted only if the following
39 * conditions are met:
40 *
41 * 3. Conditions
42 *
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision.  In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change.  Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee.  Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
54 *
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution.  In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
65 * make.
66 *
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3.4. Intel retains all right, title, and interest in and to the Original
74 * Intel Code.
75 *
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
80 *
81 * 4. Disclaimer and Export Compliance
82 *
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89 * PARTICULAR PURPOSE.
90 *
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98 * LIMITED REMEDY.
99 *
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government.  In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
114 *
115 *****************************************************************************/
116
117#define __NSACCESS_C__
118
119#include "acpi.h"
120#include "amlcode.h"
121#include "acnamesp.h"
122#include "acdispat.h"
123
124
125#define _COMPONENT          ACPI_NAMESPACE
126        ACPI_MODULE_NAME    ("nsaccess")
127
128
129/*******************************************************************************
130 *
131 * FUNCTION:    AcpiNsRootInitialize
132 *
133 * PARAMETERS:  None
134 *
135 * RETURN:      Status
136 *
137 * DESCRIPTION: Allocate and initialize the default root named objects
138 *
139 * MUTEX:       Locks namespace for entire execution
140 *
141 ******************************************************************************/
142
143ACPI_STATUS
144AcpiNsRootInitialize (void)
145{
146    ACPI_STATUS                 Status;
147    const ACPI_PREDEFINED_NAMES *InitVal = NULL;
148    ACPI_NAMESPACE_NODE         *NewNode;
149    ACPI_OPERAND_OBJECT         *ObjDesc;
150
151
152    ACPI_FUNCTION_TRACE ("NsRootInitialize");
153
154
155    Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
156    if (ACPI_FAILURE (Status))
157    {
158        return_ACPI_STATUS (Status);
159    }
160
161    /*
162     * The global root ptr is initially NULL, so a non-NULL value indicates
163     * that AcpiNsRootInitialize() has already been called; just return.
164     */
165    if (AcpiGbl_RootNode)
166    {
167        Status = AE_OK;
168        goto UnlockAndExit;
169    }
170
171    /*
172     * Tell the rest of the subsystem that the root is initialized
173     * (This is OK because the namespace is locked)
174     */
175    AcpiGbl_RootNode = &AcpiGbl_RootNodeStruct;
176
177    /* Enter the pre-defined names in the name table */
178
179    ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
180        "Entering predefined entries into namespace\n"));
181
182    for (InitVal = AcpiGbl_PreDefinedNames; InitVal->Name; InitVal++)
183    {
184        Status = AcpiNsLookup (NULL, InitVal->Name, InitVal->Type,
185                        ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, NULL, &NewNode);
186
187        if (ACPI_FAILURE (Status) || (!NewNode)) /* Must be on same line for code converter */
188        {
189            ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
190                "Could not create predefined name %s, %s\n",
191                InitVal->Name, AcpiFormatException (Status)));
192        }
193
194        /*
195         * Name entered successfully.
196         * If entry in PreDefinedNames[] specifies an
197         * initial value, create the initial value.
198         */
199        if (InitVal->Val)
200        {
201            /*
202             * Entry requests an initial value, allocate a
203             * descriptor for it.
204             */
205            ObjDesc = AcpiUtCreateInternalObject (InitVal->Type);
206            if (!ObjDesc)
207            {
208                Status = AE_NO_MEMORY;
209                goto UnlockAndExit;
210            }
211
212            /*
213             * Convert value string from table entry to
214             * internal representation. Only types actually
215             * used for initial values are implemented here.
216             */
217            switch (InitVal->Type)
218            {
219            case ACPI_TYPE_METHOD:
220                ObjDesc->Method.ParamCount =
221                        (UINT8) ACPI_STRTOUL (InitVal->Val, NULL, 10);
222                ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID;
223
224#if defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
225
226                /* Compiler cheats by putting parameter count in the OwnerID */
227
228                NewNode->OwnerId = ObjDesc->Method.ParamCount;
229#endif
230                break;
231
232            case ACPI_TYPE_INTEGER:
233
234                ObjDesc->Integer.Value =
235                        (ACPI_INTEGER) ACPI_STRTOUL (InitVal->Val, NULL, 10);
236                break;
237
238
239            case ACPI_TYPE_STRING:
240
241                /*
242                 * Build an object around the static string
243                 */
244                ObjDesc->String.Length = ACPI_STRLEN (InitVal->Val);
245                ObjDesc->String.Pointer = InitVal->Val;
246                ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER;
247                break;
248
249
250            case ACPI_TYPE_MUTEX:
251
252                ObjDesc->Mutex.SyncLevel =
253                            (UINT16) ACPI_STRTOUL (InitVal->Val, NULL, 10);
254
255                if (ACPI_STRCMP (InitVal->Name, "_GL_") == 0)
256                {
257                    /*
258                     * Create a counting semaphore for the
259                     * global lock
260                     */
261                    Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT,
262                                            1, &ObjDesc->Mutex.Semaphore);
263                    if (ACPI_FAILURE (Status))
264                    {
265                        goto UnlockAndExit;
266                    }
267
268                    /*
269                     * We just created the mutex for the
270                     * global lock, save it
271                     */
272                    AcpiGbl_GlobalLockSemaphore = ObjDesc->Mutex.Semaphore;
273                }
274                else
275                {
276                    /* Create a mutex */
277
278                    Status = AcpiOsCreateSemaphore (1, 1,
279                                        &ObjDesc->Mutex.Semaphore);
280                    if (ACPI_FAILURE (Status))
281                    {
282                        goto UnlockAndExit;
283                    }
284                }
285                break;
286
287
288            default:
289                ACPI_REPORT_ERROR (("Unsupported initial type value %X\n",
290                    InitVal->Type));
291                AcpiUtRemoveReference (ObjDesc);
292                ObjDesc = NULL;
293                continue;
294            }
295
296            /* Store pointer to value descriptor in the Node */
297
298            Status = AcpiNsAttachObject (NewNode, ObjDesc, ACPI_GET_OBJECT_TYPE (ObjDesc));
299
300            /* Remove local reference to the object */
301
302            AcpiUtRemoveReference (ObjDesc);
303        }
304    }
305
306
307UnlockAndExit:
308    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
309    return_ACPI_STATUS (Status);
310}
311
312
313/*******************************************************************************
314 *
315 * FUNCTION:    AcpiNsLookup
316 *
317 * PARAMETERS:  PrefixNode      - Search scope if name is not fully qualified
318 *              Pathname        - Search pathname, in internal format
319 *                                (as represented in the AML stream)
320 *              Type            - Type associated with name
321 *              InterpreterMode - IMODE_LOAD_PASS2 => add name if not found
322 *              Flags           - Flags describing the search restrictions
323 *              WalkState       - Current state of the walk
324 *              ReturnNode      - Where the Node is placed (if found
325 *                                or created successfully)
326 *
327 * RETURN:      Status
328 *
329 * DESCRIPTION: Find or enter the passed name in the name space.
330 *              Log an error if name not found in Exec mode.
331 *
332 * MUTEX:       Assumes namespace is locked.
333 *
334 ******************************************************************************/
335
336ACPI_STATUS
337AcpiNsLookup (
338    ACPI_GENERIC_STATE      *ScopeInfo,
339    NATIVE_CHAR             *Pathname,
340    ACPI_OBJECT_TYPE        Type,
341    ACPI_INTERPRETER_MODE   InterpreterMode,
342    UINT32                  Flags,
343    ACPI_WALK_STATE         *WalkState,
344    ACPI_NAMESPACE_NODE     **ReturnNode)
345{
346    ACPI_STATUS             Status;
347    NATIVE_CHAR             *Path = Pathname;
348    ACPI_NAMESPACE_NODE     *PrefixNode;
349    ACPI_NAMESPACE_NODE     *CurrentNode = NULL;
350    ACPI_NAMESPACE_NODE     *ThisNode = NULL;
351    UINT32                  NumSegments;
352    ACPI_NAME               SimpleName;
353    ACPI_OBJECT_TYPE        TypeToCheckFor;
354    ACPI_OBJECT_TYPE        ThisSearchType;
355    UINT32                  SearchParentFlag = ACPI_NS_SEARCH_PARENT;
356    UINT32                  LocalFlags = Flags & ~(ACPI_NS_ERROR_IF_FOUND |
357                                                   ACPI_NS_SEARCH_PARENT);
358
359
360    ACPI_FUNCTION_TRACE ("NsLookup");
361
362
363    if (!ReturnNode)
364    {
365        return_ACPI_STATUS (AE_BAD_PARAMETER);
366    }
367
368    AcpiGbl_NsLookupCount++;
369    *ReturnNode = ACPI_ENTRY_NOT_FOUND;
370
371    if (!AcpiGbl_RootNode)
372    {
373        return_ACPI_STATUS (AE_NO_NAMESPACE);
374    }
375
376    /*
377     * Get the prefix scope.
378     * A null scope means use the root scope
379     */
380    if ((!ScopeInfo) ||
381        (!ScopeInfo->Scope.Node))
382    {
383        ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
384            "Null scope prefix, using root node (%p)\n",
385            AcpiGbl_RootNode));
386
387        PrefixNode = AcpiGbl_RootNode;
388    }
389    else
390    {
391        PrefixNode = ScopeInfo->Scope.Node;
392        if (ACPI_GET_DESCRIPTOR_TYPE (PrefixNode) != ACPI_DESC_TYPE_NAMED)
393        {
394            ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "[%p] Not a namespace node\n",
395                PrefixNode));
396            return_ACPI_STATUS (AE_AML_INTERNAL);
397        }
398
399        /*
400         * This node might not be a actual "scope" node (such as a
401         * Device/Method, etc.)  It could be a Package or other object node.
402         * Backup up the tree to find the containing scope node.
403         */
404        while (!AcpiNsOpensScope (PrefixNode->Type) &&
405                PrefixNode->Type != ACPI_TYPE_ANY)
406        {
407            PrefixNode = AcpiNsGetParentNode (PrefixNode);
408        }
409    }
410
411    /*
412     * This check is explicitly split to relax the TypeToCheckFor
413     * conditions for BankFieldDefn.  Originally, both BankFieldDefn and
414     * DefFieldDefn caused TypeToCheckFor to be set to ACPI_TYPE_REGION,
415     * but the BankFieldDefn may also check for a Field definition as well
416     * as an OperationRegion.
417     */
418    if (INTERNAL_TYPE_FIELD_DEFN == Type)
419    {
420        /* DefFieldDefn defines fields in a Region */
421
422        TypeToCheckFor = ACPI_TYPE_REGION;
423    }
424    else if (INTERNAL_TYPE_BANK_FIELD_DEFN == Type)
425    {
426        /* BankFieldDefn defines data fields in a Field Object */
427
428        TypeToCheckFor = ACPI_TYPE_ANY;
429    }
430    else
431    {
432        TypeToCheckFor = Type;
433    }
434
435    /*
436     * Begin examination of the actual pathname
437     */
438    if (!Pathname)
439    {
440        /* A Null NamePath is allowed and refers to the root */
441
442        NumSegments  = 0;
443        ThisNode     = AcpiGbl_RootNode;
444        Path     = "";
445
446        ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
447            "Null Pathname (Zero segments), Flags=%X\n", Flags));
448    }
449    else
450    {
451        /*
452         * Name pointer is valid (and must be in internal name format)
453         *
454         * Check for scope prefixes:
455         *
456         * As represented in the AML stream, a namepath consists of an
457         * optional scope prefix followed by a name segment part.
458         *
459         * If present, the scope prefix is either a Root Prefix (in
460         * which case the name is fully qualified), or one or more
461         * Parent Prefixes (in which case the name's scope is relative
462         * to the current scope).
463         */
464        if (*Path == (UINT8) AML_ROOT_PREFIX)
465        {
466            /* Pathname is fully qualified, start from the root */
467
468            ThisNode = AcpiGbl_RootNode;
469            SearchParentFlag = ACPI_NS_NO_UPSEARCH;
470
471            /* Point to name segment part */
472
473            Path++;
474
475            ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
476                "Path is absolute from root [%p]\n", ThisNode));
477        }
478        else
479        {
480            /* Pathname is relative to current scope, start there */
481
482            ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
483                "Searching relative to prefix scope [%p]\n",
484                PrefixNode));
485
486            /*
487             * Handle multiple Parent Prefixes (carat) by just getting
488             * the parent node for each prefix instance.
489             */
490            ThisNode = PrefixNode;
491            while (*Path == (UINT8) AML_PARENT_PREFIX)
492            {
493                /* Name is fully qualified, no search rules apply */
494
495                SearchParentFlag = ACPI_NS_NO_UPSEARCH;
496                /*
497                 * Point past this prefix to the name segment
498                 * part or the next Parent Prefix
499                 */
500                Path++;
501
502                /* Backup to the parent node */
503
504                ThisNode = AcpiNsGetParentNode (ThisNode);
505                if (!ThisNode)
506                {
507                    /* Current scope has no parent scope */
508
509                    ACPI_REPORT_ERROR (
510                        ("ACPI path has too many parent prefixes (^) - reached beyond root node\n"));
511                    return_ACPI_STATUS (AE_NOT_FOUND);
512                }
513            }
514
515            if (SearchParentFlag == ACPI_NS_NO_UPSEARCH)
516            {
517                ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
518                    "Path is absolute with one or more carats\n"));
519            }
520        }
521
522        /*
523         * Determine the number of ACPI name segments in this pathname.
524         *
525         * The segment part consists of either:
526         *  - A Null name segment (0)
527         *  - A DualNamePrefix followed by two 4-byte name segments
528         *  - A MultiNamePrefix followed by a byte indicating the
529         *      number of segments and the segments themselves.
530         *  - A single 4-byte name segment
531         *
532         * Examine the name prefix opcode, if any, to determine the number of
533         * segments.
534         */
535        switch (*Path)
536        {
537        case 0:
538            /*
539             * Null name after a root or parent prefixes. We already
540             * have the correct target node and there are no name segments.
541             */
542            NumSegments  = 0;
543
544            ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
545                "Prefix-only Pathname (Zero name segments), Flags=%X\n", Flags));
546            break;
547
548        case AML_DUAL_NAME_PREFIX:
549
550            /* More than one NameSeg, search rules do not apply */
551
552            SearchParentFlag = ACPI_NS_NO_UPSEARCH;
553
554            /* Two segments, point to first name segment */
555
556            NumSegments = 2;
557            Path++;
558
559            ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
560                "Dual Pathname (2 segments, Flags=%X)\n", Flags));
561            break;
562
563        case AML_MULTI_NAME_PREFIX_OP:
564
565            /* More than one NameSeg, search rules do not apply */
566
567            SearchParentFlag = ACPI_NS_NO_UPSEARCH;
568
569            /* Extract segment count, point to first name segment */
570
571            Path++;
572            NumSegments = (UINT32) (UINT8) *Path;
573            Path++;
574
575            ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
576                "Multi Pathname (%d Segments, Flags=%X) \n",
577                NumSegments, Flags));
578            break;
579
580        default:
581            /*
582             * Not a Null name, no Dual or Multi prefix, hence there is
583             * only one name segment and Pathname is already pointing to it.
584             */
585            NumSegments = 1;
586
587            ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
588                "Simple Pathname (1 segment, Flags=%X)\n", Flags));
589            break;
590        }
591
592        ACPI_DEBUG_EXEC (AcpiNsPrintPathname (NumSegments, Path));
593    }
594
595
596    /*
597     * Search namespace for each segment of the name.  Loop through and
598     * verify (or add to the namespace) each name segment.
599     *
600     * The object type is significant only at the last name
601     * segment.  (We don't care about the types along the path, only
602     * the type of the final target object.)
603     */
604    ThisSearchType = ACPI_TYPE_ANY;
605    CurrentNode = ThisNode;
606    while (NumSegments && CurrentNode)
607    {
608        NumSegments--;
609        if (!NumSegments)
610        {
611            /*
612             * This is the last segment, enable typechecking
613             */
614            ThisSearchType = Type;
615
616            /*
617             * Only allow automatic parent search (search rules) if the caller
618             * requested it AND we have a single, non-fully-qualified NameSeg
619             */
620            if ((SearchParentFlag != ACPI_NS_NO_UPSEARCH) &&
621                (Flags & ACPI_NS_SEARCH_PARENT))
622            {
623                LocalFlags |= ACPI_NS_SEARCH_PARENT;
624            }
625
626            /* Set error flag according to caller */
627
628            if (Flags & ACPI_NS_ERROR_IF_FOUND)
629            {
630                LocalFlags |= ACPI_NS_ERROR_IF_FOUND;
631            }
632        }
633
634        /* Extract one ACPI name from the front of the pathname */
635
636        ACPI_MOVE_UNALIGNED32_TO_32 (&SimpleName, Path);
637
638        /* Try to find the single (4 character) ACPI name */
639
640        Status = AcpiNsSearchAndEnter (SimpleName, WalkState, CurrentNode,
641                        InterpreterMode, ThisSearchType, LocalFlags, &ThisNode);
642        if (ACPI_FAILURE (Status))
643        {
644            if (Status == AE_NOT_FOUND)
645            {
646                /* Name not found in ACPI namespace */
647
648                ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
649                    "Name [%4.4s] not found in scope [%4.4s] %p\n",
650                    (char *) &SimpleName, (char *) &CurrentNode->Name,
651                    CurrentNode));
652            }
653
654            return_ACPI_STATUS (Status);
655        }
656
657        /*
658         * Sanity typecheck of the target object:
659         *
660         * If 1) This is the last segment (NumSegments == 0)
661         *    2) And we are looking for a specific type
662         *       (Not checking for TYPE_ANY)
663         *    3) Which is not an alias
664         *    4) Which is not a local type (TYPE_DEF_ANY)
665         *    5) Which is not a local type (TYPE_SCOPE)
666         *    6) Which is not a local type (TYPE_INDEX_FIELD_DEFN)
667         *    7) And the type of target object is known (not TYPE_ANY)
668         *    8) And target object does not match what we are looking for
669         *
670         * Then we have a type mismatch.  Just warn and ignore it.
671         */
672        if ((NumSegments        == 0)                               &&
673            (TypeToCheckFor     != ACPI_TYPE_ANY)                   &&
674            (TypeToCheckFor     != INTERNAL_TYPE_ALIAS)             &&
675            (TypeToCheckFor     != INTERNAL_TYPE_DEF_ANY)           &&
676            (TypeToCheckFor     != INTERNAL_TYPE_SCOPE)             &&
677            (TypeToCheckFor     != INTERNAL_TYPE_INDEX_FIELD_DEFN)  &&
678            (ThisNode->Type     != ACPI_TYPE_ANY)                   &&
679            (ThisNode->Type     != TypeToCheckFor))
680        {
681            /* Complain about a type mismatch */
682
683            ACPI_REPORT_WARNING (
684                ("NsLookup: %4.4s, type %X, checking for type %X\n",
685                (char *) &SimpleName, ThisNode->Type, TypeToCheckFor));
686        }
687
688        /*
689         * If this is the last name segment and we are not looking for a
690         * specific type, but the type of found object is known, use that type
691         * to see if it opens a scope.
692         */
693        if ((NumSegments == 0) && (Type == ACPI_TYPE_ANY))
694        {
695            Type = ThisNode->Type;
696        }
697
698        /* Point to next name segment and make this node current */
699
700        Path += ACPI_NAME_SIZE;
701        CurrentNode = ThisNode;
702    }
703
704    /*
705     * Always check if we need to open a new scope
706     */
707    if (!(Flags & ACPI_NS_DONT_OPEN_SCOPE) && (WalkState))
708    {
709        /*
710         * If entry is a type which opens a scope, push the new scope on the
711         * scope stack.
712         */
713        if (AcpiNsOpensScope (TypeToCheckFor))
714        {
715            Status = AcpiDsScopeStackPush (ThisNode, Type, WalkState);
716            if (ACPI_FAILURE (Status))
717            {
718                return_ACPI_STATUS (Status);
719            }
720
721            ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
722                "Setting current scope to [%4.4s] (%p)\n",
723                ThisNode->Name.Ascii, ThisNode));
724        }
725    }
726
727    *ReturnNode = ThisNode;
728    return_ACPI_STATUS (AE_OK);
729}
730
731