Path: blob/main/sys/contrib/dev/acpica/compiler/aslprepkg.c
48371 views
/******************************************************************************1*2* Module Name: aslprepkg - support for ACPI predefined name package objects3*4*****************************************************************************/56/******************************************************************************7*8* 1. Copyright Notice9*10* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.11* All rights reserved.12*13* 2. License14*15* 2.1. This is your license from Intel Corp. under its intellectual property16* rights. You may have additional license terms from the party that provided17* you this software, covering your right to use that party's intellectual18* property rights.19*20* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a21* copy of the source code appearing in this file ("Covered Code") an22* irrevocable, perpetual, worldwide license under Intel's copyrights in the23* base code distributed originally by Intel ("Original Intel Code") to copy,24* make derivatives, distribute, use and display any portion of the Covered25* Code in any form, with the right to sublicense such rights; and26*27* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent28* license (with the right to sublicense), under only those claims of Intel29* patents that are infringed by the Original Intel Code, to make, use, sell,30* offer to sell, and import the Covered Code and derivative works thereof31* solely to the minimum extent necessary to exercise the above copyright32* license, and in no event shall the patent license extend to any additions33* to or modifications of the Original Intel Code. No other license or right34* is granted directly or by implication, estoppel or otherwise;35*36* The above copyright and patent license is granted only if the following37* conditions are met:38*39* 3. Conditions40*41* 3.1. Redistribution of Source with Rights to Further Distribute Source.42* Redistribution of source code of any substantial portion of the Covered43* Code or modification with rights to further distribute source must include44* the above Copyright Notice, the above License, this list of Conditions,45* and the following Disclaimer and Export Compliance provision. In addition,46* Licensee must cause all Covered Code to which Licensee contributes to47* contain a file documenting the changes Licensee made to create that Covered48* Code and the date of any change. Licensee must include in that file the49* documentation of any changes made by any predecessor Licensee. Licensee50* must include a prominent statement that the modification is derived,51* directly or indirectly, from Original Intel Code.52*53* 3.2. Redistribution of Source with no Rights to Further Distribute Source.54* Redistribution of source code of any substantial portion of the Covered55* Code or modification without rights to further distribute source must56* include the following Disclaimer and Export Compliance provision in the57* documentation and/or other materials provided with distribution. In58* addition, Licensee may not authorize further sublicense of source of any59* portion of the Covered Code, and must include terms to the effect that the60* license from Licensee to its licensee is limited to the intellectual61* property embodied in the software Licensee provides to its licensee, and62* not to intellectual property embodied in modifications its licensee may63* make.64*65* 3.3. Redistribution of Executable. Redistribution in executable form of any66* substantial portion of the Covered Code or modification must reproduce the67* above Copyright Notice, and the following Disclaimer and Export Compliance68* provision in the documentation and/or other materials provided with the69* distribution.70*71* 3.4. Intel retains all right, title, and interest in and to the Original72* Intel Code.73*74* 3.5. Neither the name Intel nor any other trademark owned or controlled by75* Intel shall be used in advertising or otherwise to promote the sale, use or76* other dealings in products derived from or relating to the Covered Code77* without prior written authorization from Intel.78*79* 4. Disclaimer and Export Compliance80*81* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED82* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE83* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,84* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY85* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY86* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A87* PARTICULAR PURPOSE.88*89* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES90* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR91* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,92* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY93* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL94* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS95* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY96* LIMITED REMEDY.97*98* 4.3. Licensee shall not export, either directly or indirectly, any of this99* software or system incorporating such software without first obtaining any100* required license or other approval from the U. S. Department of Commerce or101* any other agency or department of the United States Government. In the102* event Licensee exports any such software from the United States or103* re-exports any such software from a foreign destination, Licensee shall104* ensure that the distribution and export/re-export of the software is in105* compliance with all laws, regulations, orders, or other restrictions of the106* U.S. Export Administration Regulations. Licensee agrees that neither it nor107* any of its subsidiaries will export/re-export any technical data, process,108* software, or service, directly or indirectly, to any country for which the109* United States government or any agency thereof requires an export license,110* other governmental approval, or letter of assurance, without first obtaining111* such license, approval or letter.112*113*****************************************************************************114*115* Alternatively, you may choose to be licensed under the terms of the116* following license:117*118* Redistribution and use in source and binary forms, with or without119* modification, are permitted provided that the following conditions120* are met:121* 1. Redistributions of source code must retain the above copyright122* notice, this list of conditions, and the following disclaimer,123* without modification.124* 2. Redistributions in binary form must reproduce at minimum a disclaimer125* substantially similar to the "NO WARRANTY" disclaimer below126* ("Disclaimer") and any redistribution must be conditioned upon127* including a substantially similar Disclaimer requirement for further128* binary redistribution.129* 3. Neither the names of the above-listed copyright holders nor the names130* of any contributors may be used to endorse or promote products derived131* from this software without specific prior written permission.132*133* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS134* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT135* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR136* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT137* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,138* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT139* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,140* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY141* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT142* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE143* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.144*145* Alternatively, you may choose to be licensed under the terms of the146* GNU General Public License ("GPL") version 2 as published by the Free147* Software Foundation.148*149*****************************************************************************/150151#include <contrib/dev/acpica/compiler/aslcompiler.h>152#include "aslcompiler.y.h"153#include <contrib/dev/acpica/include/acpredef.h>154155156#define _COMPONENT ACPI_COMPILER157ACPI_MODULE_NAME ("aslprepkg")158159160/* Local prototypes */161162static ACPI_PARSE_OBJECT *163ApCheckPackageElements (164const char *PredefinedName,165ACPI_PARSE_OBJECT *Op,166UINT8 Type1,167UINT32 Count1,168UINT8 Type2,169UINT32 Count2);170171static void172ApCheckPackageList (173const char *PredefinedName,174ACPI_PARSE_OBJECT *ParentOp,175const ACPI_PREDEFINED_INFO *Package,176UINT32 StartIndex,177UINT32 Count);178179static void180ApPackageTooSmall (181const char *PredefinedName,182ACPI_PARSE_OBJECT *Op,183UINT32 Count,184UINT32 ExpectedCount);185186static void187ApZeroLengthPackage (188const char *PredefinedName,189ACPI_PARSE_OBJECT *Op);190191static void192ApPackageTooLarge (193const char *PredefinedName,194ACPI_PARSE_OBJECT *Op,195UINT32 Count,196UINT32 ExpectedCount);197198static void199ApCustomPackage (200ACPI_PARSE_OBJECT *ParentOp,201const ACPI_PREDEFINED_INFO *Predefined);202203204/*******************************************************************************205*206* FUNCTION: ApCheckPackage207*208* PARAMETERS: ParentOp - Parser op for the package209* Predefined - Pointer to package-specific info for210* the method211*212* RETURN: None213*214* DESCRIPTION: Top-level validation for predefined name return package215* objects.216*217******************************************************************************/218219void220ApCheckPackage (221ACPI_PARSE_OBJECT *ParentOp,222const ACPI_PREDEFINED_INFO *Predefined)223{224ACPI_PARSE_OBJECT *Op;225const ACPI_PREDEFINED_INFO *Package;226ACPI_STATUS Status;227UINT32 ExpectedCount;228UINT32 Count;229UINT32 i;230231232/* The package info for this name is in the next table entry */233234Package = Predefined + 1;235236/* First child is the package length */237238Op = ParentOp->Asl.Child;239Count = (UINT32) Op->Asl.Value.Integer;240241/*242* Many of the variable-length top-level packages are allowed to simply243* have zero elements. This allows the BIOS to tell the host that even244* though the predefined name/method exists, the feature is not supported.245* Other package types require one or more elements. In any case, there246* is no need to continue validation.247*/248if (!Count)249{250switch (Package->RetInfo.Type)251{252case ACPI_PTYPE1_FIXED:253case ACPI_PTYPE1_OPTION:254case ACPI_PTYPE2_PKG_COUNT:255case ACPI_PTYPE2_REV_FIXED:256257ApZeroLengthPackage (Predefined->Info.Name, ParentOp);258break;259260case ACPI_PTYPE1_VAR:261case ACPI_PTYPE2:262case ACPI_PTYPE2_COUNT:263case ACPI_PTYPE2_FIXED:264case ACPI_PTYPE2_MIN:265case ACPI_PTYPE2_FIX_VAR:266case ACPI_PTYPE2_VAR_VAR:267default:268269break;270}271272return;273}274275/* Get the first element of the package */276277Op = Op->Asl.Next;278279/* Decode the package type */280281switch (Package->RetInfo.Type)282{283case ACPI_PTYPE_CUSTOM:284285ApCustomPackage (ParentOp, Predefined);286break;287288case ACPI_PTYPE1_FIXED:289/*290* The package count is fixed and there are no subpackages291*292* If package is too small, exit.293* If package is larger than expected, issue warning but continue294*/295ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2;296if (Count < ExpectedCount)297{298goto PackageTooSmall;299}300else if (Count > ExpectedCount)301{302ApPackageTooLarge (Predefined->Info.Name, ParentOp,303Count, ExpectedCount);304}305306/* Validate all elements of the package */307308ApCheckPackageElements (Predefined->Info.Name, Op,309Package->RetInfo.ObjectType1, Package->RetInfo.Count1,310Package->RetInfo.ObjectType2, Package->RetInfo.Count2);311break;312313case ACPI_PTYPE1_VAR:314/*315* The package count is variable, there are no subpackages,316* and all elements must be of the same type317*/318for (i = 0; i < Count; i++)319{320if (!Op)321{322/*323* If we get to this point, it means that the package length324* is larger than the initializer list. Stop processing the325* package and return because we have run out of package326* elements to analyze.327*/328return;329}330331ApCheckObjectType (Predefined->Info.Name, Op,332Package->RetInfo.ObjectType1, i);333Op = Op->Asl.Next;334}335break;336337case ACPI_PTYPE1_OPTION:338/*339* The package count is variable, there are no subpackages.340* There are a fixed number of required elements, and a variable341* number of optional elements.342*343* Check if package is at least as large as the minimum required344*/345ExpectedCount = Package->RetInfo3.Count;346if (Count < ExpectedCount)347{348goto PackageTooSmall;349}350351/* Variable number of sub-objects */352353for (i = 0; i < Count; i++)354{355if (i < Package->RetInfo3.Count)356{357/* These are the required package elements (0, 1, or 2) */358359ApCheckObjectType (Predefined->Info.Name, Op,360Package->RetInfo3.ObjectType[i], i);361}362else363{364/* These are the optional package elements */365366ApCheckObjectType (Predefined->Info.Name, Op,367Package->RetInfo3.TailObjectType, i);368}369370Op = Op->Asl.Next;371}372break;373374case ACPI_PTYPE2_REV_FIXED:375376/* First element is the (Integer) revision */377378ApCheckObjectType (Predefined->Info.Name, Op,379ACPI_RTYPE_INTEGER, 0);380381Op = Op->Asl.Next;382Count--;383384/* Examine the subpackages */385386ApCheckPackageList (Predefined->Info.Name, Op,387Package, 1, Count);388break;389390case ACPI_PTYPE2_PKG_COUNT:391392/* First element is the (Integer) count of subpackages to follow */393394Status = ApCheckObjectType (Predefined->Info.Name, Op,395ACPI_RTYPE_INTEGER, 0);396397/* We must have an integer count from above (otherwise, use Count) */398399if (ACPI_SUCCESS (Status))400{401/*402* Count cannot be larger than the parent package length, but403* allow it to be smaller. The >= accounts for the Integer above.404*/405ExpectedCount = (UINT32) Op->Asl.Value.Integer;406if (ExpectedCount >= Count)407{408goto PackageTooSmall;409}410411Count = ExpectedCount;412}413414Op = Op->Asl.Next;415416/* Examine the subpackages */417418ApCheckPackageList (Predefined->Info.Name, Op,419Package, 1, Count);420break;421422case ACPI_PTYPE2_UUID_PAIR:423424/* The package contains a variable list of UUID Buffer/Package pairs */425426/* The length of the package must be even */427428if (Count & 1)429{430sprintf (AslGbl_MsgBuffer, "%4.4s: Package length, %d, must be even.",431Predefined->Info.Name, Count);432433AslError (ASL_ERROR, ASL_MSG_RESERVED_PACKAGE_LENGTH,434ParentOp->Asl.Child, AslGbl_MsgBuffer);435}436437/* Validate the alternating types */438439for (i = 0; i < Count; ++i)440{441if (i & 1)442{443ApCheckObjectType (Predefined->Info.Name, Op,444Package->RetInfo.ObjectType2, i);445}446else447{448ApCheckObjectType (Predefined->Info.Name, Op,449Package->RetInfo.ObjectType1, i);450}451452Op = Op->Asl.Next;453}454455break;456457case ACPI_PTYPE2_VAR_VAR:458459/* Check for minimum size (ints at beginning + 1 subpackage) */460461ExpectedCount = Package->RetInfo4.Count1 + 1;462if (Count < ExpectedCount)463{464goto PackageTooSmall;465}466467/* Check the non-package elements at beginning of main package */468469for (i = 0; i < Package->RetInfo4.Count1; ++i)470{471ApCheckObjectType (Predefined->Info.Name, Op,472Package->RetInfo4.ObjectType1, i);473Op = Op->Asl.Next;474}475476/* Examine the variable-length list of subpackages */477478ApCheckPackageList (Predefined->Info.Name, Op,479Package, Package->RetInfo4.Count1, Count);480481break;482483case ACPI_PTYPE2:484case ACPI_PTYPE2_FIXED:485case ACPI_PTYPE2_MIN:486case ACPI_PTYPE2_COUNT:487case ACPI_PTYPE2_FIX_VAR:488/*489* These types all return a single Package that consists of a490* variable number of subpackages.491*/492493/* Examine the subpackages */494495ApCheckPackageList (Predefined->Info.Name, Op,496Package, 0, Count);497break;498499default:500return;501}502503return;504505PackageTooSmall:506ApPackageTooSmall (Predefined->Info.Name, ParentOp,507Count, ExpectedCount);508}509510511/*******************************************************************************512*513* FUNCTION: ApCustomPackage514*515* PARAMETERS: ParentOp - Parse op for the package516* Predefined - Pointer to package-specific info for517* the method518*519* RETURN: None520*521* DESCRIPTION: Validate packages that don't fit into the standard model and522* require custom code.523*524* NOTE: Currently used for the _BIX method only. When needed for two or more525* methods, probably a detect/dispatch mechanism will be required.526*527******************************************************************************/528529static void530ApCustomPackage (531ACPI_PARSE_OBJECT *ParentOp,532const ACPI_PREDEFINED_INFO *Predefined)533{534ACPI_PARSE_OBJECT *Op;535UINT32 Count;536UINT32 ExpectedCount;537UINT32 Version;538539540/* First child is the package length */541542Op = ParentOp->Asl.Child;543Count = (UINT32) Op->Asl.Value.Integer;544545/* Get the version number, must be Integer */546547Op = Op->Asl.Next;548Version = (UINT32) Op->Asl.Value.Integer;549if (Op->Asl.ParseOpcode != PARSEOP_INTEGER)550{551AslError (ASL_ERROR, ASL_MSG_RESERVED_OPERAND_TYPE, Op, AslGbl_MsgBuffer);552return;553}554555/* Validate count (# of elements) */556557ExpectedCount = 21; /* Version 1 */558if (Version == 0)559{560ExpectedCount = 20; /* Version 0 */561}562563if (Count < ExpectedCount)564{565ApPackageTooSmall (Predefined->Info.Name, ParentOp,566Count, ExpectedCount);567return;568}569else if (Count > ExpectedCount)570{571ApPackageTooLarge (Predefined->Info.Name, ParentOp,572Count, ExpectedCount);573}574575/* Validate all elements of the package */576577Op = ApCheckPackageElements (Predefined->Info.Name, Op,578ACPI_RTYPE_INTEGER, 16,579ACPI_RTYPE_STRING, 4);580581/* Version 1 has a single trailing integer */582583if (Version > 0)584{585ApCheckPackageElements (Predefined->Info.Name, Op,586ACPI_RTYPE_INTEGER, 1, 0, 0);587}588}589590591/*******************************************************************************592*593* FUNCTION: ApCheckPackageElements594*595* PARAMETERS: PredefinedName - Name of the predefined object596* Op - Parser op for the package597* Type1 - Object type for first group598* Count1 - Count for first group599* Type2 - Object type for second group600* Count2 - Count for second group601*602* RETURN: Next Op peer in the parse tree, after all specified elements603* have been validated. Used for multiple validations (calls604* to this function).605*606* DESCRIPTION: Validate all elements of a package. Works with packages that607* are defined to contain up to two groups of different object608* types.609*610******************************************************************************/611612static ACPI_PARSE_OBJECT *613ApCheckPackageElements (614const char *PredefinedName,615ACPI_PARSE_OBJECT *Op,616UINT8 Type1,617UINT32 Count1,618UINT8 Type2,619UINT32 Count2)620{621UINT32 i;622623624/*625* Up to two groups of package elements are supported by the data626* structure. All elements in each group must be of the same type.627* The second group can have a count of zero.628*629* Aborts check upon a NULL package element, as this means (at compile630* time) that the remainder of the package elements are also NULL631* (This is the only way to create NULL package elements.)632*/633for (i = 0; (i < Count1) && Op; i++)634{635ApCheckObjectType (PredefinedName, Op, Type1, i);636Op = Op->Asl.Next;637}638639for (i = 0; (i < Count2) && Op; i++)640{641ApCheckObjectType (PredefinedName, Op, Type2, (i + Count1));642Op = Op->Asl.Next;643}644645return (Op);646}647648649/*******************************************************************************650*651* FUNCTION: ApCheckPackageList652*653* PARAMETERS: PredefinedName - Name of the predefined object654* ParentOp - Parser op of the parent package655* Package - Package info for this predefined name656* StartIndex - Index in parent package where list begins657* ParentCount - Element count of parent package658*659* RETURN: None660*661* DESCRIPTION: Validate the individual package elements for a predefined name.662* Handles the cases where the predefined name is defined as a663* Package of Packages (subpackages). These are the types:664*665* ACPI_PTYPE2666* ACPI_PTYPE2_FIXED667* ACPI_PTYPE2_MIN668* ACPI_PTYPE2_COUNT669* ACPI_PTYPE2_FIX_VAR670* ACPI_PTYPE2_VAR_VAR671*672******************************************************************************/673674static void675ApCheckPackageList (676const char *PredefinedName,677ACPI_PARSE_OBJECT *ParentOp,678const ACPI_PREDEFINED_INFO *Package,679UINT32 StartIndex,680UINT32 ParentCount)681{682ACPI_PARSE_OBJECT *SubPackageOp = ParentOp;683ACPI_PARSE_OBJECT *Op;684ACPI_STATUS Status;685UINT32 Count;686UINT32 ExpectedCount;687UINT32 i;688UINT32 j;689690691/*692* Validate each subpackage in the parent Package693*694* Note: We ignore NULL package elements on the assumption that695* they will be initialized by the BIOS or other ASL code.696*/697for (i = 0; (i < ParentCount) && SubPackageOp; i++)698{699/* Each object in the list must be of type Package */700701Status = ApCheckObjectType (PredefinedName, SubPackageOp,702ACPI_RTYPE_PACKAGE, i + StartIndex);703if (ACPI_FAILURE (Status))704{705goto NextSubpackage;706}707708/* Examine the different types of expected subpackages */709710Op = SubPackageOp->Asl.Child;711712/* First child is the package length */713714Count = (UINT32) Op->Asl.Value.Integer;715Op = Op->Asl.Next;716717/*718* Most subpackage must have at least one element, with719* only rare exceptions. (_RDI)720*/721if (!Count &&722(Package->RetInfo.Type != ACPI_PTYPE2_VAR_VAR))723{724ApZeroLengthPackage (PredefinedName, SubPackageOp);725goto NextSubpackage;726}727728/*729* Decode the package type.730* PTYPE2 indicates that a "package of packages" is expected for731* this name. The various flavors of PTYPE2 indicate the number732* and format of the subpackages.733*/734switch (Package->RetInfo.Type)735{736case ACPI_PTYPE2:737case ACPI_PTYPE2_PKG_COUNT:738case ACPI_PTYPE2_REV_FIXED:739740/* Each subpackage has a fixed number of elements */741742ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2;743if (Count < ExpectedCount)744{745ApPackageTooSmall (PredefinedName, SubPackageOp,746Count, ExpectedCount);747break;748}749if (Count > ExpectedCount)750{751ApPackageTooLarge (PredefinedName, SubPackageOp,752Count, ExpectedCount);753break;754}755756ApCheckPackageElements (PredefinedName, Op,757Package->RetInfo.ObjectType1, Package->RetInfo.Count1,758Package->RetInfo.ObjectType2, Package->RetInfo.Count2);759break;760761case ACPI_PTYPE2_FIX_VAR:762/*763* Each subpackage has a fixed number of elements and an764* optional element765*/766ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2;767if (Count < ExpectedCount)768{769ApPackageTooSmall (PredefinedName, SubPackageOp,770Count, ExpectedCount);771break;772}773774ApCheckPackageElements (PredefinedName, Op,775Package->RetInfo.ObjectType1, Package->RetInfo.Count1,776Package->RetInfo.ObjectType2,777Count - Package->RetInfo.Count1);778break;779780case ACPI_PTYPE2_VAR_VAR:781/*782* Must have at least the minimum number elements.783* A zero PkgCount means the number of elements is variable.784*/785ExpectedCount = Package->RetInfo4.PkgCount;786if (ExpectedCount && (Count < ExpectedCount))787{788ApPackageTooSmall (PredefinedName, SubPackageOp,789Count, 1);790break;791}792793ApCheckPackageElements (PredefinedName, Op,794Package->RetInfo4.SubObjectTypes,795Package->RetInfo4.PkgCount,7960, 0);797break;798799case ACPI_PTYPE2_FIXED:800801/* Each subpackage has a fixed length */802803ExpectedCount = Package->RetInfo2.Count;804if (Count < ExpectedCount)805{806ApPackageTooSmall (PredefinedName, SubPackageOp,807Count, ExpectedCount);808break;809}810if (Count > ExpectedCount)811{812ApPackageTooLarge (PredefinedName, SubPackageOp,813Count, ExpectedCount);814break;815}816817/* Check each object/type combination */818819for (j = 0; j < ExpectedCount; j++)820{821ApCheckObjectType (PredefinedName, Op,822Package->RetInfo2.ObjectType[j], j);823824Op = Op->Asl.Next;825}826break;827828case ACPI_PTYPE2_MIN:829830/* Each subpackage has a variable but minimum length */831832ExpectedCount = Package->RetInfo.Count1;833if (Count < ExpectedCount)834{835ApPackageTooSmall (PredefinedName, SubPackageOp,836Count, ExpectedCount);837break;838}839840/* Check the type of each subpackage element */841842ApCheckPackageElements (PredefinedName, Op,843Package->RetInfo.ObjectType1, Count, 0, 0);844break;845846case ACPI_PTYPE2_COUNT:847/*848* First element is the (Integer) count of elements, including849* the count field (the ACPI name is NumElements)850*/851Status = ApCheckObjectType (PredefinedName, Op,852ACPI_RTYPE_INTEGER, 0);853854/* We must have an integer count from above (otherwise, use Count) */855856if (ACPI_SUCCESS (Status))857{858/*859* Make sure package is large enough for the Count and is860* is as large as the minimum size861*/862ExpectedCount = (UINT32) Op->Asl.Value.Integer;863864if (Count < ExpectedCount)865{866ApPackageTooSmall (PredefinedName, SubPackageOp,867Count, ExpectedCount);868break;869}870else if (Count > ExpectedCount)871{872ApPackageTooLarge (PredefinedName, SubPackageOp,873Count, ExpectedCount);874}875876/* Some names of this type have a minimum length */877878if (Count < Package->RetInfo.Count1)879{880ExpectedCount = Package->RetInfo.Count1;881ApPackageTooSmall (PredefinedName, SubPackageOp,882Count, ExpectedCount);883break;884}885886Count = ExpectedCount;887}888889/* Check the type of each subpackage element */890891Op = Op->Asl.Next;892ApCheckPackageElements (PredefinedName, Op,893Package->RetInfo.ObjectType1, (Count - 1), 0, 0);894break;895896default:897break;898}899900NextSubpackage:901SubPackageOp = SubPackageOp->Asl.Next;902}903}904905906/*******************************************************************************907*908* FUNCTION: ApPackageTooSmall909*910* PARAMETERS: PredefinedName - Name of the predefined object911* Op - Current parser op912* Count - Actual package element count913* ExpectedCount - Expected package element count914*915* RETURN: None916*917* DESCRIPTION: Issue error message for a package that is smaller than918* required.919*920******************************************************************************/921922static void923ApPackageTooSmall (924const char *PredefinedName,925ACPI_PARSE_OBJECT *Op,926UINT32 Count,927UINT32 ExpectedCount)928{929930sprintf (AslGbl_MsgBuffer, "%4.4s: length %u, required minimum is %u",931PredefinedName, Count, ExpectedCount);932933AslError (ASL_ERROR, ASL_MSG_RESERVED_PACKAGE_LENGTH, Op, AslGbl_MsgBuffer);934}935936937/*******************************************************************************938*939* FUNCTION: ApZeroLengthPackage940*941* PARAMETERS: PredefinedName - Name of the predefined object942* Op - Current parser op943*944* RETURN: None945*946* DESCRIPTION: Issue error message for a zero-length package (a package that947* is required to have a non-zero length). Variable length948* packages seem to be allowed to have zero length, however.949* Even if not allowed, BIOS code does it.950*951******************************************************************************/952953static void954ApZeroLengthPackage (955const char *PredefinedName,956ACPI_PARSE_OBJECT *Op)957{958959sprintf (AslGbl_MsgBuffer, "%4.4s: length is zero", PredefinedName);960961AslError (ASL_ERROR, ASL_MSG_RESERVED_PACKAGE_LENGTH, Op, AslGbl_MsgBuffer);962}963964965/*******************************************************************************966*967* FUNCTION: ApPackageTooLarge968*969* PARAMETERS: PredefinedName - Name of the predefined object970* Op - Current parser op971* Count - Actual package element count972* ExpectedCount - Expected package element count973*974* RETURN: None975*976* DESCRIPTION: Issue a remark for a package that is larger than expected.977*978******************************************************************************/979980static void981ApPackageTooLarge (982const char *PredefinedName,983ACPI_PARSE_OBJECT *Op,984UINT32 Count,985UINT32 ExpectedCount)986{987988sprintf (AslGbl_MsgBuffer, "%4.4s: length is %u, only %u required",989PredefinedName, Count, ExpectedCount);990991AslError (ASL_REMARK, ASL_MSG_RESERVED_PACKAGE_LENGTH, Op, AslGbl_MsgBuffer);992}993994995