1 /******************************************************************************
3 * Module Name: nsutils - Utilities for accessing ACPI namespace, accessing
4 * parents and siblings and Scope manipulation
7 *****************************************************************************/
9 /******************************************************************************
13 * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp.
14 * All rights reserved.
18 * 2.1. This is your license from Intel Corp. under its intellectual property
19 * rights. You may have additional license terms from the party that provided
20 * you this software, covering your right to use that party's intellectual
23 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
24 * copy of the source code appearing in this file ("Covered Code") an
25 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
26 * base code distributed originally by Intel ("Original Intel Code") to copy,
27 * make derivatives, distribute, use and display any portion of the Covered
28 * Code in any form, with the right to sublicense such rights; and
30 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
31 * license (with the right to sublicense), under only those claims of Intel
32 * patents that are infringed by the Original Intel Code, to make, use, sell,
33 * offer to sell, and import the Covered Code and derivative works thereof
34 * solely to the minimum extent necessary to exercise the above copyright
35 * license, and in no event shall the patent license extend to any additions
36 * to or modifications of the Original Intel Code. No other license or right
37 * is granted directly or by implication, estoppel or otherwise;
39 * The above copyright and patent license is granted only if the following
44 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
45 * Redistribution of source code of any substantial portion of the Covered
46 * Code or modification with rights to further distribute source must include
47 * the above Copyright Notice, the above License, this list of Conditions,
48 * and the following Disclaimer and Export Compliance provision. In addition,
49 * Licensee must cause all Covered Code to which Licensee contributes to
50 * contain a file documenting the changes Licensee made to create that Covered
51 * Code and the date of any change. Licensee must include in that file the
52 * documentation of any changes made by any predecessor Licensee. Licensee
53 * must include a prominent statement that the modification is derived,
54 * directly or indirectly, from Original Intel Code.
56 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
57 * Redistribution of source code of any substantial portion of the Covered
58 * Code or modification without rights to further distribute source must
59 * include the following Disclaimer and Export Compliance provision in the
60 * documentation and/or other materials provided with distribution. In
61 * addition, Licensee may not authorize further sublicense of source of any
62 * portion of the Covered Code, and must include terms to the effect that the
63 * license from Licensee to its licensee is limited to the intellectual
64 * property embodied in the software Licensee provides to its licensee, and
65 * not to intellectual property embodied in modifications its licensee may
68 * 3.3. Redistribution of Executable. Redistribution in executable form of any
69 * substantial portion of the Covered Code or modification must reproduce the
70 * above Copyright Notice, and the following Disclaimer and Export Compliance
71 * provision in the documentation and/or other materials provided with the
74 * 3.4. Intel retains all right, title, and interest in and to the Original
77 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
78 * Intel shall be used in advertising or otherwise to promote the sale, use or
79 * other dealings in products derived from or relating to the Covered Code
80 * without prior written authorization from Intel.
82 * 4. Disclaimer and Export Compliance
84 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
85 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
86 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
87 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
88 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
89 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
92 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
93 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
94 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
95 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
96 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
97 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
98 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
101 * 4.3. Licensee shall not export, either directly or indirectly, any of this
102 * software or system incorporating such software without first obtaining any
103 * required license or other approval from the U. S. Department of Commerce or
104 * any other agency or department of the United States Government. In the
105 * event Licensee exports any such software from the United States or
106 * re-exports any such software from a foreign destination, Licensee shall
107 * ensure that the distribution and export/re-export of the software is in
108 * compliance with all laws, regulations, orders, or other restrictions of the
109 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
110 * any of its subsidiaries will export/re-export any technical data, process,
111 * software, or service, directly or indirectly, to any country for which the
112 * United States government or any agency thereof requires an export license,
113 * other governmental approval, or letter of assurance, without first obtaining
114 * such license, approval or letter.
116 *****************************************************************************/
118 #define __NSUTILS_C__
121 #include "acnamesp.h"
123 #include "actables.h"
125 #define _COMPONENT ACPI_NAMESPACE
126 ACPI_MODULE_NAME ("nsutils")
129 /*******************************************************************************
131 * FUNCTION: AcpiNsReportError
133 * PARAMETERS: ModuleName - Caller's module name (for error output)
134 * LineNumber - Caller's line number (for error output)
135 * ComponentId - Caller's component ID (for error output)
136 * Message - Error message to use on failure
140 * DESCRIPTION: Print warning message with full pathname
142 ******************************************************************************/
150 ACPI_STATUS LookupStatus)
156 AcpiOsPrintf ("%8s-%04d: *** Error: Looking up ",
157 ModuleName, LineNumber);
159 if (LookupStatus == AE_BAD_CHARACTER)
161 /* There is a non-ascii character in the name */
163 AcpiOsPrintf ("[0x%4.4X] (NON-ASCII)\n",
164 *(ACPI_CAST_PTR (UINT32, InternalName)));
168 /* Convert path to external format */
170 Status = AcpiNsExternalizeName (ACPI_UINT32_MAX,
171 InternalName, NULL, &Name);
173 /* Print target name */
175 if (ACPI_SUCCESS (Status))
177 AcpiOsPrintf ("[%s]", Name);
181 AcpiOsPrintf ("[COULD NOT EXTERNALIZE NAME]");
186 ACPI_MEM_FREE (Name);
190 AcpiOsPrintf (" in namespace, %s\n",
191 AcpiFormatException (LookupStatus));
195 /*******************************************************************************
197 * FUNCTION: AcpiNsReportMethodError
199 * PARAMETERS: ModuleName - Caller's module name (for error output)
200 * LineNumber - Caller's line number (for error output)
201 * ComponentId - Caller's component ID (for error output)
202 * Message - Error message to use on failure
206 * DESCRIPTION: Print warning message with full pathname
208 ******************************************************************************/
211 AcpiNsReportMethodError (
216 ACPI_NAMESPACE_NODE *PrefixNode,
218 ACPI_STATUS MethodStatus)
221 ACPI_NAMESPACE_NODE *Node = PrefixNode;
226 Status = AcpiNsGetNodeByPath (Path, PrefixNode,
227 ACPI_NS_NO_UPSEARCH, &Node);
228 if (ACPI_FAILURE (Status))
230 AcpiOsPrintf ("ReportMethodError: Could not get node\n");
235 AcpiOsPrintf ("%8s-%04d: *** Error: ", ModuleName, LineNumber);
236 AcpiNsPrintNodePathname (Node, Message);
237 AcpiOsPrintf (", %s\n", AcpiFormatException (MethodStatus));
241 /*******************************************************************************
243 * FUNCTION: AcpiNsPrintNodePathname
245 * PARAMETERS: Node - Object
246 * Msg - Prefix message
248 * DESCRIPTION: Print an object's full namespace pathname
249 * Manages allocation/freeing of a pathname buffer
251 ******************************************************************************/
254 AcpiNsPrintNodePathname (
255 ACPI_NAMESPACE_NODE *Node,
264 AcpiOsPrintf ("[NULL NAME]");
268 /* Convert handle to full pathname and print it (with supplied message) */
270 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
272 Status = AcpiNsHandleToPathname (Node, &Buffer);
273 if (ACPI_SUCCESS (Status))
277 AcpiOsPrintf ("%s ", Msg);
280 AcpiOsPrintf ("[%s] (Node %p)", (char *) Buffer.Pointer, Node);
281 ACPI_MEM_FREE (Buffer.Pointer);
286 /*******************************************************************************
288 * FUNCTION: AcpiNsValidRootPrefix
290 * PARAMETERS: Prefix - Character to be checked
292 * RETURN: TRUE if a valid prefix
294 * DESCRIPTION: Check if a character is a valid ACPI Root prefix
296 ******************************************************************************/
299 AcpiNsValidRootPrefix (
303 return ((BOOLEAN) (Prefix == '\\'));
307 /*******************************************************************************
309 * FUNCTION: AcpiNsValidPathSeparator
311 * PARAMETERS: Sep - Character to be checked
313 * RETURN: TRUE if a valid path separator
315 * DESCRIPTION: Check if a character is a valid ACPI path separator
317 ******************************************************************************/
320 AcpiNsValidPathSeparator (
324 return ((BOOLEAN) (Sep == '.'));
328 /*******************************************************************************
330 * FUNCTION: AcpiNsGetType
332 * PARAMETERS: Handle - Parent Node to be examined
334 * RETURN: Type field from Node whose handle is passed
336 ******************************************************************************/
340 ACPI_NAMESPACE_NODE *Node)
342 ACPI_FUNCTION_TRACE ("NsGetType");
347 ACPI_REPORT_WARNING (("NsGetType: Null Node input pointer\n"));
348 return_VALUE (ACPI_TYPE_ANY);
351 return_VALUE ((ACPI_OBJECT_TYPE) Node->Type);
355 /*******************************************************************************
357 * FUNCTION: AcpiNsLocal
359 * PARAMETERS: Type - A namespace object type
361 * RETURN: LOCAL if names must be found locally in objects of the
362 * passed type, 0 if enclosing scopes should be searched
364 ******************************************************************************/
368 ACPI_OBJECT_TYPE Type)
370 ACPI_FUNCTION_TRACE ("NsLocal");
373 if (!AcpiUtValidObjectType (Type))
375 /* Type code out of range */
377 ACPI_REPORT_WARNING (("NsLocal: Invalid Object Type\n"));
378 return_VALUE (ACPI_NS_NORMAL);
381 return_VALUE ((UINT32) AcpiGbl_NsProperties[Type] & ACPI_NS_LOCAL);
385 /*******************************************************************************
387 * FUNCTION: AcpiNsGetInternalNameLength
389 * PARAMETERS: Info - Info struct initialized with the
390 * external name pointer.
394 * DESCRIPTION: Calculate the length of the internal (AML) namestring
395 * corresponding to the external (ASL) namestring.
397 ******************************************************************************/
400 AcpiNsGetInternalNameLength (
401 ACPI_NAMESTRING_INFO *Info)
403 char *NextExternalChar;
407 ACPI_FUNCTION_ENTRY ();
410 NextExternalChar = Info->ExternalName;
412 Info->NumSegments = 0;
413 Info->FullyQualified = FALSE;
416 * For the internal name, the required length is 4 bytes per segment, plus
417 * 1 each for RootPrefix, MultiNamePrefixOp, segment count, trailing null
418 * (which is not really needed, but no there's harm in putting it there)
420 * strlen() + 1 covers the first NameSeg, which has no path separator
422 if (AcpiNsValidRootPrefix (NextExternalChar[0]))
424 Info->FullyQualified = TRUE;
430 * Handle Carat prefixes
432 while (*NextExternalChar == '^')
440 * Determine the number of ACPI name "segments" by counting the number of
441 * path separators within the string. Start with one segment since the
442 * segment count is [(# separators) + 1], and zero separators is ok.
444 if (*NextExternalChar)
446 Info->NumSegments = 1;
447 for (i = 0; NextExternalChar[i]; i++)
449 if (AcpiNsValidPathSeparator (NextExternalChar[i]))
456 Info->Length = (ACPI_NAME_SIZE * Info->NumSegments) +
459 Info->NextExternalChar = NextExternalChar;
463 /*******************************************************************************
465 * FUNCTION: AcpiNsBuildInternalName
467 * PARAMETERS: Info - Info struct fully initialized
471 * DESCRIPTION: Construct the internal (AML) namestring
472 * corresponding to the external (ASL) namestring.
474 ******************************************************************************/
477 AcpiNsBuildInternalName (
478 ACPI_NAMESTRING_INFO *Info)
480 UINT32 NumSegments = Info->NumSegments;
481 char *InternalName = Info->InternalName;
482 char *ExternalName = Info->NextExternalChar;
487 ACPI_FUNCTION_TRACE ("NsBuildInternalName");
490 /* Setup the correct prefixes, counts, and pointers */
492 if (Info->FullyQualified)
494 InternalName[0] = '\\';
496 if (NumSegments <= 1)
498 Result = &InternalName[1];
500 else if (NumSegments == 2)
502 InternalName[1] = AML_DUAL_NAME_PREFIX;
503 Result = &InternalName[2];
507 InternalName[1] = AML_MULTI_NAME_PREFIX_OP;
508 InternalName[2] = (char) NumSegments;
509 Result = &InternalName[3];
515 * Not fully qualified.
516 * Handle Carats first, then append the name segments
521 for (i = 0; i < Info->NumCarats; i++)
523 InternalName[i] = '^';
527 if (NumSegments <= 1)
529 Result = &InternalName[i];
531 else if (NumSegments == 2)
533 InternalName[i] = AML_DUAL_NAME_PREFIX;
534 Result = &InternalName[(ACPI_NATIVE_UINT) (i+1)];
538 InternalName[i] = AML_MULTI_NAME_PREFIX_OP;
539 InternalName[(ACPI_NATIVE_UINT) (i+1)] = (char) NumSegments;
540 Result = &InternalName[(ACPI_NATIVE_UINT) (i+2)];
544 /* Build the name (minus path separators) */
546 for (; NumSegments; NumSegments--)
548 for (i = 0; i < ACPI_NAME_SIZE; i++)
550 if (AcpiNsValidPathSeparator (*ExternalName) ||
551 (*ExternalName == 0))
553 /* Pad the segment with underscore(s) if segment is short */
559 /* Convert the character to uppercase and save it */
561 Result[i] = (char) ACPI_TOUPPER ((int) *ExternalName);
566 /* Now we must have a path separator, or the pathname is bad */
568 if (!AcpiNsValidPathSeparator (*ExternalName) &&
569 (*ExternalName != 0))
571 return_ACPI_STATUS (AE_BAD_PARAMETER);
574 /* Move on the next segment */
577 Result += ACPI_NAME_SIZE;
580 /* Terminate the string */
584 if (Info->FullyQualified)
586 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Returning [%p] (abs) \"\\%s\"\n",
587 InternalName, InternalName));
591 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Returning [%p] (rel) \"%s\"\n",
592 InternalName, InternalName));
595 return_ACPI_STATUS (AE_OK);
599 /*******************************************************************************
601 * FUNCTION: AcpiNsInternalizeName
603 * PARAMETERS: *ExternalName - External representation of name
604 * **Converted Name - Where to return the resulting
605 * internal represention of the name
609 * DESCRIPTION: Convert an external representation (e.g. "\_PR_.CPU0")
610 * to internal form (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30)
612 *******************************************************************************/
615 AcpiNsInternalizeName (
617 char **ConvertedName)
620 ACPI_NAMESTRING_INFO Info;
624 ACPI_FUNCTION_TRACE ("NsInternalizeName");
627 if ((!ExternalName) ||
628 (*ExternalName == 0) ||
631 return_ACPI_STATUS (AE_BAD_PARAMETER);
634 /* Get the length of the new internal name */
636 Info.ExternalName = ExternalName;
637 AcpiNsGetInternalNameLength (&Info);
639 /* We need a segment to store the internal name */
641 InternalName = ACPI_MEM_CALLOCATE (Info.Length);
644 return_ACPI_STATUS (AE_NO_MEMORY);
649 Info.InternalName = InternalName;
650 Status = AcpiNsBuildInternalName (&Info);
651 if (ACPI_FAILURE (Status))
653 ACPI_MEM_FREE (InternalName);
654 return_ACPI_STATUS (Status);
657 *ConvertedName = InternalName;
658 return_ACPI_STATUS (AE_OK);
662 /*******************************************************************************
664 * FUNCTION: AcpiNsExternalizeName
666 * PARAMETERS: *InternalName - Internal representation of name
667 * **ConvertedName - Where to return the resulting
668 * external representation of name
672 * DESCRIPTION: Convert internal name (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30)
673 * to its external form (e.g. "\_PR_.CPU0")
675 ******************************************************************************/
678 AcpiNsExternalizeName (
679 UINT32 InternalNameLength,
681 UINT32 *ConvertedNameLength,
682 char **ConvertedName)
684 ACPI_NATIVE_UINT NamesIndex = 0;
685 ACPI_NATIVE_UINT NumSegments = 0;
686 ACPI_NATIVE_UINT RequiredLength;
687 ACPI_NATIVE_UINT PrefixLength = 0;
688 ACPI_NATIVE_UINT i = 0;
689 ACPI_NATIVE_UINT j = 0;
692 ACPI_FUNCTION_TRACE ("NsExternalizeName");
695 if (!InternalNameLength ||
699 return_ACPI_STATUS (AE_BAD_PARAMETER);
703 * Check for a prefix (one '\' | one or more '^').
705 switch (InternalName[0])
712 for (i = 0; i < InternalNameLength; i++)
714 if (InternalName[i] == '^')
716 PrefixLength = i + 1;
724 if (i == InternalNameLength)
736 * Check for object names. Note that there could be 0-255 of these
739 if (PrefixLength < InternalNameLength)
741 switch (InternalName[PrefixLength])
743 case AML_MULTI_NAME_PREFIX_OP:
745 /* <count> 4-byte names */
747 NamesIndex = PrefixLength + 2;
748 NumSegments = (ACPI_NATIVE_UINT) (UINT8)
749 InternalName[(ACPI_NATIVE_UINT) (PrefixLength + 1)];
752 case AML_DUAL_NAME_PREFIX:
754 /* Two 4-byte names */
756 NamesIndex = PrefixLength + 1;
770 /* one 4-byte name */
772 NamesIndex = PrefixLength;
779 * Calculate the length of ConvertedName, which equals the length
780 * of the prefix, length of all object names, length of any required
781 * punctuation ('.') between object names, plus the NULL terminator.
783 RequiredLength = PrefixLength + (4 * NumSegments) +
784 ((NumSegments > 0) ? (NumSegments - 1) : 0) + 1;
787 * Check to see if we're still in bounds. If not, there's a problem
788 * with InternalName (invalid format).
790 if (RequiredLength > InternalNameLength)
792 ACPI_REPORT_ERROR (("NsExternalizeName: Invalid internal name\n"));
793 return_ACPI_STATUS (AE_BAD_PATHNAME);
797 * Build ConvertedName
799 *ConvertedName = ACPI_MEM_CALLOCATE (RequiredLength);
800 if (!(*ConvertedName))
802 return_ACPI_STATUS (AE_NO_MEMORY);
807 for (i = 0; i < PrefixLength; i++)
809 (*ConvertedName)[j++] = InternalName[i];
814 for (i = 0; i < NumSegments; i++)
818 (*ConvertedName)[j++] = '.';
821 (*ConvertedName)[j++] = InternalName[NamesIndex++];
822 (*ConvertedName)[j++] = InternalName[NamesIndex++];
823 (*ConvertedName)[j++] = InternalName[NamesIndex++];
824 (*ConvertedName)[j++] = InternalName[NamesIndex++];
828 if (ConvertedNameLength)
830 *ConvertedNameLength = (UINT32) RequiredLength;
833 return_ACPI_STATUS (AE_OK);
837 /*******************************************************************************
839 * FUNCTION: AcpiNsMapHandleToNode
841 * PARAMETERS: Handle - Handle to be converted to an Node
843 * RETURN: A Name table entry pointer
845 * DESCRIPTION: Convert a namespace handle to a real Node
847 * Note: Real integer handles allow for more verification
848 * and keep all pointers within this subsystem.
850 ******************************************************************************/
852 ACPI_NAMESPACE_NODE *
853 AcpiNsMapHandleToNode (
857 ACPI_FUNCTION_ENTRY ();
861 * Simple implementation.
868 if (Handle == ACPI_ROOT_OBJECT)
870 return (AcpiGbl_RootNode);
873 /* We can at least attempt to verify the handle */
875 if (ACPI_GET_DESCRIPTOR_TYPE (Handle) != ACPI_DESC_TYPE_NAMED)
880 return ((ACPI_NAMESPACE_NODE *) Handle);
884 /*******************************************************************************
886 * FUNCTION: AcpiNsConvertEntryToHandle
888 * PARAMETERS: Node - Node to be converted to a Handle
890 * RETURN: A user handle
892 * DESCRIPTION: Convert a real Node to a namespace handle
894 ******************************************************************************/
897 AcpiNsConvertEntryToHandle (
898 ACPI_NAMESPACE_NODE *Node)
903 * Simple implementation for now;
905 return ((ACPI_HANDLE) Node);
908 /* ---------------------------------------------------
915 if (Node == AcpiGbl_RootNode)
917 return (ACPI_ROOT_OBJECT);
921 return ((ACPI_HANDLE) Node);
922 ------------------------------------------------------*/
926 /*******************************************************************************
928 * FUNCTION: AcpiNsTerminate
934 * DESCRIPTION: free memory allocated for table storage.
936 ******************************************************************************/
939 AcpiNsTerminate (void)
941 ACPI_OPERAND_OBJECT *ObjDesc;
944 ACPI_FUNCTION_TRACE ("NsTerminate");
948 * 1) Free the entire namespace -- all nodes and objects
950 * Delete all object descriptors attached to namepsace nodes
952 AcpiNsDeleteNamespaceSubtree (AcpiGbl_RootNode);
954 /* Detach any objects attached to the root */
956 ObjDesc = AcpiNsGetAttachedObject (AcpiGbl_RootNode);
959 AcpiNsDetachObject (AcpiGbl_RootNode);
962 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace freed\n"));
965 * 2) Now we can delete the ACPI tables
967 AcpiTbDeleteAllTables ();
968 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n"));
974 /*******************************************************************************
976 * FUNCTION: AcpiNsOpensScope
978 * PARAMETERS: Type - A valid namespace type
980 * RETURN: NEWSCOPE if the passed type "opens a name scope" according
981 * to the ACPI specification, else 0
983 ******************************************************************************/
987 ACPI_OBJECT_TYPE Type)
989 ACPI_FUNCTION_TRACE_STR ("NsOpensScope", AcpiUtGetTypeName (Type));
992 if (!AcpiUtValidObjectType (Type))
994 /* type code out of range */
996 ACPI_REPORT_WARNING (("NsOpensScope: Invalid Object Type %X\n", Type));
997 return_VALUE (ACPI_NS_NORMAL);
1000 return_VALUE (((UINT32) AcpiGbl_NsProperties[Type]) & ACPI_NS_NEWSCOPE);
1004 /*******************************************************************************
1006 * FUNCTION: AcpiNsGetNodeByPath
1008 * PARAMETERS: *Pathname - Name to be found, in external (ASL) format. The
1009 * \ (backslash) and ^ (carat) prefixes, and the
1010 * . (period) to separate segments are supported.
1011 * StartNode - Root of subtree to be searched, or NS_ALL for the
1012 * root of the name space. If Name is fully
1013 * qualified (first INT8 is '\'), the passed value
1014 * of Scope will not be accessed.
1015 * Flags - Used to indicate whether to perform upsearch or
1017 * ReturnNode - Where the Node is returned
1019 * DESCRIPTION: Look up a name relative to a given scope and return the
1020 * corresponding Node. NOTE: Scope can be null.
1022 * MUTEX: Locks namespace
1024 ******************************************************************************/
1027 AcpiNsGetNodeByPath (
1029 ACPI_NAMESPACE_NODE *StartNode,
1031 ACPI_NAMESPACE_NODE **ReturnNode)
1033 ACPI_GENERIC_STATE ScopeInfo;
1035 char *InternalPath = NULL;
1038 ACPI_FUNCTION_TRACE_PTR ("NsGetNodeByPath", Pathname);
1043 /* Convert path to internal representation */
1045 Status = AcpiNsInternalizeName (Pathname, &InternalPath);
1046 if (ACPI_FAILURE (Status))
1048 return_ACPI_STATUS (Status);
1052 /* Must lock namespace during lookup */
1054 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
1055 if (ACPI_FAILURE (Status))
1060 /* Setup lookup scope (search starting point) */
1062 ScopeInfo.Scope.Node = StartNode;
1064 /* Lookup the name in the namespace */
1066 Status = AcpiNsLookup (&ScopeInfo, InternalPath,
1067 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
1068 (Flags | ACPI_NS_DONT_OPEN_SCOPE),
1070 if (ACPI_FAILURE (Status))
1072 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s, %s\n",
1073 InternalPath, AcpiFormatException (Status)));
1076 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
1082 ACPI_MEM_FREE (InternalPath);
1084 return_ACPI_STATUS (Status);
1088 /*******************************************************************************
1090 * FUNCTION: AcpiNsFindParentName
1092 * PARAMETERS: *ChildNode - Named Obj whose name is to be found
1094 * RETURN: The ACPI name
1096 * DESCRIPTION: Search for the given obj in its parent scope and return the
1097 * name segment, or "????" if the parent name can't be found
1098 * (which "should not happen").
1100 ******************************************************************************/
1103 AcpiNsFindParentName (
1104 ACPI_NAMESPACE_NODE *ChildNode)
1106 ACPI_NAMESPACE_NODE *ParentNode;
1109 ACPI_FUNCTION_TRACE ("NsFindParentName");
1114 /* Valid entry. Get the parent Node */
1116 ParentNode = AcpiNsGetParentNode (ChildNode);
1119 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
1120 "Parent of %p [%4.4s] is %p [%4.4s]\n",
1121 ChildNode, AcpiUtGetNodeName (ChildNode),
1122 ParentNode, AcpiUtGetNodeName (ParentNode)));
1124 if (ParentNode->Name.Integer)
1126 return_VALUE ((ACPI_NAME) ParentNode->Name.Integer);
1130 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
1131 "Unable to find parent of %p (%4.4s)\n",
1132 ChildNode, AcpiUtGetNodeName (ChildNode)));
1135 return_VALUE (ACPI_UNKNOWN_NAME);
1139 /*******************************************************************************
1141 * FUNCTION: AcpiNsGetParentNode
1143 * PARAMETERS: Node - Current table entry
1145 * RETURN: Parent entry of the given entry
1147 * DESCRIPTION: Obtain the parent entry for a given entry in the namespace.
1149 ******************************************************************************/
1152 ACPI_NAMESPACE_NODE *
1153 AcpiNsGetParentNode (
1154 ACPI_NAMESPACE_NODE *Node)
1156 ACPI_FUNCTION_ENTRY ();
1165 * Walk to the end of this peer list. The last entry is marked with a flag
1166 * and the peer pointer is really a pointer back to the parent. This saves
1167 * putting a parent back pointer in each and every named object!
1169 while (!(Node->Flags & ANOBJ_END_OF_PEER_LIST))
1175 return (Node->Peer);
1179 /*******************************************************************************
1181 * FUNCTION: AcpiNsGetNextValidNode
1183 * PARAMETERS: Node - Current table entry
1185 * RETURN: Next valid Node in the linked node list. NULL if no more valid
1188 * DESCRIPTION: Find the next valid node within a name table.
1189 * Useful for implementing NULL-end-of-list loops.
1191 ******************************************************************************/
1194 ACPI_NAMESPACE_NODE *
1195 AcpiNsGetNextValidNode (
1196 ACPI_NAMESPACE_NODE *Node)
1199 /* If we are at the end of this peer list, return NULL */
1201 if (Node->Flags & ANOBJ_END_OF_PEER_LIST)
1206 /* Otherwise just return the next peer */
1208 return (Node->Peer);