aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/resources/rslist.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/resources/rslist.c')
-rw-r--r--drivers/acpi/resources/rslist.c102
1 files changed, 45 insertions, 57 deletions
diff --git a/drivers/acpi/resources/rslist.c b/drivers/acpi/resources/rslist.c
index 1434e786477e..29423ce030ca 100644
--- a/drivers/acpi/resources/rslist.c
+++ b/drivers/acpi/resources/rslist.c
@@ -51,76 +51,62 @@ ACPI_MODULE_NAME("rslist")
51 * 51 *
52 * FUNCTION: acpi_rs_convert_aml_to_resources 52 * FUNCTION: acpi_rs_convert_aml_to_resources
53 * 53 *
54 * PARAMETERS: Aml - Pointer to the resource byte stream 54 * PARAMETERS: acpi_walk_aml_callback
55 * aml_length - Length of Aml 55 * resource_ptr - Pointer to the buffer that will
56 * output_buffer - Pointer to the buffer that will 56 * contain the output structures
57 * contain the output structures
58 * 57 *
59 * RETURN: Status 58 * RETURN: Status
60 * 59 *
61 * DESCRIPTION: Takes the resource byte stream and parses it, creating a 60 * DESCRIPTION: Convert an AML resource to an internal representation of the
62 * linked list of resources in the caller's output buffer 61 * resource that is aligned and easier to access.
63 * 62 *
64 ******************************************************************************/ 63 ******************************************************************************/
65acpi_status 64acpi_status
66acpi_rs_convert_aml_to_resources(u8 * aml, u32 aml_length, u8 * output_buffer) 65acpi_rs_convert_aml_to_resources(u8 * aml,
66 u32 length,
67 u32 offset, u8 resource_index, void **context)
67{ 68{
68 struct acpi_resource *resource = (void *)output_buffer; 69 struct acpi_resource **resource_ptr =
70 ACPI_CAST_INDIRECT_PTR(struct acpi_resource, context);
71 struct acpi_resource *resource;
69 acpi_status status; 72 acpi_status status;
70 u8 resource_index;
71 u8 *end_aml;
72
73 ACPI_FUNCTION_TRACE("rs_convert_aml_to_resources");
74
75 end_aml = aml + aml_length;
76
77 /* Loop until end-of-buffer or an end_tag is found */
78
79 while (aml < end_aml) {
80 /* Validate the Resource Type and Resource Length */
81
82 status = acpi_ut_validate_resource(aml, &resource_index);
83 if (ACPI_FAILURE(status)) {
84 return_ACPI_STATUS(status);
85 }
86 73
87 /* Convert the AML byte stream resource to a local resource struct */ 74 ACPI_FUNCTION_TRACE(rs_convert_aml_to_resources);
88
89 status =
90 acpi_rs_convert_aml_to_resource(resource,
91 ACPI_CAST_PTR(union
92 aml_resource,
93 aml),
94 acpi_gbl_get_resource_dispatch
95 [resource_index]);
96 if (ACPI_FAILURE(status)) {
97 ACPI_EXCEPTION((AE_INFO, status,
98 "Could not convert AML resource (Type %X)",
99 *aml));
100 return_ACPI_STATUS(status);
101 }
102 75
103 /* Normal exit on completion of an end_tag resource descriptor */ 76 /*
104 77 * Check that the input buffer and all subsequent pointers into it
105 if (acpi_ut_get_resource_type(aml) == 78 * are aligned on a native word boundary. Most important on IA64
106 ACPI_RESOURCE_NAME_END_TAG) { 79 */
107 return_ACPI_STATUS(AE_OK); 80 resource = *resource_ptr;
108 } 81 if (ACPI_IS_MISALIGNED(resource)) {
109 82 ACPI_WARNING((AE_INFO,
110 /* Point to the next input AML resource */ 83 "Misaligned resource pointer %p", resource));
111 84 }
112 aml += acpi_ut_get_descriptor_length(aml);
113
114 /* Point to the next structure in the output buffer */
115 85
116 resource = 86 /* Convert the AML byte stream resource to a local resource struct */
117 ACPI_ADD_PTR(struct acpi_resource, resource, 87
118 resource->length); 88 status =
89 acpi_rs_convert_aml_to_resource(resource,
90 ACPI_CAST_PTR(union aml_resource,
91 aml),
92 acpi_gbl_get_resource_dispatch
93 [resource_index]);
94 if (ACPI_FAILURE(status)) {
95 ACPI_EXCEPTION((AE_INFO, status,
96 "Could not convert AML resource (Type %X)",
97 *aml));
98 return_ACPI_STATUS(status);
119 } 99 }
120 100
121 /* Did not find an end_tag resource descriptor */ 101 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
102 "Type %.2X, AmlLength %.2X InternalLength %.2X\n",
103 acpi_ut_get_resource_type(aml), length,
104 resource->length));
122 105
123 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); 106 /* Point to the next structure in the output buffer */
107
108 *resource_ptr = ACPI_ADD_PTR(void, resource, resource->length);
109 return_ACPI_STATUS(AE_OK);
124} 110}
125 111
126/******************************************************************************* 112/*******************************************************************************
@@ -150,11 +136,12 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
150 u8 *end_aml = output_buffer + aml_size_needed; 136 u8 *end_aml = output_buffer + aml_size_needed;
151 acpi_status status; 137 acpi_status status;
152 138
153 ACPI_FUNCTION_TRACE("rs_convert_resources_to_aml"); 139 ACPI_FUNCTION_TRACE(rs_convert_resources_to_aml);
154 140
155 /* Walk the resource descriptor list, convert each descriptor */ 141 /* Walk the resource descriptor list, convert each descriptor */
156 142
157 while (aml < end_aml) { 143 while (aml < end_aml) {
144
158 /* Validate the (internal) Resource Type */ 145 /* Validate the (internal) Resource Type */
159 146
160 if (resource->type > ACPI_RESOURCE_TYPE_MAX) { 147 if (resource->type > ACPI_RESOURCE_TYPE_MAX) {
@@ -191,6 +178,7 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
191 /* Check for end-of-list, normal exit */ 178 /* Check for end-of-list, normal exit */
192 179
193 if (resource->type == ACPI_RESOURCE_TYPE_END_TAG) { 180 if (resource->type == ACPI_RESOURCE_TYPE_END_TAG) {
181
194 /* An End Tag indicates the end of the input Resource Template */ 182 /* An End Tag indicates the end of the input Resource Template */
195 183
196 return_ACPI_STATUS(AE_OK); 184 return_ACPI_STATUS(AE_OK);