1 /******************************************************************************
3 * Module Name: aslprepkg - support for ACPI predefined name package objects
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 *****************************************************************************/
152 #include "aslcompiler.h"
153 #include "aslcompiler.y.h"
154 #include "acpredef.h"
157 #define _COMPONENT ACPI_COMPILER
158 ACPI_MODULE_NAME ("aslprepkg")
161 /* Local prototypes */
163 static ACPI_PARSE_OBJECT
*
164 ApCheckPackageElements (
165 const char *PredefinedName
,
166 ACPI_PARSE_OBJECT
*Op
,
174 const char *PredefinedName
,
175 ACPI_PARSE_OBJECT
*ParentOp
,
176 const ACPI_PREDEFINED_INFO
*Package
,
182 const char *PredefinedName
,
183 ACPI_PARSE_OBJECT
*Op
,
185 UINT32 ExpectedCount
);
188 ApZeroLengthPackage (
189 const char *PredefinedName
,
190 ACPI_PARSE_OBJECT
*Op
);
194 const char *PredefinedName
,
195 ACPI_PARSE_OBJECT
*Op
,
197 UINT32 ExpectedCount
);
201 ACPI_PARSE_OBJECT
*ParentOp
,
202 const ACPI_PREDEFINED_INFO
*Predefined
);
205 /*******************************************************************************
207 * FUNCTION: ApCheckPackage
209 * PARAMETERS: ParentOp - Parser op for the package
210 * Predefined - Pointer to package-specific info for
215 * DESCRIPTION: Top-level validation for predefined name return package
218 ******************************************************************************/
222 ACPI_PARSE_OBJECT
*ParentOp
,
223 const ACPI_PREDEFINED_INFO
*Predefined
)
225 ACPI_PARSE_OBJECT
*Op
;
226 const ACPI_PREDEFINED_INFO
*Package
;
228 UINT32 ExpectedCount
;
233 /* The package info for this name is in the next table entry */
235 Package
= Predefined
+ 1;
237 /* First child is the package length */
239 Op
= ParentOp
->Asl
.Child
;
240 Count
= (UINT32
) Op
->Asl
.Value
.Integer
;
243 * Many of the variable-length top-level packages are allowed to simply
244 * have zero elements. This allows the BIOS to tell the host that even
245 * though the predefined name/method exists, the feature is not supported.
246 * Other package types require one or more elements. In any case, there
247 * is no need to continue validation.
251 switch (Package
->RetInfo
.Type
)
253 case ACPI_PTYPE1_FIXED
:
254 case ACPI_PTYPE1_OPTION
:
255 case ACPI_PTYPE2_PKG_COUNT
:
256 case ACPI_PTYPE2_REV_FIXED
:
258 ApZeroLengthPackage (Predefined
->Info
.Name
, ParentOp
);
261 case ACPI_PTYPE1_VAR
:
263 case ACPI_PTYPE2_COUNT
:
264 case ACPI_PTYPE2_FIXED
:
265 case ACPI_PTYPE2_MIN
:
266 case ACPI_PTYPE2_FIX_VAR
:
267 case ACPI_PTYPE2_VAR_VAR
:
276 /* Get the first element of the package */
280 /* Decode the package type */
282 switch (Package
->RetInfo
.Type
)
284 case ACPI_PTYPE_CUSTOM
:
286 ApCustomPackage (ParentOp
, Predefined
);
289 case ACPI_PTYPE1_FIXED
:
291 * The package count is fixed and there are no subpackages
293 * If package is too small, exit.
294 * If package is larger than expected, issue warning but continue
296 ExpectedCount
= Package
->RetInfo
.Count1
+ Package
->RetInfo
.Count2
;
297 if (Count
< ExpectedCount
)
299 goto PackageTooSmall
;
301 else if (Count
> ExpectedCount
)
303 ApPackageTooLarge (Predefined
->Info
.Name
, ParentOp
,
304 Count
, ExpectedCount
);
307 /* Validate all elements of the package */
309 ApCheckPackageElements (Predefined
->Info
.Name
, Op
,
310 Package
->RetInfo
.ObjectType1
, Package
->RetInfo
.Count1
,
311 Package
->RetInfo
.ObjectType2
, Package
->RetInfo
.Count2
);
314 case ACPI_PTYPE1_VAR
:
316 * The package count is variable, there are no subpackages,
317 * and all elements must be of the same type
319 for (i
= 0; i
< Count
; i
++)
321 ApCheckObjectType (Predefined
->Info
.Name
, Op
,
322 Package
->RetInfo
.ObjectType1
, i
);
327 case ACPI_PTYPE1_OPTION
:
329 * The package count is variable, there are no subpackages.
330 * There are a fixed number of required elements, and a variable
331 * number of optional elements.
333 * Check if package is at least as large as the minimum required
335 ExpectedCount
= Package
->RetInfo3
.Count
;
336 if (Count
< ExpectedCount
)
338 goto PackageTooSmall
;
341 /* Variable number of sub-objects */
343 for (i
= 0; i
< Count
; i
++)
345 if (i
< Package
->RetInfo3
.Count
)
347 /* These are the required package elements (0, 1, or 2) */
349 ApCheckObjectType (Predefined
->Info
.Name
, Op
,
350 Package
->RetInfo3
.ObjectType
[i
], i
);
354 /* These are the optional package elements */
356 ApCheckObjectType (Predefined
->Info
.Name
, Op
,
357 Package
->RetInfo3
.TailObjectType
, i
);
364 case ACPI_PTYPE2_REV_FIXED
:
366 /* First element is the (Integer) revision */
368 ApCheckObjectType (Predefined
->Info
.Name
, Op
,
369 ACPI_RTYPE_INTEGER
, 0);
374 /* Examine the subpackages */
376 ApCheckPackageList (Predefined
->Info
.Name
, Op
,
380 case ACPI_PTYPE2_PKG_COUNT
:
382 /* First element is the (Integer) count of subpackages to follow */
384 Status
= ApCheckObjectType (Predefined
->Info
.Name
, Op
,
385 ACPI_RTYPE_INTEGER
, 0);
387 /* We must have an integer count from above (otherwise, use Count) */
389 if (ACPI_SUCCESS (Status
))
392 * Count cannot be larger than the parent package length, but
393 * allow it to be smaller. The >= accounts for the Integer above.
395 ExpectedCount
= (UINT32
) Op
->Asl
.Value
.Integer
;
396 if (ExpectedCount
>= Count
)
398 goto PackageTooSmall
;
401 Count
= ExpectedCount
;
406 /* Examine the subpackages */
408 ApCheckPackageList (Predefined
->Info
.Name
, Op
,
412 case ACPI_PTYPE2_UUID_PAIR
:
414 /* The package contains a variable list of UUID Buffer/Package pairs */
416 /* The length of the package must be even */
420 sprintf (MsgBuffer
, "%4.4s: Package length, %d, must be even.",
421 Predefined
->Info
.Name
, Count
);
423 AslError (ASL_ERROR
, ASL_MSG_RESERVED_PACKAGE_LENGTH
,
424 ParentOp
->Asl
.Child
, MsgBuffer
);
427 /* Validate the alternating types */
429 for (i
= 0; i
< Count
; ++i
)
433 ApCheckObjectType (Predefined
->Info
.Name
, Op
,
434 Package
->RetInfo
.ObjectType2
, i
);
438 ApCheckObjectType (Predefined
->Info
.Name
, Op
,
439 Package
->RetInfo
.ObjectType1
, i
);
447 case ACPI_PTYPE2_VAR_VAR
:
449 /* Check for minimum size (ints at beginning + 1 subpackage) */
451 ExpectedCount
= Package
->RetInfo4
.Count1
+ 1;
452 if (Count
< ExpectedCount
)
454 goto PackageTooSmall
;
457 /* Check the non-package elements at beginning of main package */
459 for (i
= 0; i
< Package
->RetInfo4
.Count1
; ++i
)
461 Status
= ApCheckObjectType (Predefined
->Info
.Name
, Op
,
462 Package
->RetInfo4
.ObjectType1
, i
);
466 /* Examine the variable-length list of subpackages */
468 ApCheckPackageList (Predefined
->Info
.Name
, Op
,
469 Package
, Package
->RetInfo4
.Count1
, Count
);
474 case ACPI_PTYPE2_FIXED
:
475 case ACPI_PTYPE2_MIN
:
476 case ACPI_PTYPE2_COUNT
:
477 case ACPI_PTYPE2_FIX_VAR
:
479 * These types all return a single Package that consists of a
480 * variable number of subpackages.
483 /* Examine the subpackages */
485 ApCheckPackageList (Predefined
->Info
.Name
, Op
,
496 ApPackageTooSmall (Predefined
->Info
.Name
, ParentOp
,
497 Count
, ExpectedCount
);
501 /*******************************************************************************
503 * FUNCTION: ApCustomPackage
505 * PARAMETERS: ParentOp - Parse op for the package
506 * Predefined - Pointer to package-specific info for
511 * DESCRIPTION: Validate packages that don't fit into the standard model and
512 * require custom code.
514 * NOTE: Currently used for the _BIX method only. When needed for two or more
515 * methods, probably a detect/dispatch mechanism will be required.
517 ******************************************************************************/
521 ACPI_PARSE_OBJECT
*ParentOp
,
522 const ACPI_PREDEFINED_INFO
*Predefined
)
524 ACPI_PARSE_OBJECT
*Op
;
526 UINT32 ExpectedCount
;
530 /* First child is the package length */
532 Op
= ParentOp
->Asl
.Child
;
533 Count
= (UINT32
) Op
->Asl
.Value
.Integer
;
535 /* Get the version number, must be Integer */
538 Version
= (UINT32
) Op
->Asl
.Value
.Integer
;
539 if (Op
->Asl
.ParseOpcode
!= PARSEOP_INTEGER
)
541 AslError (ASL_ERROR
, ASL_MSG_RESERVED_OPERAND_TYPE
, Op
, MsgBuffer
);
545 /* Validate count (# of elements) */
547 ExpectedCount
= 21; /* Version 1 */
550 ExpectedCount
= 20; /* Version 0 */
553 if (Count
< ExpectedCount
)
555 ApPackageTooSmall (Predefined
->Info
.Name
, ParentOp
,
556 Count
, ExpectedCount
);
559 else if (Count
> ExpectedCount
)
561 ApPackageTooLarge (Predefined
->Info
.Name
, ParentOp
,
562 Count
, ExpectedCount
);
565 /* Validate all elements of the package */
567 Op
= ApCheckPackageElements (Predefined
->Info
.Name
, Op
,
568 ACPI_RTYPE_INTEGER
, 16,
569 ACPI_RTYPE_STRING
, 4);
571 /* Version 1 has a single trailing integer */
575 ApCheckPackageElements (Predefined
->Info
.Name
, Op
,
576 ACPI_RTYPE_INTEGER
, 1, 0, 0);
581 /*******************************************************************************
583 * FUNCTION: ApCheckPackageElements
585 * PARAMETERS: PredefinedName - Name of the predefined object
586 * Op - Parser op for the package
587 * Type1 - Object type for first group
588 * Count1 - Count for first group
589 * Type2 - Object type for second group
590 * Count2 - Count for second group
592 * RETURN: Next Op peer in the parse tree, after all specified elements
593 * have been validated. Used for multiple validations (calls
596 * DESCRIPTION: Validate all elements of a package. Works with packages that
597 * are defined to contain up to two groups of different object
600 ******************************************************************************/
602 static ACPI_PARSE_OBJECT
*
603 ApCheckPackageElements (
604 const char *PredefinedName
,
605 ACPI_PARSE_OBJECT
*Op
,
615 * Up to two groups of package elements are supported by the data
616 * structure. All elements in each group must be of the same type.
617 * The second group can have a count of zero.
619 * Aborts check upon a NULL package element, as this means (at compile
620 * time) that the remainder of the package elements are also NULL
621 * (This is the only way to create NULL package elements.)
623 for (i
= 0; (i
< Count1
) && Op
; i
++)
625 ApCheckObjectType (PredefinedName
, Op
, Type1
, i
);
629 for (i
= 0; (i
< Count2
) && Op
; i
++)
631 ApCheckObjectType (PredefinedName
, Op
, Type2
, (i
+ Count1
));
639 /*******************************************************************************
641 * FUNCTION: ApCheckPackageList
643 * PARAMETERS: PredefinedName - Name of the predefined object
644 * ParentOp - Parser op of the parent package
645 * Package - Package info for this predefined name
646 * StartIndex - Index in parent package where list begins
647 * ParentCount - Element count of parent package
651 * DESCRIPTION: Validate the individual package elements for a predefined name.
652 * Handles the cases where the predefined name is defined as a
653 * Package of Packages (subpackages). These are the types:
659 * ACPI_PTYPE2_FIX_VAR
660 * ACPI_PTYPE2_VAR_VAR
662 ******************************************************************************/
666 const char *PredefinedName
,
667 ACPI_PARSE_OBJECT
*ParentOp
,
668 const ACPI_PREDEFINED_INFO
*Package
,
672 ACPI_PARSE_OBJECT
*SubPackageOp
= ParentOp
;
673 ACPI_PARSE_OBJECT
*Op
;
676 UINT32 ExpectedCount
;
682 * Validate each subpackage in the parent Package
684 * Note: We ignore NULL package elements on the assumption that
685 * they will be initialized by the BIOS or other ASL code.
687 for (i
= 0; (i
< ParentCount
) && SubPackageOp
; i
++)
689 /* Each object in the list must be of type Package */
691 Status
= ApCheckObjectType (PredefinedName
, SubPackageOp
,
692 ACPI_RTYPE_PACKAGE
, i
+ StartIndex
);
693 if (ACPI_FAILURE (Status
))
698 /* Examine the different types of expected subpackages */
700 Op
= SubPackageOp
->Asl
.Child
;
702 /* First child is the package length */
704 Count
= (UINT32
) Op
->Asl
.Value
.Integer
;
708 * Most subpackage must have at least one element, with
709 * only rare exceptions. (_RDI)
712 (Package
->RetInfo
.Type
!= ACPI_PTYPE2_VAR_VAR
))
714 ApZeroLengthPackage (PredefinedName
, SubPackageOp
);
719 * Decode the package type.
720 * PTYPE2 indicates that a "package of packages" is expected for
721 * this name. The various flavors of PTYPE2 indicate the number
722 * and format of the subpackages.
724 switch (Package
->RetInfo
.Type
)
727 case ACPI_PTYPE2_PKG_COUNT
:
728 case ACPI_PTYPE2_REV_FIXED
:
730 /* Each subpackage has a fixed number of elements */
732 ExpectedCount
= Package
->RetInfo
.Count1
+ Package
->RetInfo
.Count2
;
733 if (Count
< ExpectedCount
)
735 ApPackageTooSmall (PredefinedName
, SubPackageOp
,
736 Count
, ExpectedCount
);
739 if (Count
> ExpectedCount
)
741 ApPackageTooLarge (PredefinedName
, SubPackageOp
,
742 Count
, ExpectedCount
);
746 ApCheckPackageElements (PredefinedName
, Op
,
747 Package
->RetInfo
.ObjectType1
, Package
->RetInfo
.Count1
,
748 Package
->RetInfo
.ObjectType2
, Package
->RetInfo
.Count2
);
751 case ACPI_PTYPE2_FIX_VAR
:
753 * Each subpackage has a fixed number of elements and an
756 ExpectedCount
= Package
->RetInfo
.Count1
+ Package
->RetInfo
.Count2
;
757 if (Count
< ExpectedCount
)
759 ApPackageTooSmall (PredefinedName
, SubPackageOp
,
760 Count
, ExpectedCount
);
764 ApCheckPackageElements (PredefinedName
, Op
,
765 Package
->RetInfo
.ObjectType1
, Package
->RetInfo
.Count1
,
766 Package
->RetInfo
.ObjectType2
,
767 Count
- Package
->RetInfo
.Count1
);
770 case ACPI_PTYPE2_VAR_VAR
:
772 * Must have at least the minimum number elements.
773 * A zero PkgCount means the number of elements is variable.
775 ExpectedCount
= Package
->RetInfo4
.PkgCount
;
776 if (ExpectedCount
&& (Count
< ExpectedCount
))
778 ApPackageTooSmall (PredefinedName
, SubPackageOp
,
783 ApCheckPackageElements (PredefinedName
, Op
,
784 Package
->RetInfo4
.SubObjectTypes
,
785 Package
->RetInfo4
.PkgCount
,
789 case ACPI_PTYPE2_FIXED
:
791 /* Each subpackage has a fixed length */
793 ExpectedCount
= Package
->RetInfo2
.Count
;
794 if (Count
< ExpectedCount
)
796 ApPackageTooSmall (PredefinedName
, SubPackageOp
,
797 Count
, ExpectedCount
);
800 if (Count
> ExpectedCount
)
802 ApPackageTooLarge (PredefinedName
, SubPackageOp
,
803 Count
, ExpectedCount
);
807 /* Check each object/type combination */
809 for (j
= 0; j
< ExpectedCount
; j
++)
811 ApCheckObjectType (PredefinedName
, Op
,
812 Package
->RetInfo2
.ObjectType
[j
], j
);
818 case ACPI_PTYPE2_MIN
:
820 /* Each subpackage has a variable but minimum length */
822 ExpectedCount
= Package
->RetInfo
.Count1
;
823 if (Count
< ExpectedCount
)
825 ApPackageTooSmall (PredefinedName
, SubPackageOp
,
826 Count
, ExpectedCount
);
830 /* Check the type of each subpackage element */
832 ApCheckPackageElements (PredefinedName
, Op
,
833 Package
->RetInfo
.ObjectType1
, Count
, 0, 0);
836 case ACPI_PTYPE2_COUNT
:
838 * First element is the (Integer) count of elements, including
839 * the count field (the ACPI name is NumElements)
841 Status
= ApCheckObjectType (PredefinedName
, Op
,
842 ACPI_RTYPE_INTEGER
, 0);
844 /* We must have an integer count from above (otherwise, use Count) */
846 if (ACPI_SUCCESS (Status
))
849 * Make sure package is large enough for the Count and is
850 * is as large as the minimum size
852 ExpectedCount
= (UINT32
) Op
->Asl
.Value
.Integer
;
854 if (Count
< ExpectedCount
)
856 ApPackageTooSmall (PredefinedName
, SubPackageOp
,
857 Count
, ExpectedCount
);
860 else if (Count
> ExpectedCount
)
862 ApPackageTooLarge (PredefinedName
, SubPackageOp
,
863 Count
, ExpectedCount
);
866 /* Some names of this type have a minimum length */
868 if (Count
< Package
->RetInfo
.Count1
)
870 ExpectedCount
= Package
->RetInfo
.Count1
;
871 ApPackageTooSmall (PredefinedName
, SubPackageOp
,
872 Count
, ExpectedCount
);
876 Count
= ExpectedCount
;
879 /* Check the type of each subpackage element */
882 ApCheckPackageElements (PredefinedName
, Op
,
883 Package
->RetInfo
.ObjectType1
, (Count
- 1), 0, 0);
891 SubPackageOp
= SubPackageOp
->Asl
.Next
;
896 /*******************************************************************************
898 * FUNCTION: ApPackageTooSmall
900 * PARAMETERS: PredefinedName - Name of the predefined object
901 * Op - Current parser op
902 * Count - Actual package element count
903 * ExpectedCount - Expected package element count
907 * DESCRIPTION: Issue error message for a package that is smaller than
910 ******************************************************************************/
914 const char *PredefinedName
,
915 ACPI_PARSE_OBJECT
*Op
,
917 UINT32 ExpectedCount
)
920 sprintf (MsgBuffer
, "%s: length %u, required minimum is %u",
921 PredefinedName
, Count
, ExpectedCount
);
923 AslError (ASL_ERROR
, ASL_MSG_RESERVED_PACKAGE_LENGTH
, Op
, MsgBuffer
);
927 /*******************************************************************************
929 * FUNCTION: ApZeroLengthPackage
931 * PARAMETERS: PredefinedName - Name of the predefined object
932 * Op - Current parser op
936 * DESCRIPTION: Issue error message for a zero-length package (a package that
937 * is required to have a non-zero length). Variable length
938 * packages seem to be allowed to have zero length, however.
939 * Even if not allowed, BIOS code does it.
941 ******************************************************************************/
944 ApZeroLengthPackage (
945 const char *PredefinedName
,
946 ACPI_PARSE_OBJECT
*Op
)
949 sprintf (MsgBuffer
, "%s: length is zero", PredefinedName
);
951 AslError (ASL_ERROR
, ASL_MSG_RESERVED_PACKAGE_LENGTH
, Op
, MsgBuffer
);
955 /*******************************************************************************
957 * FUNCTION: ApPackageTooLarge
959 * PARAMETERS: PredefinedName - Name of the predefined object
960 * Op - Current parser op
961 * Count - Actual package element count
962 * ExpectedCount - Expected package element count
966 * DESCRIPTION: Issue a remark for a package that is larger than expected.
968 ******************************************************************************/
972 const char *PredefinedName
,
973 ACPI_PARSE_OBJECT
*Op
,
975 UINT32 ExpectedCount
)
978 sprintf (MsgBuffer
, "%s: length is %u, only %u required",
979 PredefinedName
, Count
, ExpectedCount
);
981 AslError (ASL_REMARK
, ASL_MSG_RESERVED_PACKAGE_LENGTH
, Op
, MsgBuffer
);