1 /*******************************************************************************
3 * Module Name: rscalc - Calculate stream and list lengths
5 ******************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
12 * All rights reserved.
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
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
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
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
72 * 3.4. Intel retains all right, title, and interest in and to the Original
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
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
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 * Alternatively, you may choose to be licensed under the terms of the
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
122 * 1. Redistributions of source code must retain the above copyright
123 * notice, this list of conditions, and the following disclaimer,
124 * without modification.
125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 * substantially similar to the "NO WARRANTY" disclaimer below
127 * ("Disclaimer") and any redistribution must be conditioned upon
128 * including a substantially similar Disclaimer requirement for further
129 * binary redistribution.
130 * 3. Neither the names of the above-listed copyright holders nor the names
131 * of any contributors may be used to endorse or promote products derived
132 * from this software without specific prior written permission.
134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146 * Alternatively, you may choose to be licensed under the terms of the
147 * GNU General Public License ("GPL") version 2 as published by the Free
148 * Software Foundation.
150 *****************************************************************************/
153 #include "accommon.h"
155 #include "acnamesp.h"
158 #define _COMPONENT ACPI_RESOURCES
159 ACPI_MODULE_NAME ("rscalc")
162 /* Local prototypes */
168 static ACPI_RS_LENGTH
169 AcpiRsStructOptionLength (
170 ACPI_RESOURCE_SOURCE
*ResourceSource
);
173 AcpiRsStreamOptionLength (
174 UINT32 ResourceLength
,
175 UINT32 MinimumTotalLength
);
178 /*******************************************************************************
180 * FUNCTION: AcpiRsCountSetBits
182 * PARAMETERS: BitField - Field in which to count bits
184 * RETURN: Number of bits set within the field
186 * DESCRIPTION: Count the number of bits set in a resource field. Used for
187 * (Short descriptor) interrupt and DMA lists.
189 ******************************************************************************/
198 ACPI_FUNCTION_ENTRY ();
201 for (BitsSet
= 0; BitField
; BitsSet
++)
203 /* Zero the least significant bit that is set */
205 BitField
&= (UINT16
) (BitField
- 1);
212 /*******************************************************************************
214 * FUNCTION: AcpiRsStructOptionLength
216 * PARAMETERS: ResourceSource - Pointer to optional descriptor field
220 * DESCRIPTION: Common code to handle optional ResourceSourceIndex and
221 * ResourceSource fields in some Large descriptors. Used during
222 * list-to-stream conversion
224 ******************************************************************************/
226 static ACPI_RS_LENGTH
227 AcpiRsStructOptionLength (
228 ACPI_RESOURCE_SOURCE
*ResourceSource
)
230 ACPI_FUNCTION_ENTRY ();
234 * If the ResourceSource string is valid, return the size of the string
235 * (StringLength includes the NULL terminator) plus the size of the
236 * ResourceSourceIndex (1).
238 if (ResourceSource
->StringPtr
)
240 return ((ACPI_RS_LENGTH
) (ResourceSource
->StringLength
+ 1));
247 /*******************************************************************************
249 * FUNCTION: AcpiRsStreamOptionLength
251 * PARAMETERS: ResourceLength - Length from the resource header
252 * MinimumTotalLength - Minimum length of this resource, before
253 * any optional fields. Includes header size
255 * RETURN: Length of optional string (0 if no string present)
257 * DESCRIPTION: Common code to handle optional ResourceSourceIndex and
258 * ResourceSource fields in some Large descriptors. Used during
259 * stream-to-list conversion
261 ******************************************************************************/
264 AcpiRsStreamOptionLength (
265 UINT32 ResourceLength
,
266 UINT32 MinimumAmlResourceLength
)
268 UINT32 StringLength
= 0;
271 ACPI_FUNCTION_ENTRY ();
275 * The ResourceSourceIndex and ResourceSource are optional elements of
276 * some Large-type resource descriptors.
280 * If the length of the actual resource descriptor is greater than the
281 * ACPI spec-defined minimum length, it means that a ResourceSourceIndex
282 * exists and is followed by a (required) null terminated string. The
283 * string length (including the null terminator) is the resource length
284 * minus the minimum length, minus one byte for the ResourceSourceIndex
287 if (ResourceLength
> MinimumAmlResourceLength
)
289 /* Compute the length of the optional string */
291 StringLength
= ResourceLength
- MinimumAmlResourceLength
- 1;
295 * Round the length up to a multiple of the native word in order to
296 * guarantee that the entire resource descriptor is native word aligned
298 return ((UINT32
) ACPI_ROUND_UP_TO_NATIVE_WORD (StringLength
));
302 /*******************************************************************************
304 * FUNCTION: AcpiRsGetAmlLength
306 * PARAMETERS: Resource - Pointer to the resource linked list
307 * ResourceListSize - Size of the resource linked list
308 * SizeNeeded - Where the required size is returned
312 * DESCRIPTION: Takes a linked list of internal resource descriptors and
313 * calculates the size buffer needed to hold the corresponding
314 * external resource byte stream.
316 ******************************************************************************/
320 ACPI_RESOURCE
*Resource
,
321 ACPI_SIZE ResourceListSize
,
322 ACPI_SIZE
*SizeNeeded
)
324 ACPI_SIZE AmlSizeNeeded
= 0;
325 ACPI_RESOURCE
*ResourceEnd
;
326 ACPI_RS_LENGTH TotalSize
;
329 ACPI_FUNCTION_TRACE (RsGetAmlLength
);
332 /* Traverse entire list of internal resource descriptors */
334 ResourceEnd
= ACPI_ADD_PTR (ACPI_RESOURCE
, Resource
, ResourceListSize
);
335 while (Resource
< ResourceEnd
)
337 /* Validate the descriptor type */
339 if (Resource
->Type
> ACPI_RESOURCE_TYPE_MAX
)
341 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE
);
344 /* Sanity check the length. It must not be zero, or we loop forever */
346 if (!Resource
->Length
)
348 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH
);
351 /* Get the base size of the (external stream) resource descriptor */
353 TotalSize
= AcpiGbl_AmlResourceSizes
[Resource
->Type
];
356 * Augment the base size for descriptors with optional and/or
357 * variable-length fields
359 switch (Resource
->Type
)
361 case ACPI_RESOURCE_TYPE_IRQ
:
363 /* Length can be 3 or 2 */
365 if (Resource
->Data
.Irq
.DescriptorLength
== 2)
372 case ACPI_RESOURCE_TYPE_START_DEPENDENT
:
374 /* Length can be 1 or 0 */
376 if (Resource
->Data
.Irq
.DescriptorLength
== 0)
383 case ACPI_RESOURCE_TYPE_VENDOR
:
385 * Vendor Defined Resource:
386 * For a Vendor Specific resource, if the Length is between 1 and 7
387 * it will be created as a Small Resource data type, otherwise it
388 * is a Large Resource data type.
390 if (Resource
->Data
.Vendor
.ByteLength
> 7)
392 /* Base size of a Large resource descriptor */
394 TotalSize
= sizeof (AML_RESOURCE_LARGE_HEADER
);
397 /* Add the size of the vendor-specific data */
399 TotalSize
= (ACPI_RS_LENGTH
)
400 (TotalSize
+ Resource
->Data
.Vendor
.ByteLength
);
404 case ACPI_RESOURCE_TYPE_END_TAG
:
407 * We are done -- return the accumulated total size.
409 *SizeNeeded
= AmlSizeNeeded
+ TotalSize
;
413 return_ACPI_STATUS (AE_OK
);
416 case ACPI_RESOURCE_TYPE_ADDRESS16
:
418 * 16-Bit Address Resource:
419 * Add the size of the optional ResourceSource info
421 TotalSize
= (ACPI_RS_LENGTH
) (TotalSize
+
422 AcpiRsStructOptionLength (
423 &Resource
->Data
.Address16
.ResourceSource
));
427 case ACPI_RESOURCE_TYPE_ADDRESS32
:
429 * 32-Bit Address Resource:
430 * Add the size of the optional ResourceSource info
432 TotalSize
= (ACPI_RS_LENGTH
) (TotalSize
+
433 AcpiRsStructOptionLength (
434 &Resource
->Data
.Address32
.ResourceSource
));
438 case ACPI_RESOURCE_TYPE_ADDRESS64
:
440 * 64-Bit Address Resource:
441 * Add the size of the optional ResourceSource info
443 TotalSize
= (ACPI_RS_LENGTH
) (TotalSize
+
444 AcpiRsStructOptionLength (
445 &Resource
->Data
.Address64
.ResourceSource
));
449 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ
:
451 * Extended IRQ Resource:
452 * Add the size of each additional optional interrupt beyond the
453 * required 1 (4 bytes for each UINT32 interrupt number)
455 TotalSize
= (ACPI_RS_LENGTH
) (TotalSize
+
456 ((Resource
->Data
.ExtendedIrq
.InterruptCount
- 1) * 4) +
458 /* Add the size of the optional ResourceSource info */
460 AcpiRsStructOptionLength (
461 &Resource
->Data
.ExtendedIrq
.ResourceSource
));
465 case ACPI_RESOURCE_TYPE_GPIO
:
467 TotalSize
= (ACPI_RS_LENGTH
) (TotalSize
+
468 (Resource
->Data
.Gpio
.PinTableLength
* 2) +
469 Resource
->Data
.Gpio
.ResourceSource
.StringLength
+
470 Resource
->Data
.Gpio
.VendorLength
);
474 case ACPI_RESOURCE_TYPE_PIN_FUNCTION
:
476 TotalSize
= (ACPI_RS_LENGTH
) (TotalSize
+
477 (Resource
->Data
.PinFunction
.PinTableLength
* 2) +
478 Resource
->Data
.PinFunction
.ResourceSource
.StringLength
+
479 Resource
->Data
.PinFunction
.VendorLength
);
484 case ACPI_RESOURCE_TYPE_SERIAL_BUS
:
486 TotalSize
= AcpiGbl_AmlResourceSerialBusSizes
[
487 Resource
->Data
.CommonSerialBus
.Type
];
489 TotalSize
= (ACPI_RS_LENGTH
) (TotalSize
+
490 Resource
->Data
.I2cSerialBus
.ResourceSource
.StringLength
+
491 Resource
->Data
.I2cSerialBus
.VendorLength
);
495 case ACPI_RESOURCE_TYPE_PIN_CONFIG
:
497 TotalSize
= (ACPI_RS_LENGTH
) (TotalSize
+
498 (Resource
->Data
.PinConfig
.PinTableLength
* 2) +
499 Resource
->Data
.PinConfig
.ResourceSource
.StringLength
+
500 Resource
->Data
.PinConfig
.VendorLength
);
504 case ACPI_RESOURCE_TYPE_PIN_GROUP
:
506 TotalSize
= (ACPI_RS_LENGTH
) (TotalSize
+
507 (Resource
->Data
.PinGroup
.PinTableLength
* 2) +
508 Resource
->Data
.PinGroup
.ResourceLabel
.StringLength
+
509 Resource
->Data
.PinGroup
.VendorLength
);
513 case ACPI_RESOURCE_TYPE_PIN_GROUP_FUNCTION
:
515 TotalSize
= (ACPI_RS_LENGTH
) (TotalSize
+
516 Resource
->Data
.PinGroupFunction
.ResourceSource
.StringLength
+
517 Resource
->Data
.PinGroupFunction
.ResourceSourceLabel
.StringLength
+
518 Resource
->Data
.PinGroupFunction
.VendorLength
);
522 case ACPI_RESOURCE_TYPE_PIN_GROUP_CONFIG
:
524 TotalSize
= (ACPI_RS_LENGTH
) (TotalSize
+
525 Resource
->Data
.PinGroupConfig
.ResourceSource
.StringLength
+
526 Resource
->Data
.PinGroupConfig
.ResourceSourceLabel
.StringLength
+
527 Resource
->Data
.PinGroupConfig
.VendorLength
);
536 /* Update the total */
538 AmlSizeNeeded
+= TotalSize
;
540 /* Point to the next object */
542 Resource
= ACPI_ADD_PTR (ACPI_RESOURCE
, Resource
, Resource
->Length
);
545 /* Did not find an EndTag resource descriptor */
547 return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG
);
551 /*******************************************************************************
553 * FUNCTION: AcpiRsGetListLength
555 * PARAMETERS: AmlBuffer - Pointer to the resource byte stream
556 * AmlBufferLength - Size of AmlBuffer
557 * SizeNeeded - Where the size needed is returned
561 * DESCRIPTION: Takes an external resource byte stream and calculates the size
562 * buffer needed to hold the corresponding internal resource
563 * descriptor linked list.
565 ******************************************************************************/
568 AcpiRsGetListLength (
570 UINT32 AmlBufferLength
,
571 ACPI_SIZE
*SizeNeeded
)
578 UINT16 ResourceLength
;
579 UINT32 ExtraStructBytes
;
581 UINT8 MinimumAmlResourceLength
;
582 AML_RESOURCE
*AmlResource
;
585 ACPI_FUNCTION_TRACE (RsGetListLength
);
588 *SizeNeeded
= ACPI_RS_SIZE_MIN
; /* Minimum size is one EndTag */
589 EndAml
= AmlBuffer
+ AmlBufferLength
;
591 /* Walk the list of AML resource descriptors */
593 while (AmlBuffer
< EndAml
)
595 /* Validate the Resource Type and Resource Length */
597 Status
= AcpiUtValidateResource (NULL
, AmlBuffer
, &ResourceIndex
);
598 if (ACPI_FAILURE (Status
))
601 * Exit on failure. Cannot continue because the descriptor length
604 return_ACPI_STATUS (Status
);
607 AmlResource
= (void *) AmlBuffer
;
609 /* Get the resource length and base (minimum) AML size */
611 ResourceLength
= AcpiUtGetResourceLength (AmlBuffer
);
612 MinimumAmlResourceLength
= AcpiGbl_ResourceAmlSizes
[ResourceIndex
];
615 * Augment the size for descriptors with optional
616 * and/or variable length fields
618 ExtraStructBytes
= 0;
619 Buffer
= AmlBuffer
+ AcpiUtGetResourceHeaderLength (AmlBuffer
);
621 switch (AcpiUtGetResourceType (AmlBuffer
))
623 case ACPI_RESOURCE_NAME_IRQ
:
626 * Get the number of bits set in the 16-bit IRQ mask
628 ACPI_MOVE_16_TO_16 (&Temp16
, Buffer
);
629 ExtraStructBytes
= AcpiRsCountSetBits (Temp16
);
633 case ACPI_RESOURCE_NAME_DMA
:
636 * Get the number of bits set in the 8-bit DMA mask
638 ExtraStructBytes
= AcpiRsCountSetBits (*Buffer
);
642 case ACPI_RESOURCE_NAME_VENDOR_SMALL
:
643 case ACPI_RESOURCE_NAME_VENDOR_LARGE
:
646 * Get the number of vendor data bytes
648 ExtraStructBytes
= ResourceLength
;
651 * There is already one byte included in the minimum
652 * descriptor size. If there are extra struct bytes,
653 * subtract one from the count.
655 if (ExtraStructBytes
)
662 case ACPI_RESOURCE_NAME_END_TAG
:
664 * End Tag: This is the normal exit
666 return_ACPI_STATUS (AE_OK
);
669 case ACPI_RESOURCE_NAME_ADDRESS32
:
670 case ACPI_RESOURCE_NAME_ADDRESS16
:
671 case ACPI_RESOURCE_NAME_ADDRESS64
:
674 * Add the size of the optional ResourceSource
676 ExtraStructBytes
= AcpiRsStreamOptionLength (
677 ResourceLength
, MinimumAmlResourceLength
);
681 case ACPI_RESOURCE_NAME_EXTENDED_IRQ
:
683 * Extended IRQ Resource:
684 * Using the InterruptTableLength, add 4 bytes for each additional
685 * interrupt. Note: at least one interrupt is required and is
686 * included in the minimum descriptor size (reason for the -1)
688 ExtraStructBytes
= (Buffer
[1] - 1) * sizeof (UINT32
);
690 /* Add the size of the optional ResourceSource */
692 ExtraStructBytes
+= AcpiRsStreamOptionLength (
693 ResourceLength
- ExtraStructBytes
, MinimumAmlResourceLength
);
696 case ACPI_RESOURCE_NAME_GPIO
:
698 /* Vendor data is optional */
700 if (AmlResource
->Gpio
.VendorLength
)
703 AmlResource
->Gpio
.VendorOffset
-
704 AmlResource
->Gpio
.PinTableOffset
+
705 AmlResource
->Gpio
.VendorLength
;
710 AmlResource
->LargeHeader
.ResourceLength
+
711 sizeof (AML_RESOURCE_LARGE_HEADER
) -
712 AmlResource
->Gpio
.PinTableOffset
;
716 case ACPI_RESOURCE_NAME_PIN_FUNCTION
:
718 /* Vendor data is optional */
720 if (AmlResource
->PinFunction
.VendorLength
)
723 AmlResource
->PinFunction
.VendorOffset
-
724 AmlResource
->PinFunction
.PinTableOffset
+
725 AmlResource
->PinFunction
.VendorLength
;
730 AmlResource
->LargeHeader
.ResourceLength
+
731 sizeof (AML_RESOURCE_LARGE_HEADER
) -
732 AmlResource
->PinFunction
.PinTableOffset
;
736 case ACPI_RESOURCE_NAME_SERIAL_BUS
:
738 MinimumAmlResourceLength
= AcpiGbl_ResourceAmlSerialBusSizes
[
739 AmlResource
->CommonSerialBus
.Type
];
741 AmlResource
->CommonSerialBus
.ResourceLength
-
742 MinimumAmlResourceLength
;
745 case ACPI_RESOURCE_NAME_PIN_CONFIG
:
747 /* Vendor data is optional */
749 if (AmlResource
->PinConfig
.VendorLength
)
752 AmlResource
->PinConfig
.VendorOffset
-
753 AmlResource
->PinConfig
.PinTableOffset
+
754 AmlResource
->PinConfig
.VendorLength
;
759 AmlResource
->LargeHeader
.ResourceLength
+
760 sizeof (AML_RESOURCE_LARGE_HEADER
) -
761 AmlResource
->PinConfig
.PinTableOffset
;
765 case ACPI_RESOURCE_NAME_PIN_GROUP
:
768 AmlResource
->PinGroup
.VendorOffset
-
769 AmlResource
->PinGroup
.PinTableOffset
+
770 AmlResource
->PinGroup
.VendorLength
;
774 case ACPI_RESOURCE_NAME_PIN_GROUP_FUNCTION
:
777 AmlResource
->PinGroupFunction
.VendorOffset
-
778 AmlResource
->PinGroupFunction
.ResSourceOffset
+
779 AmlResource
->PinGroupFunction
.VendorLength
;
783 case ACPI_RESOURCE_NAME_PIN_GROUP_CONFIG
:
786 AmlResource
->PinGroupConfig
.VendorOffset
-
787 AmlResource
->PinGroupConfig
.ResSourceOffset
+
788 AmlResource
->PinGroupConfig
.VendorLength
;
798 * Update the required buffer size for the internal descriptor structs
800 * Important: Round the size up for the appropriate alignment. This
801 * is a requirement on IA64.
803 if (AcpiUtGetResourceType (AmlBuffer
) ==
804 ACPI_RESOURCE_NAME_SERIAL_BUS
)
806 BufferSize
= AcpiGbl_ResourceStructSerialBusSizes
[
807 AmlResource
->CommonSerialBus
.Type
] + ExtraStructBytes
;
811 BufferSize
= AcpiGbl_ResourceStructSizes
[ResourceIndex
] +
815 BufferSize
= (UINT32
) ACPI_ROUND_UP_TO_NATIVE_WORD (BufferSize
);
816 *SizeNeeded
+= BufferSize
;
818 ACPI_DEBUG_PRINT ((ACPI_DB_RESOURCES
,
819 "Type %.2X, AmlLength %.2X InternalLength %.2X\n",
820 AcpiUtGetResourceType (AmlBuffer
),
821 AcpiUtGetDescriptorLength (AmlBuffer
), BufferSize
));
824 * Point to the next resource within the AML stream using the length
825 * contained in the resource descriptor header
827 AmlBuffer
+= AcpiUtGetDescriptorLength (AmlBuffer
);
830 /* Did not find an EndTag resource descriptor */
832 return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG
);
836 /*******************************************************************************
838 * FUNCTION: AcpiRsGetPciRoutingTableLength
840 * PARAMETERS: PackageObject - Pointer to the package object
841 * BufferSizeNeeded - UINT32 pointer of the size buffer
842 * needed to properly return the
847 * DESCRIPTION: Given a package representing a PCI routing table, this
848 * calculates the size of the corresponding linked list of
851 ******************************************************************************/
854 AcpiRsGetPciRoutingTableLength (
855 ACPI_OPERAND_OBJECT
*PackageObject
,
856 ACPI_SIZE
*BufferSizeNeeded
)
858 UINT32 NumberOfElements
;
859 ACPI_SIZE TempSizeNeeded
= 0;
860 ACPI_OPERAND_OBJECT
**TopObjectList
;
862 ACPI_OPERAND_OBJECT
*PackageElement
;
863 ACPI_OPERAND_OBJECT
**SubObjectList
;
868 ACPI_FUNCTION_TRACE (RsGetPciRoutingTableLength
);
871 NumberOfElements
= PackageObject
->Package
.Count
;
874 * Calculate the size of the return buffer.
875 * The base size is the number of elements * the sizes of the
876 * structures. Additional space for the strings is added below.
877 * The minus one is to subtract the size of the UINT8 Source[1]
878 * member because it is added below.
880 * But each PRT_ENTRY structure has a pointer to a string and
881 * the size of that string must be found.
883 TopObjectList
= PackageObject
->Package
.Elements
;
885 for (Index
= 0; Index
< NumberOfElements
; Index
++)
887 /* Dereference the subpackage */
889 PackageElement
= *TopObjectList
;
891 /* We must have a valid Package object */
893 if (!PackageElement
||
894 (PackageElement
->Common
.Type
!= ACPI_TYPE_PACKAGE
))
896 return_ACPI_STATUS (AE_AML_OPERAND_TYPE
);
900 * The SubObjectList will now point to an array of the
901 * four IRQ elements: Address, Pin, Source and SourceIndex
903 SubObjectList
= PackageElement
->Package
.Elements
;
905 /* Scan the IrqTableElements for the Source Name String */
910 TableIndex
< PackageElement
->Package
.Count
&& !NameFound
;
913 if (*SubObjectList
&& /* Null object allowed */
915 ((ACPI_TYPE_STRING
==
916 (*SubObjectList
)->Common
.Type
) ||
918 ((ACPI_TYPE_LOCAL_REFERENCE
==
919 (*SubObjectList
)->Common
.Type
) &&
921 ((*SubObjectList
)->Reference
.Class
==
922 ACPI_REFCLASS_NAME
))))
928 /* Look at the next element */
934 TempSizeNeeded
+= (sizeof (ACPI_PCI_ROUTING_TABLE
) - 4);
936 /* Was a String type found? */
940 if ((*SubObjectList
)->Common
.Type
== ACPI_TYPE_STRING
)
943 * The length String.Length field does not include the
944 * terminating NULL, add 1
946 TempSizeNeeded
+= ((ACPI_SIZE
)
947 (*SubObjectList
)->String
.Length
+ 1);
951 TempSizeNeeded
+= AcpiNsGetPathnameLength (
952 (*SubObjectList
)->Reference
.Node
);
958 * If no name was found, then this is a NULL, which is
959 * translated as a UINT32 zero.
961 TempSizeNeeded
+= sizeof (UINT32
);
964 /* Round up the size since each element must be aligned */
966 TempSizeNeeded
= ACPI_ROUND_UP_TO_64BIT (TempSizeNeeded
);
968 /* Point to the next ACPI_OPERAND_OBJECT */
974 * Add an extra element to the end of the list, essentially a
977 *BufferSizeNeeded
= TempSizeNeeded
+ sizeof (ACPI_PCI_ROUTING_TABLE
);
978 return_ACPI_STATUS (AE_OK
);