Пример #1
0
static ssize_t
acpi_system_read_dsdt(struct file *file,
		      char __user * buffer, size_t count, loff_t * ppos)
{
	acpi_status status = AE_OK;
	struct acpi_table_header *tbl_ptr;
	ssize_t res;
	void *ptr;

	status = acpi_tb_get_table_ptr(ACPI_TABLE_ID_DSDT, 1, &tbl_ptr);
	if (ACPI_FAILURE(status))
		return -ENODEV;

	ptr = vmalloc(tbl_ptr->length);
	if (!ptr)
		return -ENOMEM;

	ACPI_MEMSET(ptr, 0, tbl_ptr->length);

	ACPI_MEMCPY(ACPI_CAST_PTR(void, ptr),
		    ACPI_CAST_PTR(void, tbl_ptr), tbl_ptr->length);

	res = simple_read_from_buffer(buffer, count, ppos, ptr,
				      tbl_ptr->length);
	vfree(ptr);

	return res;
}
Пример #2
0
acpi_status
acpi_get_table_header (
    acpi_table_type                 table_type,
    u32                             instance,
    struct acpi_table_header        *out_table_header)
{
    struct acpi_table_header        *tbl_ptr;
    acpi_status                     status;


    ACPI_FUNCTION_TRACE ("acpi_get_table_header");


    if ((instance == 0)                 ||
            (table_type == ACPI_TABLE_RSDP) ||
            (!out_table_header)) {
        return_ACPI_STATUS (AE_BAD_PARAMETER);
    }

    /* Check the table type and instance */

    if ((table_type > ACPI_TABLE_MAX)   ||
            (ACPI_IS_SINGLE_TABLE (acpi_gbl_table_data[table_type].flags) &&
             instance > 1)) {
        return_ACPI_STATUS (AE_BAD_PARAMETER);
    }


    /* Get a pointer to the entire table */

    status = acpi_tb_get_table_ptr (table_type, instance, &tbl_ptr);
    if (ACPI_FAILURE (status)) {
        return_ACPI_STATUS (status);
    }

    /*
     * The function will return a NULL pointer if the table is not loaded
     */
    if (tbl_ptr == NULL) {
        return_ACPI_STATUS (AE_NOT_EXIST);
    }

    /*
     * Copy the header to the caller's buffer
     */
    ACPI_MEMCPY ((void *) out_table_header, (void *) tbl_ptr,
                 sizeof (struct acpi_table_header));

    return_ACPI_STATUS (status);
}
Пример #3
0
acpi_status
acpi_get_table (
    acpi_table_type                 table_type,
    u32                             instance,
    struct acpi_buffer              *ret_buffer)
{
    struct acpi_table_header        *tbl_ptr;
    acpi_status                     status;
    acpi_size                       table_length;


    ACPI_FUNCTION_TRACE ("acpi_get_table");


    /* Parameter validation */

    if (instance == 0) {
        return_ACPI_STATUS (AE_BAD_PARAMETER);
    }

    status = acpi_ut_validate_buffer (ret_buffer);
    if (ACPI_FAILURE (status)) {
        return_ACPI_STATUS (status);
    }

    /* Check the table type and instance */

    if ((table_type > ACPI_TABLE_MAX)   ||
            (ACPI_IS_SINGLE_TABLE (acpi_gbl_table_data[table_type].flags) &&
             instance > 1)) {
        return_ACPI_STATUS (AE_BAD_PARAMETER);
    }


    /* Get a pointer to the entire table */

    status = acpi_tb_get_table_ptr (table_type, instance, &tbl_ptr);
    if (ACPI_FAILURE (status)) {
        return_ACPI_STATUS (status);
    }

    /*
     * acpi_tb_get_table_ptr will return a NULL pointer if the
     * table is not loaded.
     */
    if (tbl_ptr == NULL) {
        return_ACPI_STATUS (AE_NOT_EXIST);
    }

    /* Get the table length */

    if (table_type == ACPI_TABLE_RSDP) {
        /*
         *  RSD PTR is the only "table" without a header
         */
        table_length = sizeof (struct rsdp_descriptor);
    }
    else {
        table_length = (acpi_size) tbl_ptr->length;
    }

    /* Validate/Allocate/Clear caller buffer */

    status = acpi_ut_initialize_buffer (ret_buffer, table_length);
    if (ACPI_FAILURE (status)) {
        return_ACPI_STATUS (status);
    }

    /* Copy the table to the buffer */

    ACPI_MEMCPY ((void *) ret_buffer->pointer, (void *) tbl_ptr, table_length);
    return_ACPI_STATUS (AE_OK);
}
Пример #4
0
acpi_status
acpi_get_table (
	acpi_table_type         table_type,
	u32                     instance,
	acpi_buffer             *ret_buffer)
{
	acpi_table_header       *tbl_ptr;
	acpi_status             status;
	u32                     ret_buf_len;


	FUNCTION_TRACE ("Acpi_get_table");


	/*
	 *  If we have a buffer, we must have a length too
	 */
	if ((instance == 0)                 ||
		(!ret_buffer)                   ||
		((!ret_buffer->pointer) && (ret_buffer->length))) {
		return_ACPI_STATUS (AE_BAD_PARAMETER);
	}

	/* Check the table type and instance */

	if ((table_type > ACPI_TABLE_MAX)   ||
		(IS_SINGLE_TABLE (acpi_gbl_acpi_table_data[table_type].flags) &&
		 instance > 1)) {
		return_ACPI_STATUS (AE_BAD_PARAMETER);
	}


	/* Get a pointer to the entire table */

	status = acpi_tb_get_table_ptr (table_type, instance, &tbl_ptr);
	if (ACPI_FAILURE (status)) {
		return_ACPI_STATUS (status);
	}

	/*
	 * Acpi_tb_get_table_ptr will return a NULL pointer if the
	 * table is not loaded.
	 */
	if (tbl_ptr == NULL) {
		return_ACPI_STATUS (AE_NOT_EXIST);
	}

	/*
	 * Got a table ptr, assume it's ok and copy it to the user's buffer
	 */
	if (table_type == ACPI_TABLE_RSDP) {
		/*
		 *  RSD PTR is the only "table" without a header
		 */
		ret_buf_len = sizeof (RSDP_DESCRIPTOR);
	}
	else {
		ret_buf_len = tbl_ptr->length;
	}

	/*
	 * Verify we have space in the caller's buffer for the table
	 */
	if (ret_buffer->length < ret_buf_len) {
		ret_buffer->length = ret_buf_len;
		return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
	}

	ret_buffer->length = ret_buf_len;

	MEMCPY ((void *) ret_buffer->pointer, (void *) tbl_ptr, ret_buf_len);

	return_ACPI_STATUS (AE_OK);
}