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

📄 dmrestag.c

📁 acpi tools for linux include acpiexec and acpixtract
💻 C
📖 第 1 页 / 共 3 页
字号:
    AcpiNsInternalizeName (Pathname, &InternalPath);    ACPI_FREE (Pathname);    return (InternalPath);}/******************************************************************************* * * FUNCTION:    AcpiDmUpdateResourceName * * PARAMETERS:  ResourceNode        - Node for a resource descriptor * * RETURN:      Stores new name in the ResourceNode * * DESCRIPTION: Create a new, unique name for a resource descriptor. Used by *              both the disassembly of the descriptor itself and any symbolic *              references to the descriptor. Ignored if a unique name has *              already been assigned to the resource. * * NOTE: Single threaded, suitable for applications only! * ******************************************************************************/static voidAcpiDmUpdateResourceName (    ACPI_NAMESPACE_NODE     *ResourceNode){    char                    Name[ACPI_NAME_SIZE];    /* Ignore if a unique name has already been assigned */    if (ResourceNode->Name.Integer != ACPI_DEFAULT_RESNAME)    {        return;    }    /* Generate a new ACPI name for the descriptor */    Name[0] = '_';    Name[1] = AcpiGbl_Prefix[AcpiGbl_NextPrefix];    Name[2] = AcpiUtHexToAsciiChar (AcpiGbl_NextResourceId, 4);    Name[3] = AcpiUtHexToAsciiChar (AcpiGbl_NextResourceId, 0);    /* Update globals for next name */    AcpiGbl_NextResourceId++;    if (AcpiGbl_NextResourceId >= 256)    {        AcpiGbl_NextResourceId = 0;        AcpiGbl_NextPrefix++;        if (AcpiGbl_NextPrefix > ACPI_NUM_RES_PREFIX)        {            AcpiGbl_NextPrefix = 0;        }    }    /* Change the resource descriptor name */    ResourceNode->Name.Integer = *(UINT32 *) Name;}/******************************************************************************* * * FUNCTION:    AcpiDmGetResourceTag * * PARAMETERS:  BitIndex            - Index into the resource descriptor *              Resource            - Pointer to the raw resource data *              ResourceIndex       - Index correspoinding to the resource type * * RETURN:      Pointer to the resource tag (ACPI_NAME). NULL if no match. * * DESCRIPTION: Convert a BitIndex into a symbolic resource tag. * ******************************************************************************/static char *AcpiDmGetResourceTag (    UINT32                  BitIndex,    AML_RESOURCE            *Resource,    UINT8                   ResourceIndex){    ACPI_RESOURCE_TAG       *TagList;    char                    *Tag = NULL;    /* Get the tag list for this resource descriptor type */    TagList = AcpiGbl_ResourceTags[ResourceIndex];    if (!TagList)    {        /* There are no tags for this resource type */        return (NULL);    }    /*     * Handle the type-specific flags field for the address descriptors.     * Kindof brute force, but just blindly search for an index match.     */    switch (Resource->DescriptorType)    {    case ACPI_RESOURCE_NAME_ADDRESS16:    case ACPI_RESOURCE_NAME_ADDRESS32:    case ACPI_RESOURCE_NAME_ADDRESS64:    case ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64:        if (Resource->Address.ResourceType == ACPI_ADDRESS_TYPE_MEMORY_RANGE)        {            Tag = AcpiDmSearchTagList (BitIndex, AcpiDmMemoryFlagTags);        }        else if (Resource->Address.ResourceType == ACPI_ADDRESS_TYPE_IO_RANGE)        {            Tag = AcpiDmSearchTagList (BitIndex, AcpiDmIoFlagTags);        }        /* If we found a match, all done. Else, drop to normal search below */        if (Tag)        {            return (Tag);        }        break;    default:        break;    }    /* Search the tag list for this descriptor type */    Tag = AcpiDmSearchTagList (BitIndex, TagList);    return (Tag);}/******************************************************************************* * * FUNCTION:    AcpiDmSearchTagList * * PARAMETERS:  BitIndex            - Index into the resource descriptor *              TagList             - List to search * * RETURN:      Pointer to a tag (ACPI_NAME). NULL if no match found. * * DESCRIPTION: Search a tag list for a match to the input BitIndex. Matches *              a fixed offset to a symbolic resource tag name. * ******************************************************************************/static char *AcpiDmSearchTagList (    UINT32                  BitIndex,    ACPI_RESOURCE_TAG       *TagList){    /*     * Walk the null-terminated tag list to find a matching bit offset.     * We are looking for an exact match.     */    for ( ; TagList->Tag; TagList++)    {        if (BitIndex == TagList->BitIndex)        {            return (TagList->Tag);        }    }    /* A matching offset was not found */    return (NULL);}/******************************************************************************* * * FUNCTION:    AcpiDmFindResources * * PARAMETERS:  Root                - Root of the parse tree * * RETURN:      None * * DESCRIPTION: Add all ResourceTemplate declarations to the namespace. Each *              resource descriptor in each template is given a node -- used *              for later conversion of resource references to symbolic refs. * ******************************************************************************/voidAcpiDmFindResources (    ACPI_PARSE_OBJECT       *Root){    ACPI_PARSE_OBJECT       *Op = Root;    ACPI_PARSE_OBJECT       *Parent;    /* Walk the entire parse tree */    while (Op)    {        /* We are interested in Buffer() declarations */        if (Op->Common.AmlOpcode == AML_BUFFER_OP)        {            /* And only declarations of the form Name (XXXX, Buffer()... ) */            Parent = Op->Common.Parent;            if (Parent->Common.AmlOpcode == AML_NAME_OP)            {                /*                 * If the buffer is a resource template, add the individual                 * resource descriptors to the namespace, as children of the                 * buffer node.                 */                if (ACPI_SUCCESS (AcpiDmIsResourceTemplate (Op)))                {                    Op->Common.DisasmOpcode = ACPI_DASM_RESOURCE;                    AcpiDmAddResourcesToNamespace (Parent->Common.Node, Op);                }            }        }        Op = AcpiPsGetDepthNext (Root, Op);    }}/******************************************************************************* * * FUNCTION:    AcpiDmAddResourcesToNamespace * * PARAMETERS:  BufferNode          - Node for the parent buffer *              Op                  - Parse op for the buffer * * RETURN:      None * * DESCRIPTION: Add an entire resource template to the namespace. Each *              resource descriptor is added as a namespace node. * ******************************************************************************/static voidAcpiDmAddResourcesToNamespace (    ACPI_NAMESPACE_NODE     *BufferNode,    ACPI_PARSE_OBJECT       *Op){    ACPI_PARSE_OBJECT       *NextOp;    /* Get to the ByteData list */    NextOp = Op->Common.Value.Arg;    NextOp = NextOp->Common.Next;    if (!NextOp)    {        return;    }    /* Set Node and Op to point to each other */    BufferNode->Op = Op;    Op->Common.Node = BufferNode;    /*     * Insert each resource into the namespace     * NextOp contains the Aml pointer and the Aml length     */    AcpiUtWalkAmlResources ((UINT8 *) NextOp->Named.Data,        (ACPI_SIZE) NextOp->Common.Value.Integer,        AcpiDmAddResourceToNamespace, BufferNode);}/******************************************************************************* * * FUNCTION:    AcpiDmAddResourceToNamespace * * PARAMETERS:  ACPI_WALK_AML_CALLBACK *              BufferNode              - Node for the parent buffer * * RETURN:      Status * * DESCRIPTION: Add one resource descriptor to the namespace as a child of the *              parent buffer. The same name is used for each descriptor. This *              is changed later to a unique name if the resource is actually *              referenced by an AML operator. * ******************************************************************************/static ACPI_STATUSAcpiDmAddResourceToNamespace (    UINT8                   *Aml,    UINT32                  Length,    UINT32                  Offset,    UINT8                   ResourceIndex,    void                    *Context){    ACPI_STATUS             Status;    ACPI_GENERIC_STATE      ScopeInfo;    ACPI_NAMESPACE_NODE     *Node;    /* TBD: Don't need to add descriptors that have no tags defined? */    /* Add the resource to the namespace, as child of the buffer */    ScopeInfo.Scope.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Context);    Status = AcpiNsLookup (&ScopeInfo, "_TMP", ACPI_TYPE_LOCAL_RESOURCE,                ACPI_IMODE_LOAD_PASS2,                ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_PREFIX_IS_SCOPE,                NULL, &Node);    if (ACPI_FAILURE (Status))    {        return (AE_OK);    }    /* Set the name to the default, changed later if resource is referenced */    Node->Name.Integer = ACPI_DEFAULT_RESNAME;    /* Save the offset of the descriptor (within the original buffer) */    Node->Value = Offset;    Node->Length = Length;    return (AE_OK);}

⌨️ 快捷键说明

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