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 - 2003, 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 *****************************************************************************/
117 /* $DragonFly: src/sys/contrib/dev/acpica/Attic/nsutils.c,v 1.1 2003/09/24 03:32:16 drhodus Exp $ */
119 #define __NSUTILS_C__
122 #include "acnamesp.h"
124 #include "actables.h"
126 #define _COMPONENT ACPI_NAMESPACE
127 ACPI_MODULE_NAME ("nsutils")
130 /*******************************************************************************
132 * FUNCTION: AcpiNsReportError
134 * PARAMETERS: ModuleName - Caller's module name (for error output)
135 * LineNumber - Caller's line number (for error output)
136 * ComponentId - Caller's component ID (for error output)
137 * Message - Error message to use on failure
141 * DESCRIPTION: Print warning message with full pathname
143 ******************************************************************************/
151 ACPI_STATUS LookupStatus)
157 /* Convert path to external format */
159 Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, InternalName, NULL, &Name);
161 AcpiOsPrintf ("%8s-%04d: *** Error: Looking up ",
162 ModuleName, LineNumber);
164 /* Print target name */
166 if (ACPI_SUCCESS (Status))
168 AcpiOsPrintf ("[%s]", Name);
172 AcpiOsPrintf ("[COULD NOT EXTERNALIZE NAME]");
175 AcpiOsPrintf (" in namespace, %s\n",
176 AcpiFormatException (LookupStatus));
180 ACPI_MEM_FREE (Name);
185 /*******************************************************************************
187 * FUNCTION: AcpiNsReportMethodError
189 * PARAMETERS: ModuleName - Caller's module name (for error output)
190 * LineNumber - Caller's line number (for error output)
191 * ComponentId - Caller's component ID (for error output)
192 * Message - Error message to use on failure
196 * DESCRIPTION: Print warning message with full pathname
198 ******************************************************************************/
201 AcpiNsReportMethodError (
206 ACPI_NAMESPACE_NODE *PrefixNode,
208 ACPI_STATUS MethodStatus)
211 ACPI_NAMESPACE_NODE *Node = PrefixNode;
216 Status = AcpiNsGetNodeByPath (Path, PrefixNode, ACPI_NS_NO_UPSEARCH, &Node);
217 if (ACPI_FAILURE (Status))
219 AcpiOsPrintf ("ReportMethodError: Could not get node\n");
224 AcpiOsPrintf ("%8s-%04d: *** Error: ", ModuleName, LineNumber);
225 AcpiNsPrintNodePathname (Node, Message);
226 AcpiOsPrintf (", %s\n", AcpiFormatException (MethodStatus));
230 /*******************************************************************************
232 * FUNCTION: AcpiNsPrintNodePathname
234 * PARAMETERS: Node - Object
235 * Msg - Prefix message
237 * DESCRIPTION: Print an object's full namespace pathname
238 * Manages allocation/freeing of a pathname buffer
240 ******************************************************************************/
243 AcpiNsPrintNodePathname (
244 ACPI_NAMESPACE_NODE *Node,
251 /* Convert handle to a full pathname and print it (with supplied message) */
253 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
255 Status = AcpiNsHandleToPathname (Node, &Buffer);
256 if (ACPI_SUCCESS (Status))
258 AcpiOsPrintf ("%s [%s] (Node %p)", Msg, (char *) Buffer.Pointer, Node);
259 ACPI_MEM_FREE (Buffer.Pointer);
264 /*******************************************************************************
266 * FUNCTION: AcpiNsValidRootPrefix
268 * PARAMETERS: Prefix - Character to be checked
270 * RETURN: TRUE if a valid prefix
272 * DESCRIPTION: Check if a character is a valid ACPI Root prefix
274 ******************************************************************************/
277 AcpiNsValidRootPrefix (
281 return ((BOOLEAN) (Prefix == '\\'));
285 /*******************************************************************************
287 * FUNCTION: AcpiNsValidPathSeparator
289 * PARAMETERS: Sep - Character to be checked
291 * RETURN: TRUE if a valid path separator
293 * DESCRIPTION: Check if a character is a valid ACPI path separator
295 ******************************************************************************/
298 AcpiNsValidPathSeparator (
302 return ((BOOLEAN) (Sep == '.'));
306 /*******************************************************************************
308 * FUNCTION: AcpiNsGetType
310 * PARAMETERS: Handle - Parent Node to be examined
312 * RETURN: Type field from Node whose handle is passed
314 ******************************************************************************/
318 ACPI_NAMESPACE_NODE *Node)
320 ACPI_FUNCTION_TRACE ("NsGetType");
325 ACPI_REPORT_WARNING (("NsGetType: Null Node ptr"));
326 return_VALUE (ACPI_TYPE_ANY);
329 return_VALUE ((ACPI_OBJECT_TYPE) Node->Type);
333 /*******************************************************************************
335 * FUNCTION: AcpiNsLocal
337 * PARAMETERS: Type - A namespace object type
339 * RETURN: LOCAL if names must be found locally in objects of the
340 * passed type, 0 if enclosing scopes should be searched
342 ******************************************************************************/
346 ACPI_OBJECT_TYPE Type)
348 ACPI_FUNCTION_TRACE ("NsLocal");
351 if (!AcpiUtValidObjectType (Type))
353 /* Type code out of range */
355 ACPI_REPORT_WARNING (("NsLocal: Invalid Object Type\n"));
356 return_VALUE (ACPI_NS_NORMAL);
359 return_VALUE ((UINT32) AcpiGbl_NsProperties[Type] & ACPI_NS_LOCAL);
363 /*******************************************************************************
365 * FUNCTION: AcpiNsGetInternalNameLength
367 * PARAMETERS: Info - Info struct initialized with the
368 * external name pointer.
372 * DESCRIPTION: Calculate the length of the internal (AML) namestring
373 * corresponding to the external (ASL) namestring.
375 ******************************************************************************/
378 AcpiNsGetInternalNameLength (
379 ACPI_NAMESTRING_INFO *Info)
381 char *NextExternalChar;
385 ACPI_FUNCTION_ENTRY ();
388 NextExternalChar = Info->ExternalName;
390 Info->NumSegments = 0;
391 Info->FullyQualified = FALSE;
394 * For the internal name, the required length is 4 bytes
395 * per segment, plus 1 each for RootPrefix, MultiNamePrefixOp,
396 * segment count, trailing null (which is not really needed,
397 * but no there's harm in putting it there)
399 * strlen() + 1 covers the first NameSeg, which has no
402 if (AcpiNsValidRootPrefix (NextExternalChar[0]))
404 Info->FullyQualified = TRUE;
410 * Handle Carat prefixes
412 while (*NextExternalChar == '^')
420 * Determine the number of ACPI name "segments" by counting
421 * the number of path separators within the string. Start
422 * with one segment since the segment count is (# separators)
423 * + 1, and zero separators is ok.
425 if (*NextExternalChar)
427 Info->NumSegments = 1;
428 for (i = 0; NextExternalChar[i]; i++)
430 if (AcpiNsValidPathSeparator (NextExternalChar[i]))
437 Info->Length = (ACPI_NAME_SIZE * Info->NumSegments) +
440 Info->NextExternalChar = NextExternalChar;
444 /*******************************************************************************
446 * FUNCTION: AcpiNsBuildInternalName
448 * PARAMETERS: Info - Info struct fully initialized
452 * DESCRIPTION: Construct the internal (AML) namestring
453 * corresponding to the external (ASL) namestring.
455 ******************************************************************************/
458 AcpiNsBuildInternalName (
459 ACPI_NAMESTRING_INFO *Info)
461 UINT32 NumSegments = Info->NumSegments;
462 char *InternalName = Info->InternalName;
463 char *ExternalName = Info->NextExternalChar;
468 ACPI_FUNCTION_TRACE ("NsBuildInternalName");
471 /* Setup the correct prefixes, counts, and pointers */
473 if (Info->FullyQualified)
475 InternalName[0] = '\\';
477 if (NumSegments <= 1)
479 Result = &InternalName[1];
481 else if (NumSegments == 2)
483 InternalName[1] = AML_DUAL_NAME_PREFIX;
484 Result = &InternalName[2];
488 InternalName[1] = AML_MULTI_NAME_PREFIX_OP;
489 InternalName[2] = (char) NumSegments;
490 Result = &InternalName[3];
496 * Not fully qualified.
497 * Handle Carats first, then append the name segments
502 for (i = 0; i < Info->NumCarats; i++)
504 InternalName[i] = '^';
508 if (NumSegments <= 1)
510 Result = &InternalName[i];
512 else if (NumSegments == 2)
514 InternalName[i] = AML_DUAL_NAME_PREFIX;
515 Result = &InternalName[(ACPI_NATIVE_UINT) (i+1)];
519 InternalName[i] = AML_MULTI_NAME_PREFIX_OP;
520 InternalName[(ACPI_NATIVE_UINT) (i+1)] = (char) NumSegments;
521 Result = &InternalName[(ACPI_NATIVE_UINT) (i+2)];
525 /* Build the name (minus path separators) */
527 for (; NumSegments; NumSegments--)
529 for (i = 0; i < ACPI_NAME_SIZE; i++)
531 if (AcpiNsValidPathSeparator (*ExternalName) ||
532 (*ExternalName == 0))
534 /* Pad the segment with underscore(s) if segment is short */
540 /* Convert the character to uppercase and save it */
542 Result[i] = (char) ACPI_TOUPPER ((int) *ExternalName);
547 /* Now we must have a path separator, or the pathname is bad */
549 if (!AcpiNsValidPathSeparator (*ExternalName) &&
550 (*ExternalName != 0))
552 return_ACPI_STATUS (AE_BAD_PARAMETER);
555 /* Move on the next segment */
558 Result += ACPI_NAME_SIZE;
561 /* Terminate the string */
565 if (Info->FullyQualified)
567 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "returning [%p] (abs) \"\\%s\"\n",
568 InternalName, InternalName));
572 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "returning [%p] (rel) \"%s\"\n",
573 InternalName, InternalName));
576 return_ACPI_STATUS (AE_OK);
580 /*******************************************************************************
582 * FUNCTION: AcpiNsInternalizeName
584 * PARAMETERS: *ExternalName - External representation of name
585 * **Converted Name - Where to return the resulting
586 * internal represention of the name
590 * DESCRIPTION: Convert an external representation (e.g. "\_PR_.CPU0")
591 * to internal form (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30)
593 *******************************************************************************/
596 AcpiNsInternalizeName (
598 char **ConvertedName)
601 ACPI_NAMESTRING_INFO Info;
605 ACPI_FUNCTION_TRACE ("NsInternalizeName");
608 if ((!ExternalName) ||
609 (*ExternalName == 0) ||
612 return_ACPI_STATUS (AE_BAD_PARAMETER);
615 /* Get the length of the new internal name */
617 Info.ExternalName = ExternalName;
618 AcpiNsGetInternalNameLength (&Info);
620 /* We need a segment to store the internal name */
622 InternalName = ACPI_MEM_CALLOCATE (Info.Length);
625 return_ACPI_STATUS (AE_NO_MEMORY);
630 Info.InternalName = InternalName;
631 Status = AcpiNsBuildInternalName (&Info);
632 if (ACPI_FAILURE (Status))
634 ACPI_MEM_FREE (InternalName);
635 return_ACPI_STATUS (Status);
638 *ConvertedName = InternalName;
639 return_ACPI_STATUS (AE_OK);
643 /*******************************************************************************
645 * FUNCTION: AcpiNsExternalizeName
647 * PARAMETERS: *InternalName - Internal representation of name
648 * **ConvertedName - Where to return the resulting
649 * external representation of name
653 * DESCRIPTION: Convert internal name (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30)
654 * to its external form (e.g. "\_PR_.CPU0")
656 ******************************************************************************/
659 AcpiNsExternalizeName (
660 UINT32 InternalNameLength,
662 UINT32 *ConvertedNameLength,
663 char **ConvertedName)
665 ACPI_NATIVE_UINT NamesIndex = 0;
666 ACPI_NATIVE_UINT NumSegments = 0;
667 ACPI_NATIVE_UINT RequiredLength;
668 ACPI_NATIVE_UINT PrefixLength = 0;
669 ACPI_NATIVE_UINT i = 0;
670 ACPI_NATIVE_UINT j = 0;
673 ACPI_FUNCTION_TRACE ("NsExternalizeName");
676 if (!InternalNameLength ||
680 return_ACPI_STATUS (AE_BAD_PARAMETER);
684 * Check for a prefix (one '\' | one or more '^').
686 switch (InternalName[0])
693 for (i = 0; i < InternalNameLength; i++)
695 if (InternalName[i] == '^')
697 PrefixLength = i + 1;
705 if (i == InternalNameLength)
717 * Check for object names. Note that there could be 0-255 of these
720 if (PrefixLength < InternalNameLength)
722 switch (InternalName[PrefixLength])
724 case AML_MULTI_NAME_PREFIX_OP:
726 /* <count> 4-byte names */
728 NamesIndex = PrefixLength + 2;
729 NumSegments = (UINT32) (UINT8) InternalName[(ACPI_NATIVE_UINT) (PrefixLength + 1)];
732 case AML_DUAL_NAME_PREFIX:
734 /* Two 4-byte names */
736 NamesIndex = PrefixLength + 1;
750 /* one 4-byte name */
752 NamesIndex = PrefixLength;
759 * Calculate the length of ConvertedName, which equals the length
760 * of the prefix, length of all object names, length of any required
761 * punctuation ('.') between object names, plus the NULL terminator.
763 RequiredLength = PrefixLength + (4 * NumSegments) +
764 ((NumSegments > 0) ? (NumSegments - 1) : 0) + 1;
767 * Check to see if we're still in bounds. If not, there's a problem
768 * with InternalName (invalid format).
770 if (RequiredLength > InternalNameLength)
772 ACPI_REPORT_ERROR (("NsExternalizeName: Invalid internal name\n"));
773 return_ACPI_STATUS (AE_BAD_PATHNAME);
777 * Build ConvertedName...
779 *ConvertedName = ACPI_MEM_CALLOCATE (RequiredLength);
780 if (!(*ConvertedName))
782 return_ACPI_STATUS (AE_NO_MEMORY);
787 for (i = 0; i < PrefixLength; i++)
789 (*ConvertedName)[j++] = InternalName[i];
794 for (i = 0; i < NumSegments; i++)
798 (*ConvertedName)[j++] = '.';
801 (*ConvertedName)[j++] = InternalName[NamesIndex++];
802 (*ConvertedName)[j++] = InternalName[NamesIndex++];
803 (*ConvertedName)[j++] = InternalName[NamesIndex++];
804 (*ConvertedName)[j++] = InternalName[NamesIndex++];
808 if (ConvertedNameLength)
810 *ConvertedNameLength = (UINT32) RequiredLength;
813 return_ACPI_STATUS (AE_OK);
817 /*******************************************************************************
819 * FUNCTION: AcpiNsMapHandleToNode
821 * PARAMETERS: Handle - Handle to be converted to an Node
823 * RETURN: A Name table entry pointer
825 * DESCRIPTION: Convert a namespace handle to a real Node
827 * Note: Real integer handles allow for more verification
828 * and keep all pointers within this subsystem.
830 ******************************************************************************/
832 ACPI_NAMESPACE_NODE *
833 AcpiNsMapHandleToNode (
837 ACPI_FUNCTION_ENTRY ();
841 * Simple implementation.
848 if (Handle == ACPI_ROOT_OBJECT)
850 return (AcpiGbl_RootNode);
853 /* We can at least attempt to verify the handle */
855 if (ACPI_GET_DESCRIPTOR_TYPE (Handle) != ACPI_DESC_TYPE_NAMED)
860 return ((ACPI_NAMESPACE_NODE *) Handle);
864 /*******************************************************************************
866 * FUNCTION: AcpiNsConvertEntryToHandle
868 * PARAMETERS: Node - Node to be converted to a Handle
870 * RETURN: An USER ACPI_HANDLE
872 * DESCRIPTION: Convert a real Node to a namespace handle
874 ******************************************************************************/
877 AcpiNsConvertEntryToHandle (
878 ACPI_NAMESPACE_NODE *Node)
883 * Simple implementation for now;
885 return ((ACPI_HANDLE) Node);
888 /* ---------------------------------------------------
895 if (Node == AcpiGbl_RootNode)
897 return (ACPI_ROOT_OBJECT);
901 return ((ACPI_HANDLE) Node);
902 ------------------------------------------------------*/
906 /*******************************************************************************
908 * FUNCTION: AcpiNsTerminate
914 * DESCRIPTION: free memory allocated for table storage.
916 ******************************************************************************/
919 AcpiNsTerminate (void)
921 ACPI_OPERAND_OBJECT *ObjDesc;
922 ACPI_NAMESPACE_NODE *ThisNode;
925 ACPI_FUNCTION_TRACE ("NsTerminate");
928 ThisNode = AcpiGbl_RootNode;
931 * 1) Free the entire namespace -- all objects, tables, and stacks
933 * Delete all objects linked to the root
934 * (additional table descriptors)
936 AcpiNsDeleteNamespaceSubtree (ThisNode);
938 /* Detach any object(s) attached to the root */
940 ObjDesc = AcpiNsGetAttachedObject (ThisNode);
943 AcpiNsDetachObject (ThisNode);
944 AcpiUtRemoveReference (ObjDesc);
947 AcpiNsDeleteChildren (ThisNode);
948 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace freed\n"));
952 * 2) Now we can delete the ACPI tables
954 AcpiTbDeleteAcpiTables ();
955 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n"));
961 /*******************************************************************************
963 * FUNCTION: AcpiNsOpensScope
965 * PARAMETERS: Type - A valid namespace type
967 * RETURN: NEWSCOPE if the passed type "opens a name scope" according
968 * to the ACPI specification, else 0
970 ******************************************************************************/
974 ACPI_OBJECT_TYPE Type)
976 ACPI_FUNCTION_TRACE_STR ("NsOpensScope", AcpiUtGetTypeName (Type));
979 if (!AcpiUtValidObjectType (Type))
981 /* type code out of range */
983 ACPI_REPORT_WARNING (("NsOpensScope: Invalid Object Type %X\n", Type));
984 return_VALUE (ACPI_NS_NORMAL);
987 return_VALUE (((UINT32) AcpiGbl_NsProperties[Type]) & ACPI_NS_NEWSCOPE);
991 /*******************************************************************************
993 * FUNCTION: AcpiNsGetNodeByPath
995 * PARAMETERS: *Pathname - Name to be found, in external (ASL) format. The
996 * \ (backslash) and ^ (carat) prefixes, and the
997 * . (period) to separate segments are supported.
998 * StartNode - Root of subtree to be searched, or NS_ALL for the
999 * root of the name space. If Name is fully
1000 * qualified (first INT8 is '\'), the passed value
1001 * of Scope will not be accessed.
1002 * Flags - Used to indicate whether to perform upsearch or
1004 * ReturnNode - Where the Node is returned
1006 * DESCRIPTION: Look up a name relative to a given scope and return the
1007 * corresponding Node. NOTE: Scope can be null.
1009 * MUTEX: Locks namespace
1011 ******************************************************************************/
1014 AcpiNsGetNodeByPath (
1016 ACPI_NAMESPACE_NODE *StartNode,
1018 ACPI_NAMESPACE_NODE **ReturnNode)
1020 ACPI_GENERIC_STATE ScopeInfo;
1022 char *InternalPath = NULL;
1025 ACPI_FUNCTION_TRACE_PTR ("NsGetNodeByPath", Pathname);
1030 /* Convert path to internal representation */
1032 Status = AcpiNsInternalizeName (Pathname, &InternalPath);
1033 if (ACPI_FAILURE (Status))
1035 return_ACPI_STATUS (Status);
1039 /* Must lock namespace during lookup */
1041 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
1042 if (ACPI_FAILURE (Status))
1044 return_ACPI_STATUS (Status);
1047 /* Setup lookup scope (search starting point) */
1049 ScopeInfo.Scope.Node = StartNode;
1051 /* Lookup the name in the namespace */
1053 Status = AcpiNsLookup (&ScopeInfo, InternalPath,
1054 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
1055 (Flags | ACPI_NS_DONT_OPEN_SCOPE),
1057 if (ACPI_FAILURE (Status))
1059 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s, %s\n",
1060 InternalPath, AcpiFormatException (Status)));
1065 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
1069 ACPI_MEM_FREE (InternalPath);
1071 return_ACPI_STATUS (Status);
1075 /*******************************************************************************
1077 * FUNCTION: AcpiNsFindParentName
1079 * PARAMETERS: *ChildNode - Named Obj whose name is to be found
1081 * RETURN: The ACPI name
1083 * DESCRIPTION: Search for the given obj in its parent scope and return the
1084 * name segment, or "????" if the parent name can't be found
1085 * (which "should not happen").
1087 ******************************************************************************/
1090 AcpiNsFindParentName (
1091 ACPI_NAMESPACE_NODE *ChildNode)
1093 ACPI_NAMESPACE_NODE *ParentNode;
1096 ACPI_FUNCTION_TRACE ("NsFindParentName");
1101 /* Valid entry. Get the parent Node */
1103 ParentNode = AcpiNsGetParentNode (ChildNode);
1106 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Parent of %p [%4.4s] is %p [%4.4s]\n",
1107 ChildNode, ChildNode->Name.Ascii,
1108 ParentNode, ParentNode->Name.Ascii));
1110 if (ParentNode->Name.Integer)
1112 return_VALUE ((ACPI_NAME) ParentNode->Name.Integer);
1116 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "unable to find parent of %p (%4.4s)\n",
1117 ChildNode, ChildNode->Name.Ascii));
1120 return_VALUE (ACPI_UNKNOWN_NAME);
1124 /*******************************************************************************
1126 * FUNCTION: AcpiNsGetParentNode
1128 * PARAMETERS: Node - Current table entry
1130 * RETURN: Parent entry of the given entry
1132 * DESCRIPTION: Obtain the parent entry for a given entry in the namespace.
1134 ******************************************************************************/
1137 ACPI_NAMESPACE_NODE *
1138 AcpiNsGetParentNode (
1139 ACPI_NAMESPACE_NODE *Node)
1141 ACPI_FUNCTION_ENTRY ();
1150 * Walk to the end of this peer list.
1151 * The last entry is marked with a flag and the peer
1152 * pointer is really a pointer back to the parent.
1153 * This saves putting a parent back pointer in each and
1154 * every named object!
1156 while (!(Node->Flags & ANOBJ_END_OF_PEER_LIST))
1162 return (Node->Peer);
1166 /*******************************************************************************
1168 * FUNCTION: AcpiNsGetNextValidNode
1170 * PARAMETERS: Node - Current table entry
1172 * RETURN: Next valid Node in the linked node list. NULL if no more valid
1175 * DESCRIPTION: Find the next valid node within a name table.
1176 * Useful for implementing NULL-end-of-list loops.
1178 ******************************************************************************/
1181 ACPI_NAMESPACE_NODE *
1182 AcpiNsGetNextValidNode (
1183 ACPI_NAMESPACE_NODE *Node)
1186 /* If we are at the end of this peer list, return NULL */
1188 if (Node->Flags & ANOBJ_END_OF_PEER_LIST)
1193 /* Otherwise just return the next peer */
1195 return (Node->Peer);