ACPICA: Resources: New interface, AcpiWalkResourceBuffer.

Implements a new interface for walking resource lists that it at
a lower level than the existing AcpiWalkResources.  (Method is
not executed.)

Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
Bob Moore 2012-12-31 00:03:58 +00:00 committed by Rafael J. Wysocki
parent 1cd4e951e5
commit afb1bbee80
3 changed files with 79 additions and 31 deletions

View file

@ -423,7 +423,7 @@ ACPI_EXPORT_SYMBOL(acpi_resource_to_address64)
* *
* RETURN: Status * RETURN: Status
* *
* DESCRIPTION: Walk a resource template for the specified evice to find a * DESCRIPTION: Walk a resource template for the specified device to find a
* vendor-defined resource that matches the supplied UUID and * vendor-defined resource that matches the supplied UUID and
* UUID subtype. Returns a struct acpi_resource of type Vendor. * UUID subtype. Returns a struct acpi_resource of type Vendor.
* *
@ -522,57 +522,42 @@ acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context)
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_walk_resources * FUNCTION: acpi_walk_resource_buffer
* *
* PARAMETERS: device_handle - Handle to the device object for the * PARAMETERS: buffer - Formatted buffer returned by one of the
* device we are querying * various Get*Resource functions
* name - Method name of the resources we want.
* (METHOD_NAME__CRS, METHOD_NAME__PRS, or
* METHOD_NAME__AEI)
* user_function - Called for each resource * user_function - Called for each resource
* context - Passed to user_function * context - Passed to user_function
* *
* RETURN: Status * RETURN: Status
* *
* DESCRIPTION: Retrieves the current or possible resource list for the * DESCRIPTION: Walks the input resource template. The user_function is called
* specified device. The user_function is called once for * once for each resource in the list.
* each resource in the list.
* *
******************************************************************************/ ******************************************************************************/
acpi_status acpi_status
acpi_walk_resources(acpi_handle device_handle, acpi_walk_resource_buffer(struct acpi_buffer * buffer,
char *name, acpi_walk_resource_callback user_function,
acpi_walk_resource_callback user_function, void *context) void *context)
{ {
acpi_status status; acpi_status status = AE_OK;
struct acpi_buffer buffer;
struct acpi_resource *resource; struct acpi_resource *resource;
struct acpi_resource *resource_end; struct acpi_resource *resource_end;
ACPI_FUNCTION_TRACE(acpi_walk_resources); ACPI_FUNCTION_TRACE(acpi_walk_resource_buffer);
/* Parameter validation */ /* Parameter validation */
if (!device_handle || !user_function || !name || if (!buffer || !buffer->pointer || !user_function) {
(!ACPI_COMPARE_NAME(name, METHOD_NAME__CRS) &&
!ACPI_COMPARE_NAME(name, METHOD_NAME__PRS) &&
!ACPI_COMPARE_NAME(name, METHOD_NAME__AEI))) {
return_ACPI_STATUS(AE_BAD_PARAMETER); return_ACPI_STATUS(AE_BAD_PARAMETER);
} }
/* Get the _CRS/_PRS/_AEI resource list */ /* Buffer contains the resource list and length */
buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; resource = ACPI_CAST_PTR(struct acpi_resource, buffer->pointer);
status = acpi_rs_get_method_data(device_handle, name, &buffer);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* Buffer now contains the resource list */
resource = ACPI_CAST_PTR(struct acpi_resource, buffer.pointer);
resource_end = resource_end =
ACPI_ADD_PTR(struct acpi_resource, buffer.pointer, buffer.length); ACPI_ADD_PTR(struct acpi_resource, buffer->pointer, buffer->length);
/* Walk the resource list until the end_tag is found (or buffer end) */ /* Walk the resource list until the end_tag is found (or buffer end) */
@ -609,6 +594,60 @@ acpi_walk_resources(acpi_handle device_handle,
resource = ACPI_NEXT_RESOURCE(resource); resource = ACPI_NEXT_RESOURCE(resource);
} }
return_ACPI_STATUS(status);
}
ACPI_EXPORT_SYMBOL(acpi_walk_resource_buffer)
/*******************************************************************************
*
* FUNCTION: acpi_walk_resources
*
* PARAMETERS: device_handle - Handle to the device object for the
* device we are querying
* name - Method name of the resources we want.
* (METHOD_NAME__CRS, METHOD_NAME__PRS, or
* METHOD_NAME__AEI)
* user_function - Called for each resource
* context - Passed to user_function
*
* RETURN: Status
*
* DESCRIPTION: Retrieves the current or possible resource list for the
* specified device. The user_function is called once for
* each resource in the list.
*
******************************************************************************/
acpi_status
acpi_walk_resources(acpi_handle device_handle,
char *name,
acpi_walk_resource_callback user_function, void *context)
{
acpi_status status;
struct acpi_buffer buffer;
ACPI_FUNCTION_TRACE(acpi_walk_resources);
/* Parameter validation */
if (!device_handle || !user_function || !name ||
(!ACPI_COMPARE_NAME(name, METHOD_NAME__CRS) &&
!ACPI_COMPARE_NAME(name, METHOD_NAME__PRS) &&
!ACPI_COMPARE_NAME(name, METHOD_NAME__AEI))) {
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
/* Get the _CRS/_PRS/_AEI resource list */
buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
status = acpi_rs_get_method_data(device_handle, name, &buffer);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* Walk the resource list and cleanup */
status = acpi_walk_resource_buffer(&buffer, user_function, context);
ACPI_FREE(buffer.pointer); ACPI_FREE(buffer.pointer);
return_ACPI_STATUS(status); return_ACPI_STATUS(status);
} }

View file

@ -443,6 +443,11 @@ acpi_status
acpi_get_event_resources(acpi_handle device_handle, acpi_get_event_resources(acpi_handle device_handle,
struct acpi_buffer *ret_buffer); struct acpi_buffer *ret_buffer);
acpi_status
acpi_walk_resource_buffer(struct acpi_buffer *buffer,
acpi_walk_resource_callback user_function,
void *context);
acpi_status acpi_status
acpi_walk_resources(acpi_handle device, acpi_walk_resources(acpi_handle device,
char *name, char *name,

View file

@ -881,6 +881,10 @@ struct acpi_buffer {
void *pointer; /* pointer to buffer */ void *pointer; /* pointer to buffer */
}; };
/* Free a buffer created in an struct acpi_buffer via ACPI_ALLOCATE_LOCAL_BUFFER */
#define ACPI_FREE_BUFFER(b) ACPI_FREE(b.pointer)
/* /*
* name_type for acpi_get_name * name_type for acpi_get_name
*/ */