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