Home | History | Annotate | Line # | Download | only in compiler
aslmethod.c revision 1.1.1.1.10.3
      1  1.1.1.1.10.2       tls /******************************************************************************
      2  1.1.1.1.10.2       tls  *
      3  1.1.1.1.10.2       tls  * Module Name: aslmethod.c - Control method analysis walk
      4  1.1.1.1.10.2       tls  *
      5  1.1.1.1.10.2       tls  *****************************************************************************/
      6  1.1.1.1.10.2       tls 
      7  1.1.1.1.10.2       tls /*
      8  1.1.1.1.10.3  jdolecek  * Copyright (C) 2000 - 2017, Intel Corp.
      9  1.1.1.1.10.2       tls  * All rights reserved.
     10  1.1.1.1.10.2       tls  *
     11  1.1.1.1.10.2       tls  * Redistribution and use in source and binary forms, with or without
     12  1.1.1.1.10.2       tls  * modification, are permitted provided that the following conditions
     13  1.1.1.1.10.2       tls  * are met:
     14  1.1.1.1.10.2       tls  * 1. Redistributions of source code must retain the above copyright
     15  1.1.1.1.10.2       tls  *    notice, this list of conditions, and the following disclaimer,
     16  1.1.1.1.10.2       tls  *    without modification.
     17  1.1.1.1.10.2       tls  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18  1.1.1.1.10.2       tls  *    substantially similar to the "NO WARRANTY" disclaimer below
     19  1.1.1.1.10.2       tls  *    ("Disclaimer") and any redistribution must be conditioned upon
     20  1.1.1.1.10.2       tls  *    including a substantially similar Disclaimer requirement for further
     21  1.1.1.1.10.2       tls  *    binary redistribution.
     22  1.1.1.1.10.2       tls  * 3. Neither the names of the above-listed copyright holders nor the names
     23  1.1.1.1.10.2       tls  *    of any contributors may be used to endorse or promote products derived
     24  1.1.1.1.10.2       tls  *    from this software without specific prior written permission.
     25  1.1.1.1.10.2       tls  *
     26  1.1.1.1.10.2       tls  * Alternatively, this software may be distributed under the terms of the
     27  1.1.1.1.10.2       tls  * GNU General Public License ("GPL") version 2 as published by the Free
     28  1.1.1.1.10.2       tls  * Software Foundation.
     29  1.1.1.1.10.2       tls  *
     30  1.1.1.1.10.2       tls  * NO WARRANTY
     31  1.1.1.1.10.2       tls  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32  1.1.1.1.10.2       tls  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33  1.1.1.1.10.2       tls  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34  1.1.1.1.10.2       tls  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35  1.1.1.1.10.2       tls  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36  1.1.1.1.10.2       tls  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37  1.1.1.1.10.2       tls  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38  1.1.1.1.10.2       tls  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39  1.1.1.1.10.2       tls  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40  1.1.1.1.10.2       tls  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41  1.1.1.1.10.2       tls  * POSSIBILITY OF SUCH DAMAGES.
     42  1.1.1.1.10.2       tls  */
     43  1.1.1.1.10.2       tls 
     44  1.1.1.1.10.2       tls #include "aslcompiler.h"
     45  1.1.1.1.10.2       tls #include "aslcompiler.y.h"
     46  1.1.1.1.10.2       tls #include "acparser.h"
     47  1.1.1.1.10.2       tls #include "amlcode.h"
     48  1.1.1.1.10.2       tls 
     49  1.1.1.1.10.2       tls 
     50  1.1.1.1.10.2       tls #define _COMPONENT          ACPI_COMPILER
     51  1.1.1.1.10.2       tls         ACPI_MODULE_NAME    ("aslmethod")
     52  1.1.1.1.10.2       tls 
     53  1.1.1.1.10.2       tls 
     54  1.1.1.1.10.2       tls /* Local prototypes */
     55  1.1.1.1.10.2       tls 
     56  1.1.1.1.10.3  jdolecek static void
     57  1.1.1.1.10.2       tls MtCheckNamedObjectInMethod (
     58  1.1.1.1.10.2       tls     ACPI_PARSE_OBJECT       *Op,
     59  1.1.1.1.10.2       tls     ASL_METHOD_INFO         *MethodInfo);
     60  1.1.1.1.10.2       tls 
     61  1.1.1.1.10.2       tls 
     62  1.1.1.1.10.2       tls /*******************************************************************************
     63  1.1.1.1.10.2       tls  *
     64  1.1.1.1.10.2       tls  * FUNCTION:    MtMethodAnalysisWalkBegin
     65  1.1.1.1.10.2       tls  *
     66  1.1.1.1.10.2       tls  * PARAMETERS:  ASL_WALK_CALLBACK
     67  1.1.1.1.10.2       tls  *
     68  1.1.1.1.10.2       tls  * RETURN:      Status
     69  1.1.1.1.10.2       tls  *
     70  1.1.1.1.10.2       tls  * DESCRIPTION: Descending callback for the analysis walk. Check methods for:
     71  1.1.1.1.10.2       tls  *              1) Initialized local variables
     72  1.1.1.1.10.2       tls  *              2) Valid arguments
     73  1.1.1.1.10.2       tls  *              3) Return types
     74  1.1.1.1.10.2       tls  *
     75  1.1.1.1.10.2       tls  ******************************************************************************/
     76  1.1.1.1.10.2       tls 
     77  1.1.1.1.10.2       tls ACPI_STATUS
     78  1.1.1.1.10.2       tls MtMethodAnalysisWalkBegin (
     79  1.1.1.1.10.2       tls     ACPI_PARSE_OBJECT       *Op,
     80  1.1.1.1.10.2       tls     UINT32                  Level,
     81  1.1.1.1.10.2       tls     void                    *Context)
     82  1.1.1.1.10.2       tls {
     83  1.1.1.1.10.2       tls     ASL_ANALYSIS_WALK_INFO  *WalkInfo = (ASL_ANALYSIS_WALK_INFO *) Context;
     84  1.1.1.1.10.2       tls     ASL_METHOD_INFO         *MethodInfo = WalkInfo->MethodStack;
     85  1.1.1.1.10.2       tls     ACPI_PARSE_OBJECT       *Next;
     86  1.1.1.1.10.2       tls     UINT32                  RegisterNumber;
     87  1.1.1.1.10.2       tls     UINT32                  i;
     88  1.1.1.1.10.2       tls     char                    LocalName[] = "Local0";
     89  1.1.1.1.10.2       tls     char                    ArgName[] = "Arg0";
     90  1.1.1.1.10.2       tls     ACPI_PARSE_OBJECT       *ArgNode;
     91  1.1.1.1.10.2       tls     ACPI_PARSE_OBJECT       *NextType;
     92  1.1.1.1.10.2       tls     ACPI_PARSE_OBJECT       *NextParamType;
     93  1.1.1.1.10.2       tls     UINT8                   ActualArgs = 0;
     94  1.1.1.1.10.2       tls 
     95  1.1.1.1.10.2       tls 
     96  1.1.1.1.10.3  jdolecek     /* Build cross-reference output file if requested */
     97  1.1.1.1.10.3  jdolecek 
     98  1.1.1.1.10.3  jdolecek     if (Gbl_CrossReferenceOutput)
     99  1.1.1.1.10.3  jdolecek     {
    100  1.1.1.1.10.3  jdolecek         OtXrefWalkPart1 (Op, Level, MethodInfo);
    101  1.1.1.1.10.3  jdolecek     }
    102  1.1.1.1.10.3  jdolecek 
    103  1.1.1.1.10.2       tls     switch (Op->Asl.ParseOpcode)
    104  1.1.1.1.10.2       tls     {
    105  1.1.1.1.10.2       tls     case PARSEOP_METHOD:
    106  1.1.1.1.10.2       tls 
    107  1.1.1.1.10.2       tls         TotalMethods++;
    108  1.1.1.1.10.2       tls 
    109  1.1.1.1.10.2       tls         /* Create and init method info */
    110  1.1.1.1.10.2       tls 
    111  1.1.1.1.10.3  jdolecek         MethodInfo = UtLocalCalloc (sizeof (ASL_METHOD_INFO));
    112  1.1.1.1.10.2       tls         MethodInfo->Next = WalkInfo->MethodStack;
    113  1.1.1.1.10.2       tls         MethodInfo->Op = Op;
    114  1.1.1.1.10.2       tls 
    115  1.1.1.1.10.2       tls         WalkInfo->MethodStack = MethodInfo;
    116  1.1.1.1.10.2       tls 
    117  1.1.1.1.10.3  jdolecek         /*
    118  1.1.1.1.10.3  jdolecek          * Special handling for _PSx methods. Dependency rules (same scope):
    119  1.1.1.1.10.3  jdolecek          *
    120  1.1.1.1.10.3  jdolecek          * 1) _PS0 - One of these must exist: _PS1, _PS2, _PS3
    121  1.1.1.1.10.3  jdolecek          * 2) _PS1/_PS2/_PS3: A _PS0 must exist
    122  1.1.1.1.10.3  jdolecek          */
    123  1.1.1.1.10.3  jdolecek         if (ACPI_COMPARE_NAME (METHOD_NAME__PS0, Op->Asl.NameSeg))
    124  1.1.1.1.10.3  jdolecek         {
    125  1.1.1.1.10.3  jdolecek             /* For _PS0, one of _PS1/_PS2/_PS3 must exist */
    126  1.1.1.1.10.3  jdolecek 
    127  1.1.1.1.10.3  jdolecek             if ((!ApFindNameInScope (METHOD_NAME__PS1, Op)) &&
    128  1.1.1.1.10.3  jdolecek                 (!ApFindNameInScope (METHOD_NAME__PS2, Op)) &&
    129  1.1.1.1.10.3  jdolecek                 (!ApFindNameInScope (METHOD_NAME__PS3, Op)))
    130  1.1.1.1.10.3  jdolecek             {
    131  1.1.1.1.10.3  jdolecek                 AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op,
    132  1.1.1.1.10.3  jdolecek                     "_PS0 requires one of _PS1/_PS2/_PS3 in same scope");
    133  1.1.1.1.10.3  jdolecek             }
    134  1.1.1.1.10.3  jdolecek         }
    135  1.1.1.1.10.3  jdolecek         else if (
    136  1.1.1.1.10.3  jdolecek             ACPI_COMPARE_NAME (METHOD_NAME__PS1, Op->Asl.NameSeg) ||
    137  1.1.1.1.10.3  jdolecek             ACPI_COMPARE_NAME (METHOD_NAME__PS2, Op->Asl.NameSeg) ||
    138  1.1.1.1.10.3  jdolecek             ACPI_COMPARE_NAME (METHOD_NAME__PS3, Op->Asl.NameSeg))
    139  1.1.1.1.10.3  jdolecek         {
    140  1.1.1.1.10.3  jdolecek             /* For _PS1/_PS2/_PS3, a _PS0 must exist */
    141  1.1.1.1.10.3  jdolecek 
    142  1.1.1.1.10.3  jdolecek             if (!ApFindNameInScope (METHOD_NAME__PS0, Op))
    143  1.1.1.1.10.3  jdolecek             {
    144  1.1.1.1.10.3  jdolecek                 sprintf (MsgBuffer,
    145  1.1.1.1.10.3  jdolecek                     "%4.4s requires _PS0 in same scope", Op->Asl.NameSeg);
    146  1.1.1.1.10.3  jdolecek 
    147  1.1.1.1.10.3  jdolecek                 AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op,
    148  1.1.1.1.10.3  jdolecek                     MsgBuffer);
    149  1.1.1.1.10.3  jdolecek             }
    150  1.1.1.1.10.3  jdolecek         }
    151  1.1.1.1.10.3  jdolecek 
    152  1.1.1.1.10.3  jdolecek         /* Get the name node */
    153  1.1.1.1.10.2       tls 
    154  1.1.1.1.10.2       tls         Next = Op->Asl.Child;
    155  1.1.1.1.10.2       tls 
    156  1.1.1.1.10.2       tls         /* Get the NumArguments node */
    157  1.1.1.1.10.2       tls 
    158  1.1.1.1.10.2       tls         Next = Next->Asl.Next;
    159  1.1.1.1.10.2       tls         MethodInfo->NumArguments = (UINT8)
    160  1.1.1.1.10.2       tls             (((UINT8) Next->Asl.Value.Integer) & 0x07);
    161  1.1.1.1.10.2       tls 
    162  1.1.1.1.10.2       tls         /* Get the SerializeRule and SyncLevel nodes, ignored here */
    163  1.1.1.1.10.2       tls 
    164  1.1.1.1.10.2       tls         Next = Next->Asl.Next;
    165  1.1.1.1.10.2       tls         MethodInfo->ShouldBeSerialized = (UINT8) Next->Asl.Value.Integer;
    166  1.1.1.1.10.2       tls 
    167  1.1.1.1.10.2       tls         Next = Next->Asl.Next;
    168  1.1.1.1.10.2       tls         ArgNode = Next;
    169  1.1.1.1.10.2       tls 
    170  1.1.1.1.10.2       tls         /* Get the ReturnType node */
    171  1.1.1.1.10.2       tls 
    172  1.1.1.1.10.2       tls         Next = Next->Asl.Next;
    173  1.1.1.1.10.2       tls 
    174  1.1.1.1.10.2       tls         NextType = Next->Asl.Child;
    175  1.1.1.1.10.2       tls         while (NextType)
    176  1.1.1.1.10.2       tls         {
    177  1.1.1.1.10.2       tls             /* Get and map each of the ReturnTypes */
    178  1.1.1.1.10.2       tls 
    179  1.1.1.1.10.2       tls             MethodInfo->ValidReturnTypes |= AnMapObjTypeToBtype (NextType);
    180  1.1.1.1.10.2       tls             NextType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
    181  1.1.1.1.10.2       tls             NextType = NextType->Asl.Next;
    182  1.1.1.1.10.2       tls         }
    183  1.1.1.1.10.2       tls 
    184  1.1.1.1.10.2       tls         /* Get the ParameterType node */
    185  1.1.1.1.10.2       tls 
    186  1.1.1.1.10.2       tls         Next = Next->Asl.Next;
    187  1.1.1.1.10.2       tls 
    188  1.1.1.1.10.2       tls         NextType = Next->Asl.Child;
    189  1.1.1.1.10.2       tls         while (NextType)
    190  1.1.1.1.10.2       tls         {
    191  1.1.1.1.10.2       tls             if (NextType->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
    192  1.1.1.1.10.2       tls             {
    193  1.1.1.1.10.2       tls                 NextParamType = NextType->Asl.Child;
    194  1.1.1.1.10.2       tls                 while (NextParamType)
    195  1.1.1.1.10.2       tls                 {
    196  1.1.1.1.10.3  jdolecek                     MethodInfo->ValidArgTypes[ActualArgs] |=
    197  1.1.1.1.10.3  jdolecek                         AnMapObjTypeToBtype (NextParamType);
    198  1.1.1.1.10.3  jdolecek 
    199  1.1.1.1.10.2       tls                     NextParamType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
    200  1.1.1.1.10.2       tls                     NextParamType = NextParamType->Asl.Next;
    201  1.1.1.1.10.2       tls                 }
    202  1.1.1.1.10.2       tls             }
    203  1.1.1.1.10.2       tls             else
    204  1.1.1.1.10.2       tls             {
    205  1.1.1.1.10.2       tls                 MethodInfo->ValidArgTypes[ActualArgs] =
    206  1.1.1.1.10.2       tls                     AnMapObjTypeToBtype (NextType);
    207  1.1.1.1.10.3  jdolecek 
    208  1.1.1.1.10.2       tls                 NextType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
    209  1.1.1.1.10.2       tls                 ActualArgs++;
    210  1.1.1.1.10.2       tls             }
    211  1.1.1.1.10.2       tls 
    212  1.1.1.1.10.2       tls             NextType = NextType->Asl.Next;
    213  1.1.1.1.10.2       tls         }
    214  1.1.1.1.10.2       tls 
    215  1.1.1.1.10.2       tls         if ((MethodInfo->NumArguments) &&
    216  1.1.1.1.10.2       tls             (MethodInfo->NumArguments != ActualArgs))
    217  1.1.1.1.10.2       tls         {
    218  1.1.1.1.10.2       tls             /* error: Param list did not match number of args */
    219  1.1.1.1.10.2       tls         }
    220  1.1.1.1.10.2       tls 
    221  1.1.1.1.10.2       tls         /* Allow numarguments == 0 for Function() */
    222  1.1.1.1.10.2       tls 
    223  1.1.1.1.10.2       tls         if ((!MethodInfo->NumArguments) && (ActualArgs))
    224  1.1.1.1.10.2       tls         {
    225  1.1.1.1.10.2       tls             MethodInfo->NumArguments = ActualArgs;
    226  1.1.1.1.10.2       tls             ArgNode->Asl.Value.Integer |= ActualArgs;
    227  1.1.1.1.10.2       tls         }
    228  1.1.1.1.10.2       tls 
    229  1.1.1.1.10.2       tls         /*
    230  1.1.1.1.10.2       tls          * Actual arguments are initialized at method entry.
    231  1.1.1.1.10.2       tls          * All other ArgX "registers" can be used as locals, so we
    232  1.1.1.1.10.2       tls          * track their initialization.
    233  1.1.1.1.10.2       tls          */
    234  1.1.1.1.10.2       tls         for (i = 0; i < MethodInfo->NumArguments; i++)
    235  1.1.1.1.10.2       tls         {
    236  1.1.1.1.10.2       tls             MethodInfo->ArgInitialized[i] = TRUE;
    237  1.1.1.1.10.2       tls         }
    238  1.1.1.1.10.2       tls         break;
    239  1.1.1.1.10.2       tls 
    240  1.1.1.1.10.2       tls     case PARSEOP_METHODCALL:
    241  1.1.1.1.10.2       tls 
    242  1.1.1.1.10.3  jdolecek         /* Check for a recursive method call */
    243  1.1.1.1.10.3  jdolecek 
    244  1.1.1.1.10.2       tls         if (MethodInfo &&
    245  1.1.1.1.10.2       tls            (Op->Asl.Node == MethodInfo->Op->Asl.Node))
    246  1.1.1.1.10.2       tls         {
    247  1.1.1.1.10.3  jdolecek             if (MethodInfo->CreatesNamedObjects)
    248  1.1.1.1.10.3  jdolecek             {
    249  1.1.1.1.10.3  jdolecek                 /*
    250  1.1.1.1.10.3  jdolecek                  * This is an error, as it will fail at runtime on all ACPI
    251  1.1.1.1.10.3  jdolecek                  * implementations. Any named object declarations will be
    252  1.1.1.1.10.3  jdolecek                  * executed twice, causing failure the second time. Note,
    253  1.1.1.1.10.3  jdolecek                  * this is independent of whether the method is declared
    254  1.1.1.1.10.3  jdolecek                  * Serialized, because the same thread is attempting to
    255  1.1.1.1.10.3  jdolecek                  * reenter the method, and this will always succeed.
    256  1.1.1.1.10.3  jdolecek                  */
    257  1.1.1.1.10.3  jdolecek                 AslDualParseOpError (ASL_ERROR, ASL_MSG_ILLEGAL_RECURSION, Op,
    258  1.1.1.1.10.3  jdolecek                     Op->Asl.Value.String, ASL_MSG_FOUND_HERE, MethodInfo->Op,
    259  1.1.1.1.10.3  jdolecek                     MethodInfo->Op->Asl.ExternalName);
    260  1.1.1.1.10.3  jdolecek             }
    261  1.1.1.1.10.3  jdolecek             else
    262  1.1.1.1.10.3  jdolecek             {
    263  1.1.1.1.10.3  jdolecek                 /* Method does not create objects, issue a remark */
    264  1.1.1.1.10.3  jdolecek 
    265  1.1.1.1.10.3  jdolecek                 AslError (ASL_REMARK, ASL_MSG_RECURSION, Op, Op->Asl.ExternalName);
    266  1.1.1.1.10.3  jdolecek             }
    267  1.1.1.1.10.2       tls         }
    268  1.1.1.1.10.2       tls         break;
    269  1.1.1.1.10.2       tls 
    270  1.1.1.1.10.2       tls     case PARSEOP_LOCAL0:
    271  1.1.1.1.10.2       tls     case PARSEOP_LOCAL1:
    272  1.1.1.1.10.2       tls     case PARSEOP_LOCAL2:
    273  1.1.1.1.10.2       tls     case PARSEOP_LOCAL3:
    274  1.1.1.1.10.2       tls     case PARSEOP_LOCAL4:
    275  1.1.1.1.10.2       tls     case PARSEOP_LOCAL5:
    276  1.1.1.1.10.2       tls     case PARSEOP_LOCAL6:
    277  1.1.1.1.10.2       tls     case PARSEOP_LOCAL7:
    278  1.1.1.1.10.2       tls 
    279  1.1.1.1.10.2       tls         if (!MethodInfo)
    280  1.1.1.1.10.2       tls         {
    281  1.1.1.1.10.2       tls             /*
    282  1.1.1.1.10.2       tls              * Local was used outside a control method, or there was an error
    283  1.1.1.1.10.2       tls              * in the method declaration.
    284  1.1.1.1.10.2       tls              */
    285  1.1.1.1.10.3  jdolecek             AslError (ASL_REMARK, ASL_MSG_LOCAL_OUTSIDE_METHOD,
    286  1.1.1.1.10.3  jdolecek                 Op, Op->Asl.ExternalName);
    287  1.1.1.1.10.2       tls             return (AE_ERROR);
    288  1.1.1.1.10.2       tls         }
    289  1.1.1.1.10.2       tls 
    290  1.1.1.1.10.3  jdolecek         RegisterNumber = (Op->Asl.AmlOpcode & 0x0007);
    291  1.1.1.1.10.2       tls 
    292  1.1.1.1.10.2       tls         /*
    293  1.1.1.1.10.2       tls          * If the local is being used as a target, mark the local
    294  1.1.1.1.10.2       tls          * initialized
    295  1.1.1.1.10.2       tls          */
    296  1.1.1.1.10.3  jdolecek         if (Op->Asl.CompileFlags & OP_IS_TARGET)
    297  1.1.1.1.10.2       tls         {
    298  1.1.1.1.10.2       tls             MethodInfo->LocalInitialized[RegisterNumber] = TRUE;
    299  1.1.1.1.10.2       tls         }
    300  1.1.1.1.10.2       tls 
    301  1.1.1.1.10.2       tls         /*
    302  1.1.1.1.10.2       tls          * Otherwise, this is a reference, check if the local
    303  1.1.1.1.10.2       tls          * has been previously initialized.
    304  1.1.1.1.10.2       tls          *
    305  1.1.1.1.10.2       tls          * The only operator that accepts an uninitialized value is ObjectType()
    306  1.1.1.1.10.2       tls          */
    307  1.1.1.1.10.2       tls         else if ((!MethodInfo->LocalInitialized[RegisterNumber]) &&
    308  1.1.1.1.10.2       tls                  (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_OBJECTTYPE))
    309  1.1.1.1.10.2       tls         {
    310  1.1.1.1.10.2       tls             LocalName[strlen (LocalName) -1] = (char) (RegisterNumber + 0x30);
    311  1.1.1.1.10.2       tls             AslError (ASL_ERROR, ASL_MSG_LOCAL_INIT, Op, LocalName);
    312  1.1.1.1.10.2       tls         }
    313  1.1.1.1.10.2       tls         break;
    314  1.1.1.1.10.2       tls 
    315  1.1.1.1.10.2       tls     case PARSEOP_ARG0:
    316  1.1.1.1.10.2       tls     case PARSEOP_ARG1:
    317  1.1.1.1.10.2       tls     case PARSEOP_ARG2:
    318  1.1.1.1.10.2       tls     case PARSEOP_ARG3:
    319  1.1.1.1.10.2       tls     case PARSEOP_ARG4:
    320  1.1.1.1.10.2       tls     case PARSEOP_ARG5:
    321  1.1.1.1.10.2       tls     case PARSEOP_ARG6:
    322  1.1.1.1.10.2       tls 
    323  1.1.1.1.10.2       tls         if (!MethodInfo)
    324  1.1.1.1.10.2       tls         {
    325  1.1.1.1.10.2       tls             /*
    326  1.1.1.1.10.2       tls              * Arg was used outside a control method, or there was an error
    327  1.1.1.1.10.2       tls              * in the method declaration.
    328  1.1.1.1.10.2       tls              */
    329  1.1.1.1.10.3  jdolecek             AslError (ASL_REMARK, ASL_MSG_LOCAL_OUTSIDE_METHOD,
    330  1.1.1.1.10.3  jdolecek                 Op, Op->Asl.ExternalName);
    331  1.1.1.1.10.2       tls             return (AE_ERROR);
    332  1.1.1.1.10.2       tls         }
    333  1.1.1.1.10.2       tls 
    334  1.1.1.1.10.2       tls         RegisterNumber = (Op->Asl.AmlOpcode & 0x000F) - 8;
    335  1.1.1.1.10.2       tls         ArgName[strlen (ArgName) -1] = (char) (RegisterNumber + 0x30);
    336  1.1.1.1.10.2       tls 
    337  1.1.1.1.10.2       tls         /*
    338  1.1.1.1.10.2       tls          * If the Arg is being used as a target, mark the local
    339  1.1.1.1.10.2       tls          * initialized
    340  1.1.1.1.10.2       tls          */
    341  1.1.1.1.10.3  jdolecek         if (Op->Asl.CompileFlags & OP_IS_TARGET)
    342  1.1.1.1.10.2       tls         {
    343  1.1.1.1.10.2       tls             MethodInfo->ArgInitialized[RegisterNumber] = TRUE;
    344  1.1.1.1.10.2       tls         }
    345  1.1.1.1.10.2       tls 
    346  1.1.1.1.10.2       tls         /*
    347  1.1.1.1.10.2       tls          * Otherwise, this is a reference, check if the Arg
    348  1.1.1.1.10.2       tls          * has been previously initialized.
    349  1.1.1.1.10.2       tls          *
    350  1.1.1.1.10.2       tls          * The only operator that accepts an uninitialized value is ObjectType()
    351  1.1.1.1.10.2       tls          */
    352  1.1.1.1.10.2       tls         else if ((!MethodInfo->ArgInitialized[RegisterNumber]) &&
    353  1.1.1.1.10.3  jdolecek             (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_OBJECTTYPE))
    354  1.1.1.1.10.2       tls         {
    355  1.1.1.1.10.2       tls             AslError (ASL_ERROR, ASL_MSG_ARG_INIT, Op, ArgName);
    356  1.1.1.1.10.2       tls         }
    357  1.1.1.1.10.2       tls 
    358  1.1.1.1.10.2       tls         /* Flag this arg if it is not a "real" argument to the method */
    359  1.1.1.1.10.2       tls 
    360  1.1.1.1.10.2       tls         if (RegisterNumber >= MethodInfo->NumArguments)
    361  1.1.1.1.10.2       tls         {
    362  1.1.1.1.10.2       tls             AslError (ASL_REMARK, ASL_MSG_NOT_PARAMETER, Op, ArgName);
    363  1.1.1.1.10.2       tls         }
    364  1.1.1.1.10.2       tls         break;
    365  1.1.1.1.10.2       tls 
    366  1.1.1.1.10.2       tls     case PARSEOP_RETURN:
    367  1.1.1.1.10.2       tls 
    368  1.1.1.1.10.2       tls         if (!MethodInfo)
    369  1.1.1.1.10.2       tls         {
    370  1.1.1.1.10.2       tls             /*
    371  1.1.1.1.10.2       tls              * Probably was an error in the method declaration,
    372  1.1.1.1.10.2       tls              * no additional error here
    373  1.1.1.1.10.2       tls              */
    374  1.1.1.1.10.2       tls             ACPI_WARNING ((AE_INFO, "%p, No parent method", Op));
    375  1.1.1.1.10.2       tls             return (AE_ERROR);
    376  1.1.1.1.10.2       tls         }
    377  1.1.1.1.10.2       tls 
    378  1.1.1.1.10.2       tls         /*
    379  1.1.1.1.10.2       tls          * A child indicates a possible return value. A simple Return or
    380  1.1.1.1.10.3  jdolecek          * Return() is marked with OP_IS_NULL_RETURN by the parser so
    381  1.1.1.1.10.2       tls          * that it is not counted as a "real" return-with-value, although
    382  1.1.1.1.10.2       tls          * the AML code that is actually emitted is Return(0). The AML
    383  1.1.1.1.10.2       tls          * definition of Return has a required parameter, so we are
    384  1.1.1.1.10.2       tls          * forced to convert a null return to Return(0).
    385  1.1.1.1.10.2       tls          */
    386  1.1.1.1.10.2       tls         if ((Op->Asl.Child) &&
    387  1.1.1.1.10.2       tls             (Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
    388  1.1.1.1.10.3  jdolecek             (!(Op->Asl.Child->Asl.CompileFlags & OP_IS_NULL_RETURN)))
    389  1.1.1.1.10.2       tls         {
    390  1.1.1.1.10.2       tls             MethodInfo->NumReturnWithValue++;
    391  1.1.1.1.10.2       tls         }
    392  1.1.1.1.10.2       tls         else
    393  1.1.1.1.10.2       tls         {
    394  1.1.1.1.10.2       tls             MethodInfo->NumReturnNoValue++;
    395  1.1.1.1.10.2       tls         }
    396  1.1.1.1.10.2       tls         break;
    397  1.1.1.1.10.2       tls 
    398  1.1.1.1.10.2       tls     case PARSEOP_BREAK:
    399  1.1.1.1.10.2       tls     case PARSEOP_CONTINUE:
    400  1.1.1.1.10.2       tls 
    401  1.1.1.1.10.2       tls         Next = Op->Asl.Parent;
    402  1.1.1.1.10.2       tls         while (Next)
    403  1.1.1.1.10.2       tls         {
    404  1.1.1.1.10.2       tls             if (Next->Asl.ParseOpcode == PARSEOP_WHILE)
    405  1.1.1.1.10.2       tls             {
    406  1.1.1.1.10.2       tls                 break;
    407  1.1.1.1.10.2       tls             }
    408  1.1.1.1.10.2       tls             Next = Next->Asl.Parent;
    409  1.1.1.1.10.2       tls         }
    410  1.1.1.1.10.2       tls 
    411  1.1.1.1.10.2       tls         if (!Next)
    412  1.1.1.1.10.2       tls         {
    413  1.1.1.1.10.2       tls             AslError (ASL_ERROR, ASL_MSG_NO_WHILE, Op, NULL);
    414  1.1.1.1.10.2       tls         }
    415  1.1.1.1.10.2       tls         break;
    416  1.1.1.1.10.2       tls 
    417  1.1.1.1.10.2       tls     case PARSEOP_STALL:
    418  1.1.1.1.10.2       tls 
    419  1.1.1.1.10.2       tls         /* We can range check if the argument is an integer */
    420  1.1.1.1.10.2       tls 
    421  1.1.1.1.10.2       tls         if ((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) &&
    422  1.1.1.1.10.2       tls             (Op->Asl.Child->Asl.Value.Integer > ACPI_UINT8_MAX))
    423  1.1.1.1.10.2       tls         {
    424  1.1.1.1.10.2       tls             AslError (ASL_ERROR, ASL_MSG_INVALID_TIME, Op, NULL);
    425  1.1.1.1.10.2       tls         }
    426  1.1.1.1.10.2       tls         break;
    427  1.1.1.1.10.2       tls 
    428  1.1.1.1.10.2       tls     case PARSEOP_DEVICE:
    429  1.1.1.1.10.3  jdolecek 
    430  1.1.1.1.10.3  jdolecek         if (!ApFindNameInDeviceTree (METHOD_NAME__HID, Op) &&
    431  1.1.1.1.10.3  jdolecek             !ApFindNameInDeviceTree (METHOD_NAME__ADR, Op))
    432  1.1.1.1.10.3  jdolecek         {
    433  1.1.1.1.10.3  jdolecek             AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op,
    434  1.1.1.1.10.3  jdolecek                 "Device object requires a _HID or _ADR in same scope");
    435  1.1.1.1.10.3  jdolecek         }
    436  1.1.1.1.10.3  jdolecek         break;
    437  1.1.1.1.10.3  jdolecek 
    438  1.1.1.1.10.2       tls     case PARSEOP_EVENT:
    439  1.1.1.1.10.2       tls     case PARSEOP_MUTEX:
    440  1.1.1.1.10.2       tls     case PARSEOP_OPERATIONREGION:
    441  1.1.1.1.10.2       tls     case PARSEOP_POWERRESOURCE:
    442  1.1.1.1.10.2       tls     case PARSEOP_PROCESSOR:
    443  1.1.1.1.10.2       tls     case PARSEOP_THERMALZONE:
    444  1.1.1.1.10.2       tls 
    445  1.1.1.1.10.2       tls         /*
    446  1.1.1.1.10.2       tls          * The first operand is a name to be created in the namespace.
    447  1.1.1.1.10.2       tls          * Check against the reserved list.
    448  1.1.1.1.10.2       tls          */
    449  1.1.1.1.10.2       tls         i = ApCheckForPredefinedName (Op, Op->Asl.NameSeg);
    450  1.1.1.1.10.2       tls         if (i < ACPI_VALID_RESERVED_NAME_MAX)
    451  1.1.1.1.10.2       tls         {
    452  1.1.1.1.10.3  jdolecek             AslError (ASL_ERROR, ASL_MSG_RESERVED_USE,
    453  1.1.1.1.10.3  jdolecek                 Op, Op->Asl.ExternalName);
    454  1.1.1.1.10.2       tls         }
    455  1.1.1.1.10.2       tls         break;
    456  1.1.1.1.10.2       tls 
    457  1.1.1.1.10.2       tls     case PARSEOP_NAME:
    458  1.1.1.1.10.2       tls 
    459  1.1.1.1.10.2       tls         /* Typecheck any predefined names statically defined with Name() */
    460  1.1.1.1.10.2       tls 
    461  1.1.1.1.10.2       tls         ApCheckForPredefinedObject (Op, Op->Asl.NameSeg);
    462  1.1.1.1.10.2       tls 
    463  1.1.1.1.10.2       tls         /* Special typechecking for _HID */
    464  1.1.1.1.10.2       tls 
    465  1.1.1.1.10.3  jdolecek         if (!strcmp (METHOD_NAME__HID, Op->Asl.NameSeg))
    466  1.1.1.1.10.2       tls         {
    467  1.1.1.1.10.2       tls             Next = Op->Asl.Child->Asl.Next;
    468  1.1.1.1.10.2       tls             AnCheckId (Next, ASL_TYPE_HID);
    469  1.1.1.1.10.2       tls         }
    470  1.1.1.1.10.2       tls 
    471  1.1.1.1.10.2       tls         /* Special typechecking for _CID */
    472  1.1.1.1.10.2       tls 
    473  1.1.1.1.10.3  jdolecek         else if (!strcmp (METHOD_NAME__CID, Op->Asl.NameSeg))
    474  1.1.1.1.10.2       tls         {
    475  1.1.1.1.10.2       tls             Next = Op->Asl.Child->Asl.Next;
    476  1.1.1.1.10.2       tls 
    477  1.1.1.1.10.2       tls             if ((Next->Asl.ParseOpcode == PARSEOP_PACKAGE) ||
    478  1.1.1.1.10.2       tls                 (Next->Asl.ParseOpcode == PARSEOP_VAR_PACKAGE))
    479  1.1.1.1.10.2       tls             {
    480  1.1.1.1.10.2       tls                 Next = Next->Asl.Child;
    481  1.1.1.1.10.2       tls                 while (Next)
    482  1.1.1.1.10.2       tls                 {
    483  1.1.1.1.10.2       tls                     AnCheckId (Next, ASL_TYPE_CID);
    484  1.1.1.1.10.2       tls                     Next = Next->Asl.Next;
    485  1.1.1.1.10.2       tls                 }
    486  1.1.1.1.10.2       tls             }
    487  1.1.1.1.10.2       tls             else
    488  1.1.1.1.10.2       tls             {
    489  1.1.1.1.10.2       tls                 AnCheckId (Next, ASL_TYPE_CID);
    490  1.1.1.1.10.2       tls             }
    491  1.1.1.1.10.2       tls         }
    492  1.1.1.1.10.3  jdolecek 
    493  1.1.1.1.10.2       tls         break;
    494  1.1.1.1.10.2       tls 
    495  1.1.1.1.10.2       tls     default:
    496  1.1.1.1.10.2       tls 
    497  1.1.1.1.10.2       tls         break;
    498  1.1.1.1.10.2       tls     }
    499  1.1.1.1.10.2       tls 
    500  1.1.1.1.10.2       tls     /* Check for named object creation within a non-serialized method */
    501  1.1.1.1.10.2       tls 
    502  1.1.1.1.10.2       tls     MtCheckNamedObjectInMethod (Op, MethodInfo);
    503  1.1.1.1.10.2       tls     return (AE_OK);
    504  1.1.1.1.10.2       tls }
    505  1.1.1.1.10.2       tls 
    506  1.1.1.1.10.2       tls 
    507  1.1.1.1.10.2       tls /*******************************************************************************
    508  1.1.1.1.10.2       tls  *
    509  1.1.1.1.10.2       tls  * FUNCTION:    MtCheckNamedObjectInMethod
    510  1.1.1.1.10.2       tls  *
    511  1.1.1.1.10.2       tls  * PARAMETERS:  Op                  - Current parser op
    512  1.1.1.1.10.2       tls  *              MethodInfo          - Info for method being parsed
    513  1.1.1.1.10.2       tls  *
    514  1.1.1.1.10.2       tls  * RETURN:      None
    515  1.1.1.1.10.2       tls  *
    516  1.1.1.1.10.2       tls  * DESCRIPTION: Detect if a non-serialized method is creating a named object,
    517  1.1.1.1.10.2       tls  *              which could possibly cause problems if two threads execute
    518  1.1.1.1.10.2       tls  *              the method concurrently. Emit a remark in this case.
    519  1.1.1.1.10.2       tls  *
    520  1.1.1.1.10.2       tls  ******************************************************************************/
    521  1.1.1.1.10.2       tls 
    522  1.1.1.1.10.3  jdolecek static void
    523  1.1.1.1.10.2       tls MtCheckNamedObjectInMethod (
    524  1.1.1.1.10.2       tls     ACPI_PARSE_OBJECT       *Op,
    525  1.1.1.1.10.2       tls     ASL_METHOD_INFO         *MethodInfo)
    526  1.1.1.1.10.2       tls {
    527  1.1.1.1.10.2       tls     const ACPI_OPCODE_INFO  *OpInfo;
    528  1.1.1.1.10.2       tls 
    529  1.1.1.1.10.2       tls 
    530  1.1.1.1.10.3  jdolecek     /* We don't care about actual method declarations or scopes */
    531  1.1.1.1.10.2       tls 
    532  1.1.1.1.10.3  jdolecek     if ((Op->Asl.AmlOpcode == AML_METHOD_OP) ||
    533  1.1.1.1.10.3  jdolecek         (Op->Asl.AmlOpcode == AML_SCOPE_OP))
    534  1.1.1.1.10.2       tls     {
    535  1.1.1.1.10.2       tls         return;
    536  1.1.1.1.10.2       tls     }
    537  1.1.1.1.10.2       tls 
    538  1.1.1.1.10.3  jdolecek     /* Determine if we are creating a named object within a method */
    539  1.1.1.1.10.3  jdolecek 
    540  1.1.1.1.10.3  jdolecek     if (!MethodInfo)
    541  1.1.1.1.10.3  jdolecek     {
    542  1.1.1.1.10.3  jdolecek         return;
    543  1.1.1.1.10.3  jdolecek     }
    544  1.1.1.1.10.2       tls 
    545  1.1.1.1.10.2       tls     OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
    546  1.1.1.1.10.2       tls     if (OpInfo->Class == AML_CLASS_NAMED_OBJECT)
    547  1.1.1.1.10.2       tls     {
    548  1.1.1.1.10.2       tls         /*
    549  1.1.1.1.10.3  jdolecek          * 1) Mark the method as a method that creates named objects.
    550  1.1.1.1.10.3  jdolecek          *
    551  1.1.1.1.10.3  jdolecek          * 2) If the method is non-serialized, emit a remark that the method
    552  1.1.1.1.10.3  jdolecek          * should be serialized.
    553  1.1.1.1.10.2       tls          *
    554  1.1.1.1.10.2       tls          * Reason: If a thread blocks within the method for any reason, and
    555  1.1.1.1.10.3  jdolecek          * another thread enters the method, the method will fail because
    556  1.1.1.1.10.3  jdolecek          * an attempt will be made to create the same object twice.
    557  1.1.1.1.10.2       tls          */
    558  1.1.1.1.10.3  jdolecek         MethodInfo->CreatesNamedObjects = TRUE;
    559  1.1.1.1.10.3  jdolecek         if (!MethodInfo->ShouldBeSerialized)
    560  1.1.1.1.10.2       tls         {
    561  1.1.1.1.10.2       tls             AslError (ASL_REMARK, ASL_MSG_SERIALIZED_REQUIRED, MethodInfo->Op,
    562  1.1.1.1.10.2       tls                 "due to creation of named objects within");
    563  1.1.1.1.10.2       tls 
    564  1.1.1.1.10.2       tls             /* Emit message only ONCE per method */
    565  1.1.1.1.10.2       tls 
    566  1.1.1.1.10.2       tls             MethodInfo->ShouldBeSerialized = TRUE;
    567  1.1.1.1.10.2       tls         }
    568  1.1.1.1.10.2       tls     }
    569  1.1.1.1.10.2       tls }
    570  1.1.1.1.10.2       tls 
    571  1.1.1.1.10.2       tls 
    572  1.1.1.1.10.2       tls /*******************************************************************************
    573  1.1.1.1.10.2       tls  *
    574  1.1.1.1.10.2       tls  * FUNCTION:    MtMethodAnalysisWalkEnd
    575  1.1.1.1.10.2       tls  *
    576  1.1.1.1.10.2       tls  * PARAMETERS:  ASL_WALK_CALLBACK
    577  1.1.1.1.10.2       tls  *
    578  1.1.1.1.10.2       tls  * RETURN:      Status
    579  1.1.1.1.10.2       tls  *
    580  1.1.1.1.10.2       tls  * DESCRIPTION: Ascending callback for analysis walk. Complete method
    581  1.1.1.1.10.2       tls  *              return analysis.
    582  1.1.1.1.10.2       tls  *
    583  1.1.1.1.10.2       tls  ******************************************************************************/
    584  1.1.1.1.10.2       tls 
    585  1.1.1.1.10.2       tls ACPI_STATUS
    586  1.1.1.1.10.2       tls MtMethodAnalysisWalkEnd (
    587  1.1.1.1.10.2       tls     ACPI_PARSE_OBJECT       *Op,
    588  1.1.1.1.10.2       tls     UINT32                  Level,
    589  1.1.1.1.10.2       tls     void                    *Context)
    590  1.1.1.1.10.2       tls {
    591  1.1.1.1.10.2       tls     ASL_ANALYSIS_WALK_INFO  *WalkInfo = (ASL_ANALYSIS_WALK_INFO *) Context;
    592  1.1.1.1.10.2       tls     ASL_METHOD_INFO         *MethodInfo = WalkInfo->MethodStack;
    593  1.1.1.1.10.2       tls 
    594  1.1.1.1.10.2       tls 
    595  1.1.1.1.10.2       tls     switch (Op->Asl.ParseOpcode)
    596  1.1.1.1.10.2       tls     {
    597  1.1.1.1.10.2       tls     case PARSEOP_METHOD:
    598  1.1.1.1.10.2       tls     case PARSEOP_RETURN:
    599  1.1.1.1.10.2       tls 
    600  1.1.1.1.10.2       tls         if (!MethodInfo)
    601  1.1.1.1.10.2       tls         {
    602  1.1.1.1.10.2       tls             printf ("No method info for method! [%s]\n", Op->Asl.Namepath);
    603  1.1.1.1.10.2       tls             AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op,
    604  1.1.1.1.10.2       tls                 "No method info for this method");
    605  1.1.1.1.10.2       tls 
    606  1.1.1.1.10.2       tls             CmCleanupAndExit ();
    607  1.1.1.1.10.2       tls             return (AE_AML_INTERNAL);
    608  1.1.1.1.10.2       tls         }
    609  1.1.1.1.10.2       tls         break;
    610  1.1.1.1.10.2       tls 
    611  1.1.1.1.10.2       tls     default:
    612  1.1.1.1.10.2       tls 
    613  1.1.1.1.10.2       tls         break;
    614  1.1.1.1.10.2       tls     }
    615  1.1.1.1.10.2       tls 
    616  1.1.1.1.10.2       tls     switch (Op->Asl.ParseOpcode)
    617  1.1.1.1.10.2       tls     {
    618  1.1.1.1.10.2       tls     case PARSEOP_METHOD:
    619  1.1.1.1.10.2       tls 
    620  1.1.1.1.10.2       tls         WalkInfo->MethodStack = MethodInfo->Next;
    621  1.1.1.1.10.2       tls 
    622  1.1.1.1.10.2       tls         /*
    623  1.1.1.1.10.2       tls          * Check if there is no return statement at the end of the
    624  1.1.1.1.10.2       tls          * method AND we can actually get there -- i.e., the execution
    625  1.1.1.1.10.2       tls          * of the method can possibly terminate without a return statement.
    626  1.1.1.1.10.2       tls          */
    627  1.1.1.1.10.2       tls         if ((!AnLastStatementIsReturn (Op)) &&
    628  1.1.1.1.10.3  jdolecek             (!(Op->Asl.CompileFlags & OP_HAS_NO_EXIT)))
    629  1.1.1.1.10.2       tls         {
    630  1.1.1.1.10.2       tls             /*
    631  1.1.1.1.10.2       tls              * No return statement, and execution can possibly exit
    632  1.1.1.1.10.2       tls              * via this path. This is equivalent to Return ()
    633  1.1.1.1.10.2       tls              */
    634  1.1.1.1.10.2       tls             MethodInfo->NumReturnNoValue++;
    635  1.1.1.1.10.2       tls         }
    636  1.1.1.1.10.2       tls 
    637  1.1.1.1.10.2       tls         /*
    638  1.1.1.1.10.2       tls          * Check for case where some return statements have a return value
    639  1.1.1.1.10.2       tls          * and some do not. Exit without a return statement is a return with
    640  1.1.1.1.10.2       tls          * no value
    641  1.1.1.1.10.2       tls          */
    642  1.1.1.1.10.2       tls         if (MethodInfo->NumReturnNoValue &&
    643  1.1.1.1.10.2       tls             MethodInfo->NumReturnWithValue)
    644  1.1.1.1.10.2       tls         {
    645  1.1.1.1.10.2       tls             AslError (ASL_WARNING, ASL_MSG_RETURN_TYPES, Op,
    646  1.1.1.1.10.2       tls                 Op->Asl.ExternalName);
    647  1.1.1.1.10.2       tls         }
    648  1.1.1.1.10.2       tls 
    649  1.1.1.1.10.2       tls         /*
    650  1.1.1.1.10.2       tls          * If there are any RETURN() statements with no value, or there is a
    651  1.1.1.1.10.2       tls          * control path that allows the method to exit without a return value,
    652  1.1.1.1.10.2       tls          * we mark the method as a method that does not return a value. This
    653  1.1.1.1.10.2       tls          * knowledge can be used to check method invocations that expect a
    654  1.1.1.1.10.2       tls          * returned value.
    655  1.1.1.1.10.2       tls          */
    656  1.1.1.1.10.2       tls         if (MethodInfo->NumReturnNoValue)
    657  1.1.1.1.10.2       tls         {
    658  1.1.1.1.10.2       tls             if (MethodInfo->NumReturnWithValue)
    659  1.1.1.1.10.2       tls             {
    660  1.1.1.1.10.3  jdolecek                 Op->Asl.CompileFlags |= OP_METHOD_SOME_NO_RETVAL;
    661  1.1.1.1.10.2       tls             }
    662  1.1.1.1.10.2       tls             else
    663  1.1.1.1.10.2       tls             {
    664  1.1.1.1.10.3  jdolecek                 Op->Asl.CompileFlags |= OP_METHOD_NO_RETVAL;
    665  1.1.1.1.10.2       tls             }
    666  1.1.1.1.10.2       tls         }
    667  1.1.1.1.10.2       tls 
    668  1.1.1.1.10.2       tls         /*
    669  1.1.1.1.10.2       tls          * Check predefined method names for correct return behavior
    670  1.1.1.1.10.2       tls          * and correct number of arguments. Also, some special checks
    671  1.1.1.1.10.2       tls          * For GPE and _REG methods.
    672  1.1.1.1.10.2       tls          */
    673  1.1.1.1.10.2       tls         if (ApCheckForPredefinedMethod (Op, MethodInfo))
    674  1.1.1.1.10.2       tls         {
    675  1.1.1.1.10.2       tls             /* Special check for two names like _L01 and _E01 in same scope */
    676  1.1.1.1.10.2       tls 
    677  1.1.1.1.10.2       tls             ApCheckForGpeNameConflict (Op);
    678  1.1.1.1.10.2       tls 
    679  1.1.1.1.10.2       tls             /*
    680  1.1.1.1.10.2       tls              * Special check for _REG: Must have an operation region definition
    681  1.1.1.1.10.2       tls              * within the same scope!
    682  1.1.1.1.10.2       tls              */
    683  1.1.1.1.10.2       tls             ApCheckRegMethod (Op);
    684  1.1.1.1.10.2       tls         }
    685  1.1.1.1.10.2       tls 
    686  1.1.1.1.10.2       tls         ACPI_FREE (MethodInfo);
    687  1.1.1.1.10.2       tls         break;
    688  1.1.1.1.10.2       tls 
    689  1.1.1.1.10.2       tls     case PARSEOP_NAME:
    690  1.1.1.1.10.2       tls 
    691  1.1.1.1.10.2       tls          /* Special check for two names like _L01 and _E01 in same scope */
    692  1.1.1.1.10.2       tls 
    693  1.1.1.1.10.2       tls         ApCheckForGpeNameConflict (Op);
    694  1.1.1.1.10.2       tls         break;
    695  1.1.1.1.10.2       tls 
    696  1.1.1.1.10.2       tls     case PARSEOP_RETURN:
    697  1.1.1.1.10.2       tls 
    698  1.1.1.1.10.2       tls         /*
    699  1.1.1.1.10.2       tls          * If the parent is a predefined method name, attempt to typecheck
    700  1.1.1.1.10.2       tls          * the return value. Only static types can be validated.
    701  1.1.1.1.10.2       tls          */
    702  1.1.1.1.10.2       tls         ApCheckPredefinedReturnValue (Op, MethodInfo);
    703  1.1.1.1.10.2       tls 
    704  1.1.1.1.10.2       tls         /*
    705  1.1.1.1.10.2       tls          * The parent block does not "exit" and continue execution -- the
    706  1.1.1.1.10.2       tls          * method is terminated here with the Return() statement.
    707  1.1.1.1.10.2       tls          */
    708  1.1.1.1.10.3  jdolecek         Op->Asl.Parent->Asl.CompileFlags |= OP_HAS_NO_EXIT;
    709  1.1.1.1.10.2       tls 
    710  1.1.1.1.10.2       tls         /* Used in the "typing" pass later */
    711  1.1.1.1.10.2       tls 
    712  1.1.1.1.10.2       tls         Op->Asl.ParentMethod = MethodInfo->Op;
    713  1.1.1.1.10.2       tls 
    714  1.1.1.1.10.2       tls         /*
    715  1.1.1.1.10.2       tls          * If there is a peer node after the return statement, then this
    716  1.1.1.1.10.2       tls          * node is unreachable code -- i.e., it won't be executed because of
    717  1.1.1.1.10.2       tls          * the preceding Return() statement.
    718  1.1.1.1.10.2       tls          */
    719  1.1.1.1.10.2       tls         if (Op->Asl.Next)
    720  1.1.1.1.10.2       tls         {
    721  1.1.1.1.10.3  jdolecek             AslError (ASL_WARNING, ASL_MSG_UNREACHABLE_CODE,
    722  1.1.1.1.10.3  jdolecek                 Op->Asl.Next, NULL);
    723  1.1.1.1.10.2       tls         }
    724  1.1.1.1.10.2       tls         break;
    725  1.1.1.1.10.2       tls 
    726  1.1.1.1.10.2       tls     case PARSEOP_IF:
    727  1.1.1.1.10.2       tls 
    728  1.1.1.1.10.3  jdolecek         if ((Op->Asl.CompileFlags & OP_HAS_NO_EXIT) &&
    729  1.1.1.1.10.2       tls             (Op->Asl.Next) &&
    730  1.1.1.1.10.2       tls             (Op->Asl.Next->Asl.ParseOpcode == PARSEOP_ELSE))
    731  1.1.1.1.10.2       tls         {
    732  1.1.1.1.10.2       tls             /*
    733  1.1.1.1.10.2       tls              * This IF has a corresponding ELSE. The IF block has no exit,
    734  1.1.1.1.10.2       tls              * (it contains an unconditional Return)
    735  1.1.1.1.10.2       tls              * mark the ELSE block to remember this fact.
    736  1.1.1.1.10.2       tls              */
    737  1.1.1.1.10.3  jdolecek             Op->Asl.Next->Asl.CompileFlags |= OP_IF_HAS_NO_EXIT;
    738  1.1.1.1.10.2       tls         }
    739  1.1.1.1.10.2       tls         break;
    740  1.1.1.1.10.2       tls 
    741  1.1.1.1.10.2       tls     case PARSEOP_ELSE:
    742  1.1.1.1.10.2       tls 
    743  1.1.1.1.10.3  jdolecek         if ((Op->Asl.CompileFlags & OP_HAS_NO_EXIT) &&
    744  1.1.1.1.10.3  jdolecek             (Op->Asl.CompileFlags & OP_IF_HAS_NO_EXIT))
    745  1.1.1.1.10.2       tls         {
    746  1.1.1.1.10.2       tls             /*
    747  1.1.1.1.10.2       tls              * This ELSE block has no exit and the corresponding IF block
    748  1.1.1.1.10.2       tls              * has no exit either. Therefore, the parent node has no exit.
    749  1.1.1.1.10.2       tls              */
    750  1.1.1.1.10.3  jdolecek             Op->Asl.Parent->Asl.CompileFlags |= OP_HAS_NO_EXIT;
    751  1.1.1.1.10.2       tls         }
    752  1.1.1.1.10.2       tls         break;
    753  1.1.1.1.10.2       tls 
    754  1.1.1.1.10.2       tls 
    755  1.1.1.1.10.2       tls     default:
    756  1.1.1.1.10.2       tls 
    757  1.1.1.1.10.3  jdolecek         if ((Op->Asl.CompileFlags & OP_HAS_NO_EXIT) &&
    758  1.1.1.1.10.2       tls             (Op->Asl.Parent))
    759  1.1.1.1.10.2       tls         {
    760  1.1.1.1.10.2       tls             /* If this node has no exit, then the parent has no exit either */
    761  1.1.1.1.10.2       tls 
    762  1.1.1.1.10.3  jdolecek             Op->Asl.Parent->Asl.CompileFlags |= OP_HAS_NO_EXIT;
    763  1.1.1.1.10.2       tls         }
    764  1.1.1.1.10.2       tls         break;
    765  1.1.1.1.10.2       tls     }
    766  1.1.1.1.10.2       tls 
    767  1.1.1.1.10.2       tls     return (AE_OK);
    768  1.1.1.1.10.2       tls }
    769