1 /*******************************************************************************
3 * Module Name: nsaccess - Top-level functions for accessing ACPI namespace
5 ******************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2020, Intel Corp.
12 * All rights reserved.
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
37 * The above copyright and patent license is granted only if the following
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
72 * 3.4. Intel retains all right, title, and interest in and to the Original
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
80 * 4. Disclaimer and Export Compliance
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
114 *****************************************************************************
116 * Alternatively, you may choose to be licensed under the terms of the
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
122 * 1. Redistributions of source code must retain the above copyright
123 * notice, this list of conditions, and the following disclaimer,
124 * without modification.
125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 * substantially similar to the "NO WARRANTY" disclaimer below
127 * ("Disclaimer") and any redistribution must be conditioned upon
128 * including a substantially similar Disclaimer requirement for further
129 * binary redistribution.
130 * 3. Neither the names of the above-listed copyright holders nor the names
131 * of any contributors may be used to endorse or promote products derived
132 * from this software without specific prior written permission.
134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146 * Alternatively, you may choose to be licensed under the terms of the
147 * GNU General Public License ("GPL") version 2 as published by the Free
148 * Software Foundation.
150 *****************************************************************************/
152 #include <contrib/dev/acpica/include/acpi.h>
153 #include <contrib/dev/acpica/include/accommon.h>
154 #include <contrib/dev/acpica/include/amlcode.h>
155 #include <contrib/dev/acpica/include/acnamesp.h>
156 #include <contrib/dev/acpica/include/acdispat.h>
158 #ifdef ACPI_ASL_COMPILER
159 #include <contrib/dev/acpica/include/acdisasm.h>
162 #define _COMPONENT ACPI_NAMESPACE
163 ACPI_MODULE_NAME ("nsaccess")
166 /*******************************************************************************
168 * FUNCTION: AcpiNsRootInitialize
174 * DESCRIPTION: Allocate and initialize the default root named objects
176 * MUTEX: Locks namespace for entire execution
178 ******************************************************************************/
181 AcpiNsRootInitialize (
185 const ACPI_PREDEFINED_NAMES *InitVal = NULL;
186 ACPI_NAMESPACE_NODE *NewNode;
187 ACPI_NAMESPACE_NODE *PrevNode = NULL;
188 ACPI_OPERAND_OBJECT *ObjDesc;
189 ACPI_STRING Val = NULL;
192 ACPI_FUNCTION_TRACE (NsRootInitialize);
195 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
196 if (ACPI_FAILURE (Status))
198 return_ACPI_STATUS (Status);
202 * The global root ptr is initially NULL, so a non-NULL value indicates
203 * that AcpiNsRootInitialize() has already been called; just return.
205 if (AcpiGbl_RootNode)
212 * Tell the rest of the subsystem that the root is initialized
213 * (This is OK because the namespace is locked)
215 AcpiGbl_RootNode = &AcpiGbl_RootNodeStruct;
217 /* Enter the predefined names in the name table */
219 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
220 "Entering predefined entries into namespace\n"));
223 * Create the initial (default) namespace.
224 * This namespace looks like something similar to this:
226 * ACPI Namespace (from Namespace Root):
227 * 0 _GPE Scope 00203160 00
228 * 0 _PR_ Scope 002031D0 00
229 * 0 _SB_ Device 00203240 00 Notify Object: 0020ADD8
230 * 0 _SI_ Scope 002032B0 00
231 * 0 _TZ_ Device 00203320 00
232 * 0 _REV Integer 00203390 00 = 0000000000000002
233 * 0 _OS_ String 00203488 00 Len 14 "Microsoft Windows NT"
234 * 0 _GL_ Mutex 00203580 00 Object 002035F0
235 * 0 _OSI Method 00203678 00 Args 1 Len 0000 Aml 00000000
237 for (InitVal = AcpiGbl_PreDefinedNames; InitVal->Name; InitVal++)
241 /* _OSI is optional for now, will be permanent later */
243 if (!strcmp (InitVal->Name, "_OSI") && !AcpiGbl_CreateOsiMethod)
249 * Create, init, and link the new predefined name
250 * Note: No need to use AcpiNsLookup here because all the
251 * predefined names are at the root level. It is much easier to
252 * just create and link the new node(s) here.
254 NewNode = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_NAMESPACE_NODE));
257 Status = AE_NO_MEMORY;
261 ACPI_COPY_NAMESEG (NewNode->Name.Ascii, InitVal->Name);
262 NewNode->DescriptorType = ACPI_DESC_TYPE_NAMED;
263 NewNode->Type = InitVal->Type;
267 AcpiGbl_RootNodeStruct.Child = NewNode;
271 PrevNode->Peer = NewNode;
274 NewNode->Parent = &AcpiGbl_RootNodeStruct;
278 * Name entered successfully. If entry in PreDefinedNames[] specifies
279 * an initial value, create the initial value.
283 Status = AcpiOsPredefinedOverride (InitVal, &Val);
284 if (ACPI_FAILURE (Status))
286 ACPI_ERROR ((AE_INFO,
287 "Could not override predefined %s",
297 * Entry requests an initial value, allocate a
300 ObjDesc = AcpiUtCreateInternalObject (InitVal->Type);
303 Status = AE_NO_MEMORY;
308 * Convert value string from table entry to
309 * internal representation. Only types actually
310 * used for initial values are implemented here.
312 switch (InitVal->Type)
314 case ACPI_TYPE_METHOD:
316 ObjDesc->Method.ParamCount = (UINT8) ACPI_TO_INTEGER (Val);
317 ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID;
319 #if defined (ACPI_ASL_COMPILER)
321 /* Save the parameter count for the iASL compiler */
323 NewNode->Value = ObjDesc->Method.ParamCount;
325 /* Mark this as a very SPECIAL method (_OSI) */
327 ObjDesc->Method.InfoFlags = ACPI_METHOD_INTERNAL_ONLY;
328 ObjDesc->Method.Dispatch.Implementation = AcpiUtOsiImplementation;
332 case ACPI_TYPE_INTEGER:
334 ObjDesc->Integer.Value = ACPI_TO_INTEGER (Val);
337 case ACPI_TYPE_STRING:
339 /* Build an object around the static string */
341 ObjDesc->String.Length = (UINT32) strlen (Val);
342 ObjDesc->String.Pointer = Val;
343 ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER;
346 case ACPI_TYPE_MUTEX:
348 ObjDesc->Mutex.Node = NewNode;
349 ObjDesc->Mutex.SyncLevel = (UINT8) (ACPI_TO_INTEGER (Val) - 1);
353 Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex);
354 if (ACPI_FAILURE (Status))
356 AcpiUtRemoveReference (ObjDesc);
360 /* Special case for ACPI Global Lock */
362 if (strcmp (InitVal->Name, "_GL_") == 0)
364 AcpiGbl_GlobalLockMutex = ObjDesc;
366 /* Create additional counting semaphore for global lock */
368 Status = AcpiOsCreateSemaphore (
369 1, 0, &AcpiGbl_GlobalLockSemaphore);
370 if (ACPI_FAILURE (Status))
372 AcpiUtRemoveReference (ObjDesc);
380 ACPI_ERROR ((AE_INFO, "Unsupported initial type value 0x%X",
382 AcpiUtRemoveReference (ObjDesc);
387 /* Store pointer to value descriptor in the Node */
389 Status = AcpiNsAttachObject (NewNode, ObjDesc,
390 ObjDesc->Common.Type);
392 /* Remove local reference to the object */
394 AcpiUtRemoveReference (ObjDesc);
399 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
401 /* Save a handle to "_GPE", it is always present */
403 if (ACPI_SUCCESS (Status))
405 Status = AcpiNsGetNode (NULL, "\\_GPE", ACPI_NS_NO_UPSEARCH,
406 &AcpiGbl_FadtGpeDevice);
409 return_ACPI_STATUS (Status);
413 /*******************************************************************************
415 * FUNCTION: AcpiNsLookup
417 * PARAMETERS: ScopeInfo - Current scope info block
418 * Pathname - Search pathname, in internal format
419 * (as represented in the AML stream)
420 * Type - Type associated with name
421 * InterpreterMode - IMODE_LOAD_PASS2 => add name if not found
422 * Flags - Flags describing the search restrictions
423 * WalkState - Current state of the walk
424 * ReturnNode - Where the Node is placed (if found
425 * or created successfully)
429 * DESCRIPTION: Find or enter the passed name in the name space.
430 * Log an error if name not found in Exec mode.
432 * MUTEX: Assumes namespace is locked.
434 ******************************************************************************/
438 ACPI_GENERIC_STATE *ScopeInfo,
440 ACPI_OBJECT_TYPE Type,
441 ACPI_INTERPRETER_MODE InterpreterMode,
443 ACPI_WALK_STATE *WalkState,
444 ACPI_NAMESPACE_NODE **ReturnNode)
447 char *Path = Pathname;
449 ACPI_NAMESPACE_NODE *PrefixNode;
450 ACPI_NAMESPACE_NODE *CurrentNode = NULL;
451 ACPI_NAMESPACE_NODE *ThisNode = NULL;
454 ACPI_NAME SimpleName;
455 ACPI_OBJECT_TYPE TypeToCheckFor;
456 ACPI_OBJECT_TYPE ThisSearchType;
457 UINT32 SearchParentFlag = ACPI_NS_SEARCH_PARENT;
459 ACPI_INTERPRETER_MODE LocalInterpreterMode;
462 ACPI_FUNCTION_TRACE (NsLookup);
467 return_ACPI_STATUS (AE_BAD_PARAMETER);
471 ~(ACPI_NS_ERROR_IF_FOUND | ACPI_NS_OVERRIDE_IF_FOUND |
472 ACPI_NS_SEARCH_PARENT);
473 *ReturnNode = ACPI_ENTRY_NOT_FOUND;
474 AcpiGbl_NsLookupCount++;
476 if (!AcpiGbl_RootNode)
478 return_ACPI_STATUS (AE_NO_NAMESPACE);
481 /* Get the prefix scope. A null scope means use the root scope */
484 (!ScopeInfo->Scope.Node))
486 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
487 "Null scope prefix, using root node (%p)\n",
490 PrefixNode = AcpiGbl_RootNode;
494 PrefixNode = ScopeInfo->Scope.Node;
495 if (ACPI_GET_DESCRIPTOR_TYPE (PrefixNode) != ACPI_DESC_TYPE_NAMED)
497 ACPI_ERROR ((AE_INFO, "%p is not a namespace node [%s]",
498 PrefixNode, AcpiUtGetDescriptorName (PrefixNode)));
499 return_ACPI_STATUS (AE_AML_INTERNAL);
502 if (!(Flags & ACPI_NS_PREFIX_IS_SCOPE))
505 * This node might not be a actual "scope" node (such as a
506 * Device/Method, etc.) It could be a Package or other object
507 * node. Backup up the tree to find the containing scope node.
509 while (!AcpiNsOpensScope (PrefixNode->Type) &&
510 PrefixNode->Type != ACPI_TYPE_ANY)
512 PrefixNode = PrefixNode->Parent;
517 /* Save type. TBD: may be no longer necessary */
519 TypeToCheckFor = Type;
522 * Begin examination of the actual pathname
526 /* A Null NamePath is allowed and refers to the root */
529 ThisNode = AcpiGbl_RootNode;
532 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
533 "Null Pathname (Zero segments), Flags=%X\n", Flags));
538 * Name pointer is valid (and must be in internal name format)
540 * Check for scope prefixes:
542 * As represented in the AML stream, a namepath consists of an
543 * optional scope prefix followed by a name segment part.
545 * If present, the scope prefix is either a Root Prefix (in
546 * which case the name is fully qualified), or one or more
547 * Parent Prefixes (in which case the name's scope is relative
548 * to the current scope).
550 if (*Path == (UINT8) AML_ROOT_PREFIX)
552 /* Pathname is fully qualified, start from the root */
554 ThisNode = AcpiGbl_RootNode;
555 SearchParentFlag = ACPI_NS_NO_UPSEARCH;
557 /* Point to name segment part */
561 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
562 "Path is absolute from root [%p]\n", ThisNode));
566 /* Pathname is relative to current scope, start there */
568 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
569 "Searching relative to prefix scope [%4.4s] (%p)\n",
570 AcpiUtGetNodeName (PrefixNode), PrefixNode));
573 * Handle multiple Parent Prefixes (carat) by just getting
574 * the parent node for each prefix instance.
576 ThisNode = PrefixNode;
578 while (*Path == (UINT8) AML_PARENT_PREFIX)
580 /* Name is fully qualified, no search rules apply */
582 SearchParentFlag = ACPI_NS_NO_UPSEARCH;
585 * Point past this prefix to the name segment
586 * part or the next Parent Prefix
590 /* Backup to the parent node */
593 ThisNode = ThisNode->Parent;
597 * Current scope has no parent scope. Externalize
598 * the internal path for error message.
600 Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, Pathname,
601 NULL, &ExternalPath);
602 if (ACPI_SUCCESS (Status))
604 ACPI_ERROR ((AE_INFO,
605 "%s: Path has too many parent prefixes (^)",
608 ACPI_FREE (ExternalPath);
611 return_ACPI_STATUS (AE_NOT_FOUND);
615 if (SearchParentFlag == ACPI_NS_NO_UPSEARCH)
617 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
618 "Search scope is [%4.4s], path has %u carat(s)\n",
619 AcpiUtGetNodeName (ThisNode), NumCarats));
624 * Determine the number of ACPI name segments in this pathname.
626 * The segment part consists of either:
627 * - A Null name segment (0)
628 * - A DualNamePrefix followed by two 4-byte name segments
629 * - A MultiNamePrefix followed by a byte indicating the
630 * number of segments and the segments themselves.
631 * - A single 4-byte name segment
633 * Examine the name prefix opcode, if any, to determine the number of
640 * Null name after a root or parent prefixes. We already
641 * have the correct target node and there are no name segments.
644 Type = ThisNode->Type;
646 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
647 "Prefix-only Pathname (Zero name segments), Flags=%X\n",
651 case AML_DUAL_NAME_PREFIX:
653 /* More than one NameSeg, search rules do not apply */
655 SearchParentFlag = ACPI_NS_NO_UPSEARCH;
657 /* Two segments, point to first name segment */
662 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
663 "Dual Pathname (2 segments, Flags=%X)\n", Flags));
666 case AML_MULTI_NAME_PREFIX:
668 /* More than one NameSeg, search rules do not apply */
670 SearchParentFlag = ACPI_NS_NO_UPSEARCH;
672 /* Extract segment count, point to first name segment */
675 NumSegments = (UINT32) (UINT8) *Path;
678 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
679 "Multi Pathname (%u Segments, Flags=%X)\n",
680 NumSegments, Flags));
685 * Not a Null name, no Dual or Multi prefix, hence there is
686 * only one name segment and Pathname is already pointing to it.
690 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
691 "Simple Pathname (1 segment, Flags=%X)\n", Flags));
695 ACPI_DEBUG_EXEC (AcpiNsPrintPathname (NumSegments, Path));
700 * Search namespace for each segment of the name. Loop through and
701 * verify (or add to the namespace) each name segment.
703 * The object type is significant only at the last name
704 * segment. (We don't care about the types along the path, only
705 * the type of the final target object.)
707 ThisSearchType = ACPI_TYPE_ANY;
708 CurrentNode = ThisNode;
710 while (NumSegments && CurrentNode)
715 /* This is the last segment, enable typechecking */
717 ThisSearchType = Type;
720 * Only allow automatic parent search (search rules) if the caller
721 * requested it AND we have a single, non-fully-qualified NameSeg
723 if ((SearchParentFlag != ACPI_NS_NO_UPSEARCH) &&
724 (Flags & ACPI_NS_SEARCH_PARENT))
726 LocalFlags |= ACPI_NS_SEARCH_PARENT;
729 /* Set error flag according to caller */
731 if (Flags & ACPI_NS_ERROR_IF_FOUND)
733 LocalFlags |= ACPI_NS_ERROR_IF_FOUND;
736 /* Set override flag according to caller */
738 if (Flags & ACPI_NS_OVERRIDE_IF_FOUND)
740 LocalFlags |= ACPI_NS_OVERRIDE_IF_FOUND;
744 /* Handle opcodes that create a new NameSeg via a full NamePath */
746 LocalInterpreterMode = InterpreterMode;
747 if ((Flags & ACPI_NS_PREFIX_MUST_EXIST) && (NumSegments > 0))
749 /* Every element of the path must exist (except for the final NameSeg) */
751 LocalInterpreterMode = ACPI_IMODE_EXECUTE;
754 /* Extract one ACPI name from the front of the pathname */
756 ACPI_MOVE_32_TO_32 (&SimpleName, Path);
758 /* Try to find the single (4 character) ACPI name */
760 Status = AcpiNsSearchAndEnter (SimpleName, WalkState, CurrentNode,
761 LocalInterpreterMode, ThisSearchType, LocalFlags, &ThisNode);
762 if (ACPI_FAILURE (Status))
764 if (Status == AE_NOT_FOUND)
766 #if !defined ACPI_ASL_COMPILER /* Note: iASL reports this error by itself, not needed here */
767 if (Flags & ACPI_NS_PREFIX_MUST_EXIST)
769 AcpiOsPrintf (ACPI_MSG_BIOS_ERROR
770 "Object does not exist: %4.4s\n", (char *) &SimpleName);
773 /* Name not found in ACPI namespace */
775 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
776 "Name [%4.4s] not found in scope [%4.4s] %p\n",
777 (char *) &SimpleName, (char *) &CurrentNode->Name,
782 if ((Status == AE_ALREADY_EXISTS) &&
783 (ThisNode->Flags & ANOBJ_NODE_EARLY_INIT))
785 ThisNode->Flags &= ~ANOBJ_NODE_EARLY_INIT;
790 #ifdef ACPI_ASL_COMPILER
792 * If this ACPI name already exists within the namespace as an
793 * external declaration, then mark the external as a conflicting
794 * declaration and proceed to process the current node as if it did
795 * not exist in the namespace. If this node is not processed as
796 * normal, then it could cause improper namespace resolution
797 * by failing to open a new scope.
799 if (AcpiGbl_DisasmFlag &&
800 (Status == AE_ALREADY_EXISTS) &&
801 ((ThisNode->Flags & ANOBJ_IS_EXTERNAL) ||
802 (WalkState && WalkState->Opcode == AML_EXTERNAL_OP)))
804 ThisNode->Flags &= ~ANOBJ_IS_EXTERNAL;
805 ThisNode->Type = (UINT8)ThisSearchType;
806 if (WalkState->Opcode != AML_EXTERNAL_OP)
808 AcpiDmMarkExternalConflict (ThisNode);
814 *ReturnNode = ThisNode;
815 return_ACPI_STATUS (Status);
818 /* More segments to follow? */
823 * If we have an alias to an object that opens a scope (such as a
824 * device or processor), we need to dereference the alias here so
825 * that we can access any children of the original node (via the
826 * remaining segments).
828 if (ThisNode->Type == ACPI_TYPE_LOCAL_ALIAS)
830 if (!ThisNode->Object)
832 return_ACPI_STATUS (AE_NOT_EXIST);
835 if (AcpiNsOpensScope (((ACPI_NAMESPACE_NODE *)
836 ThisNode->Object)->Type))
838 ThisNode = (ACPI_NAMESPACE_NODE *) ThisNode->Object;
843 /* Special handling for the last segment (NumSegments == 0) */
848 * Sanity typecheck of the target object:
850 * If 1) This is the last segment (NumSegments == 0)
851 * 2) And we are looking for a specific type
852 * (Not checking for TYPE_ANY)
853 * 3) Which is not an alias
854 * 4) Which is not a local type (TYPE_SCOPE)
855 * 5) And the type of target object is known (not TYPE_ANY)
856 * 6) And target object does not match what we are looking for
858 * Then we have a type mismatch. Just warn and ignore it.
860 if ((TypeToCheckFor != ACPI_TYPE_ANY) &&
861 (TypeToCheckFor != ACPI_TYPE_LOCAL_ALIAS) &&
862 (TypeToCheckFor != ACPI_TYPE_LOCAL_METHOD_ALIAS) &&
863 (TypeToCheckFor != ACPI_TYPE_LOCAL_SCOPE) &&
864 (ThisNode->Type != ACPI_TYPE_ANY) &&
865 (ThisNode->Type != TypeToCheckFor))
867 /* Complain about a type mismatch */
869 ACPI_WARNING ((AE_INFO,
870 "NsLookup: Type mismatch on %4.4s (%s), searching for (%s)",
871 ACPI_CAST_PTR (char, &SimpleName),
872 AcpiUtGetTypeName (ThisNode->Type),
873 AcpiUtGetTypeName (TypeToCheckFor)));
877 * If this is the last name segment and we are not looking for a
878 * specific type, but the type of found object is known, use that
879 * type to (later) see if it opens a scope.
881 if (Type == ACPI_TYPE_ANY)
883 Type = ThisNode->Type;
887 /* Point to next name segment and make this node current */
889 Path += ACPI_NAMESEG_SIZE;
890 CurrentNode = ThisNode;
893 /* Always check if we need to open a new scope */
895 if (!(Flags & ACPI_NS_DONT_OPEN_SCOPE) && (WalkState))
898 * If entry is a type which opens a scope, push the new scope on the
901 if (AcpiNsOpensScope (Type))
903 Status = AcpiDsScopeStackPush (ThisNode, Type, WalkState);
904 if (ACPI_FAILURE (Status))
906 return_ACPI_STATUS (Status);
912 if (Flags & ACPI_NS_EARLY_INIT)
914 ThisNode->Flags |= ANOBJ_NODE_EARLY_INIT;
918 *ReturnNode = ThisNode;
919 return_ACPI_STATUS (AE_OK);