Merge master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-for-linus-2.6
[deliverable/linux.git] / drivers / acpi / resources / rscalc.c
1 /*******************************************************************************
2 *
3 * Module Name: rscalc - Calculate stream and list lengths
4 *
5 ******************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2005, R. Byron Moore
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44 #include <acpi/acpi.h>
45 #include <acpi/acresrc.h>
46 #include <acpi/amlcode.h>
47 #include <acpi/acnamesp.h>
48
49 #define _COMPONENT ACPI_RESOURCES
50 ACPI_MODULE_NAME("rscalc")
51
52 /*******************************************************************************
53 *
54 * FUNCTION: acpi_rs_get_byte_stream_length
55 *
56 * PARAMETERS: linked_list - Pointer to the resource linked list
57 * size_needed - u32 pointer of the size buffer needed
58 * to properly return the parsed data
59 *
60 * RETURN: Status
61 *
62 * DESCRIPTION: Takes the resource byte stream and parses it once, calculating
63 * the size buffer needed to hold the linked list that conveys
64 * the resource data.
65 *
66 ******************************************************************************/
67 acpi_status
68 acpi_rs_get_byte_stream_length(struct acpi_resource *linked_list,
69 acpi_size * size_needed)
70 {
71 acpi_size byte_stream_size_needed = 0;
72 acpi_size segment_size;
73 u8 done = FALSE;
74
75 ACPI_FUNCTION_TRACE("rs_get_byte_stream_length");
76
77 while (!done) {
78 /* Init the variable that will hold the size to add to the total. */
79
80 segment_size = 0;
81
82 switch (linked_list->id) {
83 case ACPI_RSTYPE_IRQ:
84 /*
85 * IRQ Resource
86 * For an IRQ Resource, Byte 3, although optional, will always be
87 * created - it holds IRQ information.
88 */
89 segment_size = 4;
90 break;
91
92 case ACPI_RSTYPE_DMA:
93 /*
94 * DMA Resource
95 * For this resource the size is static
96 */
97 segment_size = 3;
98 break;
99
100 case ACPI_RSTYPE_START_DPF:
101 /*
102 * Start Dependent Functions Resource
103 * For a start_dependent_functions Resource, Byte 1, although
104 * optional, will always be created.
105 */
106 segment_size = 2;
107 break;
108
109 case ACPI_RSTYPE_END_DPF:
110 /*
111 * End Dependent Functions Resource
112 * For this resource the size is static
113 */
114 segment_size = 1;
115 break;
116
117 case ACPI_RSTYPE_IO:
118 /*
119 * IO Port Resource
120 * For this resource the size is static
121 */
122 segment_size = 8;
123 break;
124
125 case ACPI_RSTYPE_FIXED_IO:
126 /*
127 * Fixed IO Port Resource
128 * For this resource the size is static
129 */
130 segment_size = 4;
131 break;
132
133 case ACPI_RSTYPE_VENDOR:
134 /*
135 * Vendor Defined Resource
136 * For a Vendor Specific resource, if the Length is between 1 and 7
137 * it will be created as a Small Resource data type, otherwise it
138 * is a Large Resource data type.
139 */
140 if (linked_list->data.vendor_specific.length > 7) {
141 segment_size = 3;
142 } else {
143 segment_size = 1;
144 }
145 segment_size +=
146 linked_list->data.vendor_specific.length;
147 break;
148
149 case ACPI_RSTYPE_END_TAG:
150 /*
151 * End Tag
152 * For this resource the size is static
153 */
154 segment_size = 2;
155 done = TRUE;
156 break;
157
158 case ACPI_RSTYPE_MEM24:
159 /*
160 * 24-Bit Memory Resource
161 * For this resource the size is static
162 */
163 segment_size = 12;
164 break;
165
166 case ACPI_RSTYPE_MEM32:
167 /*
168 * 32-Bit Memory Range Resource
169 * For this resource the size is static
170 */
171 segment_size = 20;
172 break;
173
174 case ACPI_RSTYPE_FIXED_MEM32:
175 /*
176 * 32-Bit Fixed Memory Resource
177 * For this resource the size is static
178 */
179 segment_size = 12;
180 break;
181
182 case ACPI_RSTYPE_ADDRESS16:
183 /*
184 * 16-Bit Address Resource
185 * The base size of this byte stream is 16. If a Resource Source
186 * string is not NULL, add 1 for the Index + the length of the null
187 * terminated string Resource Source + 1 for the null.
188 */
189 segment_size = 16;
190
191 if (linked_list->data.address16.resource_source.
192 string_ptr) {
193 segment_size +=
194 linked_list->data.address16.resource_source.
195 string_length;
196 segment_size++;
197 }
198 break;
199
200 case ACPI_RSTYPE_ADDRESS32:
201 /*
202 * 32-Bit Address Resource
203 * The base size of this byte stream is 26. If a Resource
204 * Source string is not NULL, add 1 for the Index + the
205 * length of the null terminated string Resource Source +
206 * 1 for the null.
207 */
208 segment_size = 26;
209
210 if (linked_list->data.address32.resource_source.
211 string_ptr) {
212 segment_size +=
213 linked_list->data.address32.resource_source.
214 string_length;
215 segment_size++;
216 }
217 break;
218
219 case ACPI_RSTYPE_ADDRESS64:
220 /*
221 * 64-Bit Address Resource
222 * The base size of this byte stream is 46. If a resource_source
223 * string is not NULL, add 1 for the Index + the length of the null
224 * terminated string Resource Source + 1 for the null.
225 */
226 segment_size = 46;
227
228 if (linked_list->data.address64.resource_source.
229 string_ptr) {
230 segment_size +=
231 linked_list->data.address64.resource_source.
232 string_length;
233 segment_size++;
234 }
235 break;
236
237 case ACPI_RSTYPE_EXT_IRQ:
238 /*
239 * Extended IRQ Resource
240 * The base size of this byte stream is 9. This is for an Interrupt
241 * table length of 1. For each additional interrupt, add 4.
242 * If a Resource Source string is not NULL, add 1 for the
243 * Index + the length of the null terminated string
244 * Resource Source + 1 for the null.
245 */
246 segment_size = 9 + (((acpi_size)
247 linked_list->data.extended_irq.
248 number_of_interrupts - 1) * 4);
249
250 if (linked_list->data.extended_irq.resource_source.
251 string_ptr) {
252 segment_size +=
253 linked_list->data.extended_irq.
254 resource_source.string_length;
255 segment_size++;
256 }
257 break;
258
259 default:
260
261 /* If we get here, everything is out of sync, exit with error */
262
263 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
264
265 } /* switch (linked_list->Id) */
266
267 /* Update the total */
268
269 byte_stream_size_needed += segment_size;
270
271 /* Point to the next object */
272
273 linked_list = ACPI_PTR_ADD(struct acpi_resource,
274 linked_list, linked_list->length);
275 }
276
277 /* This is the data the caller needs */
278
279 *size_needed = byte_stream_size_needed;
280 return_ACPI_STATUS(AE_OK);
281 }
282
283 /*******************************************************************************
284 *
285 * FUNCTION: acpi_rs_get_list_length
286 *
287 * PARAMETERS: byte_stream_buffer - Pointer to the resource byte stream
288 * byte_stream_buffer_length - Size of byte_stream_buffer
289 * size_needed - u32 pointer of the size buffer
290 * needed to properly return the
291 * parsed data
292 *
293 * RETURN: Status
294 *
295 * DESCRIPTION: Takes the resource byte stream and parses it once, calculating
296 * the size buffer needed to hold the linked list that conveys
297 * the resource data.
298 *
299 ******************************************************************************/
300
301 acpi_status
302 acpi_rs_get_list_length(u8 * byte_stream_buffer,
303 u32 byte_stream_buffer_length, acpi_size * size_needed)
304 {
305 u32 buffer_size = 0;
306 u32 bytes_parsed = 0;
307 u8 number_of_interrupts = 0;
308 u8 number_of_channels = 0;
309 u8 resource_type;
310 u32 structure_size;
311 u32 bytes_consumed;
312 u8 *buffer;
313 u8 temp8;
314 u16 temp16;
315 u8 index;
316 u8 additional_bytes;
317
318 ACPI_FUNCTION_TRACE("rs_get_list_length");
319
320 while (bytes_parsed < byte_stream_buffer_length) {
321 /* The next byte in the stream is the resource type */
322
323 resource_type = acpi_rs_get_resource_type(*byte_stream_buffer);
324
325 switch (resource_type) {
326 case ACPI_RDESC_TYPE_MEMORY_24:
327 /*
328 * 24-Bit Memory Resource
329 */
330 bytes_consumed = 12;
331
332 structure_size =
333 ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem24);
334 break;
335
336 case ACPI_RDESC_TYPE_LARGE_VENDOR:
337 /*
338 * Vendor Defined Resource
339 */
340 buffer = byte_stream_buffer;
341 ++buffer;
342
343 ACPI_MOVE_16_TO_16(&temp16, buffer);
344 bytes_consumed = temp16 + 3;
345
346 /* Ensure a 32-bit boundary for the structure */
347
348 temp16 = (u16) ACPI_ROUND_UP_to_32_bITS(temp16);
349
350 structure_size =
351 ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor) +
352 (temp16 * sizeof(u8));
353 break;
354
355 case ACPI_RDESC_TYPE_MEMORY_32:
356 /*
357 * 32-Bit Memory Range Resource
358 */
359 bytes_consumed = 20;
360
361 structure_size =
362 ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem32);
363 break;
364
365 case ACPI_RDESC_TYPE_FIXED_MEMORY_32:
366 /*
367 * 32-Bit Fixed Memory Resource
368 */
369 bytes_consumed = 12;
370
371 structure_size =
372 ACPI_SIZEOF_RESOURCE(struct
373 acpi_resource_fixed_mem32);
374 break;
375
376 case ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE:
377 /*
378 * 64-Bit Address Resource
379 */
380 buffer = byte_stream_buffer;
381
382 ++buffer;
383 ACPI_MOVE_16_TO_16(&temp16, buffer);
384
385 bytes_consumed = temp16 + 3;
386 structure_size =
387 ACPI_SIZEOF_RESOURCE(struct
388 acpi_resource_address64);
389 break;
390
391 case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE:
392 /*
393 * 64-Bit Address Resource
394 */
395 buffer = byte_stream_buffer;
396
397 ++buffer;
398 ACPI_MOVE_16_TO_16(&temp16, buffer);
399
400 bytes_consumed = temp16 + 3;
401
402 /*
403 * Resource Source Index and Resource Source are optional elements.
404 * Check the length of the Bytestream. If it is greater than 43,
405 * that means that an Index exists and is followed by a null
406 * terminated string. Therefore, set the temp variable to the
407 * length minus the minimum byte stream length plus the byte for
408 * the Index to determine the size of the NULL terminated string.
409 */
410 if (43 < temp16) {
411 temp8 = (u8) (temp16 - 44);
412 } else {
413 temp8 = 0;
414 }
415
416 /* Ensure a 64-bit boundary for the structure */
417
418 temp8 = (u8) ACPI_ROUND_UP_to_64_bITS(temp8);
419
420 structure_size =
421 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64)
422 + (temp8 * sizeof(u8));
423 break;
424
425 case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE:
426 /*
427 * 32-Bit Address Resource
428 */
429 buffer = byte_stream_buffer;
430
431 ++buffer;
432 ACPI_MOVE_16_TO_16(&temp16, buffer);
433
434 bytes_consumed = temp16 + 3;
435
436 /*
437 * Resource Source Index and Resource Source are optional elements.
438 * Check the length of the Bytestream. If it is greater than 23,
439 * that means that an Index exists and is followed by a null
440 * terminated string. Therefore, set the temp variable to the
441 * length minus the minimum byte stream length plus the byte for
442 * the Index to determine the size of the NULL terminated string.
443 */
444 if (23 < temp16) {
445 temp8 = (u8) (temp16 - 24);
446 } else {
447 temp8 = 0;
448 }
449
450 /* Ensure a 32-bit boundary for the structure */
451
452 temp8 = (u8) ACPI_ROUND_UP_to_32_bITS(temp8);
453
454 structure_size =
455 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32)
456 + (temp8 * sizeof(u8));
457 break;
458
459 case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE:
460 /*
461 * 16-Bit Address Resource
462 */
463 buffer = byte_stream_buffer;
464
465 ++buffer;
466 ACPI_MOVE_16_TO_16(&temp16, buffer);
467
468 bytes_consumed = temp16 + 3;
469
470 /*
471 * Resource Source Index and Resource Source are optional elements.
472 * Check the length of the Bytestream. If it is greater than 13,
473 * that means that an Index exists and is followed by a null
474 * terminated string. Therefore, set the temp variable to the
475 * length minus the minimum byte stream length plus the byte for
476 * the Index to determine the size of the NULL terminated string.
477 */
478 if (13 < temp16) {
479 temp8 = (u8) (temp16 - 14);
480 } else {
481 temp8 = 0;
482 }
483
484 /* Ensure a 32-bit boundary for the structure */
485
486 temp8 = (u8) ACPI_ROUND_UP_to_32_bITS(temp8);
487
488 structure_size =
489 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16)
490 + (temp8 * sizeof(u8));
491 break;
492
493 case ACPI_RDESC_TYPE_EXTENDED_XRUPT:
494 /*
495 * Extended IRQ
496 */
497 buffer = byte_stream_buffer;
498
499 ++buffer;
500 ACPI_MOVE_16_TO_16(&temp16, buffer);
501
502 bytes_consumed = temp16 + 3;
503
504 /*
505 * Point past the length field and the Interrupt vector flags to
506 * save off the Interrupt table length to the Temp8 variable.
507 */
508 buffer += 3;
509 temp8 = *buffer;
510
511 /*
512 * To compensate for multiple interrupt numbers, add 4 bytes for
513 * each additional interrupts greater than 1
514 */
515 additional_bytes = (u8) ((temp8 - 1) * 4);
516
517 /*
518 * Resource Source Index and Resource Source are optional elements.
519 * Check the length of the Bytestream. If it is greater than 9,
520 * that means that an Index exists and is followed by a null
521 * terminated string. Therefore, set the temp variable to the
522 * length minus the minimum byte stream length plus the byte for
523 * the Index to determine the size of the NULL terminated string.
524 */
525 if (9 + additional_bytes < temp16) {
526 temp8 = (u8) (temp16 - (9 + additional_bytes));
527 } else {
528 temp8 = 0;
529 }
530
531 /* Ensure a 32-bit boundary for the structure */
532
533 temp8 = (u8) ACPI_ROUND_UP_to_32_bITS(temp8);
534
535 structure_size =
536 ACPI_SIZEOF_RESOURCE(struct acpi_resource_ext_irq) +
537 (additional_bytes * sizeof(u8)) +
538 (temp8 * sizeof(u8));
539 break;
540
541 case ACPI_RDESC_TYPE_IRQ_FORMAT:
542 /*
543 * IRQ Resource.
544 * Determine if it there are two or three trailing bytes
545 */
546 buffer = byte_stream_buffer;
547 temp8 = *buffer;
548
549 if (temp8 & 0x01) {
550 bytes_consumed = 4;
551 } else {
552 bytes_consumed = 3;
553 }
554
555 /* Point past the descriptor */
556
557 ++buffer;
558
559 /* Look at the number of bits set */
560
561 ACPI_MOVE_16_TO_16(&temp16, buffer);
562
563 for (index = 0; index < 16; index++) {
564 if (temp16 & 0x1) {
565 ++number_of_interrupts;
566 }
567
568 temp16 >>= 1;
569 }
570
571 structure_size =
572 ACPI_SIZEOF_RESOURCE(struct acpi_resource_io) +
573 (number_of_interrupts * sizeof(u32));
574 break;
575
576 case ACPI_RDESC_TYPE_DMA_FORMAT:
577 /*
578 * DMA Resource
579 */
580 buffer = byte_stream_buffer;
581 bytes_consumed = 3;
582
583 /* Point past the descriptor */
584
585 ++buffer;
586
587 /* Look at the number of bits set */
588
589 temp8 = *buffer;
590
591 for (index = 0; index < 8; index++) {
592 if (temp8 & 0x1) {
593 ++number_of_channels;
594 }
595
596 temp8 >>= 1;
597 }
598
599 structure_size =
600 ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma) +
601 (number_of_channels * sizeof(u32));
602 break;
603
604 case ACPI_RDESC_TYPE_START_DEPENDENT:
605 /*
606 * Start Dependent Functions Resource
607 * Determine if it there are two or three trailing bytes
608 */
609 buffer = byte_stream_buffer;
610 temp8 = *buffer;
611
612 if (temp8 & 0x01) {
613 bytes_consumed = 2;
614 } else {
615 bytes_consumed = 1;
616 }
617
618 structure_size =
619 ACPI_SIZEOF_RESOURCE(struct
620 acpi_resource_start_dpf);
621 break;
622
623 case ACPI_RDESC_TYPE_END_DEPENDENT:
624 /*
625 * End Dependent Functions Resource
626 */
627 bytes_consumed = 1;
628 structure_size = ACPI_RESOURCE_LENGTH;
629 break;
630
631 case ACPI_RDESC_TYPE_IO_PORT:
632 /*
633 * IO Port Resource
634 */
635 bytes_consumed = 8;
636 structure_size =
637 ACPI_SIZEOF_RESOURCE(struct acpi_resource_io);
638 break;
639
640 case ACPI_RDESC_TYPE_FIXED_IO_PORT:
641 /*
642 * Fixed IO Port Resource
643 */
644 bytes_consumed = 4;
645 structure_size =
646 ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io);
647 break;
648
649 case ACPI_RDESC_TYPE_SMALL_VENDOR:
650 /*
651 * Vendor Specific Resource
652 */
653 buffer = byte_stream_buffer;
654
655 temp8 = *buffer;
656 temp8 = (u8) (temp8 & 0x7);
657 bytes_consumed = temp8 + 1;
658
659 /* Ensure a 32-bit boundary for the structure */
660
661 temp8 = (u8) ACPI_ROUND_UP_to_32_bITS(temp8);
662 structure_size =
663 ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor) +
664 (temp8 * sizeof(u8));
665 break;
666
667 case ACPI_RDESC_TYPE_END_TAG:
668 /*
669 * End Tag
670 */
671 bytes_consumed = 2;
672 structure_size = ACPI_RESOURCE_LENGTH;
673 byte_stream_buffer_length = bytes_parsed;
674 break;
675
676 default:
677 /*
678 * If we get here, everything is out of sync,
679 * exit with an error
680 */
681 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
682 }
683
684 /* Update the return value and counter */
685
686 buffer_size += (u32) ACPI_ALIGN_RESOURCE_SIZE(structure_size);
687 bytes_parsed += bytes_consumed;
688
689 /* Set the byte stream to point to the next resource */
690
691 byte_stream_buffer += bytes_consumed;
692 }
693
694 /* This is the data the caller needs */
695
696 *size_needed = buffer_size;
697 return_ACPI_STATUS(AE_OK);
698 }
699
700 /*******************************************************************************
701 *
702 * FUNCTION: acpi_rs_get_pci_routing_table_length
703 *
704 * PARAMETERS: package_object - Pointer to the package object
705 * buffer_size_needed - u32 pointer of the size buffer
706 * needed to properly return the
707 * parsed data
708 *
709 * RETURN: Status
710 *
711 * DESCRIPTION: Given a package representing a PCI routing table, this
712 * calculates the size of the corresponding linked list of
713 * descriptions.
714 *
715 ******************************************************************************/
716
717 acpi_status
718 acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object,
719 acpi_size * buffer_size_needed)
720 {
721 u32 number_of_elements;
722 acpi_size temp_size_needed = 0;
723 union acpi_operand_object **top_object_list;
724 u32 index;
725 union acpi_operand_object *package_element;
726 union acpi_operand_object **sub_object_list;
727 u8 name_found;
728 u32 table_index;
729
730 ACPI_FUNCTION_TRACE("rs_get_pci_routing_table_length");
731
732 number_of_elements = package_object->package.count;
733
734 /*
735 * Calculate the size of the return buffer.
736 * The base size is the number of elements * the sizes of the
737 * structures. Additional space for the strings is added below.
738 * The minus one is to subtract the size of the u8 Source[1]
739 * member because it is added below.
740 *
741 * But each PRT_ENTRY structure has a pointer to a string and
742 * the size of that string must be found.
743 */
744 top_object_list = package_object->package.elements;
745
746 for (index = 0; index < number_of_elements; index++) {
747 /* Dereference the sub-package */
748
749 package_element = *top_object_list;
750
751 /*
752 * The sub_object_list will now point to an array of the
753 * four IRQ elements: Address, Pin, Source and source_index
754 */
755 sub_object_list = package_element->package.elements;
756
757 /* Scan the irq_table_elements for the Source Name String */
758
759 name_found = FALSE;
760
761 for (table_index = 0; table_index < 4 && !name_found;
762 table_index++) {
763 if ((ACPI_TYPE_STRING ==
764 ACPI_GET_OBJECT_TYPE(*sub_object_list))
765 ||
766 ((ACPI_TYPE_LOCAL_REFERENCE ==
767 ACPI_GET_OBJECT_TYPE(*sub_object_list))
768 && ((*sub_object_list)->reference.opcode ==
769 AML_INT_NAMEPATH_OP))) {
770 name_found = TRUE;
771 } else {
772 /* Look at the next element */
773
774 sub_object_list++;
775 }
776 }
777
778 temp_size_needed += (sizeof(struct acpi_pci_routing_table) - 4);
779
780 /* Was a String type found? */
781
782 if (name_found) {
783 if (ACPI_GET_OBJECT_TYPE(*sub_object_list) ==
784 ACPI_TYPE_STRING) {
785 /*
786 * The length String.Length field does not include the
787 * terminating NULL, add 1
788 */
789 temp_size_needed += ((acpi_size)
790 (*sub_object_list)->string.
791 length + 1);
792 } else {
793 temp_size_needed += acpi_ns_get_pathname_length((*sub_object_list)->reference.node);
794 }
795 } else {
796 /*
797 * If no name was found, then this is a NULL, which is
798 * translated as a u32 zero.
799 */
800 temp_size_needed += sizeof(u32);
801 }
802
803 /* Round up the size since each element must be aligned */
804
805 temp_size_needed = ACPI_ROUND_UP_to_64_bITS(temp_size_needed);
806
807 /* Point to the next union acpi_operand_object */
808
809 top_object_list++;
810 }
811
812 /*
813 * Adding an extra element to the end of the list, essentially a
814 * NULL terminator
815 */
816 *buffer_size_needed =
817 temp_size_needed + sizeof(struct acpi_pci_routing_table);
818 return_ACPI_STATUS(AE_OK);
819 }
This page took 0.050865 seconds and 6 git commands to generate.