/******************************************************************************* * * 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); return_ACPI_STATUS(status); }
acpi_status acpi_walk_resources ( acpi_handle device_handle, char *path, ACPI_WALK_RESOURCE_CALLBACK user_function, void *context) { acpi_status status; struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; struct acpi_resource *resource; struct acpi_resource *buffer_end; ACPI_FUNCTION_TRACE ("acpi_walk_resources"); if (!device_handle || (ACPI_STRNCMP (path, METHOD_NAME__CRS, sizeof (METHOD_NAME__CRS)) && ACPI_STRNCMP (path, METHOD_NAME__PRS, sizeof (METHOD_NAME__PRS)))) { return_ACPI_STATUS (AE_BAD_PARAMETER); } status = acpi_rs_get_method_data (device_handle, path, &buffer); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } /* Setup pointers */ resource = (struct acpi_resource *) buffer.pointer; buffer_end = ACPI_CAST_PTR (struct acpi_resource, ((u8 *) buffer.pointer + buffer.length)); /* Walk the resource list */ for (;;) { if (!resource || resource->id == ACPI_RSTYPE_END_TAG) { break; } status = user_function (resource, context); switch (status) { case AE_OK: case AE_CTRL_DEPTH: /* Just keep going */ status = AE_OK; break; case AE_CTRL_TERMINATE: /* Exit now, with OK stats */ status = AE_OK; goto cleanup; default: /* All others are valid exceptions */ goto cleanup; } /* Get the next resource descriptor */ resource = ACPI_NEXT_RESOURCE (resource); /* Check for end-of-buffer */ if (resource >= buffer_end) { goto cleanup; } } cleanup: acpi_os_free (buffer.pointer); return_ACPI_STATUS (status); }
/******************************************************************************* * * 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 or METHOD_NAME__PRS) * 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; struct acpi_resource *resource; struct acpi_resource *resource_end; 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))) { return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Get the _CRS or _PRS 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); } /* Buffer now contains the resource list */ resource = ACPI_CAST_PTR(struct acpi_resource, buffer.pointer); resource_end = ACPI_ADD_PTR(struct acpi_resource, buffer.pointer, buffer.length); /* Walk the resource list until the end_tag is found (or buffer end) */ while (resource < resource_end) { /* Sanity check the resource */ if (resource->type > ACPI_RESOURCE_TYPE_MAX) { status = AE_AML_INVALID_RESOURCE_TYPE; break; } /* Invoke the user function, abort on any error returned */ status = user_function(resource, context); if (ACPI_FAILURE(status)) { if (status == AE_CTRL_TERMINATE) { /* This is an OK termination by the user function */ status = AE_OK; } break; } /* end_tag indicates end-of-list */ if (resource->type == ACPI_RESOURCE_TYPE_END_TAG) { break; } /* Get the next resource descriptor */ resource = ACPI_ADD_PTR(struct acpi_resource, resource, resource->length); } ACPI_FREE(buffer.pointer); return_ACPI_STATUS(status); }
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; struct acpi_resource *resource; struct acpi_resource *resource_end; ACPI_FUNCTION_TRACE(acpi_walk_resources); 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); } buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; status = acpi_rs_get_method_data(device_handle, name, &buffer); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } resource = ACPI_CAST_PTR(struct acpi_resource, buffer.pointer); resource_end = ACPI_ADD_PTR(struct acpi_resource, buffer.pointer, buffer.length); while (resource < resource_end) { if (resource->type > ACPI_RESOURCE_TYPE_MAX) { status = AE_AML_INVALID_RESOURCE_TYPE; break; } status = user_function(resource, context); if (ACPI_FAILURE(status)) { if (status == AE_CTRL_TERMINATE) { status = AE_OK; } break; } if (resource->type == ACPI_RESOURCE_TYPE_END_TAG) { break; } resource = ACPI_ADD_PTR(struct acpi_resource, resource, resource->length); } ACPI_FREE(buffer.pointer); return_ACPI_STATUS(status); }