aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/resources/rslist.c
diff options
context:
space:
mode:
authorRobert Moore <Robert.Moore@intel.com>2005-09-16 16:51:15 -0400
committerLen Brown <len.brown@intel.com>2005-09-21 23:51:39 -0400
commitbda663d36b94c723153246a4231bbc0f1cd1836e (patch)
treecc9f75c1d010d1b99d29f13acd600b21eda5eec5 /drivers/acpi/resources/rslist.c
parentefb0372bbaf5b829ff8c39db372779928af542a7 (diff)
[ACPI] ACPICA 20050916
Fixed a problem within the Resource Manager where support for the Generic Register descriptor was not fully implemented. This descriptor is now fully recognized, parsed, disassembled, and displayed. Restructured the Resource Manager code to utilize table-driven dispatch and lookup, eliminating many of the large switch() statements. This reduces overall subsystem code size and code complexity. Affects the resource parsing and construction, disassembly, and debug dump output. Cleaned up and restructured the debug dump output for all resource descriptors. Improved readability of the output and reduced code size. Fixed a problem where changes to internal data structures caused the optional ACPI_MUTEX_DEBUG code to fail compilation if specified. Signed-off-by: Robert Moore <Robert.Moore@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/resources/rslist.c')
-rw-r--r--drivers/acpi/resources/rslist.c533
1 files changed, 173 insertions, 360 deletions
diff --git a/drivers/acpi/resources/rslist.c b/drivers/acpi/resources/rslist.c
index 103eb31c284e..87e75349dd0a 100644
--- a/drivers/acpi/resources/rslist.c
+++ b/drivers/acpi/resources/rslist.c
@@ -47,44 +47,143 @@
47#define _COMPONENT ACPI_RESOURCES 47#define _COMPONENT ACPI_RESOURCES
48ACPI_MODULE_NAME("rslist") 48ACPI_MODULE_NAME("rslist")
49 49
50/* Dispatch table for convert-to-stream functions */
51typedef
52acpi_status(*ACPI_STREAM_HANDLER) (struct acpi_resource * resource,
53 u8 ** output_buffer,
54 acpi_size * bytes_consumed);
55
56static ACPI_STREAM_HANDLER acpi_gbl_stream_dispatch[] = {
57 acpi_rs_irq_stream, /* ACPI_RSTYPE_IRQ */
58 acpi_rs_dma_stream, /* ACPI_RSTYPE_DMA */
59 acpi_rs_start_depend_fns_stream, /* ACPI_RSTYPE_START_DPF */
60 acpi_rs_end_depend_fns_stream, /* ACPI_RSTYPE_END_DPF */
61 acpi_rs_io_stream, /* ACPI_RSTYPE_IO */
62 acpi_rs_fixed_io_stream, /* ACPI_RSTYPE_FIXED_IO */
63 acpi_rs_vendor_stream, /* ACPI_RSTYPE_VENDOR */
64 acpi_rs_end_tag_stream, /* ACPI_RSTYPE_END_TAG */
65 acpi_rs_memory24_stream, /* ACPI_RSTYPE_MEM24 */
66 acpi_rs_memory32_range_stream, /* ACPI_RSTYPE_MEM32 */
67 acpi_rs_fixed_memory32_stream, /* ACPI_RSTYPE_FIXED_MEM32 */
68 acpi_rs_address16_stream, /* ACPI_RSTYPE_ADDRESS16 */
69 acpi_rs_address32_stream, /* ACPI_RSTYPE_ADDRESS32 */
70 acpi_rs_address64_stream, /* ACPI_RSTYPE_ADDRESS64 */
71 acpi_rs_extended_irq_stream, /* ACPI_RSTYPE_EXT_IRQ */
72 acpi_rs_generic_register_stream /* ACPI_RSTYPE_GENERIC_REG */
73};
74
75/* Dispatch tables for convert-to-resource functions */
76
77typedef
78acpi_status(*ACPI_RESOURCE_HANDLER) (u8 * byte_stream_buffer,
79 acpi_size * bytes_consumed,
80 u8 ** output_buffer,
81 acpi_size * structure_size);
82
83static ACPI_RESOURCE_HANDLER acpi_gbl_sm_resource_dispatch[] = {
84 NULL, /* 0x00, Reserved */
85 NULL, /* 0x01, Reserved */
86 NULL, /* 0x02, Reserved */
87 NULL, /* 0x03, Reserved */
88 acpi_rs_irq_resource, /* ACPI_RDESC_TYPE_IRQ_FORMAT */
89 acpi_rs_dma_resource, /* ACPI_RDESC_TYPE_DMA_FORMAT */
90 acpi_rs_start_depend_fns_resource, /* ACPI_RDESC_TYPE_START_DEPENDENT */
91 acpi_rs_end_depend_fns_resource, /* ACPI_RDESC_TYPE_END_DEPENDENT */
92 acpi_rs_io_resource, /* ACPI_RDESC_TYPE_IO_PORT */
93 acpi_rs_fixed_io_resource, /* ACPI_RDESC_TYPE_FIXED_IO_PORT */
94 NULL, /* 0x0A, Reserved */
95 NULL, /* 0x0B, Reserved */
96 NULL, /* 0x0C, Reserved */
97 NULL, /* 0x0D, Reserved */
98 acpi_rs_vendor_resource, /* ACPI_RDESC_TYPE_SMALL_VENDOR */
99 acpi_rs_end_tag_resource /* ACPI_RDESC_TYPE_END_TAG */
100};
101
102static ACPI_RESOURCE_HANDLER acpi_gbl_lg_resource_dispatch[] = {
103 NULL, /* 0x00, Reserved */
104 acpi_rs_memory24_resource, /* ACPI_RDESC_TYPE_MEMORY_24 */
105 acpi_rs_generic_register_resource, /* ACPI_RDESC_TYPE_GENERIC_REGISTER */
106 NULL, /* 0x03, Reserved */
107 acpi_rs_vendor_resource, /* ACPI_RDESC_TYPE_LARGE_VENDOR */
108 acpi_rs_memory32_range_resource, /* ACPI_RDESC_TYPE_MEMORY_32 */
109 acpi_rs_fixed_memory32_resource, /* ACPI_RDESC_TYPE_FIXED_MEMORY_32 */
110 acpi_rs_address32_resource, /* ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE */
111 acpi_rs_address16_resource, /* ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE */
112 acpi_rs_extended_irq_resource, /* ACPI_RDESC_TYPE_EXTENDED_XRUPT */
113 acpi_rs_address64_resource, /* ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE */
114 acpi_rs_address64_resource /* ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE */
115};
116
117/* Local prototypes */
118
119static ACPI_RESOURCE_HANDLER acpi_rs_get_resource_handler(u8 resource_type);
120
50/******************************************************************************* 121/*******************************************************************************
51 * 122 *
52 * FUNCTION: acpi_rs_get_resource_type 123 * FUNCTION: acpi_rs_get_resource_type
53 * 124 *
54 * PARAMETERS: resource_start_byte - Byte 0 of a resource descriptor 125 * PARAMETERS: resource_type - Byte 0 of a resource descriptor
55 * 126 *
56 * RETURN: The Resource Type with no extraneous bits 127 * RETURN: The Resource Type with no extraneous bits (except the large/
128 * small bit -- left alone)
57 * 129 *
58 * DESCRIPTION: Extract the Resource Type/Name from the first byte of 130 * DESCRIPTION: Extract the Resource Type/Name from the first byte of
59 * a resource descriptor. 131 * a resource descriptor.
60 * 132 *
61 ******************************************************************************/ 133 ******************************************************************************/
62u8 acpi_rs_get_resource_type(u8 resource_start_byte)
63{
64 134
135u8 acpi_rs_get_resource_type(u8 resource_type)
136{
65 ACPI_FUNCTION_ENTRY(); 137 ACPI_FUNCTION_ENTRY();
66 138
67 /* Determine if this is a small or large resource */ 139 /* Determine if this is a small or large resource */
68 140
69 switch (resource_start_byte & ACPI_RDESC_TYPE_MASK) { 141 if (resource_type & ACPI_RDESC_TYPE_LARGE) {
70 case ACPI_RDESC_TYPE_SMALL: 142 /* Large Resource Type -- bits 6:0 contain the name */
143
144 return (resource_type);
145 } else {
146 /* Small Resource Type -- bits 6:3 contain the name */
147
148 return ((u8) (resource_type & ACPI_RDESC_SMALL_MASK));
149 }
150}
151
152/*******************************************************************************
153 *
154 * FUNCTION: acpi_rs_get_resource_handler
155 *
156 * PARAMETERS: resource_type - Byte 0 of a resource descriptor
157 *
158 * RETURN: Pointer to the resource conversion handler
159 *
160 * DESCRIPTION: Extract the Resource Type/Name from the first byte of
161 * a resource descriptor.
162 *
163 ******************************************************************************/
71 164
72 /* Small Resource Type -- Only bits 6:3 are valid */ 165static ACPI_RESOURCE_HANDLER acpi_rs_get_resource_handler(u8 resource_type)
166{
167 ACPI_FUNCTION_ENTRY();
73 168
74 return ((u8) (resource_start_byte & ACPI_RDESC_SMALL_MASK)); 169 /* Determine if this is a small or large resource */
75 170
76 case ACPI_RDESC_TYPE_LARGE: 171 if (resource_type & ACPI_RDESC_TYPE_LARGE) {
172 /* Large Resource Type -- bits 6:0 contain the name */
77 173
78 /* Large Resource Type -- All bits are valid */ 174 if (resource_type > ACPI_RDESC_LARGE_MAX) {
175 return (NULL);
176 }
79 177
80 return (resource_start_byte); 178 return (acpi_gbl_lg_resource_dispatch[(resource_type &
179 ACPI_RDESC_LARGE_MASK)]);
180 } else {
181 /* Small Resource Type -- bits 6:3 contain the name */
81 182
82 default: 183 return (acpi_gbl_sm_resource_dispatch[((resource_type &
83 /* Invalid type */ 184 ACPI_RDESC_SMALL_MASK)
84 break; 185 >> 3)]);
85 } 186 }
86
87 return (0xFF);
88} 187}
89 188
90/******************************************************************************* 189/*******************************************************************************
@@ -107,228 +206,70 @@ acpi_status
107acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer, 206acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer,
108 u32 byte_stream_buffer_length, u8 * output_buffer) 207 u32 byte_stream_buffer_length, u8 * output_buffer)
109{ 208{
209 u8 *buffer = output_buffer;
110 acpi_status status; 210 acpi_status status;
111 acpi_size bytes_parsed = 0; 211 acpi_size bytes_parsed = 0;
112 u8 resource_type = 0;
113 acpi_size bytes_consumed = 0; 212 acpi_size bytes_consumed = 0;
114 u8 *buffer = output_buffer;
115 acpi_size structure_size = 0; 213 acpi_size structure_size = 0;
116 u8 end_tag_processed = FALSE;
117 struct acpi_resource *resource; 214 struct acpi_resource *resource;
215 ACPI_RESOURCE_HANDLER handler;
118 216
119 ACPI_FUNCTION_TRACE("rs_byte_stream_to_list"); 217 ACPI_FUNCTION_TRACE("rs_byte_stream_to_list");
120 218
121 while (bytes_parsed < byte_stream_buffer_length && !end_tag_processed) { 219 /* Loop until end-of-buffer or an end_tag is found */
122 /* The next byte in the stream is the resource type */ 220
123 221 while (bytes_parsed < byte_stream_buffer_length) {
124 resource_type = acpi_rs_get_resource_type(*byte_stream_buffer); 222 /* Get the handler associated with this Descriptor Type */
125 223
126 switch (resource_type) { 224 handler = acpi_rs_get_resource_handler(*byte_stream_buffer);
127 case ACPI_RDESC_TYPE_MEMORY_24: 225 if (handler) {
128 /* 226 /* Convert a byte stream resource to local resource struct */
129 * 24-Bit Memory Resource 227
130 */ 228 status = handler(byte_stream_buffer, &bytes_consumed,
131 status = acpi_rs_memory24_resource(byte_stream_buffer, 229 &buffer, &structure_size);
132 &bytes_consumed, 230 } else {
133 &buffer, 231 /* Invalid resource type */
134 &structure_size); 232
135 break;
136
137 case ACPI_RDESC_TYPE_LARGE_VENDOR:
138 /*
139 * Vendor Defined Resource
140 */
141 status = acpi_rs_vendor_resource(byte_stream_buffer,
142 &bytes_consumed,
143 &buffer,
144 &structure_size);
145 break;
146
147 case ACPI_RDESC_TYPE_MEMORY_32:
148 /*
149 * 32-Bit Memory Range Resource
150 */
151 status =
152 acpi_rs_memory32_range_resource(byte_stream_buffer,
153 &bytes_consumed,
154 &buffer,
155 &structure_size);
156 break;
157
158 case ACPI_RDESC_TYPE_FIXED_MEMORY_32:
159 /*
160 * 32-Bit Fixed Memory Resource
161 */
162 status =
163 acpi_rs_fixed_memory32_resource(byte_stream_buffer,
164 &bytes_consumed,
165 &buffer,
166 &structure_size);
167 break;
168
169 case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE:
170 case ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE:
171 /*
172 * 64-Bit Address Resource
173 */
174 status = acpi_rs_address64_resource(byte_stream_buffer,
175 &bytes_consumed,
176 &buffer,
177 &structure_size);
178 break;
179
180 case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE:
181 /*
182 * 32-Bit Address Resource
183 */
184 status = acpi_rs_address32_resource(byte_stream_buffer,
185 &bytes_consumed,
186 &buffer,
187 &structure_size);
188 break;
189
190 case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE:
191 /*
192 * 16-Bit Address Resource
193 */
194 status = acpi_rs_address16_resource(byte_stream_buffer,
195 &bytes_consumed,
196 &buffer,
197 &structure_size);
198 break;
199
200 case ACPI_RDESC_TYPE_EXTENDED_XRUPT:
201 /*
202 * Extended IRQ
203 */
204 status =
205 acpi_rs_extended_irq_resource(byte_stream_buffer,
206 &bytes_consumed,
207 &buffer,
208 &structure_size);
209 break;
210
211 case ACPI_RDESC_TYPE_IRQ_FORMAT:
212 /*
213 * IRQ Resource
214 */
215 status = acpi_rs_irq_resource(byte_stream_buffer,
216 &bytes_consumed, &buffer,
217 &structure_size);
218 break;
219
220 case ACPI_RDESC_TYPE_DMA_FORMAT:
221 /*
222 * DMA Resource
223 */
224 status = acpi_rs_dma_resource(byte_stream_buffer,
225 &bytes_consumed, &buffer,
226 &structure_size);
227 break;
228
229 case ACPI_RDESC_TYPE_START_DEPENDENT:
230 /*
231 * Start Dependent Functions Resource
232 */
233 status =
234 acpi_rs_start_depend_fns_resource
235 (byte_stream_buffer, &bytes_consumed, &buffer,
236 &structure_size);
237 break;
238
239 case ACPI_RDESC_TYPE_END_DEPENDENT:
240 /*
241 * End Dependent Functions Resource
242 */
243 status =
244 acpi_rs_end_depend_fns_resource(byte_stream_buffer,
245 &bytes_consumed,
246 &buffer,
247 &structure_size);
248 break;
249
250 case ACPI_RDESC_TYPE_IO_PORT:
251 /*
252 * IO Port Resource
253 */
254 status = acpi_rs_io_resource(byte_stream_buffer,
255 &bytes_consumed, &buffer,
256 &structure_size);
257 break;
258
259 case ACPI_RDESC_TYPE_FIXED_IO_PORT:
260 /*
261 * Fixed IO Port Resource
262 */
263 status = acpi_rs_fixed_io_resource(byte_stream_buffer,
264 &bytes_consumed,
265 &buffer,
266 &structure_size);
267 break;
268
269 case ACPI_RDESC_TYPE_SMALL_VENDOR:
270 /*
271 * Vendor Specific Resource
272 */
273 status = acpi_rs_vendor_resource(byte_stream_buffer,
274 &bytes_consumed,
275 &buffer,
276 &structure_size);
277 break;
278
279 case ACPI_RDESC_TYPE_END_TAG:
280 /*
281 * End Tag
282 */
283 end_tag_processed = TRUE;
284 status = acpi_rs_end_tag_resource(byte_stream_buffer,
285 &bytes_consumed,
286 &buffer,
287 &structure_size);
288 break;
289
290 default:
291 /*
292 * Invalid/Unknown resource type
293 */
294 status = AE_AML_INVALID_RESOURCE_TYPE; 233 status = AE_AML_INVALID_RESOURCE_TYPE;
295 break;
296 } 234 }
297 235
298 if (ACPI_FAILURE(status)) { 236 if (ACPI_FAILURE(status)) {
299 return_ACPI_STATUS(status); 237 return_ACPI_STATUS(status);
300 } 238 }
301 239
302 /* Update the return value and counter */ 240 /* Set the aligned length of the new resource descriptor */
303 241
304 bytes_parsed += bytes_consumed; 242 resource = ACPI_CAST_PTR(struct acpi_resource, buffer);
243 resource->length =
244 (u32) ACPI_ALIGN_RESOURCE_SIZE(resource->length);
305 245
306 /* Set the byte stream to point to the next resource */ 246 /* Normal exit on completion of an end_tag resource descriptor */
307 247
248 if (acpi_rs_get_resource_type(*byte_stream_buffer) ==
249 ACPI_RDESC_TYPE_END_TAG) {
250 return_ACPI_STATUS(AE_OK);
251 }
252
253 /* Update counter and point to the next input resource */
254
255 bytes_parsed += bytes_consumed;
308 byte_stream_buffer += bytes_consumed; 256 byte_stream_buffer += bytes_consumed;
309 257
310 /* Set the Buffer to the next structure */ 258 /* Point to the next structure in the output buffer */
311 259
312 resource = ACPI_CAST_PTR(struct acpi_resource, buffer);
313 resource->length =
314 (u32) ACPI_ALIGN_RESOURCE_SIZE(resource->length);
315 buffer += ACPI_ALIGN_RESOURCE_SIZE(structure_size); 260 buffer += ACPI_ALIGN_RESOURCE_SIZE(structure_size);
316 } 261 }
317 262
318 /* Check the reason for exiting the while loop */ 263 /* Completed buffer, but did not find an end_tag resource descriptor */
319 264
320 if (!end_tag_processed) { 265 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
321 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
322 }
323
324 return_ACPI_STATUS(AE_OK);
325} 266}
326 267
327/******************************************************************************* 268/*******************************************************************************
328 * 269 *
329 * FUNCTION: acpi_rs_list_to_byte_stream 270 * FUNCTION: acpi_rs_list_to_byte_stream
330 * 271 *
331 * PARAMETERS: linked_list - Pointer to the resource linked list 272 * PARAMETERS: Resource - Pointer to the resource linked list
332 * byte_steam_size_needed - Calculated size of the byte stream 273 * byte_steam_size_needed - Calculated size of the byte stream
333 * needed from calling 274 * needed from calling
334 * acpi_rs_get_byte_stream_length() 275 * acpi_rs_get_byte_stream_length()
@@ -346,180 +287,52 @@ acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer,
346 ******************************************************************************/ 287 ******************************************************************************/
347 288
348acpi_status 289acpi_status
349acpi_rs_list_to_byte_stream(struct acpi_resource *linked_list, 290acpi_rs_list_to_byte_stream(struct acpi_resource *resource,
350 acpi_size byte_stream_size_needed, 291 acpi_size byte_stream_size_needed,
351 u8 * output_buffer) 292 u8 * output_buffer)
352{ 293{
353 acpi_status status;
354 u8 *buffer = output_buffer; 294 u8 *buffer = output_buffer;
355 acpi_size bytes_consumed = 0; 295 acpi_size bytes_consumed = 0;
356 u8 done = FALSE; 296 acpi_status status;
357 297
358 ACPI_FUNCTION_TRACE("rs_list_to_byte_stream"); 298 ACPI_FUNCTION_TRACE("rs_list_to_byte_stream");
359 299
360 while (!done) { 300 /* Convert each resource descriptor in the list */
361 switch (linked_list->id) {
362 case ACPI_RSTYPE_IRQ:
363 /*
364 * IRQ Resource
365 */
366 status =
367 acpi_rs_irq_stream(linked_list, &buffer,
368 &bytes_consumed);
369 break;
370
371 case ACPI_RSTYPE_DMA:
372 /*
373 * DMA Resource
374 */
375 status =
376 acpi_rs_dma_stream(linked_list, &buffer,
377 &bytes_consumed);
378 break;
379
380 case ACPI_RSTYPE_START_DPF:
381 /*
382 * Start Dependent Functions Resource
383 */
384 status = acpi_rs_start_depend_fns_stream(linked_list,
385 &buffer,
386 &bytes_consumed);
387 break;
388
389 case ACPI_RSTYPE_END_DPF:
390 /*
391 * End Dependent Functions Resource
392 */
393 status = acpi_rs_end_depend_fns_stream(linked_list,
394 &buffer,
395 &bytes_consumed);
396 break;
397
398 case ACPI_RSTYPE_IO:
399 /*
400 * IO Port Resource
401 */
402 status =
403 acpi_rs_io_stream(linked_list, &buffer,
404 &bytes_consumed);
405 break;
406
407 case ACPI_RSTYPE_FIXED_IO:
408 /*
409 * Fixed IO Port Resource
410 */
411 status =
412 acpi_rs_fixed_io_stream(linked_list, &buffer,
413 &bytes_consumed);
414 break;
415
416 case ACPI_RSTYPE_VENDOR:
417 /*
418 * Vendor Defined Resource
419 */
420 status =
421 acpi_rs_vendor_stream(linked_list, &buffer,
422 &bytes_consumed);
423 break;
424
425 case ACPI_RSTYPE_END_TAG:
426 /*
427 * End Tag
428 */
429 status =
430 acpi_rs_end_tag_stream(linked_list, &buffer,
431 &bytes_consumed);
432 301
433 /* An End Tag indicates the end of the Resource Template */ 302 while (1) {
303 /* Validate Type before dispatch */
434 304
435 done = TRUE; 305 if (resource->type > ACPI_RSTYPE_MAX) {
436 break;
437
438 case ACPI_RSTYPE_MEM24:
439 /*
440 * 24-Bit Memory Resource
441 */
442 status =
443 acpi_rs_memory24_stream(linked_list, &buffer,
444 &bytes_consumed);
445 break;
446
447 case ACPI_RSTYPE_MEM32:
448 /*
449 * 32-Bit Memory Range Resource
450 */
451 status =
452 acpi_rs_memory32_range_stream(linked_list, &buffer,
453 &bytes_consumed);
454 break;
455
456 case ACPI_RSTYPE_FIXED_MEM32:
457 /*
458 * 32-Bit Fixed Memory Resource
459 */
460 status =
461 acpi_rs_fixed_memory32_stream(linked_list, &buffer,
462 &bytes_consumed);
463 break;
464
465 case ACPI_RSTYPE_ADDRESS16:
466 /*
467 * 16-Bit Address Descriptor Resource
468 */
469 status = acpi_rs_address16_stream(linked_list, &buffer,
470 &bytes_consumed);
471 break;
472
473 case ACPI_RSTYPE_ADDRESS32:
474 /*
475 * 32-Bit Address Descriptor Resource
476 */
477 status = acpi_rs_address32_stream(linked_list, &buffer,
478 &bytes_consumed);
479 break;
480
481 case ACPI_RSTYPE_ADDRESS64:
482 /*
483 * 64-Bit Address Descriptor Resource
484 */
485 status = acpi_rs_address64_stream(linked_list, &buffer,
486 &bytes_consumed);
487 break;
488
489 case ACPI_RSTYPE_EXT_IRQ:
490 /*
491 * Extended IRQ Resource
492 */
493 status =
494 acpi_rs_extended_irq_stream(linked_list, &buffer,
495 &bytes_consumed);
496 break;
497
498 default:
499 /*
500 * If we get here, everything is out of sync,
501 * so exit with an error
502 */
503 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 306 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
504 "Invalid descriptor type (%X) in resource list\n", 307 "Invalid descriptor type (%X) in resource list\n",
505 linked_list->id)); 308 resource->type));
506 status = AE_BAD_DATA; 309 return_ACPI_STATUS(AE_BAD_DATA);
507 break;
508 } 310 }
509 311
312 /* Perform the conversion, per resource type */
313
314 status = acpi_gbl_stream_dispatch[resource->type] (resource,
315 &buffer,
316 &bytes_consumed);
510 if (ACPI_FAILURE(status)) { 317 if (ACPI_FAILURE(status)) {
511 return_ACPI_STATUS(status); 318 return_ACPI_STATUS(status);
512 } 319 }
513 320
514 /* Set the Buffer to point to the open byte */ 321 /* Check for end-of-list */
322
323 if (resource->type == ACPI_RSTYPE_END_TAG) {
324 /* An End Tag indicates the end of the Resource Template */
325
326 return_ACPI_STATUS(AE_OK);
327 }
328
329 /* Set the Buffer to point to the next (output) resource descriptor */
515 330
516 buffer += bytes_consumed; 331 buffer += bytes_consumed;
517 332
518 /* Point to the next object */ 333 /* Point to the next input resource object */
519 334
520 linked_list = ACPI_PTR_ADD(struct acpi_resource, 335 resource = ACPI_PTR_ADD(struct acpi_resource,
521 linked_list, linked_list->length); 336 resource, resource->length);
522 } 337 }
523
524 return_ACPI_STATUS(AE_OK);
525} 338}