示例#1
0
static void
AcpiDmAddResourcesToNamespace (
    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 (NULL, (UINT8 *) NextOp->Named.Data,
        (ACPI_SIZE) NextOp->Common.Value.Integer,
        AcpiDmAddResourceToNamespace, (void **) BufferNode);
}
示例#2
0
ACPI_STATUS
AcpiRsCreateResourceList (
    ACPI_OPERAND_OBJECT     *AmlBuffer,
    ACPI_BUFFER             *OutputBuffer)
{

    ACPI_STATUS             Status;
    UINT8                   *AmlStart;
    ACPI_SIZE               ListSizeNeeded = 0;
    UINT32                  AmlBufferLength;
    void                    *Resource;


    ACPI_FUNCTION_TRACE (RsCreateResourceList);


    ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlBuffer = %p\n",
        AmlBuffer));

    /* Params already validated, so we don't re-validate here */

    AmlBufferLength = AmlBuffer->Buffer.Length;
    AmlStart = AmlBuffer->Buffer.Pointer;

    /*
     * Pass the AmlBuffer into a module that can calculate
     * the buffer size needed for the linked list
     */
    Status = AcpiRsGetListLength (AmlStart, AmlBufferLength,
                &ListSizeNeeded);

    ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Status=%X ListSizeNeeded=%X\n",
        Status, (UINT32) ListSizeNeeded));
    if (ACPI_FAILURE (Status))
    {
        return_ACPI_STATUS (Status);
    }

    /* Validate/Allocate/Clear caller buffer */

    Status = AcpiUtInitializeBuffer (OutputBuffer, ListSizeNeeded);
    if (ACPI_FAILURE (Status))
    {
        return_ACPI_STATUS (Status);
    }

    /* Do the conversion */

    Resource = OutputBuffer->Pointer;
    Status = AcpiUtWalkAmlResources (NULL, AmlStart, AmlBufferLength,
                AcpiRsConvertAmlToResources, &Resource);
    if (ACPI_FAILURE (Status))
    {
        return_ACPI_STATUS (Status);
    }

    ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
            OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
    return_ACPI_STATUS (AE_OK);
}
示例#3
0
ACPI_STATUS
AcpiBufferToResource (
    UINT8                   *AmlBuffer,
    UINT16                  AmlBufferLength,
    ACPI_RESOURCE           **ResourcePtr)
{
    ACPI_STATUS             Status;
    ACPI_SIZE               ListSizeNeeded;
    void                    *Resource;
    void                    *CurrentResourcePtr;

    /*
     * Note: we allow AE_AML_NO_RESOURCE_END_TAG, since an end tag
     * is not required here.
     */

    /* Get the required length for the converted resource */

    Status = AcpiRsGetListLength (AmlBuffer, AmlBufferLength,
                &ListSizeNeeded);
    if (Status == AE_AML_NO_RESOURCE_END_TAG)
    {
        Status = AE_OK;
    }
    if (ACPI_FAILURE (Status))
    {
        return (Status);
    }

    /* Allocate a buffer for the converted resource */

    Resource = ACPI_ALLOCATE_ZEROED (ListSizeNeeded);
    CurrentResourcePtr = Resource;
    if (!Resource)
    {
        return (AE_NO_MEMORY);
    }

    /* Perform the AML-to-Resource conversion */

    Status = AcpiUtWalkAmlResources (NULL, AmlBuffer, AmlBufferLength,
                AcpiRsConvertAmlToResources, &CurrentResourcePtr);
    if (Status == AE_AML_NO_RESOURCE_END_TAG)
    {
        Status = AE_OK;
    }
    if (ACPI_FAILURE (Status))
    {
        ACPI_FREE (Resource);
    }
    else
    {
        *ResourcePtr = Resource;
    }

    return (Status);
}
示例#4
0
ACPI_STATUS
AcpiDmIsResourceTemplate (
    ACPI_PARSE_OBJECT       *Op)
{
    ACPI_STATUS             Status;
    ACPI_PARSE_OBJECT       *NextOp;
    UINT8                   *Aml;
    UINT8                   *EndAml;
    ACPI_SIZE               Length;


    /* This op must be a buffer */

    if (Op->Common.AmlOpcode != AML_BUFFER_OP)
    {
        return (AE_TYPE);
    }

    /* Get the ByteData list and length */

    NextOp = Op->Common.Value.Arg;
    NextOp = NextOp->Common.Next;
    if (!NextOp)
    {
        return (AE_TYPE);
    }

    Aml = NextOp->Named.Data;
    Length = (ACPI_SIZE) NextOp->Common.Value.Integer;

    /* Walk the byte list, abort on any invalid descriptor type or length */

    Status = AcpiUtWalkAmlResources (Aml, Length, NULL, &EndAml);
    if (ACPI_FAILURE (Status))
    {
        return (AE_TYPE);
    }

    /*
     * For the resource template to be valid, one EndTag must appear
     * at the very end of the ByteList, not before. (For proper disassembly
     * of a ResourceTemplate, the buffer must not have any extra data after
     * the EndTag.)
     */
    if ((Aml + Length - sizeof (AML_RESOURCE_END_TAG)) != EndAml)
    {
        return (AE_AML_NO_RESOURCE_END_TAG);
    }

    /*
     * All resource descriptors are valid, therefore this list appears
     * to be a valid resource template
     */
    return (AE_OK);
}