Path: blob/main/sys/contrib/dev/acpica/components/namespace/nsutils.c
48524 views
/******************************************************************************1*2* Module Name: nsutils - Utilities for accessing ACPI namespace, accessing3* parents and siblings and Scope manipulation4*5*****************************************************************************/67/******************************************************************************8*9* 1. Copyright Notice10*11* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.12* All rights reserved.13*14* 2. License15*16* 2.1. This is your license from Intel Corp. under its intellectual property17* rights. You may have additional license terms from the party that provided18* you this software, covering your right to use that party's intellectual19* property rights.20*21* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a22* copy of the source code appearing in this file ("Covered Code") an23* irrevocable, perpetual, worldwide license under Intel's copyrights in the24* base code distributed originally by Intel ("Original Intel Code") to copy,25* make derivatives, distribute, use and display any portion of the Covered26* Code in any form, with the right to sublicense such rights; and27*28* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent29* license (with the right to sublicense), under only those claims of Intel30* patents that are infringed by the Original Intel Code, to make, use, sell,31* offer to sell, and import the Covered Code and derivative works thereof32* solely to the minimum extent necessary to exercise the above copyright33* license, and in no event shall the patent license extend to any additions34* to or modifications of the Original Intel Code. No other license or right35* is granted directly or by implication, estoppel or otherwise;36*37* The above copyright and patent license is granted only if the following38* conditions are met:39*40* 3. Conditions41*42* 3.1. Redistribution of Source with Rights to Further Distribute Source.43* Redistribution of source code of any substantial portion of the Covered44* Code or modification with rights to further distribute source must include45* the above Copyright Notice, the above License, this list of Conditions,46* and the following Disclaimer and Export Compliance provision. In addition,47* Licensee must cause all Covered Code to which Licensee contributes to48* contain a file documenting the changes Licensee made to create that Covered49* Code and the date of any change. Licensee must include in that file the50* documentation of any changes made by any predecessor Licensee. Licensee51* must include a prominent statement that the modification is derived,52* directly or indirectly, from Original Intel Code.53*54* 3.2. Redistribution of Source with no Rights to Further Distribute Source.55* Redistribution of source code of any substantial portion of the Covered56* Code or modification without rights to further distribute source must57* include the following Disclaimer and Export Compliance provision in the58* documentation and/or other materials provided with distribution. In59* addition, Licensee may not authorize further sublicense of source of any60* portion of the Covered Code, and must include terms to the effect that the61* license from Licensee to its licensee is limited to the intellectual62* property embodied in the software Licensee provides to its licensee, and63* not to intellectual property embodied in modifications its licensee may64* make.65*66* 3.3. Redistribution of Executable. Redistribution in executable form of any67* substantial portion of the Covered Code or modification must reproduce the68* above Copyright Notice, and the following Disclaimer and Export Compliance69* provision in the documentation and/or other materials provided with the70* distribution.71*72* 3.4. Intel retains all right, title, and interest in and to the Original73* Intel Code.74*75* 3.5. Neither the name Intel nor any other trademark owned or controlled by76* Intel shall be used in advertising or otherwise to promote the sale, use or77* other dealings in products derived from or relating to the Covered Code78* without prior written authorization from Intel.79*80* 4. Disclaimer and Export Compliance81*82* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED83* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE84* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,85* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY86* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY87* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A88* PARTICULAR PURPOSE.89*90* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES91* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR92* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,93* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY94* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL95* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS96* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY97* LIMITED REMEDY.98*99* 4.3. Licensee shall not export, either directly or indirectly, any of this100* software or system incorporating such software without first obtaining any101* required license or other approval from the U. S. Department of Commerce or102* any other agency or department of the United States Government. In the103* event Licensee exports any such software from the United States or104* re-exports any such software from a foreign destination, Licensee shall105* ensure that the distribution and export/re-export of the software is in106* compliance with all laws, regulations, orders, or other restrictions of the107* U.S. Export Administration Regulations. Licensee agrees that neither it nor108* any of its subsidiaries will export/re-export any technical data, process,109* software, or service, directly or indirectly, to any country for which the110* United States government or any agency thereof requires an export license,111* other governmental approval, or letter of assurance, without first obtaining112* such license, approval or letter.113*114*****************************************************************************115*116* Alternatively, you may choose to be licensed under the terms of the117* following license:118*119* Redistribution and use in source and binary forms, with or without120* modification, are permitted provided that the following conditions121* are met:122* 1. Redistributions of source code must retain the above copyright123* notice, this list of conditions, and the following disclaimer,124* without modification.125* 2. Redistributions in binary form must reproduce at minimum a disclaimer126* substantially similar to the "NO WARRANTY" disclaimer below127* ("Disclaimer") and any redistribution must be conditioned upon128* including a substantially similar Disclaimer requirement for further129* binary redistribution.130* 3. Neither the names of the above-listed copyright holders nor the names131* of any contributors may be used to endorse or promote products derived132* from this software without specific prior written permission.133*134* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS135* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT136* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR137* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT138* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,139* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT140* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,141* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY142* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT143* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE144* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.145*146* Alternatively, you may choose to be licensed under the terms of the147* GNU General Public License ("GPL") version 2 as published by the Free148* Software Foundation.149*150*****************************************************************************/151152#include <contrib/dev/acpica/include/acpi.h>153#include <contrib/dev/acpica/include/accommon.h>154#include <contrib/dev/acpica/include/acnamesp.h>155#include <contrib/dev/acpica/include/amlcode.h>156157#define _COMPONENT ACPI_NAMESPACE158ACPI_MODULE_NAME ("nsutils")159160/* Local prototypes */161162#ifdef ACPI_OBSOLETE_FUNCTIONS163ACPI_NAME164AcpiNsFindParentName (165ACPI_NAMESPACE_NODE *NodeToSearch);166#endif167168169/*******************************************************************************170*171* FUNCTION: AcpiNsPrintNodePathname172*173* PARAMETERS: Node - Object174* Message - Prefix message175*176* DESCRIPTION: Print an object's full namespace pathname177* Manages allocation/freeing of a pathname buffer178*179******************************************************************************/180181void182AcpiNsPrintNodePathname (183ACPI_NAMESPACE_NODE *Node,184const char *Message)185{186ACPI_BUFFER Buffer;187ACPI_STATUS Status;188189190if (!Node)191{192AcpiOsPrintf ("[NULL NAME]");193return;194}195196/* Convert handle to full pathname and print it (with supplied message) */197198Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;199200Status = AcpiNsHandleToPathname (Node, &Buffer, TRUE);201if (ACPI_SUCCESS (Status))202{203if (Message)204{205AcpiOsPrintf ("%s ", Message);206}207208AcpiOsPrintf ("%s", (char *) Buffer.Pointer);209ACPI_FREE (Buffer.Pointer);210}211}212213214/*******************************************************************************215*216* FUNCTION: AcpiNsGetType217*218* PARAMETERS: Node - Parent Node to be examined219*220* RETURN: Type field from Node whose handle is passed221*222* DESCRIPTION: Return the type of a Namespace node223*224******************************************************************************/225226ACPI_OBJECT_TYPE227AcpiNsGetType (228ACPI_NAMESPACE_NODE *Node)229{230ACPI_FUNCTION_TRACE (NsGetType);231232233if (!Node)234{235ACPI_WARNING ((AE_INFO, "Null Node parameter"));236return_UINT8 (ACPI_TYPE_ANY);237}238239return_UINT8 (Node->Type);240}241242243/*******************************************************************************244*245* FUNCTION: AcpiNsLocal246*247* PARAMETERS: Type - A namespace object type248*249* RETURN: LOCAL if names must be found locally in objects of the250* passed type, 0 if enclosing scopes should be searched251*252* DESCRIPTION: Returns scope rule for the given object type.253*254******************************************************************************/255256UINT32257AcpiNsLocal (258ACPI_OBJECT_TYPE Type)259{260ACPI_FUNCTION_TRACE (NsLocal);261262263if (!AcpiUtValidObjectType (Type))264{265/* Type code out of range */266267ACPI_WARNING ((AE_INFO, "Invalid Object Type 0x%X", Type));268return_UINT32 (ACPI_NS_NORMAL);269}270271return_UINT32 (AcpiGbl_NsProperties[Type] & ACPI_NS_LOCAL);272}273274275/*******************************************************************************276*277* FUNCTION: AcpiNsGetInternalNameLength278*279* PARAMETERS: Info - Info struct initialized with the280* external name pointer.281*282* RETURN: None283*284* DESCRIPTION: Calculate the length of the internal (AML) namestring285* corresponding to the external (ASL) namestring.286*287******************************************************************************/288289void290AcpiNsGetInternalNameLength (291ACPI_NAMESTRING_INFO *Info)292{293const char *NextExternalChar;294UINT32 i;295296297ACPI_FUNCTION_ENTRY ();298299300NextExternalChar = Info->ExternalName;301Info->NumCarats = 0;302Info->NumSegments = 0;303Info->FullyQualified = FALSE;304305/*306* For the internal name, the required length is 4 bytes per segment,307* plus 1 each for RootPrefix, MultiNamePrefixOp, segment count,308* trailing null (which is not really needed, but no there's harm in309* putting it there)310*311* strlen() + 1 covers the first NameSeg, which has no path separator312*/313if (ACPI_IS_ROOT_PREFIX (*NextExternalChar))314{315Info->FullyQualified = TRUE;316NextExternalChar++;317318/* Skip redundant RootPrefix, like \\_SB.PCI0.SBRG.EC0 */319320while (ACPI_IS_ROOT_PREFIX (*NextExternalChar))321{322NextExternalChar++;323}324}325else326{327/* Handle Carat prefixes */328329while (ACPI_IS_PARENT_PREFIX (*NextExternalChar))330{331Info->NumCarats++;332NextExternalChar++;333}334}335336/*337* Determine the number of ACPI name "segments" by counting the number of338* path separators within the string. Start with one segment since the339* segment count is [(# separators) + 1], and zero separators is ok.340*/341if (*NextExternalChar)342{343Info->NumSegments = 1;344for (i = 0; NextExternalChar[i]; i++)345{346if (ACPI_IS_PATH_SEPARATOR (NextExternalChar[i]))347{348Info->NumSegments++;349}350}351}352353Info->Length = (ACPI_NAMESEG_SIZE * Info->NumSegments) +3544 + Info->NumCarats;355356Info->NextExternalChar = NextExternalChar;357}358359360/*******************************************************************************361*362* FUNCTION: AcpiNsBuildInternalName363*364* PARAMETERS: Info - Info struct fully initialized365*366* RETURN: Status367*368* DESCRIPTION: Construct the internal (AML) namestring369* corresponding to the external (ASL) namestring.370*371******************************************************************************/372373ACPI_STATUS374AcpiNsBuildInternalName (375ACPI_NAMESTRING_INFO *Info)376{377UINT32 NumSegments = Info->NumSegments;378char *InternalName = Info->InternalName;379const char *ExternalName = Info->NextExternalChar;380char *Result = NULL;381UINT32 i;382383384ACPI_FUNCTION_TRACE (NsBuildInternalName);385386387/* Setup the correct prefixes, counts, and pointers */388389if (Info->FullyQualified)390{391InternalName[0] = AML_ROOT_PREFIX;392393if (NumSegments <= 1)394{395Result = &InternalName[1];396}397else if (NumSegments == 2)398{399InternalName[1] = AML_DUAL_NAME_PREFIX;400Result = &InternalName[2];401}402else403{404InternalName[1] = AML_MULTI_NAME_PREFIX;405InternalName[2] = (char) NumSegments;406Result = &InternalName[3];407}408}409else410{411/*412* Not fully qualified.413* Handle Carats first, then append the name segments414*/415i = 0;416if (Info->NumCarats)417{418for (i = 0; i < Info->NumCarats; i++)419{420InternalName[i] = AML_PARENT_PREFIX;421}422}423424if (NumSegments <= 1)425{426Result = &InternalName[i];427}428else if (NumSegments == 2)429{430InternalName[i] = AML_DUAL_NAME_PREFIX;431Result = &InternalName[(ACPI_SIZE) i+1];432}433else434{435InternalName[i] = AML_MULTI_NAME_PREFIX;436InternalName[(ACPI_SIZE) i+1] = (char) NumSegments;437Result = &InternalName[(ACPI_SIZE) i+2];438}439}440441/* Build the name (minus path separators) */442443for (; NumSegments; NumSegments--)444{445for (i = 0; i < ACPI_NAMESEG_SIZE; i++)446{447if (ACPI_IS_PATH_SEPARATOR (*ExternalName) ||448(*ExternalName == 0))449{450/* Pad the segment with underscore(s) if segment is short */451452Result[i] = '_';453}454else455{456/* Convert the character to uppercase and save it */457458Result[i] = (char) toupper ((int) *ExternalName);459ExternalName++;460}461}462463/* Now we must have a path separator, or the pathname is bad */464465if (!ACPI_IS_PATH_SEPARATOR (*ExternalName) &&466(*ExternalName != 0))467{468return_ACPI_STATUS (AE_BAD_PATHNAME);469}470471/* Move on the next segment */472473ExternalName++;474Result += ACPI_NAMESEG_SIZE;475}476477/* Terminate the string */478479*Result = 0;480481if (Info->FullyQualified)482{483ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Returning [%p] (abs) \"\\%s\"\n",484InternalName, InternalName));485}486else487{488ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Returning [%p] (rel) \"%s\"\n",489InternalName, InternalName));490}491492return_ACPI_STATUS (AE_OK);493}494495496/*******************************************************************************497*498* FUNCTION: AcpiNsInternalizeName499*500* PARAMETERS: *ExternalName - External representation of name501* **Converted Name - Where to return the resulting502* internal representation of the name503*504* RETURN: Status505*506* DESCRIPTION: Convert an external representation (e.g. "\_PR_.CPU0")507* to internal form (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30)508*509*******************************************************************************/510511ACPI_STATUS512AcpiNsInternalizeName (513const char *ExternalName,514char **ConvertedName)515{516char *InternalName;517ACPI_NAMESTRING_INFO Info;518ACPI_STATUS Status;519520521ACPI_FUNCTION_TRACE (NsInternalizeName);522523524if ((!ExternalName) ||525(*ExternalName == 0) ||526(!ConvertedName))527{528return_ACPI_STATUS (AE_BAD_PARAMETER);529}530531/* Get the length of the new internal name */532533Info.ExternalName = ExternalName;534AcpiNsGetInternalNameLength (&Info);535536/* We need a segment to store the internal name */537538InternalName = ACPI_ALLOCATE_ZEROED (Info.Length);539if (!InternalName)540{541return_ACPI_STATUS (AE_NO_MEMORY);542}543544/* Build the name */545546Info.InternalName = InternalName;547Status = AcpiNsBuildInternalName (&Info);548if (ACPI_FAILURE (Status))549{550ACPI_FREE (InternalName);551return_ACPI_STATUS (Status);552}553554*ConvertedName = InternalName;555return_ACPI_STATUS (AE_OK);556}557558559/*******************************************************************************560*561* FUNCTION: AcpiNsExternalizeName562*563* PARAMETERS: InternalNameLength - Length of the internal name below564* InternalName - Internal representation of name565* ConvertedNameLength - Where the length is returned566* ConvertedName - Where the resulting external name567* is returned568*569* RETURN: Status570*571* DESCRIPTION: Convert internal name (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30)572* to its external (printable) form (e.g. "\_PR_.CPU0")573*574******************************************************************************/575576ACPI_STATUS577AcpiNsExternalizeName (578UINT32 InternalNameLength,579const char *InternalName,580UINT32 *ConvertedNameLength,581char **ConvertedName)582{583UINT32 NamesIndex = 0;584UINT32 NumSegments = 0;585UINT32 RequiredLength;586UINT32 PrefixLength = 0;587UINT32 i = 0;588UINT32 j = 0;589590591ACPI_FUNCTION_TRACE (NsExternalizeName);592593594if (!InternalNameLength ||595!InternalName ||596!ConvertedName)597{598return_ACPI_STATUS (AE_BAD_PARAMETER);599}600601/* Check for a prefix (one '\' | one or more '^') */602603switch (InternalName[0])604{605case AML_ROOT_PREFIX:606607PrefixLength = 1;608break;609610case AML_PARENT_PREFIX:611612for (i = 0; i < InternalNameLength; i++)613{614if (ACPI_IS_PARENT_PREFIX (InternalName[i]))615{616PrefixLength = i + 1;617}618else619{620break;621}622}623624if (i == InternalNameLength)625{626PrefixLength = i;627}628629break;630631default:632633break;634}635636/*637* Check for object names. Note that there could be 0-255 of these638* 4-byte elements.639*/640if (PrefixLength < InternalNameLength)641{642switch (InternalName[PrefixLength])643{644case AML_MULTI_NAME_PREFIX:645646/* <count> 4-byte names */647648NamesIndex = PrefixLength + 2;649NumSegments = (UINT8)650InternalName[(ACPI_SIZE) PrefixLength + 1];651break;652653case AML_DUAL_NAME_PREFIX:654655/* Two 4-byte names */656657NamesIndex = PrefixLength + 1;658NumSegments = 2;659break;660661case 0:662663/* NullName */664665NamesIndex = 0;666NumSegments = 0;667break;668669default:670671/* one 4-byte name */672673NamesIndex = PrefixLength;674NumSegments = 1;675break;676}677}678679/*680* Calculate the length of ConvertedName, which equals the length681* of the prefix, length of all object names, length of any required682* punctuation ('.') between object names, plus the NULL terminator.683*/684RequiredLength = PrefixLength + (4 * NumSegments) +685((NumSegments > 0) ? (NumSegments - 1) : 0) + 1;686687/*688* Check to see if we're still in bounds. If not, there's a problem689* with InternalName (invalid format).690*/691if (RequiredLength > InternalNameLength)692{693ACPI_ERROR ((AE_INFO, "Invalid internal name"));694return_ACPI_STATUS (AE_BAD_PATHNAME);695}696697/* Build the ConvertedName */698699*ConvertedName = ACPI_ALLOCATE_ZEROED (RequiredLength);700if (!(*ConvertedName))701{702return_ACPI_STATUS (AE_NO_MEMORY);703}704705j = 0;706707for (i = 0; i < PrefixLength; i++)708{709(*ConvertedName)[j++] = InternalName[i];710}711712if (NumSegments > 0)713{714for (i = 0; i < NumSegments; i++)715{716if (i > 0)717{718(*ConvertedName)[j++] = '.';719}720721/* Copy and validate the 4-char name segment */722723ACPI_COPY_NAMESEG (&(*ConvertedName)[j],724&InternalName[NamesIndex]);725AcpiUtRepairName (&(*ConvertedName)[j]);726727j += ACPI_NAMESEG_SIZE;728NamesIndex += ACPI_NAMESEG_SIZE;729}730}731732if (ConvertedNameLength)733{734*ConvertedNameLength = (UINT32) RequiredLength;735}736737return_ACPI_STATUS (AE_OK);738}739740741/*******************************************************************************742*743* FUNCTION: AcpiNsValidateHandle744*745* PARAMETERS: Handle - Handle to be validated and typecast to a746* namespace node.747*748* RETURN: A pointer to a namespace node749*750* DESCRIPTION: Convert a namespace handle to a namespace node. Handles special751* cases for the root node.752*753* NOTE: Real integer handles would allow for more verification754* and keep all pointers within this subsystem - however this introduces755* more overhead and has not been necessary to this point. Drivers756* holding handles are typically notified before a node becomes invalid757* due to a table unload.758*759******************************************************************************/760761ACPI_NAMESPACE_NODE *762AcpiNsValidateHandle (763ACPI_HANDLE Handle)764{765766ACPI_FUNCTION_ENTRY ();767768769/* Parameter validation */770771if ((!Handle) || (Handle == ACPI_ROOT_OBJECT))772{773return (AcpiGbl_RootNode);774}775776/* We can at least attempt to verify the handle */777778if (ACPI_GET_DESCRIPTOR_TYPE (Handle) != ACPI_DESC_TYPE_NAMED)779{780return (NULL);781}782783return (ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Handle));784}785786787/*******************************************************************************788*789* FUNCTION: AcpiNsTerminate790*791* PARAMETERS: none792*793* RETURN: none794*795* DESCRIPTION: free memory allocated for namespace and ACPI table storage.796*797******************************************************************************/798799void800AcpiNsTerminate (801void)802{803ACPI_STATUS Status;804805806ACPI_FUNCTION_TRACE (NsTerminate);807808809/*810* Free the entire namespace -- all nodes and all objects811* attached to the nodes812*/813AcpiNsDeleteNamespaceSubtree (AcpiGbl_RootNode);814815/* Delete any objects attached to the root node */816817Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);818if (ACPI_FAILURE (Status))819{820return_VOID;821}822823AcpiNsDeleteNode (AcpiGbl_RootNode);824(void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);825826ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace freed\n"));827return_VOID;828}829830831/*******************************************************************************832*833* FUNCTION: AcpiNsOpensScope834*835* PARAMETERS: Type - A valid namespace type836*837* RETURN: NEWSCOPE if the passed type "opens a name scope" according838* to the ACPI specification, else 0839*840******************************************************************************/841842UINT32843AcpiNsOpensScope (844ACPI_OBJECT_TYPE Type)845{846ACPI_FUNCTION_ENTRY ();847848849if (Type > ACPI_TYPE_LOCAL_MAX)850{851/* type code out of range */852853ACPI_WARNING ((AE_INFO, "Invalid Object Type 0x%X", Type));854return (ACPI_NS_NORMAL);855}856857return (((UINT32) AcpiGbl_NsProperties[Type]) & ACPI_NS_NEWSCOPE);858}859860861/*******************************************************************************862*863* FUNCTION: AcpiNsGetNodeUnlocked864*865* PARAMETERS: *Pathname - Name to be found, in external (ASL) format. The866* \ (backslash) and ^ (carat) prefixes, and the867* . (period) to separate segments are supported.868* PrefixNode - Root of subtree to be searched, or NS_ALL for the869* root of the name space. If Name is fully870* qualified (first INT8 is '\'), the passed value871* of Scope will not be accessed.872* Flags - Used to indicate whether to perform upsearch or873* not.874* ReturnNode - Where the Node is returned875*876* DESCRIPTION: Look up a name relative to a given scope and return the877* corresponding Node. NOTE: Scope can be null.878*879* MUTEX: Doesn't locks namespace880*881******************************************************************************/882883ACPI_STATUS884AcpiNsGetNodeUnlocked (885ACPI_NAMESPACE_NODE *PrefixNode,886const char *Pathname,887UINT32 Flags,888ACPI_NAMESPACE_NODE **ReturnNode)889{890ACPI_GENERIC_STATE ScopeInfo;891ACPI_STATUS Status;892char *InternalPath;893894895ACPI_FUNCTION_TRACE_PTR (NsGetNodeUnlocked, ACPI_CAST_PTR (char, Pathname));896897898/* Simplest case is a null pathname */899900if (!Pathname)901{902*ReturnNode = PrefixNode;903if (!PrefixNode)904{905*ReturnNode = AcpiGbl_RootNode;906}907908return_ACPI_STATUS (AE_OK);909}910911/* Quick check for a reference to the root */912913if (ACPI_IS_ROOT_PREFIX (Pathname[0]) && (!Pathname[1]))914{915*ReturnNode = AcpiGbl_RootNode;916return_ACPI_STATUS (AE_OK);917}918919/* Convert path to internal representation */920921Status = AcpiNsInternalizeName (Pathname, &InternalPath);922if (ACPI_FAILURE (Status))923{924return_ACPI_STATUS (Status);925}926927/* Setup lookup scope (search starting point) */928929ScopeInfo.Scope.Node = PrefixNode;930931/* Lookup the name in the namespace */932933Status = AcpiNsLookup (&ScopeInfo, InternalPath, ACPI_TYPE_ANY,934ACPI_IMODE_EXECUTE, (Flags | ACPI_NS_DONT_OPEN_SCOPE),935NULL, ReturnNode);936if (ACPI_FAILURE (Status))937{938ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s, %s\n",939Pathname, AcpiFormatException (Status)));940}941942ACPI_FREE (InternalPath);943return_ACPI_STATUS (Status);944}945946947/*******************************************************************************948*949* FUNCTION: AcpiNsGetNode950*951* PARAMETERS: *Pathname - Name to be found, in external (ASL) format. The952* \ (backslash) and ^ (carat) prefixes, and the953* . (period) to separate segments are supported.954* PrefixNode - Root of subtree to be searched, or NS_ALL for the955* root of the name space. If Name is fully956* qualified (first INT8 is '\'), the passed value957* of Scope will not be accessed.958* Flags - Used to indicate whether to perform upsearch or959* not.960* ReturnNode - Where the Node is returned961*962* DESCRIPTION: Look up a name relative to a given scope and return the963* corresponding Node. NOTE: Scope can be null.964*965* MUTEX: Locks namespace966*967******************************************************************************/968969ACPI_STATUS970AcpiNsGetNode (971ACPI_NAMESPACE_NODE *PrefixNode,972const char *Pathname,973UINT32 Flags,974ACPI_NAMESPACE_NODE **ReturnNode)975{976ACPI_STATUS Status;977978979ACPI_FUNCTION_TRACE_PTR (NsGetNode, ACPI_CAST_PTR (char, Pathname));980981982Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);983if (ACPI_FAILURE (Status))984{985return_ACPI_STATUS (Status);986}987988Status = AcpiNsGetNodeUnlocked (PrefixNode, Pathname,989Flags, ReturnNode);990991(void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);992return_ACPI_STATUS (Status);993}994995996