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", *(ACPI_CAST_PTR (UINT32, InternalName)));
167 /* Convert path to external format */
169 Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, InternalName, NULL, &Name);
171 /* Print target name */
173 if (ACPI_SUCCESS (Status))
175 AcpiOsPrintf ("[%s]", Name);
179 AcpiOsPrintf ("[COULD NOT EXTERNALIZE NAME]");
184 ACPI_MEM_FREE (Name);
188 AcpiOsPrintf (" in namespace, %s\n",
189 AcpiFormatException (LookupStatus));
193 /*******************************************************************************
195 * FUNCTION: AcpiNsReportMethodError
197 * PARAMETERS: ModuleName - Caller's module name (for error output)
198 * LineNumber - Caller's line number (for error output)
199 * ComponentId - Caller's component ID (for error output)
200 * Message - Error message to use on failure
204 * DESCRIPTION: Print warning message with full pathname
206 ******************************************************************************/
209 AcpiNsReportMethodError (
214 ACPI_NAMESPACE_NODE *PrefixNode,
216 ACPI_STATUS MethodStatus)
219 ACPI_NAMESPACE_NODE *Node = PrefixNode;
224 Status = AcpiNsGetNodeByPath (Path, PrefixNode, ACPI_NS_NO_UPSEARCH, &Node);
225 if (ACPI_FAILURE (Status))
227 AcpiOsPrintf ("ReportMethodError: Could not get node\n");
232 AcpiOsPrintf ("%8s-%04d: *** Error: ", ModuleName, LineNumber);
233 AcpiNsPrintNodePathname (Node, Message);
234 AcpiOsPrintf (", %s\n", AcpiFormatException (MethodStatus));
238 /*******************************************************************************
240 * FUNCTION: AcpiNsPrintNodePathname
242 * PARAMETERS: Node - Object
243 * Msg - Prefix message
245 * DESCRIPTION: Print an object's full namespace pathname
246 * Manages allocation/freeing of a pathname buffer
248 ******************************************************************************/
251 AcpiNsPrintNodePathname (
252 ACPI_NAMESPACE_NODE *Node,
261 AcpiOsPrintf ("[NULL NAME]");
265 /* Convert handle to a full pathname and print it (with supplied message) */
267 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
269 Status = AcpiNsHandleToPathname (Node, &Buffer);
270 if (ACPI_SUCCESS (Status))
274 AcpiOsPrintf ("%s ", Msg);
277 AcpiOsPrintf ("[%s] (Node %p)", (char *) Buffer.Pointer, Node);
278 ACPI_MEM_FREE (Buffer.Pointer);
283 /*******************************************************************************
285 * FUNCTION: AcpiNsValidRootPrefix
287 * PARAMETERS: Prefix - Character to be checked
289 * RETURN: TRUE if a valid prefix
291 * DESCRIPTION: Check if a character is a valid ACPI Root prefix
293 ******************************************************************************/
296 AcpiNsValidRootPrefix (
300 return ((BOOLEAN) (Prefix == '\\'));
304 /*******************************************************************************
306 * FUNCTION: AcpiNsValidPathSeparator
308 * PARAMETERS: Sep - Character to be checked
310 * RETURN: TRUE if a valid path separator
312 * DESCRIPTION: Check if a character is a valid ACPI path separator
314 ******************************************************************************/
317 AcpiNsValidPathSeparator (
321 return ((BOOLEAN) (Sep == '.'));
325 /*******************************************************************************
327 * FUNCTION: AcpiNsGetType
329 * PARAMETERS: Handle - Parent Node to be examined
331 * RETURN: Type field from Node whose handle is passed
333 ******************************************************************************/
337 ACPI_NAMESPACE_NODE *Node)
339 ACPI_FUNCTION_TRACE ("NsGetType");
344 ACPI_REPORT_WARNING (("NsGetType: Null Node input pointer\n"));
345 return_VALUE (ACPI_TYPE_ANY);
348 return_VALUE ((ACPI_OBJECT_TYPE) Node->Type);
352 /*******************************************************************************
354 * FUNCTION: AcpiNsLocal
356 * PARAMETERS: Type - A namespace object type
358 * RETURN: LOCAL if names must be found locally in objects of the
359 * passed type, 0 if enclosing scopes should be searched
361 ******************************************************************************/
365 ACPI_OBJECT_TYPE Type)
367 ACPI_FUNCTION_TRACE ("NsLocal");
370 if (!AcpiUtValidObjectType (Type))
372 /* Type code out of range */
374 ACPI_REPORT_WARNING (("NsLocal: Invalid Object Type\n"));
375 return_VALUE (ACPI_NS_NORMAL);
378 return_VALUE ((UINT32) AcpiGbl_NsProperties[Type] & ACPI_NS_LOCAL);
382 /*******************************************************************************
384 * FUNCTION: AcpiNsGetInternalNameLength
386 * PARAMETERS: Info - Info struct initialized with the
387 * external name pointer.
391 * DESCRIPTION: Calculate the length of the internal (AML) namestring
392 * corresponding to the external (ASL) namestring.
394 ******************************************************************************/
397 AcpiNsGetInternalNameLength (
398 ACPI_NAMESTRING_INFO *Info)
400 char *NextExternalChar;
404 ACPI_FUNCTION_ENTRY ();
407 NextExternalChar = Info->ExternalName;
409 Info->NumSegments = 0;
410 Info->FullyQualified = FALSE;
413 * For the internal name, the required length is 4 bytes
414 * per segment, plus 1 each for RootPrefix, MultiNamePrefixOp,
415 * segment count, trailing null (which is not really needed,
416 * but no there's harm in putting it there)
418 * strlen() + 1 covers the first NameSeg, which has no
421 if (AcpiNsValidRootPrefix (NextExternalChar[0]))
423 Info->FullyQualified = TRUE;
429 * Handle Carat prefixes
431 while (*NextExternalChar == '^')
439 * Determine the number of ACPI name "segments" by counting
440 * the number of path separators within the string. Start
441 * with one segment since the segment count is (# separators)
442 * + 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) InternalName[(ACPI_NATIVE_UINT) (PrefixLength + 1)];
751 case AML_DUAL_NAME_PREFIX:
753 /* Two 4-byte names */
755 NamesIndex = PrefixLength + 1;
769 /* one 4-byte name */
771 NamesIndex = PrefixLength;
778 * Calculate the length of ConvertedName, which equals the length
779 * of the prefix, length of all object names, length of any required
780 * punctuation ('.') between object names, plus the NULL terminator.
782 RequiredLength = PrefixLength + (4 * NumSegments) +
783 ((NumSegments > 0) ? (NumSegments - 1) : 0) + 1;
786 * Check to see if we're still in bounds. If not, there's a problem
787 * with InternalName (invalid format).
789 if (RequiredLength > InternalNameLength)
791 ACPI_REPORT_ERROR (("NsExternalizeName: Invalid internal name\n"));
792 return_ACPI_STATUS (AE_BAD_PATHNAME);
796 * Build ConvertedName...
798 *ConvertedName = ACPI_MEM_CALLOCATE (RequiredLength);
799 if (!(*ConvertedName))
801 return_ACPI_STATUS (AE_NO_MEMORY);
806 for (i = 0; i < PrefixLength; i++)
808 (*ConvertedName)[j++] = InternalName[i];
813 for (i = 0; i < NumSegments; i++)
817 (*ConvertedName)[j++] = '.';
820 (*ConvertedName)[j++] = InternalName[NamesIndex++];
821 (*ConvertedName)[j++] = InternalName[NamesIndex++];
822 (*ConvertedName)[j++] = InternalName[NamesIndex++];
823 (*ConvertedName)[j++] = InternalName[NamesIndex++];
827 if (ConvertedNameLength)
829 *ConvertedNameLength = (UINT32) RequiredLength;
832 return_ACPI_STATUS (AE_OK);
836 /*******************************************************************************
838 * FUNCTION: AcpiNsMapHandleToNode
840 * PARAMETERS: Handle - Handle to be converted to an Node
842 * RETURN: A Name table entry pointer
844 * DESCRIPTION: Convert a namespace handle to a real Node
846 * Note: Real integer handles allow for more verification
847 * and keep all pointers within this subsystem.
849 ******************************************************************************/
851 ACPI_NAMESPACE_NODE *
852 AcpiNsMapHandleToNode (
856 ACPI_FUNCTION_ENTRY ();
860 * Simple implementation.
867 if (Handle == ACPI_ROOT_OBJECT)
869 return (AcpiGbl_RootNode);
872 /* We can at least attempt to verify the handle */
874 if (ACPI_GET_DESCRIPTOR_TYPE (Handle) != ACPI_DESC_TYPE_NAMED)
879 return ((ACPI_NAMESPACE_NODE *) Handle);
883 /*******************************************************************************
885 * FUNCTION: AcpiNsConvertEntryToHandle
887 * PARAMETERS: Node - Node to be converted to a Handle
889 * RETURN: An USER ACPI_HANDLE
891 * DESCRIPTION: Convert a real Node to a namespace handle
893 ******************************************************************************/
896 AcpiNsConvertEntryToHandle (
897 ACPI_NAMESPACE_NODE *Node)
902 * Simple implementation for now;
904 return ((ACPI_HANDLE) Node);
907 /* ---------------------------------------------------
914 if (Node == AcpiGbl_RootNode)
916 return (ACPI_ROOT_OBJECT);
920 return ((ACPI_HANDLE) Node);
921 ------------------------------------------------------*/
925 /*******************************************************************************
927 * FUNCTION: AcpiNsTerminate
933 * DESCRIPTION: free memory allocated for table storage.
935 ******************************************************************************/
938 AcpiNsTerminate (void)
940 ACPI_OPERAND_OBJECT *ObjDesc;
943 ACPI_FUNCTION_TRACE ("NsTerminate");
947 * 1) Free the entire namespace -- all nodes and objects
949 * Delete all object descriptors attached to namepsace nodes
951 AcpiNsDeleteNamespaceSubtree (AcpiGbl_RootNode);
953 /* Detach any objects attached to the root */
955 ObjDesc = AcpiNsGetAttachedObject (AcpiGbl_RootNode);
958 AcpiNsDetachObject (AcpiGbl_RootNode);
961 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace freed\n"));
964 * 2) Now we can delete the ACPI tables
966 AcpiTbDeleteAllTables ();
967 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n"));
973 /*******************************************************************************
975 * FUNCTION: AcpiNsOpensScope
977 * PARAMETERS: Type - A valid namespace type
979 * RETURN: NEWSCOPE if the passed type "opens a name scope" according
980 * to the ACPI specification, else 0
982 ******************************************************************************/
986 ACPI_OBJECT_TYPE Type)
988 ACPI_FUNCTION_TRACE_STR ("NsOpensScope", AcpiUtGetTypeName (Type));
991 if (!AcpiUtValidObjectType (Type))
993 /* type code out of range */
995 ACPI_REPORT_WARNING (("NsOpensScope: Invalid Object Type %X\n", Type));
996 return_VALUE (ACPI_NS_NORMAL);
999 return_VALUE (((UINT32) AcpiGbl_NsProperties[Type]) & ACPI_NS_NEWSCOPE);
1003 /*******************************************************************************
1005 * FUNCTION: AcpiNsGetNodeByPath
1007 * PARAMETERS: *Pathname - Name to be found, in external (ASL) format. The
1008 * \ (backslash) and ^ (carat) prefixes, and the
1009 * . (period) to separate segments are supported.
1010 * StartNode - Root of subtree to be searched, or NS_ALL for the
1011 * root of the name space. If Name is fully
1012 * qualified (first INT8 is '\'), the passed value
1013 * of Scope will not be accessed.
1014 * Flags - Used to indicate whether to perform upsearch or
1016 * ReturnNode - Where the Node is returned
1018 * DESCRIPTION: Look up a name relative to a given scope and return the
1019 * corresponding Node. NOTE: Scope can be null.
1021 * MUTEX: Locks namespace
1023 ******************************************************************************/
1026 AcpiNsGetNodeByPath (
1028 ACPI_NAMESPACE_NODE *StartNode,
1030 ACPI_NAMESPACE_NODE **ReturnNode)
1032 ACPI_GENERIC_STATE ScopeInfo;
1034 char *InternalPath = NULL;
1037 ACPI_FUNCTION_TRACE_PTR ("NsGetNodeByPath", Pathname);
1042 /* Convert path to internal representation */
1044 Status = AcpiNsInternalizeName (Pathname, &InternalPath);
1045 if (ACPI_FAILURE (Status))
1047 return_ACPI_STATUS (Status);
1051 /* Must lock namespace during lookup */
1053 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
1054 if (ACPI_FAILURE (Status))
1059 /* Setup lookup scope (search starting point) */
1061 ScopeInfo.Scope.Node = StartNode;
1063 /* Lookup the name in the namespace */
1065 Status = AcpiNsLookup (&ScopeInfo, InternalPath,
1066 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
1067 (Flags | ACPI_NS_DONT_OPEN_SCOPE),
1069 if (ACPI_FAILURE (Status))
1071 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s, %s\n",
1072 InternalPath, AcpiFormatException (Status)));
1075 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
1081 ACPI_MEM_FREE (InternalPath);
1083 return_ACPI_STATUS (Status);
1087 /*******************************************************************************
1089 * FUNCTION: AcpiNsFindParentName
1091 * PARAMETERS: *ChildNode - Named Obj whose name is to be found
1093 * RETURN: The ACPI name
1095 * DESCRIPTION: Search for the given obj in its parent scope and return the
1096 * name segment, or "????" if the parent name can't be found
1097 * (which "should not happen").
1099 ******************************************************************************/
1102 AcpiNsFindParentName (
1103 ACPI_NAMESPACE_NODE *ChildNode)
1105 ACPI_NAMESPACE_NODE *ParentNode;
1108 ACPI_FUNCTION_TRACE ("NsFindParentName");
1113 /* Valid entry. Get the parent Node */
1115 ParentNode = AcpiNsGetParentNode (ChildNode);
1118 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Parent of %p [%4.4s] is %p [%4.4s]\n",
1119 ChildNode, AcpiUtGetNodeName (ChildNode),
1120 ParentNode, AcpiUtGetNodeName (ParentNode)));
1122 if (ParentNode->Name.Integer)
1124 return_VALUE ((ACPI_NAME) ParentNode->Name.Integer);
1128 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "unable to find parent of %p (%4.4s)\n",
1129 ChildNode, AcpiUtGetNodeName (ChildNode)));
1132 return_VALUE (ACPI_UNKNOWN_NAME);
1136 /*******************************************************************************
1138 * FUNCTION: AcpiNsGetParentNode
1140 * PARAMETERS: Node - Current table entry
1142 * RETURN: Parent entry of the given entry
1144 * DESCRIPTION: Obtain the parent entry for a given entry in the namespace.
1146 ******************************************************************************/
1149 ACPI_NAMESPACE_NODE *
1150 AcpiNsGetParentNode (
1151 ACPI_NAMESPACE_NODE *Node)
1153 ACPI_FUNCTION_ENTRY ();
1162 * Walk to the end of this peer list.
1163 * The last entry is marked with a flag and the peer
1164 * pointer is really a pointer back to the parent.
1165 * This saves putting a parent back pointer in each and
1166 * every named object!
1168 while (!(Node->Flags & ANOBJ_END_OF_PEER_LIST))
1174 return (Node->Peer);
1178 /*******************************************************************************
1180 * FUNCTION: AcpiNsGetNextValidNode
1182 * PARAMETERS: Node - Current table entry
1184 * RETURN: Next valid Node in the linked node list. NULL if no more valid
1187 * DESCRIPTION: Find the next valid node within a name table.
1188 * Useful for implementing NULL-end-of-list loops.
1190 ******************************************************************************/
1193 ACPI_NAMESPACE_NODE *
1194 AcpiNsGetNextValidNode (
1195 ACPI_NAMESPACE_NODE *Node)
1198 /* If we are at the end of this peer list, return NULL */
1200 if (Node->Flags & ANOBJ_END_OF_PEER_LIST)
1205 /* Otherwise just return the next peer */
1207 return (Node->Peer);