⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nsutils.c

📁 acpi tools for linux include acpiexec and acpixtract
💻 C
📖 第 1 页 / 共 3 页
字号:
     */    *ConvertedName = ACPI_ALLOCATE_ZEROED (RequiredLength);    if (!(*ConvertedName))    {        return_ACPI_STATUS (AE_NO_MEMORY);    }    j = 0;    for (i = 0; i < PrefixLength; i++)    {        (*ConvertedName)[j++] = InternalName[i];    }    if (NumSegments > 0)    {        for (i = 0; i < NumSegments; i++)        {            if (i > 0)            {                (*ConvertedName)[j++] = '.';            }            (*ConvertedName)[j++] = InternalName[NamesIndex++];            (*ConvertedName)[j++] = InternalName[NamesIndex++];            (*ConvertedName)[j++] = InternalName[NamesIndex++];            (*ConvertedName)[j++] = InternalName[NamesIndex++];        }    }    if (ConvertedNameLength)    {        *ConvertedNameLength = (UINT32) RequiredLength;    }    return_ACPI_STATUS (AE_OK);}/******************************************************************************* * * FUNCTION:    AcpiNsMapHandleToNode * * PARAMETERS:  Handle          - Handle to be converted to an Node * * RETURN:      A Name table entry pointer * * DESCRIPTION: Convert a namespace handle to a real Node * * Note: Real integer handles would allow for more verification *       and keep all pointers within this subsystem - however this introduces *       more (and perhaps unnecessary) overhead. * ******************************************************************************/ACPI_NAMESPACE_NODE *AcpiNsMapHandleToNode (    ACPI_HANDLE             Handle){    ACPI_FUNCTION_ENTRY ();    /*     * Simple implementation     */    if ((!Handle) || (Handle == ACPI_ROOT_OBJECT))    {        return (AcpiGbl_RootNode);    }    /* We can at least attempt to verify the handle */    if (ACPI_GET_DESCRIPTOR_TYPE (Handle) != ACPI_DESC_TYPE_NAMED)    {        return (NULL);    }    return (ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Handle));}/******************************************************************************* * * FUNCTION:    AcpiNsConvertEntryToHandle * * PARAMETERS:  Node          - Node to be converted to a Handle * * RETURN:      A user handle * * DESCRIPTION: Convert a real Node to a namespace handle * ******************************************************************************/ACPI_HANDLEAcpiNsConvertEntryToHandle (    ACPI_NAMESPACE_NODE         *Node){    /*     * Simple implementation for now;     */    return ((ACPI_HANDLE) Node);/* Example future implementation ---------------------    if (!Node)    {        return (NULL);    }    if (Node == AcpiGbl_RootNode)    {        return (ACPI_ROOT_OBJECT);    }    return ((ACPI_HANDLE) Node);------------------------------------------------------*/}/******************************************************************************* * * FUNCTION:    AcpiNsTerminate * * PARAMETERS:  none * * RETURN:      none * * DESCRIPTION: free memory allocated for namespace and ACPI table storage. * ******************************************************************************/voidAcpiNsTerminate (    void){    ACPI_OPERAND_OBJECT     *ObjDesc;    ACPI_FUNCTION_TRACE (NsTerminate);    /*     * 1) Free the entire namespace -- all nodes and objects     *     * Delete all object descriptors attached to namepsace nodes     */    AcpiNsDeleteNamespaceSubtree (AcpiGbl_RootNode);    /* Detach any objects attached to the root */    ObjDesc = AcpiNsGetAttachedObject (AcpiGbl_RootNode);    if (ObjDesc)    {        AcpiNsDetachObject (AcpiGbl_RootNode);    }    ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace freed\n"));    return_VOID;}/******************************************************************************* * * FUNCTION:    AcpiNsOpensScope * * PARAMETERS:  Type        - A valid namespace type * * RETURN:      NEWSCOPE if the passed type "opens a name scope" according *              to the ACPI specification, else 0 * ******************************************************************************/UINT32AcpiNsOpensScope (    ACPI_OBJECT_TYPE        Type){    ACPI_FUNCTION_TRACE_STR (NsOpensScope, AcpiUtGetTypeName (Type));    if (!AcpiUtValidObjectType (Type))    {        /* type code out of range  */        ACPI_WARNING ((AE_INFO, "Invalid Object Type %X", Type));        return_UINT32 (ACPI_NS_NORMAL);    }    return_UINT32 (((UINT32) AcpiGbl_NsProperties[Type]) & ACPI_NS_NEWSCOPE);}/******************************************************************************* * * FUNCTION:    AcpiNsGetNode * * PARAMETERS:  *Pathname   - Name to be found, in external (ASL) format. The *                            \ (backslash) and ^ (carat) prefixes, and the *                            . (period) to separate segments are supported. *              PrefixNode   - Root of subtree to be searched, or NS_ALL for the *                            root of the name space.  If Name is fully *                            qualified (first INT8 is '\'), the passed value *                            of Scope will not be accessed. *              Flags       - Used to indicate whether to perform upsearch or *                            not. *              ReturnNode  - Where the Node is returned * * DESCRIPTION: Look up a name relative to a given scope and return the *              corresponding Node.  NOTE: Scope can be null. * * MUTEX:       Locks namespace * ******************************************************************************/ACPI_STATUSAcpiNsGetNode (    ACPI_NAMESPACE_NODE     *PrefixNode,    char                    *Pathname,    UINT32                  Flags,    ACPI_NAMESPACE_NODE     **ReturnNode){    ACPI_GENERIC_STATE      ScopeInfo;    ACPI_STATUS             Status;    char                    *InternalPath;    ACPI_FUNCTION_TRACE_PTR (NsGetNode, Pathname);    if (!Pathname)    {        *ReturnNode = PrefixNode;        if (!PrefixNode)        {            *ReturnNode = AcpiGbl_RootNode;        }        return_ACPI_STATUS (AE_OK);    }    /* Convert path to internal representation */    Status = AcpiNsInternalizeName (Pathname, &InternalPath);    if (ACPI_FAILURE (Status))    {        return_ACPI_STATUS (Status);    }    /* Must lock namespace during lookup */    Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);    if (ACPI_FAILURE (Status))    {        goto Cleanup;    }    /* Setup lookup scope (search starting point) */    ScopeInfo.Scope.Node = PrefixNode;    /* Lookup the name in the namespace */    Status = AcpiNsLookup (&ScopeInfo, InternalPath, ACPI_TYPE_ANY,                ACPI_IMODE_EXECUTE, (Flags | ACPI_NS_DONT_OPEN_SCOPE),                NULL, ReturnNode);    if (ACPI_FAILURE (Status))    {        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s, %s\n",                Pathname, AcpiFormatException (Status)));    }    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);Cleanup:    ACPI_FREE (InternalPath);    return_ACPI_STATUS (Status);}/******************************************************************************* * * FUNCTION:    AcpiNsGetParentNode * * PARAMETERS:  Node       - Current table entry * * RETURN:      Parent entry of the given entry * * DESCRIPTION: Obtain the parent entry for a given entry in the namespace. * ******************************************************************************/ACPI_NAMESPACE_NODE *AcpiNsGetParentNode (    ACPI_NAMESPACE_NODE     *Node){    ACPI_FUNCTION_ENTRY ();    if (!Node)    {        return (NULL);    }    /*     * Walk to the end of this peer list. The last entry is marked with a flag     * and the peer pointer is really a pointer back to the parent. This saves     * putting a parent back pointer in each and every named object!     */    while (!(Node->Flags & ANOBJ_END_OF_PEER_LIST))    {        Node = Node->Peer;    }    return (Node->Peer);}/******************************************************************************* * * FUNCTION:    AcpiNsGetNextValidNode * * PARAMETERS:  Node       - Current table entry * * RETURN:      Next valid Node in the linked node list. NULL if no more valid *              nodes. * * DESCRIPTION: Find the next valid node within a name table. *              Useful for implementing NULL-end-of-list loops. * ******************************************************************************/ACPI_NAMESPACE_NODE *AcpiNsGetNextValidNode (    ACPI_NAMESPACE_NODE     *Node){    /* If we are at the end of this peer list, return NULL */    if (Node->Flags & ANOBJ_END_OF_PEER_LIST)    {        return NULL;    }    /* Otherwise just return the next peer */    return (Node->Peer);}#ifdef ACPI_OBSOLETE_FUNCTIONS/******************************************************************************* * * FUNCTION:    AcpiNsFindParentName * * PARAMETERS:  *ChildNode             - Named Obj whose name is to be found * * RETURN:      The ACPI name * * DESCRIPTION: Search for the given obj in its parent scope and return the *              name segment, or "????" if the parent name can't be found *              (which "should not happen"). * ******************************************************************************/ACPI_NAMEAcpiNsFindParentName (    ACPI_NAMESPACE_NODE     *ChildNode){    ACPI_NAMESPACE_NODE     *ParentNode;    ACPI_FUNCTION_TRACE (NsFindParentName);    if (ChildNode)    {        /* Valid entry.  Get the parent Node */        ParentNode = AcpiNsGetParentNode (ChildNode);        if (ParentNode)        {            ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,                "Parent of %p [%4.4s] is %p [%4.4s]\n",                ChildNode,  AcpiUtGetNodeName (ChildNode),                ParentNode, AcpiUtGetNodeName (ParentNode)));            if (ParentNode->Name.Integer)            {                return_VALUE ((ACPI_NAME) ParentNode->Name.Integer);            }        }        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,            "Unable to find parent of %p (%4.4s)\n",            ChildNode, AcpiUtGetNodeName (ChildNode)));    }    return_VALUE (ACPI_UNKNOWN_NAME);}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -