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