aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/resources/rsmisc.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/rsmisc.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/rsmisc.c')
-rw-r--r--drivers/acpi/resources/rsmisc.c234
1 files changed, 198 insertions, 36 deletions
diff --git a/drivers/acpi/resources/rsmisc.c b/drivers/acpi/resources/rsmisc.c
index 7a8a34e757f5..fa7f5a85b61d 100644
--- a/drivers/acpi/resources/rsmisc.c
+++ b/drivers/acpi/resources/rsmisc.c
@@ -49,6 +49,169 @@ ACPI_MODULE_NAME("rsmisc")
49 49
50/******************************************************************************* 50/*******************************************************************************
51 * 51 *
52 * FUNCTION: acpi_rs_generic_register_resource
53 *
54 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
55 * stream
56 * bytes_consumed - Pointer to where the number of bytes
57 * consumed the byte_stream_buffer is
58 * returned
59 * output_buffer - Pointer to the return data buffer
60 * structure_size - Pointer to where the number of bytes
61 * in the return data struct is returned
62 *
63 * RETURN: Status
64 *
65 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
66 * structure pointed to by the output_buffer. Return the
67 * number of bytes consumed from the byte stream.
68 *
69 ******************************************************************************/
70acpi_status
71acpi_rs_generic_register_resource(u8 * byte_stream_buffer,
72 acpi_size * bytes_consumed,
73 u8 ** output_buffer,
74 acpi_size * structure_size)
75{
76 u8 *buffer = byte_stream_buffer;
77 struct acpi_resource *output_struct = (void *)*output_buffer;
78 u16 temp16;
79 u8 temp8;
80 acpi_size struct_size =
81 ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_reg);
82
83 ACPI_FUNCTION_TRACE("rs_generic_register_resource");
84
85 /* Byte 0 is the Descriptor Type */
86
87 buffer += 1;
88
89 /* Get the Descriptor Length field (Bytes 1-2) */
90
91 ACPI_MOVE_16_TO_16(&temp16, buffer);
92 buffer += 2;
93
94 /* Validate the descriptor length */
95
96 if (temp16 != 12) {
97 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
98 }
99
100 /* The number of bytes consumed is fixed (12 + 3) */
101
102 *bytes_consumed = 15;
103
104 /* Fill out the structure */
105
106 output_struct->type = ACPI_RSTYPE_GENERIC_REG;
107
108 /* Get space_id (Byte 3) */
109
110 temp8 = *buffer;
111 output_struct->data.generic_reg.space_id = temp8;
112 buffer += 1;
113
114 /* Get register_bit_width (Byte 4) */
115
116 temp8 = *buffer;
117 output_struct->data.generic_reg.bit_width = temp8;
118 buffer += 1;
119
120 /* Get register_bit_offset (Byte 5) */
121
122 temp8 = *buffer;
123 output_struct->data.generic_reg.bit_offset = temp8;
124 buffer += 1;
125
126 /* Get address_size (Byte 6) */
127
128 temp8 = *buffer;
129 output_struct->data.generic_reg.address_size = temp8;
130 buffer += 1;
131
132 /* Get register_address (Bytes 7-14) */
133
134 ACPI_MOVE_64_TO_64(&output_struct->data.generic_reg.address, buffer);
135
136 /* Set the Length parameter */
137
138 output_struct->length = (u32) struct_size;
139
140 /* Return the final size of the structure */
141
142 *structure_size = struct_size;
143 return_ACPI_STATUS(AE_OK);
144}
145
146/*******************************************************************************
147 *
148 * FUNCTION: acpi_rs_generic_register_stream
149 *
150 * PARAMETERS: Resource - Pointer to the resource linked list
151 * output_buffer - Pointer to the user's return buffer
152 * bytes_consumed - Pointer to where the number of bytes
153 * used in the output_buffer is returned
154 *
155 * RETURN: Status
156 *
157 * DESCRIPTION: Take the linked list resource structure and fills in the
158 * the appropriate bytes in a byte stream
159 *
160 ******************************************************************************/
161
162acpi_status
163acpi_rs_generic_register_stream(struct acpi_resource *resource,
164 u8 ** output_buffer, acpi_size * bytes_consumed)
165{
166 u8 *buffer = *output_buffer;
167 u16 temp16;
168
169 ACPI_FUNCTION_TRACE("rs_generic_register_stream");
170
171 /* Set the Descriptor Type (Byte 0) */
172
173 *buffer = ACPI_RDESC_TYPE_GENERIC_REGISTER;
174 buffer += 1;
175
176 /* Set the Descriptor Length (Bytes 1-2) */
177
178 temp16 = 12;
179 ACPI_MOVE_16_TO_16(buffer, &temp16);
180 buffer += 2;
181
182 /* Set space_id (Byte 3) */
183
184 *buffer = (u8) resource->data.generic_reg.space_id;
185 buffer += 1;
186
187 /* Set register_bit_width (Byte 4) */
188
189 *buffer = (u8) resource->data.generic_reg.bit_width;
190 buffer += 1;
191
192 /* Set register_bit_offset (Byte 5) */
193
194 *buffer = (u8) resource->data.generic_reg.bit_offset;
195 buffer += 1;
196
197 /* Set address_size (Byte 6) */
198
199 *buffer = (u8) resource->data.generic_reg.address_size;
200 buffer += 1;
201
202 /* Set register_address (Bytes 7-14) */
203
204 ACPI_MOVE_64_TO_64(buffer, &resource->data.generic_reg.address);
205 buffer += 8;
206
207 /* Return the number of bytes consumed in this operation */
208
209 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
210 return_ACPI_STATUS(AE_OK);
211}
212
213/*******************************************************************************
214 *
52 * FUNCTION: acpi_rs_end_tag_resource 215 * FUNCTION: acpi_rs_end_tag_resource
53 * 216 *
54 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 217 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
@@ -67,6 +230,7 @@ ACPI_MODULE_NAME("rsmisc")
67 * number of bytes consumed from the byte stream. 230 * number of bytes consumed from the byte stream.
68 * 231 *
69 ******************************************************************************/ 232 ******************************************************************************/
233
70acpi_status 234acpi_status
71acpi_rs_end_tag_resource(u8 * byte_stream_buffer, 235acpi_rs_end_tag_resource(u8 * byte_stream_buffer,
72 acpi_size * bytes_consumed, 236 acpi_size * bytes_consumed,
@@ -81,9 +245,9 @@ acpi_rs_end_tag_resource(u8 * byte_stream_buffer,
81 245
82 *bytes_consumed = 2; 246 *bytes_consumed = 2;
83 247
84 /* Fill out the structure */ 248 /* Fill out the structure */
85 249
86 output_struct->id = ACPI_RSTYPE_END_TAG; 250 output_struct->type = ACPI_RSTYPE_END_TAG;
87 251
88 /* Set the Length parameter */ 252 /* Set the Length parameter */
89 253
@@ -99,7 +263,7 @@ acpi_rs_end_tag_resource(u8 * byte_stream_buffer,
99 * 263 *
100 * FUNCTION: acpi_rs_end_tag_stream 264 * FUNCTION: acpi_rs_end_tag_stream
101 * 265 *
102 * PARAMETERS: linked_list - Pointer to the resource linked list 266 * PARAMETERS: Resource - Pointer to the resource linked list
103 * output_buffer - Pointer to the user's return buffer 267 * output_buffer - Pointer to the user's return buffer
104 * bytes_consumed - Pointer to where the number of bytes 268 * bytes_consumed - Pointer to where the number of bytes
105 * used in the output_buffer is returned 269 * used in the output_buffer is returned
@@ -112,7 +276,7 @@ acpi_rs_end_tag_resource(u8 * byte_stream_buffer,
112 ******************************************************************************/ 276 ******************************************************************************/
113 277
114acpi_status 278acpi_status
115acpi_rs_end_tag_stream(struct acpi_resource *linked_list, 279acpi_rs_end_tag_stream(struct acpi_resource *resource,
116 u8 ** output_buffer, acpi_size * bytes_consumed) 280 u8 ** output_buffer, acpi_size * bytes_consumed)
117{ 281{
118 u8 *buffer = *output_buffer; 282 u8 *buffer = *output_buffer;
@@ -120,9 +284,9 @@ acpi_rs_end_tag_stream(struct acpi_resource *linked_list,
120 284
121 ACPI_FUNCTION_TRACE("rs_end_tag_stream"); 285 ACPI_FUNCTION_TRACE("rs_end_tag_stream");
122 286
123 /* The descriptor field is static */ 287 /* The Descriptor Type field is static */
124 288
125 *buffer = 0x79; 289 *buffer = ACPI_RDESC_TYPE_END_TAG | 0x01;
126 buffer += 1; 290 buffer += 1;
127 291
128 /* 292 /*
@@ -180,7 +344,7 @@ acpi_rs_vendor_resource(u8 * byte_stream_buffer,
180 344
181 temp8 = *buffer; 345 temp8 = *buffer;
182 346
183 if (temp8 & 0x80) { 347 if (temp8 & ACPI_RDESC_TYPE_LARGE) {
184 /* Large Item, point to the length field */ 348 /* Large Item, point to the length field */
185 349
186 buffer += 1; 350 buffer += 1;
@@ -210,7 +374,7 @@ acpi_rs_vendor_resource(u8 * byte_stream_buffer,
210 buffer += 1; 374 buffer += 1;
211 } 375 }
212 376
213 output_struct->id = ACPI_RSTYPE_VENDOR; 377 output_struct->type = ACPI_RSTYPE_VENDOR;
214 output_struct->data.vendor_specific.length = temp16; 378 output_struct->data.vendor_specific.length = temp16;
215 379
216 for (index = 0; index < temp16; index++) { 380 for (index = 0; index < temp16; index++) {
@@ -239,7 +403,7 @@ acpi_rs_vendor_resource(u8 * byte_stream_buffer,
239 * 403 *
240 * FUNCTION: acpi_rs_vendor_stream 404 * FUNCTION: acpi_rs_vendor_stream
241 * 405 *
242 * PARAMETERS: linked_list - Pointer to the resource linked list 406 * PARAMETERS: Resource - Pointer to the resource linked list
243 * output_buffer - Pointer to the user's return buffer 407 * output_buffer - Pointer to the user's return buffer
244 * bytes_consumed - Pointer to where the number of bytes 408 * bytes_consumed - Pointer to where the number of bytes
245 * used in the output_buffer is returned 409 * used in the output_buffer is returned
@@ -252,7 +416,7 @@ acpi_rs_vendor_resource(u8 * byte_stream_buffer,
252 ******************************************************************************/ 416 ******************************************************************************/
253 417
254acpi_status 418acpi_status
255acpi_rs_vendor_stream(struct acpi_resource *linked_list, 419acpi_rs_vendor_stream(struct acpi_resource *resource,
256 u8 ** output_buffer, acpi_size * bytes_consumed) 420 u8 ** output_buffer, acpi_size * bytes_consumed)
257{ 421{
258 u8 *buffer = *output_buffer; 422 u8 *buffer = *output_buffer;
@@ -264,21 +428,21 @@ acpi_rs_vendor_stream(struct acpi_resource *linked_list,
264 428
265 /* Dereference the length to find if this is a large or small item. */ 429 /* Dereference the length to find if this is a large or small item. */
266 430
267 if (linked_list->data.vendor_specific.length > 7) { 431 if (resource->data.vendor_specific.length > 7) {
268 /* Large Item, Set the descriptor field and length bytes */ 432 /* Large Item, Set the descriptor field and length bytes */
269 433
270 *buffer = 0x84; 434 *buffer = ACPI_RDESC_TYPE_LARGE_VENDOR;
271 buffer += 1; 435 buffer += 1;
272 436
273 temp16 = (u16) linked_list->data.vendor_specific.length; 437 temp16 = (u16) resource->data.vendor_specific.length;
274 438
275 ACPI_MOVE_16_TO_16(buffer, &temp16); 439 ACPI_MOVE_16_TO_16(buffer, &temp16);
276 buffer += 2; 440 buffer += 2;
277 } else { 441 } else {
278 /* Small Item, Set the descriptor field */ 442 /* Small Item, Set the descriptor field */
279 443
280 temp8 = 0x70; 444 temp8 = ACPI_RDESC_TYPE_SMALL_VENDOR;
281 temp8 |= (u8) linked_list->data.vendor_specific.length; 445 temp8 |= (u8) resource->data.vendor_specific.length;
282 446
283 *buffer = temp8; 447 *buffer = temp8;
284 buffer += 1; 448 buffer += 1;
@@ -286,9 +450,8 @@ acpi_rs_vendor_stream(struct acpi_resource *linked_list,
286 450
287 /* Loop through all of the Vendor Specific fields */ 451 /* Loop through all of the Vendor Specific fields */
288 452
289 for (index = 0; index < linked_list->data.vendor_specific.length; 453 for (index = 0; index < resource->data.vendor_specific.length; index++) {
290 index++) { 454 temp8 = resource->data.vendor_specific.reserved[index];
291 temp8 = linked_list->data.vendor_specific.reserved[index];
292 455
293 *buffer = temp8; 456 *buffer = temp8;
294 buffer += 1; 457 buffer += 1;
@@ -341,7 +504,7 @@ acpi_rs_start_depend_fns_resource(u8 * byte_stream_buffer,
341 504
342 *bytes_consumed = (temp8 & 0x01) + 1; 505 *bytes_consumed = (temp8 & 0x01) + 1;
343 506
344 output_struct->id = ACPI_RSTYPE_START_DPF; 507 output_struct->type = ACPI_RSTYPE_START_DPF;
345 508
346 /* Point to Byte 1 if it is used */ 509 /* Point to Byte 1 if it is used */
347 510
@@ -421,7 +584,7 @@ acpi_rs_end_depend_fns_resource(u8 * byte_stream_buffer,
421 584
422 /* Fill out the structure */ 585 /* Fill out the structure */
423 586
424 output_struct->id = ACPI_RSTYPE_END_DPF; 587 output_struct->type = ACPI_RSTYPE_END_DPF;
425 588
426 /* Set the Length parameter */ 589 /* Set the Length parameter */
427 590
@@ -437,7 +600,7 @@ acpi_rs_end_depend_fns_resource(u8 * byte_stream_buffer,
437 * 600 *
438 * FUNCTION: acpi_rs_start_depend_fns_stream 601 * FUNCTION: acpi_rs_start_depend_fns_stream
439 * 602 *
440 * PARAMETERS: linked_list - Pointer to the resource linked list 603 * PARAMETERS: Resource - Pointer to the resource linked list
441 * output_buffer - Pointer to the user's return buffer 604 * output_buffer - Pointer to the user's return buffer
442 * bytes_consumed - u32 pointer that is filled with 605 * bytes_consumed - u32 pointer that is filled with
443 * the number of bytes of the 606 * the number of bytes of the
@@ -451,7 +614,7 @@ acpi_rs_end_depend_fns_resource(u8 * byte_stream_buffer,
451 ******************************************************************************/ 614 ******************************************************************************/
452 615
453acpi_status 616acpi_status
454acpi_rs_start_depend_fns_stream(struct acpi_resource *linked_list, 617acpi_rs_start_depend_fns_stream(struct acpi_resource *resource,
455 u8 ** output_buffer, acpi_size * bytes_consumed) 618 u8 ** output_buffer, acpi_size * bytes_consumed)
456{ 619{
457 u8 *buffer = *output_buffer; 620 u8 *buffer = *output_buffer;
@@ -460,26 +623,25 @@ acpi_rs_start_depend_fns_stream(struct acpi_resource *linked_list,
460 ACPI_FUNCTION_TRACE("rs_start_depend_fns_stream"); 623 ACPI_FUNCTION_TRACE("rs_start_depend_fns_stream");
461 624
462 /* 625 /*
463 * The descriptor field is set based upon whether a byte is needed 626 * The descriptor type field is set based upon whether a byte is needed
464 * to contain Priority data. 627 * to contain Priority data.
465 */ 628 */
466 if (ACPI_ACCEPTABLE_CONFIGURATION == 629 if (ACPI_ACCEPTABLE_CONFIGURATION ==
467 linked_list->data.start_dpf.compatibility_priority && 630 resource->data.start_dpf.compatibility_priority &&
468 ACPI_ACCEPTABLE_CONFIGURATION == 631 ACPI_ACCEPTABLE_CONFIGURATION ==
469 linked_list->data.start_dpf.performance_robustness) { 632 resource->data.start_dpf.performance_robustness) {
470 *buffer = 0x30; 633 *buffer = ACPI_RDESC_TYPE_START_DEPENDENT;
471 } else { 634 } else {
472 *buffer = 0x31; 635 *buffer = ACPI_RDESC_TYPE_START_DEPENDENT | 0x01;
473 buffer += 1; 636 buffer += 1;
474 637
475 /* Set the Priority Byte Definition */ 638 /* Set the Priority Byte Definition */
476 639
477 temp8 = 0; 640 temp8 = 0;
478 temp8 = 641 temp8 = (u8) ((resource->data.start_dpf.performance_robustness &
479 (u8) ((linked_list->data.start_dpf. 642 0x03) << 2);
480 performance_robustness & 0x03) << 2); 643 temp8 |= (resource->data.start_dpf.compatibility_priority &
481 temp8 |= 644 0x03);
482 (linked_list->data.start_dpf.compatibility_priority & 0x03);
483 *buffer = temp8; 645 *buffer = temp8;
484 } 646 }
485 647
@@ -495,7 +657,7 @@ acpi_rs_start_depend_fns_stream(struct acpi_resource *linked_list,
495 * 657 *
496 * FUNCTION: acpi_rs_end_depend_fns_stream 658 * FUNCTION: acpi_rs_end_depend_fns_stream
497 * 659 *
498 * PARAMETERS: linked_list - Pointer to the resource linked list 660 * PARAMETERS: Resource - Pointer to the resource linked list
499 * output_buffer - Pointer to the user's return buffer 661 * output_buffer - Pointer to the user's return buffer
500 * bytes_consumed - Pointer to where the number of bytes 662 * bytes_consumed - Pointer to where the number of bytes
501 * used in the output_buffer is returned 663 * used in the output_buffer is returned
@@ -508,16 +670,16 @@ acpi_rs_start_depend_fns_stream(struct acpi_resource *linked_list,
508 ******************************************************************************/ 670 ******************************************************************************/
509 671
510acpi_status 672acpi_status
511acpi_rs_end_depend_fns_stream(struct acpi_resource *linked_list, 673acpi_rs_end_depend_fns_stream(struct acpi_resource *resource,
512 u8 ** output_buffer, acpi_size * bytes_consumed) 674 u8 ** output_buffer, acpi_size * bytes_consumed)
513{ 675{
514 u8 *buffer = *output_buffer; 676 u8 *buffer = *output_buffer;
515 677
516 ACPI_FUNCTION_TRACE("rs_end_depend_fns_stream"); 678 ACPI_FUNCTION_TRACE("rs_end_depend_fns_stream");
517 679
518 /* The descriptor field is static */ 680 /* The Descriptor Type field is static */
519 681
520 *buffer = 0x38; 682 *buffer = ACPI_RDESC_TYPE_END_DEPENDENT;
521 buffer += 1; 683 buffer += 1;
522 684
523 /* Return the number of bytes consumed in this operation */ 685 /* Return the number of bytes consumed in this operation */