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

📄 dmrestag.c

📁 acpi tools for linux include acpiexec and acpixtract
💻 C
📖 第 1 页 / 共 3 页
字号:
    {( 5 * 8) + 4,  ACPI_RESTAG_TYPE},    {( 5 * 8) + 5,  ACPI_RESTAG_TRANSTYPE},    {0,             NULL}};/* Dispatch table used to obtain the correct tag table for a descriptor */static ACPI_RESOURCE_TAG        *AcpiGbl_ResourceTags [] ={    /* Small descriptors */    NULL,                           /* 0x00, Reserved */    NULL,                           /* 0x01, Reserved */    NULL,                           /* 0x02, Reserved */    NULL,                           /* 0x03, Reserved */    AcpiDmIrqTags,                  /* 0x04, ACPI_RESOURCE_NAME_IRQ_FORMAT */    AcpiDmDmaTags,                  /* 0x05, ACPI_RESOURCE_NAME_DMA_FORMAT */    NULL,                           /* 0x06, ACPI_RESOURCE_NAME_START_DEPENDENT */    NULL,                           /* 0x07, ACPI_RESOURCE_NAME_END_DEPENDENT */    AcpiDmIoTags,                   /* 0x08, ACPI_RESOURCE_NAME_IO_PORT */    AcpiDmFixedIoTags,              /* 0x09, ACPI_RESOURCE_NAME_FIXED_IO_PORT */    NULL,                           /* 0x0A, Reserved */    NULL,                           /* 0x0B, Reserved */    NULL,                           /* 0x0C, Reserved */    NULL,                           /* 0x0D, Reserved */    NULL,                           /* 0x0E, ACPI_RESOURCE_NAME_SMALL_VENDOR */    NULL,                           /* 0x0F, ACPI_RESOURCE_NAME_END_TAG (not used) */    /* Large descriptors */    NULL,                           /* 0x00, Reserved */    AcpiDmMemory24Tags,             /* 0x01, ACPI_RESOURCE_NAME_MEMORY_24 */    AcpiDmRegisterTags,             /* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */    NULL,                           /* 0x03, Reserved */    NULL,                           /* 0x04, ACPI_RESOURCE_NAME_LARGE_VENDOR */    AcpiDmMemory32Tags,             /* 0x05, ACPI_RESOURCE_NAME_MEMORY_32 */    AcpiDmFixedMemory32Tags,        /* 0x06, ACPI_RESOURCE_NAME_FIXED_MEMORY_32 */    AcpiDmAddress32Tags,            /* 0x07, ACPI_RESOURCE_NAME_DWORD_ADDRESS_SPACE */    AcpiDmAddress16Tags,            /* 0x08, ACPI_RESOURCE_NAME_WORD_ADDRESS_SPACE */    AcpiDmInterruptTags,            /* 0x09, ACPI_RESOURCE_NAME_EXTENDED_XRUPT */    AcpiDmAddress64Tags,            /* 0x0A, ACPI_RESOURCE_NAME_QWORD_ADDRESS_SPACE */    AcpiDmExtendedAddressTags       /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS_SPACE */};/* * Globals used to generate unique resource descriptor names. We use names that * start with underscore and a prefix letter that is not used by other ACPI * reserved names. To this, we append hex 0x00 through 0xFF. These 5 prefixes * allow for 5*256 = 1280 unique names, probably sufficient for any single ASL * file. If this becomes too small, we can use alpha+numerals for a total * of 5*36*36 = 6480. */#define ACPI_NUM_RES_PREFIX     5static UINT32                   AcpiGbl_NextResourceId = 0;static UINT8                    AcpiGbl_NextPrefix = 0;static UINT8                    AcpiGbl_Prefix[ACPI_NUM_RES_PREFIX] =                                    {'Y','Z','J','K','X'};/******************************************************************************* * * FUNCTION:    AcpiDmCheckResourceReference * * PARAMETERS:  Op                  - Parse Op for the AML opcode *              WalkState           - Current walk state (with valid scope) * * RETURN:      None * * DESCRIPTION: Convert a reference to a resource descriptor to a symbolic *              reference if possible * * NOTE:        Bit index is used to transparently handle both resource bit *              fields and byte fields. * ******************************************************************************/voidAcpiDmCheckResourceReference (    ACPI_PARSE_OBJECT       *Op,    ACPI_WALK_STATE         *WalkState){    ACPI_STATUS             Status;    ACPI_PARSE_OBJECT       *BufferNameOp;    ACPI_PARSE_OBJECT       *IndexOp;    ACPI_NAMESPACE_NODE     *BufferNode;    ACPI_NAMESPACE_NODE     *ResourceNode;    const ACPI_OPCODE_INFO  *OpInfo;    char                    *Pathname;    UINT32                  BitIndex;    /* We are only interested in the CreateXxxxField opcodes */    OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);    if (OpInfo->Type != AML_TYPE_CREATE_FIELD)    {        return;    }    /* Get the buffer term operand */    BufferNameOp = AcpiPsGetDepthNext (NULL, Op);    /* Must be a named buffer, not an arg or local or method call */    if (BufferNameOp->Common.AmlOpcode != AML_INT_NAMEPATH_OP)    {        return;    }    /* Get the Index term, must be an integer constant to convert */    IndexOp = BufferNameOp->Common.Next;    OpInfo = AcpiPsGetOpcodeInfo (IndexOp->Common.AmlOpcode);    if (OpInfo->ObjectType != ACPI_TYPE_INTEGER)    {        return;    }    /* Get the bit offset of the descriptor within the buffer */    if ((Op->Common.AmlOpcode == AML_CREATE_BIT_FIELD_OP) ||        (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP))    {        /* Index operand is a bit offset */        BitIndex = (UINT32) IndexOp->Common.Value.Integer;    }    else    {        /* Index operand is a byte offset, convert to bits */        BitIndex = (UINT32) ACPI_MUL_8 (IndexOp->Common.Value.Integer);    }    /* Lookup the buffer in the namespace */    Status = AcpiNsLookup (WalkState->ScopeInfo,                BufferNameOp->Common.Value.String, ACPI_TYPE_BUFFER,                ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState,                &BufferNode);    if (ACPI_FAILURE (Status))    {        return;    }    /* Validate object type, we must have a buffer */    if (BufferNode->Type != ACPI_TYPE_BUFFER)    {        return;    }    /* Find the resource descriptor node corresponding to the index */    ResourceNode = AcpiDmGetResourceNode (BufferNode, BitIndex);    if (!ResourceNode)    {        return;    }    /* Translate the Index to a resource tag pathname */    Pathname = AcpiGetTagPathname (BufferNode, ResourceNode, BitIndex);    if (Pathname)    {        /* Complete the conversion of the Index to a symbol */        IndexOp->Common.AmlOpcode = AML_INT_NAMEPATH_OP;        IndexOp->Common.Value.String = Pathname;    }}/******************************************************************************* * * FUNCTION:    AcpiDmGetResourceNode * * PARAMETERS:  BufferNode          - Node for the parent buffer *              BitIndex            - Index into the resource descriptor * * RETURN:      Namespace node for the resource descriptor. NULL if not found * * DESCRIPTION: Find a resource descriptor that corresponds to the bit index * ******************************************************************************/static ACPI_NAMESPACE_NODE *AcpiDmGetResourceNode (    ACPI_NAMESPACE_NODE     *BufferNode,    UINT32                  BitIndex){    ACPI_NAMESPACE_NODE     *Node;    UINT32                  ByteIndex = ACPI_DIV_8 (BitIndex);    /*     * Child list contains an entry for each resource descriptor. Find     * the descriptor that corresponds to the Index.     *     * If there are no children, this is not a resource template     */    Node = BufferNode->Child;    while (Node)    {        /*         * Check if the Index falls within this resource.         *         * Value contains the resource offset, Object contains the resource         * length (both in bytes)         */        if ((ByteIndex >= Node->Value) &&            (ByteIndex < (Node->Value + Node->Length)))        {            return (Node);        }        /* List is circular, this flag marks the end */        if (Node->Flags & ANOBJ_END_OF_PEER_LIST)        {            return (NULL);        }        Node = Node->Peer;    }    return (NULL);}/******************************************************************************* * * FUNCTION:    AcpiGetTagPathname * * PARAMETERS:  BufferNode          - Node for the parent buffer *              ResourceNode        - Node for a resource descriptor *              BitIndex            - Index into the resource descriptor * * RETURN:      Full pathname for a resource tag. NULL if no match. *              Path is returned in AML (packed) format. * * DESCRIPTION: Convert a BitIndex into a symbolic resource tag (full pathname) * ******************************************************************************/static char *AcpiGetTagPathname (    ACPI_NAMESPACE_NODE     *BufferNode,    ACPI_NAMESPACE_NODE     *ResourceNode,    UINT32                  BitIndex){    ACPI_STATUS             Status;    UINT32                  ResourceBitIndex;    UINT8                   ResourceTableIndex;    ACPI_SIZE               RequiredSize;    char                    *Pathname;    AML_RESOURCE            *Aml;    ACPI_PARSE_OBJECT       *Op;    char                    *InternalPath;    char                    *Tag;    /* Get the Op that contains the actual buffer data */    Op = BufferNode->Op->Common.Value.Arg;    Op = Op->Common.Next;    if (!Op)    {        return (NULL);    }    /* Get the individual resource descriptor and validate it */    Aml = ACPI_CAST_PTR (AML_RESOURCE,            &Op->Named.Data[ResourceNode->Value]);    Status = AcpiUtValidateResource (Aml, &ResourceTableIndex);    if (ACPI_FAILURE (Status))    {        return (NULL);    }    /* Get offset into this descriptor (from offset into entire buffer) */    ResourceBitIndex = BitIndex - ACPI_MUL_8 (ResourceNode->Value);    /* Get the tag associated with this resource descriptor and offset */    Tag = AcpiDmGetResourceTag (ResourceBitIndex, Aml, ResourceTableIndex);    if (!Tag)    {        return (NULL);    }    /*     * Now that we know that we have a reference that can be converted to a     * symbol, change the name of the resource to a unique name.     */    AcpiDmUpdateResourceName (ResourceNode);    /* Get the full pathname to the parent buffer */    RequiredSize = AcpiNsGetPathnameLength (BufferNode);    Pathname = ACPI_ALLOCATE_ZEROED (RequiredSize + ACPI_PATH_SEGMENT_LENGTH);    if (!Pathname)    {        return (NULL);    }    AcpiNsBuildExternalPath (BufferNode, RequiredSize, Pathname);    /*     * Create the full path to the resource and tag by: remove the buffer name,     * append the resource descriptor name, append a dot, append the tag name.     *     * TBD: Always using the full path is a bit brute force, the path can be     * often be optimized with carats (if the original buffer namepath is a     * single nameseg). This doesn't really matter, because these paths do not     * end up in the final compiled AML, it's just an appearance issue for the     * disassembled code.     */    Pathname[ACPI_STRLEN (Pathname) - ACPI_NAME_SIZE] = 0;    ACPI_STRNCAT (Pathname, ResourceNode->Name.Ascii, ACPI_NAME_SIZE);    ACPI_STRCAT (Pathname, ".");    ACPI_STRNCAT (Pathname, Tag, ACPI_NAME_SIZE);    /* Internalize the namepath to AML format */

⌨️ 快捷键说明

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