nsaccess.c revision 82367
119370Spst/******************************************************************************* 219370Spst * 3130803Smarcel * Module Name: nsaccess - Top-level functions for accessing ACPI namespace 4130803Smarcel * $Revision: 130 $ 5130803Smarcel * 698944Sobrien ******************************************************************************/ 719370Spst 898944Sobrien/****************************************************************************** 998944Sobrien * 1098944Sobrien * 1. Copyright Notice 1198944Sobrien * 1219370Spst * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. 1398944Sobrien * All rights reserved. 1498944Sobrien * 1598944Sobrien * 2. License 1698944Sobrien * 1719370Spst * 2.1. This is your license from Intel Corp. under its intellectual property 1898944Sobrien * rights. You may have additional license terms from the party that provided 1998944Sobrien * you this software, covering your right to use that party's intellectual 2098944Sobrien * property rights. 2198944Sobrien * 2219370Spst * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 2319370Spst * copy of the source code appearing in this file ("Covered Code") an 2419370Spst * irrevocable, perpetual, worldwide license under Intel's copyrights in the 2519370Spst * base code distributed originally by Intel ("Original Intel Code") to copy, 2619370Spst * make derivatives, distribute, use and display any portion of the Covered 2719370Spst * Code in any form, with the right to sublicense such rights; and 28130803Smarcel * 29130803Smarcel * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30130803Smarcel * license (with the right to sublicense), under only those claims of Intel 31130803Smarcel * patents that are infringed by the Original Intel Code, to make, use, sell, 32130803Smarcel * offer to sell, and import the Covered Code and derivative works thereof 3319370Spst * solely to the minimum extent necessary to exercise the above copyright 34130803Smarcel * license, and in no event shall the patent license extend to any additions 35130803Smarcel * to or modifications of the Original Intel Code. No other license or right 36130803Smarcel * is granted directly or by implication, estoppel or otherwise; 37130803Smarcel * 38130803Smarcel * The above copyright and patent license is granted only if the following 39130803Smarcel * conditions are met: 40130803Smarcel * 41130803Smarcel * 3. Conditions 4298944Sobrien * 43130803Smarcel * 3.1. Redistribution of Source with Rights to Further Distribute Source. 4446283Sdfr * Redistribution of source code of any substantial portion of the Covered 45130803Smarcel * Code or modification with rights to further distribute source must include 46130803Smarcel * the above Copyright Notice, the above License, this list of Conditions, 47130803Smarcel * and the following Disclaimer and Export Compliance provision. In addition, 4846283Sdfr * Licensee must cause all Covered Code to which Licensee contributes to 49130803Smarcel * contain a file documenting the changes Licensee made to create that Covered 5046283Sdfr * Code and the date of any change. Licensee must include in that file the 51130803Smarcel * documentation of any changes made by any predecessor Licensee. Licensee 52130803Smarcel * must include a prominent statement that the modification is derived, 5346283Sdfr * directly or indirectly, from Original Intel Code. 54130803Smarcel * 5546283Sdfr * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56130803Smarcel * Redistribution of source code of any substantial portion of the Covered 57130803Smarcel * Code or modification without rights to further distribute source must 58130803Smarcel * include the following Disclaimer and Export Compliance provision in the 59130803Smarcel * documentation and/or other materials provided with distribution. In 60130803Smarcel * addition, Licensee may not authorize further sublicense of source of any 6146283Sdfr * portion of the Covered Code, and must include terms to the effect that the 62130803Smarcel * license from Licensee to its licensee is limited to the intellectual 63130803Smarcel * property embodied in the software Licensee provides to its licensee, and 6498944Sobrien * not to intellectual property embodied in modifications its licensee may 6598944Sobrien * make. 6698944Sobrien * 67130803Smarcel * 3.3. Redistribution of Executable. Redistribution in executable form of any 68130803Smarcel * substantial portion of the Covered Code or modification must reproduce the 69130803Smarcel * above Copyright Notice, and the following Disclaimer and Export Compliance 70130803Smarcel * provision in the documentation and/or other materials provided with the 71130803Smarcel * distribution. 72130803Smarcel * 7398944Sobrien * 3.4. Intel retains all right, title, and interest in and to the Original 74130803Smarcel * Intel Code. 75130803Smarcel * 76130803Smarcel * 3.5. Neither the name Intel nor any other trademark owned or controlled by 7798944Sobrien * Intel shall be used in advertising or otherwise to promote the sale, use or 7898944Sobrien * other dealings in products derived from or relating to the Covered Code 7998944Sobrien * without prior written authorization from Intel. 8098944Sobrien * 8198944Sobrien * 4. Disclaimer and Export Compliance 8298944Sobrien * 83130803Smarcel * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 8419370Spst * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 8519370Spst * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 8619370Spst * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 8719370Spst * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 8819370Spst * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 8998944Sobrien * PARTICULAR PURPOSE. 90130803Smarcel * 9119370Spst * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92130803Smarcel * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93130803Smarcel * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 9419370Spst * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95130803Smarcel * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 9619370Spst * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97130803Smarcel * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98130803Smarcel * LIMITED REMEDY. 99130803Smarcel * 10019370Spst * 4.3. Licensee shall not export, either directly or indirectly, any of this 101130803Smarcel * software or system incorporating such software without first obtaining any 10219370Spst * required license or other approval from the U. S. Department of Commerce or 103130803Smarcel * any other agency or department of the United States Government. In the 104130803Smarcel * event Licensee exports any such software from the United States or 105130803Smarcel * re-exports any such software from a foreign destination, Licensee shall 10619370Spst * ensure that the distribution and export/re-export of the software is in 107130803Smarcel * compliance with all laws, regulations, orders, or other restrictions of the 10819370Spst * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109130803Smarcel * any of its subsidiaries will export/re-export any technical data, process, 110130803Smarcel * software, or service, directly or indirectly, to any country for which the 111130803Smarcel * United States government or any agency thereof requires an export license, 112130803Smarcel * other governmental approval, or letter of assurance, without first obtaining 113130803Smarcel * such license, approval or letter. 11419370Spst * 115130803Smarcel *****************************************************************************/ 11619370Spst 117130803Smarcel#define __NSACCESS_C__ 118130803Smarcel 119130803Smarcel#include "acpi.h" 12019370Spst#include "amlcode.h" 121130803Smarcel#include "acinterp.h" 12219370Spst#include "acnamesp.h" 123130803Smarcel#include "acdispat.h" 124130803Smarcel 125130803Smarcel 126130803Smarcel#define _COMPONENT ACPI_NAMESPACE 127130803Smarcel MODULE_NAME ("nsaccess") 128130803Smarcel 12919370Spst 130130803Smarcel/******************************************************************************* 13119370Spst * 132130803Smarcel * FUNCTION: AcpiNsRootInitialize 133130803Smarcel * 134130803Smarcel * PARAMETERS: None 135130803Smarcel * 13619370Spst * RETURN: Status 137130803Smarcel * 13819370Spst * DESCRIPTION: Allocate and initialize the default root named objects 139130803Smarcel * 14098944Sobrien * MUTEX: Locks namespace for entire execution 14146283Sdfr * 14246283Sdfr ******************************************************************************/ 14346283Sdfr 144130803SmarcelACPI_STATUS 145130803SmarcelAcpiNsRootInitialize (void) 14646283Sdfr{ 14746283Sdfr ACPI_STATUS Status = AE_OK; 148130803Smarcel PREDEFINED_NAMES *InitVal = NULL; 149130803Smarcel ACPI_NAMESPACE_NODE *NewNode; 15019370Spst ACPI_OPERAND_OBJECT *ObjDesc; 151130803Smarcel 15219370Spst 15319370Spst FUNCTION_TRACE ("NsRootInitialize"); 15419370Spst 155130803Smarcel 156130803Smarcel AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 157130803Smarcel 158130803Smarcel /* 159130803Smarcel * The global root ptr is initially NULL, so a non-NULL value indicates 160130803Smarcel * that AcpiNsRootInitialize() has already been called; just return. 16119370Spst */ 162130803Smarcel 163130803Smarcel if (AcpiGbl_RootNode) 164130803Smarcel { 165130803Smarcel Status = AE_OK; 166130803Smarcel goto UnlockAndExit; 167130803Smarcel } 168130803Smarcel 16946283Sdfr 17046283Sdfr /* 17198944Sobrien * Tell the rest of the subsystem that the root is initialized 17219370Spst * (This is OK because the namespace is locked) 17398944Sobrien */ 17419370Spst 17598944Sobrien AcpiGbl_RootNode = &AcpiGbl_RootNodeStruct; 17619370Spst 17798944Sobrien 17819370Spst /* Enter the pre-defined names in the name table */ 17998944Sobrien 18019370Spst ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Entering predefined entries into namespace\n")); 18198944Sobrien 18219370Spst for (InitVal = AcpiGbl_PreDefinedNames; InitVal->Name; InitVal++) 183130803Smarcel { 184130803Smarcel Status = AcpiNsLookup (NULL, InitVal->Name, InitVal->Type, 185130803Smarcel IMODE_LOAD_PASS2, NS_NO_UPSEARCH, 18619370Spst NULL, &NewNode); 18798944Sobrien 18898944Sobrien if (ACPI_FAILURE (Status) || (!NewNode)) /* Must be on same line for code converter */ 18998944Sobrien { 19098944Sobrien ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 19198944Sobrien "Could not create predefined name %s, %s\n", 192130803Smarcel InitVal->Name, AcpiFormatException (Status))); 19398944Sobrien } 194130803Smarcel 195130803Smarcel /* 19698944Sobrien * Name entered successfully. 197130803Smarcel * If entry in PreDefinedNames[] specifies an 198130803Smarcel * initial value, create the initial value. 19998944Sobrien */ 200130803Smarcel 201130803Smarcel if (InitVal->Val) 202130803Smarcel { 203130803Smarcel /* 204130803Smarcel * Entry requests an initial value, allocate a 20519370Spst * descriptor for it. 206130803Smarcel */ 207130803Smarcel 20819370Spst ObjDesc = AcpiUtCreateInternalObject (InitVal->Type); 209130803Smarcel if (!ObjDesc) 210130803Smarcel { 211130803Smarcel Status = AE_NO_MEMORY; 21298944Sobrien goto UnlockAndExit; 21398944Sobrien } 21498944Sobrien 21598944Sobrien /* 21698944Sobrien * Convert value string from table entry to 21798944Sobrien * internal representation. Only types actually 218130803Smarcel * used for initial values are implemented here. 219130803Smarcel */ 220130803Smarcel 22119370Spst switch (InitVal->Type) 222130803Smarcel { 22319370Spst 224130803Smarcel case ACPI_TYPE_INTEGER: 225130803Smarcel 22619370Spst ObjDesc->Integer.Value = 22798944Sobrien (ACPI_INTEGER) STRTOUL (InitVal->Val, NULL, 10); 22898944Sobrien break; 22919370Spst 23019370Spst 23119370Spst case ACPI_TYPE_STRING: 23298944Sobrien 23398944Sobrien /* 23498944Sobrien * Build an object around the static string 23598944Sobrien */ 23698944Sobrien ObjDesc->String.Length = STRLEN (InitVal->Val); 23798944Sobrien ObjDesc->String.Pointer = InitVal->Val; 23898944Sobrien ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER; 23998944Sobrien break; 240130803Smarcel 24119370Spst 24298944Sobrien case ACPI_TYPE_MUTEX: 24346283Sdfr 24498944Sobrien ObjDesc->Mutex.SyncLevel = 24598944Sobrien (UINT16) STRTOUL (InitVal->Val, NULL, 10); 24698944Sobrien 24798944Sobrien if (STRCMP (InitVal->Name, "_GL_") == 0) 24898944Sobrien { 249130803Smarcel /* 25046283Sdfr * Create a counting semaphore for the 25198944Sobrien * global lock 25246283Sdfr */ 25319370Spst Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 25419370Spst 1, &ObjDesc->Mutex.Semaphore); 25598944Sobrien 25619370Spst if (ACPI_FAILURE (Status)) 25798944Sobrien { 25846283Sdfr goto UnlockAndExit; 259130803Smarcel } 26019370Spst /* 26198944Sobrien * We just created the mutex for the 26246283Sdfr * global lock, save it 26398944Sobrien */ 26419370Spst 26546283Sdfr AcpiGbl_GlobalLockSemaphore = ObjDesc->Mutex.Semaphore; 266130803Smarcel } 267130803Smarcel 268130803Smarcel else 269130803Smarcel { 27098944Sobrien /* Create a mutex */ 27198944Sobrien 27246283Sdfr Status = AcpiOsCreateSemaphore (1, 1, 27346283Sdfr &ObjDesc->Mutex.Semaphore); 274130803Smarcel 27598944Sobrien if (ACPI_FAILURE (Status)) 27646283Sdfr { 277130803Smarcel goto UnlockAndExit; 278130803Smarcel } 27998944Sobrien } 28046283Sdfr break; 281130803Smarcel 28298944Sobrien 28346283Sdfr default: 284130803Smarcel REPORT_ERROR (("Unsupported initial type value %X\n", 28598944Sobrien InitVal->Type)); 28646283Sdfr AcpiUtRemoveReference (ObjDesc); 287130803Smarcel ObjDesc = NULL; 28898944Sobrien continue; 28946283Sdfr } 290130803Smarcel 29198944Sobrien /* Store pointer to value descriptor in the Node */ 29246283Sdfr 293130803Smarcel AcpiNsAttachObject (NewNode, ObjDesc, ObjDesc->Common.Type); 29498944Sobrien } 29546283Sdfr } 296130803Smarcel 29798944Sobrien 29846283SdfrUnlockAndExit: 299130803Smarcel AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 30098944Sobrien return_ACPI_STATUS (Status); 30146283Sdfr} 302130803Smarcel 30398944Sobrien 30498944Sobrien/******************************************************************************* 305130803Smarcel * 30698944Sobrien * FUNCTION: AcpiNsLookup 30798944Sobrien * 308130803Smarcel * PARAMETERS: PrefixNode - Search scope if name is not fully qualified 309130803Smarcel * Pathname - Search pathname, in internal format 310130803Smarcel * (as represented in the AML stream) 31119370Spst * Type - Type associated with name 31219370Spst * InterpreterMode - IMODE_LOAD_PASS2 => add name if not found 313130803Smarcel * Flags - Flags describing the search restrictions 314130803Smarcel * WalkState - Current state of the walk 31519370Spst * ReturnNode - Where the Node is placed (if found 31646283Sdfr * or created successfully) 31746283Sdfr * 318130803Smarcel * RETURN: Status 31946283Sdfr * 32098944Sobrien * DESCRIPTION: Find or enter the passed name in the name space. 32198944Sobrien * Log an error if name not found in Exec mode. 32298944Sobrien * 32319370Spst * MUTEX: Assumes namespace is locked. 32419370Spst * 32519370Spst ******************************************************************************/ 32619370Spst 327130803SmarcelACPI_STATUS 328130803SmarcelAcpiNsLookup ( 329130803Smarcel ACPI_GENERIC_STATE *ScopeInfo, 330130803Smarcel NATIVE_CHAR *Pathname, 33119370Spst ACPI_OBJECT_TYPE8 Type, 332130803Smarcel OPERATING_MODE InterpreterMode, 333130803Smarcel UINT32 Flags, 334130803Smarcel ACPI_WALK_STATE *WalkState, 33519370Spst ACPI_NAMESPACE_NODE **ReturnNode) 336130803Smarcel{ 337130803Smarcel ACPI_STATUS Status; 338130803Smarcel ACPI_NAMESPACE_NODE *PrefixNode; 339130803Smarcel ACPI_NAMESPACE_NODE *CurrentNode = NULL; 34098944Sobrien ACPI_NAMESPACE_NODE *ScopeToPush = NULL; 341 ACPI_NAMESPACE_NODE *ThisNode = NULL; 342 UINT32 NumSegments; 343 ACPI_NAME SimpleName; 344 BOOLEAN NullNamePath = FALSE; 345 ACPI_OBJECT_TYPE8 TypeToCheckFor; 346 ACPI_OBJECT_TYPE8 ThisSearchType; 347 UINT32 LocalFlags = Flags & ~NS_ERROR_IF_FOUND; 348 349 DEBUG_EXEC (UINT32 i;) 350 351 352 FUNCTION_TRACE ("NsLookup"); 353 354 355 if (!ReturnNode) 356 { 357 return_ACPI_STATUS (AE_BAD_PARAMETER); 358 } 359 360 361 AcpiGbl_NsLookupCount++; 362 363 *ReturnNode = ENTRY_NOT_FOUND; 364 365 366 if (!AcpiGbl_RootNode) 367 { 368 return (AE_NO_NAMESPACE); 369 } 370 371 /* 372 * Get the prefix scope. 373 * A null scope means use the root scope 374 */ 375 376 if ((!ScopeInfo) || 377 (!ScopeInfo->Scope.Node)) 378 { 379 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "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 } 388 389 390 /* 391 * This check is explicitly split to relax the TypeToCheckFor 392 * conditions for BankFieldDefn. Originally, both BankFieldDefn and 393 * DefFieldDefn caused TypeToCheckFor to be set to ACPI_TYPE_REGION, 394 * but the BankFieldDefn may also check for a Field definition as well 395 * as an OperationRegion. 396 */ 397 398 if (INTERNAL_TYPE_FIELD_DEFN == Type) 399 { 400 /* DefFieldDefn defines fields in a Region */ 401 402 TypeToCheckFor = ACPI_TYPE_REGION; 403 } 404 405 else if (INTERNAL_TYPE_BANK_FIELD_DEFN == Type) 406 { 407 /* BankFieldDefn defines data fields in a Field Object */ 408 409 TypeToCheckFor = ACPI_TYPE_ANY; 410 } 411 412 else 413 { 414 TypeToCheckFor = Type; 415 } 416 417 418 /* TBD: [Restructure] - Move the pathname stuff into a new procedure */ 419 420 /* Examine the name pointer */ 421 422 if (!Pathname) 423 { 424 /* 8-12-98 ASL Grammar Update supports null NamePath */ 425 426 NullNamePath = TRUE; 427 NumSegments = 0; 428 ThisNode = AcpiGbl_RootNode; 429 430 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 431 "Null Pathname (Zero segments), Flags=%x\n", Flags)); 432 } 433 434 else 435 { 436 /* 437 * Valid name pointer (Internal name format) 438 * 439 * Check for prefixes. As represented in the AML stream, a 440 * Pathname consists of an optional scope prefix followed by 441 * a segment part. 442 * 443 * If present, the scope prefix is either a RootPrefix (in 444 * which case the name is fully qualified), or zero or more 445 * ParentPrefixes (in which case the name's scope is relative 446 * to the current scope). 447 * 448 * The segment part consists of either: 449 * - A single 4-byte name segment, or 450 * - A DualNamePrefix followed by two 4-byte name segments, or 451 * - A MultiNamePrefixOp, followed by a byte indicating the 452 * number of segments and the segments themselves. 453 */ 454 455 if (*Pathname == AML_ROOT_PREFIX) 456 { 457 /* Pathname is fully qualified, look in root name table */ 458 459 CurrentNode = AcpiGbl_RootNode; 460 461 /* point to segment part */ 462 463 Pathname++; 464 465 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Searching from root [%p]\n", 466 CurrentNode)); 467 468 /* Direct reference to root, "\" */ 469 470 if (!(*Pathname)) 471 { 472 ThisNode = AcpiGbl_RootNode; 473 goto CheckForNewScopeAndExit; 474 } 475 } 476 477 else 478 { 479 /* Pathname is relative to current scope, start there */ 480 481 CurrentNode = PrefixNode; 482 483 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Searching relative to pfx scope [%p]\n", 484 PrefixNode)); 485 486 /* 487 * Handle up-prefix (carat). More than one prefix 488 * is supported 489 */ 490 491 while (*Pathname == AML_PARENT_PREFIX) 492 { 493 /* Point to segment part or next ParentPrefix */ 494 495 Pathname++; 496 497 /* Backup to the parent's scope */ 498 499 ThisNode = AcpiNsGetParentObject (CurrentNode); 500 if (!ThisNode) 501 { 502 /* Current scope has no parent scope */ 503 504 REPORT_ERROR ( 505 ("Too many parent prefixes (^) - reached root\n")); 506 return_ACPI_STATUS (AE_NOT_FOUND); 507 } 508 509 CurrentNode = ThisNode; 510 } 511 } 512 513 514 /* 515 * Examine the name prefix opcode, if any, 516 * to determine the number of segments 517 */ 518 519 if (*Pathname == AML_DUAL_NAME_PREFIX) 520 { 521 NumSegments = 2; 522 523 /* point to first segment */ 524 525 Pathname++; 526 527 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 528 "Dual Pathname (2 segments, Flags=%X)\n", Flags)); 529 } 530 531 else if (*Pathname == AML_MULTI_NAME_PREFIX_OP) 532 { 533 NumSegments = (UINT32)* (UINT8 *) ++Pathname; 534 535 /* point to first segment */ 536 537 Pathname++; 538 539 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 540 "Multi Pathname (%d Segments, Flags=%X) \n", 541 NumSegments, Flags)); 542 } 543 544 else 545 { 546 /* 547 * No Dual or Multi prefix, hence there is only one 548 * segment and Pathname is already pointing to it. 549 */ 550 NumSegments = 1; 551 552 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 553 "Simple Pathname (1 segment, Flags=%X)\n", Flags)); 554 } 555 556#ifdef ACPI_DEBUG 557 558 /* TBD: [Restructure] Make this a procedure */ 559 560 /* Debug only: print the entire name that we are about to lookup */ 561 562 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[")); 563 564 for (i = 0; i < NumSegments; i++) 565 { 566 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_NAMES, "%4.4s/", &Pathname[i * 4])); 567 } 568 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_NAMES, "]\n")); 569#endif 570 } 571 572 573 /* 574 * Search namespace for each segment of the name. 575 * Loop through and verify/add each name segment. 576 */ 577 578 579 while (NumSegments-- && CurrentNode) 580 { 581 /* 582 * Search for the current name segment under the current 583 * named object. The Type is significant only at the last (topmost) 584 * level. (We don't care about the types along the path, only 585 * the type of the final target object.) 586 */ 587 ThisSearchType = ACPI_TYPE_ANY; 588 if (!NumSegments) 589 { 590 ThisSearchType = Type; 591 LocalFlags = Flags; 592 } 593 594 /* Pluck one ACPI name from the front of the pathname */ 595 596 MOVE_UNALIGNED32_TO_32 (&SimpleName, Pathname); 597 598 /* Try to find the ACPI name */ 599 600 Status = AcpiNsSearchAndEnter (SimpleName, WalkState, 601 CurrentNode, InterpreterMode, 602 ThisSearchType, LocalFlags, 603 &ThisNode); 604 605 if (ACPI_FAILURE (Status)) 606 { 607 if (Status == AE_NOT_FOUND) 608 { 609 /* Name not found in ACPI namespace */ 610 611 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 612 "Name [%4.4s] not found in scope %X\n", 613 &SimpleName, CurrentNode)); 614 } 615 616 return_ACPI_STATUS (Status); 617 } 618 619 620 /* 621 * If 1) This is the last segment (NumSegments == 0) 622 * 2) and looking for a specific type 623 * (Not checking for TYPE_ANY) 624 * 3) Which is not an alias 625 * 4) which is not a local type (TYPE_DEF_ANY) 626 * 5) which is not a local type (TYPE_SCOPE) 627 * 6) which is not a local type (TYPE_INDEX_FIELD_DEFN) 628 * 7) and type of object is known (not TYPE_ANY) 629 * 8) and object does not match request 630 * 631 * Then we have a type mismatch. Just warn and ignore it. 632 */ 633 if ((NumSegments == 0) && 634 (TypeToCheckFor != ACPI_TYPE_ANY) && 635 (TypeToCheckFor != INTERNAL_TYPE_ALIAS) && 636 (TypeToCheckFor != INTERNAL_TYPE_DEF_ANY) && 637 (TypeToCheckFor != INTERNAL_TYPE_SCOPE) && 638 (TypeToCheckFor != INTERNAL_TYPE_INDEX_FIELD_DEFN) && 639 (ThisNode->Type != ACPI_TYPE_ANY) && 640 (ThisNode->Type != TypeToCheckFor)) 641 { 642 /* Complain about a type mismatch */ 643 644 REPORT_WARNING ( 645 ("NsLookup: %4.4s, type %X, checking for type %X\n", 646 &SimpleName, ThisNode->Type, TypeToCheckFor)); 647 } 648 649 /* 650 * If this is the last name segment and we are not looking for a 651 * specific type, but the type of found object is known, use that type 652 * to see if it opens a scope. 653 */ 654 655 if ((0 == NumSegments) && (ACPI_TYPE_ANY == Type)) 656 { 657 Type = ThisNode->Type; 658 } 659 660 if ((NumSegments || AcpiNsOpensScope (Type)) && 661 (ThisNode->Child == NULL)) 662 { 663 /* 664 * More segments or the type implies enclosed scope, 665 * and the next scope has not been allocated. 666 */ 667 668 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Load mode=%X ThisNode=%X\n", 669 InterpreterMode, ThisNode)); 670 } 671 672 CurrentNode = ThisNode; 673 674 /* point to next name segment */ 675 676 Pathname += ACPI_NAME_SIZE; 677 } 678 679 680 /* 681 * Always check if we need to open a new scope 682 */ 683 684CheckForNewScopeAndExit: 685 686 if (!(Flags & NS_DONT_OPEN_SCOPE) && (WalkState)) 687 { 688 /* 689 * If entry is a type which opens a scope, 690 * push the new scope on the scope stack. 691 */ 692 693 if (AcpiNsOpensScope (TypeToCheckFor)) 694 { 695 /* 8-12-98 ASL Grammar Update supports null NamePath */ 696 697 if (NullNamePath) 698 { 699 /* TBD: [Investigate] - is this the correct thing to do? */ 700 701 ScopeToPush = NULL; 702 } 703 else 704 { 705 ScopeToPush = ThisNode; 706 } 707 708 Status = AcpiDsScopeStackPush (ScopeToPush, Type, 709 WalkState); 710 if (ACPI_FAILURE (Status)) 711 { 712 return_ACPI_STATUS (Status); 713 } 714 715 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Set global scope to %p\n", ScopeToPush)); 716 } 717 } 718 719 *ReturnNode = ThisNode; 720 return_ACPI_STATUS (AE_OK); 721} 722 723