示例#1
0
acpi_status
acpi_rs_create_resource_list (
	union acpi_operand_object       *byte_stream_buffer,
	struct acpi_buffer              *output_buffer)
{

	acpi_status                     status;
	u8                              *byte_stream_start;
	acpi_size                       list_size_needed = 0;
	u32                             byte_stream_buffer_length;


	ACPI_FUNCTION_TRACE ("rs_create_resource_list");


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

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

	byte_stream_buffer_length = byte_stream_buffer->buffer.length;
	byte_stream_start = byte_stream_buffer->buffer.pointer;

	/*
	 * Pass the byte_stream_buffer into a module that can calculate
	 * the buffer size needed for the linked list
	 */
	status = acpi_rs_get_list_length (byte_stream_start, byte_stream_buffer_length,
			 &list_size_needed);

	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Status=%X list_size_needed=%X\n",
		status, (u32) list_size_needed));
	if (ACPI_FAILURE (status)) {
		return_ACPI_STATUS (status);
	}

	/* Validate/Allocate/Clear caller buffer */

	status = acpi_ut_initialize_buffer (output_buffer, list_size_needed);
	if (ACPI_FAILURE (status)) {
		return_ACPI_STATUS (status);
	}

	/* Do the conversion */

	status = acpi_rs_byte_stream_to_list (byte_stream_start, byte_stream_buffer_length,
			  output_buffer->pointer);
	if (ACPI_FAILURE (status)) {
		return_ACPI_STATUS (status);
	}

	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "output_buffer %p Length %X\n",
			output_buffer->pointer, (u32) output_buffer->length));
	return_ACPI_STATUS (AE_OK);
}
示例#2
0
文件: rscreate.c 项目: 274914765/C
/*******************************************************************************
 *
 * FUNCTION:    acpi_rs_create_resource_list
 *
 * PARAMETERS:  aml_buffer          - Pointer to the resource byte stream
 *              output_buffer       - Pointer to the user's buffer
 *
 * RETURN:      Status: AE_OK if okay, else a valid acpi_status code
 *              If output_buffer is not large enough, output_buffer_length
 *              indicates how large output_buffer should be, else it
 *              indicates how may u8 elements of output_buffer are valid.
 *
 * DESCRIPTION: Takes the byte stream returned from a _CRS, _PRS control method
 *              execution and parses the stream to create a linked list
 *              of device resources.
 *
 ******************************************************************************/
acpi_status
acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer,
                 struct acpi_buffer *output_buffer)
{

    acpi_status status;
    u8 *aml_start;
    acpi_size list_size_needed = 0;
    u32 aml_buffer_length;
    void *resource;

    ACPI_FUNCTION_TRACE(rs_create_resource_list);

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

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

    aml_buffer_length = aml_buffer->buffer.length;
    aml_start = aml_buffer->buffer.pointer;

    /*
     * Pass the aml_buffer into a module that can calculate
     * the buffer size needed for the linked list
     */
    status = acpi_rs_get_list_length(aml_start, aml_buffer_length,
                     &list_size_needed);

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

    /* Validate/Allocate/Clear caller buffer */

    status = acpi_ut_initialize_buffer(output_buffer, list_size_needed);
    if (ACPI_FAILURE(status)) {
        return_ACPI_STATUS(status);
    }

    /* Do the conversion */

    resource = output_buffer->pointer;
    status = acpi_ut_walk_aml_resources(aml_start, aml_buffer_length,
                        acpi_rs_convert_aml_to_resources,
                        &resource);
    if (ACPI_FAILURE(status)) {
        return_ACPI_STATUS(status);
    }

    ACPI_DEBUG_PRINT((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
              output_buffer->pointer, (u32) output_buffer->length));
    return_ACPI_STATUS(AE_OK);
}
示例#3
0
/*******************************************************************************
 *
<<<<<<< HEAD
<<<<<<< HEAD
 * FUNCTION:    acpi_buffer_to_resource
 *
 * PARAMETERS:  aml_buffer          - Pointer to the resource byte stream
 *              aml_buffer_length   - Length of the aml_buffer
 *              resource_ptr        - Where the converted resource is returned
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Convert a raw AML buffer to a resource list
 *
 ******************************************************************************/
acpi_status
acpi_buffer_to_resource(u8 *aml_buffer,
			u16 aml_buffer_length,
			struct acpi_resource **resource_ptr)
{
	acpi_status status;
	acpi_size list_size_needed;
	void *resource;
	void *current_resource_ptr;

	/*
	 * 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 = acpi_rs_get_list_length(aml_buffer, aml_buffer_length,
					 &list_size_needed);
	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(list_size_needed);
	current_resource_ptr = resource;
	if (!resource) {
		return (AE_NO_MEMORY);
	}

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

	status = acpi_ut_walk_aml_resources(aml_buffer, aml_buffer_length,
					    acpi_rs_convert_aml_to_resources,
					    &current_resource_ptr);
	if (status == AE_AML_NO_RESOURCE_END_TAG) {
		status = AE_OK;
	}
	if (ACPI_FAILURE(status)) {
		ACPI_FREE(resource);
	} else {
		*resource_ptr = resource;
	}

	return (status);
}