|
||||
Warning, cross-references for /kernel/drivers/acpica/nssearch.c need to be fixed.
0001 /******************************************************************************* 0002 * 0003 * Module Name: nssearch - Namespace search 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 __NSSEARCH_C__ 0117 0118 #include "acpi.h" 0119 #include "accommon.h" 0120 #include "acnamesp.h" 0121 0122 #ifdef ACPI_ASL_COMPILER 0123 #include "amlcode.h" 0124 #endif 0125 0126 #define _COMPONENT ACPI_NAMESPACE 0127 ACPI_MODULE_NAME ("nssearch") 0128 0129 /* Local prototypes */ 0130 0131 static ACPI_STATUS 0132 AcpiNsSearchParentTree ( 0133 UINT32 TargetName, 0134 ACPI_NAMESPACE_NODE *Node, 0135 ACPI_OBJECT_TYPE Type, 0136 ACPI_NAMESPACE_NODE **ReturnNode); 0137 0138 0139 /******************************************************************************* 0140 * 0141 * FUNCTION: AcpiNsSearchOneScope 0142 * 0143 * PARAMETERS: TargetName - Ascii ACPI name to search for 0144 * ParentNode - Starting node where search will begin 0145 * Type - Object type to match 0146 * ReturnNode - Where the matched Named obj is returned 0147 * 0148 * RETURN: Status 0149 * 0150 * DESCRIPTION: Search a single level of the namespace. Performs a 0151 * simple search of the specified level, and does not add 0152 * entries or search parents. 0153 * 0154 * 0155 * Named object lists are built (and subsequently dumped) in the 0156 * order in which the names are encountered during the namespace load; 0157 * 0158 * All namespace searching is linear in this implementation, but 0159 * could be easily modified to support any improved search 0160 * algorithm. However, the linear search was chosen for simplicity 0161 * and because the trees are small and the other interpreter 0162 * execution overhead is relatively high. 0163 * 0164 * Note: CPU execution analysis has shown that the AML interpreter spends 0165 * a very small percentage of its time searching the namespace. Therefore, 0166 * the linear search seems to be sufficient, as there would seem to be 0167 * little value in improving the search. 0168 * 0169 ******************************************************************************/ 0170 0171 ACPI_STATUS 0172 AcpiNsSearchOneScope ( 0173 UINT32 TargetName, 0174 ACPI_NAMESPACE_NODE *ParentNode, 0175 ACPI_OBJECT_TYPE Type, 0176 ACPI_NAMESPACE_NODE **ReturnNode) 0177 { 0178 ACPI_NAMESPACE_NODE *Node; 0179 0180 0181 ACPI_FUNCTION_TRACE (NsSearchOneScope); 0182 0183 0184 #ifdef ACPI_DEBUG_OUTPUT 0185 if (ACPI_LV_NAMES & AcpiDbgLevel) 0186 { 0187 char *ScopeName; 0188 0189 ScopeName = AcpiNsGetExternalPathname (ParentNode); 0190 if (ScopeName) 0191 { 0192 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 0193 "Searching %s (%p) For [%4.4s] (%s)\n", 0194 ScopeName, ParentNode, ACPI_CAST_PTR (char, &TargetName), 0195 AcpiUtGetTypeName (Type))); 0196 0197 ACPI_FREE (ScopeName); 0198 } 0199 } 0200 #endif 0201 0202 /* 0203 * Search for name at this namespace level, which is to say that we 0204 * must search for the name among the children of this object 0205 */ 0206 Node = ParentNode->Child; 0207 while (Node) 0208 { 0209 /* Check for match against the name */ 0210 0211 if (Node->Name.Integer == TargetName) 0212 { 0213 /* Resolve a control method alias if any */ 0214 0215 if (AcpiNsGetType (Node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) 0216 { 0217 Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Node->Object); 0218 } 0219 0220 /* Found matching entry */ 0221 0222 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 0223 "Name [%4.4s] (%s) %p found in scope [%4.4s] %p\n", 0224 ACPI_CAST_PTR (char, &TargetName), 0225 AcpiUtGetTypeName (Node->Type), 0226 Node, AcpiUtGetNodeName (ParentNode), ParentNode)); 0227 0228 *ReturnNode = Node; 0229 return_ACPI_STATUS (AE_OK); 0230 } 0231 0232 /* 0233 * The last entry in the list points back to the parent, 0234 * so a flag is used to indicate the end-of-list 0235 */ 0236 if (Node->Flags & ANOBJ_END_OF_PEER_LIST) 0237 { 0238 /* Searched entire list, we are done */ 0239 0240 break; 0241 } 0242 0243 /* Didn't match name, move on to the next peer object */ 0244 0245 Node = Node->Peer; 0246 } 0247 0248 /* Searched entire namespace level, not found */ 0249 0250 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 0251 "Name [%4.4s] (%s) not found in search in scope [%4.4s] " 0252 "%p first child %p\n", 0253 ACPI_CAST_PTR (char, &TargetName), AcpiUtGetTypeName (Type), 0254 AcpiUtGetNodeName (ParentNode), ParentNode, ParentNode->Child)); 0255 0256 return_ACPI_STATUS (AE_NOT_FOUND); 0257 } 0258 0259 0260 /******************************************************************************* 0261 * 0262 * FUNCTION: AcpiNsSearchParentTree 0263 * 0264 * PARAMETERS: TargetName - Ascii ACPI name to search for 0265 * Node - Starting node where search will begin 0266 * Type - Object type to match 0267 * ReturnNode - Where the matched Node is returned 0268 * 0269 * RETURN: Status 0270 * 0271 * DESCRIPTION: Called when a name has not been found in the current namespace 0272 * level. Before adding it or giving up, ACPI scope rules require 0273 * searching enclosing scopes in cases identified by AcpiNsLocal(). 0274 * 0275 * "A name is located by finding the matching name in the current 0276 * name space, and then in the parent name space. If the parent 0277 * name space does not contain the name, the search continues 0278 * recursively until either the name is found or the name space 0279 * does not have a parent (the root of the name space). This 0280 * indicates that the name is not found" (From ACPI Specification, 0281 * section 5.3) 0282 * 0283 ******************************************************************************/ 0284 0285 static ACPI_STATUS 0286 AcpiNsSearchParentTree ( 0287 UINT32 TargetName, 0288 ACPI_NAMESPACE_NODE *Node, 0289 ACPI_OBJECT_TYPE Type, 0290 ACPI_NAMESPACE_NODE **ReturnNode) 0291 { 0292 ACPI_STATUS Status; 0293 ACPI_NAMESPACE_NODE *ParentNode; 0294 0295 0296 ACPI_FUNCTION_TRACE (NsSearchParentTree); 0297 0298 0299 ParentNode = AcpiNsGetParentNode (Node); 0300 0301 /* 0302 * If there is no parent (i.e., we are at the root) or type is "local", 0303 * we won't be searching the parent tree. 0304 */ 0305 if (!ParentNode) 0306 { 0307 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[%4.4s] has no parent\n", 0308 ACPI_CAST_PTR (char, &TargetName))); 0309 return_ACPI_STATUS (AE_NOT_FOUND); 0310 } 0311 0312 if (AcpiNsLocal (Type)) 0313 { 0314 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 0315 "[%4.4s] type [%s] must be local to this scope (no parent search)\n", 0316 ACPI_CAST_PTR (char, &TargetName), AcpiUtGetTypeName (Type))); 0317 return_ACPI_STATUS (AE_NOT_FOUND); 0318 } 0319 0320 /* Search the parent tree */ 0321 0322 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 0323 "Searching parent [%4.4s] for [%4.4s]\n", 0324 AcpiUtGetNodeName (ParentNode), ACPI_CAST_PTR (char, &TargetName))); 0325 0326 /* Search parents until target is found or we have backed up to the root */ 0327 0328 while (ParentNode) 0329 { 0330 /* 0331 * Search parent scope. Use TYPE_ANY because we don't care about the 0332 * object type at this point, we only care about the existence of 0333 * the actual name we are searching for. Typechecking comes later. 0334 */ 0335 Status = AcpiNsSearchOneScope ( 0336 TargetName, ParentNode, ACPI_TYPE_ANY, ReturnNode); 0337 if (ACPI_SUCCESS (Status)) 0338 { 0339 return_ACPI_STATUS (Status); 0340 } 0341 0342 /* Not found here, go up another level (until we reach the root) */ 0343 0344 ParentNode = AcpiNsGetParentNode (ParentNode); 0345 } 0346 0347 /* Not found in parent tree */ 0348 0349 return_ACPI_STATUS (AE_NOT_FOUND); 0350 } 0351 0352 0353 /******************************************************************************* 0354 * 0355 * FUNCTION: AcpiNsSearchAndEnter 0356 * 0357 * PARAMETERS: TargetName - Ascii ACPI name to search for (4 chars) 0358 * WalkState - Current state of the walk 0359 * Node - Starting node where search will begin 0360 * InterpreterMode - Add names only in ACPI_MODE_LOAD_PASS_x. 0361 * Otherwise,search only. 0362 * Type - Object type to match 0363 * Flags - Flags describing the search restrictions 0364 * ReturnNode - Where the Node is returned 0365 * 0366 * RETURN: Status 0367 * 0368 * DESCRIPTION: Search for a name segment in a single namespace level, 0369 * optionally adding it if it is not found. If the passed 0370 * Type is not Any and the type previously stored in the 0371 * entry was Any (i.e. unknown), update the stored type. 0372 * 0373 * In ACPI_IMODE_EXECUTE, search only. 0374 * In other modes, search and add if not found. 0375 * 0376 ******************************************************************************/ 0377 0378 ACPI_STATUS 0379 AcpiNsSearchAndEnter ( 0380 UINT32 TargetName, 0381 ACPI_WALK_STATE *WalkState, 0382 ACPI_NAMESPACE_NODE *Node, 0383 ACPI_INTERPRETER_MODE InterpreterMode, 0384 ACPI_OBJECT_TYPE Type, 0385 UINT32 Flags, 0386 ACPI_NAMESPACE_NODE **ReturnNode) 0387 { 0388 ACPI_STATUS Status; 0389 ACPI_NAMESPACE_NODE *NewNode; 0390 0391 0392 ACPI_FUNCTION_TRACE (NsSearchAndEnter); 0393 0394 0395 /* Parameter validation */ 0396 0397 if (!Node || !TargetName || !ReturnNode) 0398 { 0399 ACPI_ERROR ((AE_INFO, 0400 "Null parameter: Node %p Name %X ReturnNode %p", 0401 Node, TargetName, ReturnNode)); 0402 return_ACPI_STATUS (AE_BAD_PARAMETER); 0403 } 0404 0405 /* 0406 * Name must consist of valid ACPI characters. We will repair the name if 0407 * necessary because we don't want to abort because of this, but we want 0408 * all namespace names to be printable. A warning message is appropriate. 0409 * 0410 * This issue came up because there are in fact machines that exhibit 0411 * this problem, and we want to be able to enable ACPI support for them, 0412 * even though there are a few bad names. 0413 */ 0414 AcpiUtRepairName (ACPI_CAST_PTR (char, &TargetName)); 0415 0416 /* Try to find the name in the namespace level specified by the caller */ 0417 0418 *ReturnNode = ACPI_ENTRY_NOT_FOUND; 0419 Status = AcpiNsSearchOneScope (TargetName, Node, Type, ReturnNode); 0420 if (Status != AE_NOT_FOUND) 0421 { 0422 /* 0423 * If we found it AND the request specifies that a find is an error, 0424 * return the error 0425 */ 0426 if ((Status == AE_OK) && 0427 (Flags & ACPI_NS_ERROR_IF_FOUND)) 0428 { 0429 Status = AE_ALREADY_EXISTS; 0430 } 0431 0432 #ifdef ACPI_ASL_COMPILER 0433 if (*ReturnNode && (*ReturnNode)->Type == ACPI_TYPE_ANY) 0434 { 0435 (*ReturnNode)->Flags |= ANOBJ_IS_EXTERNAL; 0436 } 0437 #endif 0438 0439 /* Either found it or there was an error: finished either way */ 0440 0441 return_ACPI_STATUS (Status); 0442 } 0443 0444 /* 0445 * The name was not found. If we are NOT performing the first pass 0446 * (name entry) of loading the namespace, search the parent tree (all the 0447 * way to the root if necessary.) We don't want to perform the parent 0448 * search when the namespace is actually being loaded. We want to perform 0449 * the search when namespace references are being resolved (load pass 2) 0450 * and during the execution phase. 0451 */ 0452 if ((InterpreterMode != ACPI_IMODE_LOAD_PASS1) && 0453 (Flags & ACPI_NS_SEARCH_PARENT)) 0454 { 0455 /* 0456 * Not found at this level - search parent tree according to the 0457 * ACPI specification 0458 */ 0459 Status = AcpiNsSearchParentTree (TargetName, Node, Type, ReturnNode); 0460 if (ACPI_SUCCESS (Status)) 0461 { 0462 return_ACPI_STATUS (Status); 0463 } 0464 } 0465 0466 /* In execute mode, just search, never add names. Exit now */ 0467 0468 if (InterpreterMode == ACPI_IMODE_EXECUTE) 0469 { 0470 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 0471 "%4.4s Not found in %p [Not adding]\n", 0472 ACPI_CAST_PTR (char, &TargetName), Node)); 0473 0474 return_ACPI_STATUS (AE_NOT_FOUND); 0475 } 0476 0477 /* Create the new named object */ 0478 0479 NewNode = AcpiNsCreateNode (TargetName); 0480 if (!NewNode) 0481 { 0482 return_ACPI_STATUS (AE_NO_MEMORY); 0483 } 0484 0485 #ifdef ACPI_ASL_COMPILER 0486 0487 /* Node is an object defined by an External() statement */ 0488 0489 if (Flags & ACPI_NS_EXTERNAL || 0490 (WalkState && WalkState->Opcode == AML_SCOPE_OP)) 0491 { 0492 NewNode->Flags |= ANOBJ_IS_EXTERNAL; 0493 } 0494 #endif 0495 0496 if (Flags & ACPI_NS_TEMPORARY) 0497 { 0498 NewNode->Flags |= ANOBJ_TEMPORARY; 0499 } 0500 0501 /* Install the new object into the parent's list of children */ 0502 0503 AcpiNsInstallNode (WalkState, Node, NewNode, Type); 0504 *ReturnNode = NewNode; 0505 return_ACPI_STATUS (AE_OK); 0506 } 0507
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 1.2.0 LXR engine. |