Update ACPICA to 20160108, removed common.
[haiku.git] / src / add-ons / kernel / bus_managers / acpi / acpica / components / resources / rscalc.c
blobf1dc49b155a8cd5af98e0ab0b85aaf019b411e6e
1 /*******************************************************************************
3 * Module Name: rscalc - Calculate stream and list lengths
5 ******************************************************************************/
7 /******************************************************************************
9 * 1. Copyright Notice
11 * Some or all of this work - Copyright (c) 1999 - 2016, Intel Corp.
12 * All rights reserved.
14 * 2. License
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
19 * property rights.
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
37 * The above copyright and patent license is granted only if the following
38 * conditions are met:
40 * 3. Conditions
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
64 * make.
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
70 * distribution.
72 * 3.4. Intel retains all right, title, and interest in and to the Original
73 * Intel Code.
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
80 * 4. Disclaimer and Export Compliance
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88 * PARTICULAR PURPOSE.
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97 * LIMITED REMEDY.
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
114 *****************************************************************************/
116 #include "acpi.h"
117 #include "accommon.h"
118 #include "acresrc.h"
119 #include "acnamesp.h"
122 #define _COMPONENT ACPI_RESOURCES
123 ACPI_MODULE_NAME ("rscalc")
126 /* Local prototypes */
128 static UINT8
129 AcpiRsCountSetBits (
130 UINT16 BitField);
132 static ACPI_RS_LENGTH
133 AcpiRsStructOptionLength (
134 ACPI_RESOURCE_SOURCE *ResourceSource);
136 static UINT32
137 AcpiRsStreamOptionLength (
138 UINT32 ResourceLength,
139 UINT32 MinimumTotalLength);
142 /*******************************************************************************
144 * FUNCTION: AcpiRsCountSetBits
146 * PARAMETERS: BitField - Field in which to count bits
148 * RETURN: Number of bits set within the field
150 * DESCRIPTION: Count the number of bits set in a resource field. Used for
151 * (Short descriptor) interrupt and DMA lists.
153 ******************************************************************************/
155 static UINT8
156 AcpiRsCountSetBits (
157 UINT16 BitField)
159 UINT8 BitsSet;
162 ACPI_FUNCTION_ENTRY ();
165 for (BitsSet = 0; BitField; BitsSet++)
167 /* Zero the least significant bit that is set */
169 BitField &= (UINT16) (BitField - 1);
172 return (BitsSet);
176 /*******************************************************************************
178 * FUNCTION: AcpiRsStructOptionLength
180 * PARAMETERS: ResourceSource - Pointer to optional descriptor field
182 * RETURN: Status
184 * DESCRIPTION: Common code to handle optional ResourceSourceIndex and
185 * ResourceSource fields in some Large descriptors. Used during
186 * list-to-stream conversion
188 ******************************************************************************/
190 static ACPI_RS_LENGTH
191 AcpiRsStructOptionLength (
192 ACPI_RESOURCE_SOURCE *ResourceSource)
194 ACPI_FUNCTION_ENTRY ();
198 * If the ResourceSource string is valid, return the size of the string
199 * (StringLength includes the NULL terminator) plus the size of the
200 * ResourceSourceIndex (1).
202 if (ResourceSource->StringPtr)
204 return ((ACPI_RS_LENGTH) (ResourceSource->StringLength + 1));
207 return (0);
211 /*******************************************************************************
213 * FUNCTION: AcpiRsStreamOptionLength
215 * PARAMETERS: ResourceLength - Length from the resource header
216 * MinimumTotalLength - Minimum length of this resource, before
217 * any optional fields. Includes header size
219 * RETURN: Length of optional string (0 if no string present)
221 * DESCRIPTION: Common code to handle optional ResourceSourceIndex and
222 * ResourceSource fields in some Large descriptors. Used during
223 * stream-to-list conversion
225 ******************************************************************************/
227 static UINT32
228 AcpiRsStreamOptionLength (
229 UINT32 ResourceLength,
230 UINT32 MinimumAmlResourceLength)
232 UINT32 StringLength = 0;
235 ACPI_FUNCTION_ENTRY ();
239 * The ResourceSourceIndex and ResourceSource are optional elements of
240 * some Large-type resource descriptors.
244 * If the length of the actual resource descriptor is greater than the
245 * ACPI spec-defined minimum length, it means that a ResourceSourceIndex
246 * exists and is followed by a (required) null terminated string. The
247 * string length (including the null terminator) is the resource length
248 * minus the minimum length, minus one byte for the ResourceSourceIndex
249 * itself.
251 if (ResourceLength > MinimumAmlResourceLength)
253 /* Compute the length of the optional string */
255 StringLength = ResourceLength - MinimumAmlResourceLength - 1;
259 * Round the length up to a multiple of the native word in order to
260 * guarantee that the entire resource descriptor is native word aligned
262 return ((UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (StringLength));
266 /*******************************************************************************
268 * FUNCTION: AcpiRsGetAmlLength
270 * PARAMETERS: Resource - Pointer to the resource linked list
271 * ResourceListSize - Size of the resource linked list
272 * SizeNeeded - Where the required size is returned
274 * RETURN: Status
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.
280 ******************************************************************************/
282 ACPI_STATUS
283 AcpiRsGetAmlLength (
284 ACPI_RESOURCE *Resource,
285 ACPI_SIZE ResourceListSize,
286 ACPI_SIZE *SizeNeeded)
288 ACPI_SIZE AmlSizeNeeded = 0;
289 ACPI_RESOURCE *ResourceEnd;
290 ACPI_RS_LENGTH TotalSize;
293 ACPI_FUNCTION_TRACE (RsGetAmlLength);
296 /* Traverse entire list of internal resource descriptors */
298 ResourceEnd = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, ResourceListSize);
299 while (Resource < ResourceEnd)
301 /* Validate the descriptor type */
303 if (Resource->Type > ACPI_RESOURCE_TYPE_MAX)
305 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
308 /* Sanity check the length. It must not be zero, or we loop forever */
310 if (!Resource->Length)
312 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH);
315 /* Get the base size of the (external stream) resource descriptor */
317 TotalSize = AcpiGbl_AmlResourceSizes [Resource->Type];
320 * Augment the base size for descriptors with optional and/or
321 * variable-length fields
323 switch (Resource->Type)
325 case ACPI_RESOURCE_TYPE_IRQ:
327 /* Length can be 3 or 2 */
329 if (Resource->Data.Irq.DescriptorLength == 2)
331 TotalSize--;
333 break;
336 case ACPI_RESOURCE_TYPE_START_DEPENDENT:
338 /* Length can be 1 or 0 */
340 if (Resource->Data.Irq.DescriptorLength == 0)
342 TotalSize--;
344 break;
347 case ACPI_RESOURCE_TYPE_VENDOR:
349 * Vendor Defined Resource:
350 * For a Vendor Specific resource, if the Length is between 1 and 7
351 * it will be created as a Small Resource data type, otherwise it
352 * is a Large Resource data type.
354 if (Resource->Data.Vendor.ByteLength > 7)
356 /* Base size of a Large resource descriptor */
358 TotalSize = sizeof (AML_RESOURCE_LARGE_HEADER);
361 /* Add the size of the vendor-specific data */
363 TotalSize = (ACPI_RS_LENGTH)
364 (TotalSize + Resource->Data.Vendor.ByteLength);
365 break;
368 case ACPI_RESOURCE_TYPE_END_TAG:
370 * End Tag:
371 * We are done -- return the accumulated total size.
373 *SizeNeeded = AmlSizeNeeded + TotalSize;
375 /* Normal exit */
377 return_ACPI_STATUS (AE_OK);
380 case ACPI_RESOURCE_TYPE_ADDRESS16:
382 * 16-Bit Address Resource:
383 * Add the size of the optional ResourceSource info
385 TotalSize = (ACPI_RS_LENGTH) (TotalSize +
386 AcpiRsStructOptionLength (
387 &Resource->Data.Address16.ResourceSource));
388 break;
391 case ACPI_RESOURCE_TYPE_ADDRESS32:
393 * 32-Bit Address Resource:
394 * Add the size of the optional ResourceSource info
396 TotalSize = (ACPI_RS_LENGTH) (TotalSize +
397 AcpiRsStructOptionLength (
398 &Resource->Data.Address32.ResourceSource));
399 break;
402 case ACPI_RESOURCE_TYPE_ADDRESS64:
404 * 64-Bit Address Resource:
405 * Add the size of the optional ResourceSource info
407 TotalSize = (ACPI_RS_LENGTH) (TotalSize +
408 AcpiRsStructOptionLength (
409 &Resource->Data.Address64.ResourceSource));
410 break;
413 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
415 * Extended IRQ Resource:
416 * Add the size of each additional optional interrupt beyond the
417 * required 1 (4 bytes for each UINT32 interrupt number)
419 TotalSize = (ACPI_RS_LENGTH) (TotalSize +
420 ((Resource->Data.ExtendedIrq.InterruptCount - 1) * 4) +
422 /* Add the size of the optional ResourceSource info */
424 AcpiRsStructOptionLength (
425 &Resource->Data.ExtendedIrq.ResourceSource));
426 break;
429 case ACPI_RESOURCE_TYPE_GPIO:
431 TotalSize = (ACPI_RS_LENGTH) (TotalSize +
432 (Resource->Data.Gpio.PinTableLength * 2) +
433 Resource->Data.Gpio.ResourceSource.StringLength +
434 Resource->Data.Gpio.VendorLength);
436 break;
439 case ACPI_RESOURCE_TYPE_SERIAL_BUS:
441 TotalSize = AcpiGbl_AmlResourceSerialBusSizes [
442 Resource->Data.CommonSerialBus.Type];
444 TotalSize = (ACPI_RS_LENGTH) (TotalSize +
445 Resource->Data.I2cSerialBus.ResourceSource.StringLength +
446 Resource->Data.I2cSerialBus.VendorLength);
448 break;
450 default:
452 break;
455 /* Update the total */
457 AmlSizeNeeded += TotalSize;
459 /* Point to the next object */
461 Resource = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, Resource->Length);
464 /* Did not find an EndTag resource descriptor */
466 return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
470 /*******************************************************************************
472 * FUNCTION: AcpiRsGetListLength
474 * PARAMETERS: AmlBuffer - Pointer to the resource byte stream
475 * AmlBufferLength - Size of AmlBuffer
476 * SizeNeeded - Where the size needed is returned
478 * RETURN: Status
480 * DESCRIPTION: Takes an external resource byte stream and calculates the size
481 * buffer needed to hold the corresponding internal resource
482 * descriptor linked list.
484 ******************************************************************************/
486 ACPI_STATUS
487 AcpiRsGetListLength (
488 UINT8 *AmlBuffer,
489 UINT32 AmlBufferLength,
490 ACPI_SIZE *SizeNeeded)
492 ACPI_STATUS Status;
493 UINT8 *EndAml;
494 UINT8 *Buffer;
495 UINT32 BufferSize;
496 UINT16 Temp16;
497 UINT16 ResourceLength;
498 UINT32 ExtraStructBytes;
499 UINT8 ResourceIndex;
500 UINT8 MinimumAmlResourceLength;
501 AML_RESOURCE *AmlResource;
504 ACPI_FUNCTION_TRACE (RsGetListLength);
507 *SizeNeeded = ACPI_RS_SIZE_MIN; /* Minimum size is one EndTag */
508 EndAml = AmlBuffer + AmlBufferLength;
510 /* Walk the list of AML resource descriptors */
512 while (AmlBuffer < EndAml)
514 /* Validate the Resource Type and Resource Length */
516 Status = AcpiUtValidateResource (NULL, AmlBuffer, &ResourceIndex);
517 if (ACPI_FAILURE (Status))
520 * Exit on failure. Cannot continue because the descriptor length
521 * may be bogus also.
523 return_ACPI_STATUS (Status);
526 AmlResource = (void *) AmlBuffer;
528 /* Get the resource length and base (minimum) AML size */
530 ResourceLength = AcpiUtGetResourceLength (AmlBuffer);
531 MinimumAmlResourceLength = AcpiGbl_ResourceAmlSizes[ResourceIndex];
534 * Augment the size for descriptors with optional
535 * and/or variable length fields
537 ExtraStructBytes = 0;
538 Buffer = AmlBuffer + AcpiUtGetResourceHeaderLength (AmlBuffer);
540 switch (AcpiUtGetResourceType (AmlBuffer))
542 case ACPI_RESOURCE_NAME_IRQ:
544 * IRQ Resource:
545 * Get the number of bits set in the 16-bit IRQ mask
547 ACPI_MOVE_16_TO_16 (&Temp16, Buffer);
548 ExtraStructBytes = AcpiRsCountSetBits (Temp16);
549 break;
552 case ACPI_RESOURCE_NAME_DMA:
554 * DMA Resource:
555 * Get the number of bits set in the 8-bit DMA mask
557 ExtraStructBytes = AcpiRsCountSetBits (*Buffer);
558 break;
561 case ACPI_RESOURCE_NAME_VENDOR_SMALL:
562 case ACPI_RESOURCE_NAME_VENDOR_LARGE:
564 * Vendor Resource:
565 * Get the number of vendor data bytes
567 ExtraStructBytes = ResourceLength;
570 * There is already one byte included in the minimum
571 * descriptor size. If there are extra struct bytes,
572 * subtract one from the count.
574 if (ExtraStructBytes)
576 ExtraStructBytes--;
578 break;
581 case ACPI_RESOURCE_NAME_END_TAG:
583 * End Tag: This is the normal exit
585 return_ACPI_STATUS (AE_OK);
588 case ACPI_RESOURCE_NAME_ADDRESS32:
589 case ACPI_RESOURCE_NAME_ADDRESS16:
590 case ACPI_RESOURCE_NAME_ADDRESS64:
592 * Address Resource:
593 * Add the size of the optional ResourceSource
595 ExtraStructBytes = AcpiRsStreamOptionLength (
596 ResourceLength, MinimumAmlResourceLength);
597 break;
600 case ACPI_RESOURCE_NAME_EXTENDED_IRQ:
602 * Extended IRQ Resource:
603 * Using the InterruptTableLength, add 4 bytes for each additional
604 * interrupt. Note: at least one interrupt is required and is
605 * included in the minimum descriptor size (reason for the -1)
607 ExtraStructBytes = (Buffer[1] - 1) * sizeof (UINT32);
609 /* Add the size of the optional ResourceSource */
611 ExtraStructBytes += AcpiRsStreamOptionLength (
612 ResourceLength - ExtraStructBytes, MinimumAmlResourceLength);
613 break;
615 case ACPI_RESOURCE_NAME_GPIO:
617 /* Vendor data is optional */
619 if (AmlResource->Gpio.VendorLength)
621 ExtraStructBytes +=
622 AmlResource->Gpio.VendorOffset -
623 AmlResource->Gpio.PinTableOffset +
624 AmlResource->Gpio.VendorLength;
626 else
628 ExtraStructBytes +=
629 AmlResource->LargeHeader.ResourceLength +
630 sizeof (AML_RESOURCE_LARGE_HEADER) -
631 AmlResource->Gpio.PinTableOffset;
633 break;
635 case ACPI_RESOURCE_NAME_SERIAL_BUS:
637 MinimumAmlResourceLength = AcpiGbl_ResourceAmlSerialBusSizes[
638 AmlResource->CommonSerialBus.Type];
639 ExtraStructBytes +=
640 AmlResource->CommonSerialBus.ResourceLength -
641 MinimumAmlResourceLength;
642 break;
644 default:
646 break;
650 * Update the required buffer size for the internal descriptor structs
652 * Important: Round the size up for the appropriate alignment. This
653 * is a requirement on IA64.
655 if (AcpiUtGetResourceType (AmlBuffer) ==
656 ACPI_RESOURCE_NAME_SERIAL_BUS)
658 BufferSize = AcpiGbl_ResourceStructSerialBusSizes[
659 AmlResource->CommonSerialBus.Type] + ExtraStructBytes;
661 else
663 BufferSize = AcpiGbl_ResourceStructSizes[ResourceIndex] +
664 ExtraStructBytes;
667 BufferSize = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (BufferSize);
668 *SizeNeeded += BufferSize;
670 ACPI_DEBUG_PRINT ((ACPI_DB_RESOURCES,
671 "Type %.2X, AmlLength %.2X InternalLength %.2X\n",
672 AcpiUtGetResourceType (AmlBuffer),
673 AcpiUtGetDescriptorLength (AmlBuffer), BufferSize));
676 * Point to the next resource within the AML stream using the length
677 * contained in the resource descriptor header
679 AmlBuffer += AcpiUtGetDescriptorLength (AmlBuffer);
682 /* Did not find an EndTag resource descriptor */
684 return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
688 /*******************************************************************************
690 * FUNCTION: AcpiRsGetPciRoutingTableLength
692 * PARAMETERS: PackageObject - Pointer to the package object
693 * BufferSizeNeeded - UINT32 pointer of the size buffer
694 * needed to properly return the
695 * parsed data
697 * RETURN: Status
699 * DESCRIPTION: Given a package representing a PCI routing table, this
700 * calculates the size of the corresponding linked list of
701 * descriptions.
703 ******************************************************************************/
705 ACPI_STATUS
706 AcpiRsGetPciRoutingTableLength (
707 ACPI_OPERAND_OBJECT *PackageObject,
708 ACPI_SIZE *BufferSizeNeeded)
710 UINT32 NumberOfElements;
711 ACPI_SIZE TempSizeNeeded = 0;
712 ACPI_OPERAND_OBJECT **TopObjectList;
713 UINT32 Index;
714 ACPI_OPERAND_OBJECT *PackageElement;
715 ACPI_OPERAND_OBJECT **SubObjectList;
716 BOOLEAN NameFound;
717 UINT32 TableIndex;
720 ACPI_FUNCTION_TRACE (RsGetPciRoutingTableLength);
723 NumberOfElements = PackageObject->Package.Count;
726 * Calculate the size of the return buffer.
727 * The base size is the number of elements * the sizes of the
728 * structures. Additional space for the strings is added below.
729 * The minus one is to subtract the size of the UINT8 Source[1]
730 * member because it is added below.
732 * But each PRT_ENTRY structure has a pointer to a string and
733 * the size of that string must be found.
735 TopObjectList = PackageObject->Package.Elements;
737 for (Index = 0; Index < NumberOfElements; Index++)
739 /* Dereference the subpackage */
741 PackageElement = *TopObjectList;
743 /* We must have a valid Package object */
745 if (!PackageElement ||
746 (PackageElement->Common.Type != ACPI_TYPE_PACKAGE))
748 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
752 * The SubObjectList will now point to an array of the
753 * four IRQ elements: Address, Pin, Source and SourceIndex
755 SubObjectList = PackageElement->Package.Elements;
757 /* Scan the IrqTableElements for the Source Name String */
759 NameFound = FALSE;
761 for (TableIndex = 0;
762 TableIndex < PackageElement->Package.Count && !NameFound;
763 TableIndex++)
765 if (*SubObjectList && /* Null object allowed */
767 ((ACPI_TYPE_STRING ==
768 (*SubObjectList)->Common.Type) ||
770 ((ACPI_TYPE_LOCAL_REFERENCE ==
771 (*SubObjectList)->Common.Type) &&
773 ((*SubObjectList)->Reference.Class ==
774 ACPI_REFCLASS_NAME))))
776 NameFound = TRUE;
778 else
780 /* Look at the next element */
782 SubObjectList++;
786 TempSizeNeeded += (sizeof (ACPI_PCI_ROUTING_TABLE) - 4);
788 /* Was a String type found? */
790 if (NameFound)
792 if ((*SubObjectList)->Common.Type == ACPI_TYPE_STRING)
795 * The length String.Length field does not include the
796 * terminating NULL, add 1
798 TempSizeNeeded += ((ACPI_SIZE)
799 (*SubObjectList)->String.Length + 1);
801 else
803 TempSizeNeeded += AcpiNsGetPathnameLength (
804 (*SubObjectList)->Reference.Node);
807 else
810 * If no name was found, then this is a NULL, which is
811 * translated as a UINT32 zero.
813 TempSizeNeeded += sizeof (UINT32);
816 /* Round up the size since each element must be aligned */
818 TempSizeNeeded = ACPI_ROUND_UP_TO_64BIT (TempSizeNeeded);
820 /* Point to the next ACPI_OPERAND_OBJECT */
822 TopObjectList++;
826 * Add an extra element to the end of the list, essentially a
827 * NULL terminator
829 *BufferSizeNeeded = TempSizeNeeded + sizeof (ACPI_PCI_ROUTING_TABLE);
830 return_ACPI_STATUS (AE_OK);