1246847Sjkim/****************************************************************************** 2246847Sjkim * 3246847Sjkim * Module Name: aslprepkg - support for ACPI predefined name package objects 4246847Sjkim * 5246847Sjkim *****************************************************************************/ 6246847Sjkim 7246847Sjkim/* 8246847Sjkim * Copyright (C) 2000 - 2013, Intel Corp. 9246847Sjkim * All rights reserved. 10246847Sjkim * 11246847Sjkim * Redistribution and use in source and binary forms, with or without 12246847Sjkim * modification, are permitted provided that the following conditions 13246847Sjkim * are met: 14246847Sjkim * 1. Redistributions of source code must retain the above copyright 15246847Sjkim * notice, this list of conditions, and the following disclaimer, 16246847Sjkim * without modification. 17246847Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18246847Sjkim * substantially similar to the "NO WARRANTY" disclaimer below 19246847Sjkim * ("Disclaimer") and any redistribution must be conditioned upon 20246847Sjkim * including a substantially similar Disclaimer requirement for further 21246847Sjkim * binary redistribution. 22246847Sjkim * 3. Neither the names of the above-listed copyright holders nor the names 23246847Sjkim * of any contributors may be used to endorse or promote products derived 24246847Sjkim * from this software without specific prior written permission. 25246847Sjkim * 26246847Sjkim * Alternatively, this software may be distributed under the terms of the 27246847Sjkim * GNU General Public License ("GPL") version 2 as published by the Free 28246847Sjkim * Software Foundation. 29246847Sjkim * 30246847Sjkim * NO WARRANTY 31246847Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32246847Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33246847Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34246847Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35246847Sjkim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36246847Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37246847Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38246847Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39246847Sjkim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40246847Sjkim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41246847Sjkim * POSSIBILITY OF SUCH DAMAGES. 42246847Sjkim */ 43246847Sjkim 44246849Sjkim#include <contrib/dev/acpica/compiler/aslcompiler.h> 45246847Sjkim#include "aslcompiler.y.h" 46246849Sjkim#include <contrib/dev/acpica/include/acpredef.h> 47246847Sjkim 48246847Sjkim 49246847Sjkim#define _COMPONENT ACPI_COMPILER 50246847Sjkim ACPI_MODULE_NAME ("aslprepkg") 51246847Sjkim 52246847Sjkim 53246847Sjkim/* Local prototypes */ 54246847Sjkim 55246847Sjkimstatic void 56246847SjkimApCheckPackageElements ( 57249663Sjkim const char *PredefinedName, 58249663Sjkim ACPI_PARSE_OBJECT *Op, 59249663Sjkim UINT8 Type1, 60249663Sjkim UINT32 Count1, 61249663Sjkim UINT8 Type2, 62249663Sjkim UINT32 Count2); 63246847Sjkim 64246847Sjkimstatic void 65246847SjkimApCheckPackageList ( 66246847Sjkim const char *PredefinedName, 67246847Sjkim ACPI_PARSE_OBJECT *ParentOp, 68246847Sjkim const ACPI_PREDEFINED_INFO *Package, 69246847Sjkim UINT32 StartIndex, 70246847Sjkim UINT32 Count); 71246847Sjkim 72246847Sjkimstatic void 73246847SjkimApPackageTooSmall ( 74246847Sjkim const char *PredefinedName, 75246847Sjkim ACPI_PARSE_OBJECT *Op, 76246847Sjkim UINT32 Count, 77246847Sjkim UINT32 ExpectedCount); 78246847Sjkim 79246847Sjkimstatic void 80246847SjkimApZeroLengthPackage ( 81246847Sjkim const char *PredefinedName, 82246847Sjkim ACPI_PARSE_OBJECT *Op); 83246847Sjkim 84246847Sjkimstatic void 85246847SjkimApPackageTooLarge ( 86246847Sjkim const char *PredefinedName, 87246847Sjkim ACPI_PARSE_OBJECT *Op, 88246847Sjkim UINT32 Count, 89246847Sjkim UINT32 ExpectedCount); 90246847Sjkim 91246847Sjkim 92246847Sjkim/******************************************************************************* 93246847Sjkim * 94246847Sjkim * FUNCTION: ApCheckPackage 95246847Sjkim * 96249663Sjkim * PARAMETERS: ParentOp - Parser op for the package 97249663Sjkim * Predefined - Pointer to package-specific info for 98249663Sjkim * the method 99246847Sjkim * 100246847Sjkim * RETURN: None 101246847Sjkim * 102246847Sjkim * DESCRIPTION: Top-level validation for predefined name return package 103246847Sjkim * objects. 104246847Sjkim * 105246847Sjkim ******************************************************************************/ 106246847Sjkim 107246847Sjkimvoid 108246847SjkimApCheckPackage ( 109246847Sjkim ACPI_PARSE_OBJECT *ParentOp, 110246847Sjkim const ACPI_PREDEFINED_INFO *Predefined) 111246847Sjkim{ 112246847Sjkim ACPI_PARSE_OBJECT *Op; 113246847Sjkim const ACPI_PREDEFINED_INFO *Package; 114246847Sjkim ACPI_STATUS Status; 115246847Sjkim UINT32 ExpectedCount; 116246847Sjkim UINT32 Count; 117246847Sjkim UINT32 i; 118246847Sjkim 119246847Sjkim 120246847Sjkim /* The package info for this name is in the next table entry */ 121246847Sjkim 122246847Sjkim Package = Predefined + 1; 123246847Sjkim 124246847Sjkim /* First child is the package length */ 125246847Sjkim 126246847Sjkim Op = ParentOp->Asl.Child; 127246847Sjkim Count = (UINT32) Op->Asl.Value.Integer; 128246847Sjkim 129246847Sjkim /* 130249112Sjkim * Many of the variable-length top-level packages are allowed to simply 131249112Sjkim * have zero elements. This allows the BIOS to tell the host that even 132249112Sjkim * though the predefined name/method exists, the feature is not supported. 133249112Sjkim * Other package types require one or more elements. In any case, there 134249112Sjkim * is no need to continue validation. 135246847Sjkim */ 136246847Sjkim if (!Count) 137246847Sjkim { 138249112Sjkim switch (Package->RetInfo.Type) 139246847Sjkim { 140249112Sjkim case ACPI_PTYPE1_FIXED: 141249112Sjkim case ACPI_PTYPE1_OPTION: 142249112Sjkim case ACPI_PTYPE2_PKG_COUNT: 143249112Sjkim case ACPI_PTYPE2_REV_FIXED: 144249112Sjkim 145246847Sjkim ApZeroLengthPackage (Predefined->Info.Name, ParentOp); 146249112Sjkim break; 147249112Sjkim 148249112Sjkim case ACPI_PTYPE1_VAR: 149249112Sjkim case ACPI_PTYPE2: 150249112Sjkim case ACPI_PTYPE2_COUNT: 151249112Sjkim case ACPI_PTYPE2_FIXED: 152249112Sjkim case ACPI_PTYPE2_MIN: 153249112Sjkim case ACPI_PTYPE2_FIX_VAR: 154249112Sjkim default: 155249112Sjkim 156249112Sjkim break; 157246847Sjkim } 158249112Sjkim 159246847Sjkim return; 160246847Sjkim } 161246847Sjkim 162246847Sjkim /* Get the first element of the package */ 163246847Sjkim 164246847Sjkim Op = Op->Asl.Next; 165246847Sjkim 166246847Sjkim /* Decode the package type */ 167246847Sjkim 168246847Sjkim switch (Package->RetInfo.Type) 169246847Sjkim { 170246847Sjkim case ACPI_PTYPE1_FIXED: 171246847Sjkim /* 172246847Sjkim * The package count is fixed and there are no sub-packages 173246847Sjkim * 174246847Sjkim * If package is too small, exit. 175246847Sjkim * If package is larger than expected, issue warning but continue 176246847Sjkim */ 177246847Sjkim ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2; 178246847Sjkim if (Count < ExpectedCount) 179246847Sjkim { 180246847Sjkim goto PackageTooSmall; 181246847Sjkim } 182246847Sjkim else if (Count > ExpectedCount) 183246847Sjkim { 184246847Sjkim ApPackageTooLarge (Predefined->Info.Name, ParentOp, 185246847Sjkim Count, ExpectedCount); 186246847Sjkim } 187246847Sjkim 188246847Sjkim /* Validate all elements of the package */ 189246847Sjkim 190246847Sjkim ApCheckPackageElements (Predefined->Info.Name, Op, 191246847Sjkim Package->RetInfo.ObjectType1, Package->RetInfo.Count1, 192246847Sjkim Package->RetInfo.ObjectType2, Package->RetInfo.Count2); 193246847Sjkim break; 194246847Sjkim 195246847Sjkim case ACPI_PTYPE1_VAR: 196246847Sjkim /* 197249663Sjkim * The package count is variable, there are no sub-packages, 198249663Sjkim * and all elements must be of the same type 199246847Sjkim */ 200246847Sjkim for (i = 0; i < Count; i++) 201246847Sjkim { 202246847Sjkim ApCheckObjectType (Predefined->Info.Name, Op, 203246847Sjkim Package->RetInfo.ObjectType1, i); 204246847Sjkim Op = Op->Asl.Next; 205246847Sjkim } 206246847Sjkim break; 207246847Sjkim 208246847Sjkim case ACPI_PTYPE1_OPTION: 209246847Sjkim /* 210249663Sjkim * The package count is variable, there are no sub-packages. 211249663Sjkim * There are a fixed number of required elements, and a variable 212249663Sjkim * number of optional elements. 213246847Sjkim * 214246847Sjkim * Check if package is at least as large as the minimum required 215246847Sjkim */ 216246847Sjkim ExpectedCount = Package->RetInfo3.Count; 217246847Sjkim if (Count < ExpectedCount) 218246847Sjkim { 219246847Sjkim goto PackageTooSmall; 220246847Sjkim } 221246847Sjkim 222246847Sjkim /* Variable number of sub-objects */ 223246847Sjkim 224246847Sjkim for (i = 0; i < Count; i++) 225246847Sjkim { 226246847Sjkim if (i < Package->RetInfo3.Count) 227246847Sjkim { 228246847Sjkim /* These are the required package elements (0, 1, or 2) */ 229246847Sjkim 230246847Sjkim ApCheckObjectType (Predefined->Info.Name, Op, 231246847Sjkim Package->RetInfo3.ObjectType[i], i); 232246847Sjkim } 233246847Sjkim else 234246847Sjkim { 235246847Sjkim /* These are the optional package elements */ 236246847Sjkim 237246847Sjkim ApCheckObjectType (Predefined->Info.Name, Op, 238246847Sjkim Package->RetInfo3.TailObjectType, i); 239246847Sjkim } 240246847Sjkim Op = Op->Asl.Next; 241246847Sjkim } 242246847Sjkim break; 243246847Sjkim 244246847Sjkim case ACPI_PTYPE2_REV_FIXED: 245246847Sjkim 246246847Sjkim /* First element is the (Integer) revision */ 247246847Sjkim 248246847Sjkim ApCheckObjectType (Predefined->Info.Name, Op, 249246847Sjkim ACPI_RTYPE_INTEGER, 0); 250246847Sjkim 251246847Sjkim Op = Op->Asl.Next; 252246847Sjkim Count--; 253246847Sjkim 254246847Sjkim /* Examine the sub-packages */ 255246847Sjkim 256246847Sjkim ApCheckPackageList (Predefined->Info.Name, Op, 257246847Sjkim Package, 1, Count); 258246847Sjkim break; 259246847Sjkim 260246847Sjkim case ACPI_PTYPE2_PKG_COUNT: 261246847Sjkim 262246847Sjkim /* First element is the (Integer) count of sub-packages to follow */ 263246847Sjkim 264246847Sjkim Status = ApCheckObjectType (Predefined->Info.Name, Op, 265246847Sjkim ACPI_RTYPE_INTEGER, 0); 266246847Sjkim 267246847Sjkim /* We must have an integer count from above (otherwise, use Count) */ 268246847Sjkim 269246847Sjkim if (ACPI_SUCCESS (Status)) 270246847Sjkim { 271246847Sjkim /* 272249663Sjkim * Count cannot be larger than the parent package length, but 273249663Sjkim * allow it to be smaller. The >= accounts for the Integer above. 274246847Sjkim */ 275246847Sjkim ExpectedCount = (UINT32) Op->Asl.Value.Integer; 276246847Sjkim if (ExpectedCount >= Count) 277246847Sjkim { 278246847Sjkim goto PackageTooSmall; 279246847Sjkim } 280246847Sjkim 281246847Sjkim Count = ExpectedCount; 282246847Sjkim } 283246847Sjkim 284246847Sjkim Op = Op->Asl.Next; 285246847Sjkim 286246847Sjkim /* Examine the sub-packages */ 287246847Sjkim 288246847Sjkim ApCheckPackageList (Predefined->Info.Name, Op, 289246847Sjkim Package, 1, Count); 290246847Sjkim break; 291246847Sjkim 292246847Sjkim case ACPI_PTYPE2: 293246847Sjkim case ACPI_PTYPE2_FIXED: 294246847Sjkim case ACPI_PTYPE2_MIN: 295246847Sjkim case ACPI_PTYPE2_COUNT: 296246847Sjkim case ACPI_PTYPE2_FIX_VAR: 297246847Sjkim /* 298246847Sjkim * These types all return a single Package that consists of a 299246847Sjkim * variable number of sub-Packages. 300246847Sjkim */ 301246847Sjkim 302246847Sjkim /* Examine the sub-packages */ 303246847Sjkim 304246847Sjkim ApCheckPackageList (Predefined->Info.Name, Op, 305246847Sjkim Package, 0, Count); 306246847Sjkim break; 307246847Sjkim 308246847Sjkim default: 309246847Sjkim return; 310246847Sjkim } 311246847Sjkim 312246847Sjkim return; 313246847Sjkim 314246847SjkimPackageTooSmall: 315246847Sjkim ApPackageTooSmall (Predefined->Info.Name, ParentOp, 316246847Sjkim Count, ExpectedCount); 317246847Sjkim} 318246847Sjkim 319246847Sjkim 320246847Sjkim/******************************************************************************* 321246847Sjkim * 322246847Sjkim * FUNCTION: ApCheckPackageElements 323246847Sjkim * 324249663Sjkim * PARAMETERS: PredefinedName - Name of the predefined object 325249663Sjkim * Op - Parser op for the package 326249663Sjkim * Type1 - Object type for first group 327249663Sjkim * Count1 - Count for first group 328249663Sjkim * Type2 - Object type for second group 329249663Sjkim * Count2 - Count for second group 330246847Sjkim * 331246847Sjkim * RETURN: None 332246847Sjkim * 333246847Sjkim * DESCRIPTION: Validate all elements of a package. Works with packages that 334246847Sjkim * are defined to contain up to two groups of different object 335246847Sjkim * types. 336246847Sjkim * 337246847Sjkim ******************************************************************************/ 338246847Sjkim 339246847Sjkimstatic void 340246847SjkimApCheckPackageElements ( 341246847Sjkim const char *PredefinedName, 342246847Sjkim ACPI_PARSE_OBJECT *Op, 343246847Sjkim UINT8 Type1, 344246847Sjkim UINT32 Count1, 345246847Sjkim UINT8 Type2, 346246847Sjkim UINT32 Count2) 347246847Sjkim{ 348246847Sjkim UINT32 i; 349246847Sjkim 350246847Sjkim 351246847Sjkim /* 352246847Sjkim * Up to two groups of package elements are supported by the data 353246847Sjkim * structure. All elements in each group must be of the same type. 354246847Sjkim * The second group can have a count of zero. 355246847Sjkim * 356246847Sjkim * Aborts check upon a NULL package element, as this means (at compile 357246847Sjkim * time) that the remainder of the package elements are also NULL 358246847Sjkim * (This is the only way to create NULL package elements.) 359246847Sjkim */ 360246847Sjkim for (i = 0; (i < Count1) && Op; i++) 361246847Sjkim { 362246847Sjkim ApCheckObjectType (PredefinedName, Op, Type1, i); 363246847Sjkim Op = Op->Asl.Next; 364246847Sjkim } 365246847Sjkim 366246847Sjkim for (i = 0; (i < Count2) && Op; i++) 367246847Sjkim { 368246847Sjkim ApCheckObjectType (PredefinedName, Op, Type2, (i + Count1)); 369246847Sjkim Op = Op->Asl.Next; 370246847Sjkim } 371246847Sjkim} 372246847Sjkim 373246847Sjkim 374246847Sjkim/******************************************************************************* 375246847Sjkim * 376246847Sjkim * FUNCTION: ApCheckPackageList 377246847Sjkim * 378246847Sjkim * PARAMETERS: PredefinedName - Name of the predefined object 379246847Sjkim * ParentOp - Parser op of the parent package 380246847Sjkim * Package - Package info for this predefined name 381246847Sjkim * StartIndex - Index in parent package where list begins 382246847Sjkim * ParentCount - Element count of parent package 383246847Sjkim * 384246847Sjkim * RETURN: None 385246847Sjkim * 386246847Sjkim * DESCRIPTION: Validate the individual package elements for a predefined name. 387246847Sjkim * Handles the cases where the predefined name is defined as a 388246847Sjkim * Package of Packages (subpackages). These are the types: 389246847Sjkim * 390246847Sjkim * ACPI_PTYPE2 391246847Sjkim * ACPI_PTYPE2_FIXED 392246847Sjkim * ACPI_PTYPE2_MIN 393246847Sjkim * ACPI_PTYPE2_COUNT 394246847Sjkim * ACPI_PTYPE2_FIX_VAR 395246847Sjkim * 396246847Sjkim ******************************************************************************/ 397246847Sjkim 398246847Sjkimstatic void 399246847SjkimApCheckPackageList ( 400246847Sjkim const char *PredefinedName, 401246847Sjkim ACPI_PARSE_OBJECT *ParentOp, 402246847Sjkim const ACPI_PREDEFINED_INFO *Package, 403246847Sjkim UINT32 StartIndex, 404246847Sjkim UINT32 ParentCount) 405246847Sjkim{ 406246847Sjkim ACPI_PARSE_OBJECT *SubPackageOp = ParentOp; 407246847Sjkim ACPI_PARSE_OBJECT *Op; 408246847Sjkim ACPI_STATUS Status; 409246847Sjkim UINT32 Count; 410246847Sjkim UINT32 ExpectedCount; 411246847Sjkim UINT32 i; 412246847Sjkim UINT32 j; 413246847Sjkim 414246847Sjkim 415246847Sjkim /* 416246847Sjkim * Validate each subpackage in the parent Package 417246847Sjkim * 418246847Sjkim * Note: We ignore NULL package elements on the assumption that 419246847Sjkim * they will be initialized by the BIOS or other ASL code. 420246847Sjkim */ 421246847Sjkim for (i = 0; (i < ParentCount) && SubPackageOp; i++) 422246847Sjkim { 423246847Sjkim /* Each object in the list must be of type Package */ 424246847Sjkim 425246847Sjkim Status = ApCheckObjectType (PredefinedName, SubPackageOp, 426246847Sjkim ACPI_RTYPE_PACKAGE, i + StartIndex); 427246847Sjkim if (ACPI_FAILURE (Status)) 428246847Sjkim { 429246847Sjkim goto NextSubpackage; 430246847Sjkim } 431246847Sjkim 432246847Sjkim /* Examine the different types of expected subpackages */ 433246847Sjkim 434246847Sjkim Op = SubPackageOp->Asl.Child; 435246847Sjkim 436246847Sjkim /* First child is the package length */ 437246847Sjkim 438246847Sjkim Count = (UINT32) Op->Asl.Value.Integer; 439246847Sjkim Op = Op->Asl.Next; 440246847Sjkim 441246847Sjkim /* The subpackage must have at least one element */ 442246847Sjkim 443246847Sjkim if (!Count) 444246847Sjkim { 445246847Sjkim ApZeroLengthPackage (PredefinedName, SubPackageOp); 446246847Sjkim goto NextSubpackage; 447246847Sjkim } 448246847Sjkim 449246847Sjkim /* 450246847Sjkim * Decode the package type. 451246847Sjkim * PTYPE2 indicates that a "package of packages" is expected for 452246847Sjkim * this name. The various flavors of PTYPE2 indicate the number 453246847Sjkim * and format of the subpackages. 454246847Sjkim */ 455246847Sjkim switch (Package->RetInfo.Type) 456246847Sjkim { 457246847Sjkim case ACPI_PTYPE2: 458246847Sjkim case ACPI_PTYPE2_PKG_COUNT: 459246847Sjkim case ACPI_PTYPE2_REV_FIXED: 460246847Sjkim 461246847Sjkim /* Each subpackage has a fixed number of elements */ 462246847Sjkim 463246847Sjkim ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2; 464246847Sjkim if (Count < ExpectedCount) 465246847Sjkim { 466246847Sjkim ApPackageTooSmall (PredefinedName, SubPackageOp, 467246847Sjkim Count, ExpectedCount); 468246847Sjkim break; 469246847Sjkim } 470246847Sjkim 471246847Sjkim ApCheckPackageElements (PredefinedName, Op, 472246847Sjkim Package->RetInfo.ObjectType1, Package->RetInfo.Count1, 473246847Sjkim Package->RetInfo.ObjectType2, Package->RetInfo.Count2); 474246847Sjkim break; 475246847Sjkim 476246847Sjkim case ACPI_PTYPE2_FIX_VAR: 477246847Sjkim /* 478246847Sjkim * Each subpackage has a fixed number of elements and an 479246847Sjkim * optional element 480246847Sjkim */ 481246847Sjkim ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2; 482246847Sjkim if (Count < ExpectedCount) 483246847Sjkim { 484246847Sjkim ApPackageTooSmall (PredefinedName, SubPackageOp, 485246847Sjkim Count, ExpectedCount); 486246847Sjkim break; 487246847Sjkim } 488246847Sjkim 489246847Sjkim ApCheckPackageElements (PredefinedName, Op, 490246847Sjkim Package->RetInfo.ObjectType1, Package->RetInfo.Count1, 491246847Sjkim Package->RetInfo.ObjectType2, 492246847Sjkim Count - Package->RetInfo.Count1); 493246847Sjkim break; 494246847Sjkim 495246847Sjkim case ACPI_PTYPE2_FIXED: 496246847Sjkim 497246847Sjkim /* Each sub-package has a fixed length */ 498246847Sjkim 499246847Sjkim ExpectedCount = Package->RetInfo2.Count; 500246847Sjkim if (Count < ExpectedCount) 501246847Sjkim { 502246847Sjkim ApPackageTooSmall (PredefinedName, SubPackageOp, 503246847Sjkim Count, ExpectedCount); 504246847Sjkim break; 505246847Sjkim } 506246847Sjkim 507246847Sjkim /* Check each object/type combination */ 508246847Sjkim 509246847Sjkim for (j = 0; j < ExpectedCount; j++) 510246847Sjkim { 511246847Sjkim ApCheckObjectType (PredefinedName, Op, 512246847Sjkim Package->RetInfo2.ObjectType[j], j); 513246847Sjkim 514246847Sjkim Op = Op->Asl.Next; 515246847Sjkim } 516246847Sjkim break; 517246847Sjkim 518246847Sjkim case ACPI_PTYPE2_MIN: 519246847Sjkim 520246847Sjkim /* Each sub-package has a variable but minimum length */ 521246847Sjkim 522246847Sjkim ExpectedCount = Package->RetInfo.Count1; 523246847Sjkim if (Count < ExpectedCount) 524246847Sjkim { 525246847Sjkim ApPackageTooSmall (PredefinedName, SubPackageOp, 526246847Sjkim Count, ExpectedCount); 527246847Sjkim break; 528246847Sjkim } 529246847Sjkim 530246847Sjkim /* Check the type of each sub-package element */ 531246847Sjkim 532246847Sjkim ApCheckPackageElements (PredefinedName, Op, 533246847Sjkim Package->RetInfo.ObjectType1, Count, 0, 0); 534246847Sjkim break; 535246847Sjkim 536246847Sjkim case ACPI_PTYPE2_COUNT: 537246847Sjkim /* 538246847Sjkim * First element is the (Integer) count of elements, including 539246847Sjkim * the count field (the ACPI name is NumElements) 540246847Sjkim */ 541246847Sjkim Status = ApCheckObjectType (PredefinedName, Op, 542246847Sjkim ACPI_RTYPE_INTEGER, 0); 543246847Sjkim 544246847Sjkim /* We must have an integer count from above (otherwise, use Count) */ 545246847Sjkim 546246847Sjkim if (ACPI_SUCCESS (Status)) 547246847Sjkim { 548246847Sjkim /* 549246847Sjkim * Make sure package is large enough for the Count and is 550246847Sjkim * is as large as the minimum size 551246847Sjkim */ 552246847Sjkim ExpectedCount = (UINT32) Op->Asl.Value.Integer; 553246847Sjkim 554246847Sjkim if (Count < ExpectedCount) 555246847Sjkim { 556246847Sjkim ApPackageTooSmall (PredefinedName, SubPackageOp, 557246847Sjkim Count, ExpectedCount); 558246847Sjkim break; 559246847Sjkim } 560246847Sjkim else if (Count > ExpectedCount) 561246847Sjkim { 562246847Sjkim ApPackageTooLarge (PredefinedName, SubPackageOp, 563246847Sjkim Count, ExpectedCount); 564246847Sjkim } 565246847Sjkim 566246847Sjkim /* Some names of this type have a minimum length */ 567246847Sjkim 568246847Sjkim if (Count < Package->RetInfo.Count1) 569246847Sjkim { 570246847Sjkim ExpectedCount = Package->RetInfo.Count1; 571246847Sjkim ApPackageTooSmall (PredefinedName, SubPackageOp, 572246847Sjkim Count, ExpectedCount); 573246847Sjkim break; 574246847Sjkim } 575246847Sjkim 576246847Sjkim Count = ExpectedCount; 577246847Sjkim } 578246847Sjkim 579246847Sjkim /* Check the type of each sub-package element */ 580246847Sjkim 581246847Sjkim Op = Op->Asl.Next; 582246847Sjkim ApCheckPackageElements (PredefinedName, Op, 583246847Sjkim Package->RetInfo.ObjectType1, (Count - 1), 0, 0); 584246847Sjkim break; 585246847Sjkim 586246847Sjkim default: 587246847Sjkim break; 588246847Sjkim } 589246847Sjkim 590246847SjkimNextSubpackage: 591246847Sjkim SubPackageOp = SubPackageOp->Asl.Next; 592246847Sjkim } 593246847Sjkim} 594246847Sjkim 595246847Sjkim 596246847Sjkim/******************************************************************************* 597246847Sjkim * 598246847Sjkim * FUNCTION: ApPackageTooSmall 599246847Sjkim * 600246847Sjkim * PARAMETERS: PredefinedName - Name of the predefined object 601246847Sjkim * Op - Current parser op 602246847Sjkim * Count - Actual package element count 603246847Sjkim * ExpectedCount - Expected package element count 604246847Sjkim * 605246847Sjkim * RETURN: None 606246847Sjkim * 607246847Sjkim * DESCRIPTION: Issue error message for a package that is smaller than 608246847Sjkim * required. 609246847Sjkim * 610246847Sjkim ******************************************************************************/ 611246847Sjkim 612246847Sjkimstatic void 613246847SjkimApPackageTooSmall ( 614246847Sjkim const char *PredefinedName, 615246847Sjkim ACPI_PARSE_OBJECT *Op, 616246847Sjkim UINT32 Count, 617246847Sjkim UINT32 ExpectedCount) 618246847Sjkim{ 619246847Sjkim 620246847Sjkim sprintf (MsgBuffer, "%s: length %u, required minimum is %u", 621246847Sjkim PredefinedName, Count, ExpectedCount); 622246847Sjkim 623246847Sjkim AslError (ASL_ERROR, ASL_MSG_RESERVED_PACKAGE_LENGTH, Op, MsgBuffer); 624246847Sjkim} 625246847Sjkim 626246847Sjkim 627246847Sjkim/******************************************************************************* 628246847Sjkim * 629246847Sjkim * FUNCTION: ApZeroLengthPackage 630246847Sjkim * 631246847Sjkim * PARAMETERS: PredefinedName - Name of the predefined object 632246847Sjkim * Op - Current parser op 633246847Sjkim * 634246847Sjkim * RETURN: None 635246847Sjkim * 636246847Sjkim * DESCRIPTION: Issue error message for a zero-length package (a package that 637246847Sjkim * is required to have a non-zero length). Variable length 638246847Sjkim * packages seem to be allowed to have zero length, however. 639246847Sjkim * Even if not allowed, BIOS code does it. 640246847Sjkim * 641246847Sjkim ******************************************************************************/ 642246847Sjkim 643246847Sjkimstatic void 644246847SjkimApZeroLengthPackage ( 645246847Sjkim const char *PredefinedName, 646246847Sjkim ACPI_PARSE_OBJECT *Op) 647246847Sjkim{ 648246847Sjkim 649246847Sjkim sprintf (MsgBuffer, "%s: length is zero", PredefinedName); 650246847Sjkim 651246847Sjkim AslError (ASL_ERROR, ASL_MSG_RESERVED_PACKAGE_LENGTH, Op, MsgBuffer); 652246847Sjkim} 653246847Sjkim 654246847Sjkim 655246847Sjkim/******************************************************************************* 656246847Sjkim * 657246847Sjkim * FUNCTION: ApPackageTooLarge 658246847Sjkim * 659246847Sjkim * PARAMETERS: PredefinedName - Name of the predefined object 660246847Sjkim * Op - Current parser op 661246847Sjkim * Count - Actual package element count 662246847Sjkim * ExpectedCount - Expected package element count 663246847Sjkim * 664246847Sjkim * RETURN: None 665246847Sjkim * 666246847Sjkim * DESCRIPTION: Issue a remark for a package that is larger than expected. 667246847Sjkim * 668246847Sjkim ******************************************************************************/ 669246847Sjkim 670246847Sjkimstatic void 671246847SjkimApPackageTooLarge ( 672246847Sjkim const char *PredefinedName, 673246847Sjkim ACPI_PARSE_OBJECT *Op, 674246847Sjkim UINT32 Count, 675246847Sjkim UINT32 ExpectedCount) 676246847Sjkim{ 677246847Sjkim 678246847Sjkim sprintf (MsgBuffer, "%s: length is %u, only %u required", 679246847Sjkim PredefinedName, Count, ExpectedCount); 680246847Sjkim 681246847Sjkim AslError (ASL_REMARK, ASL_MSG_RESERVED_PACKAGE_LENGTH, Op, MsgBuffer); 682246847Sjkim} 683