*
* FUNCTION: acpi_rs_convert_aml_to_resources
*
- * PARAMETERS: acpi_walk_aml_callback
- * resource_ptr - Pointer to the buffer that will
- * contain the output structures
+ * PARAMETERS: Aml - Pointer to the resource byte stream
+ * aml_length - Length of Aml
+ * output_buffer - Pointer to the buffer that will
+ * contain the output structures
*
* RETURN: Status
*
- * DESCRIPTION: Convert an AML resource to an internal representation of the
- * resource that is aligned and easier to access.
+ * DESCRIPTION: Takes the resource byte stream and parses it, creating a
+ * linked list of resources in the caller's output buffer
*
******************************************************************************/
acpi_status
-acpi_rs_convert_aml_to_resources(u8 * aml,
- u32 length,
- u32 offset, u8 resource_index, void **context)
+acpi_rs_convert_aml_to_resources(u8 * aml, u32 aml_length, u8 * output_buffer)
{
- struct acpi_resource **resource_ptr =
- ACPI_CAST_INDIRECT_PTR(struct acpi_resource, context);
- struct acpi_resource *resource;
+ struct acpi_resource *resource = (void *)output_buffer;
acpi_status status;
+ u8 resource_index;
+ u8 *end_aml;
- ACPI_FUNCTION_TRACE(rs_convert_aml_to_resources);
+ ACPI_FUNCTION_TRACE("rs_convert_aml_to_resources");
- /*
- * Check that the input buffer and all subsequent pointers into it
- * are aligned on a native word boundary. Most important on IA64
- */
- resource = *resource_ptr;
- if (ACPI_IS_MISALIGNED(resource)) {
- ACPI_WARNING((AE_INFO,
- "Misaligned resource pointer %p", resource));
- }
+ end_aml = aml + aml_length;
- /* Convert the AML byte stream resource to a local resource struct */
-
- status =
- acpi_rs_convert_aml_to_resource(resource,
- ACPI_CAST_PTR(union aml_resource,
- aml),
- acpi_gbl_get_resource_dispatch
- [resource_index]);
- if (ACPI_FAILURE(status)) {
- ACPI_EXCEPTION((AE_INFO, status,
- "Could not convert AML resource (Type %X)",
- *aml));
- return_ACPI_STATUS(status);
- }
+ /* Loop until end-of-buffer or an end_tag is found */
+
+ while (aml < end_aml) {
+ /* Validate the Resource Type and Resource Length */
+
+ status = acpi_ut_validate_resource(aml, &resource_index);
+ if (ACPI_FAILURE(status)) {
+ return_ACPI_STATUS(status);
+ }
+
+ /* Convert the AML byte stream resource to a local resource struct */
- ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
- "Type %.2X, AmlLength %.2X InternalLength %.2X\n",
- acpi_ut_get_resource_type(aml), length,
- resource->length));
+ status =
+ acpi_rs_convert_aml_to_resource(resource,
+ ACPI_CAST_PTR(union
+ aml_resource,
+ aml),
+ acpi_gbl_get_resource_dispatch
+ [resource_index]);
+ if (ACPI_FAILURE(status)) {
+ ACPI_EXCEPTION((AE_INFO, status,
+ "Could not convert AML resource (Type %X)",
+ *aml));
+ return_ACPI_STATUS(status);
+ }
- /* Point to the next structure in the output buffer */
+ /* Normal exit on completion of an end_tag resource descriptor */
- *resource_ptr = ACPI_ADD_PTR(void, resource, resource->length);
- return_ACPI_STATUS(AE_OK);
+ if (acpi_ut_get_resource_type(aml) ==
+ ACPI_RESOURCE_NAME_END_TAG) {
+ return_ACPI_STATUS(AE_OK);
+ }
+
+ /* Point to the next input AML resource */
+
+ aml += acpi_ut_get_descriptor_length(aml);
+
+ /* Point to the next structure in the output buffer */
+
+ resource =
+ ACPI_ADD_PTR(struct acpi_resource, resource,
+ resource->length);
+ }
+
+ /* Did not find an end_tag resource descriptor */
+
+ return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
}
/*******************************************************************************
u8 *end_aml = output_buffer + aml_size_needed;
acpi_status status;
- ACPI_FUNCTION_TRACE(rs_convert_resources_to_aml);
+ ACPI_FUNCTION_TRACE("rs_convert_resources_to_aml");
/* Walk the resource descriptor list, convert each descriptor */
while (aml < end_aml) {
-
/* Validate the (internal) Resource Type */
if (resource->type > ACPI_RESOURCE_TYPE_MAX) {
/* Check for end-of-list, normal exit */
if (resource->type == ACPI_RESOURCE_TYPE_END_TAG) {
-
/* An End Tag indicates the end of the input Resource Template */
return_ACPI_STATUS(AE_OK);