|
||||
Warning, cross-references for /kernel/drivers/acpica/nsaccess.c need to be fixed.
0001 /******************************************************************************* 0002 * 0003 * Module Name: nsaccess - Top-level functions for accessing ACPI namespace 0004 * 0005 ******************************************************************************/ 0006 0007 /****************************************************************************** 0008 * 0009 * 1. Copyright Notice 0010 * 0011 * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. 0012 * All rights reserved. 0013 * 0014 * 2. License 0015 * 0016 * 2.1. This is your license from Intel Corp. under its intellectual property 0017 * rights. You may have additional license terms from the party that provided 0018 * you this software, covering your right to use that party's intellectual 0019 * property rights. 0020 * 0021 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 0022 * copy of the source code appearing in this file ("Covered Code") an 0023 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 0024 * base code distributed originally by Intel ("Original Intel Code") to copy, 0025 * make derivatives, distribute, use and display any portion of the Covered 0026 * Code in any form, with the right to sublicense such rights; and 0027 * 0028 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 0029 * license (with the right to sublicense), under only those claims of Intel 0030 * patents that are infringed by the Original Intel Code, to make, use, sell, 0031 * offer to sell, and import the Covered Code and derivative works thereof 0032 * solely to the minimum extent necessary to exercise the above copyright 0033 * license, and in no event shall the patent license extend to any additions 0034 * to or modifications of the Original Intel Code. No other license or right 0035 * is granted directly or by implication, estoppel or otherwise; 0036 * 0037 * The above copyright and patent license is granted only if the following 0038 * conditions are met: 0039 * 0040 * 3. Conditions 0041 * 0042 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 0043 * Redistribution of source code of any substantial portion of the Covered 0044 * Code or modification with rights to further distribute source must include 0045 * the above Copyright Notice, the above License, this list of Conditions, 0046 * and the following Disclaimer and Export Compliance provision. In addition, 0047 * Licensee must cause all Covered Code to which Licensee contributes to 0048 * contain a file documenting the changes Licensee made to create that Covered 0049 * Code and the date of any change. Licensee must include in that file the 0050 * documentation of any changes made by any predecessor Licensee. Licensee 0051 * must include a prominent statement that the modification is derived, 0052 * directly or indirectly, from Original Intel Code. 0053 * 0054 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 0055 * Redistribution of source code of any substantial portion of the Covered 0056 * Code or modification without rights to further distribute source must 0057 * include the following Disclaimer and Export Compliance provision in the 0058 * documentation and/or other materials provided with distribution. In 0059 * addition, Licensee may not authorize further sublicense of source of any 0060 * portion of the Covered Code, and must include terms to the effect that the 0061 * license from Licensee to its licensee is limited to the intellectual 0062 * property embodied in the software Licensee provides to its licensee, and 0063 * not to intellectual property embodied in modifications its licensee may 0064 * make. 0065 * 0066 * 3.3. Redistribution of Executable. Redistribution in executable form of any 0067 * substantial portion of the Covered Code or modification must reproduce the 0068 * above Copyright Notice, and the following Disclaimer and Export Compliance 0069 * provision in the documentation and/or other materials provided with the 0070 * distribution. 0071 * 0072 * 3.4. Intel retains all right, title, and interest in and to the Original 0073 * Intel Code. 0074 * 0075 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 0076 * Intel shall be used in advertising or otherwise to promote the sale, use or 0077 * other dealings in products derived from or relating to the Covered Code 0078 * without prior written authorization from Intel. 0079 * 0080 * 4. Disclaimer and Export Compliance 0081 * 0082 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 0083 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 0084 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 0085 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 0086 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 0087 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 0088 * PARTICULAR PURPOSE. 0089 * 0090 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 0091 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 0092 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 0093 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 0094 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 0095 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 0096 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 0097 * LIMITED REMEDY. 0098 * 0099 * 4.3. Licensee shall not export, either directly or indirectly, any of this 0100 * software or system incorporating such software without first obtaining any 0101 * required license or other approval from the U. S. Department of Commerce or 0102 * any other agency or department of the United States Government. In the 0103 * event Licensee exports any such software from the United States or 0104 * re-exports any such software from a foreign destination, Licensee shall 0105 * ensure that the distribution and export/re-export of the software is in 0106 * compliance with all laws, regulations, orders, or other restrictions of the 0107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 0108 * any of its subsidiaries will export/re-export any technical data, process, 0109 * software, or service, directly or indirectly, to any country for which the 0110 * United States government or any agency thereof requires an export license, 0111 * other governmental approval, or letter of assurance, without first obtaining 0112 * such license, approval or letter. 0113 * 0114 *****************************************************************************/ 0115 0116 #define __NSACCESS_C__ 0117 0118 #include "acpi.h" 0119 #include "accommon.h" 0120 #include "amlcode.h" 0121 #include "acnamesp.h" 0122 #include "acdispat.h" 0123 0124 0125 #define _COMPONENT ACPI_NAMESPACE 0126 ACPI_MODULE_NAME ("nsaccess") 0127 0128 0129 /******************************************************************************* 0130 * 0131 * FUNCTION: AcpiNsRootInitialize 0132 * 0133 * PARAMETERS: None 0134 * 0135 * RETURN: Status 0136 * 0137 * DESCRIPTION: Allocate and initialize the default root named objects 0138 * 0139 * MUTEX: Locks namespace for entire execution 0140 * 0141 ******************************************************************************/ 0142 0143 ACPI_STATUS 0144 AcpiNsRootInitialize ( 0145 void) 0146 { 0147 ACPI_STATUS Status; 0148 const ACPI_PREDEFINED_NAMES *InitVal = NULL; 0149 ACPI_NAMESPACE_NODE *NewNode; 0150 ACPI_OPERAND_OBJECT *ObjDesc; 0151 ACPI_STRING Val = NULL; 0152 0153 0154 ACPI_FUNCTION_TRACE (NsRootInitialize); 0155 0156 0157 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 0158 if (ACPI_FAILURE (Status)) 0159 { 0160 return_ACPI_STATUS (Status); 0161 } 0162 0163 /* 0164 * The global root ptr is initially NULL, so a non-NULL value indicates 0165 * that AcpiNsRootInitialize() has already been called; just return. 0166 */ 0167 if (AcpiGbl_RootNode) 0168 { 0169 Status = AE_OK; 0170 goto UnlockAndExit; 0171 } 0172 0173 /* 0174 * Tell the rest of the subsystem that the root is initialized 0175 * (This is OK because the namespace is locked) 0176 */ 0177 AcpiGbl_RootNode = &AcpiGbl_RootNodeStruct; 0178 0179 /* Enter the pre-defined names in the name table */ 0180 0181 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 0182 "Entering predefined entries into namespace\n")); 0183 0184 for (InitVal = AcpiGbl_PreDefinedNames; InitVal->Name; InitVal++) 0185 { 0186 /* _OSI is optional for now, will be permanent later */ 0187 0188 if (!ACPI_STRCMP (InitVal->Name, "_OSI") && !AcpiGbl_CreateOsiMethod) 0189 { 0190 continue; 0191 } 0192 0193 Status = AcpiNsLookup (NULL, InitVal->Name, InitVal->Type, 0194 ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, 0195 NULL, &NewNode); 0196 0197 if (ACPI_FAILURE (Status) || (!NewNode)) /* Must be on same line for code converter */ 0198 { 0199 ACPI_EXCEPTION ((AE_INFO, Status, 0200 "Could not create predefined name %s", 0201 InitVal->Name)); 0202 } 0203 0204 /* 0205 * Name entered successfully. If entry in PreDefinedNames[] specifies 0206 * an initial value, create the initial value. 0207 */ 0208 if (InitVal->Val) 0209 { 0210 Status = AcpiOsPredefinedOverride (InitVal, &Val); 0211 if (ACPI_FAILURE (Status)) 0212 { 0213 ACPI_ERROR ((AE_INFO, 0214 "Could not override predefined %s", 0215 InitVal->Name)); 0216 } 0217 0218 if (!Val) 0219 { 0220 Val = InitVal->Val; 0221 } 0222 0223 /* 0224 * Entry requests an initial value, allocate a 0225 * descriptor for it. 0226 */ 0227 ObjDesc = AcpiUtCreateInternalObject (InitVal->Type); 0228 if (!ObjDesc) 0229 { 0230 Status = AE_NO_MEMORY; 0231 goto UnlockAndExit; 0232 } 0233 0234 /* 0235 * Convert value string from table entry to 0236 * internal representation. Only types actually 0237 * used for initial values are implemented here. 0238 */ 0239 switch (InitVal->Type) 0240 { 0241 case ACPI_TYPE_METHOD: 0242 ObjDesc->Method.ParamCount = (UINT8) ACPI_TO_INTEGER (Val); 0243 ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID; 0244 0245 #if defined (ACPI_ASL_COMPILER) 0246 0247 /* Save the parameter count for the iASL compiler */ 0248 0249 NewNode->Value = ObjDesc->Method.ParamCount; 0250 #else 0251 /* Mark this as a very SPECIAL method */ 0252 0253 ObjDesc->Method.MethodFlags = AML_METHOD_INTERNAL_ONLY; 0254 ObjDesc->Method.Implementation = AcpiUtOsiImplementation; 0255 #endif 0256 break; 0257 0258 case ACPI_TYPE_INTEGER: 0259 0260 ObjDesc->Integer.Value = ACPI_TO_INTEGER (Val); 0261 break; 0262 0263 0264 case ACPI_TYPE_STRING: 0265 0266 /* Build an object around the static string */ 0267 0268 ObjDesc->String.Length = (UINT32) ACPI_STRLEN (Val); 0269 ObjDesc->String.Pointer = Val; 0270 ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER; 0271 break; 0272 0273 0274 case ACPI_TYPE_MUTEX: 0275 0276 ObjDesc->Mutex.Node = NewNode; 0277 ObjDesc->Mutex.SyncLevel = (UINT8) (ACPI_TO_INTEGER (Val) - 1); 0278 0279 /* Create a mutex */ 0280 0281 Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex); 0282 if (ACPI_FAILURE (Status)) 0283 { 0284 AcpiUtRemoveReference (ObjDesc); 0285 goto UnlockAndExit; 0286 } 0287 0288 /* Special case for ACPI Global Lock */ 0289 0290 if (ACPI_STRCMP (InitVal->Name, "_GL_") == 0) 0291 { 0292 AcpiGbl_GlobalLockMutex = ObjDesc; 0293 0294 /* Create additional counting semaphore for global lock */ 0295 0296 Status = AcpiOsCreateSemaphore ( 0297 1, 0, &AcpiGbl_GlobalLockSemaphore); 0298 if (ACPI_FAILURE (Status)) 0299 { 0300 AcpiUtRemoveReference (ObjDesc); 0301 goto UnlockAndExit; 0302 } 0303 } 0304 break; 0305 0306 0307 default: 0308 0309 ACPI_ERROR ((AE_INFO, "Unsupported initial type value %X", 0310 InitVal->Type)); 0311 AcpiUtRemoveReference (ObjDesc); 0312 ObjDesc = NULL; 0313 continue; 0314 } 0315 0316 /* Store pointer to value descriptor in the Node */ 0317 0318 Status = AcpiNsAttachObject (NewNode, ObjDesc, 0319 ObjDesc->Common.Type); 0320 0321 /* Remove local reference to the object */ 0322 0323 AcpiUtRemoveReference (ObjDesc); 0324 } 0325 } 0326 0327 0328 UnlockAndExit: 0329 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 0330 0331 /* Save a handle to "_GPE", it is always present */ 0332 0333 if (ACPI_SUCCESS (Status)) 0334 { 0335 Status = AcpiNsGetNode (NULL, "\\_GPE", ACPI_NS_NO_UPSEARCH, 0336 &AcpiGbl_FadtGpeDevice); 0337 } 0338 0339 return_ACPI_STATUS (Status); 0340 } 0341 0342 0343 /******************************************************************************* 0344 * 0345 * FUNCTION: AcpiNsLookup 0346 * 0347 * PARAMETERS: ScopeInfo - Current scope info block 0348 * Pathname - Search pathname, in internal format 0349 * (as represented in the AML stream) 0350 * Type - Type associated with name 0351 * InterpreterMode - IMODE_LOAD_PASS2 => add name if not found 0352 * Flags - Flags describing the search restrictions 0353 * WalkState - Current state of the walk 0354 * ReturnNode - Where the Node is placed (if found 0355 * or created successfully) 0356 * 0357 * RETURN: Status 0358 * 0359 * DESCRIPTION: Find or enter the passed name in the name space. 0360 * Log an error if name not found in Exec mode. 0361 * 0362 * MUTEX: Assumes namespace is locked. 0363 * 0364 ******************************************************************************/ 0365 0366 ACPI_STATUS 0367 AcpiNsLookup ( 0368 ACPI_GENERIC_STATE *ScopeInfo, 0369 char *Pathname, 0370 ACPI_OBJECT_TYPE Type, 0371 ACPI_INTERPRETER_MODE InterpreterMode, 0372 UINT32 Flags, 0373 ACPI_WALK_STATE *WalkState, 0374 ACPI_NAMESPACE_NODE **ReturnNode) 0375 { 0376 ACPI_STATUS Status; 0377 char *Path = Pathname; 0378 ACPI_NAMESPACE_NODE *PrefixNode; 0379 ACPI_NAMESPACE_NODE *CurrentNode = NULL; 0380 ACPI_NAMESPACE_NODE *ThisNode = NULL; 0381 UINT32 NumSegments; 0382 UINT32 NumCarats; 0383 ACPI_NAME SimpleName; 0384 ACPI_OBJECT_TYPE TypeToCheckFor; 0385 ACPI_OBJECT_TYPE ThisSearchType; 0386 UINT32 SearchParentFlag = ACPI_NS_SEARCH_PARENT; 0387 UINT32 LocalFlags; 0388 0389 0390 ACPI_FUNCTION_TRACE (NsLookup); 0391 0392 0393 if (!ReturnNode) 0394 { 0395 return_ACPI_STATUS (AE_BAD_PARAMETER); 0396 } 0397 0398 LocalFlags = Flags & ~(ACPI_NS_ERROR_IF_FOUND | ACPI_NS_SEARCH_PARENT); 0399 *ReturnNode = ACPI_ENTRY_NOT_FOUND; 0400 AcpiGbl_NsLookupCount++; 0401 0402 if (!AcpiGbl_RootNode) 0403 { 0404 return_ACPI_STATUS (AE_NO_NAMESPACE); 0405 } 0406 0407 /* Get the prefix scope. A null scope means use the root scope */ 0408 0409 if ((!ScopeInfo) || 0410 (!ScopeInfo->Scope.Node)) 0411 { 0412 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 0413 "Null scope prefix, using root node (%p)\n", 0414 AcpiGbl_RootNode)); 0415 0416 PrefixNode = AcpiGbl_RootNode; 0417 } 0418 else 0419 { 0420 PrefixNode = ScopeInfo->Scope.Node; 0421 if (ACPI_GET_DESCRIPTOR_TYPE (PrefixNode) != ACPI_DESC_TYPE_NAMED) 0422 { 0423 ACPI_ERROR ((AE_INFO, "%p is not a namespace node [%s]", 0424 PrefixNode, AcpiUtGetDescriptorName (PrefixNode))); 0425 return_ACPI_STATUS (AE_AML_INTERNAL); 0426 } 0427 0428 if (!(Flags & ACPI_NS_PREFIX_IS_SCOPE)) 0429 { 0430 /* 0431 * This node might not be a actual "scope" node (such as a 0432 * Device/Method, etc.) It could be a Package or other object 0433 * node. Backup up the tree to find the containing scope node. 0434 */ 0435 while (!AcpiNsOpensScope (PrefixNode->Type) && 0436 PrefixNode->Type != ACPI_TYPE_ANY) 0437 { 0438 PrefixNode = AcpiNsGetParentNode (PrefixNode); 0439 } 0440 } 0441 } 0442 0443 /* Save type. TBD: may be no longer necessary */ 0444 0445 TypeToCheckFor = Type; 0446 0447 /* 0448 * Begin examination of the actual pathname 0449 */ 0450 if (!Pathname) 0451 { 0452 /* A Null NamePath is allowed and refers to the root */ 0453 0454 NumSegments = 0; 0455 ThisNode = AcpiGbl_RootNode; 0456 Path = ""; 0457 0458 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 0459 "Null Pathname (Zero segments), Flags=%X\n", Flags)); 0460 } 0461 else 0462 { 0463 /* 0464 * Name pointer is valid (and must be in internal name format) 0465 * 0466 * Check for scope prefixes: 0467 * 0468 * As represented in the AML stream, a namepath consists of an 0469 * optional scope prefix followed by a name segment part. 0470 * 0471 * If present, the scope prefix is either a Root Prefix (in 0472 * which case the name is fully qualified), or one or more 0473 * Parent Prefixes (in which case the name's scope is relative 0474 * to the current scope). 0475 */ 0476 if (*Path == (UINT8) AML_ROOT_PREFIX) 0477 { 0478 /* Pathname is fully qualified, start from the root */ 0479 0480 ThisNode = AcpiGbl_RootNode; 0481 SearchParentFlag = ACPI_NS_NO_UPSEARCH; 0482 0483 /* Point to name segment part */ 0484 0485 Path++; 0486 0487 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 0488 "Path is absolute from root [%p]\n", ThisNode)); 0489 } 0490 else 0491 { 0492 /* Pathname is relative to current scope, start there */ 0493 0494 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 0495 "Searching relative to prefix scope [%4.4s] (%p)\n", 0496 AcpiUtGetNodeName (PrefixNode), PrefixNode)); 0497 0498 /* 0499 * Handle multiple Parent Prefixes (carat) by just getting 0500 * the parent node for each prefix instance. 0501 */ 0502 ThisNode = PrefixNode; 0503 NumCarats = 0; 0504 while (*Path == (UINT8) AML_PARENT_PREFIX) 0505 { 0506 /* Name is fully qualified, no search rules apply */ 0507 0508 SearchParentFlag = ACPI_NS_NO_UPSEARCH; 0509 0510 /* 0511 * Point past this prefix to the name segment 0512 * part or the next Parent Prefix 0513 */ 0514 Path++; 0515 0516 /* Backup to the parent node */ 0517 0518 NumCarats++; 0519 ThisNode = AcpiNsGetParentNode (ThisNode); 0520 if (!ThisNode) 0521 { 0522 /* Current scope has no parent scope */ 0523 0524 ACPI_ERROR ((AE_INFO, 0525 "ACPI path has too many parent prefixes (^) " 0526 "- reached beyond root node")); 0527 return_ACPI_STATUS (AE_NOT_FOUND); 0528 } 0529 } 0530 0531 if (SearchParentFlag == ACPI_NS_NO_UPSEARCH) 0532 { 0533 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 0534 "Search scope is [%4.4s], path has %d carat(s)\n", 0535 AcpiUtGetNodeName (ThisNode), NumCarats)); 0536 } 0537 } 0538 0539 /* 0540 * Determine the number of ACPI name segments in this pathname. 0541 * 0542 * The segment part consists of either: 0543 * - A Null name segment (0) 0544 * - A DualNamePrefix followed by two 4-byte name segments 0545 * - A MultiNamePrefix followed by a byte indicating the 0546 * number of segments and the segments themselves. 0547 * - A single 4-byte name segment 0548 * 0549 * Examine the name prefix opcode, if any, to determine the number of 0550 * segments. 0551 */ 0552 switch (*Path) 0553 { 0554 case 0: 0555 /* 0556 * Null name after a root or parent prefixes. We already 0557 * have the correct target node and there are no name segments. 0558 */ 0559 NumSegments = 0; 0560 Type = ThisNode->Type; 0561 0562 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 0563 "Prefix-only Pathname (Zero name segments), Flags=%X\n", 0564 Flags)); 0565 break; 0566 0567 case AML_DUAL_NAME_PREFIX: 0568 0569 /* More than one NameSeg, search rules do not apply */ 0570 0571 SearchParentFlag = ACPI_NS_NO_UPSEARCH; 0572 0573 /* Two segments, point to first name segment */ 0574 0575 NumSegments = 2; 0576 Path++; 0577 0578 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 0579 "Dual Pathname (2 segments, Flags=%X)\n", Flags)); 0580 break; 0581 0582 case AML_MULTI_NAME_PREFIX_OP: 0583 0584 /* More than one NameSeg, search rules do not apply */ 0585 0586 SearchParentFlag = ACPI_NS_NO_UPSEARCH; 0587 0588 /* Extract segment count, point to first name segment */ 0589 0590 Path++; 0591 NumSegments = (UINT32) (UINT8) *Path; 0592 Path++; 0593 0594 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 0595 "Multi Pathname (%d Segments, Flags=%X)\n", 0596 NumSegments, Flags)); 0597 break; 0598 0599 default: 0600 /* 0601 * Not a Null name, no Dual or Multi prefix, hence there is 0602 * only one name segment and Pathname is already pointing to it. 0603 */ 0604 NumSegments = 1; 0605 0606 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 0607 "Simple Pathname (1 segment, Flags=%X)\n", Flags)); 0608 break; 0609 } 0610 0611 ACPI_DEBUG_EXEC (AcpiNsPrintPathname (NumSegments, Path)); 0612 } 0613 0614 0615 /* 0616 * Search namespace for each segment of the name. Loop through and 0617 * verify (or add to the namespace) each name segment. 0618 * 0619 * The object type is significant only at the last name 0620 * segment. (We don't care about the types along the path, only 0621 * the type of the final target object.) 0622 */ 0623 ThisSearchType = ACPI_TYPE_ANY; 0624 CurrentNode = ThisNode; 0625 while (NumSegments && CurrentNode) 0626 { 0627 NumSegments--; 0628 if (!NumSegments) 0629 { 0630 /* This is the last segment, enable typechecking */ 0631 0632 ThisSearchType = Type; 0633 0634 /* 0635 * Only allow automatic parent search (search rules) if the caller 0636 * requested it AND we have a single, non-fully-qualified NameSeg 0637 */ 0638 if ((SearchParentFlag != ACPI_NS_NO_UPSEARCH) && 0639 (Flags & ACPI_NS_SEARCH_PARENT)) 0640 { 0641 LocalFlags |= ACPI_NS_SEARCH_PARENT; 0642 } 0643 0644 /* Set error flag according to caller */ 0645 0646 if (Flags & ACPI_NS_ERROR_IF_FOUND) 0647 { 0648 LocalFlags |= ACPI_NS_ERROR_IF_FOUND; 0649 } 0650 } 0651 0652 /* Extract one ACPI name from the front of the pathname */ 0653 0654 ACPI_MOVE_32_TO_32 (&SimpleName, Path); 0655 0656 /* Try to find the single (4 character) ACPI name */ 0657 0658 Status = AcpiNsSearchAndEnter (SimpleName, WalkState, CurrentNode, 0659 InterpreterMode, ThisSearchType, LocalFlags, &ThisNode); 0660 if (ACPI_FAILURE (Status)) 0661 { 0662 if (Status == AE_NOT_FOUND) 0663 { 0664 /* Name not found in ACPI namespace */ 0665 0666 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 0667 "Name [%4.4s] not found in scope [%4.4s] %p\n", 0668 (char *) &SimpleName, (char *) &CurrentNode->Name, 0669 CurrentNode)); 0670 } 0671 0672 *ReturnNode = ThisNode; 0673 return_ACPI_STATUS (Status); 0674 } 0675 0676 /* More segments to follow? */ 0677 0678 if (NumSegments > 0) 0679 { 0680 /* 0681 * If we have an alias to an object that opens a scope (such as a 0682 * device or processor), we need to dereference the alias here so 0683 * that we can access any children of the original node (via the 0684 * remaining segments). 0685 */ 0686 if (ThisNode->Type == ACPI_TYPE_LOCAL_ALIAS) 0687 { 0688 if (!ThisNode->Object) 0689 { 0690 return_ACPI_STATUS (AE_NOT_EXIST); 0691 } 0692 0693 if (AcpiNsOpensScope (((ACPI_NAMESPACE_NODE *) 0694 ThisNode->Object)->Type)) 0695 { 0696 ThisNode = (ACPI_NAMESPACE_NODE *) ThisNode->Object; 0697 } 0698 } 0699 } 0700 0701 /* Special handling for the last segment (NumSegments == 0) */ 0702 0703 else 0704 { 0705 /* 0706 * Sanity typecheck of the target object: 0707 * 0708 * If 1) This is the last segment (NumSegments == 0) 0709 * 2) And we are looking for a specific type 0710 * (Not checking for TYPE_ANY) 0711 * 3) Which is not an alias 0712 * 4) Which is not a local type (TYPE_SCOPE) 0713 * 5) And the type of target object is known (not TYPE_ANY) 0714 * 6) And target object does not match what we are looking for 0715 * 0716 * Then we have a type mismatch. Just warn and ignore it. 0717 */ 0718 if ((TypeToCheckFor != ACPI_TYPE_ANY) && 0719 (TypeToCheckFor != ACPI_TYPE_LOCAL_ALIAS) && 0720 (TypeToCheckFor != ACPI_TYPE_LOCAL_METHOD_ALIAS) && 0721 (TypeToCheckFor != ACPI_TYPE_LOCAL_SCOPE) && 0722 (ThisNode->Type != ACPI_TYPE_ANY) && 0723 (ThisNode->Type != TypeToCheckFor)) 0724 { 0725 /* Complain about a type mismatch */ 0726 0727 ACPI_WARNING ((AE_INFO, 0728 "NsLookup: Type mismatch on %4.4s (%s), searching for (%s)", 0729 ACPI_CAST_PTR (char, &SimpleName), 0730 AcpiUtGetTypeName (ThisNode->Type), 0731 AcpiUtGetTypeName (TypeToCheckFor))); 0732 } 0733 0734 /* 0735 * If this is the last name segment and we are not looking for a 0736 * specific type, but the type of found object is known, use that 0737 * type to (later) see if it opens a scope. 0738 */ 0739 if (Type == ACPI_TYPE_ANY) 0740 { 0741 Type = ThisNode->Type; 0742 } 0743 } 0744 0745 /* Point to next name segment and make this node current */ 0746 0747 Path += ACPI_NAME_SIZE; 0748 CurrentNode = ThisNode; 0749 } 0750 0751 /* Always check if we need to open a new scope */ 0752 0753 if (!(Flags & ACPI_NS_DONT_OPEN_SCOPE) && (WalkState)) 0754 { 0755 /* 0756 * If entry is a type which opens a scope, push the new scope on the 0757 * scope stack. 0758 */ 0759 if (AcpiNsOpensScope (Type)) 0760 { 0761 Status = AcpiDsScopeStackPush (ThisNode, Type, WalkState); 0762 if (ACPI_FAILURE (Status)) 0763 { 0764 return_ACPI_STATUS (Status); 0765 } 0766 } 0767 } 0768 0769 *ReturnNode = ThisNode; 0770 return_ACPI_STATUS (AE_OK); 0771 } 0772
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 1.2.0 LXR engine. |