1 /******************************************************************************* 2 * 3 * Module Name: nsaccess - Top-level functions for accessing ACPI namespace 4 * 5 ******************************************************************************/ 6 7 /* 8 * Copyright (C) 2000 - 2019, 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 char *ExternalPath; 306 ACPI_NAMESPACE_NODE *PrefixNode; 307 ACPI_NAMESPACE_NODE *CurrentNode = NULL; 308 ACPI_NAMESPACE_NODE *ThisNode = NULL; 309 UINT32 NumSegments; 310 UINT32 NumCarats; 311 ACPI_NAME SimpleName; 312 ACPI_OBJECT_TYPE TypeToCheckFor; 313 ACPI_OBJECT_TYPE ThisSearchType; 314 UINT32 SearchParentFlag = ACPI_NS_SEARCH_PARENT; 315 UINT32 LocalFlags; 316 ACPI_INTERPRETER_MODE LocalInterpreterMode; 317 318 319 ACPI_FUNCTION_TRACE (NsLookup); 320 321 322 if (!ReturnNode) 323 { 324 return_ACPI_STATUS (AE_BAD_PARAMETER); 325 } 326 327 LocalFlags = Flags & 328 ~(ACPI_NS_ERROR_IF_FOUND | ACPI_NS_OVERRIDE_IF_FOUND | 329 ACPI_NS_SEARCH_PARENT); 330 *ReturnNode = ACPI_ENTRY_NOT_FOUND; 331 AcpiGbl_NsLookupCount++; 332 333 if (!AcpiGbl_RootNode) 334 { 335 return_ACPI_STATUS (AE_NO_NAMESPACE); 336 } 337 338 /* Get the prefix scope. A null scope means use the root scope */ 339 340 if ((!ScopeInfo) || 341 (!ScopeInfo->Scope.Node)) 342 { 343 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 344 "Null scope prefix, using root node (%p)\n", 345 AcpiGbl_RootNode)); 346 347 PrefixNode = AcpiGbl_RootNode; 348 } 349 else 350 { 351 PrefixNode = ScopeInfo->Scope.Node; 352 if (ACPI_GET_DESCRIPTOR_TYPE (PrefixNode) != ACPI_DESC_TYPE_NAMED) 353 { 354 ACPI_ERROR ((AE_INFO, "%p is not a namespace node [%s]", 355 PrefixNode, AcpiUtGetDescriptorName (PrefixNode))); 356 return_ACPI_STATUS (AE_AML_INTERNAL); 357 } 358 359 if (!(Flags & ACPI_NS_PREFIX_IS_SCOPE)) 360 { 361 /* 362 * This node might not be a actual "scope" node (such as a 363 * Device/Method, etc.) It could be a Package or other object 364 * node. Backup up the tree to find the containing scope node. 365 */ 366 while (!AcpiNsOpensScope (PrefixNode->Type) && 367 PrefixNode->Type != ACPI_TYPE_ANY) 368 { 369 PrefixNode = PrefixNode->Parent; 370 } 371 } 372 } 373 374 /* Save type. TBD: may be no longer necessary */ 375 376 TypeToCheckFor = Type; 377 378 /* 379 * Begin examination of the actual pathname 380 */ 381 if (!Pathname) 382 { 383 /* A Null NamePath is allowed and refers to the root */ 384 385 NumSegments = 0; 386 ThisNode = AcpiGbl_RootNode; 387 Path = ""; 388 389 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 390 "Null Pathname (Zero segments), Flags=%X\n", Flags)); 391 } 392 else 393 { 394 /* 395 * Name pointer is valid (and must be in internal name format) 396 * 397 * Check for scope prefixes: 398 * 399 * As represented in the AML stream, a namepath consists of an 400 * optional scope prefix followed by a name segment part. 401 * 402 * If present, the scope prefix is either a Root Prefix (in 403 * which case the name is fully qualified), or one or more 404 * Parent Prefixes (in which case the name's scope is relative 405 * to the current scope). 406 */ 407 if (*Path == (UINT8) AML_ROOT_PREFIX) 408 { 409 /* Pathname is fully qualified, start from the root */ 410 411 ThisNode = AcpiGbl_RootNode; 412 SearchParentFlag = ACPI_NS_NO_UPSEARCH; 413 414 /* Point to name segment part */ 415 416 Path++; 417 418 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 419 "Path is absolute from root [%p]\n", ThisNode)); 420 } 421 else 422 { 423 /* Pathname is relative to current scope, start there */ 424 425 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 426 "Searching relative to prefix scope [%4.4s] (%p)\n", 427 AcpiUtGetNodeName (PrefixNode), PrefixNode)); 428 429 /* 430 * Handle multiple Parent Prefixes (carat) by just getting 431 * the parent node for each prefix instance. 432 */ 433 ThisNode = PrefixNode; 434 NumCarats = 0; 435 while (*Path == (UINT8) AML_PARENT_PREFIX) 436 { 437 /* Name is fully qualified, no search rules apply */ 438 439 SearchParentFlag = ACPI_NS_NO_UPSEARCH; 440 441 /* 442 * Point past this prefix to the name segment 443 * part or the next Parent Prefix 444 */ 445 Path++; 446 447 /* Backup to the parent node */ 448 449 NumCarats++; 450 ThisNode = ThisNode->Parent; 451 if (!ThisNode) 452 { 453 /* 454 * Current scope has no parent scope. Externalize 455 * the internal path for error message. 456 */ 457 Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, Pathname, 458 NULL, &ExternalPath); 459 if (ACPI_SUCCESS (Status)) 460 { 461 ACPI_ERROR ((AE_INFO, 462 "%s: Path has too many parent prefixes (^)", 463 ExternalPath)); 464 465 ACPI_FREE (ExternalPath); 466 } 467 468 return_ACPI_STATUS (AE_NOT_FOUND); 469 } 470 } 471 472 if (SearchParentFlag == ACPI_NS_NO_UPSEARCH) 473 { 474 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 475 "Search scope is [%4.4s], path has %u carat(s)\n", 476 AcpiUtGetNodeName (ThisNode), NumCarats)); 477 } 478 } 479 480 /* 481 * Determine the number of ACPI name segments in this pathname. 482 * 483 * The segment part consists of either: 484 * - A Null name segment (0) 485 * - A DualNamePrefix followed by two 4-byte name segments 486 * - A MultiNamePrefix followed by a byte indicating the 487 * number of segments and the segments themselves. 488 * - A single 4-byte name segment 489 * 490 * Examine the name prefix opcode, if any, to determine the number of 491 * segments. 492 */ 493 switch (*Path) 494 { 495 case 0: 496 /* 497 * Null name after a root or parent prefixes. We already 498 * have the correct target node and there are no name segments. 499 */ 500 NumSegments = 0; 501 Type = ThisNode->Type; 502 503 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 504 "Prefix-only Pathname (Zero name segments), Flags=%X\n", 505 Flags)); 506 break; 507 508 case AML_DUAL_NAME_PREFIX: 509 510 /* More than one NameSeg, search rules do not apply */ 511 512 SearchParentFlag = ACPI_NS_NO_UPSEARCH; 513 514 /* Two segments, point to first name segment */ 515 516 NumSegments = 2; 517 Path++; 518 519 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 520 "Dual Pathname (2 segments, Flags=%X)\n", Flags)); 521 break; 522 523 case AML_MULTI_NAME_PREFIX: 524 525 /* More than one NameSeg, search rules do not apply */ 526 527 SearchParentFlag = ACPI_NS_NO_UPSEARCH; 528 529 /* Extract segment count, point to first name segment */ 530 531 Path++; 532 NumSegments = (UINT32) (UINT8) *Path; 533 Path++; 534 535 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 536 "Multi Pathname (%u Segments, Flags=%X)\n", 537 NumSegments, Flags)); 538 break; 539 540 default: 541 /* 542 * Not a Null name, no Dual or Multi prefix, hence there is 543 * only one name segment and Pathname is already pointing to it. 544 */ 545 NumSegments = 1; 546 547 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 548 "Simple Pathname (1 segment, Flags=%X)\n", Flags)); 549 break; 550 } 551 552 ACPI_DEBUG_EXEC (AcpiNsPrintPathname (NumSegments, Path)); 553 } 554 555 556 /* 557 * Search namespace for each segment of the name. Loop through and 558 * verify (or add to the namespace) each name segment. 559 * 560 * The object type is significant only at the last name 561 * segment. (We don't care about the types along the path, only 562 * the type of the final target object.) 563 */ 564 ThisSearchType = ACPI_TYPE_ANY; 565 CurrentNode = ThisNode; 566 567 while (NumSegments && CurrentNode) 568 { 569 NumSegments--; 570 if (!NumSegments) 571 { 572 /* This is the last segment, enable typechecking */ 573 574 ThisSearchType = Type; 575 576 /* 577 * Only allow automatic parent search (search rules) if the caller 578 * requested it AND we have a single, non-fully-qualified NameSeg 579 */ 580 if ((SearchParentFlag != ACPI_NS_NO_UPSEARCH) && 581 (Flags & ACPI_NS_SEARCH_PARENT)) 582 { 583 LocalFlags |= ACPI_NS_SEARCH_PARENT; 584 } 585 586 /* Set error flag according to caller */ 587 588 if (Flags & ACPI_NS_ERROR_IF_FOUND) 589 { 590 LocalFlags |= ACPI_NS_ERROR_IF_FOUND; 591 } 592 593 /* Set override flag according to caller */ 594 595 if (Flags & ACPI_NS_OVERRIDE_IF_FOUND) 596 { 597 LocalFlags |= ACPI_NS_OVERRIDE_IF_FOUND; 598 } 599 } 600 601 /* Handle opcodes that create a new NameSeg via a full NamePath */ 602 603 LocalInterpreterMode = InterpreterMode; 604 if ((Flags & ACPI_NS_PREFIX_MUST_EXIST) && (NumSegments > 0)) 605 { 606 /* Every element of the path must exist (except for the final NameSeg) */ 607 608 LocalInterpreterMode = ACPI_IMODE_EXECUTE; 609 } 610 611 /* Extract one ACPI name from the front of the pathname */ 612 613 ACPI_MOVE_32_TO_32 (&SimpleName, Path); 614 615 /* Try to find the single (4 character) ACPI name */ 616 617 Status = AcpiNsSearchAndEnter (SimpleName, WalkState, CurrentNode, 618 LocalInterpreterMode, ThisSearchType, LocalFlags, &ThisNode); 619 if (ACPI_FAILURE (Status)) 620 { 621 if (Status == AE_NOT_FOUND) 622 { 623 #if !defined ACPI_ASL_COMPILER /* Note: iASL reports this error by itself, not needed here */ 624 if (Flags & ACPI_NS_PREFIX_MUST_EXIST) 625 { 626 AcpiOsPrintf (ACPI_MSG_BIOS_ERROR 627 "Object does not exist: %4.4s\n", &SimpleName); 628 } 629 #endif 630 /* Name not found in ACPI namespace */ 631 632 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 633 "Name [%4.4s] not found in scope [%4.4s] %p\n", 634 (char *) &SimpleName, (char *) &CurrentNode->Name, 635 CurrentNode)); 636 } 637 638 #ifdef ACPI_EXEC_APP 639 if ((Status == AE_ALREADY_EXISTS) && 640 (ThisNode->Flags & ANOBJ_NODE_EARLY_INIT)) 641 { 642 ThisNode->Flags &= ~ANOBJ_NODE_EARLY_INIT; 643 Status = AE_OK; 644 } 645 #endif 646 647 #ifdef ACPI_ASL_COMPILER 648 /* 649 * If this ACPI name already exists within the namespace as an 650 * external declaration, then mark the external as a conflicting 651 * declaration and proceed to process the current node as if it did 652 * not exist in the namespace. If this node is not processed as 653 * normal, then it could cause improper namespace resolution 654 * by failing to open a new scope. 655 */ 656 if (AcpiGbl_DisasmFlag && 657 (Status == AE_ALREADY_EXISTS) && 658 ((ThisNode->Flags & ANOBJ_IS_EXTERNAL) || 659 (WalkState && WalkState->Opcode == AML_EXTERNAL_OP))) 660 { 661 ThisNode->Flags &= ~ANOBJ_IS_EXTERNAL; 662 ThisNode->Type = (UINT8)ThisSearchType; 663 if (WalkState->Opcode != AML_EXTERNAL_OP) 664 { 665 AcpiDmMarkExternalConflict (ThisNode); 666 } 667 break; 668 } 669 #endif 670 671 *ReturnNode = ThisNode; 672 return_ACPI_STATUS (Status); 673 } 674 675 /* More segments to follow? */ 676 677 if (NumSegments > 0) 678 { 679 /* 680 * If we have an alias to an object that opens a scope (such as a 681 * device or processor), we need to dereference the alias here so 682 * that we can access any children of the original node (via the 683 * remaining segments). 684 */ 685 if (ThisNode->Type == ACPI_TYPE_LOCAL_ALIAS) 686 { 687 if (!ThisNode->Object) 688 { 689 return_ACPI_STATUS (AE_NOT_EXIST); 690 } 691 692 if (AcpiNsOpensScope (((ACPI_NAMESPACE_NODE *) 693 ThisNode->Object)->Type)) 694 { 695 ThisNode = (ACPI_NAMESPACE_NODE *) ThisNode->Object; 696 } 697 } 698 } 699 700 /* Special handling for the last segment (NumSegments == 0) */ 701 702 else 703 { 704 /* 705 * Sanity typecheck of the target object: 706 * 707 * If 1) This is the last segment (NumSegments == 0) 708 * 2) And we are looking for a specific type 709 * (Not checking for TYPE_ANY) 710 * 3) Which is not an alias 711 * 4) Which is not a local type (TYPE_SCOPE) 712 * 5) And the type of target object is known (not TYPE_ANY) 713 * 6) And target object does not match what we are looking for 714 * 715 * Then we have a type mismatch. Just warn and ignore it. 716 */ 717 if ((TypeToCheckFor != ACPI_TYPE_ANY) && 718 (TypeToCheckFor != ACPI_TYPE_LOCAL_ALIAS) && 719 (TypeToCheckFor != ACPI_TYPE_LOCAL_METHOD_ALIAS) && 720 (TypeToCheckFor != ACPI_TYPE_LOCAL_SCOPE) && 721 (ThisNode->Type != ACPI_TYPE_ANY) && 722 (ThisNode->Type != TypeToCheckFor)) 723 { 724 /* Complain about a type mismatch */ 725 726 ACPI_WARNING ((AE_INFO, 727 "NsLookup: Type mismatch on %4.4s (%s), searching for (%s)", 728 ACPI_CAST_PTR (char, &SimpleName), 729 AcpiUtGetTypeName (ThisNode->Type), 730 AcpiUtGetTypeName (TypeToCheckFor))); 731 } 732 733 /* 734 * If this is the last name segment and we are not looking for a 735 * specific type, but the type of found object is known, use that 736 * type to (later) see if it opens a scope. 737 */ 738 if (Type == ACPI_TYPE_ANY) 739 { 740 Type = ThisNode->Type; 741 } 742 } 743 744 /* Point to next name segment and make this node current */ 745 746 Path += ACPI_NAME_SIZE; 747 CurrentNode = ThisNode; 748 } 749 750 /* Always check if we need to open a new scope */ 751 752 if (!(Flags & ACPI_NS_DONT_OPEN_SCOPE) && (WalkState)) 753 { 754 /* 755 * If entry is a type which opens a scope, push the new scope on the 756 * scope stack. 757 */ 758 if (AcpiNsOpensScope (Type)) 759 { 760 Status = AcpiDsScopeStackPush (ThisNode, Type, WalkState); 761 if (ACPI_FAILURE (Status)) 762 { 763 return_ACPI_STATUS (Status); 764 } 765 } 766 } 767 768 #ifdef ACPI_EXEC_APP 769 if (Flags & ACPI_NS_EARLY_INIT) 770 { 771 ThisNode->Flags |= ANOBJ_NODE_EARLY_INIT; 772 } 773 #endif 774 775 *ReturnNode = ThisNode; 776 return_ACPI_STATUS (AE_OK); 777 } 778