f176c73cd7c8cc21e3760ed77abb916e4c0d6ba6
[reactos.git] / reactos / drivers / bus / acpi / acpica / namespace / nsaccess.c
1 /*******************************************************************************
2 *
3 * Module Name: nsaccess - Top-level functions for accessing ACPI namespace
4 *
5 ******************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2017, 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_OPERAND_OBJECT *ObjDesc;
80 ACPI_STRING Val = NULL;
81
82
83 ACPI_FUNCTION_TRACE (NsRootInitialize);
84
85
86 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
87 if (ACPI_FAILURE (Status))
88 {
89 return_ACPI_STATUS (Status);
90 }
91
92 /*
93 * The global root ptr is initially NULL, so a non-NULL value indicates
94 * that AcpiNsRootInitialize() has already been called; just return.
95 */
96 if (AcpiGbl_RootNode)
97 {
98 Status = AE_OK;
99 goto UnlockAndExit;
100 }
101
102 /*
103 * Tell the rest of the subsystem that the root is initialized
104 * (This is OK because the namespace is locked)
105 */
106 AcpiGbl_RootNode = &AcpiGbl_RootNodeStruct;
107
108 /* Enter the pre-defined names in the name table */
109
110 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
111 "Entering predefined entries into namespace\n"));
112
113 for (InitVal = AcpiGbl_PreDefinedNames; InitVal->Name; InitVal++)
114 {
115 /* _OSI is optional for now, will be permanent later */
116
117 if (!strcmp (InitVal->Name, "_OSI") && !AcpiGbl_CreateOsiMethod)
118 {
119 continue;
120 }
121
122 Status = AcpiNsLookup (NULL, ACPI_CAST_PTR (char, InitVal->Name),
123 InitVal->Type, ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH,
124 NULL, &NewNode);
125 if (ACPI_FAILURE (Status))
126 {
127 ACPI_EXCEPTION ((AE_INFO, Status,
128 "Could not create predefined name %s",
129 InitVal->Name));
130 continue;
131 }
132
133 /*
134 * Name entered successfully. If entry in PreDefinedNames[] specifies
135 * an initial value, create the initial value.
136 */
137 if (InitVal->Val)
138 {
139 Status = AcpiOsPredefinedOverride (InitVal, &Val);
140 if (ACPI_FAILURE (Status))
141 {
142 ACPI_ERROR ((AE_INFO,
143 "Could not override predefined %s",
144 InitVal->Name));
145 }
146
147 if (!Val)
148 {
149 Val = InitVal->Val;
150 }
151
152 /*
153 * Entry requests an initial value, allocate a
154 * descriptor for it.
155 */
156 ObjDesc = AcpiUtCreateInternalObject (InitVal->Type);
157 if (!ObjDesc)
158 {
159 Status = AE_NO_MEMORY;
160 goto UnlockAndExit;
161 }
162
163 /*
164 * Convert value string from table entry to
165 * internal representation. Only types actually
166 * used for initial values are implemented here.
167 */
168 switch (InitVal->Type)
169 {
170 case ACPI_TYPE_METHOD:
171
172 ObjDesc->Method.ParamCount = (UINT8) ACPI_TO_INTEGER (Val);
173 ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID;
174
175 #if defined (ACPI_ASL_COMPILER)
176
177 /* Save the parameter count for the iASL compiler */
178
179 NewNode->Value = ObjDesc->Method.ParamCount;
180 #else
181 /* Mark this as a very SPECIAL method */
182
183 ObjDesc->Method.InfoFlags = ACPI_METHOD_INTERNAL_ONLY;
184 ObjDesc->Method.Dispatch.Implementation = AcpiUtOsiImplementation;
185 #endif
186 break;
187
188 case ACPI_TYPE_INTEGER:
189
190 ObjDesc->Integer.Value = ACPI_TO_INTEGER (Val);
191 break;
192
193 case ACPI_TYPE_STRING:
194
195 /* Build an object around the static string */
196
197 ObjDesc->String.Length = (UINT32) strlen (Val);
198 ObjDesc->String.Pointer = Val;
199 ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER;
200 break;
201
202 case ACPI_TYPE_MUTEX:
203
204 ObjDesc->Mutex.Node = NewNode;
205 ObjDesc->Mutex.SyncLevel = (UINT8) (ACPI_TO_INTEGER (Val) - 1);
206
207 /* Create a mutex */
208
209 Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex);
210 if (ACPI_FAILURE (Status))
211 {
212 AcpiUtRemoveReference (ObjDesc);
213 goto UnlockAndExit;
214 }
215
216 /* Special case for ACPI Global Lock */
217
218 if (strcmp (InitVal->Name, "_GL_") == 0)
219 {
220 AcpiGbl_GlobalLockMutex = ObjDesc;
221
222 /* Create additional counting semaphore for global lock */
223
224 Status = AcpiOsCreateSemaphore (
225 1, 0, &AcpiGbl_GlobalLockSemaphore);
226 if (ACPI_FAILURE (Status))
227 {
228 AcpiUtRemoveReference (ObjDesc);
229 goto UnlockAndExit;
230 }
231 }
232 break;
233
234 default:
235
236 ACPI_ERROR ((AE_INFO, "Unsupported initial type value 0x%X",
237 InitVal->Type));
238 AcpiUtRemoveReference (ObjDesc);
239 ObjDesc = NULL;
240 continue;
241 }
242
243 /* Store pointer to value descriptor in the Node */
244
245 Status = AcpiNsAttachObject (NewNode, ObjDesc,
246 ObjDesc->Common.Type);
247
248 /* Remove local reference to the object */
249
250 AcpiUtRemoveReference (ObjDesc);
251 }
252 }
253
254
255 UnlockAndExit:
256 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
257
258 /* Save a handle to "_GPE", it is always present */
259
260 if (ACPI_SUCCESS (Status))
261 {
262 Status = AcpiNsGetNode (NULL, "\\_GPE", ACPI_NS_NO_UPSEARCH,
263 &AcpiGbl_FadtGpeDevice);
264 }
265
266 return_ACPI_STATUS (Status);
267 }
268
269
270 /*******************************************************************************
271 *
272 * FUNCTION: AcpiNsLookup
273 *
274 * PARAMETERS: ScopeInfo - Current scope info block
275 * Pathname - Search pathname, in internal format
276 * (as represented in the AML stream)
277 * Type - Type associated with name
278 * InterpreterMode - IMODE_LOAD_PASS2 => add name if not found
279 * Flags - Flags describing the search restrictions
280 * WalkState - Current state of the walk
281 * ReturnNode - Where the Node is placed (if found
282 * or created successfully)
283 *
284 * RETURN: Status
285 *
286 * DESCRIPTION: Find or enter the passed name in the name space.
287 * Log an error if name not found in Exec mode.
288 *
289 * MUTEX: Assumes namespace is locked.
290 *
291 ******************************************************************************/
292
293 ACPI_STATUS
294 AcpiNsLookup (
295 ACPI_GENERIC_STATE *ScopeInfo,
296 char *Pathname,
297 ACPI_OBJECT_TYPE Type,
298 ACPI_INTERPRETER_MODE InterpreterMode,
299 UINT32 Flags,
300 ACPI_WALK_STATE *WalkState,
301 ACPI_NAMESPACE_NODE **ReturnNode)
302 {
303 ACPI_STATUS Status;
304 char *Path = Pathname;
305 ACPI_NAMESPACE_NODE *PrefixNode;
306 ACPI_NAMESPACE_NODE *CurrentNode = NULL;
307 ACPI_NAMESPACE_NODE *ThisNode = NULL;
308 UINT32 NumSegments;
309 UINT32 NumCarats;
310 ACPI_NAME SimpleName;
311 ACPI_OBJECT_TYPE TypeToCheckFor;
312 ACPI_OBJECT_TYPE ThisSearchType;
313 UINT32 SearchParentFlag = ACPI_NS_SEARCH_PARENT;
314 UINT32 LocalFlags;
315
316
317 ACPI_FUNCTION_TRACE (NsLookup);
318
319
320 if (!ReturnNode)
321 {
322 return_ACPI_STATUS (AE_BAD_PARAMETER);
323 }
324
325 LocalFlags = Flags &
326 ~(ACPI_NS_ERROR_IF_FOUND | ACPI_NS_OVERRIDE_IF_FOUND |
327 ACPI_NS_SEARCH_PARENT);
328 *ReturnNode = ACPI_ENTRY_NOT_FOUND;
329 AcpiGbl_NsLookupCount++;
330
331 if (!AcpiGbl_RootNode)
332 {
333 return_ACPI_STATUS (AE_NO_NAMESPACE);
334 }
335
336 /* Get the prefix scope. A null scope means use the root scope */
337
338 if ((!ScopeInfo) ||
339 (!ScopeInfo->Scope.Node))
340 {
341 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
342 "Null scope prefix, using root node (%p)\n",
343 AcpiGbl_RootNode));
344
345 PrefixNode = AcpiGbl_RootNode;
346 }
347 else
348 {
349 PrefixNode = ScopeInfo->Scope.Node;
350 if (ACPI_GET_DESCRIPTOR_TYPE (PrefixNode) != ACPI_DESC_TYPE_NAMED)
351 {
352 ACPI_ERROR ((AE_INFO, "%p is not a namespace node [%s]",
353 PrefixNode, AcpiUtGetDescriptorName (PrefixNode)));
354 return_ACPI_STATUS (AE_AML_INTERNAL);
355 }
356
357 if (!(Flags & ACPI_NS_PREFIX_IS_SCOPE))
358 {
359 /*
360 * This node might not be a actual "scope" node (such as a
361 * Device/Method, etc.) It could be a Package or other object
362 * node. Backup up the tree to find the containing scope node.
363 */
364 while (!AcpiNsOpensScope (PrefixNode->Type) &&
365 PrefixNode->Type != ACPI_TYPE_ANY)
366 {
367 PrefixNode = PrefixNode->Parent;
368 }
369 }
370 }
371
372 /* Save type. TBD: may be no longer necessary */
373
374 TypeToCheckFor = Type;
375
376 /*
377 * Begin examination of the actual pathname
378 */
379 if (!Pathname)
380 {
381 /* A Null NamePath is allowed and refers to the root */
382
383 NumSegments = 0;
384 ThisNode = AcpiGbl_RootNode;
385 Path = "";
386
387 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
388 "Null Pathname (Zero segments), Flags=%X\n", Flags));
389 }
390 else
391 {
392 /*
393 * Name pointer is valid (and must be in internal name format)
394 *
395 * Check for scope prefixes:
396 *
397 * As represented in the AML stream, a namepath consists of an
398 * optional scope prefix followed by a name segment part.
399 *
400 * If present, the scope prefix is either a Root Prefix (in
401 * which case the name is fully qualified), or one or more
402 * Parent Prefixes (in which case the name's scope is relative
403 * to the current scope).
404 */
405 if (*Path == (UINT8) AML_ROOT_PREFIX)
406 {
407 /* Pathname is fully qualified, start from the root */
408
409 ThisNode = AcpiGbl_RootNode;
410 SearchParentFlag = ACPI_NS_NO_UPSEARCH;
411
412 /* Point to name segment part */
413
414 Path++;
415
416 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
417 "Path is absolute from root [%p]\n", ThisNode));
418 }
419 else
420 {
421 /* Pathname is relative to current scope, start there */
422
423 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
424 "Searching relative to prefix scope [%4.4s] (%p)\n",
425 AcpiUtGetNodeName (PrefixNode), PrefixNode));
426
427 /*
428 * Handle multiple Parent Prefixes (carat) by just getting
429 * the parent node for each prefix instance.
430 */
431 ThisNode = PrefixNode;
432 NumCarats = 0;
433 while (*Path == (UINT8) AML_PARENT_PREFIX)
434 {
435 /* Name is fully qualified, no search rules apply */
436
437 SearchParentFlag = ACPI_NS_NO_UPSEARCH;
438
439 /*
440 * Point past this prefix to the name segment
441 * part or the next Parent Prefix
442 */
443 Path++;
444
445 /* Backup to the parent node */
446
447 NumCarats++;
448 ThisNode = ThisNode->Parent;
449 if (!ThisNode)
450 {
451 /* Current scope has no parent scope */
452
453 ACPI_ERROR ((AE_INFO,
454 "%s: Path has too many parent prefixes (^) "
455 "- reached beyond root node", Pathname));
456 return_ACPI_STATUS (AE_NOT_FOUND);
457 }
458 }
459
460 if (SearchParentFlag == ACPI_NS_NO_UPSEARCH)
461 {
462 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
463 "Search scope is [%4.4s], path has %u carat(s)\n",
464 AcpiUtGetNodeName (ThisNode), NumCarats));
465 }
466 }
467
468 /*
469 * Determine the number of ACPI name segments in this pathname.
470 *
471 * The segment part consists of either:
472 * - A Null name segment (0)
473 * - A DualNamePrefix followed by two 4-byte name segments
474 * - A MultiNamePrefix followed by a byte indicating the
475 * number of segments and the segments themselves.
476 * - A single 4-byte name segment
477 *
478 * Examine the name prefix opcode, if any, to determine the number of
479 * segments.
480 */
481 switch (*Path)
482 {
483 case 0:
484 /*
485 * Null name after a root or parent prefixes. We already
486 * have the correct target node and there are no name segments.
487 */
488 NumSegments = 0;
489 Type = ThisNode->Type;
490
491 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
492 "Prefix-only Pathname (Zero name segments), Flags=%X\n",
493 Flags));
494 break;
495
496 case AML_DUAL_NAME_PREFIX:
497
498 /* More than one NameSeg, search rules do not apply */
499
500 SearchParentFlag = ACPI_NS_NO_UPSEARCH;
501
502 /* Two segments, point to first name segment */
503
504 NumSegments = 2;
505 Path++;
506
507 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
508 "Dual Pathname (2 segments, Flags=%X)\n", Flags));
509 break;
510
511 case AML_MULTI_NAME_PREFIX:
512
513 /* More than one NameSeg, search rules do not apply */
514
515 SearchParentFlag = ACPI_NS_NO_UPSEARCH;
516
517 /* Extract segment count, point to first name segment */
518
519 Path++;
520 NumSegments = (UINT32) (UINT8) *Path;
521 Path++;
522
523 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
524 "Multi Pathname (%u Segments, Flags=%X)\n",
525 NumSegments, Flags));
526 break;
527
528 default:
529 /*
530 * Not a Null name, no Dual or Multi prefix, hence there is
531 * only one name segment and Pathname is already pointing to it.
532 */
533 NumSegments = 1;
534
535 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
536 "Simple Pathname (1 segment, Flags=%X)\n", Flags));
537 break;
538 }
539
540 ACPI_DEBUG_EXEC (AcpiNsPrintPathname (NumSegments, Path));
541 }
542
543
544 /*
545 * Search namespace for each segment of the name. Loop through and
546 * verify (or add to the namespace) each name segment.
547 *
548 * The object type is significant only at the last name
549 * segment. (We don't care about the types along the path, only
550 * the type of the final target object.)
551 */
552 ThisSearchType = ACPI_TYPE_ANY;
553 CurrentNode = ThisNode;
554 while (NumSegments && CurrentNode)
555 {
556 NumSegments--;
557 if (!NumSegments)
558 {
559 /* This is the last segment, enable typechecking */
560
561 ThisSearchType = Type;
562
563 /*
564 * Only allow automatic parent search (search rules) if the caller
565 * requested it AND we have a single, non-fully-qualified NameSeg
566 */
567 if ((SearchParentFlag != ACPI_NS_NO_UPSEARCH) &&
568 (Flags & ACPI_NS_SEARCH_PARENT))
569 {
570 LocalFlags |= ACPI_NS_SEARCH_PARENT;
571 }
572
573 /* Set error flag according to caller */
574
575 if (Flags & ACPI_NS_ERROR_IF_FOUND)
576 {
577 LocalFlags |= ACPI_NS_ERROR_IF_FOUND;
578 }
579
580 /* Set override flag according to caller */
581
582 if (Flags & ACPI_NS_OVERRIDE_IF_FOUND)
583 {
584 LocalFlags |= ACPI_NS_OVERRIDE_IF_FOUND;
585 }
586 }
587
588 /* Extract one ACPI name from the front of the pathname */
589
590 ACPI_MOVE_32_TO_32 (&SimpleName, Path);
591
592 /* Try to find the single (4 character) ACPI name */
593
594 Status = AcpiNsSearchAndEnter (SimpleName, WalkState, CurrentNode,
595 InterpreterMode, ThisSearchType, LocalFlags, &ThisNode);
596 if (ACPI_FAILURE (Status))
597 {
598 if (Status == AE_NOT_FOUND)
599 {
600 /* Name not found in ACPI namespace */
601
602 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
603 "Name [%4.4s] not found in scope [%4.4s] %p\n",
604 (char *) &SimpleName, (char *) &CurrentNode->Name,
605 CurrentNode));
606 }
607
608 #ifdef ACPI_ASL_COMPILER
609 /*
610 * If this ACPI name already exists within the namespace as an
611 * external declaration, then mark the external as a conflicting
612 * declaration and proceed to process the current node as if it did
613 * not exist in the namespace. If this node is not processed as
614 * normal, then it could cause improper namespace resolution
615 * by failing to open a new scope.
616 */
617 if (AcpiGbl_DisasmFlag &&
618 (Status == AE_ALREADY_EXISTS) &&
619 ((ThisNode->Flags & ANOBJ_IS_EXTERNAL) ||
620 (WalkState && WalkState->Opcode == AML_EXTERNAL_OP)))
621 {
622 ThisNode->Flags &= ~ANOBJ_IS_EXTERNAL;
623 ThisNode->Type = (UINT8)ThisSearchType;
624 if (WalkState->Opcode != AML_EXTERNAL_OP)
625 {
626 AcpiDmMarkExternalConflict (ThisNode);
627 }
628 break;
629 }
630 #endif
631
632 *ReturnNode = ThisNode;
633 return_ACPI_STATUS (Status);
634 }
635
636 /* More segments to follow? */
637
638 if (NumSegments > 0)
639 {
640 /*
641 * If we have an alias to an object that opens a scope (such as a
642 * device or processor), we need to dereference the alias here so
643 * that we can access any children of the original node (via the
644 * remaining segments).
645 */
646 if (ThisNode->Type == ACPI_TYPE_LOCAL_ALIAS)
647 {
648 if (!ThisNode->Object)
649 {
650 return_ACPI_STATUS (AE_NOT_EXIST);
651 }
652
653 if (AcpiNsOpensScope (((ACPI_NAMESPACE_NODE *)
654 ThisNode->Object)->Type))
655 {
656 ThisNode = (ACPI_NAMESPACE_NODE *) ThisNode->Object;
657 }
658 }
659 #ifdef ACPI_ASL_COMPILER
660 if (!AcpiGbl_DisasmFlag &&
661 (ThisNode->Flags & ANOBJ_IS_EXTERNAL))
662 {
663 ThisNode->Flags |= IMPLICIT_EXTERNAL;
664 }
665 #endif
666 }
667
668 /* Special handling for the last segment (NumSegments == 0) */
669
670 else
671 {
672 /*
673 * Sanity typecheck of the target object:
674 *
675 * If 1) This is the last segment (NumSegments == 0)
676 * 2) And we are looking for a specific type
677 * (Not checking for TYPE_ANY)
678 * 3) Which is not an alias
679 * 4) Which is not a local type (TYPE_SCOPE)
680 * 5) And the type of target object is known (not TYPE_ANY)
681 * 6) And target object does not match what we are looking for
682 *
683 * Then we have a type mismatch. Just warn and ignore it.
684 */
685 if ((TypeToCheckFor != ACPI_TYPE_ANY) &&
686 (TypeToCheckFor != ACPI_TYPE_LOCAL_ALIAS) &&
687 (TypeToCheckFor != ACPI_TYPE_LOCAL_METHOD_ALIAS) &&
688 (TypeToCheckFor != ACPI_TYPE_LOCAL_SCOPE) &&
689 (ThisNode->Type != ACPI_TYPE_ANY) &&
690 (ThisNode->Type != TypeToCheckFor))
691 {
692 /* Complain about a type mismatch */
693
694 ACPI_WARNING ((AE_INFO,
695 "NsLookup: Type mismatch on %4.4s (%s), searching for (%s)",
696 ACPI_CAST_PTR (char, &SimpleName),
697 AcpiUtGetTypeName (ThisNode->Type),
698 AcpiUtGetTypeName (TypeToCheckFor)));
699 }
700
701 /*
702 * If this is the last name segment and we are not looking for a
703 * specific type, but the type of found object is known, use that
704 * type to (later) see if it opens a scope.
705 */
706 if (Type == ACPI_TYPE_ANY)
707 {
708 Type = ThisNode->Type;
709 }
710 }
711
712 /* Point to next name segment and make this node current */
713
714 Path += ACPI_NAME_SIZE;
715 CurrentNode = ThisNode;
716 }
717
718 /* Always check if we need to open a new scope */
719
720 if (!(Flags & ACPI_NS_DONT_OPEN_SCOPE) && (WalkState))
721 {
722 /*
723 * If entry is a type which opens a scope, push the new scope on the
724 * scope stack.
725 */
726 if (AcpiNsOpensScope (Type))
727 {
728 Status = AcpiDsScopeStackPush (ThisNode, Type, WalkState);
729 if (ACPI_FAILURE (Status))
730 {
731 return_ACPI_STATUS (Status);
732 }
733 }
734 }
735
736 *ReturnNode = ThisNode;
737 return_ACPI_STATUS (AE_OK);
738 }