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