Home | History | Annotate | Line # | Download | only in compiler
aslpredef.c revision 1.6.4.1
      1 /******************************************************************************
      2  *
      3  * Module Name: aslpredef - support for ACPI predefined names
      4  *
      5  *****************************************************************************/
      6 
      7 /*
      8  * Copyright (C) 2000 - 2017, Intel Corp.
      9  * All rights reserved.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions, and the following disclaimer,
     16  *    without modification.
     17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18  *    substantially similar to the "NO WARRANTY" disclaimer below
     19  *    ("Disclaimer") and any redistribution must be conditioned upon
     20  *    including a substantially similar Disclaimer requirement for further
     21  *    binary redistribution.
     22  * 3. Neither the names of the above-listed copyright holders nor the names
     23  *    of any contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * Alternatively, this software may be distributed under the terms of the
     27  * GNU General Public License ("GPL") version 2 as published by the Free
     28  * Software Foundation.
     29  *
     30  * NO WARRANTY
     31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41  * POSSIBILITY OF SUCH DAMAGES.
     42  */
     43 
     44 #define ACPI_CREATE_PREDEFINED_TABLE
     45 #define ACPI_CREATE_RESOURCE_TABLE
     46 
     47 #include "aslcompiler.h"
     48 #include "aslcompiler.y.h"
     49 #include "acpredef.h"
     50 #include "acnamesp.h"
     51 
     52 
     53 #define _COMPONENT          ACPI_COMPILER
     54         ACPI_MODULE_NAME    ("aslpredef")
     55 
     56 
     57 /* Local prototypes */
     58 
     59 static void
     60 ApCheckForUnexpectedReturnValue (
     61     ACPI_PARSE_OBJECT       *Op,
     62     ASL_METHOD_INFO         *MethodInfo);
     63 
     64 static UINT32
     65 ApCheckForSpecialName (
     66     ACPI_PARSE_OBJECT       *Op,
     67     char                    *Name);
     68 
     69 
     70 /*******************************************************************************
     71  *
     72  * FUNCTION:    ApCheckForPredefinedMethod
     73  *
     74  * PARAMETERS:  Op              - A parse node of type "METHOD".
     75  *              MethodInfo      - Saved info about this method
     76  *
     77  * RETURN:      None
     78  *
     79  * DESCRIPTION: If method is a predefined name, check that the number of
     80  *              arguments and the return type (returns a value or not)
     81  *              is correct.
     82  *
     83  ******************************************************************************/
     84 
     85 BOOLEAN
     86 ApCheckForPredefinedMethod (
     87     ACPI_PARSE_OBJECT       *Op,
     88     ASL_METHOD_INFO         *MethodInfo)
     89 {
     90     UINT32                      Index;
     91     UINT32                      RequiredArgCount;
     92     const ACPI_PREDEFINED_INFO  *ThisName;
     93 
     94 
     95     /* Check for a match against the predefined name list */
     96 
     97     Index = ApCheckForPredefinedName (Op, Op->Asl.NameSeg);
     98 
     99     switch (Index)
    100     {
    101     case ACPI_NOT_RESERVED_NAME:        /* No underscore or _Txx or _xxx name not matched */
    102     case ACPI_PREDEFINED_NAME:          /* Resource Name or reserved scope name */
    103     case ACPI_COMPILER_RESERVED_NAME:   /* A _Txx that was not emitted by compiler */
    104 
    105         /* Just return, nothing to do */
    106         return (FALSE);
    107 
    108 
    109     case ACPI_EVENT_RESERVED_NAME:      /* _Lxx/_Exx/_Wxx/_Qxx methods */
    110 
    111         Gbl_ReservedMethods++;
    112 
    113         /* NumArguments must be zero for all _Lxx/_Exx/_Wxx/_Qxx methods */
    114 
    115         if (MethodInfo->NumArguments != 0)
    116         {
    117             snprintf (MsgBuffer, sizeof(MsgBuffer), "%s requires %u", Op->Asl.ExternalName, 0);
    118 
    119             AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op,
    120                 MsgBuffer);
    121         }
    122         break;
    123 
    124 
    125     default:
    126         /*
    127          * Matched a predefined method name - validate the ASL-defined
    128          * argument count against the ACPI specification.
    129          *
    130          * Some methods are allowed to have a "minimum" number of args
    131          * (_SCP) because their definition in ACPI has changed over time.
    132          */
    133         Gbl_ReservedMethods++;
    134         ThisName = &AcpiGbl_PredefinedMethods[Index];
    135         RequiredArgCount = METHOD_GET_ARG_COUNT (ThisName->Info.ArgumentList);
    136 
    137         if (MethodInfo->NumArguments != RequiredArgCount)
    138         {
    139             snprintf (MsgBuffer, sizeof(MsgBuffer), "%4.4s requires %u",
    140                 ThisName->Info.Name, RequiredArgCount);
    141 
    142             if (MethodInfo->NumArguments < RequiredArgCount)
    143             {
    144                 AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_LO, Op,
    145                     MsgBuffer);
    146             }
    147             else if ((MethodInfo->NumArguments > RequiredArgCount) &&
    148                 !(ThisName->Info.ArgumentList & ARG_COUNT_IS_MINIMUM))
    149             {
    150                 AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op,
    151                     MsgBuffer);
    152             }
    153         }
    154 
    155         /*
    156          * Check if method returns no value, but the predefined name is
    157          * required to return a value
    158          */
    159         if (MethodInfo->NumReturnNoValue &&
    160             ThisName->Info.ExpectedBtypes)
    161         {
    162             AcpiUtGetExpectedReturnTypes (StringBuffer,
    163                 ThisName->Info.ExpectedBtypes);
    164 
    165             snprintf (MsgBuffer, sizeof(MsgBuffer), "%s required for %4.4s",
    166                 StringBuffer, ThisName->Info.Name);
    167 
    168             AslError (ASL_WARNING, ASL_MSG_RESERVED_RETURN_VALUE, Op,
    169                 MsgBuffer);
    170         }
    171         break;
    172     }
    173 
    174     return (TRUE);
    175 }
    176 
    177 
    178 /*******************************************************************************
    179  *
    180  * FUNCTION:    ApCheckForUnexpectedReturnValue
    181  *
    182  * PARAMETERS:  Op              - A parse node of type "RETURN".
    183  *              MethodInfo      - Saved info about this method
    184  *
    185  * RETURN:      None
    186  *
    187  * DESCRIPTION: Check for an unexpected return value from a predefined method.
    188  *              Invoked for predefined methods that are defined to not return
    189  *              any value. If there is a return value, issue a remark, since
    190  *              the ASL writer may be confused as to the method definition
    191  *              and/or functionality.
    192  *
    193  * Note: We ignore all return values of "Zero", since this is what a standalone
    194  *       Return() statement will always generate -- so we ignore it here --
    195  *       i.e., there is no difference between Return() and Return(Zero).
    196  *       Also, a null Return() will be disassembled to return(Zero) -- so, we
    197  *       don't want to generate extraneous remarks/warnings for a disassembled
    198  *       ASL file.
    199  *
    200  ******************************************************************************/
    201 
    202 static void
    203 ApCheckForUnexpectedReturnValue (
    204     ACPI_PARSE_OBJECT       *Op,
    205     ASL_METHOD_INFO         *MethodInfo)
    206 {
    207     ACPI_PARSE_OBJECT       *ReturnValueOp;
    208 
    209 
    210     /* Ignore Return() and Return(Zero) (they are the same) */
    211 
    212     ReturnValueOp = Op->Asl.Child;
    213     if (ReturnValueOp->Asl.ParseOpcode == PARSEOP_ZERO)
    214     {
    215         return;
    216     }
    217 
    218     /* We have a valid return value, but the reserved name did not expect it */
    219 
    220     AslError (ASL_WARNING, ASL_MSG_RESERVED_NO_RETURN_VAL,
    221         Op, MethodInfo->Op->Asl.ExternalName);
    222 }
    223 
    224 
    225 /*******************************************************************************
    226  *
    227  * FUNCTION:    ApCheckPredefinedReturnValue
    228  *
    229  * PARAMETERS:  Op              - A parse node of type "RETURN".
    230  *              MethodInfo      - Saved info about this method
    231  *
    232  * RETURN:      None
    233  *
    234  * DESCRIPTION: If method is a predefined name, attempt to validate the return
    235  *              value. Only "static" types can be validated - a simple return
    236  *              of an integer/string/buffer/package or a named reference to
    237  *              a static object. Values such as a Localx or Argx or a control
    238  *              method invocation are not checked. Issue a warning if there is
    239  *              a valid return value, but the reserved method defines no
    240  *              return value.
    241  *
    242  ******************************************************************************/
    243 
    244 void
    245 ApCheckPredefinedReturnValue (
    246     ACPI_PARSE_OBJECT       *Op,
    247     ASL_METHOD_INFO         *MethodInfo)
    248 {
    249     UINT32                      Index;
    250     ACPI_PARSE_OBJECT           *ReturnValueOp;
    251     const ACPI_PREDEFINED_INFO  *ThisName;
    252 
    253 
    254     /*
    255      * Check parent method for a match against the predefined name list.
    256      *
    257      * Note: Disable compiler errors/warnings because any errors will be
    258      * caught when analyzing the parent method. Eliminates duplicate errors.
    259      */
    260     Gbl_AllExceptionsDisabled = TRUE;
    261     Index = ApCheckForPredefinedName (MethodInfo->Op,
    262         MethodInfo->Op->Asl.NameSeg);
    263     Gbl_AllExceptionsDisabled = FALSE;
    264 
    265     switch (Index)
    266     {
    267     case ACPI_EVENT_RESERVED_NAME:      /* _Lxx/_Exx/_Wxx/_Qxx methods */
    268 
    269         /* No return value expected, warn if there is one */
    270 
    271         ApCheckForUnexpectedReturnValue (Op, MethodInfo);
    272         return;
    273 
    274     case ACPI_NOT_RESERVED_NAME:        /* No underscore or _Txx or _xxx name not matched */
    275     case ACPI_PREDEFINED_NAME:          /* Resource Name or reserved scope name */
    276     case ACPI_COMPILER_RESERVED_NAME:   /* A _Txx that was not emitted by compiler */
    277 
    278         /* Just return, nothing to do */
    279         return;
    280 
    281     default: /* A standard predefined ACPI name */
    282 
    283         ThisName = &AcpiGbl_PredefinedMethods[Index];
    284         if (!ThisName->Info.ExpectedBtypes)
    285         {
    286             /* No return value expected, warn if there is one */
    287 
    288             ApCheckForUnexpectedReturnValue (Op, MethodInfo);
    289             return;
    290         }
    291 
    292         /* Get the object returned, it is the next argument */
    293 
    294         ReturnValueOp = Op->Asl.Child;
    295         switch (ReturnValueOp->Asl.ParseOpcode)
    296         {
    297         case PARSEOP_ZERO:
    298         case PARSEOP_ONE:
    299         case PARSEOP_ONES:
    300         case PARSEOP_INTEGER:
    301         case PARSEOP_STRING_LITERAL:
    302         case PARSEOP_BUFFER:
    303         case PARSEOP_PACKAGE:
    304 
    305             /* Static data return object - check against expected type */
    306 
    307             ApCheckObjectType (ThisName->Info.Name, ReturnValueOp,
    308                 ThisName->Info.ExpectedBtypes, ACPI_NOT_PACKAGE_ELEMENT);
    309 
    310             /* For packages, check the individual package elements */
    311 
    312             if (ReturnValueOp->Asl.ParseOpcode == PARSEOP_PACKAGE)
    313             {
    314                 ApCheckPackage (ReturnValueOp, ThisName);
    315             }
    316             break;
    317 
    318         default:
    319             /*
    320              * All other ops are very difficult or impossible to typecheck at
    321              * compile time. These include all Localx, Argx, and method
    322              * invocations. Also, NAMESEG and NAMESTRING because the type of
    323              * any named object can be changed at runtime (for example,
    324              * CopyObject will change the type of the target object.)
    325              */
    326             break;
    327         }
    328     }
    329 }
    330 
    331 
    332 /*******************************************************************************
    333  *
    334  * FUNCTION:    ApCheckForPredefinedObject
    335  *
    336  * PARAMETERS:  Op              - A parse node
    337  *              Name            - The ACPI name to be checked
    338  *
    339  * RETURN:      None
    340  *
    341  * DESCRIPTION: Check for a predefined name for a static object (created via
    342  *              the ASL Name operator). If it is a predefined ACPI name, ensure
    343  *              that the name does not require any arguments (which would
    344  *              require a control method implemenation of the name), and that
    345  *              the type of the object is one of the expected types for the
    346  *              predefined name.
    347  *
    348  ******************************************************************************/
    349 
    350 void
    351 ApCheckForPredefinedObject (
    352     ACPI_PARSE_OBJECT       *Op,
    353     char                    *Name)
    354 {
    355     UINT32                      Index;
    356     ACPI_PARSE_OBJECT           *ObjectOp;
    357     const ACPI_PREDEFINED_INFO  *ThisName;
    358 
    359 
    360     /*
    361      * Check for a real predefined name -- not a resource descriptor name
    362      * or a predefined scope name
    363      */
    364     Index = ApCheckForPredefinedName (Op, Name);
    365 
    366     switch (Index)
    367     {
    368     case ACPI_NOT_RESERVED_NAME:        /* No underscore or _Txx or _xxx name not matched */
    369     case ACPI_PREDEFINED_NAME:          /* Resource Name or reserved scope name */
    370     case ACPI_COMPILER_RESERVED_NAME:   /* A _Txx that was not emitted by compiler */
    371 
    372         /* Nothing to do */
    373         return;
    374 
    375     case ACPI_EVENT_RESERVED_NAME:      /* _Lxx/_Exx/_Wxx/_Qxx methods */
    376 
    377         /*
    378          * These names must be control methods, by definition in ACPI spec.
    379          * Also because they are defined to return no value. None of them
    380          * require any arguments.
    381          */
    382         AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op,
    383             "with zero arguments");
    384         return;
    385 
    386     default:
    387 
    388         break;
    389     }
    390 
    391     /* A standard predefined ACPI name */
    392 
    393     /*
    394      * If this predefined name requires input arguments, then
    395      * it must be implemented as a control method
    396      */
    397     ThisName = &AcpiGbl_PredefinedMethods[Index];
    398     if (METHOD_GET_ARG_COUNT (ThisName->Info.ArgumentList) > 0)
    399     {
    400         AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op,
    401             "with arguments");
    402         return;
    403     }
    404 
    405     /*
    406      * If no return value is expected from this predefined name, then
    407      * it follows that it must be implemented as a control method
    408      * (with zero args, because the args > 0 case was handled above)
    409      * Examples are: _DIS, _INI, _IRC, _OFF, _ON, _PSx
    410      */
    411     if (!ThisName->Info.ExpectedBtypes)
    412     {
    413         AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op,
    414             "with zero arguments");
    415         return;
    416     }
    417 
    418     /* Typecheck the actual object, it is the next argument */
    419 
    420     ObjectOp = Op->Asl.Child->Asl.Next;
    421     ApCheckObjectType (ThisName->Info.Name, Op->Asl.Child->Asl.Next,
    422         ThisName->Info.ExpectedBtypes, ACPI_NOT_PACKAGE_ELEMENT);
    423 
    424     /* For packages, check the individual package elements */
    425 
    426     if (ObjectOp->Asl.ParseOpcode == PARSEOP_PACKAGE)
    427     {
    428         ApCheckPackage (ObjectOp, ThisName);
    429     }
    430 }
    431 
    432 
    433 /*******************************************************************************
    434  *
    435  * FUNCTION:    ApCheckForPredefinedName
    436  *
    437  * PARAMETERS:  Op              - A parse node
    438  *              Name            - NameSeg to check
    439  *
    440  * RETURN:      None
    441  *
    442  * DESCRIPTION: Check a NameSeg against the reserved list.
    443  *
    444  ******************************************************************************/
    445 
    446 UINT32
    447 ApCheckForPredefinedName (
    448     ACPI_PARSE_OBJECT       *Op,
    449     char                    *Name)
    450 {
    451     UINT32                      i;
    452     const ACPI_PREDEFINED_INFO  *ThisName;
    453 
    454 
    455     if (Name[0] == 0)
    456     {
    457         AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op,
    458             "zero length name found");
    459     }
    460 
    461     /* All reserved names are prefixed with a single underscore */
    462 
    463     if (Name[0] != '_')
    464     {
    465         return (ACPI_NOT_RESERVED_NAME);
    466     }
    467 
    468     /* Check for a standard predefined method name */
    469 
    470     ThisName = AcpiGbl_PredefinedMethods;
    471     for (i = 0; ThisName->Info.Name[0]; i++)
    472     {
    473         if (ACPI_COMPARE_NAME (Name, ThisName->Info.Name))
    474         {
    475             /* Return index into predefined array */
    476             return (i);
    477         }
    478 
    479         ThisName++; /* Does not account for extra package data, but is OK */
    480     }
    481 
    482     /* Check for resource names and predefined scope names */
    483 
    484     ThisName = AcpiGbl_ResourceNames;
    485     while (ThisName->Info.Name[0])
    486     {
    487         if (ACPI_COMPARE_NAME (Name, ThisName->Info.Name))
    488         {
    489             return (ACPI_PREDEFINED_NAME);
    490         }
    491 
    492         ThisName++;
    493     }
    494 
    495     ThisName = AcpiGbl_ScopeNames;
    496     while (ThisName->Info.Name[0])
    497     {
    498         if (ACPI_COMPARE_NAME (Name, ThisName->Info.Name))
    499         {
    500             return (ACPI_PREDEFINED_NAME);
    501         }
    502 
    503         ThisName++;
    504     }
    505 
    506     /* Check for _Lxx/_Exx/_Wxx/_Qxx/_T_x. Warning if unknown predefined name */
    507 
    508     return (ApCheckForSpecialName (Op, Name));
    509 }
    510 
    511 
    512 /*******************************************************************************
    513  *
    514  * FUNCTION:    ApCheckForSpecialName
    515  *
    516  * PARAMETERS:  Op              - A parse node
    517  *              Name            - NameSeg to check
    518  *
    519  * RETURN:      None
    520  *
    521  * DESCRIPTION: Check for the "special" predefined names -
    522  *              _Lxx, _Exx, _Qxx, _Wxx, and _T_x
    523  *
    524  ******************************************************************************/
    525 
    526 static UINT32
    527 ApCheckForSpecialName (
    528     ACPI_PARSE_OBJECT       *Op,
    529     char                    *Name)
    530 {
    531 
    532     /*
    533      * Check for the "special" predefined names. We already know that the
    534      * first character is an underscore.
    535      *   GPE:  _Lxx
    536      *   GPE:  _Exx
    537      *   GPE:  _Wxx
    538      *   EC:   _Qxx
    539      */
    540     if ((Name[1] == 'L') ||
    541         (Name[1] == 'E') ||
    542         (Name[1] == 'W') ||
    543         (Name[1] == 'Q'))
    544     {
    545         /* The next two characters must be hex digits */
    546 
    547         if ((isxdigit ((int) Name[2])) &&
    548             (isxdigit ((int) Name[3])))
    549         {
    550             return (ACPI_EVENT_RESERVED_NAME);
    551         }
    552     }
    553 
    554     /* Check for the names reserved for the compiler itself: _T_x */
    555 
    556     else if ((Op->Asl.ExternalName[1] == 'T') &&
    557              (Op->Asl.ExternalName[2] == '_'))
    558     {
    559         /* Ignore if actually emitted by the compiler */
    560 
    561         if (Op->Asl.CompileFlags & NODE_COMPILER_EMITTED)
    562         {
    563             return (ACPI_NOT_RESERVED_NAME);
    564         }
    565 
    566         /*
    567          * Was not actually emitted by the compiler. This is a special case,
    568          * however. If the ASL code being compiled was the result of a
    569          * dissasembly, it may possibly contain valid compiler-emitted names
    570          * of the form "_T_x". We don't want to issue an error or even a
    571          * warning and force the user to manually change the names. So, we
    572          * will issue a remark instead.
    573          */
    574         AslError (ASL_REMARK, ASL_MSG_COMPILER_RESERVED,
    575             Op, Op->Asl.ExternalName);
    576         return (ACPI_COMPILER_RESERVED_NAME);
    577     }
    578 
    579     /*
    580      * The name didn't match any of the known predefined names. Flag it as a
    581      * warning, since the entire namespace starting with an underscore is
    582      * reserved by the ACPI spec.
    583      */
    584     AslError (ASL_WARNING, ASL_MSG_UNKNOWN_RESERVED_NAME,
    585         Op, Op->Asl.ExternalName);
    586 
    587     return (ACPI_NOT_RESERVED_NAME);
    588 }
    589 
    590 
    591 /*******************************************************************************
    592  *
    593  * FUNCTION:    ApCheckObjectType
    594  *
    595  * PARAMETERS:  PredefinedName  - Name of the predefined object we are checking
    596  *              Op              - Current parse node
    597  *              ExpectedBtypes  - Bitmap of expected return type(s)
    598  *              PackageIndex    - Index of object within parent package (if
    599  *                                applicable - ACPI_NOT_PACKAGE_ELEMENT
    600  *                                otherwise)
    601  *
    602  * RETURN:      None
    603  *
    604  * DESCRIPTION: Check if the object type is one of the types that is expected
    605  *              by the predefined name. Only a limited number of object types
    606  *              can be returned by the predefined names.
    607  *
    608  ******************************************************************************/
    609 
    610 ACPI_STATUS
    611 ApCheckObjectType (
    612     const char              *PredefinedName,
    613     ACPI_PARSE_OBJECT       *Op,
    614     UINT32                  ExpectedBtypes,
    615     UINT32                  PackageIndex)
    616 {
    617     UINT32                  ReturnBtype;
    618     char                    *TypeName;
    619 
    620 
    621     if (!Op)
    622     {
    623         return (AE_TYPE);
    624     }
    625 
    626     /* Map the parse opcode to a bitmapped return type (RTYPE) */
    627 
    628     switch (Op->Asl.ParseOpcode)
    629     {
    630     case PARSEOP_ZERO:
    631     case PARSEOP_ONE:
    632     case PARSEOP_ONES:
    633     case PARSEOP_INTEGER:
    634 
    635         ReturnBtype = ACPI_RTYPE_INTEGER;
    636         TypeName = "Integer";
    637         break;
    638 
    639     case PARSEOP_STRING_LITERAL:
    640 
    641         ReturnBtype = ACPI_RTYPE_STRING;
    642         TypeName = "String";
    643         break;
    644 
    645     case PARSEOP_BUFFER:
    646 
    647         ReturnBtype = ACPI_RTYPE_BUFFER;
    648         TypeName = "Buffer";
    649         break;
    650 
    651     case PARSEOP_PACKAGE:
    652     case PARSEOP_VAR_PACKAGE:
    653 
    654         ReturnBtype = ACPI_RTYPE_PACKAGE;
    655         TypeName = "Package";
    656         break;
    657 
    658     case PARSEOP_NAMESEG:
    659     case PARSEOP_NAMESTRING:
    660         /*
    661          * Ignore any named references within a package object.
    662          *
    663          * For Package objects, references are allowed instead of any of the
    664          * standard data types (Integer/String/Buffer/Package). These
    665          * references are resolved at runtime. NAMESEG and NAMESTRING are
    666          * impossible to typecheck at compile time because the type of
    667          * any named object can be changed at runtime (for example,
    668          * CopyObject will change the type of the target object).
    669          */
    670         if (PackageIndex != ACPI_NOT_PACKAGE_ELEMENT)
    671         {
    672             return (AE_OK);
    673         }
    674 
    675         ReturnBtype = ACPI_RTYPE_REFERENCE;
    676         TypeName = "Reference";
    677         break;
    678 
    679     default:
    680 
    681         /* Not one of the supported object types */
    682 
    683         TypeName = UtGetOpName (Op->Asl.ParseOpcode);
    684         goto TypeErrorExit;
    685     }
    686 
    687     /* Exit if the object is one of the expected types */
    688 
    689     if (ReturnBtype & ExpectedBtypes)
    690     {
    691         return (AE_OK);
    692     }
    693 
    694 
    695 TypeErrorExit:
    696 
    697     /* Format the expected types and emit an error message */
    698 
    699     AcpiUtGetExpectedReturnTypes (StringBuffer, ExpectedBtypes);
    700 
    701     if (PackageIndex == ACPI_NOT_PACKAGE_ELEMENT)
    702     {
    703         snprintf (MsgBuffer, sizeof(MsgBuffer), "%4.4s: found %s, %s required",
    704             PredefinedName, TypeName, StringBuffer);
    705     }
    706     else
    707     {
    708         snprintf (MsgBuffer, sizeof(MsgBuffer), "%4.4s: found %s at index %u, %s required",
    709             PredefinedName, TypeName, PackageIndex, StringBuffer);
    710     }
    711 
    712     AslError (ASL_ERROR, ASL_MSG_RESERVED_OPERAND_TYPE, Op, MsgBuffer);
    713     return (AE_TYPE);
    714 }
    715 
    716 
    717 /*******************************************************************************
    718  *
    719  * FUNCTION:    ApDisplayReservedNames
    720  *
    721  * PARAMETERS:  None
    722  *
    723  * RETURN:      None
    724  *
    725  * DESCRIPTION: Dump information about the ACPI predefined names and predefined
    726  *              resource descriptor names.
    727  *
    728  ******************************************************************************/
    729 
    730 void
    731 ApDisplayReservedNames (
    732     void)
    733 {
    734     const ACPI_PREDEFINED_INFO  *ThisName;
    735     UINT32                      Count;
    736     UINT32                      NumTypes;
    737 
    738 
    739     /*
    740      * Predefined names/methods
    741      */
    742     printf ("\nPredefined Name Information\n\n");
    743 
    744     Count = 0;
    745     ThisName = AcpiGbl_PredefinedMethods;
    746     while (ThisName->Info.Name[0])
    747     {
    748         AcpiUtDisplayPredefinedMethod (MsgBuffer, ThisName, FALSE);
    749         Count++;
    750         ThisName = AcpiUtGetNextPredefinedMethod (ThisName);
    751     }
    752 
    753     printf ("%u Predefined Names are recognized\n", Count);
    754 
    755     /*
    756      * Resource Descriptor names
    757      */
    758     printf ("\nPredefined Names for Resource Descriptor Fields\n\n");
    759 
    760     Count = 0;
    761     ThisName = AcpiGbl_ResourceNames;
    762     while (ThisName->Info.Name[0])
    763     {
    764         NumTypes = AcpiUtGetResourceBitWidth (MsgBuffer,
    765             ThisName->Info.ArgumentList);
    766 
    767         printf ("%4.4s    Field is %s bits wide%s\n",
    768             ThisName->Info.Name, MsgBuffer,
    769             (NumTypes > 1) ? " (depending on descriptor type)" : "");
    770 
    771         Count++;
    772         ThisName++;
    773     }
    774 
    775     printf ("%u Resource Descriptor Field Names are recognized\n", Count);
    776 
    777     /*
    778      * Predefined scope names
    779      */
    780     printf ("\nPredefined Scope/Device Names (automatically created at root)\n\n");
    781 
    782     ThisName = AcpiGbl_ScopeNames;
    783     while (ThisName->Info.Name[0])
    784     {
    785         printf ("%4.4s    Scope/Device\n", ThisName->Info.Name);
    786         ThisName++;
    787     }
    788 }
    789