Home | History | Annotate | Line # | Download | only in compiler
aslfold.c revision 1.1.1.4.2.1
      1          1.1    jruoho /******************************************************************************
      2          1.1    jruoho  *
      3          1.1    jruoho  * Module Name: aslfold - Constant folding
      4          1.1    jruoho  *
      5          1.1    jruoho  *****************************************************************************/
      6          1.1    jruoho 
      7      1.1.1.2    jruoho /*
      8  1.1.1.4.2.1     skrll  * Copyright (C) 2000 - 2015, Intel Corp.
      9          1.1    jruoho  * All rights reserved.
     10          1.1    jruoho  *
     11      1.1.1.2    jruoho  * Redistribution and use in source and binary forms, with or without
     12      1.1.1.2    jruoho  * modification, are permitted provided that the following conditions
     13      1.1.1.2    jruoho  * are met:
     14      1.1.1.2    jruoho  * 1. Redistributions of source code must retain the above copyright
     15      1.1.1.2    jruoho  *    notice, this list of conditions, and the following disclaimer,
     16      1.1.1.2    jruoho  *    without modification.
     17      1.1.1.2    jruoho  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18      1.1.1.2    jruoho  *    substantially similar to the "NO WARRANTY" disclaimer below
     19      1.1.1.2    jruoho  *    ("Disclaimer") and any redistribution must be conditioned upon
     20      1.1.1.2    jruoho  *    including a substantially similar Disclaimer requirement for further
     21      1.1.1.2    jruoho  *    binary redistribution.
     22      1.1.1.2    jruoho  * 3. Neither the names of the above-listed copyright holders nor the names
     23      1.1.1.2    jruoho  *    of any contributors may be used to endorse or promote products derived
     24      1.1.1.2    jruoho  *    from this software without specific prior written permission.
     25      1.1.1.2    jruoho  *
     26      1.1.1.2    jruoho  * Alternatively, this software may be distributed under the terms of the
     27      1.1.1.2    jruoho  * GNU General Public License ("GPL") version 2 as published by the Free
     28      1.1.1.2    jruoho  * Software Foundation.
     29      1.1.1.2    jruoho  *
     30      1.1.1.2    jruoho  * NO WARRANTY
     31      1.1.1.2    jruoho  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32      1.1.1.2    jruoho  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33      1.1.1.2    jruoho  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34      1.1.1.2    jruoho  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35      1.1.1.2    jruoho  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36      1.1.1.2    jruoho  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37      1.1.1.2    jruoho  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38      1.1.1.2    jruoho  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39      1.1.1.2    jruoho  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40      1.1.1.2    jruoho  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41      1.1.1.2    jruoho  * POSSIBILITY OF SUCH DAMAGES.
     42      1.1.1.2    jruoho  */
     43          1.1    jruoho 
     44          1.1    jruoho #include "aslcompiler.h"
     45          1.1    jruoho #include "aslcompiler.y.h"
     46          1.1    jruoho #include "amlcode.h"
     47          1.1    jruoho 
     48          1.1    jruoho #include "acdispat.h"
     49          1.1    jruoho #include "acparser.h"
     50          1.1    jruoho 
     51          1.1    jruoho #define _COMPONENT          ACPI_COMPILER
     52          1.1    jruoho         ACPI_MODULE_NAME    ("aslfold")
     53          1.1    jruoho 
     54          1.1    jruoho /* Local prototypes */
     55          1.1    jruoho 
     56          1.1    jruoho static ACPI_STATUS
     57          1.1    jruoho OpcAmlEvaluationWalk1 (
     58          1.1    jruoho     ACPI_PARSE_OBJECT       *Op,
     59          1.1    jruoho     UINT32                  Level,
     60          1.1    jruoho     void                    *Context);
     61          1.1    jruoho 
     62          1.1    jruoho static ACPI_STATUS
     63          1.1    jruoho OpcAmlEvaluationWalk2 (
     64          1.1    jruoho     ACPI_PARSE_OBJECT       *Op,
     65          1.1    jruoho     UINT32                  Level,
     66          1.1    jruoho     void                    *Context);
     67          1.1    jruoho 
     68          1.1    jruoho static ACPI_STATUS
     69          1.1    jruoho OpcAmlCheckForConstant (
     70          1.1    jruoho     ACPI_PARSE_OBJECT       *Op,
     71          1.1    jruoho     UINT32                  Level,
     72          1.1    jruoho     void                    *Context);
     73          1.1    jruoho 
     74      1.1.1.3  christos static void
     75      1.1.1.3  christos OpcUpdateIntegerNode (
     76      1.1.1.3  christos     ACPI_PARSE_OBJECT       *Op,
     77      1.1.1.3  christos     UINT64                  Value);
     78      1.1.1.3  christos 
     79  1.1.1.4.2.1     skrll static ACPI_STATUS
     80  1.1.1.4.2.1     skrll TrTransformToStoreOp (
     81  1.1.1.4.2.1     skrll     ACPI_PARSE_OBJECT       *Op,
     82  1.1.1.4.2.1     skrll     ACPI_WALK_STATE         *WalkState);
     83  1.1.1.4.2.1     skrll 
     84  1.1.1.4.2.1     skrll static ACPI_STATUS
     85  1.1.1.4.2.1     skrll TrSimpleConstantReduction (
     86  1.1.1.4.2.1     skrll     ACPI_PARSE_OBJECT       *Op,
     87  1.1.1.4.2.1     skrll     ACPI_WALK_STATE         *WalkState);
     88  1.1.1.4.2.1     skrll 
     89  1.1.1.4.2.1     skrll static void
     90  1.1.1.4.2.1     skrll TrInstallReducedConstant (
     91  1.1.1.4.2.1     skrll     ACPI_PARSE_OBJECT       *Op,
     92  1.1.1.4.2.1     skrll     ACPI_OPERAND_OBJECT     *ObjDesc);
     93  1.1.1.4.2.1     skrll 
     94          1.1    jruoho 
     95          1.1    jruoho /*******************************************************************************
     96          1.1    jruoho  *
     97  1.1.1.4.2.1     skrll  * FUNCTION:    OpcAmlConstantWalk
     98          1.1    jruoho  *
     99          1.1    jruoho  * PARAMETERS:  ASL_WALK_CALLBACK
    100          1.1    jruoho  *
    101          1.1    jruoho  * RETURN:      Status
    102          1.1    jruoho  *
    103  1.1.1.4.2.1     skrll  * DESCRIPTION: Reduce an Op and its subtree to a constant if possible
    104          1.1    jruoho  *
    105          1.1    jruoho  ******************************************************************************/
    106          1.1    jruoho 
    107  1.1.1.4.2.1     skrll ACPI_STATUS
    108  1.1.1.4.2.1     skrll OpcAmlConstantWalk (
    109          1.1    jruoho     ACPI_PARSE_OBJECT       *Op,
    110          1.1    jruoho     UINT32                  Level,
    111          1.1    jruoho     void                    *Context)
    112          1.1    jruoho {
    113  1.1.1.4.2.1     skrll     ACPI_WALK_STATE         *WalkState;
    114  1.1.1.4.2.1     skrll     ACPI_STATUS             Status = AE_OK;
    115          1.1    jruoho 
    116          1.1    jruoho 
    117  1.1.1.4.2.1     skrll     if (Op->Asl.CompileFlags == 0)
    118  1.1.1.4.2.1     skrll     {
    119  1.1.1.4.2.1     skrll         return (AE_OK);
    120  1.1.1.4.2.1     skrll     }
    121          1.1    jruoho 
    122  1.1.1.4.2.1     skrll     /*
    123  1.1.1.4.2.1     skrll      * Only interested in subtrees that could possibly contain
    124  1.1.1.4.2.1     skrll      * expressions that can be evaluated at this time
    125  1.1.1.4.2.1     skrll      */
    126  1.1.1.4.2.1     skrll     if ((!(Op->Asl.CompileFlags & NODE_COMPILE_TIME_CONST)) ||
    127  1.1.1.4.2.1     skrll           (Op->Asl.CompileFlags & NODE_IS_TARGET))
    128          1.1    jruoho     {
    129  1.1.1.4.2.1     skrll         return (AE_OK);
    130          1.1    jruoho     }
    131          1.1    jruoho 
    132  1.1.1.4.2.1     skrll     /* Create a new walk state */
    133          1.1    jruoho 
    134  1.1.1.4.2.1     skrll     WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);
    135  1.1.1.4.2.1     skrll     if (!WalkState)
    136          1.1    jruoho     {
    137  1.1.1.4.2.1     skrll         return (AE_NO_MEMORY);
    138          1.1    jruoho     }
    139          1.1    jruoho 
    140  1.1.1.4.2.1     skrll     WalkState->NextOp = NULL;
    141  1.1.1.4.2.1     skrll     WalkState->Params = NULL;
    142          1.1    jruoho 
    143  1.1.1.4.2.1     skrll     /*
    144  1.1.1.4.2.1     skrll      * Examine the entire subtree -- all nodes must be constants
    145  1.1.1.4.2.1     skrll      * or type 3/4/5 opcodes
    146  1.1.1.4.2.1     skrll      */
    147  1.1.1.4.2.1     skrll     Status = TrWalkParseTree (Op, ASL_WALK_VISIT_DOWNWARD,
    148  1.1.1.4.2.1     skrll         OpcAmlCheckForConstant, NULL, WalkState);
    149          1.1    jruoho 
    150  1.1.1.4.2.1     skrll     /*
    151  1.1.1.4.2.1     skrll      * Did we find an entire subtree that contains all constants
    152  1.1.1.4.2.1     skrll      * and type 3/4/5 opcodes?
    153  1.1.1.4.2.1     skrll      */
    154  1.1.1.4.2.1     skrll     switch (Status)
    155  1.1.1.4.2.1     skrll     {
    156  1.1.1.4.2.1     skrll     case AE_OK:
    157          1.1    jruoho 
    158  1.1.1.4.2.1     skrll         /* Simple case, like Add(3,4) -> 7 */
    159          1.1    jruoho 
    160  1.1.1.4.2.1     skrll         Status = TrSimpleConstantReduction (Op, WalkState);
    161  1.1.1.4.2.1     skrll         break;
    162          1.1    jruoho 
    163  1.1.1.4.2.1     skrll     case AE_CTRL_RETURN_VALUE:
    164          1.1    jruoho 
    165  1.1.1.4.2.1     skrll         /* More complex case, like Add(3,4,Local0) -> Store(7,Local0) */
    166          1.1    jruoho 
    167  1.1.1.4.2.1     skrll         Status = TrTransformToStoreOp (Op, WalkState);
    168  1.1.1.4.2.1     skrll         break;
    169          1.1    jruoho 
    170  1.1.1.4.2.1     skrll     case AE_TYPE:
    171  1.1.1.4.2.1     skrll 
    172  1.1.1.4.2.1     skrll         AcpiDsDeleteWalkState (WalkState);
    173  1.1.1.4.2.1     skrll         return (AE_OK);
    174  1.1.1.4.2.1     skrll 
    175  1.1.1.4.2.1     skrll     default:
    176  1.1.1.4.2.1     skrll         AcpiDsDeleteWalkState (WalkState);
    177  1.1.1.4.2.1     skrll         break;
    178  1.1.1.4.2.1     skrll     }
    179          1.1    jruoho 
    180          1.1    jruoho     if (ACPI_FAILURE (Status))
    181          1.1    jruoho     {
    182  1.1.1.4.2.1     skrll         DbgPrint (ASL_PARSE_OUTPUT, "Cannot resolve, %s\n",
    183  1.1.1.4.2.1     skrll             AcpiFormatException (Status));
    184  1.1.1.4.2.1     skrll 
    185  1.1.1.4.2.1     skrll         /* We could not resolve the subtree for some reason */
    186  1.1.1.4.2.1     skrll 
    187  1.1.1.4.2.1     skrll         AslError (ASL_ERROR, ASL_MSG_CONSTANT_EVALUATION, Op,
    188  1.1.1.4.2.1     skrll             (char *) AcpiFormatException (Status));
    189  1.1.1.4.2.1     skrll 
    190  1.1.1.4.2.1     skrll         /* Set the subtree value to ZERO anyway. Eliminates further errors */
    191  1.1.1.4.2.1     skrll 
    192  1.1.1.4.2.1     skrll         OpcUpdateIntegerNode (Op, 0);
    193          1.1    jruoho     }
    194          1.1    jruoho 
    195  1.1.1.4.2.1     skrll     /* Abort the walk of this subtree, we are done with it */
    196  1.1.1.4.2.1     skrll 
    197  1.1.1.4.2.1     skrll     return (AE_CTRL_DEPTH);
    198          1.1    jruoho }
    199          1.1    jruoho 
    200          1.1    jruoho 
    201          1.1    jruoho /*******************************************************************************
    202          1.1    jruoho  *
    203          1.1    jruoho  * FUNCTION:    OpcAmlCheckForConstant
    204          1.1    jruoho  *
    205          1.1    jruoho  * PARAMETERS:  ASL_WALK_CALLBACK
    206          1.1    jruoho  *
    207          1.1    jruoho  * RETURN:      Status
    208          1.1    jruoho  *
    209          1.1    jruoho  * DESCRIPTION: Check one Op for a type 3/4/5 AML opcode
    210          1.1    jruoho  *
    211          1.1    jruoho  ******************************************************************************/
    212          1.1    jruoho 
    213          1.1    jruoho static ACPI_STATUS
    214          1.1    jruoho OpcAmlCheckForConstant (
    215          1.1    jruoho     ACPI_PARSE_OBJECT       *Op,
    216          1.1    jruoho     UINT32                  Level,
    217          1.1    jruoho     void                    *Context)
    218          1.1    jruoho {
    219          1.1    jruoho     ACPI_WALK_STATE         *WalkState = Context;
    220  1.1.1.4.2.1     skrll     ACPI_STATUS             Status = AE_OK;
    221          1.1    jruoho 
    222          1.1    jruoho 
    223          1.1    jruoho     WalkState->Op = Op;
    224          1.1    jruoho     WalkState->Opcode = Op->Common.AmlOpcode;
    225          1.1    jruoho     WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
    226          1.1    jruoho 
    227          1.1    jruoho     DbgPrint (ASL_PARSE_OUTPUT, "[%.4d] Opcode: %12.12s ",
    228  1.1.1.4.2.1     skrll         Op->Asl.LogicalLineNumber, Op->Asl.ParseOpName);
    229  1.1.1.4.2.1     skrll 
    230  1.1.1.4.2.1     skrll     /*
    231  1.1.1.4.2.1     skrll      * TBD: Ignore buffer constants for now. The problem is that these
    232  1.1.1.4.2.1     skrll      * constants have been transformed into RAW_DATA at this point, from
    233  1.1.1.4.2.1     skrll      * the parse tree transform process which currently happens before
    234  1.1.1.4.2.1     skrll      * the constant folding process. We may need to defer this transform
    235  1.1.1.4.2.1     skrll      * for buffer until after the constant folding.
    236  1.1.1.4.2.1     skrll      */
    237  1.1.1.4.2.1     skrll     if (WalkState->Opcode == AML_BUFFER_OP)
    238  1.1.1.4.2.1     skrll     {
    239  1.1.1.4.2.1     skrll         Status = AE_TYPE;
    240  1.1.1.4.2.1     skrll         goto CleanupAndExit;
    241  1.1.1.4.2.1     skrll     }
    242          1.1    jruoho 
    243      1.1.1.3  christos     /*
    244      1.1.1.3  christos      * These opcodes do not appear in the OpcodeInfo table, but
    245      1.1.1.3  christos      * they represent constants, so abort the constant walk now.
    246      1.1.1.3  christos      */
    247      1.1.1.3  christos     if ((WalkState->Opcode == AML_RAW_DATA_BYTE) ||
    248      1.1.1.3  christos         (WalkState->Opcode == AML_RAW_DATA_WORD) ||
    249      1.1.1.3  christos         (WalkState->Opcode == AML_RAW_DATA_DWORD) ||
    250      1.1.1.3  christos         (WalkState->Opcode == AML_RAW_DATA_QWORD))
    251      1.1.1.3  christos     {
    252  1.1.1.4.2.1     skrll         DbgPrint (ASL_PARSE_OUTPUT, "RAW DATA");
    253  1.1.1.4.2.1     skrll         Status = AE_TYPE;
    254  1.1.1.4.2.1     skrll         goto CleanupAndExit;
    255      1.1.1.3  christos     }
    256      1.1.1.3  christos 
    257  1.1.1.4.2.1     skrll     /* Type 3/4/5 opcodes have the AML_CONSTANT flag set */
    258  1.1.1.4.2.1     skrll 
    259          1.1    jruoho     if (!(WalkState->OpInfo->Flags & AML_CONSTANT))
    260          1.1    jruoho     {
    261  1.1.1.4.2.1     skrll         /* Not 3/4/5 opcode, but maybe can convert to STORE */
    262          1.1    jruoho 
    263          1.1    jruoho         if (Op->Asl.CompileFlags & NODE_IS_TARGET)
    264          1.1    jruoho         {
    265          1.1    jruoho             DbgPrint (ASL_PARSE_OUTPUT,
    266  1.1.1.4.2.1     skrll                 "**** Valid Target, transform to Store ****\n");
    267  1.1.1.4.2.1     skrll             return (AE_CTRL_RETURN_VALUE);
    268          1.1    jruoho         }
    269          1.1    jruoho 
    270  1.1.1.4.2.1     skrll         /* Expression cannot be reduced */
    271          1.1    jruoho 
    272  1.1.1.4.2.1     skrll         DbgPrint (ASL_PARSE_OUTPUT,
    273  1.1.1.4.2.1     skrll             "**** Not a Type 3/4/5 opcode (%s) ****",
    274  1.1.1.4.2.1     skrll              Op->Asl.ParseOpName);
    275          1.1    jruoho 
    276  1.1.1.4.2.1     skrll         Status = AE_TYPE;
    277  1.1.1.4.2.1     skrll         goto CleanupAndExit;
    278          1.1    jruoho     }
    279          1.1    jruoho 
    280          1.1    jruoho     /* Debug output */
    281          1.1    jruoho 
    282          1.1    jruoho     DbgPrint (ASL_PARSE_OUTPUT, "TYPE_345");
    283          1.1    jruoho 
    284          1.1    jruoho     if (Op->Asl.CompileFlags & NODE_IS_TARGET)
    285          1.1    jruoho     {
    286  1.1.1.4.2.1     skrll         if (Op->Asl.ParseOpcode == PARSEOP_ZERO)
    287  1.1.1.4.2.1     skrll         {
    288  1.1.1.4.2.1     skrll             DbgPrint (ASL_PARSE_OUTPUT, "%-16s", " NULL TARGET");
    289  1.1.1.4.2.1     skrll         }
    290  1.1.1.4.2.1     skrll         else
    291  1.1.1.4.2.1     skrll         {
    292  1.1.1.4.2.1     skrll             DbgPrint (ASL_PARSE_OUTPUT, "%-16s", " VALID TARGET");
    293  1.1.1.4.2.1     skrll         }
    294          1.1    jruoho     }
    295          1.1    jruoho     if (Op->Asl.CompileFlags & NODE_IS_TERM_ARG)
    296          1.1    jruoho     {
    297  1.1.1.4.2.1     skrll         DbgPrint (ASL_PARSE_OUTPUT, "%-16s", " TERMARG");
    298          1.1    jruoho     }
    299          1.1    jruoho 
    300  1.1.1.4.2.1     skrll CleanupAndExit:
    301  1.1.1.4.2.1     skrll 
    302  1.1.1.4.2.1     skrll     /* Dump the node compile flags also */
    303  1.1.1.4.2.1     skrll 
    304  1.1.1.4.2.1     skrll     TrPrintNodeCompileFlags (Op->Asl.CompileFlags);
    305      1.1.1.3  christos     DbgPrint (ASL_PARSE_OUTPUT, "\n");
    306  1.1.1.4.2.1     skrll     return (Status);
    307          1.1    jruoho }
    308          1.1    jruoho 
    309          1.1    jruoho 
    310          1.1    jruoho /*******************************************************************************
    311          1.1    jruoho  *
    312  1.1.1.4.2.1     skrll  * FUNCTION:    TrSimpleConstantReduction
    313          1.1    jruoho  *
    314  1.1.1.4.2.1     skrll  * PARAMETERS:  Op                  - Parent operator to be transformed
    315  1.1.1.4.2.1     skrll  *              WalkState           - Current walk state
    316          1.1    jruoho  *
    317          1.1    jruoho  * RETURN:      Status
    318          1.1    jruoho  *
    319  1.1.1.4.2.1     skrll  * DESCRIPTION: Reduce an entire AML operation to a single constant. The
    320  1.1.1.4.2.1     skrll  *              operation must not have a target operand.
    321  1.1.1.4.2.1     skrll  *
    322  1.1.1.4.2.1     skrll  *              Add (32,64) --> 96
    323          1.1    jruoho  *
    324          1.1    jruoho  ******************************************************************************/
    325          1.1    jruoho 
    326  1.1.1.4.2.1     skrll static ACPI_STATUS
    327  1.1.1.4.2.1     skrll TrSimpleConstantReduction (
    328          1.1    jruoho     ACPI_PARSE_OBJECT       *Op,
    329  1.1.1.4.2.1     skrll     ACPI_WALK_STATE         *WalkState)
    330          1.1    jruoho {
    331          1.1    jruoho     ACPI_PARSE_OBJECT       *RootOp;
    332          1.1    jruoho     ACPI_PARSE_OBJECT       *OriginalParentOp;
    333  1.1.1.4.2.1     skrll     ACPI_OPERAND_OBJECT     *ObjDesc;
    334  1.1.1.4.2.1     skrll     ACPI_STATUS             Status;
    335          1.1    jruoho 
    336          1.1    jruoho 
    337  1.1.1.4.2.1     skrll     DbgPrint (ASL_PARSE_OUTPUT,
    338  1.1.1.4.2.1     skrll         "Simple subtree constant reduction, operator to constant\n");
    339  1.1.1.4.2.1     skrll 
    340  1.1.1.4.2.1     skrll     /* Allocate a new temporary root for this subtree */
    341  1.1.1.4.2.1     skrll 
    342  1.1.1.4.2.1     skrll     RootOp = TrAllocateNode (PARSEOP_INTEGER);
    343  1.1.1.4.2.1     skrll     if (!RootOp)
    344          1.1    jruoho     {
    345  1.1.1.4.2.1     skrll         return (AE_NO_MEMORY);
    346          1.1    jruoho     }
    347          1.1    jruoho 
    348  1.1.1.4.2.1     skrll     RootOp->Common.AmlOpcode = AML_INT_EVAL_SUBTREE_OP;
    349          1.1    jruoho 
    350  1.1.1.4.2.1     skrll     OriginalParentOp = Op->Common.Parent;
    351  1.1.1.4.2.1     skrll     Op->Common.Parent = RootOp;
    352          1.1    jruoho 
    353  1.1.1.4.2.1     skrll     /* Hand off the subtree to the AML interpreter */
    354          1.1    jruoho 
    355  1.1.1.4.2.1     skrll     WalkState->CallerReturnDesc = &ObjDesc;
    356  1.1.1.4.2.1     skrll 
    357  1.1.1.4.2.1     skrll     Status = TrWalkParseTree (Op, ASL_WALK_VISIT_TWICE,
    358  1.1.1.4.2.1     skrll         OpcAmlEvaluationWalk1, OpcAmlEvaluationWalk2, WalkState);
    359  1.1.1.4.2.1     skrll 
    360  1.1.1.4.2.1     skrll     /* Restore original parse tree */
    361          1.1    jruoho 
    362  1.1.1.4.2.1     skrll     Op->Common.Parent = OriginalParentOp;
    363  1.1.1.4.2.1     skrll 
    364  1.1.1.4.2.1     skrll     if (ACPI_FAILURE (Status))
    365  1.1.1.4.2.1     skrll     {
    366  1.1.1.4.2.1     skrll         DbgPrint (ASL_PARSE_OUTPUT,
    367  1.1.1.4.2.1     skrll             "Constant Subtree evaluation(1), %s\n",
    368  1.1.1.4.2.1     skrll             AcpiFormatException (Status));
    369  1.1.1.4.2.1     skrll         return (Status);
    370          1.1    jruoho     }
    371          1.1    jruoho 
    372  1.1.1.4.2.1     skrll     /* Get the final result */
    373          1.1    jruoho 
    374  1.1.1.4.2.1     skrll     Status = AcpiDsResultPop (&ObjDesc, WalkState);
    375  1.1.1.4.2.1     skrll     if (ACPI_FAILURE (Status))
    376          1.1    jruoho     {
    377  1.1.1.4.2.1     skrll         DbgPrint (ASL_PARSE_OUTPUT,
    378  1.1.1.4.2.1     skrll             "Constant Subtree evaluation(2), %s\n",
    379  1.1.1.4.2.1     skrll             AcpiFormatException (Status));
    380  1.1.1.4.2.1     skrll         return (Status);
    381          1.1    jruoho     }
    382          1.1    jruoho 
    383  1.1.1.4.2.1     skrll     TrInstallReducedConstant (Op, ObjDesc);
    384          1.1    jruoho 
    385  1.1.1.4.2.1     skrll     UtSetParseOpName (Op);
    386  1.1.1.4.2.1     skrll     Op->Asl.Child = NULL;
    387  1.1.1.4.2.1     skrll     return (AE_OK);
    388  1.1.1.4.2.1     skrll }
    389  1.1.1.4.2.1     skrll 
    390  1.1.1.4.2.1     skrll 
    391  1.1.1.4.2.1     skrll /*******************************************************************************
    392  1.1.1.4.2.1     skrll  *
    393  1.1.1.4.2.1     skrll  * FUNCTION:    TrTransformToStoreOp
    394  1.1.1.4.2.1     skrll  *
    395  1.1.1.4.2.1     skrll  * PARAMETERS:  Op                  - Parent operator to be transformed
    396  1.1.1.4.2.1     skrll  *              WalkState           - Current walk state
    397  1.1.1.4.2.1     skrll  *
    398  1.1.1.4.2.1     skrll  * RETURN:      Status
    399  1.1.1.4.2.1     skrll  *
    400  1.1.1.4.2.1     skrll  * DESCRIPTION: Transforms a single AML operation with a constant and target
    401  1.1.1.4.2.1     skrll  *              to a simple store operation:
    402  1.1.1.4.2.1     skrll  *
    403  1.1.1.4.2.1     skrll  *              Add (32,64,DATA) --> Store (96,DATA)
    404  1.1.1.4.2.1     skrll  *
    405  1.1.1.4.2.1     skrll  ******************************************************************************/
    406  1.1.1.4.2.1     skrll 
    407  1.1.1.4.2.1     skrll static ACPI_STATUS
    408  1.1.1.4.2.1     skrll TrTransformToStoreOp (
    409  1.1.1.4.2.1     skrll     ACPI_PARSE_OBJECT       *Op,
    410  1.1.1.4.2.1     skrll     ACPI_WALK_STATE         *WalkState)
    411  1.1.1.4.2.1     skrll {
    412  1.1.1.4.2.1     skrll     ACPI_PARSE_OBJECT       *OriginalTarget;
    413  1.1.1.4.2.1     skrll     ACPI_PARSE_OBJECT       *NewTarget;
    414  1.1.1.4.2.1     skrll     ACPI_PARSE_OBJECT       *Child1;
    415  1.1.1.4.2.1     skrll     ACPI_PARSE_OBJECT       *Child2;
    416  1.1.1.4.2.1     skrll     ACPI_OPERAND_OBJECT     *ObjDesc;
    417  1.1.1.4.2.1     skrll     ACPI_PARSE_OBJECT       *NewParent;
    418  1.1.1.4.2.1     skrll     ACPI_PARSE_OBJECT       *OriginalParent;
    419  1.1.1.4.2.1     skrll     ACPI_STATUS             Status;
    420  1.1.1.4.2.1     skrll 
    421  1.1.1.4.2.1     skrll 
    422  1.1.1.4.2.1     skrll     DbgPrint (ASL_PARSE_OUTPUT,
    423  1.1.1.4.2.1     skrll         "Reduction/Transform to StoreOp: Store(Constant, Target)\n");
    424  1.1.1.4.2.1     skrll 
    425  1.1.1.4.2.1     skrll     /* Extract the operands */
    426  1.1.1.4.2.1     skrll 
    427  1.1.1.4.2.1     skrll     Child1 = Op->Asl.Child;
    428  1.1.1.4.2.1     skrll     Child2 = Child1->Asl.Next;
    429          1.1    jruoho 
    430          1.1    jruoho     /*
    431  1.1.1.4.2.1     skrll      * Special case for DIVIDE -- it has two targets. The first
    432  1.1.1.4.2.1     skrll      * is for the remainder and if present, we will not attempt
    433  1.1.1.4.2.1     skrll      * to reduce the expression.
    434          1.1    jruoho      */
    435  1.1.1.4.2.1     skrll     if (Op->Asl.ParseOpcode == PARSEOP_DIVIDE)
    436          1.1    jruoho     {
    437  1.1.1.4.2.1     skrll         Child2 = Child2->Asl.Next;
    438  1.1.1.4.2.1     skrll         if (Child2->Asl.ParseOpcode != PARSEOP_ZERO)
    439          1.1    jruoho         {
    440  1.1.1.4.2.1     skrll             DbgPrint (ASL_PARSE_OUTPUT,
    441  1.1.1.4.2.1     skrll                 "Cannot reduce DIVIDE - has two targets\n\n");
    442          1.1    jruoho             return (AE_OK);
    443          1.1    jruoho         }
    444  1.1.1.4.2.1     skrll     }
    445  1.1.1.4.2.1     skrll 
    446  1.1.1.4.2.1     skrll     /*
    447  1.1.1.4.2.1     skrll      * Create a NULL (zero) target so that we can use the
    448  1.1.1.4.2.1     skrll      * interpreter to evaluate the expression.
    449  1.1.1.4.2.1     skrll      */
    450  1.1.1.4.2.1     skrll     NewTarget = TrCreateNullTarget ();
    451  1.1.1.4.2.1     skrll     NewTarget->Common.AmlOpcode = AML_INT_NAMEPATH_OP;
    452          1.1    jruoho 
    453  1.1.1.4.2.1     skrll     /* Handle one-operand cases (NOT, TOBCD, etc.) */
    454          1.1    jruoho 
    455  1.1.1.4.2.1     skrll     if (!Child2->Asl.Next)
    456          1.1    jruoho     {
    457  1.1.1.4.2.1     skrll         Child2 = Child1;
    458  1.1.1.4.2.1     skrll     }
    459          1.1    jruoho 
    460  1.1.1.4.2.1     skrll     /* Link in new NULL target as the last operand */
    461          1.1    jruoho 
    462  1.1.1.4.2.1     skrll     OriginalTarget = Child2->Asl.Next;
    463  1.1.1.4.2.1     skrll     Child2->Asl.Next = NewTarget;
    464  1.1.1.4.2.1     skrll     NewTarget->Asl.Parent = OriginalTarget->Asl.Parent;
    465          1.1    jruoho 
    466  1.1.1.4.2.1     skrll     NewParent = TrAllocateNode (PARSEOP_INTEGER);
    467  1.1.1.4.2.1     skrll     NewParent->Common.AmlOpcode = AML_INT_EVAL_SUBTREE_OP;
    468          1.1    jruoho 
    469  1.1.1.4.2.1     skrll     OriginalParent = Op->Common.Parent;
    470  1.1.1.4.2.1     skrll     Op->Common.Parent = NewParent;
    471          1.1    jruoho 
    472  1.1.1.4.2.1     skrll     /* Hand off the subtree to the AML interpreter */
    473          1.1    jruoho 
    474  1.1.1.4.2.1     skrll     WalkState->CallerReturnDesc = &ObjDesc;
    475          1.1    jruoho 
    476  1.1.1.4.2.1     skrll     Status = TrWalkParseTree (Op, ASL_WALK_VISIT_TWICE,
    477  1.1.1.4.2.1     skrll         OpcAmlEvaluationWalk1, OpcAmlEvaluationWalk2, WalkState);
    478  1.1.1.4.2.1     skrll     if (ACPI_FAILURE (Status))
    479  1.1.1.4.2.1     skrll     {
    480  1.1.1.4.2.1     skrll         DbgPrint (ASL_PARSE_OUTPUT,
    481  1.1.1.4.2.1     skrll             "Constant Subtree evaluation(3), %s\n",
    482  1.1.1.4.2.1     skrll             AcpiFormatException (Status));
    483  1.1.1.4.2.1     skrll         goto EvalError;
    484  1.1.1.4.2.1     skrll     }
    485          1.1    jruoho 
    486  1.1.1.4.2.1     skrll     /* Get the final result */
    487          1.1    jruoho 
    488  1.1.1.4.2.1     skrll     Status = AcpiDsResultPop (&ObjDesc, WalkState);
    489  1.1.1.4.2.1     skrll     if (ACPI_FAILURE (Status))
    490  1.1.1.4.2.1     skrll     {
    491  1.1.1.4.2.1     skrll         DbgPrint (ASL_PARSE_OUTPUT,
    492  1.1.1.4.2.1     skrll             "Constant Subtree evaluation(4), %s\n",
    493  1.1.1.4.2.1     skrll             AcpiFormatException (Status));
    494  1.1.1.4.2.1     skrll         goto EvalError;
    495  1.1.1.4.2.1     skrll     }
    496          1.1    jruoho 
    497  1.1.1.4.2.1     skrll     /* Folded constant is in ObjDesc, store into Child1 */
    498      1.1.1.3  christos 
    499  1.1.1.4.2.1     skrll     TrInstallReducedConstant (Child1, ObjDesc);
    500      1.1.1.3  christos 
    501  1.1.1.4.2.1     skrll     /* Convert operator to STORE */
    502          1.1    jruoho 
    503  1.1.1.4.2.1     skrll     Op->Asl.ParseOpcode = PARSEOP_STORE;
    504  1.1.1.4.2.1     skrll     Op->Asl.AmlOpcode = AML_STORE_OP;
    505  1.1.1.4.2.1     skrll     UtSetParseOpName (Op);
    506  1.1.1.4.2.1     skrll     Op->Common.Parent = OriginalParent;
    507          1.1    jruoho 
    508  1.1.1.4.2.1     skrll     /* Truncate any subtree expressions, they have been evaluated */
    509          1.1    jruoho 
    510  1.1.1.4.2.1     skrll     Child1->Asl.Child = NULL;
    511  1.1.1.4.2.1     skrll     Child2->Asl.Child = NULL;
    512          1.1    jruoho 
    513  1.1.1.4.2.1     skrll     /* First child is the folded constant */
    514          1.1    jruoho 
    515  1.1.1.4.2.1     skrll     /* Second child will be the target */
    516          1.1    jruoho 
    517  1.1.1.4.2.1     skrll     Child1->Asl.Next = OriginalTarget;
    518  1.1.1.4.2.1     skrll     return (AE_OK);
    519          1.1    jruoho 
    520          1.1    jruoho 
    521  1.1.1.4.2.1     skrll EvalError:
    522  1.1.1.4.2.1     skrll 
    523  1.1.1.4.2.1     skrll     /* Restore original links */
    524  1.1.1.4.2.1     skrll 
    525  1.1.1.4.2.1     skrll     Op->Common.Parent = OriginalParent;
    526  1.1.1.4.2.1     skrll     Child2->Asl.Next = OriginalTarget;
    527  1.1.1.4.2.1     skrll     return (Status);
    528  1.1.1.4.2.1     skrll }
    529  1.1.1.4.2.1     skrll 
    530  1.1.1.4.2.1     skrll 
    531  1.1.1.4.2.1     skrll /*******************************************************************************
    532  1.1.1.4.2.1     skrll  *
    533  1.1.1.4.2.1     skrll  * FUNCTION:    TrInstallReducedConstant
    534  1.1.1.4.2.1     skrll  *
    535  1.1.1.4.2.1     skrll  * PARAMETERS:  Op                  - Parent operator to be transformed
    536  1.1.1.4.2.1     skrll  *              ObjDesc             - Reduced constant to be installed
    537  1.1.1.4.2.1     skrll  *
    538  1.1.1.4.2.1     skrll  * RETURN:      None
    539  1.1.1.4.2.1     skrll  *
    540  1.1.1.4.2.1     skrll  * DESCRIPTION: Transform the original operator to a simple constant.
    541  1.1.1.4.2.1     skrll  *              Handles Integers, Strings, and Buffers.
    542  1.1.1.4.2.1     skrll  *
    543  1.1.1.4.2.1     skrll  ******************************************************************************/
    544          1.1    jruoho 
    545  1.1.1.4.2.1     skrll static void
    546  1.1.1.4.2.1     skrll TrInstallReducedConstant (
    547  1.1.1.4.2.1     skrll     ACPI_PARSE_OBJECT       *Op,
    548  1.1.1.4.2.1     skrll     ACPI_OPERAND_OBJECT     *ObjDesc)
    549  1.1.1.4.2.1     skrll {
    550  1.1.1.4.2.1     skrll     ACPI_PARSE_OBJECT       *RootOp;
    551          1.1    jruoho 
    552          1.1    jruoho 
    553  1.1.1.4.2.1     skrll     TotalFolds++;
    554  1.1.1.4.2.1     skrll     AslError (ASL_OPTIMIZATION, ASL_MSG_CONSTANT_FOLDED, Op,
    555  1.1.1.4.2.1     skrll         Op->Asl.ParseOpName);
    556          1.1    jruoho 
    557  1.1.1.4.2.1     skrll     /*
    558  1.1.1.4.2.1     skrll      * Because we know we executed type 3/4/5 opcodes above, we know that
    559  1.1.1.4.2.1     skrll      * the result must be either an Integer, String, or Buffer.
    560  1.1.1.4.2.1     skrll      */
    561  1.1.1.4.2.1     skrll     switch (ObjDesc->Common.Type)
    562  1.1.1.4.2.1     skrll     {
    563  1.1.1.4.2.1     skrll     case ACPI_TYPE_INTEGER:
    564          1.1    jruoho 
    565  1.1.1.4.2.1     skrll         OpcUpdateIntegerNode (Op, ObjDesc->Integer.Value);
    566          1.1    jruoho 
    567  1.1.1.4.2.1     skrll         DbgPrint (ASL_PARSE_OUTPUT,
    568  1.1.1.4.2.1     skrll             "Constant expression reduced to (%s) %8.8X%8.8X\n\n",
    569  1.1.1.4.2.1     skrll             Op->Asl.ParseOpName,
    570  1.1.1.4.2.1     skrll             ACPI_FORMAT_UINT64 (Op->Common.Value.Integer));
    571  1.1.1.4.2.1     skrll         break;
    572          1.1    jruoho 
    573  1.1.1.4.2.1     skrll     case ACPI_TYPE_STRING:
    574          1.1    jruoho 
    575  1.1.1.4.2.1     skrll         Op->Asl.ParseOpcode = PARSEOP_STRING_LITERAL;
    576  1.1.1.4.2.1     skrll         Op->Common.AmlOpcode = AML_STRING_OP;
    577  1.1.1.4.2.1     skrll         Op->Asl.AmlLength = ACPI_STRLEN (ObjDesc->String.Pointer) + 1;
    578  1.1.1.4.2.1     skrll         Op->Common.Value.String = ObjDesc->String.Pointer;
    579  1.1.1.4.2.1     skrll 
    580  1.1.1.4.2.1     skrll         DbgPrint (ASL_PARSE_OUTPUT,
    581  1.1.1.4.2.1     skrll             "Constant expression reduced to (STRING) %s\n\n",
    582  1.1.1.4.2.1     skrll             Op->Common.Value.String);
    583          1.1    jruoho 
    584  1.1.1.4.2.1     skrll         break;
    585          1.1    jruoho 
    586  1.1.1.4.2.1     skrll     case ACPI_TYPE_BUFFER:
    587          1.1    jruoho 
    588  1.1.1.4.2.1     skrll         Op->Asl.ParseOpcode = PARSEOP_BUFFER;
    589  1.1.1.4.2.1     skrll         Op->Common.AmlOpcode = AML_BUFFER_OP;
    590  1.1.1.4.2.1     skrll         Op->Asl.CompileFlags = NODE_AML_PACKAGE;
    591  1.1.1.4.2.1     skrll         UtSetParseOpName (Op);
    592          1.1    jruoho 
    593  1.1.1.4.2.1     skrll         /* Child node is the buffer length */
    594          1.1    jruoho 
    595  1.1.1.4.2.1     skrll         RootOp = TrAllocateNode (PARSEOP_INTEGER);
    596          1.1    jruoho 
    597  1.1.1.4.2.1     skrll         RootOp->Asl.AmlOpcode = AML_DWORD_OP;
    598  1.1.1.4.2.1     skrll         RootOp->Asl.Value.Integer = ObjDesc->Buffer.Length;
    599  1.1.1.4.2.1     skrll         RootOp->Asl.Parent = Op;
    600  1.1.1.4.2.1     skrll 
    601  1.1.1.4.2.1     skrll         (void) OpcSetOptimalIntegerSize (RootOp);
    602  1.1.1.4.2.1     skrll 
    603  1.1.1.4.2.1     skrll         Op->Asl.Child = RootOp;
    604  1.1.1.4.2.1     skrll         Op = RootOp;
    605  1.1.1.4.2.1     skrll         UtSetParseOpName (Op);
    606  1.1.1.4.2.1     skrll 
    607  1.1.1.4.2.1     skrll         /* Peer to the child is the raw buffer data */
    608  1.1.1.4.2.1     skrll 
    609  1.1.1.4.2.1     skrll         RootOp = TrAllocateNode (PARSEOP_RAW_DATA);
    610  1.1.1.4.2.1     skrll         RootOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER;
    611  1.1.1.4.2.1     skrll         RootOp->Asl.AmlLength = ObjDesc->Buffer.Length;
    612  1.1.1.4.2.1     skrll         RootOp->Asl.Value.String = (char *) ObjDesc->Buffer.Pointer;
    613  1.1.1.4.2.1     skrll         RootOp->Asl.Parent = Op->Asl.Parent;
    614  1.1.1.4.2.1     skrll 
    615  1.1.1.4.2.1     skrll         Op->Asl.Next = RootOp;
    616  1.1.1.4.2.1     skrll         Op = RootOp;
    617  1.1.1.4.2.1     skrll 
    618  1.1.1.4.2.1     skrll         DbgPrint (ASL_PARSE_OUTPUT,
    619  1.1.1.4.2.1     skrll             "Constant expression reduced to (BUFFER) length %X\n\n",
    620  1.1.1.4.2.1     skrll             ObjDesc->Buffer.Length);
    621  1.1.1.4.2.1     skrll         break;
    622  1.1.1.4.2.1     skrll 
    623  1.1.1.4.2.1     skrll     default:
    624  1.1.1.4.2.1     skrll         break;
    625  1.1.1.4.2.1     skrll     }
    626          1.1    jruoho }
    627          1.1    jruoho 
    628      1.1.1.3  christos 
    629      1.1.1.3  christos /*******************************************************************************
    630      1.1.1.3  christos  *
    631      1.1.1.3  christos  * FUNCTION:    OpcUpdateIntegerNode
    632      1.1.1.3  christos  *
    633      1.1.1.3  christos  * PARAMETERS:  Op                  - Current parse object
    634  1.1.1.4.2.1     skrll  *              Value               - Value for the integer op
    635      1.1.1.3  christos  *
    636      1.1.1.3  christos  * RETURN:      None
    637      1.1.1.3  christos  *
    638  1.1.1.4.2.1     skrll  * DESCRIPTION: Update node to the correct Integer type and value
    639      1.1.1.3  christos  *
    640      1.1.1.3  christos  ******************************************************************************/
    641      1.1.1.3  christos 
    642      1.1.1.3  christos static void
    643      1.1.1.3  christos OpcUpdateIntegerNode (
    644      1.1.1.3  christos     ACPI_PARSE_OBJECT       *Op,
    645      1.1.1.3  christos     UINT64                  Value)
    646      1.1.1.3  christos {
    647      1.1.1.3  christos 
    648      1.1.1.3  christos     Op->Common.Value.Integer = Value;
    649      1.1.1.3  christos 
    650      1.1.1.3  christos     /*
    651      1.1.1.3  christos      * The AmlLength is used by the parser to indicate a constant,
    652      1.1.1.3  christos      * (if non-zero). Length is either (1/2/4/8)
    653      1.1.1.3  christos      */
    654      1.1.1.3  christos     switch (Op->Asl.AmlLength)
    655      1.1.1.3  christos     {
    656      1.1.1.3  christos     case 1:
    657      1.1.1.3  christos 
    658      1.1.1.3  christos         TrUpdateNode (PARSEOP_BYTECONST, Op);
    659      1.1.1.3  christos         Op->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
    660      1.1.1.3  christos         break;
    661      1.1.1.3  christos 
    662      1.1.1.3  christos     case 2:
    663      1.1.1.3  christos 
    664      1.1.1.3  christos         TrUpdateNode (PARSEOP_WORDCONST, Op);
    665      1.1.1.3  christos         Op->Asl.AmlOpcode = AML_RAW_DATA_WORD;
    666      1.1.1.3  christos         break;
    667      1.1.1.3  christos 
    668      1.1.1.3  christos     case 4:
    669      1.1.1.3  christos 
    670      1.1.1.3  christos         TrUpdateNode (PARSEOP_DWORDCONST, Op);
    671      1.1.1.3  christos         Op->Asl.AmlOpcode = AML_RAW_DATA_DWORD;
    672      1.1.1.3  christos         break;
    673      1.1.1.3  christos 
    674      1.1.1.3  christos     case 8:
    675      1.1.1.3  christos 
    676      1.1.1.3  christos         TrUpdateNode (PARSEOP_QWORDCONST, Op);
    677      1.1.1.3  christos         Op->Asl.AmlOpcode = AML_RAW_DATA_QWORD;
    678      1.1.1.3  christos         break;
    679      1.1.1.3  christos 
    680      1.1.1.3  christos     case 0:
    681      1.1.1.3  christos     default:
    682      1.1.1.3  christos 
    683      1.1.1.3  christos         OpcSetOptimalIntegerSize (Op);
    684      1.1.1.3  christos         TrUpdateNode (PARSEOP_INTEGER, Op);
    685      1.1.1.3  christos         break;
    686      1.1.1.3  christos     }
    687      1.1.1.3  christos 
    688      1.1.1.3  christos     Op->Asl.AmlLength = 0;
    689      1.1.1.3  christos }
    690  1.1.1.4.2.1     skrll 
    691  1.1.1.4.2.1     skrll 
    692  1.1.1.4.2.1     skrll /*******************************************************************************
    693  1.1.1.4.2.1     skrll  *
    694  1.1.1.4.2.1     skrll  * FUNCTION:    OpcAmlEvaluationWalk1
    695  1.1.1.4.2.1     skrll  *
    696  1.1.1.4.2.1     skrll  * PARAMETERS:  ASL_WALK_CALLBACK
    697  1.1.1.4.2.1     skrll  *
    698  1.1.1.4.2.1     skrll  * RETURN:      Status
    699  1.1.1.4.2.1     skrll  *
    700  1.1.1.4.2.1     skrll  * DESCRIPTION: Descending callback for AML execution of constant subtrees
    701  1.1.1.4.2.1     skrll  *
    702  1.1.1.4.2.1     skrll  ******************************************************************************/
    703  1.1.1.4.2.1     skrll 
    704  1.1.1.4.2.1     skrll static ACPI_STATUS
    705  1.1.1.4.2.1     skrll OpcAmlEvaluationWalk1 (
    706  1.1.1.4.2.1     skrll     ACPI_PARSE_OBJECT       *Op,
    707  1.1.1.4.2.1     skrll     UINT32                  Level,
    708  1.1.1.4.2.1     skrll     void                    *Context)
    709  1.1.1.4.2.1     skrll {
    710  1.1.1.4.2.1     skrll     ACPI_WALK_STATE         *WalkState = Context;
    711  1.1.1.4.2.1     skrll     ACPI_STATUS             Status;
    712  1.1.1.4.2.1     skrll     ACPI_PARSE_OBJECT       *OutOp;
    713  1.1.1.4.2.1     skrll 
    714  1.1.1.4.2.1     skrll 
    715  1.1.1.4.2.1     skrll     WalkState->Op = Op;
    716  1.1.1.4.2.1     skrll     WalkState->Opcode = Op->Common.AmlOpcode;
    717  1.1.1.4.2.1     skrll     WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
    718  1.1.1.4.2.1     skrll 
    719  1.1.1.4.2.1     skrll     /* Copy child pointer to Arg for compatibility with Interpreter */
    720  1.1.1.4.2.1     skrll 
    721  1.1.1.4.2.1     skrll     if (Op->Asl.Child)
    722  1.1.1.4.2.1     skrll     {
    723  1.1.1.4.2.1     skrll         Op->Common.Value.Arg = Op->Asl.Child;
    724  1.1.1.4.2.1     skrll     }
    725  1.1.1.4.2.1     skrll 
    726  1.1.1.4.2.1     skrll     /* Call AML dispatcher */
    727  1.1.1.4.2.1     skrll 
    728  1.1.1.4.2.1     skrll     Status = AcpiDsExecBeginOp (WalkState, &OutOp);
    729  1.1.1.4.2.1     skrll     if (ACPI_FAILURE (Status))
    730  1.1.1.4.2.1     skrll     {
    731  1.1.1.4.2.1     skrll         DbgPrint (ASL_PARSE_OUTPUT,
    732  1.1.1.4.2.1     skrll             "%s Constant interpretation failed (1) - %s\n",
    733  1.1.1.4.2.1     skrll             Op->Asl.ParseOpName, AcpiFormatException (Status));
    734  1.1.1.4.2.1     skrll     }
    735  1.1.1.4.2.1     skrll 
    736  1.1.1.4.2.1     skrll     return (Status);
    737  1.1.1.4.2.1     skrll }
    738  1.1.1.4.2.1     skrll 
    739  1.1.1.4.2.1     skrll 
    740  1.1.1.4.2.1     skrll /*******************************************************************************
    741  1.1.1.4.2.1     skrll  *
    742  1.1.1.4.2.1     skrll  * FUNCTION:    OpcAmlEvaluationWalk2
    743  1.1.1.4.2.1     skrll  *
    744  1.1.1.4.2.1     skrll  * PARAMETERS:  ASL_WALK_CALLBACK
    745  1.1.1.4.2.1     skrll  *
    746  1.1.1.4.2.1     skrll  * RETURN:      Status
    747  1.1.1.4.2.1     skrll  *
    748  1.1.1.4.2.1     skrll  * DESCRIPTION: Ascending callback for AML execution of constant subtrees
    749  1.1.1.4.2.1     skrll  *
    750  1.1.1.4.2.1     skrll  ******************************************************************************/
    751  1.1.1.4.2.1     skrll 
    752  1.1.1.4.2.1     skrll static ACPI_STATUS
    753  1.1.1.4.2.1     skrll OpcAmlEvaluationWalk2 (
    754  1.1.1.4.2.1     skrll     ACPI_PARSE_OBJECT       *Op,
    755  1.1.1.4.2.1     skrll     UINT32                  Level,
    756  1.1.1.4.2.1     skrll     void                    *Context)
    757  1.1.1.4.2.1     skrll {
    758  1.1.1.4.2.1     skrll     ACPI_WALK_STATE         *WalkState = Context;
    759  1.1.1.4.2.1     skrll     ACPI_STATUS             Status;
    760  1.1.1.4.2.1     skrll 
    761  1.1.1.4.2.1     skrll 
    762  1.1.1.4.2.1     skrll     WalkState->Op = Op;
    763  1.1.1.4.2.1     skrll     WalkState->Opcode = Op->Common.AmlOpcode;
    764  1.1.1.4.2.1     skrll     WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
    765  1.1.1.4.2.1     skrll 
    766  1.1.1.4.2.1     skrll     /* Copy child pointer to Arg for compatibility with Interpreter */
    767  1.1.1.4.2.1     skrll 
    768  1.1.1.4.2.1     skrll     if (Op->Asl.Child)
    769  1.1.1.4.2.1     skrll     {
    770  1.1.1.4.2.1     skrll         Op->Common.Value.Arg = Op->Asl.Child;
    771  1.1.1.4.2.1     skrll     }
    772  1.1.1.4.2.1     skrll 
    773  1.1.1.4.2.1     skrll     /* Call AML dispatcher */
    774  1.1.1.4.2.1     skrll 
    775  1.1.1.4.2.1     skrll     Status = AcpiDsExecEndOp (WalkState);
    776  1.1.1.4.2.1     skrll     if (ACPI_FAILURE (Status))
    777  1.1.1.4.2.1     skrll     {
    778  1.1.1.4.2.1     skrll         DbgPrint (ASL_PARSE_OUTPUT,
    779  1.1.1.4.2.1     skrll             "%s: Constant interpretation failed (2) - %s\n",
    780  1.1.1.4.2.1     skrll             Op->Asl.ParseOpName, AcpiFormatException (Status));
    781  1.1.1.4.2.1     skrll     }
    782  1.1.1.4.2.1     skrll 
    783  1.1.1.4.2.1     skrll     return (Status);
    784  1.1.1.4.2.1     skrll }
    785