19c48c75eSJung-uk Kim /****************************************************************************** 29c48c75eSJung-uk Kim * 39c48c75eSJung-uk Kim * Module Name: aslprepkg - support for ACPI predefined name package objects 49c48c75eSJung-uk Kim * 59c48c75eSJung-uk Kim *****************************************************************************/ 69c48c75eSJung-uk Kim 70d84335fSJung-uk Kim /****************************************************************************** 80d84335fSJung-uk Kim * 90d84335fSJung-uk Kim * 1. Copyright Notice 100d84335fSJung-uk Kim * 11*804fe266SJung-uk Kim * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp. 129c48c75eSJung-uk Kim * All rights reserved. 139c48c75eSJung-uk Kim * 140d84335fSJung-uk Kim * 2. License 150d84335fSJung-uk Kim * 160d84335fSJung-uk Kim * 2.1. This is your license from Intel Corp. under its intellectual property 170d84335fSJung-uk Kim * rights. You may have additional license terms from the party that provided 180d84335fSJung-uk Kim * you this software, covering your right to use that party's intellectual 190d84335fSJung-uk Kim * property rights. 200d84335fSJung-uk Kim * 210d84335fSJung-uk Kim * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 220d84335fSJung-uk Kim * copy of the source code appearing in this file ("Covered Code") an 230d84335fSJung-uk Kim * irrevocable, perpetual, worldwide license under Intel's copyrights in the 240d84335fSJung-uk Kim * base code distributed originally by Intel ("Original Intel Code") to copy, 250d84335fSJung-uk Kim * make derivatives, distribute, use and display any portion of the Covered 260d84335fSJung-uk Kim * Code in any form, with the right to sublicense such rights; and 270d84335fSJung-uk Kim * 280d84335fSJung-uk Kim * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 290d84335fSJung-uk Kim * license (with the right to sublicense), under only those claims of Intel 300d84335fSJung-uk Kim * patents that are infringed by the Original Intel Code, to make, use, sell, 310d84335fSJung-uk Kim * offer to sell, and import the Covered Code and derivative works thereof 320d84335fSJung-uk Kim * solely to the minimum extent necessary to exercise the above copyright 330d84335fSJung-uk Kim * license, and in no event shall the patent license extend to any additions 340d84335fSJung-uk Kim * to or modifications of the Original Intel Code. No other license or right 350d84335fSJung-uk Kim * is granted directly or by implication, estoppel or otherwise; 360d84335fSJung-uk Kim * 370d84335fSJung-uk Kim * The above copyright and patent license is granted only if the following 380d84335fSJung-uk Kim * conditions are met: 390d84335fSJung-uk Kim * 400d84335fSJung-uk Kim * 3. Conditions 410d84335fSJung-uk Kim * 420d84335fSJung-uk Kim * 3.1. Redistribution of Source with Rights to Further Distribute Source. 430d84335fSJung-uk Kim * Redistribution of source code of any substantial portion of the Covered 440d84335fSJung-uk Kim * Code or modification with rights to further distribute source must include 450d84335fSJung-uk Kim * the above Copyright Notice, the above License, this list of Conditions, 460d84335fSJung-uk Kim * and the following Disclaimer and Export Compliance provision. In addition, 470d84335fSJung-uk Kim * Licensee must cause all Covered Code to which Licensee contributes to 480d84335fSJung-uk Kim * contain a file documenting the changes Licensee made to create that Covered 490d84335fSJung-uk Kim * Code and the date of any change. Licensee must include in that file the 500d84335fSJung-uk Kim * documentation of any changes made by any predecessor Licensee. Licensee 510d84335fSJung-uk Kim * must include a prominent statement that the modification is derived, 520d84335fSJung-uk Kim * directly or indirectly, from Original Intel Code. 530d84335fSJung-uk Kim * 540d84335fSJung-uk Kim * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 550d84335fSJung-uk Kim * Redistribution of source code of any substantial portion of the Covered 560d84335fSJung-uk Kim * Code or modification without rights to further distribute source must 570d84335fSJung-uk Kim * include the following Disclaimer and Export Compliance provision in the 580d84335fSJung-uk Kim * documentation and/or other materials provided with distribution. In 590d84335fSJung-uk Kim * addition, Licensee may not authorize further sublicense of source of any 600d84335fSJung-uk Kim * portion of the Covered Code, and must include terms to the effect that the 610d84335fSJung-uk Kim * license from Licensee to its licensee is limited to the intellectual 620d84335fSJung-uk Kim * property embodied in the software Licensee provides to its licensee, and 630d84335fSJung-uk Kim * not to intellectual property embodied in modifications its licensee may 640d84335fSJung-uk Kim * make. 650d84335fSJung-uk Kim * 660d84335fSJung-uk Kim * 3.3. Redistribution of Executable. Redistribution in executable form of any 670d84335fSJung-uk Kim * substantial portion of the Covered Code or modification must reproduce the 680d84335fSJung-uk Kim * above Copyright Notice, and the following Disclaimer and Export Compliance 690d84335fSJung-uk Kim * provision in the documentation and/or other materials provided with the 700d84335fSJung-uk Kim * distribution. 710d84335fSJung-uk Kim * 720d84335fSJung-uk Kim * 3.4. Intel retains all right, title, and interest in and to the Original 730d84335fSJung-uk Kim * Intel Code. 740d84335fSJung-uk Kim * 750d84335fSJung-uk Kim * 3.5. Neither the name Intel nor any other trademark owned or controlled by 760d84335fSJung-uk Kim * Intel shall be used in advertising or otherwise to promote the sale, use or 770d84335fSJung-uk Kim * other dealings in products derived from or relating to the Covered Code 780d84335fSJung-uk Kim * without prior written authorization from Intel. 790d84335fSJung-uk Kim * 800d84335fSJung-uk Kim * 4. Disclaimer and Export Compliance 810d84335fSJung-uk Kim * 820d84335fSJung-uk Kim * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 830d84335fSJung-uk Kim * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 840d84335fSJung-uk Kim * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 850d84335fSJung-uk Kim * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 860d84335fSJung-uk Kim * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 870d84335fSJung-uk Kim * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 880d84335fSJung-uk Kim * PARTICULAR PURPOSE. 890d84335fSJung-uk Kim * 900d84335fSJung-uk Kim * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 910d84335fSJung-uk Kim * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 920d84335fSJung-uk Kim * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 930d84335fSJung-uk Kim * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 940d84335fSJung-uk Kim * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 950d84335fSJung-uk Kim * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 960d84335fSJung-uk Kim * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 970d84335fSJung-uk Kim * LIMITED REMEDY. 980d84335fSJung-uk Kim * 990d84335fSJung-uk Kim * 4.3. Licensee shall not export, either directly or indirectly, any of this 1000d84335fSJung-uk Kim * software or system incorporating such software without first obtaining any 1010d84335fSJung-uk Kim * required license or other approval from the U. S. Department of Commerce or 1020d84335fSJung-uk Kim * any other agency or department of the United States Government. In the 1030d84335fSJung-uk Kim * event Licensee exports any such software from the United States or 1040d84335fSJung-uk Kim * re-exports any such software from a foreign destination, Licensee shall 1050d84335fSJung-uk Kim * ensure that the distribution and export/re-export of the software is in 1060d84335fSJung-uk Kim * compliance with all laws, regulations, orders, or other restrictions of the 1070d84335fSJung-uk Kim * U.S. Export Administration Regulations. Licensee agrees that neither it nor 1080d84335fSJung-uk Kim * any of its subsidiaries will export/re-export any technical data, process, 1090d84335fSJung-uk Kim * software, or service, directly or indirectly, to any country for which the 1100d84335fSJung-uk Kim * United States government or any agency thereof requires an export license, 1110d84335fSJung-uk Kim * other governmental approval, or letter of assurance, without first obtaining 1120d84335fSJung-uk Kim * such license, approval or letter. 1130d84335fSJung-uk Kim * 1140d84335fSJung-uk Kim ***************************************************************************** 1150d84335fSJung-uk Kim * 1160d84335fSJung-uk Kim * Alternatively, you may choose to be licensed under the terms of the 1170d84335fSJung-uk Kim * following license: 1180d84335fSJung-uk Kim * 1199c48c75eSJung-uk Kim * Redistribution and use in source and binary forms, with or without 1209c48c75eSJung-uk Kim * modification, are permitted provided that the following conditions 1219c48c75eSJung-uk Kim * are met: 1229c48c75eSJung-uk Kim * 1. Redistributions of source code must retain the above copyright 1239c48c75eSJung-uk Kim * notice, this list of conditions, and the following disclaimer, 1249c48c75eSJung-uk Kim * without modification. 1259c48c75eSJung-uk Kim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 1269c48c75eSJung-uk Kim * substantially similar to the "NO WARRANTY" disclaimer below 1279c48c75eSJung-uk Kim * ("Disclaimer") and any redistribution must be conditioned upon 1289c48c75eSJung-uk Kim * including a substantially similar Disclaimer requirement for further 1299c48c75eSJung-uk Kim * binary redistribution. 1309c48c75eSJung-uk Kim * 3. Neither the names of the above-listed copyright holders nor the names 1319c48c75eSJung-uk Kim * of any contributors may be used to endorse or promote products derived 1329c48c75eSJung-uk Kim * from this software without specific prior written permission. 1339c48c75eSJung-uk Kim * 1340d84335fSJung-uk Kim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1350d84335fSJung-uk Kim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1360d84335fSJung-uk Kim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1370d84335fSJung-uk Kim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1380d84335fSJung-uk Kim * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1390d84335fSJung-uk Kim * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 1400d84335fSJung-uk Kim * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1410d84335fSJung-uk Kim * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 1420d84335fSJung-uk Kim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1430d84335fSJung-uk Kim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 1440d84335fSJung-uk Kim * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1450d84335fSJung-uk Kim * 1460d84335fSJung-uk Kim * Alternatively, you may choose to be licensed under the terms of the 1479c48c75eSJung-uk Kim * GNU General Public License ("GPL") version 2 as published by the Free 1489c48c75eSJung-uk Kim * Software Foundation. 1499c48c75eSJung-uk Kim * 1500d84335fSJung-uk Kim *****************************************************************************/ 1519c48c75eSJung-uk Kim 1529c48c75eSJung-uk Kim #include <contrib/dev/acpica/compiler/aslcompiler.h> 1539c48c75eSJung-uk Kim #include "aslcompiler.y.h" 1549c48c75eSJung-uk Kim #include <contrib/dev/acpica/include/acpredef.h> 1559c48c75eSJung-uk Kim 1569c48c75eSJung-uk Kim 1579c48c75eSJung-uk Kim #define _COMPONENT ACPI_COMPILER 1589c48c75eSJung-uk Kim ACPI_MODULE_NAME ("aslprepkg") 1599c48c75eSJung-uk Kim 1609c48c75eSJung-uk Kim 1619c48c75eSJung-uk Kim /* Local prototypes */ 1629c48c75eSJung-uk Kim 163f8146b88SJung-uk Kim static ACPI_PARSE_OBJECT * 1649c48c75eSJung-uk Kim ApCheckPackageElements ( 1659c48c75eSJung-uk Kim const char *PredefinedName, 1669c48c75eSJung-uk Kim ACPI_PARSE_OBJECT *Op, 1679c48c75eSJung-uk Kim UINT8 Type1, 1689c48c75eSJung-uk Kim UINT32 Count1, 1699c48c75eSJung-uk Kim UINT8 Type2, 1709c48c75eSJung-uk Kim UINT32 Count2); 1719c48c75eSJung-uk Kim 1729c48c75eSJung-uk Kim static void 1739c48c75eSJung-uk Kim ApCheckPackageList ( 1749c48c75eSJung-uk Kim const char *PredefinedName, 1759c48c75eSJung-uk Kim ACPI_PARSE_OBJECT *ParentOp, 1769c48c75eSJung-uk Kim const ACPI_PREDEFINED_INFO *Package, 1779c48c75eSJung-uk Kim UINT32 StartIndex, 1789c48c75eSJung-uk Kim UINT32 Count); 1799c48c75eSJung-uk Kim 1809c48c75eSJung-uk Kim static void 1819c48c75eSJung-uk Kim ApPackageTooSmall ( 1829c48c75eSJung-uk Kim const char *PredefinedName, 1839c48c75eSJung-uk Kim ACPI_PARSE_OBJECT *Op, 1849c48c75eSJung-uk Kim UINT32 Count, 1859c48c75eSJung-uk Kim UINT32 ExpectedCount); 1869c48c75eSJung-uk Kim 1879c48c75eSJung-uk Kim static void 1889c48c75eSJung-uk Kim ApZeroLengthPackage ( 1899c48c75eSJung-uk Kim const char *PredefinedName, 1909c48c75eSJung-uk Kim ACPI_PARSE_OBJECT *Op); 1919c48c75eSJung-uk Kim 1929c48c75eSJung-uk Kim static void 1939c48c75eSJung-uk Kim ApPackageTooLarge ( 1949c48c75eSJung-uk Kim const char *PredefinedName, 1959c48c75eSJung-uk Kim ACPI_PARSE_OBJECT *Op, 1969c48c75eSJung-uk Kim UINT32 Count, 1979c48c75eSJung-uk Kim UINT32 ExpectedCount); 1989c48c75eSJung-uk Kim 199f8146b88SJung-uk Kim static void 200f8146b88SJung-uk Kim ApCustomPackage ( 201f8146b88SJung-uk Kim ACPI_PARSE_OBJECT *ParentOp, 202f8146b88SJung-uk Kim const ACPI_PREDEFINED_INFO *Predefined); 203f8146b88SJung-uk Kim 2049c48c75eSJung-uk Kim 2059c48c75eSJung-uk Kim /******************************************************************************* 2069c48c75eSJung-uk Kim * 2079c48c75eSJung-uk Kim * FUNCTION: ApCheckPackage 2089c48c75eSJung-uk Kim * 2099c48c75eSJung-uk Kim * PARAMETERS: ParentOp - Parser op for the package 210895f26a9SJung-uk Kim * Predefined - Pointer to package-specific info for 211895f26a9SJung-uk Kim * the method 2129c48c75eSJung-uk Kim * 2139c48c75eSJung-uk Kim * RETURN: None 2149c48c75eSJung-uk Kim * 2159c48c75eSJung-uk Kim * DESCRIPTION: Top-level validation for predefined name return package 2169c48c75eSJung-uk Kim * objects. 2179c48c75eSJung-uk Kim * 2189c48c75eSJung-uk Kim ******************************************************************************/ 2199c48c75eSJung-uk Kim 2209c48c75eSJung-uk Kim void 2219c48c75eSJung-uk Kim ApCheckPackage ( 2229c48c75eSJung-uk Kim ACPI_PARSE_OBJECT *ParentOp, 2239c48c75eSJung-uk Kim const ACPI_PREDEFINED_INFO *Predefined) 2249c48c75eSJung-uk Kim { 2259c48c75eSJung-uk Kim ACPI_PARSE_OBJECT *Op; 2269c48c75eSJung-uk Kim const ACPI_PREDEFINED_INFO *Package; 2279c48c75eSJung-uk Kim ACPI_STATUS Status; 2289c48c75eSJung-uk Kim UINT32 ExpectedCount; 2299c48c75eSJung-uk Kim UINT32 Count; 2309c48c75eSJung-uk Kim UINT32 i; 2319c48c75eSJung-uk Kim 2329c48c75eSJung-uk Kim 2339c48c75eSJung-uk Kim /* The package info for this name is in the next table entry */ 2349c48c75eSJung-uk Kim 2359c48c75eSJung-uk Kim Package = Predefined + 1; 2369c48c75eSJung-uk Kim 2379c48c75eSJung-uk Kim /* First child is the package length */ 2389c48c75eSJung-uk Kim 2399c48c75eSJung-uk Kim Op = ParentOp->Asl.Child; 2409c48c75eSJung-uk Kim Count = (UINT32) Op->Asl.Value.Integer; 2419c48c75eSJung-uk Kim 2429c48c75eSJung-uk Kim /* 2439c7c683cSJung-uk Kim * Many of the variable-length top-level packages are allowed to simply 2449c7c683cSJung-uk Kim * have zero elements. This allows the BIOS to tell the host that even 2459c7c683cSJung-uk Kim * though the predefined name/method exists, the feature is not supported. 2469c7c683cSJung-uk Kim * Other package types require one or more elements. In any case, there 2479c7c683cSJung-uk Kim * is no need to continue validation. 2489c48c75eSJung-uk Kim */ 2499c48c75eSJung-uk Kim if (!Count) 2509c48c75eSJung-uk Kim { 2519c7c683cSJung-uk Kim switch (Package->RetInfo.Type) 2529c48c75eSJung-uk Kim { 2539c7c683cSJung-uk Kim case ACPI_PTYPE1_FIXED: 2549c7c683cSJung-uk Kim case ACPI_PTYPE1_OPTION: 2559c7c683cSJung-uk Kim case ACPI_PTYPE2_PKG_COUNT: 2569c7c683cSJung-uk Kim case ACPI_PTYPE2_REV_FIXED: 2579c7c683cSJung-uk Kim 2589c48c75eSJung-uk Kim ApZeroLengthPackage (Predefined->Info.Name, ParentOp); 2599c7c683cSJung-uk Kim break; 2609c7c683cSJung-uk Kim 2619c7c683cSJung-uk Kim case ACPI_PTYPE1_VAR: 2629c7c683cSJung-uk Kim case ACPI_PTYPE2: 2639c7c683cSJung-uk Kim case ACPI_PTYPE2_COUNT: 2649c7c683cSJung-uk Kim case ACPI_PTYPE2_FIXED: 2659c7c683cSJung-uk Kim case ACPI_PTYPE2_MIN: 2669c7c683cSJung-uk Kim case ACPI_PTYPE2_FIX_VAR: 267a371a5fdSJung-uk Kim case ACPI_PTYPE2_VAR_VAR: 2689c7c683cSJung-uk Kim default: 2699c7c683cSJung-uk Kim 2709c7c683cSJung-uk Kim break; 2719c48c75eSJung-uk Kim } 2729c7c683cSJung-uk Kim 2739c48c75eSJung-uk Kim return; 2749c48c75eSJung-uk Kim } 2759c48c75eSJung-uk Kim 2769c48c75eSJung-uk Kim /* Get the first element of the package */ 2779c48c75eSJung-uk Kim 2789c48c75eSJung-uk Kim Op = Op->Asl.Next; 2799c48c75eSJung-uk Kim 2809c48c75eSJung-uk Kim /* Decode the package type */ 2819c48c75eSJung-uk Kim 2829c48c75eSJung-uk Kim switch (Package->RetInfo.Type) 2839c48c75eSJung-uk Kim { 284f8146b88SJung-uk Kim case ACPI_PTYPE_CUSTOM: 285f8146b88SJung-uk Kim 286f8146b88SJung-uk Kim ApCustomPackage (ParentOp, Predefined); 287f8146b88SJung-uk Kim break; 288f8146b88SJung-uk Kim 2899c48c75eSJung-uk Kim case ACPI_PTYPE1_FIXED: 2909c48c75eSJung-uk Kim /* 291313a0c13SJung-uk Kim * The package count is fixed and there are no subpackages 2929c48c75eSJung-uk Kim * 2939c48c75eSJung-uk Kim * If package is too small, exit. 2949c48c75eSJung-uk Kim * If package is larger than expected, issue warning but continue 2959c48c75eSJung-uk Kim */ 2969c48c75eSJung-uk Kim ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2; 2979c48c75eSJung-uk Kim if (Count < ExpectedCount) 2989c48c75eSJung-uk Kim { 2999c48c75eSJung-uk Kim goto PackageTooSmall; 3009c48c75eSJung-uk Kim } 3019c48c75eSJung-uk Kim else if (Count > ExpectedCount) 3029c48c75eSJung-uk Kim { 3039c48c75eSJung-uk Kim ApPackageTooLarge (Predefined->Info.Name, ParentOp, 3049c48c75eSJung-uk Kim Count, ExpectedCount); 3059c48c75eSJung-uk Kim } 3069c48c75eSJung-uk Kim 3079c48c75eSJung-uk Kim /* Validate all elements of the package */ 3089c48c75eSJung-uk Kim 3099c48c75eSJung-uk Kim ApCheckPackageElements (Predefined->Info.Name, Op, 3109c48c75eSJung-uk Kim Package->RetInfo.ObjectType1, Package->RetInfo.Count1, 3119c48c75eSJung-uk Kim Package->RetInfo.ObjectType2, Package->RetInfo.Count2); 3129c48c75eSJung-uk Kim break; 3139c48c75eSJung-uk Kim 3149c48c75eSJung-uk Kim case ACPI_PTYPE1_VAR: 3159c48c75eSJung-uk Kim /* 316313a0c13SJung-uk Kim * The package count is variable, there are no subpackages, 317895f26a9SJung-uk Kim * and all elements must be of the same type 3189c48c75eSJung-uk Kim */ 3199c48c75eSJung-uk Kim for (i = 0; i < Count; i++) 3209c48c75eSJung-uk Kim { 321f15e9afbSJung-uk Kim if (!Op) 322f15e9afbSJung-uk Kim { 323f15e9afbSJung-uk Kim /* 324f15e9afbSJung-uk Kim * If we get to this point, it means that the package length 325f15e9afbSJung-uk Kim * is larger than the initializer list. Stop processing the 326f15e9afbSJung-uk Kim * package and return because we have run out of package 327f15e9afbSJung-uk Kim * elements to analyze. 328f15e9afbSJung-uk Kim */ 329f15e9afbSJung-uk Kim return; 330f15e9afbSJung-uk Kim } 331f15e9afbSJung-uk Kim 3329c48c75eSJung-uk Kim ApCheckObjectType (Predefined->Info.Name, Op, 3339c48c75eSJung-uk Kim Package->RetInfo.ObjectType1, i); 3349c48c75eSJung-uk Kim Op = Op->Asl.Next; 3359c48c75eSJung-uk Kim } 3369c48c75eSJung-uk Kim break; 3379c48c75eSJung-uk Kim 3389c48c75eSJung-uk Kim case ACPI_PTYPE1_OPTION: 3399c48c75eSJung-uk Kim /* 340313a0c13SJung-uk Kim * The package count is variable, there are no subpackages. 341895f26a9SJung-uk Kim * There are a fixed number of required elements, and a variable 342895f26a9SJung-uk Kim * number of optional elements. 3439c48c75eSJung-uk Kim * 3449c48c75eSJung-uk Kim * Check if package is at least as large as the minimum required 3459c48c75eSJung-uk Kim */ 3469c48c75eSJung-uk Kim ExpectedCount = Package->RetInfo3.Count; 3479c48c75eSJung-uk Kim if (Count < ExpectedCount) 3489c48c75eSJung-uk Kim { 3499c48c75eSJung-uk Kim goto PackageTooSmall; 3509c48c75eSJung-uk Kim } 3519c48c75eSJung-uk Kim 3529c48c75eSJung-uk Kim /* Variable number of sub-objects */ 3539c48c75eSJung-uk Kim 3549c48c75eSJung-uk Kim for (i = 0; i < Count; i++) 3559c48c75eSJung-uk Kim { 3569c48c75eSJung-uk Kim if (i < Package->RetInfo3.Count) 3579c48c75eSJung-uk Kim { 3589c48c75eSJung-uk Kim /* These are the required package elements (0, 1, or 2) */ 3599c48c75eSJung-uk Kim 3609c48c75eSJung-uk Kim ApCheckObjectType (Predefined->Info.Name, Op, 3619c48c75eSJung-uk Kim Package->RetInfo3.ObjectType[i], i); 3629c48c75eSJung-uk Kim } 3639c48c75eSJung-uk Kim else 3649c48c75eSJung-uk Kim { 3659c48c75eSJung-uk Kim /* These are the optional package elements */ 3669c48c75eSJung-uk Kim 3679c48c75eSJung-uk Kim ApCheckObjectType (Predefined->Info.Name, Op, 3689c48c75eSJung-uk Kim Package->RetInfo3.TailObjectType, i); 3699c48c75eSJung-uk Kim } 370f8146b88SJung-uk Kim 3719c48c75eSJung-uk Kim Op = Op->Asl.Next; 3729c48c75eSJung-uk Kim } 3739c48c75eSJung-uk Kim break; 3749c48c75eSJung-uk Kim 3759c48c75eSJung-uk Kim case ACPI_PTYPE2_REV_FIXED: 3769c48c75eSJung-uk Kim 3779c48c75eSJung-uk Kim /* First element is the (Integer) revision */ 3789c48c75eSJung-uk Kim 3799c48c75eSJung-uk Kim ApCheckObjectType (Predefined->Info.Name, Op, 3809c48c75eSJung-uk Kim ACPI_RTYPE_INTEGER, 0); 3819c48c75eSJung-uk Kim 3829c48c75eSJung-uk Kim Op = Op->Asl.Next; 3839c48c75eSJung-uk Kim Count--; 3849c48c75eSJung-uk Kim 385313a0c13SJung-uk Kim /* Examine the subpackages */ 3869c48c75eSJung-uk Kim 3879c48c75eSJung-uk Kim ApCheckPackageList (Predefined->Info.Name, Op, 3889c48c75eSJung-uk Kim Package, 1, Count); 3899c48c75eSJung-uk Kim break; 3909c48c75eSJung-uk Kim 3919c48c75eSJung-uk Kim case ACPI_PTYPE2_PKG_COUNT: 3929c48c75eSJung-uk Kim 393313a0c13SJung-uk Kim /* First element is the (Integer) count of subpackages to follow */ 3949c48c75eSJung-uk Kim 3959c48c75eSJung-uk Kim Status = ApCheckObjectType (Predefined->Info.Name, Op, 3969c48c75eSJung-uk Kim ACPI_RTYPE_INTEGER, 0); 3979c48c75eSJung-uk Kim 3989c48c75eSJung-uk Kim /* We must have an integer count from above (otherwise, use Count) */ 3999c48c75eSJung-uk Kim 4009c48c75eSJung-uk Kim if (ACPI_SUCCESS (Status)) 4019c48c75eSJung-uk Kim { 4029c48c75eSJung-uk Kim /* 403895f26a9SJung-uk Kim * Count cannot be larger than the parent package length, but 404895f26a9SJung-uk Kim * allow it to be smaller. The >= accounts for the Integer above. 4059c48c75eSJung-uk Kim */ 4069c48c75eSJung-uk Kim ExpectedCount = (UINT32) Op->Asl.Value.Integer; 4079c48c75eSJung-uk Kim if (ExpectedCount >= Count) 4089c48c75eSJung-uk Kim { 4099c48c75eSJung-uk Kim goto PackageTooSmall; 4109c48c75eSJung-uk Kim } 4119c48c75eSJung-uk Kim 4129c48c75eSJung-uk Kim Count = ExpectedCount; 4139c48c75eSJung-uk Kim } 4149c48c75eSJung-uk Kim 4159c48c75eSJung-uk Kim Op = Op->Asl.Next; 4169c48c75eSJung-uk Kim 417313a0c13SJung-uk Kim /* Examine the subpackages */ 4189c48c75eSJung-uk Kim 4199c48c75eSJung-uk Kim ApCheckPackageList (Predefined->Info.Name, Op, 4209c48c75eSJung-uk Kim Package, 1, Count); 4219c48c75eSJung-uk Kim break; 4229c48c75eSJung-uk Kim 423313a0c13SJung-uk Kim case ACPI_PTYPE2_UUID_PAIR: 424313a0c13SJung-uk Kim 425313a0c13SJung-uk Kim /* The package contains a variable list of UUID Buffer/Package pairs */ 426313a0c13SJung-uk Kim 427313a0c13SJung-uk Kim /* The length of the package must be even */ 428313a0c13SJung-uk Kim 429313a0c13SJung-uk Kim if (Count & 1) 430313a0c13SJung-uk Kim { 4316f1f1a63SJung-uk Kim sprintf (AslGbl_MsgBuffer, "%4.4s: Package length, %d, must be even.", 432313a0c13SJung-uk Kim Predefined->Info.Name, Count); 433313a0c13SJung-uk Kim 434313a0c13SJung-uk Kim AslError (ASL_ERROR, ASL_MSG_RESERVED_PACKAGE_LENGTH, 4356f1f1a63SJung-uk Kim ParentOp->Asl.Child, AslGbl_MsgBuffer); 436313a0c13SJung-uk Kim } 437313a0c13SJung-uk Kim 438313a0c13SJung-uk Kim /* Validate the alternating types */ 439313a0c13SJung-uk Kim 440313a0c13SJung-uk Kim for (i = 0; i < Count; ++i) 441313a0c13SJung-uk Kim { 442313a0c13SJung-uk Kim if (i & 1) 443313a0c13SJung-uk Kim { 444313a0c13SJung-uk Kim ApCheckObjectType (Predefined->Info.Name, Op, 445313a0c13SJung-uk Kim Package->RetInfo.ObjectType2, i); 446313a0c13SJung-uk Kim } 447313a0c13SJung-uk Kim else 448313a0c13SJung-uk Kim { 449313a0c13SJung-uk Kim ApCheckObjectType (Predefined->Info.Name, Op, 450313a0c13SJung-uk Kim Package->RetInfo.ObjectType1, i); 451313a0c13SJung-uk Kim } 452313a0c13SJung-uk Kim 453313a0c13SJung-uk Kim Op = Op->Asl.Next; 454313a0c13SJung-uk Kim } 455313a0c13SJung-uk Kim 456313a0c13SJung-uk Kim break; 457313a0c13SJung-uk Kim 458a371a5fdSJung-uk Kim case ACPI_PTYPE2_VAR_VAR: 459a371a5fdSJung-uk Kim 460a371a5fdSJung-uk Kim /* Check for minimum size (ints at beginning + 1 subpackage) */ 461a371a5fdSJung-uk Kim 462a371a5fdSJung-uk Kim ExpectedCount = Package->RetInfo4.Count1 + 1; 463a371a5fdSJung-uk Kim if (Count < ExpectedCount) 464a371a5fdSJung-uk Kim { 465a371a5fdSJung-uk Kim goto PackageTooSmall; 466a371a5fdSJung-uk Kim } 467a371a5fdSJung-uk Kim 468a371a5fdSJung-uk Kim /* Check the non-package elements at beginning of main package */ 469a371a5fdSJung-uk Kim 470a371a5fdSJung-uk Kim for (i = 0; i < Package->RetInfo4.Count1; ++i) 471a371a5fdSJung-uk Kim { 472a009b7dcSJung-uk Kim ApCheckObjectType (Predefined->Info.Name, Op, 473a371a5fdSJung-uk Kim Package->RetInfo4.ObjectType1, i); 474a371a5fdSJung-uk Kim Op = Op->Asl.Next; 475a371a5fdSJung-uk Kim } 476a371a5fdSJung-uk Kim 477a371a5fdSJung-uk Kim /* Examine the variable-length list of subpackages */ 478a371a5fdSJung-uk Kim 479a371a5fdSJung-uk Kim ApCheckPackageList (Predefined->Info.Name, Op, 480a371a5fdSJung-uk Kim Package, Package->RetInfo4.Count1, Count); 481a371a5fdSJung-uk Kim 482a371a5fdSJung-uk Kim break; 483a371a5fdSJung-uk Kim 4849c48c75eSJung-uk Kim case ACPI_PTYPE2: 4859c48c75eSJung-uk Kim case ACPI_PTYPE2_FIXED: 4869c48c75eSJung-uk Kim case ACPI_PTYPE2_MIN: 4879c48c75eSJung-uk Kim case ACPI_PTYPE2_COUNT: 4889c48c75eSJung-uk Kim case ACPI_PTYPE2_FIX_VAR: 4899c48c75eSJung-uk Kim /* 4909c48c75eSJung-uk Kim * These types all return a single Package that consists of a 491313a0c13SJung-uk Kim * variable number of subpackages. 4929c48c75eSJung-uk Kim */ 4939c48c75eSJung-uk Kim 494313a0c13SJung-uk Kim /* Examine the subpackages */ 4959c48c75eSJung-uk Kim 4969c48c75eSJung-uk Kim ApCheckPackageList (Predefined->Info.Name, Op, 4979c48c75eSJung-uk Kim Package, 0, Count); 4989c48c75eSJung-uk Kim break; 4999c48c75eSJung-uk Kim 5009c48c75eSJung-uk Kim default: 5019c48c75eSJung-uk Kim return; 5029c48c75eSJung-uk Kim } 5039c48c75eSJung-uk Kim 5049c48c75eSJung-uk Kim return; 5059c48c75eSJung-uk Kim 5069c48c75eSJung-uk Kim PackageTooSmall: 5079c48c75eSJung-uk Kim ApPackageTooSmall (Predefined->Info.Name, ParentOp, 5089c48c75eSJung-uk Kim Count, ExpectedCount); 5099c48c75eSJung-uk Kim } 5109c48c75eSJung-uk Kim 5119c48c75eSJung-uk Kim 5129c48c75eSJung-uk Kim /******************************************************************************* 5139c48c75eSJung-uk Kim * 514f8146b88SJung-uk Kim * FUNCTION: ApCustomPackage 515f8146b88SJung-uk Kim * 516f8146b88SJung-uk Kim * PARAMETERS: ParentOp - Parse op for the package 517f8146b88SJung-uk Kim * Predefined - Pointer to package-specific info for 518f8146b88SJung-uk Kim * the method 519f8146b88SJung-uk Kim * 520f8146b88SJung-uk Kim * RETURN: None 521f8146b88SJung-uk Kim * 522f8146b88SJung-uk Kim * DESCRIPTION: Validate packages that don't fit into the standard model and 523f8146b88SJung-uk Kim * require custom code. 524f8146b88SJung-uk Kim * 525f8146b88SJung-uk Kim * NOTE: Currently used for the _BIX method only. When needed for two or more 526f8146b88SJung-uk Kim * methods, probably a detect/dispatch mechanism will be required. 527f8146b88SJung-uk Kim * 528f8146b88SJung-uk Kim ******************************************************************************/ 529f8146b88SJung-uk Kim 530f8146b88SJung-uk Kim static void 531f8146b88SJung-uk Kim ApCustomPackage ( 532f8146b88SJung-uk Kim ACPI_PARSE_OBJECT *ParentOp, 533f8146b88SJung-uk Kim const ACPI_PREDEFINED_INFO *Predefined) 534f8146b88SJung-uk Kim { 535f8146b88SJung-uk Kim ACPI_PARSE_OBJECT *Op; 536f8146b88SJung-uk Kim UINT32 Count; 537f8146b88SJung-uk Kim UINT32 ExpectedCount; 538f8146b88SJung-uk Kim UINT32 Version; 539f8146b88SJung-uk Kim 540f8146b88SJung-uk Kim 541f8146b88SJung-uk Kim /* First child is the package length */ 542f8146b88SJung-uk Kim 543f8146b88SJung-uk Kim Op = ParentOp->Asl.Child; 544f8146b88SJung-uk Kim Count = (UINT32) Op->Asl.Value.Integer; 545f8146b88SJung-uk Kim 546f8146b88SJung-uk Kim /* Get the version number, must be Integer */ 547f8146b88SJung-uk Kim 548f8146b88SJung-uk Kim Op = Op->Asl.Next; 549f8146b88SJung-uk Kim Version = (UINT32) Op->Asl.Value.Integer; 550f8146b88SJung-uk Kim if (Op->Asl.ParseOpcode != PARSEOP_INTEGER) 551f8146b88SJung-uk Kim { 5526f1f1a63SJung-uk Kim AslError (ASL_ERROR, ASL_MSG_RESERVED_OPERAND_TYPE, Op, AslGbl_MsgBuffer); 553f8146b88SJung-uk Kim return; 554f8146b88SJung-uk Kim } 555f8146b88SJung-uk Kim 556f8146b88SJung-uk Kim /* Validate count (# of elements) */ 557f8146b88SJung-uk Kim 558f8146b88SJung-uk Kim ExpectedCount = 21; /* Version 1 */ 559f8146b88SJung-uk Kim if (Version == 0) 560f8146b88SJung-uk Kim { 561f8146b88SJung-uk Kim ExpectedCount = 20; /* Version 0 */ 562f8146b88SJung-uk Kim } 563f8146b88SJung-uk Kim 564f8146b88SJung-uk Kim if (Count < ExpectedCount) 565f8146b88SJung-uk Kim { 566f8146b88SJung-uk Kim ApPackageTooSmall (Predefined->Info.Name, ParentOp, 567f8146b88SJung-uk Kim Count, ExpectedCount); 568f8146b88SJung-uk Kim return; 569f8146b88SJung-uk Kim } 570f8146b88SJung-uk Kim else if (Count > ExpectedCount) 571f8146b88SJung-uk Kim { 572f8146b88SJung-uk Kim ApPackageTooLarge (Predefined->Info.Name, ParentOp, 573f8146b88SJung-uk Kim Count, ExpectedCount); 574f8146b88SJung-uk Kim } 575f8146b88SJung-uk Kim 576f8146b88SJung-uk Kim /* Validate all elements of the package */ 577f8146b88SJung-uk Kim 578f8146b88SJung-uk Kim Op = ApCheckPackageElements (Predefined->Info.Name, Op, 579f8146b88SJung-uk Kim ACPI_RTYPE_INTEGER, 16, 580f8146b88SJung-uk Kim ACPI_RTYPE_STRING, 4); 581f8146b88SJung-uk Kim 582f8146b88SJung-uk Kim /* Version 1 has a single trailing integer */ 583f8146b88SJung-uk Kim 584f8146b88SJung-uk Kim if (Version > 0) 585f8146b88SJung-uk Kim { 586f8146b88SJung-uk Kim ApCheckPackageElements (Predefined->Info.Name, Op, 587f8146b88SJung-uk Kim ACPI_RTYPE_INTEGER, 1, 0, 0); 588f8146b88SJung-uk Kim } 589f8146b88SJung-uk Kim } 590f8146b88SJung-uk Kim 591f8146b88SJung-uk Kim 592f8146b88SJung-uk Kim /******************************************************************************* 593f8146b88SJung-uk Kim * 5949c48c75eSJung-uk Kim * FUNCTION: ApCheckPackageElements 5959c48c75eSJung-uk Kim * 596895f26a9SJung-uk Kim * PARAMETERS: PredefinedName - Name of the predefined object 5979c48c75eSJung-uk Kim * Op - Parser op for the package 5989c48c75eSJung-uk Kim * Type1 - Object type for first group 5999c48c75eSJung-uk Kim * Count1 - Count for first group 6009c48c75eSJung-uk Kim * Type2 - Object type for second group 6019c48c75eSJung-uk Kim * Count2 - Count for second group 6029c48c75eSJung-uk Kim * 603f8146b88SJung-uk Kim * RETURN: Next Op peer in the parse tree, after all specified elements 604f8146b88SJung-uk Kim * have been validated. Used for multiple validations (calls 605f8146b88SJung-uk Kim * to this function). 6069c48c75eSJung-uk Kim * 6079c48c75eSJung-uk Kim * DESCRIPTION: Validate all elements of a package. Works with packages that 6089c48c75eSJung-uk Kim * are defined to contain up to two groups of different object 6099c48c75eSJung-uk Kim * types. 6109c48c75eSJung-uk Kim * 6119c48c75eSJung-uk Kim ******************************************************************************/ 6129c48c75eSJung-uk Kim 613f8146b88SJung-uk Kim static ACPI_PARSE_OBJECT * 6149c48c75eSJung-uk Kim ApCheckPackageElements ( 6159c48c75eSJung-uk Kim const char *PredefinedName, 6169c48c75eSJung-uk Kim ACPI_PARSE_OBJECT *Op, 6179c48c75eSJung-uk Kim UINT8 Type1, 6189c48c75eSJung-uk Kim UINT32 Count1, 6199c48c75eSJung-uk Kim UINT8 Type2, 6209c48c75eSJung-uk Kim UINT32 Count2) 6219c48c75eSJung-uk Kim { 6229c48c75eSJung-uk Kim UINT32 i; 6239c48c75eSJung-uk Kim 6249c48c75eSJung-uk Kim 6259c48c75eSJung-uk Kim /* 6269c48c75eSJung-uk Kim * Up to two groups of package elements are supported by the data 6279c48c75eSJung-uk Kim * structure. All elements in each group must be of the same type. 6289c48c75eSJung-uk Kim * The second group can have a count of zero. 6299c48c75eSJung-uk Kim * 6309c48c75eSJung-uk Kim * Aborts check upon a NULL package element, as this means (at compile 6319c48c75eSJung-uk Kim * time) that the remainder of the package elements are also NULL 6329c48c75eSJung-uk Kim * (This is the only way to create NULL package elements.) 6339c48c75eSJung-uk Kim */ 6349c48c75eSJung-uk Kim for (i = 0; (i < Count1) && Op; i++) 6359c48c75eSJung-uk Kim { 6369c48c75eSJung-uk Kim ApCheckObjectType (PredefinedName, Op, Type1, i); 6379c48c75eSJung-uk Kim Op = Op->Asl.Next; 6389c48c75eSJung-uk Kim } 6399c48c75eSJung-uk Kim 6409c48c75eSJung-uk Kim for (i = 0; (i < Count2) && Op; i++) 6419c48c75eSJung-uk Kim { 6429c48c75eSJung-uk Kim ApCheckObjectType (PredefinedName, Op, Type2, (i + Count1)); 6439c48c75eSJung-uk Kim Op = Op->Asl.Next; 6449c48c75eSJung-uk Kim } 645f8146b88SJung-uk Kim 646f8146b88SJung-uk Kim return (Op); 6479c48c75eSJung-uk Kim } 6489c48c75eSJung-uk Kim 6499c48c75eSJung-uk Kim 6509c48c75eSJung-uk Kim /******************************************************************************* 6519c48c75eSJung-uk Kim * 6529c48c75eSJung-uk Kim * FUNCTION: ApCheckPackageList 6539c48c75eSJung-uk Kim * 6549c48c75eSJung-uk Kim * PARAMETERS: PredefinedName - Name of the predefined object 6559c48c75eSJung-uk Kim * ParentOp - Parser op of the parent package 6569c48c75eSJung-uk Kim * Package - Package info for this predefined name 6579c48c75eSJung-uk Kim * StartIndex - Index in parent package where list begins 6589c48c75eSJung-uk Kim * ParentCount - Element count of parent package 6599c48c75eSJung-uk Kim * 6609c48c75eSJung-uk Kim * RETURN: None 6619c48c75eSJung-uk Kim * 6629c48c75eSJung-uk Kim * DESCRIPTION: Validate the individual package elements for a predefined name. 6639c48c75eSJung-uk Kim * Handles the cases where the predefined name is defined as a 6649c48c75eSJung-uk Kim * Package of Packages (subpackages). These are the types: 6659c48c75eSJung-uk Kim * 6669c48c75eSJung-uk Kim * ACPI_PTYPE2 6679c48c75eSJung-uk Kim * ACPI_PTYPE2_FIXED 6689c48c75eSJung-uk Kim * ACPI_PTYPE2_MIN 6699c48c75eSJung-uk Kim * ACPI_PTYPE2_COUNT 6709c48c75eSJung-uk Kim * ACPI_PTYPE2_FIX_VAR 671a371a5fdSJung-uk Kim * ACPI_PTYPE2_VAR_VAR 6729c48c75eSJung-uk Kim * 6739c48c75eSJung-uk Kim ******************************************************************************/ 6749c48c75eSJung-uk Kim 6759c48c75eSJung-uk Kim static void 6769c48c75eSJung-uk Kim ApCheckPackageList ( 6779c48c75eSJung-uk Kim const char *PredefinedName, 6789c48c75eSJung-uk Kim ACPI_PARSE_OBJECT *ParentOp, 6799c48c75eSJung-uk Kim const ACPI_PREDEFINED_INFO *Package, 6809c48c75eSJung-uk Kim UINT32 StartIndex, 6819c48c75eSJung-uk Kim UINT32 ParentCount) 6829c48c75eSJung-uk Kim { 6839c48c75eSJung-uk Kim ACPI_PARSE_OBJECT *SubPackageOp = ParentOp; 6849c48c75eSJung-uk Kim ACPI_PARSE_OBJECT *Op; 6859c48c75eSJung-uk Kim ACPI_STATUS Status; 6869c48c75eSJung-uk Kim UINT32 Count; 6879c48c75eSJung-uk Kim UINT32 ExpectedCount; 6889c48c75eSJung-uk Kim UINT32 i; 6899c48c75eSJung-uk Kim UINT32 j; 6909c48c75eSJung-uk Kim 6919c48c75eSJung-uk Kim 6929c48c75eSJung-uk Kim /* 6939c48c75eSJung-uk Kim * Validate each subpackage in the parent Package 6949c48c75eSJung-uk Kim * 6959c48c75eSJung-uk Kim * Note: We ignore NULL package elements on the assumption that 6969c48c75eSJung-uk Kim * they will be initialized by the BIOS or other ASL code. 6979c48c75eSJung-uk Kim */ 6989c48c75eSJung-uk Kim for (i = 0; (i < ParentCount) && SubPackageOp; i++) 6999c48c75eSJung-uk Kim { 7009c48c75eSJung-uk Kim /* Each object in the list must be of type Package */ 7019c48c75eSJung-uk Kim 7029c48c75eSJung-uk Kim Status = ApCheckObjectType (PredefinedName, SubPackageOp, 7039c48c75eSJung-uk Kim ACPI_RTYPE_PACKAGE, i + StartIndex); 7049c48c75eSJung-uk Kim if (ACPI_FAILURE (Status)) 7059c48c75eSJung-uk Kim { 7069c48c75eSJung-uk Kim goto NextSubpackage; 7079c48c75eSJung-uk Kim } 7089c48c75eSJung-uk Kim 7099c48c75eSJung-uk Kim /* Examine the different types of expected subpackages */ 7109c48c75eSJung-uk Kim 7119c48c75eSJung-uk Kim Op = SubPackageOp->Asl.Child; 7129c48c75eSJung-uk Kim 7139c48c75eSJung-uk Kim /* First child is the package length */ 7149c48c75eSJung-uk Kim 7159c48c75eSJung-uk Kim Count = (UINT32) Op->Asl.Value.Integer; 7169c48c75eSJung-uk Kim Op = Op->Asl.Next; 7179c48c75eSJung-uk Kim 718a371a5fdSJung-uk Kim /* 719a371a5fdSJung-uk Kim * Most subpackage must have at least one element, with 720a371a5fdSJung-uk Kim * only rare exceptions. (_RDI) 721a371a5fdSJung-uk Kim */ 722a371a5fdSJung-uk Kim if (!Count && 723a371a5fdSJung-uk Kim (Package->RetInfo.Type != ACPI_PTYPE2_VAR_VAR)) 7249c48c75eSJung-uk Kim { 7259c48c75eSJung-uk Kim ApZeroLengthPackage (PredefinedName, SubPackageOp); 7269c48c75eSJung-uk Kim goto NextSubpackage; 7279c48c75eSJung-uk Kim } 7289c48c75eSJung-uk Kim 7299c48c75eSJung-uk Kim /* 7309c48c75eSJung-uk Kim * Decode the package type. 7319c48c75eSJung-uk Kim * PTYPE2 indicates that a "package of packages" is expected for 7329c48c75eSJung-uk Kim * this name. The various flavors of PTYPE2 indicate the number 7339c48c75eSJung-uk Kim * and format of the subpackages. 7349c48c75eSJung-uk Kim */ 7359c48c75eSJung-uk Kim switch (Package->RetInfo.Type) 7369c48c75eSJung-uk Kim { 7379c48c75eSJung-uk Kim case ACPI_PTYPE2: 7389c48c75eSJung-uk Kim case ACPI_PTYPE2_PKG_COUNT: 7399c48c75eSJung-uk Kim case ACPI_PTYPE2_REV_FIXED: 7409c48c75eSJung-uk Kim 7419c48c75eSJung-uk Kim /* Each subpackage has a fixed number of elements */ 7429c48c75eSJung-uk Kim 7439c48c75eSJung-uk Kim ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2; 7449c48c75eSJung-uk Kim if (Count < ExpectedCount) 7459c48c75eSJung-uk Kim { 7469c48c75eSJung-uk Kim ApPackageTooSmall (PredefinedName, SubPackageOp, 7479c48c75eSJung-uk Kim Count, ExpectedCount); 7489c48c75eSJung-uk Kim break; 7499c48c75eSJung-uk Kim } 750313a0c13SJung-uk Kim if (Count > ExpectedCount) 751313a0c13SJung-uk Kim { 752313a0c13SJung-uk Kim ApPackageTooLarge (PredefinedName, SubPackageOp, 753313a0c13SJung-uk Kim Count, ExpectedCount); 754313a0c13SJung-uk Kim break; 755313a0c13SJung-uk Kim } 7569c48c75eSJung-uk Kim 7579c48c75eSJung-uk Kim ApCheckPackageElements (PredefinedName, Op, 7589c48c75eSJung-uk Kim Package->RetInfo.ObjectType1, Package->RetInfo.Count1, 7599c48c75eSJung-uk Kim Package->RetInfo.ObjectType2, Package->RetInfo.Count2); 7609c48c75eSJung-uk Kim break; 7619c48c75eSJung-uk Kim 7629c48c75eSJung-uk Kim case ACPI_PTYPE2_FIX_VAR: 7639c48c75eSJung-uk Kim /* 7649c48c75eSJung-uk Kim * Each subpackage has a fixed number of elements and an 7659c48c75eSJung-uk Kim * optional element 7669c48c75eSJung-uk Kim */ 7679c48c75eSJung-uk Kim ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2; 7689c48c75eSJung-uk Kim if (Count < ExpectedCount) 7699c48c75eSJung-uk Kim { 7709c48c75eSJung-uk Kim ApPackageTooSmall (PredefinedName, SubPackageOp, 7719c48c75eSJung-uk Kim Count, ExpectedCount); 7729c48c75eSJung-uk Kim break; 7739c48c75eSJung-uk Kim } 7749c48c75eSJung-uk Kim 7759c48c75eSJung-uk Kim ApCheckPackageElements (PredefinedName, Op, 7769c48c75eSJung-uk Kim Package->RetInfo.ObjectType1, Package->RetInfo.Count1, 7779c48c75eSJung-uk Kim Package->RetInfo.ObjectType2, 7789c48c75eSJung-uk Kim Count - Package->RetInfo.Count1); 7799c48c75eSJung-uk Kim break; 7809c48c75eSJung-uk Kim 781a371a5fdSJung-uk Kim case ACPI_PTYPE2_VAR_VAR: 782a371a5fdSJung-uk Kim /* 783a371a5fdSJung-uk Kim * Must have at least the minimum number elements. 784a371a5fdSJung-uk Kim * A zero PkgCount means the number of elements is variable. 785a371a5fdSJung-uk Kim */ 786a371a5fdSJung-uk Kim ExpectedCount = Package->RetInfo4.PkgCount; 787a371a5fdSJung-uk Kim if (ExpectedCount && (Count < ExpectedCount)) 788a371a5fdSJung-uk Kim { 789a371a5fdSJung-uk Kim ApPackageTooSmall (PredefinedName, SubPackageOp, 790a371a5fdSJung-uk Kim Count, 1); 791a371a5fdSJung-uk Kim break; 792a371a5fdSJung-uk Kim } 793a371a5fdSJung-uk Kim 794a371a5fdSJung-uk Kim ApCheckPackageElements (PredefinedName, Op, 795a371a5fdSJung-uk Kim Package->RetInfo4.SubObjectTypes, 796a371a5fdSJung-uk Kim Package->RetInfo4.PkgCount, 797a371a5fdSJung-uk Kim 0, 0); 798a371a5fdSJung-uk Kim break; 799a371a5fdSJung-uk Kim 8009c48c75eSJung-uk Kim case ACPI_PTYPE2_FIXED: 8019c48c75eSJung-uk Kim 802313a0c13SJung-uk Kim /* Each subpackage has a fixed length */ 8039c48c75eSJung-uk Kim 8049c48c75eSJung-uk Kim ExpectedCount = Package->RetInfo2.Count; 8059c48c75eSJung-uk Kim if (Count < ExpectedCount) 8069c48c75eSJung-uk Kim { 8079c48c75eSJung-uk Kim ApPackageTooSmall (PredefinedName, SubPackageOp, 8089c48c75eSJung-uk Kim Count, ExpectedCount); 8099c48c75eSJung-uk Kim break; 8109c48c75eSJung-uk Kim } 811313a0c13SJung-uk Kim if (Count > ExpectedCount) 812313a0c13SJung-uk Kim { 813313a0c13SJung-uk Kim ApPackageTooLarge (PredefinedName, SubPackageOp, 814313a0c13SJung-uk Kim Count, ExpectedCount); 815313a0c13SJung-uk Kim break; 816313a0c13SJung-uk Kim } 8179c48c75eSJung-uk Kim 8189c48c75eSJung-uk Kim /* Check each object/type combination */ 8199c48c75eSJung-uk Kim 8209c48c75eSJung-uk Kim for (j = 0; j < ExpectedCount; j++) 8219c48c75eSJung-uk Kim { 8229c48c75eSJung-uk Kim ApCheckObjectType (PredefinedName, Op, 8239c48c75eSJung-uk Kim Package->RetInfo2.ObjectType[j], j); 8249c48c75eSJung-uk Kim 8259c48c75eSJung-uk Kim Op = Op->Asl.Next; 8269c48c75eSJung-uk Kim } 8279c48c75eSJung-uk Kim break; 8289c48c75eSJung-uk Kim 8299c48c75eSJung-uk Kim case ACPI_PTYPE2_MIN: 8309c48c75eSJung-uk Kim 831313a0c13SJung-uk Kim /* Each subpackage has a variable but minimum length */ 8329c48c75eSJung-uk Kim 8339c48c75eSJung-uk Kim ExpectedCount = Package->RetInfo.Count1; 8349c48c75eSJung-uk Kim if (Count < ExpectedCount) 8359c48c75eSJung-uk Kim { 8369c48c75eSJung-uk Kim ApPackageTooSmall (PredefinedName, SubPackageOp, 8379c48c75eSJung-uk Kim Count, ExpectedCount); 8389c48c75eSJung-uk Kim break; 8399c48c75eSJung-uk Kim } 8409c48c75eSJung-uk Kim 841313a0c13SJung-uk Kim /* Check the type of each subpackage element */ 8429c48c75eSJung-uk Kim 8439c48c75eSJung-uk Kim ApCheckPackageElements (PredefinedName, Op, 8449c48c75eSJung-uk Kim Package->RetInfo.ObjectType1, Count, 0, 0); 8459c48c75eSJung-uk Kim break; 8469c48c75eSJung-uk Kim 8479c48c75eSJung-uk Kim case ACPI_PTYPE2_COUNT: 8489c48c75eSJung-uk Kim /* 8499c48c75eSJung-uk Kim * First element is the (Integer) count of elements, including 8509c48c75eSJung-uk Kim * the count field (the ACPI name is NumElements) 8519c48c75eSJung-uk Kim */ 8529c48c75eSJung-uk Kim Status = ApCheckObjectType (PredefinedName, Op, 8539c48c75eSJung-uk Kim ACPI_RTYPE_INTEGER, 0); 8549c48c75eSJung-uk Kim 8559c48c75eSJung-uk Kim /* We must have an integer count from above (otherwise, use Count) */ 8569c48c75eSJung-uk Kim 8579c48c75eSJung-uk Kim if (ACPI_SUCCESS (Status)) 8589c48c75eSJung-uk Kim { 8599c48c75eSJung-uk Kim /* 8609c48c75eSJung-uk Kim * Make sure package is large enough for the Count and is 8619c48c75eSJung-uk Kim * is as large as the minimum size 8629c48c75eSJung-uk Kim */ 8639c48c75eSJung-uk Kim ExpectedCount = (UINT32) Op->Asl.Value.Integer; 8649c48c75eSJung-uk Kim 8659c48c75eSJung-uk Kim if (Count < ExpectedCount) 8669c48c75eSJung-uk Kim { 8679c48c75eSJung-uk Kim ApPackageTooSmall (PredefinedName, SubPackageOp, 8689c48c75eSJung-uk Kim Count, ExpectedCount); 8699c48c75eSJung-uk Kim break; 8709c48c75eSJung-uk Kim } 8719c48c75eSJung-uk Kim else if (Count > ExpectedCount) 8729c48c75eSJung-uk Kim { 8739c48c75eSJung-uk Kim ApPackageTooLarge (PredefinedName, SubPackageOp, 8749c48c75eSJung-uk Kim Count, ExpectedCount); 8759c48c75eSJung-uk Kim } 8769c48c75eSJung-uk Kim 8779c48c75eSJung-uk Kim /* Some names of this type have a minimum length */ 8789c48c75eSJung-uk Kim 8799c48c75eSJung-uk Kim if (Count < Package->RetInfo.Count1) 8809c48c75eSJung-uk Kim { 8819c48c75eSJung-uk Kim ExpectedCount = Package->RetInfo.Count1; 8829c48c75eSJung-uk Kim ApPackageTooSmall (PredefinedName, SubPackageOp, 8839c48c75eSJung-uk Kim Count, ExpectedCount); 8849c48c75eSJung-uk Kim break; 8859c48c75eSJung-uk Kim } 8869c48c75eSJung-uk Kim 8879c48c75eSJung-uk Kim Count = ExpectedCount; 8889c48c75eSJung-uk Kim } 8899c48c75eSJung-uk Kim 890313a0c13SJung-uk Kim /* Check the type of each subpackage element */ 8919c48c75eSJung-uk Kim 8929c48c75eSJung-uk Kim Op = Op->Asl.Next; 8939c48c75eSJung-uk Kim ApCheckPackageElements (PredefinedName, Op, 8949c48c75eSJung-uk Kim Package->RetInfo.ObjectType1, (Count - 1), 0, 0); 8959c48c75eSJung-uk Kim break; 8969c48c75eSJung-uk Kim 8979c48c75eSJung-uk Kim default: 8989c48c75eSJung-uk Kim break; 8999c48c75eSJung-uk Kim } 9009c48c75eSJung-uk Kim 9019c48c75eSJung-uk Kim NextSubpackage: 9029c48c75eSJung-uk Kim SubPackageOp = SubPackageOp->Asl.Next; 9039c48c75eSJung-uk Kim } 9049c48c75eSJung-uk Kim } 9059c48c75eSJung-uk Kim 9069c48c75eSJung-uk Kim 9079c48c75eSJung-uk Kim /******************************************************************************* 9089c48c75eSJung-uk Kim * 9099c48c75eSJung-uk Kim * FUNCTION: ApPackageTooSmall 9109c48c75eSJung-uk Kim * 9119c48c75eSJung-uk Kim * PARAMETERS: PredefinedName - Name of the predefined object 9129c48c75eSJung-uk Kim * Op - Current parser op 9139c48c75eSJung-uk Kim * Count - Actual package element count 9149c48c75eSJung-uk Kim * ExpectedCount - Expected package element count 9159c48c75eSJung-uk Kim * 9169c48c75eSJung-uk Kim * RETURN: None 9179c48c75eSJung-uk Kim * 9189c48c75eSJung-uk Kim * DESCRIPTION: Issue error message for a package that is smaller than 9199c48c75eSJung-uk Kim * required. 9209c48c75eSJung-uk Kim * 9219c48c75eSJung-uk Kim ******************************************************************************/ 9229c48c75eSJung-uk Kim 9239c48c75eSJung-uk Kim static void 9249c48c75eSJung-uk Kim ApPackageTooSmall ( 9259c48c75eSJung-uk Kim const char *PredefinedName, 9269c48c75eSJung-uk Kim ACPI_PARSE_OBJECT *Op, 9279c48c75eSJung-uk Kim UINT32 Count, 9289c48c75eSJung-uk Kim UINT32 ExpectedCount) 9299c48c75eSJung-uk Kim { 9309c48c75eSJung-uk Kim 931f15e9afbSJung-uk Kim sprintf (AslGbl_MsgBuffer, "%4.4s: length %u, required minimum is %u", 9329c48c75eSJung-uk Kim PredefinedName, Count, ExpectedCount); 9339c48c75eSJung-uk Kim 9346f1f1a63SJung-uk Kim AslError (ASL_ERROR, ASL_MSG_RESERVED_PACKAGE_LENGTH, Op, AslGbl_MsgBuffer); 9359c48c75eSJung-uk Kim } 9369c48c75eSJung-uk Kim 9379c48c75eSJung-uk Kim 9389c48c75eSJung-uk Kim /******************************************************************************* 9399c48c75eSJung-uk Kim * 9409c48c75eSJung-uk Kim * FUNCTION: ApZeroLengthPackage 9419c48c75eSJung-uk Kim * 9429c48c75eSJung-uk Kim * PARAMETERS: PredefinedName - Name of the predefined object 9439c48c75eSJung-uk Kim * Op - Current parser op 9449c48c75eSJung-uk Kim * 9459c48c75eSJung-uk Kim * RETURN: None 9469c48c75eSJung-uk Kim * 9479c48c75eSJung-uk Kim * DESCRIPTION: Issue error message for a zero-length package (a package that 9489c48c75eSJung-uk Kim * is required to have a non-zero length). Variable length 9499c48c75eSJung-uk Kim * packages seem to be allowed to have zero length, however. 9509c48c75eSJung-uk Kim * Even if not allowed, BIOS code does it. 9519c48c75eSJung-uk Kim * 9529c48c75eSJung-uk Kim ******************************************************************************/ 9539c48c75eSJung-uk Kim 9549c48c75eSJung-uk Kim static void 9559c48c75eSJung-uk Kim ApZeroLengthPackage ( 9569c48c75eSJung-uk Kim const char *PredefinedName, 9579c48c75eSJung-uk Kim ACPI_PARSE_OBJECT *Op) 9589c48c75eSJung-uk Kim { 9599c48c75eSJung-uk Kim 960f15e9afbSJung-uk Kim sprintf (AslGbl_MsgBuffer, "%4.4s: length is zero", PredefinedName); 9619c48c75eSJung-uk Kim 9626f1f1a63SJung-uk Kim AslError (ASL_ERROR, ASL_MSG_RESERVED_PACKAGE_LENGTH, Op, AslGbl_MsgBuffer); 9639c48c75eSJung-uk Kim } 9649c48c75eSJung-uk Kim 9659c48c75eSJung-uk Kim 9669c48c75eSJung-uk Kim /******************************************************************************* 9679c48c75eSJung-uk Kim * 9689c48c75eSJung-uk Kim * FUNCTION: ApPackageTooLarge 9699c48c75eSJung-uk Kim * 9709c48c75eSJung-uk Kim * PARAMETERS: PredefinedName - Name of the predefined object 9719c48c75eSJung-uk Kim * Op - Current parser op 9729c48c75eSJung-uk Kim * Count - Actual package element count 9739c48c75eSJung-uk Kim * ExpectedCount - Expected package element count 9749c48c75eSJung-uk Kim * 9759c48c75eSJung-uk Kim * RETURN: None 9769c48c75eSJung-uk Kim * 9779c48c75eSJung-uk Kim * DESCRIPTION: Issue a remark for a package that is larger than expected. 9789c48c75eSJung-uk Kim * 9799c48c75eSJung-uk Kim ******************************************************************************/ 9809c48c75eSJung-uk Kim 9819c48c75eSJung-uk Kim static void 9829c48c75eSJung-uk Kim ApPackageTooLarge ( 9839c48c75eSJung-uk Kim const char *PredefinedName, 9849c48c75eSJung-uk Kim ACPI_PARSE_OBJECT *Op, 9859c48c75eSJung-uk Kim UINT32 Count, 9869c48c75eSJung-uk Kim UINT32 ExpectedCount) 9879c48c75eSJung-uk Kim { 9889c48c75eSJung-uk Kim 989f15e9afbSJung-uk Kim sprintf (AslGbl_MsgBuffer, "%4.4s: length is %u, only %u required", 9909c48c75eSJung-uk Kim PredefinedName, Count, ExpectedCount); 9919c48c75eSJung-uk Kim 9926f1f1a63SJung-uk Kim AslError (ASL_REMARK, ASL_MSG_RESERVED_PACKAGE_LENGTH, Op, AslGbl_MsgBuffer); 9939c48c75eSJung-uk Kim } 994