xref: /titanic_50/usr/src/uts/intel/io/acpica/resources/rscalc.c (revision c5c4113dfcabb1eed3d4bdf7609de5170027a794)
1 /*******************************************************************************
2  *
3  * Module Name: rscalc - Calculate stream and list lengths
4  *              $Revision: 1.79 $
5  *
6  ******************************************************************************/
7 
8 /******************************************************************************
9  *
10  * 1. Copyright Notice
11  *
12  * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp.
13  * All rights reserved.
14  *
15  * 2. License
16  *
17  * 2.1. This is your license from Intel Corp. under its intellectual property
18  * rights.  You may have additional license terms from the party that provided
19  * you this software, covering your right to use that party's intellectual
20  * property rights.
21  *
22  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23  * copy of the source code appearing in this file ("Covered Code") an
24  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25  * base code distributed originally by Intel ("Original Intel Code") to copy,
26  * make derivatives, distribute, use and display any portion of the Covered
27  * Code in any form, with the right to sublicense such rights; and
28  *
29  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30  * license (with the right to sublicense), under only those claims of Intel
31  * patents that are infringed by the Original Intel Code, to make, use, sell,
32  * offer to sell, and import the Covered Code and derivative works thereof
33  * solely to the minimum extent necessary to exercise the above copyright
34  * license, and in no event shall the patent license extend to any additions
35  * to or modifications of the Original Intel Code.  No other license or right
36  * is granted directly or by implication, estoppel or otherwise;
37  *
38  * The above copyright and patent license is granted only if the following
39  * conditions are met:
40  *
41  * 3. Conditions
42  *
43  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44  * Redistribution of source code of any substantial portion of the Covered
45  * Code or modification with rights to further distribute source must include
46  * the above Copyright Notice, the above License, this list of Conditions,
47  * and the following Disclaimer and Export Compliance provision.  In addition,
48  * Licensee must cause all Covered Code to which Licensee contributes to
49  * contain a file documenting the changes Licensee made to create that Covered
50  * Code and the date of any change.  Licensee must include in that file the
51  * documentation of any changes made by any predecessor Licensee.  Licensee
52  * must include a prominent statement that the modification is derived,
53  * directly or indirectly, from Original Intel Code.
54  *
55  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56  * Redistribution of source code of any substantial portion of the Covered
57  * Code or modification without rights to further distribute source must
58  * include the following Disclaimer and Export Compliance provision in the
59  * documentation and/or other materials provided with distribution.  In
60  * addition, Licensee may not authorize further sublicense of source of any
61  * portion of the Covered Code, and must include terms to the effect that the
62  * license from Licensee to its licensee is limited to the intellectual
63  * property embodied in the software Licensee provides to its licensee, and
64  * not to intellectual property embodied in modifications its licensee may
65  * make.
66  *
67  * 3.3. Redistribution of Executable. Redistribution in executable form of any
68  * substantial portion of the Covered Code or modification must reproduce the
69  * above Copyright Notice, and the following Disclaimer and Export Compliance
70  * provision in the documentation and/or other materials provided with the
71  * distribution.
72  *
73  * 3.4. Intel retains all right, title, and interest in and to the Original
74  * Intel Code.
75  *
76  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77  * Intel shall be used in advertising or otherwise to promote the sale, use or
78  * other dealings in products derived from or relating to the Covered Code
79  * without prior written authorization from Intel.
80  *
81  * 4. Disclaimer and Export Compliance
82  *
83  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89  * PARTICULAR PURPOSE.
90  *
91  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98  * LIMITED REMEDY.
99  *
100  * 4.3. Licensee shall not export, either directly or indirectly, any of this
101  * software or system incorporating such software without first obtaining any
102  * required license or other approval from the U. S. Department of Commerce or
103  * any other agency or department of the United States Government.  In the
104  * event Licensee exports any such software from the United States or
105  * re-exports any such software from a foreign destination, Licensee shall
106  * ensure that the distribution and export/re-export of the software is in
107  * compliance with all laws, regulations, orders, or other restrictions of the
108  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109  * any of its subsidiaries will export/re-export any technical data, process,
110  * software, or service, directly or indirectly, to any country for which the
111  * United States government or any agency thereof requires an export license,
112  * other governmental approval, or letter of assurance, without first obtaining
113  * such license, approval or letter.
114  *
115  *****************************************************************************/
116 
117 #define __RSCALC_C__
118 
119 #include "acpi.h"
120 #include "acresrc.h"
121 #include "amlcode.h"
122 #include "acnamesp.h"
123 
124 #define _COMPONENT          ACPI_RESOURCES
125         ACPI_MODULE_NAME    ("rscalc")
126 
127 
128 /* Local prototypes */
129 
130 static UINT8
131 AcpiRsCountSetBits (
132     UINT16                  BitField);
133 
134 static ACPI_RS_LENGTH
135 AcpiRsStructOptionLength (
136     ACPI_RESOURCE_SOURCE    *ResourceSource);
137 
138 static UINT32
139 AcpiRsStreamOptionLength (
140     UINT32                  ResourceLength,
141     UINT32                  MinimumTotalLength);
142 
143 
144 /*******************************************************************************
145  *
146  * FUNCTION:    AcpiRsCountSetBits
147  *
148  * PARAMETERS:  BitField        - Field in which to count bits
149  *
150  * RETURN:      Number of bits set within the field
151  *
152  * DESCRIPTION: Count the number of bits set in a resource field. Used for
153  *              (Short descriptor) interrupt and DMA lists.
154  *
155  ******************************************************************************/
156 
157 static UINT8
158 AcpiRsCountSetBits (
159     UINT16                  BitField)
160 {
161     UINT8                   BitsSet;
162 
163 
164     ACPI_FUNCTION_ENTRY ();
165 
166 
167     for (BitsSet = 0; BitField; BitsSet++)
168     {
169         /* Zero the least significant bit that is set */
170 
171         BitField &= (BitField - 1);
172     }
173 
174     return (BitsSet);
175 }
176 
177 
178 /*******************************************************************************
179  *
180  * FUNCTION:    AcpiRsStructOptionLength
181  *
182  * PARAMETERS:  ResourceSource      - Pointer to optional descriptor field
183  *
184  * RETURN:      Status
185  *
186  * DESCRIPTION: Common code to handle optional ResourceSourceIndex and
187  *              ResourceSource fields in some Large descriptors. Used during
188  *              list-to-stream conversion
189  *
190  ******************************************************************************/
191 
192 static ACPI_RS_LENGTH
193 AcpiRsStructOptionLength (
194     ACPI_RESOURCE_SOURCE    *ResourceSource)
195 {
196     ACPI_FUNCTION_ENTRY ();
197 
198 
199     /*
200      * If the ResourceSource string is valid, return the size of the string
201      * (StringLength includes the NULL terminator) plus the size of the
202      * ResourceSourceIndex (1).
203      */
204     if (ResourceSource->StringPtr)
205     {
206         return ((ACPI_RS_LENGTH) (ResourceSource->StringLength + 1));
207     }
208 
209     return (0);
210 }
211 
212 
213 /*******************************************************************************
214  *
215  * FUNCTION:    AcpiRsStreamOptionLength
216  *
217  * PARAMETERS:  ResourceLength      - Length from the resource header
218  *              MinimumTotalLength  - Minimum length of this resource, before
219  *                                    any optional fields. Includes header size
220  *
221  * RETURN:      Length of optional string (0 if no string present)
222  *
223  * DESCRIPTION: Common code to handle optional ResourceSourceIndex and
224  *              ResourceSource fields in some Large descriptors. Used during
225  *              stream-to-list conversion
226  *
227  ******************************************************************************/
228 
229 static UINT32
230 AcpiRsStreamOptionLength (
231     UINT32                  ResourceLength,
232     UINT32                  MinimumAmlResourceLength)
233 {
234     UINT32                  StringLength = 0;
235 
236 
237     ACPI_FUNCTION_ENTRY ();
238 
239 
240     /*
241      * The ResourceSourceIndex and ResourceSource are optional elements of some
242      * Large-type resource descriptors.
243      */
244 
245     /*
246      * If the length of the actual resource descriptor is greater than the ACPI
247      * spec-defined minimum length, it means that a ResourceSourceIndex exists
248      * and is followed by a (required) null terminated string. The string length
249      * (including the null terminator) is the resource length minus the minimum
250      * length, minus one byte for the ResourceSourceIndex itself.
251      */
252     if (ResourceLength > MinimumAmlResourceLength)
253     {
254         /* Compute the length of the optional string */
255 
256         StringLength = ResourceLength - MinimumAmlResourceLength - 1;
257     }
258 
259     /*
260      * Round the length up to a multiple of the native word in order to
261      * guarantee that the entire resource descriptor is native word aligned
262      */
263     return ((UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (StringLength));
264 }
265 
266 
267 /*******************************************************************************
268  *
269  * FUNCTION:    AcpiRsGetAmlLength
270  *
271  * PARAMETERS:  Resource            - Pointer to the resource linked list
272  *              SizeNeeded          - Where the required size is returned
273  *
274  * RETURN:      Status
275  *
276  * DESCRIPTION: Takes a linked list of internal resource descriptors and
277  *              calculates the size buffer needed to hold the corresponding
278  *              external resource byte stream.
279  *
280  ******************************************************************************/
281 
282 ACPI_STATUS
283 AcpiRsGetAmlLength (
284     ACPI_RESOURCE           *Resource,
285     ACPI_SIZE               *SizeNeeded)
286 {
287     ACPI_SIZE               AmlSizeNeeded = 0;
288     ACPI_RS_LENGTH          TotalSize;
289 
290 
291     ACPI_FUNCTION_TRACE (RsGetAmlLength);
292 
293 
294     /* Traverse entire list of internal resource descriptors */
295 
296     while (Resource)
297     {
298         /* Validate the descriptor type */
299 
300         if (Resource->Type > ACPI_RESOURCE_TYPE_MAX)
301         {
302             return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
303         }
304 
305         /* Get the base size of the (external stream) resource descriptor */
306 
307         TotalSize = AcpiGbl_AmlResourceSizes [Resource->Type];
308 
309         /*
310          * Augment the base size for descriptors with optional and/or
311          * variable-length fields
312          */
313         switch (Resource->Type)
314         {
315         case ACPI_RESOURCE_TYPE_VENDOR:
316             /*
317              * Vendor Defined Resource:
318              * For a Vendor Specific resource, if the Length is between 1 and 7
319              * it will be created as a Small Resource data type, otherwise it
320              * is a Large Resource data type.
321              */
322             if (Resource->Data.Vendor.ByteLength > 7)
323             {
324                 /* Base size of a Large resource descriptor */
325 
326                 TotalSize = sizeof (AML_RESOURCE_LARGE_HEADER);
327             }
328 
329             /* Add the size of the vendor-specific data */
330 
331             TotalSize = (ACPI_RS_LENGTH)
332                 (TotalSize + Resource->Data.Vendor.ByteLength);
333             break;
334 
335 
336         case ACPI_RESOURCE_TYPE_END_TAG:
337             /*
338              * End Tag:
339              * We are done -- return the accumulated total size.
340              */
341             *SizeNeeded = AmlSizeNeeded + TotalSize;
342 
343             /* Normal exit */
344 
345             return_ACPI_STATUS (AE_OK);
346 
347 
348         case ACPI_RESOURCE_TYPE_ADDRESS16:
349             /*
350              * 16-Bit Address Resource:
351              * Add the size of the optional ResourceSource info
352              */
353             TotalSize = (ACPI_RS_LENGTH)
354                 (TotalSize + AcpiRsStructOptionLength (
355                                 &Resource->Data.Address16.ResourceSource));
356             break;
357 
358 
359         case ACPI_RESOURCE_TYPE_ADDRESS32:
360             /*
361              * 32-Bit Address Resource:
362              * Add the size of the optional ResourceSource info
363              */
364             TotalSize = (ACPI_RS_LENGTH)
365                 (TotalSize + AcpiRsStructOptionLength (
366                                 &Resource->Data.Address32.ResourceSource));
367             break;
368 
369 
370         case ACPI_RESOURCE_TYPE_ADDRESS64:
371             /*
372              * 64-Bit Address Resource:
373              * Add the size of the optional ResourceSource info
374              */
375             TotalSize = (ACPI_RS_LENGTH)
376                 (TotalSize + AcpiRsStructOptionLength (
377                                 &Resource->Data.Address64.ResourceSource));
378             break;
379 
380 
381         case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
382             /*
383              * Extended IRQ Resource:
384              * Add the size of each additional optional interrupt beyond the
385              * required 1 (4 bytes for each UINT32 interrupt number)
386              */
387             TotalSize = (ACPI_RS_LENGTH)
388                 (TotalSize +
389                 ((Resource->Data.ExtendedIrq.InterruptCount - 1) * 4) +
390 
391                 /* Add the size of the optional ResourceSource info */
392 
393                 AcpiRsStructOptionLength (
394                     &Resource->Data.ExtendedIrq.ResourceSource));
395             break;
396 
397 
398         default:
399             break;
400         }
401 
402         /* Update the total */
403 
404         AmlSizeNeeded += TotalSize;
405 
406         /* Point to the next object */
407 
408         Resource = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, Resource->Length);
409     }
410 
411     /* Did not find an EndTag resource descriptor */
412 
413     return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
414 }
415 
416 
417 /*******************************************************************************
418  *
419  * FUNCTION:    AcpiRsGetListLength
420  *
421  * PARAMETERS:  AmlBuffer           - Pointer to the resource byte stream
422  *              AmlBufferLength     - Size of AmlBuffer
423  *              SizeNeeded          - Where the size needed is returned
424  *
425  * RETURN:      Status
426  *
427  * DESCRIPTION: Takes an external resource byte stream and calculates the size
428  *              buffer needed to hold the corresponding internal resource
429  *              descriptor linked list.
430  *
431  ******************************************************************************/
432 
433 ACPI_STATUS
434 AcpiRsGetListLength (
435     UINT8                   *AmlBuffer,
436     UINT32                  AmlBufferLength,
437     ACPI_SIZE               *SizeNeeded)
438 {
439     ACPI_STATUS             Status;
440     UINT8                   *EndAml;
441     UINT8                   *Buffer;
442     UINT32                  BufferSize;
443     UINT16                  Temp16;
444     UINT16                  ResourceLength;
445     UINT32                  ExtraStructBytes;
446     UINT8                   ResourceIndex;
447     UINT8                   MinimumAmlResourceLength;
448 
449 
450     ACPI_FUNCTION_TRACE (RsGetListLength);
451 
452 
453     *SizeNeeded = 0;
454     EndAml = AmlBuffer + AmlBufferLength;
455 
456     /* Walk the list of AML resource descriptors */
457 
458     while (AmlBuffer < EndAml)
459     {
460         /* Validate the Resource Type and Resource Length */
461 
462         Status = AcpiUtValidateResource (AmlBuffer, &ResourceIndex);
463         if (ACPI_FAILURE (Status))
464         {
465             return_ACPI_STATUS (Status);
466         }
467 
468         /* Get the resource length and base (minimum) AML size */
469 
470         ResourceLength = AcpiUtGetResourceLength (AmlBuffer);
471         MinimumAmlResourceLength = AcpiGbl_ResourceAmlSizes[ResourceIndex];
472 
473         /*
474          * Augment the size for descriptors with optional
475          * and/or variable length fields
476          */
477         ExtraStructBytes = 0;
478         Buffer = AmlBuffer + AcpiUtGetResourceHeaderLength (AmlBuffer);
479 
480         switch (AcpiUtGetResourceType (AmlBuffer))
481         {
482         case ACPI_RESOURCE_NAME_IRQ:
483             /*
484              * IRQ Resource:
485              * Get the number of bits set in the 16-bit IRQ mask
486              */
487             ACPI_MOVE_16_TO_16 (&Temp16, Buffer);
488             ExtraStructBytes = AcpiRsCountSetBits (Temp16);
489             break;
490 
491 
492         case ACPI_RESOURCE_NAME_DMA:
493             /*
494              * DMA Resource:
495              * Get the number of bits set in the 8-bit DMA mask
496              */
497             ExtraStructBytes = AcpiRsCountSetBits (*Buffer);
498             break;
499 
500 
501         case ACPI_RESOURCE_NAME_VENDOR_SMALL:
502         case ACPI_RESOURCE_NAME_VENDOR_LARGE:
503             /*
504              * Vendor Resource:
505              * Get the number of vendor data bytes
506              */
507             ExtraStructBytes = ResourceLength;
508             break;
509 
510 
511         case ACPI_RESOURCE_NAME_END_TAG:
512             /*
513              * End Tag:
514              * This is the normal exit, add size of EndTag
515              */
516             *SizeNeeded += ACPI_RS_SIZE_MIN;
517             return_ACPI_STATUS (AE_OK);
518 
519 
520         case ACPI_RESOURCE_NAME_ADDRESS32:
521         case ACPI_RESOURCE_NAME_ADDRESS16:
522         case ACPI_RESOURCE_NAME_ADDRESS64:
523             /*
524              * Address Resource:
525              * Add the size of the optional ResourceSource
526              */
527             ExtraStructBytes = AcpiRsStreamOptionLength (
528                 ResourceLength, MinimumAmlResourceLength);
529             break;
530 
531 
532         case ACPI_RESOURCE_NAME_EXTENDED_IRQ:
533             /*
534              * Extended IRQ Resource:
535              * Using the InterruptTableLength, add 4 bytes for each additional
536              * interrupt. Note: at least one interrupt is required and is
537              * included in the minimum descriptor size (reason for the -1)
538              */
539             ExtraStructBytes = (Buffer[1] - 1) * sizeof (UINT32);
540 
541             /* Add the size of the optional ResourceSource */
542 
543             ExtraStructBytes += AcpiRsStreamOptionLength (
544                 ResourceLength - ExtraStructBytes, MinimumAmlResourceLength);
545             break;
546 
547 
548         default:
549             break;
550         }
551 
552         /*
553          * Update the required buffer size for the internal descriptor structs
554          *
555          * Important: Round the size up for the appropriate alignment. This
556          * is a requirement on IA64.
557          */
558         BufferSize = AcpiGbl_ResourceStructSizes[ResourceIndex] +
559                         ExtraStructBytes;
560         BufferSize = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (BufferSize);
561 
562         *SizeNeeded += BufferSize;
563 
564         ACPI_DEBUG_PRINT ((ACPI_DB_RESOURCES,
565             "Type %.2X, AmlLength %.2X InternalLength %.2X\n",
566             AcpiUtGetResourceType (AmlBuffer),
567             AcpiUtGetDescriptorLength (AmlBuffer), BufferSize));
568 
569         /*
570          * Point to the next resource within the AML stream using the length
571          * contained in the resource descriptor header
572          */
573         AmlBuffer += AcpiUtGetDescriptorLength (AmlBuffer);
574     }
575 
576     /* Did not find an EndTag resource descriptor */
577 
578     return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
579 }
580 
581 
582 /*******************************************************************************
583  *
584  * FUNCTION:    AcpiRsGetPciRoutingTableLength
585  *
586  * PARAMETERS:  PackageObject           - Pointer to the package object
587  *              BufferSizeNeeded        - UINT32 pointer of the size buffer
588  *                                        needed to properly return the
589  *                                        parsed data
590  *
591  * RETURN:      Status
592  *
593  * DESCRIPTION: Given a package representing a PCI routing table, this
594  *              calculates the size of the corresponding linked list of
595  *              descriptions.
596  *
597  ******************************************************************************/
598 
599 ACPI_STATUS
600 AcpiRsGetPciRoutingTableLength (
601     ACPI_OPERAND_OBJECT     *PackageObject,
602     ACPI_SIZE               *BufferSizeNeeded)
603 {
604     UINT32                  NumberOfElements;
605     ACPI_SIZE               TempSizeNeeded = 0;
606     ACPI_OPERAND_OBJECT     **TopObjectList;
607     UINT32                  Index;
608     ACPI_OPERAND_OBJECT     *PackageElement;
609     ACPI_OPERAND_OBJECT     **SubObjectList;
610     BOOLEAN                 NameFound;
611     UINT32                  TableIndex;
612 
613 
614     ACPI_FUNCTION_TRACE (RsGetPciRoutingTableLength);
615 
616 
617     NumberOfElements = PackageObject->Package.Count;
618 
619     /*
620      * Calculate the size of the return buffer.
621      * The base size is the number of elements * the sizes of the
622      * structures.  Additional space for the strings is added below.
623      * The minus one is to subtract the size of the UINT8 Source[1]
624      * member because it is added below.
625      *
626      * But each PRT_ENTRY structure has a pointer to a string and
627      * the size of that string must be found.
628      */
629     TopObjectList = PackageObject->Package.Elements;
630 
631     for (Index = 0; Index < NumberOfElements; Index++)
632     {
633         /* Dereference the sub-package */
634 
635         PackageElement = *TopObjectList;
636 
637         /*
638          * The SubObjectList will now point to an array of the
639          * four IRQ elements: Address, Pin, Source and SourceIndex
640          */
641         SubObjectList = PackageElement->Package.Elements;
642 
643         /* Scan the IrqTableElements for the Source Name String */
644 
645         NameFound = FALSE;
646 
647         for (TableIndex = 0; TableIndex < 4 && !NameFound; TableIndex++)
648         {
649             if (*SubObjectList && /* Null object allowed */
650 
651                 ((ACPI_TYPE_STRING ==
652                     ACPI_GET_OBJECT_TYPE (*SubObjectList)) ||
653 
654                 ((ACPI_TYPE_LOCAL_REFERENCE ==
655                     ACPI_GET_OBJECT_TYPE (*SubObjectList)) &&
656 
657                     ((*SubObjectList)->Reference.Opcode ==
658                         AML_INT_NAMEPATH_OP))))
659             {
660                 NameFound = TRUE;
661             }
662             else
663             {
664                 /* Look at the next element */
665 
666                 SubObjectList++;
667             }
668         }
669 
670         TempSizeNeeded += (sizeof (ACPI_PCI_ROUTING_TABLE) - 4);
671 
672         /* Was a String type found? */
673 
674         if (NameFound)
675         {
676             if (ACPI_GET_OBJECT_TYPE (*SubObjectList) == ACPI_TYPE_STRING)
677             {
678                 /*
679                  * The length String.Length field does not include the
680                  * terminating NULL, add 1
681                  */
682                 TempSizeNeeded += ((ACPI_SIZE)
683                     (*SubObjectList)->String.Length + 1);
684             }
685             else
686             {
687                 TempSizeNeeded += AcpiNsGetPathnameLength (
688                                     (*SubObjectList)->Reference.Node);
689             }
690         }
691         else
692         {
693             /*
694              * If no name was found, then this is a NULL, which is
695              * translated as a UINT32 zero.
696              */
697             TempSizeNeeded += sizeof (UINT32);
698         }
699 
700         /* Round up the size since each element must be aligned */
701 
702         TempSizeNeeded = ACPI_ROUND_UP_TO_64BIT (TempSizeNeeded);
703 
704         /* Point to the next ACPI_OPERAND_OBJECT */
705 
706         TopObjectList++;
707     }
708 
709     /*
710      * Add an extra element to the end of the list, essentially a
711      * NULL terminator
712      */
713     *BufferSizeNeeded = TempSizeNeeded + sizeof (ACPI_PCI_ROUTING_TABLE);
714     return_ACPI_STATUS (AE_OK);
715 }
716