aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/resources/rsirq.c
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2005-08-05 00:44:28 -0400
committerLen Brown <len.brown@intel.com>2005-08-05 00:45:14 -0400
commit4be44fcd3bf648b782f4460fd06dfae6c42ded4b (patch)
tree5b5b7d296ea58786f53b95e5eac9565ff66890b0 /drivers/acpi/resources/rsirq.c
parentc65ade4dc8b486e8c8b9b0a6399789a5428e2039 (diff)
[ACPI] Lindent all ACPI files
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/resources/rsirq.c')
-rw-r--r--drivers/acpi/resources/rsirq.c236
1 files changed, 111 insertions, 125 deletions
diff --git a/drivers/acpi/resources/rsirq.c b/drivers/acpi/resources/rsirq.c
index 8a2b630be45b..7179b6243f5b 100644
--- a/drivers/acpi/resources/rsirq.c
+++ b/drivers/acpi/resources/rsirq.c
@@ -41,13 +41,11 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acresrc.h> 45#include <acpi/acresrc.h>
47 46
48#define _COMPONENT ACPI_RESOURCES 47#define _COMPONENT ACPI_RESOURCES
49 ACPI_MODULE_NAME ("rsirq") 48ACPI_MODULE_NAME("rsirq")
50
51 49
52/******************************************************************************* 50/*******************************************************************************
53 * 51 *
@@ -69,26 +67,20 @@
69 * number of bytes consumed from the byte stream. 67 * number of bytes consumed from the byte stream.
70 * 68 *
71 ******************************************************************************/ 69 ******************************************************************************/
72
73acpi_status 70acpi_status
74acpi_rs_irq_resource ( 71acpi_rs_irq_resource(u8 * byte_stream_buffer,
75 u8 *byte_stream_buffer, 72 acpi_size * bytes_consumed,
76 acpi_size *bytes_consumed, 73 u8 ** output_buffer, acpi_size * structure_size)
77 u8 **output_buffer,
78 acpi_size *structure_size)
79{ 74{
80 u8 *buffer = byte_stream_buffer; 75 u8 *buffer = byte_stream_buffer;
81 struct acpi_resource *output_struct = (void *) *output_buffer; 76 struct acpi_resource *output_struct = (void *)*output_buffer;
82 u16 temp16 = 0; 77 u16 temp16 = 0;
83 u8 temp8 = 0; 78 u8 temp8 = 0;
84 u8 index; 79 u8 index;
85 u8 i; 80 u8 i;
86 acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( 81 acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_irq);
87 struct acpi_resource_irq);
88
89
90 ACPI_FUNCTION_TRACE ("rs_irq_resource");
91 82
83 ACPI_FUNCTION_TRACE("rs_irq_resource");
92 84
93 /* 85 /*
94 * The number of bytes consumed are contained in the descriptor 86 * The number of bytes consumed are contained in the descriptor
@@ -101,7 +93,7 @@ acpi_rs_irq_resource (
101 /* Point to the 16-bits of Bytes 1 and 2 */ 93 /* Point to the 16-bits of Bytes 1 and 2 */
102 94
103 buffer += 1; 95 buffer += 1;
104 ACPI_MOVE_16_TO_16 (&temp16, buffer); 96 ACPI_MOVE_16_TO_16(&temp16, buffer);
105 97
106 output_struct->data.irq.number_of_interrupts = 0; 98 output_struct->data.irq.number_of_interrupts = 0;
107 99
@@ -132,14 +124,18 @@ acpi_rs_irq_resource (
132 /* Check for HE, LL interrupts */ 124 /* Check for HE, LL interrupts */
133 125
134 switch (temp8 & 0x09) { 126 switch (temp8 & 0x09) {
135 case 0x01: /* HE */ 127 case 0x01: /* HE */
136 output_struct->data.irq.edge_level = ACPI_EDGE_SENSITIVE; 128 output_struct->data.irq.edge_level =
137 output_struct->data.irq.active_high_low = ACPI_ACTIVE_HIGH; 129 ACPI_EDGE_SENSITIVE;
130 output_struct->data.irq.active_high_low =
131 ACPI_ACTIVE_HIGH;
138 break; 132 break;
139 133
140 case 0x08: /* LL */ 134 case 0x08: /* LL */
141 output_struct->data.irq.edge_level = ACPI_LEVEL_SENSITIVE; 135 output_struct->data.irq.edge_level =
142 output_struct->data.irq.active_high_low = ACPI_ACTIVE_LOW; 136 ACPI_LEVEL_SENSITIVE;
137 output_struct->data.irq.active_high_low =
138 ACPI_ACTIVE_LOW;
143 break; 139 break;
144 140
145 default: 141 default:
@@ -148,17 +144,16 @@ acpi_rs_irq_resource (
148 * are allowed (ACPI spec, section "IRQ Format") 144 * are allowed (ACPI spec, section "IRQ Format")
149 * so 0x00 and 0x09 are illegal. 145 * so 0x00 and 0x09 are illegal.
150 */ 146 */
151 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 147 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
152 "Invalid interrupt polarity/trigger in resource list, %X\n", 148 "Invalid interrupt polarity/trigger in resource list, %X\n",
153 temp8)); 149 temp8));
154 return_ACPI_STATUS (AE_BAD_DATA); 150 return_ACPI_STATUS(AE_BAD_DATA);
155 } 151 }
156 152
157 /* Check for sharable */ 153 /* Check for sharable */
158 154
159 output_struct->data.irq.shared_exclusive = (temp8 >> 3) & 0x01; 155 output_struct->data.irq.shared_exclusive = (temp8 >> 3) & 0x01;
160 } 156 } else {
161 else {
162 /* 157 /*
163 * Assume Edge Sensitive, Active High, Non-Sharable 158 * Assume Edge Sensitive, Active High, Non-Sharable
164 * per ACPI Specification 159 * per ACPI Specification
@@ -175,10 +170,9 @@ acpi_rs_irq_resource (
175 /* Return the final size of the structure */ 170 /* Return the final size of the structure */
176 171
177 *structure_size = struct_size; 172 *structure_size = struct_size;
178 return_ACPI_STATUS (AE_OK); 173 return_ACPI_STATUS(AE_OK);
179} 174}
180 175
181
182/******************************************************************************* 176/*******************************************************************************
183 * 177 *
184 * FUNCTION: acpi_rs_irq_stream 178 * FUNCTION: acpi_rs_irq_stream
@@ -196,32 +190,27 @@ acpi_rs_irq_resource (
196 ******************************************************************************/ 190 ******************************************************************************/
197 191
198acpi_status 192acpi_status
199acpi_rs_irq_stream ( 193acpi_rs_irq_stream(struct acpi_resource *linked_list,
200 struct acpi_resource *linked_list, 194 u8 ** output_buffer, acpi_size * bytes_consumed)
201 u8 **output_buffer,
202 acpi_size *bytes_consumed)
203{ 195{
204 u8 *buffer = *output_buffer; 196 u8 *buffer = *output_buffer;
205 u16 temp16 = 0; 197 u16 temp16 = 0;
206 u8 temp8 = 0; 198 u8 temp8 = 0;
207 u8 index; 199 u8 index;
208 u8 IRqinfo_byte_needed; 200 u8 IRqinfo_byte_needed;
209
210
211 ACPI_FUNCTION_TRACE ("rs_irq_stream");
212 201
202 ACPI_FUNCTION_TRACE("rs_irq_stream");
213 203
214 /* 204 /*
215 * The descriptor field is set based upon whether a third byte is 205 * The descriptor field is set based upon whether a third byte is
216 * needed to contain the IRQ Information. 206 * needed to contain the IRQ Information.
217 */ 207 */
218 if (ACPI_EDGE_SENSITIVE == linked_list->data.irq.edge_level && 208 if (ACPI_EDGE_SENSITIVE == linked_list->data.irq.edge_level &&
219 ACPI_ACTIVE_HIGH == linked_list->data.irq.active_high_low && 209 ACPI_ACTIVE_HIGH == linked_list->data.irq.active_high_low &&
220 ACPI_EXCLUSIVE == linked_list->data.irq.shared_exclusive) { 210 ACPI_EXCLUSIVE == linked_list->data.irq.shared_exclusive) {
221 *buffer = 0x22; 211 *buffer = 0x22;
222 IRqinfo_byte_needed = FALSE; 212 IRqinfo_byte_needed = FALSE;
223 } 213 } else {
224 else {
225 *buffer = 0x23; 214 *buffer = 0x23;
226 IRqinfo_byte_needed = TRUE; 215 IRqinfo_byte_needed = TRUE;
227 } 216 }
@@ -231,14 +220,13 @@ acpi_rs_irq_stream (
231 220
232 /* Loop through all of the interrupts and set the mask bits */ 221 /* Loop through all of the interrupts and set the mask bits */
233 222
234 for(index = 0; 223 for (index = 0;
235 index < linked_list->data.irq.number_of_interrupts; 224 index < linked_list->data.irq.number_of_interrupts; index++) {
236 index++) {
237 temp8 = (u8) linked_list->data.irq.interrupts[index]; 225 temp8 = (u8) linked_list->data.irq.interrupts[index];
238 temp16 |= 0x1 << temp8; 226 temp16 |= 0x1 << temp8;
239 } 227 }
240 228
241 ACPI_MOVE_16_TO_16 (buffer, &temp16); 229 ACPI_MOVE_16_TO_16(buffer, &temp16);
242 buffer += 2; 230 buffer += 2;
243 231
244 /* Set the IRQ Info byte if needed. */ 232 /* Set the IRQ Info byte if needed. */
@@ -246,13 +234,12 @@ acpi_rs_irq_stream (
246 if (IRqinfo_byte_needed) { 234 if (IRqinfo_byte_needed) {
247 temp8 = 0; 235 temp8 = 0;
248 temp8 = (u8) ((linked_list->data.irq.shared_exclusive & 236 temp8 = (u8) ((linked_list->data.irq.shared_exclusive &
249 0x01) << 4); 237 0x01) << 4);
250 238
251 if (ACPI_LEVEL_SENSITIVE == linked_list->data.irq.edge_level && 239 if (ACPI_LEVEL_SENSITIVE == linked_list->data.irq.edge_level &&
252 ACPI_ACTIVE_LOW == linked_list->data.irq.active_high_low) { 240 ACPI_ACTIVE_LOW == linked_list->data.irq.active_high_low) {
253 temp8 |= 0x08; 241 temp8 |= 0x08;
254 } 242 } else {
255 else {
256 temp8 |= 0x01; 243 temp8 |= 0x01;
257 } 244 }
258 245
@@ -262,11 +249,10 @@ acpi_rs_irq_stream (
262 249
263 /* Return the number of bytes consumed in this operation */ 250 /* Return the number of bytes consumed in this operation */
264 251
265 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 252 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
266 return_ACPI_STATUS (AE_OK); 253 return_ACPI_STATUS(AE_OK);
267} 254}
268 255
269
270/******************************************************************************* 256/*******************************************************************************
271 * 257 *
272 * FUNCTION: acpi_rs_extended_irq_resource 258 * FUNCTION: acpi_rs_extended_irq_resource
@@ -289,34 +275,30 @@ acpi_rs_irq_stream (
289 ******************************************************************************/ 275 ******************************************************************************/
290 276
291acpi_status 277acpi_status
292acpi_rs_extended_irq_resource ( 278acpi_rs_extended_irq_resource(u8 * byte_stream_buffer,
293 u8 *byte_stream_buffer, 279 acpi_size * bytes_consumed,
294 acpi_size *bytes_consumed, 280 u8 ** output_buffer, acpi_size * structure_size)
295 u8 **output_buffer,
296 acpi_size *structure_size)
297{ 281{
298 u8 *buffer = byte_stream_buffer; 282 u8 *buffer = byte_stream_buffer;
299 struct acpi_resource *output_struct = (void *) *output_buffer; 283 struct acpi_resource *output_struct = (void *)*output_buffer;
300 u16 temp16 = 0; 284 u16 temp16 = 0;
301 u8 temp8 = 0; 285 u8 temp8 = 0;
302 u8 *temp_ptr; 286 u8 *temp_ptr;
303 u8 index; 287 u8 index;
304 acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( 288 acpi_size struct_size =
305 struct acpi_resource_ext_irq); 289 ACPI_SIZEOF_RESOURCE(struct acpi_resource_ext_irq);
306
307
308 ACPI_FUNCTION_TRACE ("rs_extended_irq_resource");
309 290
291 ACPI_FUNCTION_TRACE("rs_extended_irq_resource");
310 292
311 /* Point past the Descriptor to get the number of bytes consumed */ 293 /* Point past the Descriptor to get the number of bytes consumed */
312 294
313 buffer += 1; 295 buffer += 1;
314 ACPI_MOVE_16_TO_16 (&temp16, buffer); 296 ACPI_MOVE_16_TO_16(&temp16, buffer);
315 297
316 /* Validate minimum descriptor length */ 298 /* Validate minimum descriptor length */
317 299
318 if (temp16 < 6) { 300 if (temp16 < 6) {
319 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); 301 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
320 } 302 }
321 303
322 *bytes_consumed = temp16 + 3; 304 *bytes_consumed = temp16 + 3;
@@ -338,7 +320,7 @@ acpi_rs_extended_irq_resource (
338 * - Edge/Level are defined opposite in the table vs the headers 320 * - Edge/Level are defined opposite in the table vs the headers
339 */ 321 */
340 output_struct->data.extended_irq.edge_level = 322 output_struct->data.extended_irq.edge_level =
341 (temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE; 323 (temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE;
342 324
343 /* Check Interrupt Polarity */ 325 /* Check Interrupt Polarity */
344 326
@@ -356,7 +338,7 @@ acpi_rs_extended_irq_resource (
356 /* Must have at least one IRQ */ 338 /* Must have at least one IRQ */
357 339
358 if (temp8 < 1) { 340 if (temp8 < 1) {
359 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); 341 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
360 } 342 }
361 343
362 output_struct->data.extended_irq.number_of_interrupts = temp8; 344 output_struct->data.extended_irq.number_of_interrupts = temp8;
@@ -374,8 +356,8 @@ acpi_rs_extended_irq_resource (
374 /* Cycle through every IRQ in the table */ 356 /* Cycle through every IRQ in the table */
375 357
376 for (index = 0; index < temp8; index++) { 358 for (index = 0; index < temp8; index++) {
377 ACPI_MOVE_32_TO_32 ( 359 ACPI_MOVE_32_TO_32(&output_struct->data.extended_irq.
378 &output_struct->data.extended_irq.interrupts[index], buffer); 360 interrupts[index], buffer);
379 361
380 /* Point to the next IRQ */ 362 /* Point to the next IRQ */
381 363
@@ -393,12 +375,13 @@ acpi_rs_extended_irq_resource (
393 * we add 1 to the length. 375 * we add 1 to the length.
394 */ 376 */
395 if (*bytes_consumed > 377 if (*bytes_consumed >
396 ((acpi_size) output_struct->data.extended_irq.number_of_interrupts * 4) + 378 ((acpi_size) output_struct->data.extended_irq.number_of_interrupts *
397 (5 + 1)) { 379 4) + (5 + 1)) {
398 /* Dereference the Index */ 380 /* Dereference the Index */
399 381
400 temp8 = *buffer; 382 temp8 = *buffer;
401 output_struct->data.extended_irq.resource_source.index = (u32) temp8; 383 output_struct->data.extended_irq.resource_source.index =
384 (u32) temp8;
402 385
403 /* Point to the String */ 386 /* Point to the String */
404 387
@@ -407,10 +390,10 @@ acpi_rs_extended_irq_resource (
407 /* Point the String pointer to the end of this structure. */ 390 /* Point the String pointer to the end of this structure. */
408 391
409 output_struct->data.extended_irq.resource_source.string_ptr = 392 output_struct->data.extended_irq.resource_source.string_ptr =
410 (char *)((char *) output_struct + struct_size); 393 (char *)((char *)output_struct + struct_size);
411 394
412 temp_ptr = (u8 *) 395 temp_ptr = (u8 *)
413 output_struct->data.extended_irq.resource_source.string_ptr; 396 output_struct->data.extended_irq.resource_source.string_ptr;
414 397
415 /* Copy the string into the buffer */ 398 /* Copy the string into the buffer */
416 399
@@ -426,7 +409,8 @@ acpi_rs_extended_irq_resource (
426 /* Add the terminating null */ 409 /* Add the terminating null */
427 410
428 *temp_ptr = 0x00; 411 *temp_ptr = 0x00;
429 output_struct->data.extended_irq.resource_source.string_length = index + 1; 412 output_struct->data.extended_irq.resource_source.string_length =
413 index + 1;
430 414
431 /* 415 /*
432 * In order for the struct_size to fall on a 32-bit boundary, 416 * In order for the struct_size to fall on a 32-bit boundary,
@@ -434,12 +418,13 @@ acpi_rs_extended_irq_resource (
434 * struct_size to the next 32-bit boundary. 418 * struct_size to the next 32-bit boundary.
435 */ 419 */
436 temp8 = (u8) (index + 1); 420 temp8 = (u8) (index + 1);
437 struct_size += ACPI_ROUND_UP_to_32_bITS (temp8); 421 struct_size += ACPI_ROUND_UP_to_32_bITS(temp8);
438 } 422 } else {
439 else {
440 output_struct->data.extended_irq.resource_source.index = 0x00; 423 output_struct->data.extended_irq.resource_source.index = 0x00;
441 output_struct->data.extended_irq.resource_source.string_length = 0; 424 output_struct->data.extended_irq.resource_source.string_length =
442 output_struct->data.extended_irq.resource_source.string_ptr = NULL; 425 0;
426 output_struct->data.extended_irq.resource_source.string_ptr =
427 NULL;
443 } 428 }
444 429
445 /* Set the Length parameter */ 430 /* Set the Length parameter */
@@ -449,10 +434,9 @@ acpi_rs_extended_irq_resource (
449 /* Return the final size of the structure */ 434 /* Return the final size of the structure */
450 435
451 *structure_size = struct_size; 436 *structure_size = struct_size;
452 return_ACPI_STATUS (AE_OK); 437 return_ACPI_STATUS(AE_OK);
453} 438}
454 439
455
456/******************************************************************************* 440/*******************************************************************************
457 * 441 *
458 * FUNCTION: acpi_rs_extended_irq_stream 442 * FUNCTION: acpi_rs_extended_irq_stream
@@ -470,20 +454,16 @@ acpi_rs_extended_irq_resource (
470 ******************************************************************************/ 454 ******************************************************************************/
471 455
472acpi_status 456acpi_status
473acpi_rs_extended_irq_stream ( 457acpi_rs_extended_irq_stream(struct acpi_resource *linked_list,
474 struct acpi_resource *linked_list, 458 u8 ** output_buffer, acpi_size * bytes_consumed)
475 u8 **output_buffer,
476 acpi_size *bytes_consumed)
477{ 459{
478 u8 *buffer = *output_buffer; 460 u8 *buffer = *output_buffer;
479 u16 *length_field; 461 u16 *length_field;
480 u8 temp8 = 0; 462 u8 temp8 = 0;
481 u8 index; 463 u8 index;
482 char *temp_pointer = NULL; 464 char *temp_pointer = NULL;
483
484
485 ACPI_FUNCTION_TRACE ("rs_extended_irq_stream");
486 465
466 ACPI_FUNCTION_TRACE("rs_extended_irq_stream");
487 467
488 /* The descriptor field is static */ 468 /* The descriptor field is static */
489 469
@@ -492,13 +472,14 @@ acpi_rs_extended_irq_stream (
492 472
493 /* Set a pointer to the Length field - to be filled in later */ 473 /* Set a pointer to the Length field - to be filled in later */
494 474
495 length_field = ACPI_CAST_PTR (u16, buffer); 475 length_field = ACPI_CAST_PTR(u16, buffer);
496 buffer += 2; 476 buffer += 2;
497 477
498 /* Set the Interrupt vector flags */ 478 /* Set the Interrupt vector flags */
499 479
500 temp8 = (u8)(linked_list->data.extended_irq.producer_consumer & 0x01); 480 temp8 = (u8) (linked_list->data.extended_irq.producer_consumer & 0x01);
501 temp8 |= ((linked_list->data.extended_irq.shared_exclusive & 0x01) << 3); 481 temp8 |=
482 ((linked_list->data.extended_irq.shared_exclusive & 0x01) << 3);
502 483
503 /* 484 /*
504 * Set the Interrupt Mode 485 * Set the Interrupt Mode
@@ -527,43 +508,48 @@ acpi_rs_extended_irq_stream (
527 *buffer = temp8; 508 *buffer = temp8;
528 buffer += 1; 509 buffer += 1;
529 510
530 for (index = 0; index < linked_list->data.extended_irq.number_of_interrupts; 511 for (index = 0;
531 index++) { 512 index < linked_list->data.extended_irq.number_of_interrupts;
532 ACPI_MOVE_32_TO_32 (buffer, 513 index++) {
533 &linked_list->data.extended_irq.interrupts[index]); 514 ACPI_MOVE_32_TO_32(buffer,
515 &linked_list->data.extended_irq.
516 interrupts[index]);
534 buffer += 4; 517 buffer += 4;
535 } 518 }
536 519
537 /* Resource Source Index and Resource Source are optional */ 520 /* Resource Source Index and Resource Source are optional */
538 521
539 if (0 != linked_list->data.extended_irq.resource_source.string_length) { 522 if (0 != linked_list->data.extended_irq.resource_source.string_length) {
540 *buffer = (u8) linked_list->data.extended_irq.resource_source.index; 523 *buffer =
524 (u8) linked_list->data.extended_irq.resource_source.index;
541 buffer += 1; 525 buffer += 1;
542 526
543 temp_pointer = (char *) buffer; 527 temp_pointer = (char *)buffer;
544 528
545 /* Copy the string */ 529 /* Copy the string */
546 530
547 ACPI_STRCPY (temp_pointer, 531 ACPI_STRCPY(temp_pointer,
548 linked_list->data.extended_irq.resource_source.string_ptr); 532 linked_list->data.extended_irq.resource_source.
533 string_ptr);
549 534
550 /* 535 /*
551 * Buffer needs to be set to the length of the sting + one for the 536 * Buffer needs to be set to the length of the sting + one for the
552 * terminating null 537 * terminating null
553 */ 538 */
554 buffer += (acpi_size) (ACPI_STRLEN ( 539 buffer +=
555 linked_list->data.extended_irq.resource_source.string_ptr) + 1); 540 (acpi_size) (ACPI_STRLEN
541 (linked_list->data.extended_irq.
542 resource_source.string_ptr) + 1);
556 } 543 }
557 544
558 /* Return the number of bytes consumed in this operation */ 545 /* Return the number of bytes consumed in this operation */
559 546
560 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 547 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
561 548
562 /* 549 /*
563 * Set the length field to the number of bytes consumed 550 * Set the length field to the number of bytes consumed
564 * minus the header size (3 bytes) 551 * minus the header size (3 bytes)
565 */ 552 */
566 *length_field = (u16) (*bytes_consumed - 3); 553 *length_field = (u16) (*bytes_consumed - 3);
567 return_ACPI_STATUS (AE_OK); 554 return_ACPI_STATUS(AE_OK);
568} 555}
569