Home | History | Annotate | Line # | Download | only in compiler
aslprepkg.c revision 1.18
      1   1.1  christos /******************************************************************************
      2   1.1  christos  *
      3   1.1  christos  * Module Name: aslprepkg - support for ACPI predefined name package objects
      4   1.1  christos  *
      5   1.1  christos  *****************************************************************************/
      6   1.1  christos 
      7  1.18  christos /******************************************************************************
      8  1.18  christos  *
      9  1.18  christos  * 1. Copyright Notice
     10  1.18  christos  *
     11  1.18  christos  * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp.
     12   1.1  christos  * All rights reserved.
     13   1.1  christos  *
     14  1.18  christos  * 2. License
     15  1.18  christos  *
     16  1.18  christos  * 2.1. This is your license from Intel Corp. under its intellectual property
     17  1.18  christos  * rights. You may have additional license terms from the party that provided
     18  1.18  christos  * you this software, covering your right to use that party's intellectual
     19  1.18  christos  * property rights.
     20  1.18  christos  *
     21  1.18  christos  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
     22  1.18  christos  * copy of the source code appearing in this file ("Covered Code") an
     23  1.18  christos  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
     24  1.18  christos  * base code distributed originally by Intel ("Original Intel Code") to copy,
     25  1.18  christos  * make derivatives, distribute, use and display any portion of the Covered
     26  1.18  christos  * Code in any form, with the right to sublicense such rights; and
     27  1.18  christos  *
     28  1.18  christos  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
     29  1.18  christos  * license (with the right to sublicense), under only those claims of Intel
     30  1.18  christos  * patents that are infringed by the Original Intel Code, to make, use, sell,
     31  1.18  christos  * offer to sell, and import the Covered Code and derivative works thereof
     32  1.18  christos  * solely to the minimum extent necessary to exercise the above copyright
     33  1.18  christos  * license, and in no event shall the patent license extend to any additions
     34  1.18  christos  * to or modifications of the Original Intel Code. No other license or right
     35  1.18  christos  * is granted directly or by implication, estoppel or otherwise;
     36  1.18  christos  *
     37  1.18  christos  * The above copyright and patent license is granted only if the following
     38  1.18  christos  * conditions are met:
     39  1.18  christos  *
     40  1.18  christos  * 3. Conditions
     41  1.18  christos  *
     42  1.18  christos  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
     43  1.18  christos  * Redistribution of source code of any substantial portion of the Covered
     44  1.18  christos  * Code or modification with rights to further distribute source must include
     45  1.18  christos  * the above Copyright Notice, the above License, this list of Conditions,
     46  1.18  christos  * and the following Disclaimer and Export Compliance provision. In addition,
     47  1.18  christos  * Licensee must cause all Covered Code to which Licensee contributes to
     48  1.18  christos  * contain a file documenting the changes Licensee made to create that Covered
     49  1.18  christos  * Code and the date of any change. Licensee must include in that file the
     50  1.18  christos  * documentation of any changes made by any predecessor Licensee. Licensee
     51  1.18  christos  * must include a prominent statement that the modification is derived,
     52  1.18  christos  * directly or indirectly, from Original Intel Code.
     53  1.18  christos  *
     54  1.18  christos  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
     55  1.18  christos  * Redistribution of source code of any substantial portion of the Covered
     56  1.18  christos  * Code or modification without rights to further distribute source must
     57  1.18  christos  * include the following Disclaimer and Export Compliance provision in the
     58  1.18  christos  * documentation and/or other materials provided with distribution. In
     59  1.18  christos  * addition, Licensee may not authorize further sublicense of source of any
     60  1.18  christos  * portion of the Covered Code, and must include terms to the effect that the
     61  1.18  christos  * license from Licensee to its licensee is limited to the intellectual
     62  1.18  christos  * property embodied in the software Licensee provides to its licensee, and
     63  1.18  christos  * not to intellectual property embodied in modifications its licensee may
     64  1.18  christos  * make.
     65  1.18  christos  *
     66  1.18  christos  * 3.3. Redistribution of Executable. Redistribution in executable form of any
     67  1.18  christos  * substantial portion of the Covered Code or modification must reproduce the
     68  1.18  christos  * above Copyright Notice, and the following Disclaimer and Export Compliance
     69  1.18  christos  * provision in the documentation and/or other materials provided with the
     70  1.18  christos  * distribution.
     71  1.18  christos  *
     72  1.18  christos  * 3.4. Intel retains all right, title, and interest in and to the Original
     73  1.18  christos  * Intel Code.
     74  1.18  christos  *
     75  1.18  christos  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
     76  1.18  christos  * Intel shall be used in advertising or otherwise to promote the sale, use or
     77  1.18  christos  * other dealings in products derived from or relating to the Covered Code
     78  1.18  christos  * without prior written authorization from Intel.
     79  1.18  christos  *
     80  1.18  christos  * 4. Disclaimer and Export Compliance
     81  1.18  christos  *
     82  1.18  christos  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
     83  1.18  christos  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
     84  1.18  christos  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
     85  1.18  christos  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
     86  1.18  christos  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
     87  1.18  christos  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
     88  1.18  christos  * PARTICULAR PURPOSE.
     89  1.18  christos  *
     90  1.18  christos  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
     91  1.18  christos  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
     92  1.18  christos  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
     93  1.18  christos  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
     94  1.18  christos  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
     95  1.18  christos  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
     96  1.18  christos  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
     97  1.18  christos  * LIMITED REMEDY.
     98  1.18  christos  *
     99  1.18  christos  * 4.3. Licensee shall not export, either directly or indirectly, any of this
    100  1.18  christos  * software or system incorporating such software without first obtaining any
    101  1.18  christos  * required license or other approval from the U. S. Department of Commerce or
    102  1.18  christos  * any other agency or department of the United States Government. In the
    103  1.18  christos  * event Licensee exports any such software from the United States or
    104  1.18  christos  * re-exports any such software from a foreign destination, Licensee shall
    105  1.18  christos  * ensure that the distribution and export/re-export of the software is in
    106  1.18  christos  * compliance with all laws, regulations, orders, or other restrictions of the
    107  1.18  christos  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
    108  1.18  christos  * any of its subsidiaries will export/re-export any technical data, process,
    109  1.18  christos  * software, or service, directly or indirectly, to any country for which the
    110  1.18  christos  * United States government or any agency thereof requires an export license,
    111  1.18  christos  * other governmental approval, or letter of assurance, without first obtaining
    112  1.18  christos  * such license, approval or letter.
    113  1.18  christos  *
    114  1.18  christos  *****************************************************************************
    115  1.18  christos  *
    116  1.18  christos  * Alternatively, you may choose to be licensed under the terms of the
    117  1.18  christos  * following license:
    118  1.18  christos  *
    119   1.1  christos  * Redistribution and use in source and binary forms, with or without
    120   1.1  christos  * modification, are permitted provided that the following conditions
    121   1.1  christos  * are met:
    122   1.1  christos  * 1. Redistributions of source code must retain the above copyright
    123   1.1  christos  *    notice, this list of conditions, and the following disclaimer,
    124   1.1  christos  *    without modification.
    125   1.1  christos  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
    126   1.1  christos  *    substantially similar to the "NO WARRANTY" disclaimer below
    127   1.1  christos  *    ("Disclaimer") and any redistribution must be conditioned upon
    128   1.1  christos  *    including a substantially similar Disclaimer requirement for further
    129   1.1  christos  *    binary redistribution.
    130   1.1  christos  * 3. Neither the names of the above-listed copyright holders nor the names
    131   1.1  christos  *    of any contributors may be used to endorse or promote products derived
    132   1.1  christos  *    from this software without specific prior written permission.
    133   1.1  christos  *
    134   1.1  christos  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    135   1.1  christos  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    136  1.15  christos  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    137   1.1  christos  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    138  1.18  christos  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    139  1.18  christos  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    140  1.18  christos  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    141  1.18  christos  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    142  1.18  christos  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    143  1.18  christos  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    144  1.18  christos  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    145  1.18  christos  *
    146  1.18  christos  * Alternatively, you may choose to be licensed under the terms of the
    147  1.18  christos  * GNU General Public License ("GPL") version 2 as published by the Free
    148  1.18  christos  * Software Foundation.
    149  1.18  christos  *
    150  1.18  christos  *****************************************************************************/
    151   1.1  christos 
    152   1.1  christos #include "aslcompiler.h"
    153   1.1  christos #include "aslcompiler.y.h"
    154   1.1  christos #include "acpredef.h"
    155   1.1  christos 
    156   1.1  christos 
    157   1.1  christos #define _COMPONENT          ACPI_COMPILER
    158   1.1  christos         ACPI_MODULE_NAME    ("aslprepkg")
    159   1.1  christos 
    160   1.1  christos 
    161   1.1  christos /* Local prototypes */
    162   1.1  christos 
    163   1.7  christos static ACPI_PARSE_OBJECT *
    164   1.1  christos ApCheckPackageElements (
    165   1.1  christos     const char                  *PredefinedName,
    166   1.1  christos     ACPI_PARSE_OBJECT           *Op,
    167   1.1  christos     UINT8                       Type1,
    168   1.1  christos     UINT32                      Count1,
    169   1.1  christos     UINT8                       Type2,
    170   1.1  christos     UINT32                      Count2);
    171   1.1  christos 
    172   1.1  christos static void
    173   1.1  christos ApCheckPackageList (
    174   1.1  christos     const char                  *PredefinedName,
    175   1.1  christos     ACPI_PARSE_OBJECT           *ParentOp,
    176   1.1  christos     const ACPI_PREDEFINED_INFO  *Package,
    177   1.1  christos     UINT32                      StartIndex,
    178   1.1  christos     UINT32                      Count);
    179   1.1  christos 
    180   1.1  christos static void
    181   1.1  christos ApPackageTooSmall (
    182   1.1  christos     const char                  *PredefinedName,
    183   1.1  christos     ACPI_PARSE_OBJECT           *Op,
    184   1.1  christos     UINT32                      Count,
    185   1.1  christos     UINT32                      ExpectedCount);
    186   1.1  christos 
    187   1.1  christos static void
    188   1.1  christos ApZeroLengthPackage (
    189   1.1  christos     const char                  *PredefinedName,
    190   1.1  christos     ACPI_PARSE_OBJECT           *Op);
    191   1.1  christos 
    192   1.1  christos static void
    193   1.1  christos ApPackageTooLarge (
    194   1.1  christos     const char                  *PredefinedName,
    195   1.1  christos     ACPI_PARSE_OBJECT           *Op,
    196   1.1  christos     UINT32                      Count,
    197   1.1  christos     UINT32                      ExpectedCount);
    198   1.1  christos 
    199   1.7  christos static void
    200   1.7  christos ApCustomPackage (
    201   1.7  christos     ACPI_PARSE_OBJECT           *ParentOp,
    202   1.7  christos     const ACPI_PREDEFINED_INFO  *Predefined);
    203   1.7  christos 
    204   1.1  christos 
    205   1.1  christos /*******************************************************************************
    206   1.1  christos  *
    207   1.1  christos  * FUNCTION:    ApCheckPackage
    208   1.1  christos  *
    209   1.1  christos  * PARAMETERS:  ParentOp            - Parser op for the package
    210   1.1  christos  *              Predefined          - Pointer to package-specific info for
    211   1.1  christos  *                                    the method
    212   1.1  christos  *
    213   1.1  christos  * RETURN:      None
    214   1.1  christos  *
    215   1.1  christos  * DESCRIPTION: Top-level validation for predefined name return package
    216   1.1  christos  *              objects.
    217   1.1  christos  *
    218   1.1  christos  ******************************************************************************/
    219   1.1  christos 
    220   1.1  christos void
    221   1.1  christos ApCheckPackage (
    222   1.1  christos     ACPI_PARSE_OBJECT           *ParentOp,
    223   1.1  christos     const ACPI_PREDEFINED_INFO  *Predefined)
    224   1.1  christos {
    225   1.1  christos     ACPI_PARSE_OBJECT           *Op;
    226   1.1  christos     const ACPI_PREDEFINED_INFO  *Package;
    227   1.1  christos     ACPI_STATUS                 Status;
    228   1.1  christos     UINT32                      ExpectedCount;
    229   1.1  christos     UINT32                      Count;
    230   1.1  christos     UINT32                      i;
    231   1.1  christos 
    232   1.1  christos 
    233   1.1  christos     /* The package info for this name is in the next table entry */
    234   1.1  christos 
    235   1.1  christos     Package = Predefined + 1;
    236   1.1  christos 
    237   1.1  christos     /* First child is the package length */
    238   1.1  christos 
    239   1.1  christos     Op = ParentOp->Asl.Child;
    240   1.1  christos     Count = (UINT32) Op->Asl.Value.Integer;
    241   1.1  christos 
    242   1.1  christos     /*
    243   1.1  christos      * Many of the variable-length top-level packages are allowed to simply
    244   1.1  christos      * have zero elements. This allows the BIOS to tell the host that even
    245   1.1  christos      * though the predefined name/method exists, the feature is not supported.
    246   1.1  christos      * Other package types require one or more elements. In any case, there
    247   1.1  christos      * is no need to continue validation.
    248   1.1  christos      */
    249   1.1  christos     if (!Count)
    250   1.1  christos     {
    251   1.1  christos         switch (Package->RetInfo.Type)
    252   1.1  christos         {
    253   1.1  christos         case ACPI_PTYPE1_FIXED:
    254   1.1  christos         case ACPI_PTYPE1_OPTION:
    255   1.1  christos         case ACPI_PTYPE2_PKG_COUNT:
    256   1.1  christos         case ACPI_PTYPE2_REV_FIXED:
    257   1.1  christos 
    258   1.1  christos             ApZeroLengthPackage (Predefined->Info.Name, ParentOp);
    259   1.1  christos             break;
    260   1.1  christos 
    261   1.1  christos         case ACPI_PTYPE1_VAR:
    262   1.1  christos         case ACPI_PTYPE2:
    263   1.1  christos         case ACPI_PTYPE2_COUNT:
    264   1.1  christos         case ACPI_PTYPE2_FIXED:
    265   1.1  christos         case ACPI_PTYPE2_MIN:
    266   1.1  christos         case ACPI_PTYPE2_FIX_VAR:
    267   1.5  christos         case ACPI_PTYPE2_VAR_VAR:
    268   1.1  christos         default:
    269   1.1  christos 
    270   1.1  christos             break;
    271   1.1  christos         }
    272   1.1  christos 
    273   1.1  christos         return;
    274   1.1  christos     }
    275   1.1  christos 
    276   1.1  christos     /* Get the first element of the package */
    277   1.1  christos 
    278   1.1  christos     Op = Op->Asl.Next;
    279   1.1  christos 
    280   1.1  christos     /* Decode the package type */
    281   1.1  christos 
    282   1.1  christos     switch (Package->RetInfo.Type)
    283   1.1  christos     {
    284   1.7  christos     case ACPI_PTYPE_CUSTOM:
    285   1.7  christos 
    286   1.7  christos         ApCustomPackage (ParentOp, Predefined);
    287   1.7  christos         break;
    288   1.7  christos 
    289   1.1  christos     case ACPI_PTYPE1_FIXED:
    290   1.1  christos         /*
    291   1.3  christos          * The package count is fixed and there are no subpackages
    292   1.1  christos          *
    293   1.1  christos          * If package is too small, exit.
    294   1.1  christos          * If package is larger than expected, issue warning but continue
    295   1.1  christos          */
    296   1.1  christos         ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2;
    297   1.1  christos         if (Count < ExpectedCount)
    298   1.1  christos         {
    299   1.1  christos             goto PackageTooSmall;
    300   1.1  christos         }
    301   1.1  christos         else if (Count > ExpectedCount)
    302   1.1  christos         {
    303   1.1  christos             ApPackageTooLarge (Predefined->Info.Name, ParentOp,
    304   1.1  christos                 Count, ExpectedCount);
    305   1.1  christos         }
    306   1.1  christos 
    307   1.1  christos         /* Validate all elements of the package */
    308   1.1  christos 
    309   1.1  christos         ApCheckPackageElements (Predefined->Info.Name, Op,
    310   1.1  christos             Package->RetInfo.ObjectType1, Package->RetInfo.Count1,
    311   1.1  christos             Package->RetInfo.ObjectType2, Package->RetInfo.Count2);
    312   1.1  christos         break;
    313   1.1  christos 
    314   1.1  christos     case ACPI_PTYPE1_VAR:
    315   1.1  christos         /*
    316   1.3  christos          * The package count is variable, there are no subpackages,
    317   1.1  christos          * and all elements must be of the same type
    318   1.1  christos          */
    319   1.1  christos         for (i = 0; i < Count; i++)
    320   1.1  christos         {
    321  1.14  christos             if (!Op)
    322  1.14  christos             {
    323  1.14  christos                 /*
    324  1.14  christos                  * If we get to this point, it means that the package length
    325  1.14  christos                  * is larger than the initializer list. Stop processing the
    326  1.14  christos                  * package and return because we have run out of package
    327  1.14  christos                  * elements to analyze.
    328  1.14  christos                  */
    329  1.14  christos                 return;
    330  1.14  christos             }
    331  1.14  christos 
    332   1.1  christos             ApCheckObjectType (Predefined->Info.Name, Op,
    333   1.1  christos                 Package->RetInfo.ObjectType1, i);
    334   1.1  christos             Op = Op->Asl.Next;
    335   1.1  christos         }
    336   1.1  christos         break;
    337   1.1  christos 
    338   1.1  christos     case ACPI_PTYPE1_OPTION:
    339   1.1  christos         /*
    340   1.3  christos          * The package count is variable, there are no subpackages.
    341   1.1  christos          * There are a fixed number of required elements, and a variable
    342   1.1  christos          * number of optional elements.
    343   1.1  christos          *
    344   1.1  christos          * Check if package is at least as large as the minimum required
    345   1.1  christos          */
    346   1.1  christos         ExpectedCount = Package->RetInfo3.Count;
    347   1.1  christos         if (Count < ExpectedCount)
    348   1.1  christos         {
    349   1.1  christos             goto PackageTooSmall;
    350   1.1  christos         }
    351   1.1  christos 
    352   1.1  christos         /* Variable number of sub-objects */
    353   1.1  christos 
    354   1.1  christos         for (i = 0; i < Count; i++)
    355   1.1  christos         {
    356   1.1  christos             if (i < Package->RetInfo3.Count)
    357   1.1  christos             {
    358   1.1  christos                 /* These are the required package elements (0, 1, or 2) */
    359   1.1  christos 
    360   1.1  christos                 ApCheckObjectType (Predefined->Info.Name, Op,
    361   1.1  christos                     Package->RetInfo3.ObjectType[i], i);
    362   1.1  christos             }
    363   1.1  christos             else
    364   1.1  christos             {
    365   1.1  christos                 /* These are the optional package elements */
    366   1.1  christos 
    367   1.1  christos                 ApCheckObjectType (Predefined->Info.Name, Op,
    368   1.1  christos                     Package->RetInfo3.TailObjectType, i);
    369   1.1  christos             }
    370   1.6  christos 
    371   1.1  christos             Op = Op->Asl.Next;
    372   1.1  christos         }
    373   1.1  christos         break;
    374   1.1  christos 
    375   1.1  christos     case ACPI_PTYPE2_REV_FIXED:
    376   1.1  christos 
    377   1.1  christos         /* First element is the (Integer) revision */
    378   1.1  christos 
    379   1.1  christos         ApCheckObjectType (Predefined->Info.Name, Op,
    380   1.1  christos             ACPI_RTYPE_INTEGER, 0);
    381   1.1  christos 
    382   1.1  christos         Op = Op->Asl.Next;
    383   1.1  christos         Count--;
    384   1.1  christos 
    385   1.3  christos         /* Examine the subpackages */
    386   1.1  christos 
    387   1.1  christos         ApCheckPackageList (Predefined->Info.Name, Op,
    388   1.1  christos             Package, 1, Count);
    389   1.1  christos         break;
    390   1.1  christos 
    391   1.1  christos     case ACPI_PTYPE2_PKG_COUNT:
    392   1.1  christos 
    393   1.3  christos         /* First element is the (Integer) count of subpackages to follow */
    394   1.1  christos 
    395   1.1  christos         Status = ApCheckObjectType (Predefined->Info.Name, Op,
    396   1.1  christos             ACPI_RTYPE_INTEGER, 0);
    397   1.1  christos 
    398   1.1  christos         /* We must have an integer count from above (otherwise, use Count) */
    399   1.1  christos 
    400   1.1  christos         if (ACPI_SUCCESS (Status))
    401   1.1  christos         {
    402   1.1  christos             /*
    403   1.1  christos              * Count cannot be larger than the parent package length, but
    404   1.1  christos              * allow it to be smaller. The >= accounts for the Integer above.
    405   1.1  christos              */
    406   1.1  christos             ExpectedCount = (UINT32) Op->Asl.Value.Integer;
    407   1.1  christos             if (ExpectedCount >= Count)
    408   1.1  christos             {
    409   1.1  christos                 goto PackageTooSmall;
    410   1.1  christos             }
    411   1.1  christos 
    412   1.1  christos             Count = ExpectedCount;
    413   1.1  christos         }
    414   1.1  christos 
    415   1.1  christos         Op = Op->Asl.Next;
    416   1.1  christos 
    417   1.3  christos         /* Examine the subpackages */
    418   1.1  christos 
    419   1.1  christos         ApCheckPackageList (Predefined->Info.Name, Op,
    420   1.1  christos             Package, 1, Count);
    421   1.1  christos         break;
    422   1.1  christos 
    423   1.3  christos     case ACPI_PTYPE2_UUID_PAIR:
    424   1.3  christos 
    425   1.3  christos         /* The package contains a variable list of UUID Buffer/Package pairs */
    426   1.3  christos 
    427   1.3  christos         /* The length of the package must be even */
    428   1.3  christos 
    429   1.3  christos         if (Count & 1)
    430   1.3  christos         {
    431  1.10  christos             sprintf (AslGbl_MsgBuffer, "%4.4s: Package length, %d, must be even.",
    432   1.3  christos                 Predefined->Info.Name, Count);
    433   1.3  christos 
    434   1.3  christos             AslError (ASL_ERROR, ASL_MSG_RESERVED_PACKAGE_LENGTH,
    435  1.10  christos                 ParentOp->Asl.Child, AslGbl_MsgBuffer);
    436   1.3  christos         }
    437   1.3  christos 
    438   1.3  christos         /* Validate the alternating types */
    439   1.3  christos 
    440   1.3  christos         for (i = 0; i < Count; ++i)
    441   1.3  christos         {
    442   1.3  christos             if (i & 1)
    443   1.3  christos             {
    444   1.3  christos                 ApCheckObjectType (Predefined->Info.Name, Op,
    445   1.3  christos                     Package->RetInfo.ObjectType2, i);
    446   1.3  christos             }
    447   1.3  christos             else
    448   1.3  christos             {
    449   1.3  christos                 ApCheckObjectType (Predefined->Info.Name, Op,
    450   1.3  christos                     Package->RetInfo.ObjectType1, i);
    451   1.3  christos             }
    452   1.3  christos 
    453   1.3  christos             Op = Op->Asl.Next;
    454   1.3  christos         }
    455   1.3  christos 
    456   1.3  christos         break;
    457   1.3  christos 
    458   1.5  christos     case ACPI_PTYPE2_VAR_VAR:
    459   1.5  christos 
    460   1.5  christos         /* Check for minimum size (ints at beginning + 1 subpackage) */
    461   1.5  christos 
    462   1.5  christos         ExpectedCount = Package->RetInfo4.Count1 + 1;
    463   1.5  christos         if (Count < ExpectedCount)
    464   1.5  christos         {
    465   1.5  christos             goto PackageTooSmall;
    466   1.5  christos         }
    467   1.5  christos 
    468   1.5  christos         /* Check the non-package elements at beginning of main package */
    469   1.5  christos 
    470   1.5  christos         for (i = 0; i < Package->RetInfo4.Count1; ++i)
    471   1.5  christos         {
    472  1.12  christos             ApCheckObjectType (Predefined->Info.Name, Op,
    473   1.5  christos                 Package->RetInfo4.ObjectType1, i);
    474   1.5  christos             Op = Op->Asl.Next;
    475   1.5  christos         }
    476   1.5  christos 
    477   1.5  christos         /* Examine the variable-length list of subpackages */
    478   1.5  christos 
    479   1.5  christos         ApCheckPackageList (Predefined->Info.Name, Op,
    480   1.5  christos             Package, Package->RetInfo4.Count1, Count);
    481   1.5  christos 
    482   1.5  christos         break;
    483   1.5  christos 
    484   1.1  christos     case ACPI_PTYPE2:
    485   1.1  christos     case ACPI_PTYPE2_FIXED:
    486   1.1  christos     case ACPI_PTYPE2_MIN:
    487   1.1  christos     case ACPI_PTYPE2_COUNT:
    488   1.1  christos     case ACPI_PTYPE2_FIX_VAR:
    489   1.1  christos         /*
    490   1.1  christos          * These types all return a single Package that consists of a
    491   1.3  christos          * variable number of subpackages.
    492   1.1  christos          */
    493   1.1  christos 
    494   1.3  christos         /* Examine the subpackages */
    495   1.1  christos 
    496   1.1  christos         ApCheckPackageList (Predefined->Info.Name, Op,
    497   1.1  christos             Package, 0, Count);
    498   1.1  christos         break;
    499   1.1  christos 
    500   1.1  christos     default:
    501   1.1  christos         return;
    502   1.1  christos     }
    503   1.1  christos 
    504   1.1  christos     return;
    505   1.1  christos 
    506   1.1  christos PackageTooSmall:
    507   1.1  christos     ApPackageTooSmall (Predefined->Info.Name, ParentOp,
    508   1.1  christos         Count, ExpectedCount);
    509   1.1  christos }
    510   1.1  christos 
    511   1.1  christos 
    512   1.1  christos /*******************************************************************************
    513   1.1  christos  *
    514   1.7  christos  * FUNCTION:    ApCustomPackage
    515   1.7  christos  *
    516   1.7  christos  * PARAMETERS:  ParentOp            - Parse op for the package
    517   1.7  christos  *              Predefined          - Pointer to package-specific info for
    518   1.7  christos  *                                    the method
    519   1.7  christos  *
    520   1.7  christos  * RETURN:      None
    521   1.7  christos  *
    522   1.7  christos  * DESCRIPTION: Validate packages that don't fit into the standard model and
    523   1.7  christos  *              require custom code.
    524   1.7  christos  *
    525   1.7  christos  * NOTE: Currently used for the _BIX method only. When needed for two or more
    526   1.7  christos  * methods, probably a detect/dispatch mechanism will be required.
    527   1.7  christos  *
    528   1.7  christos  ******************************************************************************/
    529   1.7  christos 
    530   1.7  christos static void
    531   1.7  christos ApCustomPackage (
    532   1.7  christos     ACPI_PARSE_OBJECT           *ParentOp,
    533   1.7  christos     const ACPI_PREDEFINED_INFO  *Predefined)
    534   1.7  christos {
    535   1.7  christos     ACPI_PARSE_OBJECT           *Op;
    536   1.7  christos     UINT32                      Count;
    537   1.7  christos     UINT32                      ExpectedCount;
    538   1.7  christos     UINT32                      Version;
    539   1.7  christos 
    540   1.7  christos 
    541   1.7  christos     /* First child is the package length */
    542   1.7  christos 
    543   1.7  christos     Op = ParentOp->Asl.Child;
    544   1.7  christos     Count = (UINT32) Op->Asl.Value.Integer;
    545   1.7  christos 
    546   1.7  christos     /* Get the version number, must be Integer */
    547   1.7  christos 
    548   1.7  christos     Op = Op->Asl.Next;
    549   1.7  christos     Version = (UINT32) Op->Asl.Value.Integer;
    550   1.7  christos     if (Op->Asl.ParseOpcode != PARSEOP_INTEGER)
    551   1.7  christos     {
    552  1.10  christos         AslError (ASL_ERROR, ASL_MSG_RESERVED_OPERAND_TYPE, Op, AslGbl_MsgBuffer);
    553   1.7  christos         return;
    554   1.7  christos     }
    555   1.7  christos 
    556   1.7  christos     /* Validate count (# of elements) */
    557   1.7  christos 
    558   1.7  christos     ExpectedCount = 21;         /* Version 1 */
    559   1.7  christos     if (Version == 0)
    560   1.7  christos     {
    561   1.7  christos         ExpectedCount = 20;     /* Version 0 */
    562   1.7  christos     }
    563   1.7  christos 
    564   1.7  christos     if (Count < ExpectedCount)
    565   1.7  christos     {
    566   1.7  christos         ApPackageTooSmall (Predefined->Info.Name, ParentOp,
    567   1.7  christos             Count, ExpectedCount);
    568   1.7  christos         return;
    569   1.7  christos     }
    570   1.7  christos     else if (Count > ExpectedCount)
    571   1.7  christos     {
    572   1.7  christos         ApPackageTooLarge (Predefined->Info.Name, ParentOp,
    573   1.7  christos             Count, ExpectedCount);
    574   1.7  christos     }
    575   1.7  christos 
    576   1.7  christos     /* Validate all elements of the package */
    577   1.7  christos 
    578   1.7  christos     Op = ApCheckPackageElements (Predefined->Info.Name, Op,
    579   1.7  christos         ACPI_RTYPE_INTEGER, 16,
    580   1.7  christos         ACPI_RTYPE_STRING, 4);
    581   1.7  christos 
    582   1.7  christos     /* Version 1 has a single trailing integer */
    583   1.7  christos 
    584   1.7  christos     if (Version > 0)
    585   1.7  christos     {
    586   1.7  christos         ApCheckPackageElements (Predefined->Info.Name, Op,
    587   1.7  christos             ACPI_RTYPE_INTEGER, 1, 0, 0);
    588   1.7  christos     }
    589   1.7  christos }
    590   1.7  christos 
    591   1.7  christos 
    592   1.7  christos /*******************************************************************************
    593   1.7  christos  *
    594   1.1  christos  * FUNCTION:    ApCheckPackageElements
    595   1.1  christos  *
    596   1.1  christos  * PARAMETERS:  PredefinedName      - Name of the predefined object
    597   1.1  christos  *              Op                  - Parser op for the package
    598   1.1  christos  *              Type1               - Object type for first group
    599   1.1  christos  *              Count1              - Count for first group
    600   1.1  christos  *              Type2               - Object type for second group
    601   1.1  christos  *              Count2              - Count for second group
    602   1.1  christos  *
    603   1.7  christos  * RETURN:      Next Op peer in the parse tree, after all specified elements
    604   1.7  christos  *              have been validated. Used for multiple validations (calls
    605   1.7  christos  *              to this function).
    606   1.1  christos  *
    607   1.1  christos  * DESCRIPTION: Validate all elements of a package. Works with packages that
    608   1.1  christos  *              are defined to contain up to two groups of different object
    609   1.1  christos  *              types.
    610   1.1  christos  *
    611   1.1  christos  ******************************************************************************/
    612   1.1  christos 
    613   1.7  christos static ACPI_PARSE_OBJECT *
    614   1.1  christos ApCheckPackageElements (
    615   1.1  christos     const char              *PredefinedName,
    616   1.1  christos     ACPI_PARSE_OBJECT       *Op,
    617   1.1  christos     UINT8                   Type1,
    618   1.1  christos     UINT32                  Count1,
    619   1.1  christos     UINT8                   Type2,
    620   1.1  christos     UINT32                  Count2)
    621   1.1  christos {
    622   1.1  christos     UINT32                  i;
    623   1.1  christos 
    624   1.1  christos 
    625   1.1  christos     /*
    626   1.1  christos      * Up to two groups of package elements are supported by the data
    627   1.1  christos      * structure. All elements in each group must be of the same type.
    628   1.1  christos      * The second group can have a count of zero.
    629   1.1  christos      *
    630   1.1  christos      * Aborts check upon a NULL package element, as this means (at compile
    631   1.1  christos      * time) that the remainder of the package elements are also NULL
    632   1.1  christos      * (This is the only way to create NULL package elements.)
    633   1.1  christos      */
    634   1.1  christos     for (i = 0; (i < Count1) && Op; i++)
    635   1.1  christos     {
    636   1.1  christos         ApCheckObjectType (PredefinedName, Op, Type1, i);
    637   1.1  christos         Op = Op->Asl.Next;
    638   1.1  christos     }
    639   1.1  christos 
    640   1.1  christos     for (i = 0; (i < Count2) && Op; i++)
    641   1.1  christos     {
    642   1.1  christos         ApCheckObjectType (PredefinedName, Op, Type2, (i + Count1));
    643   1.1  christos         Op = Op->Asl.Next;
    644   1.1  christos     }
    645   1.7  christos 
    646   1.7  christos     return (Op);
    647   1.1  christos }
    648   1.1  christos 
    649   1.1  christos 
    650   1.1  christos /*******************************************************************************
    651   1.1  christos  *
    652   1.1  christos  * FUNCTION:    ApCheckPackageList
    653   1.1  christos  *
    654   1.1  christos  * PARAMETERS:  PredefinedName      - Name of the predefined object
    655   1.1  christos  *              ParentOp            - Parser op of the parent package
    656   1.1  christos  *              Package             - Package info for this predefined name
    657   1.1  christos  *              StartIndex          - Index in parent package where list begins
    658   1.1  christos  *              ParentCount         - Element count of parent package
    659   1.1  christos  *
    660   1.1  christos  * RETURN:      None
    661   1.1  christos  *
    662   1.1  christos  * DESCRIPTION: Validate the individual package elements for a predefined name.
    663   1.1  christos  *              Handles the cases where the predefined name is defined as a
    664   1.1  christos  *              Package of Packages (subpackages). These are the types:
    665   1.1  christos  *
    666   1.1  christos  *              ACPI_PTYPE2
    667   1.1  christos  *              ACPI_PTYPE2_FIXED
    668   1.1  christos  *              ACPI_PTYPE2_MIN
    669   1.1  christos  *              ACPI_PTYPE2_COUNT
    670   1.1  christos  *              ACPI_PTYPE2_FIX_VAR
    671   1.5  christos  *              ACPI_PTYPE2_VAR_VAR
    672   1.1  christos  *
    673   1.1  christos  ******************************************************************************/
    674   1.1  christos 
    675   1.1  christos static void
    676   1.1  christos ApCheckPackageList (
    677   1.1  christos     const char                  *PredefinedName,
    678   1.1  christos     ACPI_PARSE_OBJECT           *ParentOp,
    679   1.1  christos     const ACPI_PREDEFINED_INFO  *Package,
    680   1.1  christos     UINT32                      StartIndex,
    681   1.1  christos     UINT32                      ParentCount)
    682   1.1  christos {
    683   1.1  christos     ACPI_PARSE_OBJECT           *SubPackageOp = ParentOp;
    684   1.1  christos     ACPI_PARSE_OBJECT           *Op;
    685   1.1  christos     ACPI_STATUS                 Status;
    686   1.1  christos     UINT32                      Count;
    687   1.1  christos     UINT32                      ExpectedCount;
    688   1.1  christos     UINT32                      i;
    689   1.1  christos     UINT32                      j;
    690   1.1  christos 
    691   1.1  christos 
    692   1.1  christos     /*
    693   1.1  christos      * Validate each subpackage in the parent Package
    694   1.1  christos      *
    695   1.1  christos      * Note: We ignore NULL package elements on the assumption that
    696   1.1  christos      * they will be initialized by the BIOS or other ASL code.
    697   1.1  christos      */
    698   1.1  christos     for (i = 0; (i < ParentCount) && SubPackageOp; i++)
    699   1.1  christos     {
    700   1.1  christos         /* Each object in the list must be of type Package */
    701   1.1  christos 
    702   1.1  christos         Status = ApCheckObjectType (PredefinedName, SubPackageOp,
    703   1.1  christos             ACPI_RTYPE_PACKAGE, i + StartIndex);
    704   1.1  christos         if (ACPI_FAILURE (Status))
    705   1.1  christos         {
    706   1.1  christos             goto NextSubpackage;
    707   1.1  christos         }
    708   1.1  christos 
    709   1.1  christos         /* Examine the different types of expected subpackages */
    710   1.1  christos 
    711   1.1  christos         Op = SubPackageOp->Asl.Child;
    712   1.1  christos 
    713   1.1  christos         /* First child is the package length */
    714   1.1  christos 
    715   1.1  christos         Count = (UINT32) Op->Asl.Value.Integer;
    716   1.1  christos         Op = Op->Asl.Next;
    717   1.1  christos 
    718   1.5  christos         /*
    719   1.5  christos          * Most subpackage must have at least one element, with
    720   1.5  christos          * only rare exceptions. (_RDI)
    721   1.5  christos          */
    722   1.5  christos         if (!Count &&
    723   1.5  christos             (Package->RetInfo.Type != ACPI_PTYPE2_VAR_VAR))
    724   1.1  christos         {
    725   1.1  christos             ApZeroLengthPackage (PredefinedName, SubPackageOp);
    726   1.1  christos             goto NextSubpackage;
    727   1.1  christos         }
    728   1.1  christos 
    729   1.1  christos         /*
    730   1.1  christos          * Decode the package type.
    731   1.1  christos          * PTYPE2 indicates that a "package of packages" is expected for
    732   1.1  christos          * this name. The various flavors of PTYPE2 indicate the number
    733   1.1  christos          * and format of the subpackages.
    734   1.1  christos          */
    735   1.1  christos         switch (Package->RetInfo.Type)
    736   1.1  christos         {
    737   1.1  christos         case ACPI_PTYPE2:
    738   1.1  christos         case ACPI_PTYPE2_PKG_COUNT:
    739   1.1  christos         case ACPI_PTYPE2_REV_FIXED:
    740   1.1  christos 
    741   1.1  christos             /* Each subpackage has a fixed number of elements */
    742   1.1  christos 
    743   1.1  christos             ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2;
    744   1.1  christos             if (Count < ExpectedCount)
    745   1.1  christos             {
    746   1.1  christos                 ApPackageTooSmall (PredefinedName, SubPackageOp,
    747   1.1  christos                     Count, ExpectedCount);
    748   1.1  christos                 break;
    749   1.1  christos             }
    750   1.3  christos             if (Count > ExpectedCount)
    751   1.3  christos             {
    752   1.3  christos                 ApPackageTooLarge (PredefinedName, SubPackageOp,
    753   1.3  christos                     Count, ExpectedCount);
    754   1.3  christos                 break;
    755   1.3  christos             }
    756   1.1  christos 
    757   1.1  christos             ApCheckPackageElements (PredefinedName, Op,
    758   1.1  christos                 Package->RetInfo.ObjectType1, Package->RetInfo.Count1,
    759   1.1  christos                 Package->RetInfo.ObjectType2, Package->RetInfo.Count2);
    760   1.1  christos             break;
    761   1.1  christos 
    762   1.1  christos         case ACPI_PTYPE2_FIX_VAR:
    763   1.1  christos             /*
    764   1.1  christos              * Each subpackage has a fixed number of elements and an
    765   1.1  christos              * optional element
    766   1.1  christos              */
    767   1.1  christos             ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2;
    768   1.1  christos             if (Count < ExpectedCount)
    769   1.1  christos             {
    770   1.1  christos                 ApPackageTooSmall (PredefinedName, SubPackageOp,
    771   1.1  christos                     Count, ExpectedCount);
    772   1.1  christos                 break;
    773   1.1  christos             }
    774   1.1  christos 
    775   1.1  christos             ApCheckPackageElements (PredefinedName, Op,
    776   1.1  christos                 Package->RetInfo.ObjectType1, Package->RetInfo.Count1,
    777   1.1  christos                 Package->RetInfo.ObjectType2,
    778   1.1  christos                 Count - Package->RetInfo.Count1);
    779   1.1  christos             break;
    780   1.1  christos 
    781   1.5  christos         case ACPI_PTYPE2_VAR_VAR:
    782   1.5  christos             /*
    783   1.5  christos              * Must have at least the minimum number elements.
    784   1.5  christos              * A zero PkgCount means the number of elements is variable.
    785   1.5  christos              */
    786   1.5  christos             ExpectedCount = Package->RetInfo4.PkgCount;
    787   1.5  christos             if (ExpectedCount && (Count < ExpectedCount))
    788   1.5  christos             {
    789   1.5  christos                 ApPackageTooSmall (PredefinedName, SubPackageOp,
    790   1.5  christos                     Count, 1);
    791   1.5  christos                 break;
    792   1.5  christos             }
    793   1.5  christos 
    794   1.5  christos             ApCheckPackageElements (PredefinedName, Op,
    795   1.5  christos                 Package->RetInfo4.SubObjectTypes,
    796   1.5  christos                 Package->RetInfo4.PkgCount,
    797   1.5  christos                 0, 0);
    798   1.5  christos             break;
    799   1.5  christos 
    800   1.1  christos         case ACPI_PTYPE2_FIXED:
    801   1.1  christos 
    802   1.3  christos             /* Each subpackage has a fixed length */
    803   1.1  christos 
    804   1.1  christos             ExpectedCount = Package->RetInfo2.Count;
    805   1.1  christos             if (Count < ExpectedCount)
    806   1.1  christos             {
    807   1.1  christos                 ApPackageTooSmall (PredefinedName, SubPackageOp,
    808   1.1  christos                     Count, ExpectedCount);
    809   1.1  christos                 break;
    810   1.1  christos             }
    811   1.3  christos             if (Count > ExpectedCount)
    812   1.3  christos             {
    813   1.3  christos                 ApPackageTooLarge (PredefinedName, SubPackageOp,
    814   1.3  christos                     Count, ExpectedCount);
    815   1.3  christos                 break;
    816   1.3  christos             }
    817   1.1  christos 
    818   1.1  christos             /* Check each object/type combination */
    819   1.1  christos 
    820   1.1  christos             for (j = 0; j < ExpectedCount; j++)
    821   1.1  christos             {
    822   1.1  christos                 ApCheckObjectType (PredefinedName, Op,
    823   1.1  christos                     Package->RetInfo2.ObjectType[j], j);
    824   1.1  christos 
    825   1.1  christos                 Op = Op->Asl.Next;
    826   1.1  christos             }
    827   1.1  christos             break;
    828   1.1  christos 
    829   1.1  christos         case ACPI_PTYPE2_MIN:
    830   1.1  christos 
    831   1.3  christos             /* Each subpackage has a variable but minimum length */
    832   1.1  christos 
    833   1.1  christos             ExpectedCount = Package->RetInfo.Count1;
    834   1.1  christos             if (Count < ExpectedCount)
    835   1.1  christos             {
    836   1.1  christos                 ApPackageTooSmall (PredefinedName, SubPackageOp,
    837   1.1  christos                     Count, ExpectedCount);
    838   1.1  christos                 break;
    839   1.1  christos             }
    840   1.1  christos 
    841   1.3  christos             /* Check the type of each subpackage element */
    842   1.1  christos 
    843   1.1  christos             ApCheckPackageElements (PredefinedName, Op,
    844   1.1  christos                 Package->RetInfo.ObjectType1, Count, 0, 0);
    845   1.1  christos             break;
    846   1.1  christos 
    847   1.1  christos         case ACPI_PTYPE2_COUNT:
    848   1.1  christos             /*
    849   1.1  christos              * First element is the (Integer) count of elements, including
    850   1.1  christos              * the count field (the ACPI name is NumElements)
    851   1.1  christos              */
    852   1.1  christos             Status = ApCheckObjectType (PredefinedName, Op,
    853   1.1  christos                 ACPI_RTYPE_INTEGER, 0);
    854   1.1  christos 
    855   1.1  christos             /* We must have an integer count from above (otherwise, use Count) */
    856   1.1  christos 
    857   1.1  christos             if (ACPI_SUCCESS (Status))
    858   1.1  christos             {
    859   1.1  christos                 /*
    860   1.1  christos                  * Make sure package is large enough for the Count and is
    861   1.1  christos                  * is as large as the minimum size
    862   1.1  christos                  */
    863   1.1  christos                 ExpectedCount = (UINT32) Op->Asl.Value.Integer;
    864   1.1  christos 
    865   1.1  christos                 if (Count < ExpectedCount)
    866   1.1  christos                 {
    867   1.1  christos                     ApPackageTooSmall (PredefinedName, SubPackageOp,
    868   1.1  christos                         Count, ExpectedCount);
    869   1.1  christos                     break;
    870   1.1  christos                 }
    871   1.1  christos                 else if (Count > ExpectedCount)
    872   1.1  christos                 {
    873   1.1  christos                     ApPackageTooLarge (PredefinedName, SubPackageOp,
    874   1.1  christos                         Count, ExpectedCount);
    875   1.1  christos                 }
    876   1.1  christos 
    877   1.1  christos                 /* Some names of this type have a minimum length */
    878   1.1  christos 
    879   1.1  christos                 if (Count < Package->RetInfo.Count1)
    880   1.1  christos                 {
    881   1.1  christos                     ExpectedCount = Package->RetInfo.Count1;
    882   1.1  christos                     ApPackageTooSmall (PredefinedName, SubPackageOp,
    883   1.1  christos                         Count, ExpectedCount);
    884   1.1  christos                     break;
    885   1.1  christos                 }
    886   1.1  christos 
    887   1.1  christos                 Count = ExpectedCount;
    888   1.1  christos             }
    889   1.1  christos 
    890   1.3  christos             /* Check the type of each subpackage element */
    891   1.1  christos 
    892   1.1  christos             Op = Op->Asl.Next;
    893   1.1  christos             ApCheckPackageElements (PredefinedName, Op,
    894   1.1  christos                 Package->RetInfo.ObjectType1, (Count - 1), 0, 0);
    895   1.1  christos             break;
    896   1.1  christos 
    897   1.1  christos         default:
    898   1.1  christos             break;
    899   1.1  christos         }
    900   1.1  christos 
    901   1.1  christos NextSubpackage:
    902   1.1  christos         SubPackageOp = SubPackageOp->Asl.Next;
    903   1.1  christos     }
    904   1.1  christos }
    905   1.1  christos 
    906   1.1  christos 
    907   1.1  christos /*******************************************************************************
    908   1.1  christos  *
    909   1.1  christos  * FUNCTION:    ApPackageTooSmall
    910   1.1  christos  *
    911   1.1  christos  * PARAMETERS:  PredefinedName      - Name of the predefined object
    912   1.1  christos  *              Op                  - Current parser op
    913   1.1  christos  *              Count               - Actual package element count
    914   1.1  christos  *              ExpectedCount       - Expected package element count
    915   1.1  christos  *
    916   1.1  christos  * RETURN:      None
    917   1.1  christos  *
    918   1.1  christos  * DESCRIPTION: Issue error message for a package that is smaller than
    919   1.1  christos  *              required.
    920   1.1  christos  *
    921   1.1  christos  ******************************************************************************/
    922   1.1  christos 
    923   1.1  christos static void
    924   1.1  christos ApPackageTooSmall (
    925   1.1  christos     const char                  *PredefinedName,
    926   1.1  christos     ACPI_PARSE_OBJECT           *Op,
    927   1.1  christos     UINT32                      Count,
    928   1.1  christos     UINT32                      ExpectedCount)
    929   1.1  christos {
    930   1.1  christos 
    931  1.14  christos     snprintf (AslGbl_MsgBuffer, sizeof(AslGbl_MsgBuffer), "%4.4s: length %u, required minimum is %u",
    932   1.1  christos         PredefinedName, Count, ExpectedCount);
    933   1.1  christos 
    934  1.10  christos     AslError (ASL_ERROR, ASL_MSG_RESERVED_PACKAGE_LENGTH, Op, AslGbl_MsgBuffer);
    935   1.1  christos }
    936   1.1  christos 
    937   1.1  christos 
    938   1.1  christos /*******************************************************************************
    939   1.1  christos  *
    940   1.1  christos  * FUNCTION:    ApZeroLengthPackage
    941   1.1  christos  *
    942   1.1  christos  * PARAMETERS:  PredefinedName      - Name of the predefined object
    943   1.1  christos  *              Op                  - Current parser op
    944   1.1  christos  *
    945   1.1  christos  * RETURN:      None
    946   1.1  christos  *
    947   1.1  christos  * DESCRIPTION: Issue error message for a zero-length package (a package that
    948   1.1  christos  *              is required to have a non-zero length). Variable length
    949   1.1  christos  *              packages seem to be allowed to have zero length, however.
    950   1.1  christos  *              Even if not allowed, BIOS code does it.
    951   1.1  christos  *
    952   1.1  christos  ******************************************************************************/
    953   1.1  christos 
    954   1.1  christos static void
    955   1.1  christos ApZeroLengthPackage (
    956   1.1  christos     const char                  *PredefinedName,
    957   1.1  christos     ACPI_PARSE_OBJECT           *Op)
    958   1.1  christos {
    959   1.1  christos 
    960  1.14  christos     snprintf (AslGbl_MsgBuffer, sizeof(AslGbl_MsgBuffer), "%4.4s: length is zero", PredefinedName);
    961   1.1  christos 
    962  1.10  christos     AslError (ASL_ERROR, ASL_MSG_RESERVED_PACKAGE_LENGTH, Op, AslGbl_MsgBuffer);
    963   1.1  christos }
    964   1.1  christos 
    965   1.1  christos 
    966   1.1  christos /*******************************************************************************
    967   1.1  christos  *
    968   1.1  christos  * FUNCTION:    ApPackageTooLarge
    969   1.1  christos  *
    970   1.1  christos  * PARAMETERS:  PredefinedName      - Name of the predefined object
    971   1.1  christos  *              Op                  - Current parser op
    972   1.1  christos  *              Count               - Actual package element count
    973   1.1  christos  *              ExpectedCount       - Expected package element count
    974   1.1  christos  *
    975   1.1  christos  * RETURN:      None
    976   1.1  christos  *
    977   1.1  christos  * DESCRIPTION: Issue a remark for a package that is larger than expected.
    978   1.1  christos  *
    979   1.1  christos  ******************************************************************************/
    980   1.1  christos 
    981   1.1  christos static void
    982   1.1  christos ApPackageTooLarge (
    983   1.1  christos     const char                  *PredefinedName,
    984   1.1  christos     ACPI_PARSE_OBJECT           *Op,
    985   1.1  christos     UINT32                      Count,
    986   1.1  christos     UINT32                      ExpectedCount)
    987   1.1  christos {
    988   1.1  christos 
    989  1.14  christos     snprintf (AslGbl_MsgBuffer, sizeof(AslGbl_MsgBuffer), "%4.4s: length is %u, only %u required",
    990   1.1  christos         PredefinedName, Count, ExpectedCount);
    991   1.1  christos 
    992  1.10  christos     AslError (ASL_REMARK, ASL_MSG_RESERVED_PACKAGE_LENGTH, Op, AslGbl_MsgBuffer);
    993   1.1  christos }
    994