aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/resources/rsirq.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/resources/rsirq.c')
-rw-r--r--drivers/acpi/resources/rsirq.c167
1 files changed, 72 insertions, 95 deletions
diff --git a/drivers/acpi/resources/rsirq.c b/drivers/acpi/resources/rsirq.c
index fd07a8702fbe..8a2b630be45b 100644
--- a/drivers/acpi/resources/rsirq.c
+++ b/drivers/acpi/resources/rsirq.c
@@ -83,7 +83,8 @@ acpi_rs_irq_resource (
83 u8 temp8 = 0; 83 u8 temp8 = 0;
84 u8 index; 84 u8 index;
85 u8 i; 85 u8 i;
86 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_irq); 86 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (
87 struct acpi_resource_irq);
87 88
88 89
89 ACPI_FUNCTION_TRACE ("rs_irq_resource"); 90 ACPI_FUNCTION_TRACE ("rs_irq_resource");
@@ -91,15 +92,14 @@ acpi_rs_irq_resource (
91 92
92 /* 93 /*
93 * The number of bytes consumed are contained in the descriptor 94 * The number of bytes consumed are contained in the descriptor
94 * (Bits:0-1) 95 * (Bits:0-1)
95 */ 96 */
96 temp8 = *buffer; 97 temp8 = *buffer;
97 *bytes_consumed = (temp8 & 0x03) + 1; 98 *bytes_consumed = (temp8 & 0x03) + 1;
98 output_struct->id = ACPI_RSTYPE_IRQ; 99 output_struct->id = ACPI_RSTYPE_IRQ;
99 100
100 /* 101 /* Point to the 16-bits of Bytes 1 and 2 */
101 * Point to the 16-bits of Bytes 1 and 2 102
102 */
103 buffer += 1; 103 buffer += 1;
104 ACPI_MOVE_16_TO_16 (&temp16, buffer); 104 ACPI_MOVE_16_TO_16 (&temp16, buffer);
105 105
@@ -118,22 +118,19 @@ acpi_rs_irq_resource (
118 118
119 output_struct->data.irq.number_of_interrupts = i; 119 output_struct->data.irq.number_of_interrupts = i;
120 if (i > 0) { 120 if (i > 0) {
121 /* 121 /* Calculate the structure size based upon the number of interrupts */
122 * Calculate the structure size based upon the number of interrupts 122
123 */
124 struct_size += ((acpi_size) i - 1) * 4; 123 struct_size += ((acpi_size) i - 1) * 4;
125 } 124 }
126 125
127 /* 126 /* Point to Byte 3 if it is used */
128 * Point to Byte 3 if it is used 127
129 */
130 if (4 == *bytes_consumed) { 128 if (4 == *bytes_consumed) {
131 buffer += 2; 129 buffer += 2;
132 temp8 = *buffer; 130 temp8 = *buffer;
133 131
134 /* 132 /* Check for HE, LL interrupts */
135 * Check for HE, LL interrupts 133
136 */
137 switch (temp8 & 0x09) { 134 switch (temp8 & 0x09) {
138 case 0x01: /* HE */ 135 case 0x01: /* HE */
139 output_struct->data.irq.edge_level = ACPI_EDGE_SENSITIVE; 136 output_struct->data.irq.edge_level = ACPI_EDGE_SENSITIVE;
@@ -152,13 +149,13 @@ acpi_rs_irq_resource (
152 * so 0x00 and 0x09 are illegal. 149 * so 0x00 and 0x09 are illegal.
153 */ 150 */
154 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 151 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
155 "Invalid interrupt polarity/trigger in resource list, %X\n", temp8)); 152 "Invalid interrupt polarity/trigger in resource list, %X\n",
153 temp8));
156 return_ACPI_STATUS (AE_BAD_DATA); 154 return_ACPI_STATUS (AE_BAD_DATA);
157 } 155 }
158 156
159 /* 157 /* Check for sharable */
160 * Check for sharable 158
161 */
162 output_struct->data.irq.shared_exclusive = (temp8 >> 3) & 0x01; 159 output_struct->data.irq.shared_exclusive = (temp8 >> 3) & 0x01;
163 } 160 }
164 else { 161 else {
@@ -171,14 +168,12 @@ acpi_rs_irq_resource (
171 output_struct->data.irq.shared_exclusive = ACPI_EXCLUSIVE; 168 output_struct->data.irq.shared_exclusive = ACPI_EXCLUSIVE;
172 } 169 }
173 170
174 /* 171 /* Set the Length parameter */
175 * Set the Length parameter 172
176 */
177 output_struct->length = (u32) struct_size; 173 output_struct->length = (u32) struct_size;
178 174
179 /* 175 /* Return the final size of the structure */
180 * Return the final size of the structure 176
181 */
182 *structure_size = struct_size; 177 *structure_size = struct_size;
183 return_ACPI_STATUS (AE_OK); 178 return_ACPI_STATUS (AE_OK);
184} 179}
@@ -234,9 +229,8 @@ acpi_rs_irq_stream (
234 buffer += 1; 229 buffer += 1;
235 temp16 = 0; 230 temp16 = 0;
236 231
237 /* 232 /* Loop through all of the interrupts and set the mask bits */
238 * Loop through all of the interrupts and set the mask bits 233
239 */
240 for(index = 0; 234 for(index = 0;
241 index < linked_list->data.irq.number_of_interrupts; 235 index < linked_list->data.irq.number_of_interrupts;
242 index++) { 236 index++) {
@@ -247,9 +241,8 @@ acpi_rs_irq_stream (
247 ACPI_MOVE_16_TO_16 (buffer, &temp16); 241 ACPI_MOVE_16_TO_16 (buffer, &temp16);
248 buffer += 2; 242 buffer += 2;
249 243
250 /* 244 /* Set the IRQ Info byte if needed. */
251 * Set the IRQ Info byte if needed. 245
252 */
253 if (IRqinfo_byte_needed) { 246 if (IRqinfo_byte_needed) {
254 temp8 = 0; 247 temp8 = 0;
255 temp8 = (u8) ((linked_list->data.irq.shared_exclusive & 248 temp8 = (u8) ((linked_list->data.irq.shared_exclusive &
@@ -267,9 +260,8 @@ acpi_rs_irq_stream (
267 buffer += 1; 260 buffer += 1;
268 } 261 }
269 262
270 /* 263 /* Return the number of bytes consumed in this operation */
271 * Return the number of bytes consumed in this operation 264
272 */
273 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 265 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
274 return_ACPI_STATUS (AE_OK); 266 return_ACPI_STATUS (AE_OK);
275} 267}
@@ -309,15 +301,15 @@ acpi_rs_extended_irq_resource (
309 u8 temp8 = 0; 301 u8 temp8 = 0;
310 u8 *temp_ptr; 302 u8 *temp_ptr;
311 u8 index; 303 u8 index;
312 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_ext_irq); 304 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (
305 struct acpi_resource_ext_irq);
313 306
314 307
315 ACPI_FUNCTION_TRACE ("rs_extended_irq_resource"); 308 ACPI_FUNCTION_TRACE ("rs_extended_irq_resource");
316 309
317 310
318 /* 311 /* Point past the Descriptor to get the number of bytes consumed */
319 * Point past the Descriptor to get the number of bytes consumed 312
320 */
321 buffer += 1; 313 buffer += 1;
322 ACPI_MOVE_16_TO_16 (&temp16, buffer); 314 ACPI_MOVE_16_TO_16 (&temp16, buffer);
323 315
@@ -330,9 +322,8 @@ acpi_rs_extended_irq_resource (
330 *bytes_consumed = temp16 + 3; 322 *bytes_consumed = temp16 + 3;
331 output_struct->id = ACPI_RSTYPE_EXT_IRQ; 323 output_struct->id = ACPI_RSTYPE_EXT_IRQ;
332 324
333 /* 325 /* Point to the Byte3 */
334 * Point to the Byte3 326
335 */
336 buffer += 2; 327 buffer += 2;
337 temp8 = *buffer; 328 temp8 = *buffer;
338 329
@@ -347,21 +338,18 @@ acpi_rs_extended_irq_resource (
347 * - Edge/Level are defined opposite in the table vs the headers 338 * - Edge/Level are defined opposite in the table vs the headers
348 */ 339 */
349 output_struct->data.extended_irq.edge_level = 340 output_struct->data.extended_irq.edge_level =
350 (temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE; 341 (temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE;
342
343 /* Check Interrupt Polarity */
351 344
352 /*
353 * Check Interrupt Polarity
354 */
355 output_struct->data.extended_irq.active_high_low = (temp8 >> 2) & 0x1; 345 output_struct->data.extended_irq.active_high_low = (temp8 >> 2) & 0x1;
356 346
357 /* 347 /* Check for sharable */
358 * Check for sharable 348
359 */
360 output_struct->data.extended_irq.shared_exclusive = (temp8 >> 3) & 0x01; 349 output_struct->data.extended_irq.shared_exclusive = (temp8 >> 3) & 0x01;
361 350
362 /* 351 /* Point to Byte4 (IRQ Table length) */
363 * Point to Byte4 (IRQ Table length) 352
364 */
365 buffer += 1; 353 buffer += 1;
366 temp8 = *buffer; 354 temp8 = *buffer;
367 355
@@ -379,14 +367,12 @@ acpi_rs_extended_irq_resource (
379 */ 367 */
380 struct_size += (temp8 - 1) * 4; 368 struct_size += (temp8 - 1) * 4;
381 369
382 /* 370 /* Point to Byte5 (First IRQ Number) */
383 * Point to Byte5 (First IRQ Number) 371
384 */
385 buffer += 1; 372 buffer += 1;
386 373
387 /* 374 /* Cycle through every IRQ in the table */
388 * Cycle through every IRQ in the table 375
389 */
390 for (index = 0; index < temp8; index++) { 376 for (index = 0; index < temp8; index++) {
391 ACPI_MOVE_32_TO_32 ( 377 ACPI_MOVE_32_TO_32 (
392 &output_struct->data.extended_irq.interrupts[index], buffer); 378 &output_struct->data.extended_irq.interrupts[index], buffer);
@@ -407,7 +393,8 @@ acpi_rs_extended_irq_resource (
407 * we add 1 to the length. 393 * we add 1 to the length.
408 */ 394 */
409 if (*bytes_consumed > 395 if (*bytes_consumed >
410 ((acpi_size) output_struct->data.extended_irq.number_of_interrupts * 4) + (5 + 1)) { 396 ((acpi_size) output_struct->data.extended_irq.number_of_interrupts * 4) +
397 (5 + 1)) {
411 /* Dereference the Index */ 398 /* Dereference the Index */
412 399
413 temp8 = *buffer; 400 temp8 = *buffer;
@@ -417,13 +404,13 @@ acpi_rs_extended_irq_resource (
417 404
418 buffer += 1; 405 buffer += 1;
419 406
420 /* 407 /* Point the String pointer to the end of this structure. */
421 * Point the String pointer to the end of this structure. 408
422 */
423 output_struct->data.extended_irq.resource_source.string_ptr = 409 output_struct->data.extended_irq.resource_source.string_ptr =
424 (char *)((char *) output_struct + struct_size); 410 (char *)((char *) output_struct + struct_size);
425 411
426 temp_ptr = (u8 *) output_struct->data.extended_irq.resource_source.string_ptr; 412 temp_ptr = (u8 *)
413 output_struct->data.extended_irq.resource_source.string_ptr;
427 414
428 /* Copy the string into the buffer */ 415 /* Copy the string into the buffer */
429 416
@@ -436,9 +423,8 @@ acpi_rs_extended_irq_resource (
436 index += 1; 423 index += 1;
437 } 424 }
438 425
439 /* 426 /* Add the terminating null */
440 * Add the terminating null 427
441 */
442 *temp_ptr = 0x00; 428 *temp_ptr = 0x00;
443 output_struct->data.extended_irq.resource_source.string_length = index + 1; 429 output_struct->data.extended_irq.resource_source.string_length = index + 1;
444 430
@@ -456,14 +442,12 @@ acpi_rs_extended_irq_resource (
456 output_struct->data.extended_irq.resource_source.string_ptr = NULL; 442 output_struct->data.extended_irq.resource_source.string_ptr = NULL;
457 } 443 }
458 444
459 /* 445 /* Set the Length parameter */
460 * Set the Length parameter 446
461 */
462 output_struct->length = (u32) struct_size; 447 output_struct->length = (u32) struct_size;
463 448
464 /* 449 /* Return the final size of the structure */
465 * Return the final size of the structure 450
466 */
467 *structure_size = struct_size; 451 *structure_size = struct_size;
468 return_ACPI_STATUS (AE_OK); 452 return_ACPI_STATUS (AE_OK);
469} 453}
@@ -501,21 +485,18 @@ acpi_rs_extended_irq_stream (
501 ACPI_FUNCTION_TRACE ("rs_extended_irq_stream"); 485 ACPI_FUNCTION_TRACE ("rs_extended_irq_stream");
502 486
503 487
504 /* 488 /* The descriptor field is static */
505 * The descriptor field is static 489
506 */
507 *buffer = 0x89; 490 *buffer = 0x89;
508 buffer += 1; 491 buffer += 1;
509 492
510 /* 493 /* Set a pointer to the Length field - to be filled in later */
511 * Set a pointer to the Length field - to be filled in later 494
512 */
513 length_field = ACPI_CAST_PTR (u16, buffer); 495 length_field = ACPI_CAST_PTR (u16, buffer);
514 buffer += 2; 496 buffer += 2;
515 497
516 /* 498 /* Set the Interrupt vector flags */
517 * Set the Interrupt vector flags 499
518 */
519 temp8 = (u8)(linked_list->data.extended_irq.producer_consumer & 0x01); 500 temp8 = (u8)(linked_list->data.extended_irq.producer_consumer & 0x01);
520 temp8 |= ((linked_list->data.extended_irq.shared_exclusive & 0x01) << 3); 501 temp8 |= ((linked_list->data.extended_irq.shared_exclusive & 0x01) << 3);
521 502
@@ -532,17 +513,15 @@ acpi_rs_extended_irq_stream (
532 temp8 |= 0x2; 513 temp8 |= 0x2;
533 } 514 }
534 515
535 /* 516 /* Set the Interrupt Polarity */
536 * Set the Interrupt Polarity 517
537 */
538 temp8 |= ((linked_list->data.extended_irq.active_high_low & 0x1) << 2); 518 temp8 |= ((linked_list->data.extended_irq.active_high_low & 0x1) << 2);
539 519
540 *buffer = temp8; 520 *buffer = temp8;
541 buffer += 1; 521 buffer += 1;
542 522
543 /* 523 /* Set the Interrupt table length */
544 * Set the Interrupt table length 524
545 */
546 temp8 = (u8) linked_list->data.extended_irq.number_of_interrupts; 525 temp8 = (u8) linked_list->data.extended_irq.number_of_interrupts;
547 526
548 *buffer = temp8; 527 *buffer = temp8;
@@ -555,18 +534,16 @@ acpi_rs_extended_irq_stream (
555 buffer += 4; 534 buffer += 4;
556 } 535 }
557 536
558 /* 537 /* Resource Source Index and Resource Source are optional */
559 * Resource Source Index and Resource Source are optional 538
560 */
561 if (0 != linked_list->data.extended_irq.resource_source.string_length) { 539 if (0 != linked_list->data.extended_irq.resource_source.string_length) {
562 *buffer = (u8) linked_list->data.extended_irq.resource_source.index; 540 *buffer = (u8) linked_list->data.extended_irq.resource_source.index;
563 buffer += 1; 541 buffer += 1;
564 542
565 temp_pointer = (char *) buffer; 543 temp_pointer = (char *) buffer;
566 544
567 /* 545 /* Copy the string */
568 * Copy the string 546
569 */
570 ACPI_STRCPY (temp_pointer, 547 ACPI_STRCPY (temp_pointer,
571 linked_list->data.extended_irq.resource_source.string_ptr); 548 linked_list->data.extended_irq.resource_source.string_ptr);
572 549
@@ -574,12 +551,12 @@ acpi_rs_extended_irq_stream (
574 * Buffer needs to be set to the length of the sting + one for the 551 * Buffer needs to be set to the length of the sting + one for the
575 * terminating null 552 * terminating null
576 */ 553 */
577 buffer += (acpi_size)(ACPI_STRLEN (linked_list->data.extended_irq.resource_source.string_ptr) + 1); 554 buffer += (acpi_size) (ACPI_STRLEN (
555 linked_list->data.extended_irq.resource_source.string_ptr) + 1);
578 } 556 }
579 557
580 /* 558 /* Return the number of bytes consumed in this operation */
581 * Return the number of bytes consumed in this operation 559
582 */
583 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 560 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
584 561
585 /* 562 /*