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 - 2005, 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__
120 #include <contrib/dev/acpica/acpi.h>
121 #include <contrib/dev/acpica/acnamesp.h>
122 #include <contrib/dev/acpica/amlcode.h>
123 #include <contrib/dev/acpica/actables.h>
125 #define _COMPONENT ACPI_NAMESPACE
126 ACPI_MODULE_NAME ("nsutils")
128 /* Local prototypes */
131 AcpiNsValidPathSeparator (
134 #ifdef ACPI_OBSOLETE_FUNCTIONS
136 AcpiNsFindParentName (
137 ACPI_NAMESPACE_NODE *NodeToSearch);
141 /*******************************************************************************
143 * FUNCTION: AcpiNsReportError
145 * PARAMETERS: ModuleName - Caller's module name (for error output)
146 * LineNumber - Caller's line number (for error output)
147 * ComponentId - Caller's component ID (for error output)
148 * InternalName - Name or path of the namespace node
149 * LookupStatus - Exception code from NS lookup
153 * DESCRIPTION: Print warning message with full pathname
155 ******************************************************************************/
163 ACPI_STATUS LookupStatus)
169 AcpiOsPrintf ("%8s-%04d: *** Error: Looking up ",
170 ModuleName, LineNumber);
172 if (LookupStatus == AE_BAD_CHARACTER)
174 /* There is a non-ascii character in the name */
176 AcpiOsPrintf ("[0x%4.4X] (NON-ASCII)\n",
177 *(ACPI_CAST_PTR (UINT32, InternalName)));
181 /* Convert path to external format */
183 Status = AcpiNsExternalizeName (ACPI_UINT32_MAX,
184 InternalName, NULL, &Name);
186 /* Print target name */
188 if (ACPI_SUCCESS (Status))
190 AcpiOsPrintf ("[%s]", Name);
194 AcpiOsPrintf ("[COULD NOT EXTERNALIZE NAME]");
199 ACPI_MEM_FREE (Name);
203 AcpiOsPrintf (" in namespace, %s\n",
204 AcpiFormatException (LookupStatus));
208 /*******************************************************************************
210 * FUNCTION: AcpiNsReportMethodError
212 * PARAMETERS: ModuleName - Caller's module name (for error output)
213 * LineNumber - Caller's line number (for error output)
214 * ComponentId - Caller's component ID (for error output)
215 * Message - Error message to use on failure
216 * PrefixNode - Prefix relative to the path
217 * Path - Path to the node
218 * MethodStatus - Execution status
222 * DESCRIPTION: Print warning message with full pathname
224 ******************************************************************************/
227 AcpiNsReportMethodError (
232 ACPI_NAMESPACE_NODE *PrefixNode,
234 ACPI_STATUS MethodStatus)
237 ACPI_NAMESPACE_NODE *Node = PrefixNode;
242 Status = AcpiNsGetNodeByPath (Path, PrefixNode,
243 ACPI_NS_NO_UPSEARCH, &Node);
244 if (ACPI_FAILURE (Status))
246 AcpiOsPrintf ("ReportMethodError: Could not get node\n");
251 AcpiOsPrintf ("%8s-%04d: *** Error: ", ModuleName, LineNumber);
252 AcpiNsPrintNodePathname (Node, Message);
253 AcpiOsPrintf (", %s\n", AcpiFormatException (MethodStatus));
257 /*******************************************************************************
259 * FUNCTION: AcpiNsPrintNodePathname
261 * PARAMETERS: Node - Object
262 * Message - Prefix message
264 * DESCRIPTION: Print an object's full namespace pathname
265 * Manages allocation/freeing of a pathname buffer
267 ******************************************************************************/
270 AcpiNsPrintNodePathname (
271 ACPI_NAMESPACE_NODE *Node,
280 AcpiOsPrintf ("[NULL NAME]");
284 /* Convert handle to full pathname and print it (with supplied message) */
286 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
288 Status = AcpiNsHandleToPathname (Node, &Buffer);
289 if (ACPI_SUCCESS (Status))
293 AcpiOsPrintf ("%s ", Message);
296 AcpiOsPrintf ("[%s] (Node %p)", (char *) Buffer.Pointer, Node);
297 ACPI_MEM_FREE (Buffer.Pointer);
302 /*******************************************************************************
304 * FUNCTION: AcpiNsValidRootPrefix
306 * PARAMETERS: Prefix - Character to be checked
308 * RETURN: TRUE if a valid prefix
310 * DESCRIPTION: Check if a character is a valid ACPI Root prefix
312 ******************************************************************************/
315 AcpiNsValidRootPrefix (
319 return ((BOOLEAN) (Prefix == '\\'));
323 /*******************************************************************************
325 * FUNCTION: AcpiNsValidPathSeparator
327 * PARAMETERS: Sep - Character to be checked
329 * RETURN: TRUE if a valid path separator
331 * DESCRIPTION: Check if a character is a valid ACPI path separator
333 ******************************************************************************/
336 AcpiNsValidPathSeparator (
340 return ((BOOLEAN) (Sep == '.'));
344 /*******************************************************************************
346 * FUNCTION: AcpiNsGetType
348 * PARAMETERS: Node - Parent Node to be examined
350 * RETURN: Type field from Node whose handle is passed
352 * DESCRIPTION: Return the type of a Namespace node
354 ******************************************************************************/
358 ACPI_NAMESPACE_NODE *Node)
360 ACPI_FUNCTION_TRACE ("NsGetType");
365 ACPI_REPORT_WARNING (("NsGetType: Null Node input pointer\n"));
366 return_UINT32 (ACPI_TYPE_ANY);
369 return_UINT32 ((ACPI_OBJECT_TYPE) Node->Type);
373 /*******************************************************************************
375 * FUNCTION: AcpiNsLocal
377 * PARAMETERS: Type - A namespace object type
379 * RETURN: LOCAL if names must be found locally in objects of the
380 * passed type, 0 if enclosing scopes should be searched
382 * DESCRIPTION: Returns scope rule for the given object type.
384 ******************************************************************************/
388 ACPI_OBJECT_TYPE Type)
390 ACPI_FUNCTION_TRACE ("NsLocal");
393 if (!AcpiUtValidObjectType (Type))
395 /* Type code out of range */
397 ACPI_REPORT_WARNING (("NsLocal: Invalid Object Type\n"));
398 return_UINT32 (ACPI_NS_NORMAL);
401 return_UINT32 ((UINT32) AcpiGbl_NsProperties[Type] & ACPI_NS_LOCAL);
405 /*******************************************************************************
407 * FUNCTION: AcpiNsGetInternalNameLength
409 * PARAMETERS: Info - Info struct initialized with the
410 * external name pointer.
414 * DESCRIPTION: Calculate the length of the internal (AML) namestring
415 * corresponding to the external (ASL) namestring.
417 ******************************************************************************/
420 AcpiNsGetInternalNameLength (
421 ACPI_NAMESTRING_INFO *Info)
423 char *NextExternalChar;
427 ACPI_FUNCTION_ENTRY ();
430 NextExternalChar = Info->ExternalName;
432 Info->NumSegments = 0;
433 Info->FullyQualified = FALSE;
436 * For the internal name, the required length is 4 bytes per segment, plus
437 * 1 each for RootPrefix, MultiNamePrefixOp, segment count, trailing null
438 * (which is not really needed, but no there's harm in putting it there)
440 * strlen() + 1 covers the first NameSeg, which has no path separator
442 if (AcpiNsValidRootPrefix (NextExternalChar[0]))
444 Info->FullyQualified = TRUE;
450 * Handle Carat prefixes
452 while (*NextExternalChar == '^')
460 * Determine the number of ACPI name "segments" by counting the number of
461 * path separators within the string. Start with one segment since the
462 * segment count is [(# separators) + 1], and zero separators is ok.
464 if (*NextExternalChar)
466 Info->NumSegments = 1;
467 for (i = 0; NextExternalChar[i]; i++)
469 if (AcpiNsValidPathSeparator (NextExternalChar[i]))
476 Info->Length = (ACPI_NAME_SIZE * Info->NumSegments) +
479 Info->NextExternalChar = NextExternalChar;
483 /*******************************************************************************
485 * FUNCTION: AcpiNsBuildInternalName
487 * PARAMETERS: Info - Info struct fully initialized
491 * DESCRIPTION: Construct the internal (AML) namestring
492 * corresponding to the external (ASL) namestring.
494 ******************************************************************************/
497 AcpiNsBuildInternalName (
498 ACPI_NAMESTRING_INFO *Info)
500 UINT32 NumSegments = Info->NumSegments;
501 char *InternalName = Info->InternalName;
502 char *ExternalName = Info->NextExternalChar;
507 ACPI_FUNCTION_TRACE ("NsBuildInternalName");
510 /* Setup the correct prefixes, counts, and pointers */
512 if (Info->FullyQualified)
514 InternalName[0] = '\\';
516 if (NumSegments <= 1)
518 Result = &InternalName[1];
520 else if (NumSegments == 2)
522 InternalName[1] = AML_DUAL_NAME_PREFIX;
523 Result = &InternalName[2];
527 InternalName[1] = AML_MULTI_NAME_PREFIX_OP;
528 InternalName[2] = (char) NumSegments;
529 Result = &InternalName[3];
535 * Not fully qualified.
536 * Handle Carats first, then append the name segments
541 for (i = 0; i < Info->NumCarats; i++)
543 InternalName[i] = '^';
547 if (NumSegments <= 1)
549 Result = &InternalName[i];
551 else if (NumSegments == 2)
553 InternalName[i] = AML_DUAL_NAME_PREFIX;
554 Result = &InternalName[(ACPI_NATIVE_UINT) (i+1)];
558 InternalName[i] = AML_MULTI_NAME_PREFIX_OP;
559 InternalName[(ACPI_NATIVE_UINT) (i+1)] = (char) NumSegments;
560 Result = &InternalName[(ACPI_NATIVE_UINT) (i+2)];
564 /* Build the name (minus path separators) */
566 for (; NumSegments; NumSegments--)
568 for (i = 0; i < ACPI_NAME_SIZE; i++)
570 if (AcpiNsValidPathSeparator (*ExternalName) ||
571 (*ExternalName == 0))
573 /* Pad the segment with underscore(s) if segment is short */
579 /* Convert the character to uppercase and save it */
581 Result[i] = (char) ACPI_TOUPPER ((int) *ExternalName);
586 /* Now we must have a path separator, or the pathname is bad */
588 if (!AcpiNsValidPathSeparator (*ExternalName) &&
589 (*ExternalName != 0))
591 return_ACPI_STATUS (AE_BAD_PARAMETER);
594 /* Move on the next segment */
597 Result += ACPI_NAME_SIZE;
600 /* Terminate the string */
604 if (Info->FullyQualified)
606 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Returning [%p] (abs) \"\\%s\"\n",
607 InternalName, InternalName));
611 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Returning [%p] (rel) \"%s\"\n",
612 InternalName, InternalName));
615 return_ACPI_STATUS (AE_OK);
619 /*******************************************************************************
621 * FUNCTION: AcpiNsInternalizeName
623 * PARAMETERS: *ExternalName - External representation of name
624 * **Converted Name - Where to return the resulting
625 * internal represention of the name
629 * DESCRIPTION: Convert an external representation (e.g. "\_PR_.CPU0")
630 * to internal form (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30)
632 *******************************************************************************/
635 AcpiNsInternalizeName (
637 char **ConvertedName)
640 ACPI_NAMESTRING_INFO Info;
644 ACPI_FUNCTION_TRACE ("NsInternalizeName");
647 if ((!ExternalName) ||
648 (*ExternalName == 0) ||
651 return_ACPI_STATUS (AE_BAD_PARAMETER);
654 /* Get the length of the new internal name */
656 Info.ExternalName = ExternalName;
657 AcpiNsGetInternalNameLength (&Info);
659 /* We need a segment to store the internal name */
661 InternalName = ACPI_MEM_CALLOCATE (Info.Length);
664 return_ACPI_STATUS (AE_NO_MEMORY);
669 Info.InternalName = InternalName;
670 Status = AcpiNsBuildInternalName (&Info);
671 if (ACPI_FAILURE (Status))
673 ACPI_MEM_FREE (InternalName);
674 return_ACPI_STATUS (Status);
677 *ConvertedName = InternalName;
678 return_ACPI_STATUS (AE_OK);
682 /*******************************************************************************
684 * FUNCTION: AcpiNsExternalizeName
686 * PARAMETERS: InternalNameLength - Lenth of the internal name below
687 * InternalName - Internal representation of name
688 * ConvertedNameLength - Where the length is returned
689 * ConvertedName - Where the resulting external name
694 * DESCRIPTION: Convert internal name (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30)
695 * to its external (printable) form (e.g. "\_PR_.CPU0")
697 ******************************************************************************/
700 AcpiNsExternalizeName (
701 UINT32 InternalNameLength,
703 UINT32 *ConvertedNameLength,
704 char **ConvertedName)
706 ACPI_NATIVE_UINT NamesIndex = 0;
707 ACPI_NATIVE_UINT NumSegments = 0;
708 ACPI_NATIVE_UINT RequiredLength;
709 ACPI_NATIVE_UINT PrefixLength = 0;
710 ACPI_NATIVE_UINT i = 0;
711 ACPI_NATIVE_UINT j = 0;
714 ACPI_FUNCTION_TRACE ("NsExternalizeName");
717 if (!InternalNameLength ||
721 return_ACPI_STATUS (AE_BAD_PARAMETER);
725 * Check for a prefix (one '\' | one or more '^').
727 switch (InternalName[0])
734 for (i = 0; i < InternalNameLength; i++)
736 if (InternalName[i] == '^')
738 PrefixLength = i + 1;
746 if (i == InternalNameLength)
758 * Check for object names. Note that there could be 0-255 of these
761 if (PrefixLength < InternalNameLength)
763 switch (InternalName[PrefixLength])
765 case AML_MULTI_NAME_PREFIX_OP:
767 /* <count> 4-byte names */
769 NamesIndex = PrefixLength + 2;
770 NumSegments = (ACPI_NATIVE_UINT) (UINT8)
771 InternalName[(ACPI_NATIVE_UINT) (PrefixLength + 1)];
774 case AML_DUAL_NAME_PREFIX:
776 /* Two 4-byte names */
778 NamesIndex = PrefixLength + 1;
792 /* one 4-byte name */
794 NamesIndex = PrefixLength;
801 * Calculate the length of ConvertedName, which equals the length
802 * of the prefix, length of all object names, length of any required
803 * punctuation ('.') between object names, plus the NULL terminator.
805 RequiredLength = PrefixLength + (4 * NumSegments) +
806 ((NumSegments > 0) ? (NumSegments - 1) : 0) + 1;
809 * Check to see if we're still in bounds. If not, there's a problem
810 * with InternalName (invalid format).
812 if (RequiredLength > InternalNameLength)
814 ACPI_REPORT_ERROR (("NsExternalizeName: Invalid internal name\n"));
815 return_ACPI_STATUS (AE_BAD_PATHNAME);
819 * Build ConvertedName
821 *ConvertedName = ACPI_MEM_CALLOCATE (RequiredLength);
822 if (!(*ConvertedName))
824 return_ACPI_STATUS (AE_NO_MEMORY);
829 for (i = 0; i < PrefixLength; i++)
831 (*ConvertedName)[j++] = InternalName[i];
836 for (i = 0; i < NumSegments; i++)
840 (*ConvertedName)[j++] = '.';
843 (*ConvertedName)[j++] = InternalName[NamesIndex++];
844 (*ConvertedName)[j++] = InternalName[NamesIndex++];
845 (*ConvertedName)[j++] = InternalName[NamesIndex++];
846 (*ConvertedName)[j++] = InternalName[NamesIndex++];
850 if (ConvertedNameLength)
852 *ConvertedNameLength = (UINT32) RequiredLength;
855 return_ACPI_STATUS (AE_OK);
859 /*******************************************************************************
861 * FUNCTION: AcpiNsMapHandleToNode
863 * PARAMETERS: Handle - Handle to be converted to an Node
865 * RETURN: A Name table entry pointer
867 * DESCRIPTION: Convert a namespace handle to a real Node
869 * Note: Real integer handles would allow for more verification
870 * and keep all pointers within this subsystem - however this introduces
871 * more (and perhaps unnecessary) overhead.
873 ******************************************************************************/
875 ACPI_NAMESPACE_NODE *
876 AcpiNsMapHandleToNode (
880 ACPI_FUNCTION_ENTRY ();
884 * Simple implementation.
891 if (Handle == ACPI_ROOT_OBJECT)
893 return (AcpiGbl_RootNode);
896 /* We can at least attempt to verify the handle */
898 if (ACPI_GET_DESCRIPTOR_TYPE (Handle) != ACPI_DESC_TYPE_NAMED)
903 return ((ACPI_NAMESPACE_NODE *) Handle);
907 /*******************************************************************************
909 * FUNCTION: AcpiNsConvertEntryToHandle
911 * PARAMETERS: Node - Node to be converted to a Handle
913 * RETURN: A user handle
915 * DESCRIPTION: Convert a real Node to a namespace handle
917 ******************************************************************************/
920 AcpiNsConvertEntryToHandle (
921 ACPI_NAMESPACE_NODE *Node)
926 * Simple implementation for now;
928 return ((ACPI_HANDLE) Node);
931 /* Example future implementation ---------------------
938 if (Node == AcpiGbl_RootNode)
940 return (ACPI_ROOT_OBJECT);
944 return ((ACPI_HANDLE) Node);
945 ------------------------------------------------------*/
949 /*******************************************************************************
951 * FUNCTION: AcpiNsTerminate
957 * DESCRIPTION: free memory allocated for namespace and ACPI table storage.
959 ******************************************************************************/
965 ACPI_OPERAND_OBJECT *ObjDesc;
968 ACPI_FUNCTION_TRACE ("NsTerminate");
972 * 1) Free the entire namespace -- all nodes and objects
974 * Delete all object descriptors attached to namepsace nodes
976 AcpiNsDeleteNamespaceSubtree (AcpiGbl_RootNode);
978 /* Detach any objects attached to the root */
980 ObjDesc = AcpiNsGetAttachedObject (AcpiGbl_RootNode);
983 AcpiNsDetachObject (AcpiGbl_RootNode);
986 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace freed\n"));
989 * 2) Now we can delete the ACPI tables
991 AcpiTbDeleteAllTables ();
992 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n"));
998 /*******************************************************************************
1000 * FUNCTION: AcpiNsOpensScope
1002 * PARAMETERS: Type - A valid namespace type
1004 * RETURN: NEWSCOPE if the passed type "opens a name scope" according
1005 * to the ACPI specification, else 0
1007 ******************************************************************************/
1011 ACPI_OBJECT_TYPE Type)
1013 ACPI_FUNCTION_TRACE_STR ("NsOpensScope", AcpiUtGetTypeName (Type));
1016 if (!AcpiUtValidObjectType (Type))
1018 /* type code out of range */
1020 ACPI_REPORT_WARNING (("NsOpensScope: Invalid Object Type %X\n", Type));
1021 return_UINT32 (ACPI_NS_NORMAL);
1024 return_UINT32 (((UINT32) AcpiGbl_NsProperties[Type]) & ACPI_NS_NEWSCOPE);
1028 /*******************************************************************************
1030 * FUNCTION: AcpiNsGetNodeByPath
1032 * PARAMETERS: *Pathname - Name to be found, in external (ASL) format. The
1033 * \ (backslash) and ^ (carat) prefixes, and the
1034 * . (period) to separate segments are supported.
1035 * StartNode - Root of subtree to be searched, or NS_ALL for the
1036 * root of the name space. If Name is fully
1037 * qualified (first INT8 is '\'), the passed value
1038 * of Scope will not be accessed.
1039 * Flags - Used to indicate whether to perform upsearch or
1041 * ReturnNode - Where the Node is returned
1043 * DESCRIPTION: Look up a name relative to a given scope and return the
1044 * corresponding Node. NOTE: Scope can be null.
1046 * MUTEX: Locks namespace
1048 ******************************************************************************/
1051 AcpiNsGetNodeByPath (
1053 ACPI_NAMESPACE_NODE *StartNode,
1055 ACPI_NAMESPACE_NODE **ReturnNode)
1057 ACPI_GENERIC_STATE ScopeInfo;
1059 char *InternalPath = NULL;
1062 ACPI_FUNCTION_TRACE_PTR ("NsGetNodeByPath", Pathname);
1067 /* Convert path to internal representation */
1069 Status = AcpiNsInternalizeName (Pathname, &InternalPath);
1070 if (ACPI_FAILURE (Status))
1072 return_ACPI_STATUS (Status);
1076 /* Must lock namespace during lookup */
1078 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
1079 if (ACPI_FAILURE (Status))
1084 /* Setup lookup scope (search starting point) */
1086 ScopeInfo.Scope.Node = StartNode;
1088 /* Lookup the name in the namespace */
1090 Status = AcpiNsLookup (&ScopeInfo, InternalPath,
1091 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
1092 (Flags | ACPI_NS_DONT_OPEN_SCOPE),
1094 if (ACPI_FAILURE (Status))
1096 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s, %s\n",
1097 InternalPath, AcpiFormatException (Status)));
1100 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
1105 ACPI_MEM_FREE (InternalPath);
1107 return_ACPI_STATUS (Status);
1111 /*******************************************************************************
1113 * FUNCTION: AcpiNsGetParentNode
1115 * PARAMETERS: Node - Current table entry
1117 * RETURN: Parent entry of the given entry
1119 * DESCRIPTION: Obtain the parent entry for a given entry in the namespace.
1121 ******************************************************************************/
1123 ACPI_NAMESPACE_NODE *
1124 AcpiNsGetParentNode (
1125 ACPI_NAMESPACE_NODE *Node)
1127 ACPI_FUNCTION_ENTRY ();
1136 * Walk to the end of this peer list. The last entry is marked with a flag
1137 * and the peer pointer is really a pointer back to the parent. This saves
1138 * putting a parent back pointer in each and every named object!
1140 while (!(Node->Flags & ANOBJ_END_OF_PEER_LIST))
1145 return (Node->Peer);
1149 /*******************************************************************************
1151 * FUNCTION: AcpiNsGetNextValidNode
1153 * PARAMETERS: Node - Current table entry
1155 * RETURN: Next valid Node in the linked node list. NULL if no more valid
1158 * DESCRIPTION: Find the next valid node within a name table.
1159 * Useful for implementing NULL-end-of-list loops.
1161 ******************************************************************************/
1163 ACPI_NAMESPACE_NODE *
1164 AcpiNsGetNextValidNode (
1165 ACPI_NAMESPACE_NODE *Node)
1168 /* If we are at the end of this peer list, return NULL */
1170 if (Node->Flags & ANOBJ_END_OF_PEER_LIST)
1175 /* Otherwise just return the next peer */
1177 return (Node->Peer);
1181 #ifdef ACPI_OBSOLETE_FUNCTIONS
1182 /*******************************************************************************
1184 * FUNCTION: AcpiNsFindParentName
1186 * PARAMETERS: *ChildNode - Named Obj whose name is to be found
1188 * RETURN: The ACPI name
1190 * DESCRIPTION: Search for the given obj in its parent scope and return the
1191 * name segment, or "????" if the parent name can't be found
1192 * (which "should not happen").
1194 ******************************************************************************/
1197 AcpiNsFindParentName (
1198 ACPI_NAMESPACE_NODE *ChildNode)
1200 ACPI_NAMESPACE_NODE *ParentNode;
1203 ACPI_FUNCTION_TRACE ("NsFindParentName");
1208 /* Valid entry. Get the parent Node */
1210 ParentNode = AcpiNsGetParentNode (ChildNode);
1213 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
1214 "Parent of %p [%4.4s] is %p [%4.4s]\n",
1215 ChildNode, AcpiUtGetNodeName (ChildNode),
1216 ParentNode, AcpiUtGetNodeName (ParentNode)));
1218 if (ParentNode->Name.Integer)
1220 return_VALUE ((ACPI_NAME) ParentNode->Name.Integer);
1224 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
1225 "Unable to find parent of %p (%4.4s)\n",
1226 ChildNode, AcpiUtGetNodeName (ChildNode)));
1229 return_VALUE (ACPI_UNKNOWN_NAME);