xref: /illumos-gate/usr/src/cmd/acpi/iasl/aslfold.c (revision 35786f6866ae52207d0f1a25fe7ca5f652f32ce0)
1bc36eafdSMike Gerdts /******************************************************************************
2bc36eafdSMike Gerdts  *
3bc36eafdSMike Gerdts  * Module Name: aslfold - Constant folding
4bc36eafdSMike Gerdts  *
5bc36eafdSMike Gerdts  *****************************************************************************/
6bc36eafdSMike Gerdts 
7*35786f68SRobert Mustacchi /******************************************************************************
8*35786f68SRobert Mustacchi  *
9*35786f68SRobert Mustacchi  * 1. Copyright Notice
10*35786f68SRobert Mustacchi  *
11*35786f68SRobert Mustacchi  * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
12bc36eafdSMike Gerdts  * All rights reserved.
13bc36eafdSMike Gerdts  *
14*35786f68SRobert Mustacchi  * 2. License
15*35786f68SRobert Mustacchi  *
16*35786f68SRobert Mustacchi  * 2.1. This is your license from Intel Corp. under its intellectual property
17*35786f68SRobert Mustacchi  * rights. You may have additional license terms from the party that provided
18*35786f68SRobert Mustacchi  * you this software, covering your right to use that party's intellectual
19*35786f68SRobert Mustacchi  * property rights.
20*35786f68SRobert Mustacchi  *
21*35786f68SRobert Mustacchi  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22*35786f68SRobert Mustacchi  * copy of the source code appearing in this file ("Covered Code") an
23*35786f68SRobert Mustacchi  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24*35786f68SRobert Mustacchi  * base code distributed originally by Intel ("Original Intel Code") to copy,
25*35786f68SRobert Mustacchi  * make derivatives, distribute, use and display any portion of the Covered
26*35786f68SRobert Mustacchi  * Code in any form, with the right to sublicense such rights; and
27*35786f68SRobert Mustacchi  *
28*35786f68SRobert Mustacchi  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29*35786f68SRobert Mustacchi  * license (with the right to sublicense), under only those claims of Intel
30*35786f68SRobert Mustacchi  * patents that are infringed by the Original Intel Code, to make, use, sell,
31*35786f68SRobert Mustacchi  * offer to sell, and import the Covered Code and derivative works thereof
32*35786f68SRobert Mustacchi  * solely to the minimum extent necessary to exercise the above copyright
33*35786f68SRobert Mustacchi  * license, and in no event shall the patent license extend to any additions
34*35786f68SRobert Mustacchi  * to or modifications of the Original Intel Code. No other license or right
35*35786f68SRobert Mustacchi  * is granted directly or by implication, estoppel or otherwise;
36*35786f68SRobert Mustacchi  *
37*35786f68SRobert Mustacchi  * The above copyright and patent license is granted only if the following
38*35786f68SRobert Mustacchi  * conditions are met:
39*35786f68SRobert Mustacchi  *
40*35786f68SRobert Mustacchi  * 3. Conditions
41*35786f68SRobert Mustacchi  *
42*35786f68SRobert Mustacchi  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43*35786f68SRobert Mustacchi  * Redistribution of source code of any substantial portion of the Covered
44*35786f68SRobert Mustacchi  * Code or modification with rights to further distribute source must include
45*35786f68SRobert Mustacchi  * the above Copyright Notice, the above License, this list of Conditions,
46*35786f68SRobert Mustacchi  * and the following Disclaimer and Export Compliance provision. In addition,
47*35786f68SRobert Mustacchi  * Licensee must cause all Covered Code to which Licensee contributes to
48*35786f68SRobert Mustacchi  * contain a file documenting the changes Licensee made to create that Covered
49*35786f68SRobert Mustacchi  * Code and the date of any change. Licensee must include in that file the
50*35786f68SRobert Mustacchi  * documentation of any changes made by any predecessor Licensee. Licensee
51*35786f68SRobert Mustacchi  * must include a prominent statement that the modification is derived,
52*35786f68SRobert Mustacchi  * directly or indirectly, from Original Intel Code.
53*35786f68SRobert Mustacchi  *
54*35786f68SRobert Mustacchi  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55*35786f68SRobert Mustacchi  * Redistribution of source code of any substantial portion of the Covered
56*35786f68SRobert Mustacchi  * Code or modification without rights to further distribute source must
57*35786f68SRobert Mustacchi  * include the following Disclaimer and Export Compliance provision in the
58*35786f68SRobert Mustacchi  * documentation and/or other materials provided with distribution. In
59*35786f68SRobert Mustacchi  * addition, Licensee may not authorize further sublicense of source of any
60*35786f68SRobert Mustacchi  * portion of the Covered Code, and must include terms to the effect that the
61*35786f68SRobert Mustacchi  * license from Licensee to its licensee is limited to the intellectual
62*35786f68SRobert Mustacchi  * property embodied in the software Licensee provides to its licensee, and
63*35786f68SRobert Mustacchi  * not to intellectual property embodied in modifications its licensee may
64*35786f68SRobert Mustacchi  * make.
65*35786f68SRobert Mustacchi  *
66*35786f68SRobert Mustacchi  * 3.3. Redistribution of Executable. Redistribution in executable form of any
67*35786f68SRobert Mustacchi  * substantial portion of the Covered Code or modification must reproduce the
68*35786f68SRobert Mustacchi  * above Copyright Notice, and the following Disclaimer and Export Compliance
69*35786f68SRobert Mustacchi  * provision in the documentation and/or other materials provided with the
70*35786f68SRobert Mustacchi  * distribution.
71*35786f68SRobert Mustacchi  *
72*35786f68SRobert Mustacchi  * 3.4. Intel retains all right, title, and interest in and to the Original
73*35786f68SRobert Mustacchi  * Intel Code.
74*35786f68SRobert Mustacchi  *
75*35786f68SRobert Mustacchi  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76*35786f68SRobert Mustacchi  * Intel shall be used in advertising or otherwise to promote the sale, use or
77*35786f68SRobert Mustacchi  * other dealings in products derived from or relating to the Covered Code
78*35786f68SRobert Mustacchi  * without prior written authorization from Intel.
79*35786f68SRobert Mustacchi  *
80*35786f68SRobert Mustacchi  * 4. Disclaimer and Export Compliance
81*35786f68SRobert Mustacchi  *
82*35786f68SRobert Mustacchi  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83*35786f68SRobert Mustacchi  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84*35786f68SRobert Mustacchi  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85*35786f68SRobert Mustacchi  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86*35786f68SRobert Mustacchi  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87*35786f68SRobert Mustacchi  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88*35786f68SRobert Mustacchi  * PARTICULAR PURPOSE.
89*35786f68SRobert Mustacchi  *
90*35786f68SRobert Mustacchi  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91*35786f68SRobert Mustacchi  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92*35786f68SRobert Mustacchi  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93*35786f68SRobert Mustacchi  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94*35786f68SRobert Mustacchi  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95*35786f68SRobert Mustacchi  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96*35786f68SRobert Mustacchi  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97*35786f68SRobert Mustacchi  * LIMITED REMEDY.
98*35786f68SRobert Mustacchi  *
99*35786f68SRobert Mustacchi  * 4.3. Licensee shall not export, either directly or indirectly, any of this
100*35786f68SRobert Mustacchi  * software or system incorporating such software without first obtaining any
101*35786f68SRobert Mustacchi  * required license or other approval from the U. S. Department of Commerce or
102*35786f68SRobert Mustacchi  * any other agency or department of the United States Government. In the
103*35786f68SRobert Mustacchi  * event Licensee exports any such software from the United States or
104*35786f68SRobert Mustacchi  * re-exports any such software from a foreign destination, Licensee shall
105*35786f68SRobert Mustacchi  * ensure that the distribution and export/re-export of the software is in
106*35786f68SRobert Mustacchi  * compliance with all laws, regulations, orders, or other restrictions of the
107*35786f68SRobert Mustacchi  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108*35786f68SRobert Mustacchi  * any of its subsidiaries will export/re-export any technical data, process,
109*35786f68SRobert Mustacchi  * software, or service, directly or indirectly, to any country for which the
110*35786f68SRobert Mustacchi  * United States government or any agency thereof requires an export license,
111*35786f68SRobert Mustacchi  * other governmental approval, or letter of assurance, without first obtaining
112*35786f68SRobert Mustacchi  * such license, approval or letter.
113*35786f68SRobert Mustacchi  *
114*35786f68SRobert Mustacchi  *****************************************************************************
115*35786f68SRobert Mustacchi  *
116*35786f68SRobert Mustacchi  * Alternatively, you may choose to be licensed under the terms of the
117*35786f68SRobert Mustacchi  * following license:
118*35786f68SRobert Mustacchi  *
119bc36eafdSMike Gerdts  * Redistribution and use in source and binary forms, with or without
120bc36eafdSMike Gerdts  * modification, are permitted provided that the following conditions
121bc36eafdSMike Gerdts  * are met:
122bc36eafdSMike Gerdts  * 1. Redistributions of source code must retain the above copyright
123bc36eafdSMike Gerdts  *    notice, this list of conditions, and the following disclaimer,
124bc36eafdSMike Gerdts  *    without modification.
125bc36eafdSMike Gerdts  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126bc36eafdSMike Gerdts  *    substantially similar to the "NO WARRANTY" disclaimer below
127bc36eafdSMike Gerdts  *    ("Disclaimer") and any redistribution must be conditioned upon
128bc36eafdSMike Gerdts  *    including a substantially similar Disclaimer requirement for further
129bc36eafdSMike Gerdts  *    binary redistribution.
130bc36eafdSMike Gerdts  * 3. Neither the names of the above-listed copyright holders nor the names
131bc36eafdSMike Gerdts  *    of any contributors may be used to endorse or promote products derived
132bc36eafdSMike Gerdts  *    from this software without specific prior written permission.
133bc36eafdSMike Gerdts  *
134*35786f68SRobert Mustacchi  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135*35786f68SRobert Mustacchi  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136*35786f68SRobert Mustacchi  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137*35786f68SRobert Mustacchi  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138*35786f68SRobert Mustacchi  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139*35786f68SRobert Mustacchi  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140*35786f68SRobert Mustacchi  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141*35786f68SRobert Mustacchi  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142*35786f68SRobert Mustacchi  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143*35786f68SRobert Mustacchi  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144*35786f68SRobert Mustacchi  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145*35786f68SRobert Mustacchi  *
146*35786f68SRobert Mustacchi  * Alternatively, you may choose to be licensed under the terms of the
147bc36eafdSMike Gerdts  * GNU General Public License ("GPL") version 2 as published by the Free
148bc36eafdSMike Gerdts  * Software Foundation.
149bc36eafdSMike Gerdts  *
150*35786f68SRobert Mustacchi  *****************************************************************************/
151bc36eafdSMike Gerdts 
152bc36eafdSMike Gerdts #include "aslcompiler.h"
153bc36eafdSMike Gerdts #include "aslcompiler.y.h"
154bc36eafdSMike Gerdts #include "amlcode.h"
155bc36eafdSMike Gerdts 
156bc36eafdSMike Gerdts #include "acdispat.h"
157bc36eafdSMike Gerdts #include "acparser.h"
158bc36eafdSMike Gerdts 
159bc36eafdSMike Gerdts #define _COMPONENT          ACPI_COMPILER
160bc36eafdSMike Gerdts         ACPI_MODULE_NAME    ("aslfold")
161bc36eafdSMike Gerdts 
162bc36eafdSMike Gerdts /* Local prototypes */
163bc36eafdSMike Gerdts 
164bc36eafdSMike Gerdts static ACPI_STATUS
165bc36eafdSMike Gerdts OpcAmlEvaluationWalk1 (
166bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *Op,
167bc36eafdSMike Gerdts     UINT32                  Level,
168bc36eafdSMike Gerdts     void                    *Context);
169bc36eafdSMike Gerdts 
170bc36eafdSMike Gerdts static ACPI_STATUS
171bc36eafdSMike Gerdts OpcAmlEvaluationWalk2 (
172bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *Op,
173bc36eafdSMike Gerdts     UINT32                  Level,
174bc36eafdSMike Gerdts     void                    *Context);
175bc36eafdSMike Gerdts 
176bc36eafdSMike Gerdts static ACPI_STATUS
177bc36eafdSMike Gerdts OpcAmlCheckForConstant (
178bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *Op,
179bc36eafdSMike Gerdts     UINT32                  Level,
180bc36eafdSMike Gerdts     void                    *Context);
181bc36eafdSMike Gerdts 
182bc36eafdSMike Gerdts static void
183bc36eafdSMike Gerdts OpcUpdateIntegerNode (
184bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *Op,
185bc36eafdSMike Gerdts     UINT64                  Value);
186bc36eafdSMike Gerdts 
187bc36eafdSMike Gerdts static ACPI_STATUS
188bc36eafdSMike Gerdts TrTransformToStoreOp (
189bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *Op,
190bc36eafdSMike Gerdts     ACPI_WALK_STATE         *WalkState);
191bc36eafdSMike Gerdts 
192bc36eafdSMike Gerdts static ACPI_STATUS
193bc36eafdSMike Gerdts TrSimpleConstantReduction (
194bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *Op,
195bc36eafdSMike Gerdts     ACPI_WALK_STATE         *WalkState);
196bc36eafdSMike Gerdts 
197bc36eafdSMike Gerdts static void
198bc36eafdSMike Gerdts TrInstallReducedConstant (
199bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *Op,
200bc36eafdSMike Gerdts     ACPI_OPERAND_OBJECT     *ObjDesc);
201bc36eafdSMike Gerdts 
202bc36eafdSMike Gerdts 
203bc36eafdSMike Gerdts /*******************************************************************************
204bc36eafdSMike Gerdts  *
205bc36eafdSMike Gerdts  * FUNCTION:    OpcAmlConstantWalk
206bc36eafdSMike Gerdts  *
207bc36eafdSMike Gerdts  * PARAMETERS:  ASL_WALK_CALLBACK
208bc36eafdSMike Gerdts  *
209bc36eafdSMike Gerdts  * RETURN:      Status
210bc36eafdSMike Gerdts  *
211bc36eafdSMike Gerdts  * DESCRIPTION: Reduce an Op and its subtree to a constant if possible.
212bc36eafdSMike Gerdts  *              Called during ascent of the parse tree.
213bc36eafdSMike Gerdts  *
214bc36eafdSMike Gerdts  ******************************************************************************/
215bc36eafdSMike Gerdts 
216bc36eafdSMike Gerdts ACPI_STATUS
OpcAmlConstantWalk(ACPI_PARSE_OBJECT * Op,UINT32 Level,void * Context)217bc36eafdSMike Gerdts OpcAmlConstantWalk (
218bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *Op,
219bc36eafdSMike Gerdts     UINT32                  Level,
220bc36eafdSMike Gerdts     void                    *Context)
221bc36eafdSMike Gerdts {
222bc36eafdSMike Gerdts     ACPI_WALK_STATE         *WalkState;
223bc36eafdSMike Gerdts     ACPI_STATUS             Status = AE_OK;
224bc36eafdSMike Gerdts 
225bc36eafdSMike Gerdts 
226bc36eafdSMike Gerdts     if (Op->Asl.CompileFlags == 0)
227bc36eafdSMike Gerdts     {
228bc36eafdSMike Gerdts         return (AE_OK);
229bc36eafdSMike Gerdts     }
230bc36eafdSMike Gerdts 
231bc36eafdSMike Gerdts     /*
232bc36eafdSMike Gerdts      * Only interested in subtrees that could possibly contain
233bc36eafdSMike Gerdts      * expressions that can be evaluated at this time
234bc36eafdSMike Gerdts      */
235*35786f68SRobert Mustacchi     if ((!(Op->Asl.CompileFlags & OP_COMPILE_TIME_CONST)) ||
236*35786f68SRobert Mustacchi           (Op->Asl.CompileFlags & OP_IS_TARGET))
237bc36eafdSMike Gerdts     {
238bc36eafdSMike Gerdts         return (AE_OK);
239bc36eafdSMike Gerdts     }
240bc36eafdSMike Gerdts 
241bc36eafdSMike Gerdts     /* Create a new walk state */
242bc36eafdSMike Gerdts 
243bc36eafdSMike Gerdts     WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);
244bc36eafdSMike Gerdts     if (!WalkState)
245bc36eafdSMike Gerdts     {
246bc36eafdSMike Gerdts         return (AE_NO_MEMORY);
247bc36eafdSMike Gerdts     }
248bc36eafdSMike Gerdts 
249bc36eafdSMike Gerdts     WalkState->NextOp = NULL;
250bc36eafdSMike Gerdts     WalkState->Params = NULL;
251bc36eafdSMike Gerdts 
252bc36eafdSMike Gerdts     /*
253bc36eafdSMike Gerdts      * Examine the entire subtree -- all nodes must be constants
254bc36eafdSMike Gerdts      * or type 3/4/5 opcodes
255bc36eafdSMike Gerdts      */
256bc36eafdSMike Gerdts     Status = TrWalkParseTree (Op, ASL_WALK_VISIT_DOWNWARD,
257bc36eafdSMike Gerdts         OpcAmlCheckForConstant, NULL, WalkState);
258bc36eafdSMike Gerdts 
259bc36eafdSMike Gerdts     /*
260bc36eafdSMike Gerdts      * Did we find an entire subtree that contains all constants
261bc36eafdSMike Gerdts      * and type 3/4/5 opcodes?
262bc36eafdSMike Gerdts      */
263bc36eafdSMike Gerdts     switch (Status)
264bc36eafdSMike Gerdts     {
265bc36eafdSMike Gerdts     case AE_OK:
266bc36eafdSMike Gerdts 
267bc36eafdSMike Gerdts         /* Simple case, like Add(3,4) -> 7 */
268bc36eafdSMike Gerdts 
269bc36eafdSMike Gerdts         Status = TrSimpleConstantReduction (Op, WalkState);
270bc36eafdSMike Gerdts         break;
271bc36eafdSMike Gerdts 
272bc36eafdSMike Gerdts     case AE_CTRL_RETURN_VALUE:
273bc36eafdSMike Gerdts 
274bc36eafdSMike Gerdts         /* More complex case, like Add(3,4,Local0) -> Store(7,Local0) */
275bc36eafdSMike Gerdts 
276bc36eafdSMike Gerdts         Status = TrTransformToStoreOp (Op, WalkState);
277bc36eafdSMike Gerdts         break;
278bc36eafdSMike Gerdts 
279bc36eafdSMike Gerdts     case AE_TYPE:
280bc36eafdSMike Gerdts 
281bc36eafdSMike Gerdts         AcpiDsDeleteWalkState (WalkState);
282bc36eafdSMike Gerdts         return (AE_OK);
283bc36eafdSMike Gerdts 
284bc36eafdSMike Gerdts     default:
285bc36eafdSMike Gerdts         AcpiDsDeleteWalkState (WalkState);
286bc36eafdSMike Gerdts         break;
287bc36eafdSMike Gerdts     }
288bc36eafdSMike Gerdts 
289bc36eafdSMike Gerdts     if (ACPI_FAILURE (Status))
290bc36eafdSMike Gerdts     {
291bc36eafdSMike Gerdts         DbgPrint (ASL_PARSE_OUTPUT, "Cannot resolve, %s\n",
292bc36eafdSMike Gerdts             AcpiFormatException (Status));
293bc36eafdSMike Gerdts 
294bc36eafdSMike Gerdts         /* We could not resolve the subtree for some reason */
295bc36eafdSMike Gerdts 
296bc36eafdSMike Gerdts         AslError (ASL_ERROR, ASL_MSG_CONSTANT_EVALUATION, Op,
297bc36eafdSMike Gerdts             (char *) AcpiFormatException (Status));
298bc36eafdSMike Gerdts 
299bc36eafdSMike Gerdts         /* Set the subtree value to ZERO anyway. Eliminates further errors */
300bc36eafdSMike Gerdts 
301bc36eafdSMike Gerdts         OpcUpdateIntegerNode (Op, 0);
302bc36eafdSMike Gerdts     }
303bc36eafdSMike Gerdts 
304bc36eafdSMike Gerdts     return (AE_OK);
305bc36eafdSMike Gerdts }
306bc36eafdSMike Gerdts 
307bc36eafdSMike Gerdts 
308bc36eafdSMike Gerdts /*******************************************************************************
309bc36eafdSMike Gerdts  *
310bc36eafdSMike Gerdts  * FUNCTION:    OpcAmlCheckForConstant
311bc36eafdSMike Gerdts  *
312bc36eafdSMike Gerdts  * PARAMETERS:  ASL_WALK_CALLBACK
313bc36eafdSMike Gerdts  *
314bc36eafdSMike Gerdts  * RETURN:      Status
315bc36eafdSMike Gerdts  *
316bc36eafdSMike Gerdts  * DESCRIPTION: Check one Op for a reducible type 3/4/5 AML opcode.
317bc36eafdSMike Gerdts  *              This is performed via an upward walk of the parse subtree.
318bc36eafdSMike Gerdts  *
319bc36eafdSMike Gerdts  ******************************************************************************/
320bc36eafdSMike Gerdts 
321bc36eafdSMike Gerdts static ACPI_STATUS
OpcAmlCheckForConstant(ACPI_PARSE_OBJECT * Op,UINT32 Level,void * Context)322bc36eafdSMike Gerdts OpcAmlCheckForConstant (
323bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *Op,
324bc36eafdSMike Gerdts     UINT32                  Level,
325bc36eafdSMike Gerdts     void                    *Context)
326bc36eafdSMike Gerdts {
327bc36eafdSMike Gerdts     ACPI_WALK_STATE         *WalkState = Context;
328bc36eafdSMike Gerdts     ACPI_STATUS             Status = AE_OK;
329bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *NextOp;
330bc36eafdSMike Gerdts     const ACPI_OPCODE_INFO  *OpInfo;
331bc36eafdSMike Gerdts 
332bc36eafdSMike Gerdts 
333bc36eafdSMike Gerdts     WalkState->Op = Op;
334bc36eafdSMike Gerdts     WalkState->Opcode = Op->Common.AmlOpcode;
335bc36eafdSMike Gerdts     WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
336bc36eafdSMike Gerdts 
337bc36eafdSMike Gerdts     DbgPrint (ASL_PARSE_OUTPUT, "[%.4d] Opcode: %12.12s ",
338bc36eafdSMike Gerdts         Op->Asl.LogicalLineNumber, Op->Asl.ParseOpName);
339bc36eafdSMike Gerdts 
340bc36eafdSMike Gerdts     /*
341bc36eafdSMike Gerdts      * These opcodes do not appear in the OpcodeInfo table, but
342bc36eafdSMike Gerdts      * they represent constants, so abort the constant walk now.
343bc36eafdSMike Gerdts      */
344bc36eafdSMike Gerdts     if ((WalkState->Opcode == AML_RAW_DATA_BYTE) ||
345bc36eafdSMike Gerdts         (WalkState->Opcode == AML_RAW_DATA_WORD) ||
346bc36eafdSMike Gerdts         (WalkState->Opcode == AML_RAW_DATA_DWORD) ||
347bc36eafdSMike Gerdts         (WalkState->Opcode == AML_RAW_DATA_QWORD))
348bc36eafdSMike Gerdts     {
349bc36eafdSMike Gerdts         DbgPrint (ASL_PARSE_OUTPUT, "RAW DATA");
350bc36eafdSMike Gerdts         Status = AE_TYPE;
351bc36eafdSMike Gerdts         goto CleanupAndExit;
352bc36eafdSMike Gerdts     }
353bc36eafdSMike Gerdts 
354bc36eafdSMike Gerdts     /*
355bc36eafdSMike Gerdts      * Search upwards for a possible Name() operator. This is done
356bc36eafdSMike Gerdts      * because a type 3/4/5 opcode within a Name() expression
357bc36eafdSMike Gerdts      * MUST be reduced to a simple constant.
358bc36eafdSMike Gerdts      */
359bc36eafdSMike Gerdts     NextOp = Op->Asl.Parent;
360bc36eafdSMike Gerdts     while (NextOp)
361bc36eafdSMike Gerdts     {
362bc36eafdSMike Gerdts         /* Finished if we find a Name() opcode */
363bc36eafdSMike Gerdts 
364bc36eafdSMike Gerdts         if (NextOp->Asl.AmlOpcode == AML_NAME_OP)
365bc36eafdSMike Gerdts         {
366bc36eafdSMike Gerdts             break;
367bc36eafdSMike Gerdts         }
368bc36eafdSMike Gerdts 
369bc36eafdSMike Gerdts         /*
370bc36eafdSMike Gerdts          * Any "deferred" opcodes contain one or more TermArg parameters,
371bc36eafdSMike Gerdts          * and thus are not required to be folded to constants at compile
372bc36eafdSMike Gerdts          * time. This affects things like Buffer() and Package() objects.
373bc36eafdSMike Gerdts          * We just ignore them here. However, any sub-expressions can and
374bc36eafdSMike Gerdts          * will still be typechecked. Note: These are called the
375bc36eafdSMike Gerdts          * "deferred" opcodes in the AML interpreter.
376bc36eafdSMike Gerdts          */
377bc36eafdSMike Gerdts         OpInfo = AcpiPsGetOpcodeInfo (NextOp->Common.AmlOpcode);
378bc36eafdSMike Gerdts         if (OpInfo->Flags & AML_DEFER)
379bc36eafdSMike Gerdts         {
380bc36eafdSMike Gerdts             NextOp = NULL;
381bc36eafdSMike Gerdts             break;
382bc36eafdSMike Gerdts         }
383bc36eafdSMike Gerdts 
384bc36eafdSMike Gerdts         NextOp = NextOp->Asl.Parent;
385bc36eafdSMike Gerdts     }
386bc36eafdSMike Gerdts 
387bc36eafdSMike Gerdts     /* Type 3/4/5 opcodes have the AML_CONSTANT flag set */
388bc36eafdSMike Gerdts 
389bc36eafdSMike Gerdts     if (!(WalkState->OpInfo->Flags & AML_CONSTANT))
390bc36eafdSMike Gerdts     {
391bc36eafdSMike Gerdts         /*
392bc36eafdSMike Gerdts          * From the ACPI specification:
393bc36eafdSMike Gerdts          *
394bc36eafdSMike Gerdts          * "The Type 3/4/5 opcodes return a value and can be used in an
395bc36eafdSMike Gerdts          * expression that evaluates to a constant. These opcodes may be
396bc36eafdSMike Gerdts          * evaluated at ASL compile-time. To ensure that these opcodes
397bc36eafdSMike Gerdts          * will evaluate to a constant, the following rules apply: The
398bc36eafdSMike Gerdts          * term cannot have a destination (target) operand, and must have
399bc36eafdSMike Gerdts          * either a Type3Opcode, Type4Opcode, Type5Opcode, ConstExprTerm,
400bc36eafdSMike Gerdts          * Integer, BufferTerm, Package, or String for all arguments."
401bc36eafdSMike Gerdts          */
402bc36eafdSMike Gerdts 
403bc36eafdSMike Gerdts         /*
404bc36eafdSMike Gerdts          * The value (second) operand for the Name() operator MUST
405bc36eafdSMike Gerdts          * reduce to a single constant, as per the ACPI specification
406bc36eafdSMike Gerdts          * (the operand is a DataObject). This also implies that there
407bc36eafdSMike Gerdts          * can be no target operand. Name() is the only ASL operator
408bc36eafdSMike Gerdts          * with a "DataObject" as an operand and is thus special-
409bc36eafdSMike Gerdts          * cased here.
410bc36eafdSMike Gerdts          */
411bc36eafdSMike Gerdts         if (NextOp) /* Inspect a Name() operator */
412bc36eafdSMike Gerdts         {
413bc36eafdSMike Gerdts             /* Error if there is a target operand */
414bc36eafdSMike Gerdts 
415*35786f68SRobert Mustacchi             if (Op->Asl.CompileFlags & OP_IS_TARGET)
416bc36eafdSMike Gerdts             {
417bc36eafdSMike Gerdts                 AslError (ASL_ERROR, ASL_MSG_INVALID_TARGET, Op, NULL);
418bc36eafdSMike Gerdts                 Status = AE_TYPE;
419bc36eafdSMike Gerdts             }
420bc36eafdSMike Gerdts 
421bc36eafdSMike Gerdts             /* Error if expression cannot be reduced (folded) */
422bc36eafdSMike Gerdts 
423*35786f68SRobert Mustacchi             if (!(NextOp->Asl.CompileFlags & OP_COULD_NOT_REDUCE))
424bc36eafdSMike Gerdts             {
425bc36eafdSMike Gerdts                 /* Ensure only one error message per statement */
426bc36eafdSMike Gerdts 
427*35786f68SRobert Mustacchi                 NextOp->Asl.CompileFlags |= OP_COULD_NOT_REDUCE;
428bc36eafdSMike Gerdts                 DbgPrint (ASL_PARSE_OUTPUT,
429bc36eafdSMike Gerdts                     "**** Could not reduce operands for NAME opcode ****\n");
430bc36eafdSMike Gerdts 
431bc36eafdSMike Gerdts                 AslError (ASL_ERROR, ASL_MSG_CONSTANT_REQUIRED, Op,
432bc36eafdSMike Gerdts                     "Constant is required for Name operator");
433bc36eafdSMike Gerdts                 Status = AE_TYPE;
434bc36eafdSMike Gerdts             }
435bc36eafdSMike Gerdts         }
436bc36eafdSMike Gerdts 
437bc36eafdSMike Gerdts         if (ACPI_FAILURE (Status))
438bc36eafdSMike Gerdts         {
439bc36eafdSMike Gerdts             goto CleanupAndExit;
440bc36eafdSMike Gerdts         }
441bc36eafdSMike Gerdts 
442bc36eafdSMike Gerdts         /* This is not a 3/4/5 opcode, but maybe can convert to STORE */
443bc36eafdSMike Gerdts 
444*35786f68SRobert Mustacchi         if (Op->Asl.CompileFlags & OP_IS_TARGET)
445bc36eafdSMike Gerdts         {
446bc36eafdSMike Gerdts             DbgPrint (ASL_PARSE_OUTPUT,
447*35786f68SRobert Mustacchi                 "**** Valid Target, transform to Store or CopyObject ****\n");
448bc36eafdSMike Gerdts             return (AE_CTRL_RETURN_VALUE);
449bc36eafdSMike Gerdts         }
450bc36eafdSMike Gerdts 
451bc36eafdSMike Gerdts         /* Expression cannot be reduced */
452bc36eafdSMike Gerdts 
453bc36eafdSMike Gerdts         DbgPrint (ASL_PARSE_OUTPUT,
454bc36eafdSMike Gerdts             "**** Not a Type 3/4/5 opcode or cannot reduce/fold (%s) ****\n",
455bc36eafdSMike Gerdts              Op->Asl.ParseOpName);
456bc36eafdSMike Gerdts 
457bc36eafdSMike Gerdts         Status = AE_TYPE;
458bc36eafdSMike Gerdts         goto CleanupAndExit;
459bc36eafdSMike Gerdts     }
460bc36eafdSMike Gerdts 
461bc36eafdSMike Gerdts     /*
462bc36eafdSMike Gerdts      * TBD: Ignore buffer constants for now. The problem is that these
463bc36eafdSMike Gerdts      * constants have been transformed into RAW_DATA at this point, from
464bc36eafdSMike Gerdts      * the parse tree transform process which currently happens before
465bc36eafdSMike Gerdts      * the constant folding process. We may need to defer this transform
466bc36eafdSMike Gerdts      * for buffer until after the constant folding.
467bc36eafdSMike Gerdts      */
468bc36eafdSMike Gerdts     if (WalkState->Opcode == AML_BUFFER_OP)
469bc36eafdSMike Gerdts     {
470bc36eafdSMike Gerdts         DbgPrint (ASL_PARSE_OUTPUT,
471*35786f68SRobert Mustacchi             "\nBuffer constant reduction is currently not supported\n");
472bc36eafdSMike Gerdts 
473bc36eafdSMike Gerdts         if (NextOp) /* Found a Name() operator, error */
474bc36eafdSMike Gerdts         {
475bc36eafdSMike Gerdts             AslError (ASL_ERROR, ASL_MSG_UNSUPPORTED, Op,
476bc36eafdSMike Gerdts                 "Buffer expression cannot be reduced");
477bc36eafdSMike Gerdts         }
478bc36eafdSMike Gerdts 
479bc36eafdSMike Gerdts         Status = AE_TYPE;
480bc36eafdSMike Gerdts         goto CleanupAndExit;
481bc36eafdSMike Gerdts     }
482bc36eafdSMike Gerdts 
483bc36eafdSMike Gerdts     /* Debug output */
484bc36eafdSMike Gerdts 
485bc36eafdSMike Gerdts     DbgPrint (ASL_PARSE_OUTPUT, "TYPE_345");
486bc36eafdSMike Gerdts 
487*35786f68SRobert Mustacchi     if (Op->Asl.CompileFlags & OP_IS_TARGET)
488bc36eafdSMike Gerdts     {
489bc36eafdSMike Gerdts         if (Op->Asl.ParseOpcode == PARSEOP_ZERO)
490bc36eafdSMike Gerdts         {
491bc36eafdSMike Gerdts             DbgPrint (ASL_PARSE_OUTPUT, "%-16s", " NULL TARGET");
492bc36eafdSMike Gerdts         }
493bc36eafdSMike Gerdts         else
494bc36eafdSMike Gerdts         {
495bc36eafdSMike Gerdts             DbgPrint (ASL_PARSE_OUTPUT, "%-16s", " VALID TARGET");
496bc36eafdSMike Gerdts         }
497bc36eafdSMike Gerdts     }
498bc36eafdSMike Gerdts 
499*35786f68SRobert Mustacchi     if (Op->Asl.CompileFlags & OP_IS_TERM_ARG)
500bc36eafdSMike Gerdts     {
501bc36eafdSMike Gerdts         DbgPrint (ASL_PARSE_OUTPUT, "%-16s", " TERMARG");
502bc36eafdSMike Gerdts     }
503bc36eafdSMike Gerdts 
504bc36eafdSMike Gerdts CleanupAndExit:
505bc36eafdSMike Gerdts 
506bc36eafdSMike Gerdts     /* Dump the node compile flags also */
507bc36eafdSMike Gerdts 
508*35786f68SRobert Mustacchi     TrPrintOpFlags (Op->Asl.CompileFlags, ASL_PARSE_OUTPUT);
509bc36eafdSMike Gerdts     DbgPrint (ASL_PARSE_OUTPUT, "\n");
510bc36eafdSMike Gerdts     return (Status);
511bc36eafdSMike Gerdts }
512bc36eafdSMike Gerdts 
513bc36eafdSMike Gerdts 
514bc36eafdSMike Gerdts /*******************************************************************************
515bc36eafdSMike Gerdts  *
516bc36eafdSMike Gerdts  * FUNCTION:    TrSimpleConstantReduction
517bc36eafdSMike Gerdts  *
518bc36eafdSMike Gerdts  * PARAMETERS:  Op                  - Parent operator to be transformed
519bc36eafdSMike Gerdts  *              WalkState           - Current walk state
520bc36eafdSMike Gerdts  *
521bc36eafdSMike Gerdts  * RETURN:      Status
522bc36eafdSMike Gerdts  *
523bc36eafdSMike Gerdts  * DESCRIPTION: Reduce an entire AML operation to a single constant. The
524bc36eafdSMike Gerdts  *              operation must not have a target operand.
525bc36eafdSMike Gerdts  *
526bc36eafdSMike Gerdts  *              Add (32,64) --> 96
527bc36eafdSMike Gerdts  *
528bc36eafdSMike Gerdts  ******************************************************************************/
529bc36eafdSMike Gerdts 
530bc36eafdSMike Gerdts static ACPI_STATUS
TrSimpleConstantReduction(ACPI_PARSE_OBJECT * Op,ACPI_WALK_STATE * WalkState)531bc36eafdSMike Gerdts TrSimpleConstantReduction (
532bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *Op,
533bc36eafdSMike Gerdts     ACPI_WALK_STATE         *WalkState)
534bc36eafdSMike Gerdts {
535bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *RootOp;
536bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *OriginalParentOp;
537bc36eafdSMike Gerdts     ACPI_OPERAND_OBJECT     *ObjDesc;
538bc36eafdSMike Gerdts     ACPI_STATUS             Status;
539bc36eafdSMike Gerdts 
540bc36eafdSMike Gerdts 
541bc36eafdSMike Gerdts     DbgPrint (ASL_PARSE_OUTPUT,
542bc36eafdSMike Gerdts         "Simple subtree constant reduction, operator to constant\n");
543bc36eafdSMike Gerdts 
544bc36eafdSMike Gerdts     /* Allocate a new temporary root for this subtree */
545bc36eafdSMike Gerdts 
546*35786f68SRobert Mustacchi     RootOp = TrAllocateOp (PARSEOP_INTEGER);
547bc36eafdSMike Gerdts     if (!RootOp)
548bc36eafdSMike Gerdts     {
549bc36eafdSMike Gerdts         return (AE_NO_MEMORY);
550bc36eafdSMike Gerdts     }
551bc36eafdSMike Gerdts 
552bc36eafdSMike Gerdts     RootOp->Common.AmlOpcode = AML_INT_EVAL_SUBTREE_OP;
553bc36eafdSMike Gerdts 
554bc36eafdSMike Gerdts     OriginalParentOp = Op->Common.Parent;
555bc36eafdSMike Gerdts     Op->Common.Parent = RootOp;
556bc36eafdSMike Gerdts 
557bc36eafdSMike Gerdts     /* Hand off the subtree to the AML interpreter */
558bc36eafdSMike Gerdts 
559bc36eafdSMike Gerdts     WalkState->CallerReturnDesc = &ObjDesc;
560bc36eafdSMike Gerdts 
561bc36eafdSMike Gerdts     Status = TrWalkParseTree (Op, ASL_WALK_VISIT_TWICE,
562bc36eafdSMike Gerdts         OpcAmlEvaluationWalk1, OpcAmlEvaluationWalk2, WalkState);
563bc36eafdSMike Gerdts 
564bc36eafdSMike Gerdts     /* Restore original parse tree */
565bc36eafdSMike Gerdts 
566bc36eafdSMike Gerdts     Op->Common.Parent = OriginalParentOp;
567bc36eafdSMike Gerdts 
568bc36eafdSMike Gerdts     if (ACPI_FAILURE (Status))
569bc36eafdSMike Gerdts     {
570bc36eafdSMike Gerdts         DbgPrint (ASL_PARSE_OUTPUT,
571bc36eafdSMike Gerdts             "Constant Subtree evaluation(1), %s\n",
572bc36eafdSMike Gerdts             AcpiFormatException (Status));
573bc36eafdSMike Gerdts         return (Status);
574bc36eafdSMike Gerdts     }
575bc36eafdSMike Gerdts 
576bc36eafdSMike Gerdts     /* Get the final result */
577bc36eafdSMike Gerdts 
578bc36eafdSMike Gerdts     Status = AcpiDsResultPop (&ObjDesc, WalkState);
579bc36eafdSMike Gerdts     if (ACPI_FAILURE (Status))
580bc36eafdSMike Gerdts     {
581bc36eafdSMike Gerdts         DbgPrint (ASL_PARSE_OUTPUT,
582bc36eafdSMike Gerdts             "Constant Subtree evaluation(2), %s\n",
583bc36eafdSMike Gerdts             AcpiFormatException (Status));
584bc36eafdSMike Gerdts         return (Status);
585bc36eafdSMike Gerdts     }
586bc36eafdSMike Gerdts 
587bc36eafdSMike Gerdts     /* Disconnect any existing children, install new constant */
588bc36eafdSMike Gerdts 
589bc36eafdSMike Gerdts     Op->Asl.Child = NULL;
590bc36eafdSMike Gerdts     TrInstallReducedConstant (Op, ObjDesc);
591bc36eafdSMike Gerdts 
592bc36eafdSMike Gerdts     UtSetParseOpName (Op);
593bc36eafdSMike Gerdts     return (AE_OK);
594bc36eafdSMike Gerdts }
595bc36eafdSMike Gerdts 
596bc36eafdSMike Gerdts 
597bc36eafdSMike Gerdts /*******************************************************************************
598bc36eafdSMike Gerdts  *
599bc36eafdSMike Gerdts  * FUNCTION:    TrTransformToStoreOp
600bc36eafdSMike Gerdts  *
601bc36eafdSMike Gerdts  * PARAMETERS:  Op                  - Parent operator to be transformed
602bc36eafdSMike Gerdts  *              WalkState           - Current walk state
603bc36eafdSMike Gerdts  *
604bc36eafdSMike Gerdts  * RETURN:      Status
605bc36eafdSMike Gerdts  *
606bc36eafdSMike Gerdts  * DESCRIPTION: Transforms a single AML operation with a constant and target
607bc36eafdSMike Gerdts  *              to a simple store operation:
608bc36eafdSMike Gerdts  *
609bc36eafdSMike Gerdts  *              Add (32,64,DATA) --> Store (96,DATA)
610bc36eafdSMike Gerdts  *
611bc36eafdSMike Gerdts  ******************************************************************************/
612bc36eafdSMike Gerdts 
613bc36eafdSMike Gerdts static ACPI_STATUS
TrTransformToStoreOp(ACPI_PARSE_OBJECT * Op,ACPI_WALK_STATE * WalkState)614bc36eafdSMike Gerdts TrTransformToStoreOp (
615bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *Op,
616bc36eafdSMike Gerdts     ACPI_WALK_STATE         *WalkState)
617bc36eafdSMike Gerdts {
618bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *OriginalTarget;
619bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *NewTarget;
620bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *Child1;
621bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *Child2;
622bc36eafdSMike Gerdts     ACPI_OPERAND_OBJECT     *ObjDesc;
623bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *NewParent;
624bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *OriginalParent;
625bc36eafdSMike Gerdts     ACPI_STATUS             Status;
626*35786f68SRobert Mustacchi     UINT16                  NewParseOpcode;
627*35786f68SRobert Mustacchi     UINT16                  NewAmlOpcode;
628bc36eafdSMike Gerdts 
629bc36eafdSMike Gerdts 
630bc36eafdSMike Gerdts     /* Extract the operands */
631bc36eafdSMike Gerdts 
632bc36eafdSMike Gerdts     Child1 = Op->Asl.Child;
633bc36eafdSMike Gerdts     Child2 = Child1->Asl.Next;
634bc36eafdSMike Gerdts 
635bc36eafdSMike Gerdts     /*
636bc36eafdSMike Gerdts      * Special case for DIVIDE -- it has two targets. The first
637bc36eafdSMike Gerdts      * is for the remainder and if present, we will not attempt
638bc36eafdSMike Gerdts      * to reduce the expression.
639bc36eafdSMike Gerdts      */
640bc36eafdSMike Gerdts     if (Op->Asl.ParseOpcode == PARSEOP_DIVIDE)
641bc36eafdSMike Gerdts     {
642bc36eafdSMike Gerdts         Child2 = Child2->Asl.Next;
643bc36eafdSMike Gerdts         if (Child2->Asl.ParseOpcode != PARSEOP_ZERO)
644bc36eafdSMike Gerdts         {
645bc36eafdSMike Gerdts             DbgPrint (ASL_PARSE_OUTPUT,
646bc36eafdSMike Gerdts                 "Cannot reduce DIVIDE - has two targets\n\n");
647bc36eafdSMike Gerdts             return (AE_OK);
648bc36eafdSMike Gerdts         }
649bc36eafdSMike Gerdts     }
650bc36eafdSMike Gerdts 
651*35786f68SRobert Mustacchi     switch (Op->Asl.ParseOpcode)
652*35786f68SRobert Mustacchi     {
653*35786f68SRobert Mustacchi     /*
654*35786f68SRobert Mustacchi      * Folding of the explicit conversion opcodes must use CopyObject
655*35786f68SRobert Mustacchi      * instead of Store. This can change the object type of the target
656*35786f68SRobert Mustacchi      * operand, as per the ACPI specification:
657*35786f68SRobert Mustacchi      *
658*35786f68SRobert Mustacchi      * "If the ASL operator is one of the explicit conversion operators
659*35786f68SRobert Mustacchi      * (ToString, ToInteger, etc., and the CopyObject operator), no
660*35786f68SRobert Mustacchi      * [implicit] conversion is performed. (In other words, the result
661*35786f68SRobert Mustacchi      * object is stored directly to the target and completely overwrites
662*35786f68SRobert Mustacchi      * any existing object already stored at the target)"
663*35786f68SRobert Mustacchi      */
664*35786f68SRobert Mustacchi     case PARSEOP_TOINTEGER:
665*35786f68SRobert Mustacchi     case PARSEOP_TOSTRING:
666*35786f68SRobert Mustacchi     case PARSEOP_TOBUFFER:
667*35786f68SRobert Mustacchi     case PARSEOP_TODECIMALSTRING:
668*35786f68SRobert Mustacchi     case PARSEOP_TOHEXSTRING:
669*35786f68SRobert Mustacchi     case PARSEOP_TOBCD:
670*35786f68SRobert Mustacchi     case PARSEOP_FROMBCD:
671*35786f68SRobert Mustacchi 
672*35786f68SRobert Mustacchi         NewParseOpcode = PARSEOP_COPYOBJECT;
673*35786f68SRobert Mustacchi         NewAmlOpcode = AML_COPY_OBJECT_OP;
674*35786f68SRobert Mustacchi 
675*35786f68SRobert Mustacchi         DbgPrint (ASL_PARSE_OUTPUT,
676*35786f68SRobert Mustacchi             "Reduction/Transform to CopyObjectOp: CopyObject(%s, %s)\n",
677*35786f68SRobert Mustacchi             Child1->Asl.ParseOpName, Child2->Asl.ParseOpName);
678*35786f68SRobert Mustacchi         break;
679*35786f68SRobert Mustacchi 
680*35786f68SRobert Mustacchi     default:
681*35786f68SRobert Mustacchi 
682*35786f68SRobert Mustacchi         NewParseOpcode = PARSEOP_STORE;
683*35786f68SRobert Mustacchi         NewAmlOpcode = AML_STORE_OP;
684*35786f68SRobert Mustacchi 
685bc36eafdSMike Gerdts         DbgPrint (ASL_PARSE_OUTPUT,
686bc36eafdSMike Gerdts             "Reduction/Transform to StoreOp: Store(%s, %s)\n",
687bc36eafdSMike Gerdts             Child1->Asl.ParseOpName, Child2->Asl.ParseOpName);
688*35786f68SRobert Mustacchi         break;
689*35786f68SRobert Mustacchi     }
690bc36eafdSMike Gerdts 
691bc36eafdSMike Gerdts     /*
692bc36eafdSMike Gerdts      * Create a NULL (zero) target so that we can use the
693bc36eafdSMike Gerdts      * interpreter to evaluate the expression.
694bc36eafdSMike Gerdts      */
695*35786f68SRobert Mustacchi     NewTarget = TrCreateNullTargetOp ();
696bc36eafdSMike Gerdts     NewTarget->Common.AmlOpcode = AML_INT_NAMEPATH_OP;
697bc36eafdSMike Gerdts 
698bc36eafdSMike Gerdts     /* Handle one-operand cases (NOT, TOBCD, etc.) */
699bc36eafdSMike Gerdts 
700bc36eafdSMike Gerdts     if (!Child2->Asl.Next)
701bc36eafdSMike Gerdts     {
702bc36eafdSMike Gerdts         Child2 = Child1;
703bc36eafdSMike Gerdts     }
704bc36eafdSMike Gerdts 
705bc36eafdSMike Gerdts     /* Link in new NULL target as the last operand */
706bc36eafdSMike Gerdts 
707bc36eafdSMike Gerdts     OriginalTarget = Child2->Asl.Next;
708bc36eafdSMike Gerdts     Child2->Asl.Next = NewTarget;
709bc36eafdSMike Gerdts     NewTarget->Asl.Parent = OriginalTarget->Asl.Parent;
710bc36eafdSMike Gerdts 
711*35786f68SRobert Mustacchi     NewParent = TrAllocateOp (PARSEOP_INTEGER);
712bc36eafdSMike Gerdts     NewParent->Common.AmlOpcode = AML_INT_EVAL_SUBTREE_OP;
713bc36eafdSMike Gerdts 
714bc36eafdSMike Gerdts     OriginalParent = Op->Common.Parent;
715bc36eafdSMike Gerdts     Op->Common.Parent = NewParent;
716bc36eafdSMike Gerdts 
717bc36eafdSMike Gerdts     /* Hand off the subtree to the AML interpreter */
718bc36eafdSMike Gerdts 
719bc36eafdSMike Gerdts     WalkState->CallerReturnDesc = &ObjDesc;
720bc36eafdSMike Gerdts 
721bc36eafdSMike Gerdts     Status = TrWalkParseTree (Op, ASL_WALK_VISIT_TWICE,
722bc36eafdSMike Gerdts         OpcAmlEvaluationWalk1, OpcAmlEvaluationWalk2, WalkState);
723bc36eafdSMike Gerdts     if (ACPI_FAILURE (Status))
724bc36eafdSMike Gerdts     {
725bc36eafdSMike Gerdts         DbgPrint (ASL_PARSE_OUTPUT,
726bc36eafdSMike Gerdts             "Constant Subtree evaluation(3), %s\n",
727bc36eafdSMike Gerdts             AcpiFormatException (Status));
728bc36eafdSMike Gerdts         goto EvalError;
729bc36eafdSMike Gerdts     }
730bc36eafdSMike Gerdts 
731bc36eafdSMike Gerdts     /* Get the final result */
732bc36eafdSMike Gerdts 
733bc36eafdSMike Gerdts     Status = AcpiDsResultPop (&ObjDesc, WalkState);
734bc36eafdSMike Gerdts     if (ACPI_FAILURE (Status))
735bc36eafdSMike Gerdts     {
736bc36eafdSMike Gerdts         DbgPrint (ASL_PARSE_OUTPUT,
737bc36eafdSMike Gerdts             "Constant Subtree evaluation(4), %s\n",
738bc36eafdSMike Gerdts             AcpiFormatException (Status));
739bc36eafdSMike Gerdts         goto EvalError;
740bc36eafdSMike Gerdts     }
741bc36eafdSMike Gerdts 
742bc36eafdSMike Gerdts     /* Truncate any subtree expressions, they have been evaluated */
743bc36eafdSMike Gerdts 
744bc36eafdSMike Gerdts     Child1->Asl.Child = NULL;
745bc36eafdSMike Gerdts 
746bc36eafdSMike Gerdts     /* Folded constant is in ObjDesc, store into Child1 */
747bc36eafdSMike Gerdts 
748bc36eafdSMike Gerdts     TrInstallReducedConstant (Child1, ObjDesc);
749bc36eafdSMike Gerdts 
750*35786f68SRobert Mustacchi     /* Convert operator to STORE or COPYOBJECT */
751bc36eafdSMike Gerdts 
752*35786f68SRobert Mustacchi     Op->Asl.ParseOpcode = NewParseOpcode;
753*35786f68SRobert Mustacchi     Op->Asl.AmlOpcode = NewAmlOpcode;
754bc36eafdSMike Gerdts     UtSetParseOpName (Op);
755bc36eafdSMike Gerdts     Op->Common.Parent = OriginalParent;
756bc36eafdSMike Gerdts 
757bc36eafdSMike Gerdts     /* First child is the folded constant */
758bc36eafdSMike Gerdts 
759bc36eafdSMike Gerdts     /* Second child will be the target */
760bc36eafdSMike Gerdts 
761bc36eafdSMike Gerdts     Child1->Asl.Next = OriginalTarget;
762bc36eafdSMike Gerdts     return (AE_OK);
763bc36eafdSMike Gerdts 
764bc36eafdSMike Gerdts 
765bc36eafdSMike Gerdts EvalError:
766bc36eafdSMike Gerdts 
767bc36eafdSMike Gerdts     /* Restore original links */
768bc36eafdSMike Gerdts 
769bc36eafdSMike Gerdts     Op->Common.Parent = OriginalParent;
770bc36eafdSMike Gerdts     Child2->Asl.Next = OriginalTarget;
771bc36eafdSMike Gerdts     return (Status);
772bc36eafdSMike Gerdts }
773bc36eafdSMike Gerdts 
774bc36eafdSMike Gerdts 
775bc36eafdSMike Gerdts /*******************************************************************************
776bc36eafdSMike Gerdts  *
777bc36eafdSMike Gerdts  * FUNCTION:    TrInstallReducedConstant
778bc36eafdSMike Gerdts  *
779bc36eafdSMike Gerdts  * PARAMETERS:  Op                  - Parent operator to be transformed
780bc36eafdSMike Gerdts  *              ObjDesc             - Reduced constant to be installed
781bc36eafdSMike Gerdts  *
782bc36eafdSMike Gerdts  * RETURN:      None
783bc36eafdSMike Gerdts  *
784bc36eafdSMike Gerdts  * DESCRIPTION: Transform the original operator to a simple constant.
785bc36eafdSMike Gerdts  *              Handles Integers, Strings, and Buffers.
786bc36eafdSMike Gerdts  *
787bc36eafdSMike Gerdts  ******************************************************************************/
788bc36eafdSMike Gerdts 
789bc36eafdSMike Gerdts static void
TrInstallReducedConstant(ACPI_PARSE_OBJECT * Op,ACPI_OPERAND_OBJECT * ObjDesc)790bc36eafdSMike Gerdts TrInstallReducedConstant (
791bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *Op,
792bc36eafdSMike Gerdts     ACPI_OPERAND_OBJECT     *ObjDesc)
793bc36eafdSMike Gerdts {
794bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *LengthOp;
795bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *DataOp;
796bc36eafdSMike Gerdts 
797bc36eafdSMike Gerdts 
798bc36eafdSMike Gerdts     TotalFolds++;
799bc36eafdSMike Gerdts     AslError (ASL_OPTIMIZATION, ASL_MSG_CONSTANT_FOLDED, Op,
800bc36eafdSMike Gerdts         Op->Asl.ParseOpName);
801bc36eafdSMike Gerdts 
802bc36eafdSMike Gerdts     /*
803bc36eafdSMike Gerdts      * Because we know we executed type 3/4/5 opcodes above, we know that
804bc36eafdSMike Gerdts      * the result must be either an Integer, String, or Buffer.
805bc36eafdSMike Gerdts      */
806bc36eafdSMike Gerdts     switch (ObjDesc->Common.Type)
807bc36eafdSMike Gerdts     {
808bc36eafdSMike Gerdts     case ACPI_TYPE_INTEGER:
809bc36eafdSMike Gerdts 
810bc36eafdSMike Gerdts         OpcUpdateIntegerNode (Op, ObjDesc->Integer.Value);
811bc36eafdSMike Gerdts 
812bc36eafdSMike Gerdts         DbgPrint (ASL_PARSE_OUTPUT,
813bc36eafdSMike Gerdts             "Constant expression reduced to (%s) %8.8X%8.8X\n\n",
814bc36eafdSMike Gerdts             Op->Asl.ParseOpName,
815bc36eafdSMike Gerdts             ACPI_FORMAT_UINT64 (Op->Common.Value.Integer));
816bc36eafdSMike Gerdts         break;
817bc36eafdSMike Gerdts 
818bc36eafdSMike Gerdts     case ACPI_TYPE_STRING:
819bc36eafdSMike Gerdts 
820bc36eafdSMike Gerdts         Op->Asl.ParseOpcode = PARSEOP_STRING_LITERAL;
821bc36eafdSMike Gerdts         Op->Common.AmlOpcode = AML_STRING_OP;
822bc36eafdSMike Gerdts         Op->Asl.AmlLength = strlen (ObjDesc->String.Pointer) + 1;
823bc36eafdSMike Gerdts         Op->Common.Value.String = ObjDesc->String.Pointer;
824bc36eafdSMike Gerdts 
825bc36eafdSMike Gerdts         DbgPrint (ASL_PARSE_OUTPUT,
826bc36eafdSMike Gerdts             "Constant expression reduced to (STRING) %s\n\n",
827bc36eafdSMike Gerdts             Op->Common.Value.String);
828bc36eafdSMike Gerdts         break;
829bc36eafdSMike Gerdts 
830bc36eafdSMike Gerdts     case ACPI_TYPE_BUFFER:
831bc36eafdSMike Gerdts         /*
832bc36eafdSMike Gerdts          * Create a new parse subtree of the form:
833bc36eafdSMike Gerdts          *
834bc36eafdSMike Gerdts          * BUFFER (Buffer AML opcode)
835bc36eafdSMike Gerdts          *    INTEGER (Buffer length in bytes)
836bc36eafdSMike Gerdts          *    RAW_DATA (Buffer byte data)
837bc36eafdSMike Gerdts          */
838bc36eafdSMike Gerdts         Op->Asl.ParseOpcode = PARSEOP_BUFFER;
839bc36eafdSMike Gerdts         Op->Common.AmlOpcode = AML_BUFFER_OP;
840*35786f68SRobert Mustacchi         Op->Asl.CompileFlags = OP_AML_PACKAGE;
841bc36eafdSMike Gerdts         UtSetParseOpName (Op);
842bc36eafdSMike Gerdts 
843bc36eafdSMike Gerdts         /* Child node is the buffer length */
844bc36eafdSMike Gerdts 
845*35786f68SRobert Mustacchi         LengthOp = TrAllocateOp (PARSEOP_INTEGER);
846bc36eafdSMike Gerdts 
847bc36eafdSMike Gerdts         LengthOp->Asl.AmlOpcode = AML_DWORD_OP;
848bc36eafdSMike Gerdts         LengthOp->Asl.Value.Integer = ObjDesc->Buffer.Length;
849bc36eafdSMike Gerdts         LengthOp->Asl.Parent = Op;
850bc36eafdSMike Gerdts         (void) OpcSetOptimalIntegerSize (LengthOp);
851bc36eafdSMike Gerdts 
852bc36eafdSMike Gerdts         Op->Asl.Child = LengthOp;
853bc36eafdSMike Gerdts 
854bc36eafdSMike Gerdts         /* Next child is the raw buffer data */
855bc36eafdSMike Gerdts 
856*35786f68SRobert Mustacchi         DataOp = TrAllocateOp (PARSEOP_RAW_DATA);
857bc36eafdSMike Gerdts         DataOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER;
858bc36eafdSMike Gerdts         DataOp->Asl.AmlLength = ObjDesc->Buffer.Length;
859bc36eafdSMike Gerdts         DataOp->Asl.Value.String = (char *) ObjDesc->Buffer.Pointer;
860bc36eafdSMike Gerdts         DataOp->Asl.Parent = Op;
861bc36eafdSMike Gerdts 
862bc36eafdSMike Gerdts         LengthOp->Asl.Next = DataOp;
863bc36eafdSMike Gerdts 
864bc36eafdSMike Gerdts         DbgPrint (ASL_PARSE_OUTPUT,
865bc36eafdSMike Gerdts             "Constant expression reduced to (BUFFER) length %X\n\n",
866bc36eafdSMike Gerdts             ObjDesc->Buffer.Length);
867bc36eafdSMike Gerdts         break;
868bc36eafdSMike Gerdts 
869bc36eafdSMike Gerdts     default:
870bc36eafdSMike Gerdts         break;
871bc36eafdSMike Gerdts     }
872bc36eafdSMike Gerdts }
873bc36eafdSMike Gerdts 
874bc36eafdSMike Gerdts 
875bc36eafdSMike Gerdts /*******************************************************************************
876bc36eafdSMike Gerdts  *
877bc36eafdSMike Gerdts  * FUNCTION:    OpcUpdateIntegerNode
878bc36eafdSMike Gerdts  *
879bc36eafdSMike Gerdts  * PARAMETERS:  Op                  - Current parse object
880bc36eafdSMike Gerdts  *              Value               - Value for the integer op
881bc36eafdSMike Gerdts  *
882bc36eafdSMike Gerdts  * RETURN:      None
883bc36eafdSMike Gerdts  *
884bc36eafdSMike Gerdts  * DESCRIPTION: Update node to the correct Integer type and value
885bc36eafdSMike Gerdts  *
886bc36eafdSMike Gerdts  ******************************************************************************/
887bc36eafdSMike Gerdts 
888bc36eafdSMike Gerdts static void
OpcUpdateIntegerNode(ACPI_PARSE_OBJECT * Op,UINT64 Value)889bc36eafdSMike Gerdts OpcUpdateIntegerNode (
890bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *Op,
891bc36eafdSMike Gerdts     UINT64                  Value)
892bc36eafdSMike Gerdts {
893bc36eafdSMike Gerdts 
894bc36eafdSMike Gerdts     Op->Common.Value.Integer = Value;
895bc36eafdSMike Gerdts 
896bc36eafdSMike Gerdts     /*
897bc36eafdSMike Gerdts      * The AmlLength is used by the parser to indicate a constant,
898bc36eafdSMike Gerdts      * (if non-zero). Length is either (1/2/4/8)
899bc36eafdSMike Gerdts      */
900bc36eafdSMike Gerdts     switch (Op->Asl.AmlLength)
901bc36eafdSMike Gerdts     {
902bc36eafdSMike Gerdts     case 1:
903bc36eafdSMike Gerdts 
904*35786f68SRobert Mustacchi         TrSetOpIntegerValue (PARSEOP_BYTECONST, Op);
905bc36eafdSMike Gerdts         Op->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
906bc36eafdSMike Gerdts         break;
907bc36eafdSMike Gerdts 
908bc36eafdSMike Gerdts     case 2:
909bc36eafdSMike Gerdts 
910*35786f68SRobert Mustacchi         TrSetOpIntegerValue (PARSEOP_WORDCONST, Op);
911bc36eafdSMike Gerdts         Op->Asl.AmlOpcode = AML_RAW_DATA_WORD;
912bc36eafdSMike Gerdts         break;
913bc36eafdSMike Gerdts 
914bc36eafdSMike Gerdts     case 4:
915bc36eafdSMike Gerdts 
916*35786f68SRobert Mustacchi         TrSetOpIntegerValue (PARSEOP_DWORDCONST, Op);
917bc36eafdSMike Gerdts         Op->Asl.AmlOpcode = AML_RAW_DATA_DWORD;
918bc36eafdSMike Gerdts         break;
919bc36eafdSMike Gerdts 
920bc36eafdSMike Gerdts     case 8:
921bc36eafdSMike Gerdts 
922*35786f68SRobert Mustacchi         TrSetOpIntegerValue (PARSEOP_QWORDCONST, Op);
923bc36eafdSMike Gerdts         Op->Asl.AmlOpcode = AML_RAW_DATA_QWORD;
924bc36eafdSMike Gerdts         break;
925bc36eafdSMike Gerdts 
926bc36eafdSMike Gerdts     case 0:
927bc36eafdSMike Gerdts     default:
928bc36eafdSMike Gerdts 
929bc36eafdSMike Gerdts         OpcSetOptimalIntegerSize (Op);
930*35786f68SRobert Mustacchi         TrSetOpIntegerValue (PARSEOP_INTEGER, Op);
931bc36eafdSMike Gerdts         break;
932bc36eafdSMike Gerdts     }
933bc36eafdSMike Gerdts 
934bc36eafdSMike Gerdts     Op->Asl.AmlLength = 0;
935bc36eafdSMike Gerdts }
936bc36eafdSMike Gerdts 
937bc36eafdSMike Gerdts 
938bc36eafdSMike Gerdts /*******************************************************************************
939bc36eafdSMike Gerdts  *
940bc36eafdSMike Gerdts  * FUNCTION:    OpcAmlEvaluationWalk1
941bc36eafdSMike Gerdts  *
942bc36eafdSMike Gerdts  * PARAMETERS:  ASL_WALK_CALLBACK
943bc36eafdSMike Gerdts  *
944bc36eafdSMike Gerdts  * RETURN:      Status
945bc36eafdSMike Gerdts  *
946bc36eafdSMike Gerdts  * DESCRIPTION: Descending callback for AML execution of constant subtrees
947bc36eafdSMike Gerdts  *
948bc36eafdSMike Gerdts  ******************************************************************************/
949bc36eafdSMike Gerdts 
950bc36eafdSMike Gerdts static ACPI_STATUS
OpcAmlEvaluationWalk1(ACPI_PARSE_OBJECT * Op,UINT32 Level,void * Context)951bc36eafdSMike Gerdts OpcAmlEvaluationWalk1 (
952bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *Op,
953bc36eafdSMike Gerdts     UINT32                  Level,
954bc36eafdSMike Gerdts     void                    *Context)
955bc36eafdSMike Gerdts {
956bc36eafdSMike Gerdts     ACPI_WALK_STATE         *WalkState = Context;
957bc36eafdSMike Gerdts     ACPI_STATUS             Status;
958bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *OutOp;
959bc36eafdSMike Gerdts 
960bc36eafdSMike Gerdts 
961bc36eafdSMike Gerdts     WalkState->Op = Op;
962bc36eafdSMike Gerdts     WalkState->Opcode = Op->Common.AmlOpcode;
963bc36eafdSMike Gerdts     WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
964bc36eafdSMike Gerdts 
965bc36eafdSMike Gerdts     /* Copy child pointer to Arg for compatibility with Interpreter */
966bc36eafdSMike Gerdts 
967bc36eafdSMike Gerdts     if (Op->Asl.Child)
968bc36eafdSMike Gerdts     {
969bc36eafdSMike Gerdts         Op->Common.Value.Arg = Op->Asl.Child;
970bc36eafdSMike Gerdts     }
971bc36eafdSMike Gerdts 
972bc36eafdSMike Gerdts     /* Call AML dispatcher */
973bc36eafdSMike Gerdts 
974bc36eafdSMike Gerdts     Status = AcpiDsExecBeginOp (WalkState, &OutOp);
975bc36eafdSMike Gerdts     if (ACPI_FAILURE (Status))
976bc36eafdSMike Gerdts     {
977bc36eafdSMike Gerdts         DbgPrint (ASL_PARSE_OUTPUT,
978bc36eafdSMike Gerdts             "%s Constant interpretation failed (1) - %s\n",
979bc36eafdSMike Gerdts             Op->Asl.ParseOpName, AcpiFormatException (Status));
980bc36eafdSMike Gerdts     }
981bc36eafdSMike Gerdts 
982bc36eafdSMike Gerdts     return (Status);
983bc36eafdSMike Gerdts }
984bc36eafdSMike Gerdts 
985bc36eafdSMike Gerdts 
986bc36eafdSMike Gerdts /*******************************************************************************
987bc36eafdSMike Gerdts  *
988bc36eafdSMike Gerdts  * FUNCTION:    OpcAmlEvaluationWalk2
989bc36eafdSMike Gerdts  *
990bc36eafdSMike Gerdts  * PARAMETERS:  ASL_WALK_CALLBACK
991bc36eafdSMike Gerdts  *
992bc36eafdSMike Gerdts  * RETURN:      Status
993bc36eafdSMike Gerdts  *
994bc36eafdSMike Gerdts  * DESCRIPTION: Ascending callback for AML execution of constant subtrees
995bc36eafdSMike Gerdts  *
996bc36eafdSMike Gerdts  ******************************************************************************/
997bc36eafdSMike Gerdts 
998bc36eafdSMike Gerdts static ACPI_STATUS
OpcAmlEvaluationWalk2(ACPI_PARSE_OBJECT * Op,UINT32 Level,void * Context)999bc36eafdSMike Gerdts OpcAmlEvaluationWalk2 (
1000bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *Op,
1001bc36eafdSMike Gerdts     UINT32                  Level,
1002bc36eafdSMike Gerdts     void                    *Context)
1003bc36eafdSMike Gerdts {
1004bc36eafdSMike Gerdts     ACPI_WALK_STATE         *WalkState = Context;
1005bc36eafdSMike Gerdts     ACPI_STATUS             Status;
1006bc36eafdSMike Gerdts 
1007bc36eafdSMike Gerdts 
1008bc36eafdSMike Gerdts     WalkState->Op = Op;
1009bc36eafdSMike Gerdts     WalkState->Opcode = Op->Common.AmlOpcode;
1010bc36eafdSMike Gerdts     WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
1011bc36eafdSMike Gerdts 
1012bc36eafdSMike Gerdts     /* Copy child pointer to Arg for compatibility with Interpreter */
1013bc36eafdSMike Gerdts 
1014bc36eafdSMike Gerdts     if (Op->Asl.Child)
1015bc36eafdSMike Gerdts     {
1016bc36eafdSMike Gerdts         Op->Common.Value.Arg = Op->Asl.Child;
1017bc36eafdSMike Gerdts     }
1018bc36eafdSMike Gerdts 
1019bc36eafdSMike Gerdts     /* Call AML dispatcher */
1020bc36eafdSMike Gerdts 
1021bc36eafdSMike Gerdts     Status = AcpiDsExecEndOp (WalkState);
1022bc36eafdSMike Gerdts     if (ACPI_FAILURE (Status))
1023bc36eafdSMike Gerdts     {
1024bc36eafdSMike Gerdts         DbgPrint (ASL_PARSE_OUTPUT,
1025bc36eafdSMike Gerdts             "%s: Constant interpretation failed (2) - %s\n",
1026bc36eafdSMike Gerdts             Op->Asl.ParseOpName, AcpiFormatException (Status));
1027bc36eafdSMike Gerdts     }
1028bc36eafdSMike Gerdts 
1029bc36eafdSMike Gerdts     return (Status);
1030bc36eafdSMike Gerdts }
1031