13446Smrj /******************************************************************************
23446Smrj *
33446Smrj * Module Name: nsutils - Utilities for accessing ACPI namespace, accessing
43446Smrj * parents and siblings and Scope manipulation
53446Smrj *
63446Smrj *****************************************************************************/
73446Smrj
83446Smrj /******************************************************************************
93446Smrj *
103446Smrj * 1. Copyright Notice
113446Smrj *
129980SDana.Myers@Sun.COM * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
133446Smrj * All rights reserved.
143446Smrj *
153446Smrj * 2. License
163446Smrj *
173446Smrj * 2.1. This is your license from Intel Corp. under its intellectual property
183446Smrj * rights. You may have additional license terms from the party that provided
193446Smrj * you this software, covering your right to use that party's intellectual
203446Smrj * property rights.
213446Smrj *
223446Smrj * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
233446Smrj * copy of the source code appearing in this file ("Covered Code") an
243446Smrj * irrevocable, perpetual, worldwide license under Intel's copyrights in the
253446Smrj * base code distributed originally by Intel ("Original Intel Code") to copy,
263446Smrj * make derivatives, distribute, use and display any portion of the Covered
273446Smrj * Code in any form, with the right to sublicense such rights; and
283446Smrj *
293446Smrj * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
303446Smrj * license (with the right to sublicense), under only those claims of Intel
313446Smrj * patents that are infringed by the Original Intel Code, to make, use, sell,
323446Smrj * offer to sell, and import the Covered Code and derivative works thereof
333446Smrj * solely to the minimum extent necessary to exercise the above copyright
343446Smrj * license, and in no event shall the patent license extend to any additions
353446Smrj * to or modifications of the Original Intel Code. No other license or right
363446Smrj * is granted directly or by implication, estoppel or otherwise;
373446Smrj *
383446Smrj * The above copyright and patent license is granted only if the following
393446Smrj * conditions are met:
403446Smrj *
413446Smrj * 3. Conditions
423446Smrj *
433446Smrj * 3.1. Redistribution of Source with Rights to Further Distribute Source.
443446Smrj * Redistribution of source code of any substantial portion of the Covered
453446Smrj * Code or modification with rights to further distribute source must include
463446Smrj * the above Copyright Notice, the above License, this list of Conditions,
473446Smrj * and the following Disclaimer and Export Compliance provision. In addition,
483446Smrj * Licensee must cause all Covered Code to which Licensee contributes to
493446Smrj * contain a file documenting the changes Licensee made to create that Covered
503446Smrj * Code and the date of any change. Licensee must include in that file the
513446Smrj * documentation of any changes made by any predecessor Licensee. Licensee
523446Smrj * must include a prominent statement that the modification is derived,
533446Smrj * directly or indirectly, from Original Intel Code.
543446Smrj *
553446Smrj * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
563446Smrj * Redistribution of source code of any substantial portion of the Covered
573446Smrj * Code or modification without rights to further distribute source must
583446Smrj * include the following Disclaimer and Export Compliance provision in the
593446Smrj * documentation and/or other materials provided with distribution. In
603446Smrj * addition, Licensee may not authorize further sublicense of source of any
613446Smrj * portion of the Covered Code, and must include terms to the effect that the
623446Smrj * license from Licensee to its licensee is limited to the intellectual
633446Smrj * property embodied in the software Licensee provides to its licensee, and
643446Smrj * not to intellectual property embodied in modifications its licensee may
653446Smrj * make.
663446Smrj *
673446Smrj * 3.3. Redistribution of Executable. Redistribution in executable form of any
683446Smrj * substantial portion of the Covered Code or modification must reproduce the
693446Smrj * above Copyright Notice, and the following Disclaimer and Export Compliance
703446Smrj * provision in the documentation and/or other materials provided with the
713446Smrj * distribution.
723446Smrj *
733446Smrj * 3.4. Intel retains all right, title, and interest in and to the Original
743446Smrj * Intel Code.
753446Smrj *
763446Smrj * 3.5. Neither the name Intel nor any other trademark owned or controlled by
773446Smrj * Intel shall be used in advertising or otherwise to promote the sale, use or
783446Smrj * other dealings in products derived from or relating to the Covered Code
793446Smrj * without prior written authorization from Intel.
803446Smrj *
813446Smrj * 4. Disclaimer and Export Compliance
823446Smrj *
833446Smrj * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
843446Smrj * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
853446Smrj * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
863446Smrj * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
873446Smrj * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
883446Smrj * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
893446Smrj * PARTICULAR PURPOSE.
903446Smrj *
913446Smrj * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
923446Smrj * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
933446Smrj * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
943446Smrj * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
953446Smrj * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
963446Smrj * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
973446Smrj * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
983446Smrj * LIMITED REMEDY.
993446Smrj *
1003446Smrj * 4.3. Licensee shall not export, either directly or indirectly, any of this
1013446Smrj * software or system incorporating such software without first obtaining any
1023446Smrj * required license or other approval from the U. S. Department of Commerce or
1033446Smrj * any other agency or department of the United States Government. In the
1043446Smrj * event Licensee exports any such software from the United States or
1053446Smrj * re-exports any such software from a foreign destination, Licensee shall
1063446Smrj * ensure that the distribution and export/re-export of the software is in
1073446Smrj * compliance with all laws, regulations, orders, or other restrictions of the
1083446Smrj * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1093446Smrj * any of its subsidiaries will export/re-export any technical data, process,
1103446Smrj * software, or service, directly or indirectly, to any country for which the
1113446Smrj * United States government or any agency thereof requires an export license,
1123446Smrj * other governmental approval, or letter of assurance, without first obtaining
1133446Smrj * such license, approval or letter.
1143446Smrj *
1153446Smrj *****************************************************************************/
1163446Smrj
1173446Smrj #define __NSUTILS_C__
1183446Smrj
1193446Smrj #include "acpi.h"
1209980SDana.Myers@Sun.COM #include "accommon.h"
1213446Smrj #include "acnamesp.h"
1223446Smrj #include "amlcode.h"
1233446Smrj
1243446Smrj #define _COMPONENT ACPI_NAMESPACE
1253446Smrj ACPI_MODULE_NAME ("nsutils")
1263446Smrj
1273446Smrj /* Local prototypes */
1283446Smrj
1293446Smrj static BOOLEAN
1303446Smrj AcpiNsValidPathSeparator (
1313446Smrj char Sep);
1323446Smrj
1333446Smrj #ifdef ACPI_OBSOLETE_FUNCTIONS
1343446Smrj ACPI_NAME
1353446Smrj AcpiNsFindParentName (
1363446Smrj ACPI_NAMESPACE_NODE *NodeToSearch);
1373446Smrj #endif
1383446Smrj
1393446Smrj
1403446Smrj /*******************************************************************************
1413446Smrj *
1423446Smrj * FUNCTION: AcpiNsReportError
1433446Smrj *
1443446Smrj * PARAMETERS: ModuleName - Caller's module name (for error output)
1453446Smrj * LineNumber - Caller's line number (for error output)
1463446Smrj * InternalName - Name or path of the namespace node
1473446Smrj * LookupStatus - Exception code from NS lookup
1483446Smrj *
1493446Smrj * RETURN: None
1503446Smrj *
1513446Smrj * DESCRIPTION: Print warning message with full pathname
1523446Smrj *
1533446Smrj ******************************************************************************/
1543446Smrj
1553446Smrj void
AcpiNsReportError(const char * ModuleName,UINT32 LineNumber,const char * InternalName,ACPI_STATUS LookupStatus)1563446Smrj AcpiNsReportError (
1577851SDana.Myers@Sun.COM const char *ModuleName,
1583446Smrj UINT32 LineNumber,
1597851SDana.Myers@Sun.COM const char *InternalName,
1603446Smrj ACPI_STATUS LookupStatus)
1613446Smrj {
1623446Smrj ACPI_STATUS Status;
1633446Smrj UINT32 BadName;
1643446Smrj char *Name = NULL;
1653446Smrj
1663446Smrj
1673446Smrj AcpiOsPrintf ("ACPI Error (%s-%04d): ", ModuleName, LineNumber);
1683446Smrj
1693446Smrj if (LookupStatus == AE_BAD_CHARACTER)
1703446Smrj {
1713446Smrj /* There is a non-ascii character in the name */
1723446Smrj
173*11225SDana.Myers@Sun.COM ACPI_MOVE_32_TO_32 (&BadName, ACPI_CAST_PTR (UINT32, InternalName));
1743446Smrj AcpiOsPrintf ("[0x%4.4X] (NON-ASCII)", BadName);
1753446Smrj }
1763446Smrj else
1773446Smrj {
1783446Smrj /* Convert path to external format */
1793446Smrj
1803446Smrj Status = AcpiNsExternalizeName (ACPI_UINT32_MAX,
1813446Smrj InternalName, NULL, &Name);
1823446Smrj
1833446Smrj /* Print target name */
1843446Smrj
1853446Smrj if (ACPI_SUCCESS (Status))
1863446Smrj {
1873446Smrj AcpiOsPrintf ("[%s]", Name);
1883446Smrj }
1893446Smrj else
1903446Smrj {
1913446Smrj AcpiOsPrintf ("[COULD NOT EXTERNALIZE NAME]");
1923446Smrj }
1933446Smrj
1943446Smrj if (Name)
1953446Smrj {
1963446Smrj ACPI_FREE (Name);
1973446Smrj }
1983446Smrj }
1993446Smrj
2003446Smrj AcpiOsPrintf (" Namespace lookup failure, %s\n",
2013446Smrj AcpiFormatException (LookupStatus));
2023446Smrj }
2033446Smrj
2043446Smrj
2053446Smrj /*******************************************************************************
2063446Smrj *
2073446Smrj * FUNCTION: AcpiNsReportMethodError
2083446Smrj *
2093446Smrj * PARAMETERS: ModuleName - Caller's module name (for error output)
2103446Smrj * LineNumber - Caller's line number (for error output)
2113446Smrj * Message - Error message to use on failure
2123446Smrj * PrefixNode - Prefix relative to the path
2133446Smrj * Path - Path to the node (optional)
2143446Smrj * MethodStatus - Execution status
2153446Smrj *
2163446Smrj * RETURN: None
2173446Smrj *
2183446Smrj * DESCRIPTION: Print warning message with full pathname
2193446Smrj *
2203446Smrj ******************************************************************************/
2213446Smrj
2223446Smrj void
AcpiNsReportMethodError(const char * ModuleName,UINT32 LineNumber,const char * Message,ACPI_NAMESPACE_NODE * PrefixNode,const char * Path,ACPI_STATUS MethodStatus)2233446Smrj AcpiNsReportMethodError (
2247851SDana.Myers@Sun.COM const char *ModuleName,
2253446Smrj UINT32 LineNumber,
2267851SDana.Myers@Sun.COM const char *Message,
2273446Smrj ACPI_NAMESPACE_NODE *PrefixNode,
2287851SDana.Myers@Sun.COM const char *Path,
2293446Smrj ACPI_STATUS MethodStatus)
2303446Smrj {
2313446Smrj ACPI_STATUS Status;
2323446Smrj ACPI_NAMESPACE_NODE *Node = PrefixNode;
2333446Smrj
2343446Smrj
2353446Smrj AcpiOsPrintf ("ACPI Error (%s-%04d): ", ModuleName, LineNumber);
2363446Smrj
2373446Smrj if (Path)
2383446Smrj {
2393446Smrj Status = AcpiNsGetNode (PrefixNode, Path, ACPI_NS_NO_UPSEARCH,
2403446Smrj &Node);
2413446Smrj if (ACPI_FAILURE (Status))
2423446Smrj {
2433446Smrj AcpiOsPrintf ("[Could not get node by pathname]");
2443446Smrj }
2453446Smrj }
2463446Smrj
2473446Smrj AcpiNsPrintNodePathname (Node, Message);
2483446Smrj AcpiOsPrintf (", %s\n", AcpiFormatException (MethodStatus));
2493446Smrj }
2503446Smrj
2513446Smrj
2523446Smrj /*******************************************************************************
2533446Smrj *
2543446Smrj * FUNCTION: AcpiNsPrintNodePathname
2553446Smrj *
2563446Smrj * PARAMETERS: Node - Object
2573446Smrj * Message - Prefix message
2583446Smrj *
2593446Smrj * DESCRIPTION: Print an object's full namespace pathname
2603446Smrj * Manages allocation/freeing of a pathname buffer
2613446Smrj *
2623446Smrj ******************************************************************************/
2633446Smrj
2643446Smrj void
AcpiNsPrintNodePathname(ACPI_NAMESPACE_NODE * Node,const char * Message)2653446Smrj AcpiNsPrintNodePathname (
2663446Smrj ACPI_NAMESPACE_NODE *Node,
2677851SDana.Myers@Sun.COM const char *Message)
2683446Smrj {
2693446Smrj ACPI_BUFFER Buffer;
2703446Smrj ACPI_STATUS Status;
2713446Smrj
2723446Smrj
2733446Smrj if (!Node)
2743446Smrj {
2753446Smrj AcpiOsPrintf ("[NULL NAME]");
2763446Smrj return;
2773446Smrj }
2783446Smrj
2793446Smrj /* Convert handle to full pathname and print it (with supplied message) */
2803446Smrj
2813446Smrj Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
2823446Smrj
2833446Smrj Status = AcpiNsHandleToPathname (Node, &Buffer);
2843446Smrj if (ACPI_SUCCESS (Status))
2853446Smrj {
2863446Smrj if (Message)
2873446Smrj {
2883446Smrj AcpiOsPrintf ("%s ", Message);
2893446Smrj }
2903446Smrj
2913446Smrj AcpiOsPrintf ("[%s] (Node %p)", (char *) Buffer.Pointer, Node);
2923446Smrj ACPI_FREE (Buffer.Pointer);
2933446Smrj }
2943446Smrj }
2953446Smrj
2963446Smrj
2973446Smrj /*******************************************************************************
2983446Smrj *
2993446Smrj * FUNCTION: AcpiNsValidRootPrefix
3003446Smrj *
3013446Smrj * PARAMETERS: Prefix - Character to be checked
3023446Smrj *
3033446Smrj * RETURN: TRUE if a valid prefix
3043446Smrj *
3053446Smrj * DESCRIPTION: Check if a character is a valid ACPI Root prefix
3063446Smrj *
3073446Smrj ******************************************************************************/
3083446Smrj
3093446Smrj BOOLEAN
AcpiNsValidRootPrefix(char Prefix)3103446Smrj AcpiNsValidRootPrefix (
3113446Smrj char Prefix)
3123446Smrj {
3133446Smrj
3143446Smrj return ((BOOLEAN) (Prefix == '\\'));
3153446Smrj }
3163446Smrj
3173446Smrj
3183446Smrj /*******************************************************************************
3193446Smrj *
3203446Smrj * FUNCTION: AcpiNsValidPathSeparator
3213446Smrj *
3223446Smrj * PARAMETERS: Sep - Character to be checked
3233446Smrj *
3243446Smrj * RETURN: TRUE if a valid path separator
3253446Smrj *
3263446Smrj * DESCRIPTION: Check if a character is a valid ACPI path separator
3273446Smrj *
3283446Smrj ******************************************************************************/
3293446Smrj
3303446Smrj static BOOLEAN
AcpiNsValidPathSeparator(char Sep)3313446Smrj AcpiNsValidPathSeparator (
3323446Smrj char Sep)
3333446Smrj {
3343446Smrj
3353446Smrj return ((BOOLEAN) (Sep == '.'));
3363446Smrj }
3373446Smrj
3383446Smrj
3393446Smrj /*******************************************************************************
3403446Smrj *
3413446Smrj * FUNCTION: AcpiNsGetType
3423446Smrj *
3433446Smrj * PARAMETERS: Node - Parent Node to be examined
3443446Smrj *
3453446Smrj * RETURN: Type field from Node whose handle is passed
3463446Smrj *
3473446Smrj * DESCRIPTION: Return the type of a Namespace node
3483446Smrj *
3493446Smrj ******************************************************************************/
3503446Smrj
3513446Smrj ACPI_OBJECT_TYPE
AcpiNsGetType(ACPI_NAMESPACE_NODE * Node)3523446Smrj AcpiNsGetType (
3533446Smrj ACPI_NAMESPACE_NODE *Node)
3543446Smrj {
3553446Smrj ACPI_FUNCTION_TRACE (NsGetType);
3563446Smrj
3573446Smrj
3583446Smrj if (!Node)
3593446Smrj {
3603446Smrj ACPI_WARNING ((AE_INFO, "Null Node parameter"));
3613446Smrj return_UINT32 (ACPI_TYPE_ANY);
3623446Smrj }
3633446Smrj
3643446Smrj return_UINT32 ((ACPI_OBJECT_TYPE) Node->Type);
3653446Smrj }
3663446Smrj
3673446Smrj
3683446Smrj /*******************************************************************************
3693446Smrj *
3703446Smrj * FUNCTION: AcpiNsLocal
3713446Smrj *
3723446Smrj * PARAMETERS: Type - A namespace object type
3733446Smrj *
3743446Smrj * RETURN: LOCAL if names must be found locally in objects of the
3753446Smrj * passed type, 0 if enclosing scopes should be searched
3763446Smrj *
3773446Smrj * DESCRIPTION: Returns scope rule for the given object type.
3783446Smrj *
3793446Smrj ******************************************************************************/
3803446Smrj
3813446Smrj UINT32
AcpiNsLocal(ACPI_OBJECT_TYPE Type)3823446Smrj AcpiNsLocal (
3833446Smrj ACPI_OBJECT_TYPE Type)
3843446Smrj {
3853446Smrj ACPI_FUNCTION_TRACE (NsLocal);
3863446Smrj
3873446Smrj
3883446Smrj if (!AcpiUtValidObjectType (Type))
3893446Smrj {
3903446Smrj /* Type code out of range */
3913446Smrj
3923446Smrj ACPI_WARNING ((AE_INFO, "Invalid Object Type %X", Type));
3933446Smrj return_UINT32 (ACPI_NS_NORMAL);
3943446Smrj }
3953446Smrj
3963446Smrj return_UINT32 ((UINT32) AcpiGbl_NsProperties[Type] & ACPI_NS_LOCAL);
3973446Smrj }
3983446Smrj
3993446Smrj
4003446Smrj /*******************************************************************************
4013446Smrj *
4023446Smrj * FUNCTION: AcpiNsGetInternalNameLength
4033446Smrj *
4043446Smrj * PARAMETERS: Info - Info struct initialized with the
4053446Smrj * external name pointer.
4063446Smrj *
4073446Smrj * RETURN: None
4083446Smrj *
4093446Smrj * DESCRIPTION: Calculate the length of the internal (AML) namestring
4103446Smrj * corresponding to the external (ASL) namestring.
4113446Smrj *
4123446Smrj ******************************************************************************/
4133446Smrj
4143446Smrj void
AcpiNsGetInternalNameLength(ACPI_NAMESTRING_INFO * Info)4153446Smrj AcpiNsGetInternalNameLength (
4163446Smrj ACPI_NAMESTRING_INFO *Info)
4173446Smrj {
4187851SDana.Myers@Sun.COM const char *NextExternalChar;
4193446Smrj UINT32 i;
4203446Smrj
4213446Smrj
4223446Smrj ACPI_FUNCTION_ENTRY ();
4233446Smrj
4243446Smrj
4253446Smrj NextExternalChar = Info->ExternalName;
4263446Smrj Info->NumCarats = 0;
4273446Smrj Info->NumSegments = 0;
4283446Smrj Info->FullyQualified = FALSE;
4293446Smrj
4303446Smrj /*
4313446Smrj * For the internal name, the required length is 4 bytes per segment, plus
4323446Smrj * 1 each for RootPrefix, MultiNamePrefixOp, segment count, trailing null
4333446Smrj * (which is not really needed, but no there's harm in putting it there)
4343446Smrj *
4353446Smrj * strlen() + 1 covers the first NameSeg, which has no path separator
4363446Smrj */
4379980SDana.Myers@Sun.COM if (AcpiNsValidRootPrefix (*NextExternalChar))
4383446Smrj {
4393446Smrj Info->FullyQualified = TRUE;
4403446Smrj NextExternalChar++;
4419980SDana.Myers@Sun.COM
4429980SDana.Myers@Sun.COM /* Skip redundant RootPrefix, like \\_SB.PCI0.SBRG.EC0 */
4439980SDana.Myers@Sun.COM
4449980SDana.Myers@Sun.COM while (AcpiNsValidRootPrefix (*NextExternalChar))
4459980SDana.Myers@Sun.COM {
4469980SDana.Myers@Sun.COM NextExternalChar++;
4479980SDana.Myers@Sun.COM }
4483446Smrj }
4493446Smrj else
4503446Smrj {
4519980SDana.Myers@Sun.COM /* Handle Carat prefixes */
4529980SDana.Myers@Sun.COM
4533446Smrj while (*NextExternalChar == '^')
4543446Smrj {
4553446Smrj Info->NumCarats++;
4563446Smrj NextExternalChar++;
4573446Smrj }
4583446Smrj }
4593446Smrj
4603446Smrj /*
4613446Smrj * Determine the number of ACPI name "segments" by counting the number of
4623446Smrj * path separators within the string. Start with one segment since the
4633446Smrj * segment count is [(# separators) + 1], and zero separators is ok.
4643446Smrj */
4653446Smrj if (*NextExternalChar)
4663446Smrj {
4673446Smrj Info->NumSegments = 1;
4683446Smrj for (i = 0; NextExternalChar[i]; i++)
4693446Smrj {
4703446Smrj if (AcpiNsValidPathSeparator (NextExternalChar[i]))
4713446Smrj {
4723446Smrj Info->NumSegments++;
4733446Smrj }
4743446Smrj }
4753446Smrj }
4763446Smrj
4773446Smrj Info->Length = (ACPI_NAME_SIZE * Info->NumSegments) +
4783446Smrj 4 + Info->NumCarats;
4793446Smrj
4803446Smrj Info->NextExternalChar = NextExternalChar;
4813446Smrj }
4823446Smrj
4833446Smrj
4843446Smrj /*******************************************************************************
4853446Smrj *
4863446Smrj * FUNCTION: AcpiNsBuildInternalName
4873446Smrj *
4883446Smrj * PARAMETERS: Info - Info struct fully initialized
4893446Smrj *
4903446Smrj * RETURN: Status
4913446Smrj *
4923446Smrj * DESCRIPTION: Construct the internal (AML) namestring
4933446Smrj * corresponding to the external (ASL) namestring.
4943446Smrj *
4953446Smrj ******************************************************************************/
4963446Smrj
4973446Smrj ACPI_STATUS
AcpiNsBuildInternalName(ACPI_NAMESTRING_INFO * Info)4983446Smrj AcpiNsBuildInternalName (
4993446Smrj ACPI_NAMESTRING_INFO *Info)
5003446Smrj {
5013446Smrj UINT32 NumSegments = Info->NumSegments;
5023446Smrj char *InternalName = Info->InternalName;
5037851SDana.Myers@Sun.COM const char *ExternalName = Info->NextExternalChar;
5043446Smrj char *Result = NULL;
5057851SDana.Myers@Sun.COM UINT32 i;
5063446Smrj
5073446Smrj
5083446Smrj ACPI_FUNCTION_TRACE (NsBuildInternalName);
5093446Smrj
5103446Smrj
5113446Smrj /* Setup the correct prefixes, counts, and pointers */
5123446Smrj
5133446Smrj if (Info->FullyQualified)
5143446Smrj {
5153446Smrj InternalName[0] = '\\';
5163446Smrj
5173446Smrj if (NumSegments <= 1)
5183446Smrj {
5193446Smrj Result = &InternalName[1];
5203446Smrj }
5213446Smrj else if (NumSegments == 2)
5223446Smrj {
5233446Smrj InternalName[1] = AML_DUAL_NAME_PREFIX;
5243446Smrj Result = &InternalName[2];
5253446Smrj }
5263446Smrj else
5273446Smrj {
5283446Smrj InternalName[1] = AML_MULTI_NAME_PREFIX_OP;
5293446Smrj InternalName[2] = (char) NumSegments;
5303446Smrj Result = &InternalName[3];
5313446Smrj }
5323446Smrj }
5333446Smrj else
5343446Smrj {
5353446Smrj /*
5363446Smrj * Not fully qualified.
5373446Smrj * Handle Carats first, then append the name segments
5383446Smrj */
5393446Smrj i = 0;
5403446Smrj if (Info->NumCarats)
5413446Smrj {
5423446Smrj for (i = 0; i < Info->NumCarats; i++)
5433446Smrj {
5443446Smrj InternalName[i] = '^';
5453446Smrj }
5463446Smrj }
5473446Smrj
5483446Smrj if (NumSegments <= 1)
5493446Smrj {
5503446Smrj Result = &InternalName[i];
5513446Smrj }
5523446Smrj else if (NumSegments == 2)
5533446Smrj {
5543446Smrj InternalName[i] = AML_DUAL_NAME_PREFIX;
5557851SDana.Myers@Sun.COM Result = &InternalName[(ACPI_SIZE) i+1];
5563446Smrj }
5573446Smrj else
5583446Smrj {
5593446Smrj InternalName[i] = AML_MULTI_NAME_PREFIX_OP;
5607851SDana.Myers@Sun.COM InternalName[(ACPI_SIZE) i+1] = (char) NumSegments;
5617851SDana.Myers@Sun.COM Result = &InternalName[(ACPI_SIZE) i+2];
5623446Smrj }
5633446Smrj }
5643446Smrj
5653446Smrj /* Build the name (minus path separators) */
5663446Smrj
5673446Smrj for (; NumSegments; NumSegments--)
5683446Smrj {
5693446Smrj for (i = 0; i < ACPI_NAME_SIZE; i++)
5703446Smrj {
5713446Smrj if (AcpiNsValidPathSeparator (*ExternalName) ||
5723446Smrj (*ExternalName == 0))
5733446Smrj {
5743446Smrj /* Pad the segment with underscore(s) if segment is short */
5753446Smrj
5763446Smrj Result[i] = '_';
5773446Smrj }
5783446Smrj else
5793446Smrj {
5803446Smrj /* Convert the character to uppercase and save it */
5813446Smrj
5823446Smrj Result[i] = (char) ACPI_TOUPPER ((int) *ExternalName);
5833446Smrj ExternalName++;
5843446Smrj }
5853446Smrj }
5863446Smrj
5873446Smrj /* Now we must have a path separator, or the pathname is bad */
5883446Smrj
5893446Smrj if (!AcpiNsValidPathSeparator (*ExternalName) &&
5903446Smrj (*ExternalName != 0))
5913446Smrj {
5923446Smrj return_ACPI_STATUS (AE_BAD_PARAMETER);
5933446Smrj }
5943446Smrj
5953446Smrj /* Move on the next segment */
5963446Smrj
5973446Smrj ExternalName++;
5983446Smrj Result += ACPI_NAME_SIZE;
5993446Smrj }
6003446Smrj
6013446Smrj /* Terminate the string */
6023446Smrj
6033446Smrj *Result = 0;
6043446Smrj
6053446Smrj if (Info->FullyQualified)
6063446Smrj {
6073446Smrj ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Returning [%p] (abs) \"\\%s\"\n",
6083446Smrj InternalName, InternalName));
6093446Smrj }
6103446Smrj else
6113446Smrj {
6123446Smrj ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Returning [%p] (rel) \"%s\"\n",
6133446Smrj InternalName, InternalName));
6143446Smrj }
6153446Smrj
6163446Smrj return_ACPI_STATUS (AE_OK);
6173446Smrj }
6183446Smrj
6193446Smrj
6203446Smrj /*******************************************************************************
6213446Smrj *
6223446Smrj * FUNCTION: AcpiNsInternalizeName
6233446Smrj *
6243446Smrj * PARAMETERS: *ExternalName - External representation of name
6253446Smrj * **Converted Name - Where to return the resulting
6263446Smrj * internal represention of the name
6273446Smrj *
6283446Smrj * RETURN: Status
6293446Smrj *
6303446Smrj * DESCRIPTION: Convert an external representation (e.g. "\_PR_.CPU0")
6313446Smrj * to internal form (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30)
6323446Smrj *
6333446Smrj *******************************************************************************/
6343446Smrj
6353446Smrj ACPI_STATUS
AcpiNsInternalizeName(const char * ExternalName,char ** ConvertedName)6363446Smrj AcpiNsInternalizeName (
6377851SDana.Myers@Sun.COM const char *ExternalName,
6383446Smrj char **ConvertedName)
6393446Smrj {
6403446Smrj char *InternalName;
6413446Smrj ACPI_NAMESTRING_INFO Info;
6423446Smrj ACPI_STATUS Status;
6433446Smrj
6443446Smrj
6453446Smrj ACPI_FUNCTION_TRACE (NsInternalizeName);
6463446Smrj
6473446Smrj
6483446Smrj if ((!ExternalName) ||
6493446Smrj (*ExternalName == 0) ||
6503446Smrj (!ConvertedName))
6513446Smrj {
6523446Smrj return_ACPI_STATUS (AE_BAD_PARAMETER);
6533446Smrj }
6543446Smrj
6553446Smrj /* Get the length of the new internal name */
6563446Smrj
6573446Smrj Info.ExternalName = ExternalName;
6583446Smrj AcpiNsGetInternalNameLength (&Info);
6593446Smrj
6603446Smrj /* We need a segment to store the internal name */
6613446Smrj
6623446Smrj InternalName = ACPI_ALLOCATE_ZEROED (Info.Length);
6633446Smrj if (!InternalName)
6643446Smrj {
6653446Smrj return_ACPI_STATUS (AE_NO_MEMORY);
6663446Smrj }
6673446Smrj
6683446Smrj /* Build the name */
6693446Smrj
6703446Smrj Info.InternalName = InternalName;
6713446Smrj Status = AcpiNsBuildInternalName (&Info);
6723446Smrj if (ACPI_FAILURE (Status))
6733446Smrj {
6743446Smrj ACPI_FREE (InternalName);
6753446Smrj return_ACPI_STATUS (Status);
6763446Smrj }
6773446Smrj
6783446Smrj *ConvertedName = InternalName;
6793446Smrj return_ACPI_STATUS (AE_OK);
6803446Smrj }
6813446Smrj
6823446Smrj
6833446Smrj /*******************************************************************************
6843446Smrj *
6853446Smrj * FUNCTION: AcpiNsExternalizeName
6863446Smrj *
6873446Smrj * PARAMETERS: InternalNameLength - Lenth of the internal name below
6883446Smrj * InternalName - Internal representation of name
6893446Smrj * ConvertedNameLength - Where the length is returned
6903446Smrj * ConvertedName - Where the resulting external name
6913446Smrj * is returned
6923446Smrj *
6933446Smrj * RETURN: Status
6943446Smrj *
6953446Smrj * DESCRIPTION: Convert internal name (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30)
6963446Smrj * to its external (printable) form (e.g. "\_PR_.CPU0")
6973446Smrj *
6983446Smrj ******************************************************************************/
6993446Smrj
7003446Smrj ACPI_STATUS
AcpiNsExternalizeName(UINT32 InternalNameLength,const char * InternalName,UINT32 * ConvertedNameLength,char ** ConvertedName)7013446Smrj AcpiNsExternalizeName (
7023446Smrj UINT32 InternalNameLength,
7037851SDana.Myers@Sun.COM const char *InternalName,
7043446Smrj UINT32 *ConvertedNameLength,
7053446Smrj char **ConvertedName)
7063446Smrj {
7077851SDana.Myers@Sun.COM UINT32 NamesIndex = 0;
7087851SDana.Myers@Sun.COM UINT32 NumSegments = 0;
7097851SDana.Myers@Sun.COM UINT32 RequiredLength;
7107851SDana.Myers@Sun.COM UINT32 PrefixLength = 0;
7117851SDana.Myers@Sun.COM UINT32 i = 0;
7127851SDana.Myers@Sun.COM UINT32 j = 0;
7133446Smrj
7143446Smrj
7153446Smrj ACPI_FUNCTION_TRACE (NsExternalizeName);
7163446Smrj
7173446Smrj
7183446Smrj if (!InternalNameLength ||
7193446Smrj !InternalName ||
7203446Smrj !ConvertedName)
7213446Smrj {
7223446Smrj return_ACPI_STATUS (AE_BAD_PARAMETER);
7233446Smrj }
7243446Smrj
7259980SDana.Myers@Sun.COM /* Check for a prefix (one '\' | one or more '^') */
7269980SDana.Myers@Sun.COM
7273446Smrj switch (InternalName[0])
7283446Smrj {
7293446Smrj case '\\':
7303446Smrj PrefixLength = 1;
7313446Smrj break;
7323446Smrj
7333446Smrj case '^':
7343446Smrj for (i = 0; i < InternalNameLength; i++)
7353446Smrj {
7363446Smrj if (InternalName[i] == '^')
7373446Smrj {
7383446Smrj PrefixLength = i + 1;
7393446Smrj }
7403446Smrj else
7413446Smrj {
7423446Smrj break;
7433446Smrj }
7443446Smrj }
7453446Smrj
7463446Smrj if (i == InternalNameLength)
7473446Smrj {
7483446Smrj PrefixLength = i;
7493446Smrj }
7503446Smrj
7513446Smrj break;
7523446Smrj
7533446Smrj default:
7543446Smrj break;
7553446Smrj }
7563446Smrj
7573446Smrj /*
7589980SDana.Myers@Sun.COM * Check for object names. Note that there could be 0-255 of these
7593446Smrj * 4-byte elements.
7603446Smrj */
7613446Smrj if (PrefixLength < InternalNameLength)
7623446Smrj {
7633446Smrj switch (InternalName[PrefixLength])
7643446Smrj {
7653446Smrj case AML_MULTI_NAME_PREFIX_OP:
7663446Smrj
7673446Smrj /* <count> 4-byte names */
7683446Smrj
7693446Smrj NamesIndex = PrefixLength + 2;
7707851SDana.Myers@Sun.COM NumSegments = (UINT8)
7717851SDana.Myers@Sun.COM InternalName[(ACPI_SIZE) PrefixLength + 1];
7723446Smrj break;
7733446Smrj
7743446Smrj case AML_DUAL_NAME_PREFIX:
7753446Smrj
7763446Smrj /* Two 4-byte names */
7773446Smrj
7783446Smrj NamesIndex = PrefixLength + 1;
7793446Smrj NumSegments = 2;
7803446Smrj break;
7813446Smrj
7823446Smrj case 0:
7833446Smrj
7843446Smrj /* NullName */
7853446Smrj
7863446Smrj NamesIndex = 0;
7873446Smrj NumSegments = 0;
7883446Smrj break;
7893446Smrj
7903446Smrj default:
7913446Smrj
7923446Smrj /* one 4-byte name */
7933446Smrj
7943446Smrj NamesIndex = PrefixLength;
7953446Smrj NumSegments = 1;
7963446Smrj break;
7973446Smrj }
7983446Smrj }
7993446Smrj
8003446Smrj /*
8013446Smrj * Calculate the length of ConvertedName, which equals the length
8023446Smrj * of the prefix, length of all object names, length of any required
8033446Smrj * punctuation ('.') between object names, plus the NULL terminator.
8043446Smrj */
8053446Smrj RequiredLength = PrefixLength + (4 * NumSegments) +
8063446Smrj ((NumSegments > 0) ? (NumSegments - 1) : 0) + 1;
8073446Smrj
8083446Smrj /*
8093446Smrj * Check to see if we're still in bounds. If not, there's a problem
8103446Smrj * with InternalName (invalid format).
8113446Smrj */
8123446Smrj if (RequiredLength > InternalNameLength)
8133446Smrj {
8143446Smrj ACPI_ERROR ((AE_INFO, "Invalid internal name"));
8153446Smrj return_ACPI_STATUS (AE_BAD_PATHNAME);
8163446Smrj }
8173446Smrj
8189980SDana.Myers@Sun.COM /* Build the ConvertedName */
8199980SDana.Myers@Sun.COM
8203446Smrj *ConvertedName = ACPI_ALLOCATE_ZEROED (RequiredLength);
8213446Smrj if (!(*ConvertedName))
8223446Smrj {
8233446Smrj return_ACPI_STATUS (AE_NO_MEMORY);
8243446Smrj }
8253446Smrj
8263446Smrj j = 0;
8273446Smrj
8283446Smrj for (i = 0; i < PrefixLength; i++)
8293446Smrj {
8303446Smrj (*ConvertedName)[j++] = InternalName[i];
8313446Smrj }
8323446Smrj
8333446Smrj if (NumSegments > 0)
8343446Smrj {
8353446Smrj for (i = 0; i < NumSegments; i++)
8363446Smrj {
8373446Smrj if (i > 0)
8383446Smrj {
8393446Smrj (*ConvertedName)[j++] = '.';
8403446Smrj }
8413446Smrj
8423446Smrj (*ConvertedName)[j++] = InternalName[NamesIndex++];
8433446Smrj (*ConvertedName)[j++] = InternalName[NamesIndex++];
8443446Smrj (*ConvertedName)[j++] = InternalName[NamesIndex++];
8453446Smrj (*ConvertedName)[j++] = InternalName[NamesIndex++];
8463446Smrj }
8473446Smrj }
8483446Smrj
8493446Smrj if (ConvertedNameLength)
8503446Smrj {
8513446Smrj *ConvertedNameLength = (UINT32) RequiredLength;
8523446Smrj }
8533446Smrj
8543446Smrj return_ACPI_STATUS (AE_OK);
8553446Smrj }
8563446Smrj
8573446Smrj
8583446Smrj /*******************************************************************************
8593446Smrj *
8603446Smrj * FUNCTION: AcpiNsMapHandleToNode
8613446Smrj *
8623446Smrj * PARAMETERS: Handle - Handle to be converted to an Node
8633446Smrj *
8643446Smrj * RETURN: A Name table entry pointer
8653446Smrj *
8663446Smrj * DESCRIPTION: Convert a namespace handle to a real Node
8673446Smrj *
8683446Smrj * Note: Real integer handles would allow for more verification
8693446Smrj * and keep all pointers within this subsystem - however this introduces
8703446Smrj * more (and perhaps unnecessary) overhead.
8713446Smrj *
8729980SDana.Myers@Sun.COM * The current implemenation is basically a placeholder until such time comes
8739980SDana.Myers@Sun.COM * that it is needed.
8749980SDana.Myers@Sun.COM *
8753446Smrj ******************************************************************************/
8763446Smrj
8773446Smrj ACPI_NAMESPACE_NODE *
AcpiNsMapHandleToNode(ACPI_HANDLE Handle)8783446Smrj AcpiNsMapHandleToNode (
8793446Smrj ACPI_HANDLE Handle)
8803446Smrj {
8813446Smrj
8823446Smrj ACPI_FUNCTION_ENTRY ();
8833446Smrj
8843446Smrj
8859980SDana.Myers@Sun.COM /* Parameter validation */
8869980SDana.Myers@Sun.COM
8873446Smrj if ((!Handle) || (Handle == ACPI_ROOT_OBJECT))
8883446Smrj {
8893446Smrj return (AcpiGbl_RootNode);
8903446Smrj }
8913446Smrj
8923446Smrj /* We can at least attempt to verify the handle */
8933446Smrj
8943446Smrj if (ACPI_GET_DESCRIPTOR_TYPE (Handle) != ACPI_DESC_TYPE_NAMED)
8953446Smrj {
8963446Smrj return (NULL);
8973446Smrj }
8983446Smrj
8993446Smrj return (ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Handle));
9003446Smrj }
9013446Smrj
9023446Smrj
9033446Smrj /*******************************************************************************
9043446Smrj *
9053446Smrj * FUNCTION: AcpiNsConvertEntryToHandle
9063446Smrj *
9073446Smrj * PARAMETERS: Node - Node to be converted to a Handle
9083446Smrj *
9093446Smrj * RETURN: A user handle
9103446Smrj *
9113446Smrj * DESCRIPTION: Convert a real Node to a namespace handle
9123446Smrj *
9133446Smrj ******************************************************************************/
9143446Smrj
9153446Smrj ACPI_HANDLE
AcpiNsConvertEntryToHandle(ACPI_NAMESPACE_NODE * Node)9163446Smrj AcpiNsConvertEntryToHandle (
9173446Smrj ACPI_NAMESPACE_NODE *Node)
9183446Smrj {
9193446Smrj
9203446Smrj
9213446Smrj /*
9223446Smrj * Simple implementation for now;
9233446Smrj */
9243446Smrj return ((ACPI_HANDLE) Node);
9253446Smrj
9263446Smrj
9273446Smrj /* Example future implementation ---------------------
9283446Smrj
9293446Smrj if (!Node)
9303446Smrj {
9313446Smrj return (NULL);
9323446Smrj }
9333446Smrj
9343446Smrj if (Node == AcpiGbl_RootNode)
9353446Smrj {
9363446Smrj return (ACPI_ROOT_OBJECT);
9373446Smrj }
9383446Smrj
9393446Smrj
9403446Smrj return ((ACPI_HANDLE) Node);
9413446Smrj ------------------------------------------------------*/
9423446Smrj }
9433446Smrj
9443446Smrj
9453446Smrj /*******************************************************************************
9463446Smrj *
9473446Smrj * FUNCTION: AcpiNsTerminate
9483446Smrj *
9493446Smrj * PARAMETERS: none
9503446Smrj *
9513446Smrj * RETURN: none
9523446Smrj *
9533446Smrj * DESCRIPTION: free memory allocated for namespace and ACPI table storage.
9543446Smrj *
9553446Smrj ******************************************************************************/
9563446Smrj
9573446Smrj void
AcpiNsTerminate(void)9583446Smrj AcpiNsTerminate (
9593446Smrj void)
9603446Smrj {
9613446Smrj ACPI_OPERAND_OBJECT *ObjDesc;
9623446Smrj
9633446Smrj
9643446Smrj ACPI_FUNCTION_TRACE (NsTerminate);
9653446Smrj
9663446Smrj
9673446Smrj /*
9683446Smrj * 1) Free the entire namespace -- all nodes and objects
9693446Smrj *
9703446Smrj * Delete all object descriptors attached to namepsace nodes
9713446Smrj */
9723446Smrj AcpiNsDeleteNamespaceSubtree (AcpiGbl_RootNode);
9733446Smrj
9743446Smrj /* Detach any objects attached to the root */
9753446Smrj
9763446Smrj ObjDesc = AcpiNsGetAttachedObject (AcpiGbl_RootNode);
9773446Smrj if (ObjDesc)
9783446Smrj {
9793446Smrj AcpiNsDetachObject (AcpiGbl_RootNode);
9803446Smrj }
9813446Smrj
9823446Smrj ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace freed\n"));
9833446Smrj return_VOID;
9843446Smrj }
9853446Smrj
9863446Smrj
9873446Smrj /*******************************************************************************
9883446Smrj *
9893446Smrj * FUNCTION: AcpiNsOpensScope
9903446Smrj *
9913446Smrj * PARAMETERS: Type - A valid namespace type
9923446Smrj *
9933446Smrj * RETURN: NEWSCOPE if the passed type "opens a name scope" according
9943446Smrj * to the ACPI specification, else 0
9953446Smrj *
9963446Smrj ******************************************************************************/
9973446Smrj
9983446Smrj UINT32
AcpiNsOpensScope(ACPI_OBJECT_TYPE Type)9993446Smrj AcpiNsOpensScope (
10003446Smrj ACPI_OBJECT_TYPE Type)
10013446Smrj {
10023446Smrj ACPI_FUNCTION_TRACE_STR (NsOpensScope, AcpiUtGetTypeName (Type));
10033446Smrj
10043446Smrj
10053446Smrj if (!AcpiUtValidObjectType (Type))
10063446Smrj {
10073446Smrj /* type code out of range */
10083446Smrj
10093446Smrj ACPI_WARNING ((AE_INFO, "Invalid Object Type %X", Type));
10103446Smrj return_UINT32 (ACPI_NS_NORMAL);
10113446Smrj }
10123446Smrj
10133446Smrj return_UINT32 (((UINT32) AcpiGbl_NsProperties[Type]) & ACPI_NS_NEWSCOPE);
10143446Smrj }
10153446Smrj
10163446Smrj
10173446Smrj /*******************************************************************************
10183446Smrj *
10193446Smrj * FUNCTION: AcpiNsGetNode
10203446Smrj *
10213446Smrj * PARAMETERS: *Pathname - Name to be found, in external (ASL) format. The
10223446Smrj * \ (backslash) and ^ (carat) prefixes, and the
10233446Smrj * . (period) to separate segments are supported.
10243446Smrj * PrefixNode - Root of subtree to be searched, or NS_ALL for the
10253446Smrj * root of the name space. If Name is fully
10263446Smrj * qualified (first INT8 is '\'), the passed value
10273446Smrj * of Scope will not be accessed.
10283446Smrj * Flags - Used to indicate whether to perform upsearch or
10293446Smrj * not.
10303446Smrj * ReturnNode - Where the Node is returned
10313446Smrj *
10323446Smrj * DESCRIPTION: Look up a name relative to a given scope and return the
10333446Smrj * corresponding Node. NOTE: Scope can be null.
10343446Smrj *
10353446Smrj * MUTEX: Locks namespace
10363446Smrj *
10373446Smrj ******************************************************************************/
10383446Smrj
10393446Smrj ACPI_STATUS
AcpiNsGetNode(ACPI_NAMESPACE_NODE * PrefixNode,const char * Pathname,UINT32 Flags,ACPI_NAMESPACE_NODE ** ReturnNode)10403446Smrj AcpiNsGetNode (
10413446Smrj ACPI_NAMESPACE_NODE *PrefixNode,
10427851SDana.Myers@Sun.COM const char *Pathname,
10433446Smrj UINT32 Flags,
10443446Smrj ACPI_NAMESPACE_NODE **ReturnNode)
10453446Smrj {
10463446Smrj ACPI_GENERIC_STATE ScopeInfo;
10473446Smrj ACPI_STATUS Status;
10483446Smrj char *InternalPath;
10493446Smrj
10503446Smrj
1051*11225SDana.Myers@Sun.COM ACPI_FUNCTION_TRACE_PTR (NsGetNode, ACPI_CAST_PTR (char, Pathname));
10523446Smrj
10533446Smrj
10543446Smrj if (!Pathname)
10553446Smrj {
10563446Smrj *ReturnNode = PrefixNode;
10573446Smrj if (!PrefixNode)
10583446Smrj {
10593446Smrj *ReturnNode = AcpiGbl_RootNode;
10603446Smrj }
10613446Smrj return_ACPI_STATUS (AE_OK);
10623446Smrj }
10633446Smrj
10643446Smrj /* Convert path to internal representation */
10653446Smrj
10663446Smrj Status = AcpiNsInternalizeName (Pathname, &InternalPath);
10673446Smrj if (ACPI_FAILURE (Status))
10683446Smrj {
10693446Smrj return_ACPI_STATUS (Status);
10703446Smrj }
10713446Smrj
10723446Smrj /* Must lock namespace during lookup */
10733446Smrj
10743446Smrj Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
10753446Smrj if (ACPI_FAILURE (Status))
10763446Smrj {
10773446Smrj goto Cleanup;
10783446Smrj }
10793446Smrj
10803446Smrj /* Setup lookup scope (search starting point) */
10813446Smrj
10823446Smrj ScopeInfo.Scope.Node = PrefixNode;
10833446Smrj
10843446Smrj /* Lookup the name in the namespace */
10853446Smrj
10863446Smrj Status = AcpiNsLookup (&ScopeInfo, InternalPath, ACPI_TYPE_ANY,
10873446Smrj ACPI_IMODE_EXECUTE, (Flags | ACPI_NS_DONT_OPEN_SCOPE),
10883446Smrj NULL, ReturnNode);
10893446Smrj if (ACPI_FAILURE (Status))
10903446Smrj {
10919980SDana.Myers@Sun.COM ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s, %s\n",
10923446Smrj Pathname, AcpiFormatException (Status)));
10933446Smrj }
10943446Smrj
10953446Smrj (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
10963446Smrj
10973446Smrj Cleanup:
10983446Smrj ACPI_FREE (InternalPath);
10993446Smrj return_ACPI_STATUS (Status);
11003446Smrj }
11013446Smrj
11023446Smrj
11033446Smrj /*******************************************************************************
11043446Smrj *
11053446Smrj * FUNCTION: AcpiNsGetParentNode
11063446Smrj *
11073446Smrj * PARAMETERS: Node - Current table entry
11083446Smrj *
11093446Smrj * RETURN: Parent entry of the given entry
11103446Smrj *
11113446Smrj * DESCRIPTION: Obtain the parent entry for a given entry in the namespace.
11123446Smrj *
11133446Smrj ******************************************************************************/
11143446Smrj
11153446Smrj ACPI_NAMESPACE_NODE *
AcpiNsGetParentNode(ACPI_NAMESPACE_NODE * Node)11163446Smrj AcpiNsGetParentNode (
11173446Smrj ACPI_NAMESPACE_NODE *Node)
11183446Smrj {
11193446Smrj ACPI_FUNCTION_ENTRY ();
11203446Smrj
11213446Smrj
11223446Smrj if (!Node)
11233446Smrj {
11243446Smrj return (NULL);
11253446Smrj }
11263446Smrj
11273446Smrj /*
11283446Smrj * Walk to the end of this peer list. The last entry is marked with a flag
11293446Smrj * and the peer pointer is really a pointer back to the parent. This saves
11303446Smrj * putting a parent back pointer in each and every named object!
11313446Smrj */
11323446Smrj while (!(Node->Flags & ANOBJ_END_OF_PEER_LIST))
11333446Smrj {
11343446Smrj Node = Node->Peer;
11353446Smrj }
11363446Smrj
11373446Smrj return (Node->Peer);
11383446Smrj }
11393446Smrj
11403446Smrj
11413446Smrj /*******************************************************************************
11423446Smrj *
11433446Smrj * FUNCTION: AcpiNsGetNextValidNode
11443446Smrj *
11453446Smrj * PARAMETERS: Node - Current table entry
11463446Smrj *
11473446Smrj * RETURN: Next valid Node in the linked node list. NULL if no more valid
11483446Smrj * nodes.
11493446Smrj *
11503446Smrj * DESCRIPTION: Find the next valid node within a name table.
11513446Smrj * Useful for implementing NULL-end-of-list loops.
11523446Smrj *
11533446Smrj ******************************************************************************/
11543446Smrj
11553446Smrj ACPI_NAMESPACE_NODE *
AcpiNsGetNextValidNode(ACPI_NAMESPACE_NODE * Node)11563446Smrj AcpiNsGetNextValidNode (
11573446Smrj ACPI_NAMESPACE_NODE *Node)
11583446Smrj {
11593446Smrj
11603446Smrj /* If we are at the end of this peer list, return NULL */
11613446Smrj
11623446Smrj if (Node->Flags & ANOBJ_END_OF_PEER_LIST)
11633446Smrj {
11643446Smrj return NULL;
11653446Smrj }
11663446Smrj
11673446Smrj /* Otherwise just return the next peer */
11683446Smrj
11693446Smrj return (Node->Peer);
11703446Smrj }
11713446Smrj
11723446Smrj
11733446Smrj #ifdef ACPI_OBSOLETE_FUNCTIONS
11743446Smrj /*******************************************************************************
11753446Smrj *
11763446Smrj * FUNCTION: AcpiNsFindParentName
11773446Smrj *
11783446Smrj * PARAMETERS: *ChildNode - Named Obj whose name is to be found
11793446Smrj *
11803446Smrj * RETURN: The ACPI name
11813446Smrj *
11823446Smrj * DESCRIPTION: Search for the given obj in its parent scope and return the
11833446Smrj * name segment, or "????" if the parent name can't be found
11843446Smrj * (which "should not happen").
11853446Smrj *
11863446Smrj ******************************************************************************/
11873446Smrj
11883446Smrj ACPI_NAME
AcpiNsFindParentName(ACPI_NAMESPACE_NODE * ChildNode)11893446Smrj AcpiNsFindParentName (
11903446Smrj ACPI_NAMESPACE_NODE *ChildNode)
11913446Smrj {
11923446Smrj ACPI_NAMESPACE_NODE *ParentNode;
11933446Smrj
11943446Smrj
11953446Smrj ACPI_FUNCTION_TRACE (NsFindParentName);
11963446Smrj
11973446Smrj
11983446Smrj if (ChildNode)
11993446Smrj {
12003446Smrj /* Valid entry. Get the parent Node */
12013446Smrj
12023446Smrj ParentNode = AcpiNsGetParentNode (ChildNode);
12033446Smrj if (ParentNode)
12043446Smrj {
12053446Smrj ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
12063446Smrj "Parent of %p [%4.4s] is %p [%4.4s]\n",
12073446Smrj ChildNode, AcpiUtGetNodeName (ChildNode),
12083446Smrj ParentNode, AcpiUtGetNodeName (ParentNode)));
12093446Smrj
12103446Smrj if (ParentNode->Name.Integer)
12113446Smrj {
12123446Smrj return_VALUE ((ACPI_NAME) ParentNode->Name.Integer);
12133446Smrj }
12143446Smrj }
12153446Smrj
12163446Smrj ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
12173446Smrj "Unable to find parent of %p (%4.4s)\n",
12183446Smrj ChildNode, AcpiUtGetNodeName (ChildNode)));
12193446Smrj }
12203446Smrj
12213446Smrj return_VALUE (ACPI_UNKNOWN_NAME);
12223446Smrj }
12233446Smrj #endif
12243446Smrj
12253446Smrj
1226