aslfold.c revision 1.1.1.7 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.7 christos * Copyright (C) 2000 - 2016, 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.5 christos static ACPI_STATUS
80 1.1.1.5 christos TrTransformToStoreOp (
81 1.1.1.5 christos ACPI_PARSE_OBJECT *Op,
82 1.1.1.5 christos ACPI_WALK_STATE *WalkState);
83 1.1.1.5 christos
84 1.1.1.5 christos static ACPI_STATUS
85 1.1.1.5 christos TrSimpleConstantReduction (
86 1.1.1.5 christos ACPI_PARSE_OBJECT *Op,
87 1.1.1.5 christos ACPI_WALK_STATE *WalkState);
88 1.1.1.5 christos
89 1.1.1.5 christos static void
90 1.1.1.5 christos TrInstallReducedConstant (
91 1.1.1.5 christos ACPI_PARSE_OBJECT *Op,
92 1.1.1.5 christos ACPI_OPERAND_OBJECT *ObjDesc);
93 1.1.1.5 christos
94 1.1 jruoho
95 1.1 jruoho /*******************************************************************************
96 1.1 jruoho *
97 1.1.1.5 christos * 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.7 christos * 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.5 christos ACPI_STATUS
108 1.1.1.5 christos 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.5 christos ACPI_WALK_STATE *WalkState;
114 1.1.1.5 christos ACPI_STATUS Status = AE_OK;
115 1.1 jruoho
116 1.1 jruoho
117 1.1.1.5 christos if (Op->Asl.CompileFlags == 0)
118 1.1.1.5 christos {
119 1.1.1.5 christos return (AE_OK);
120 1.1.1.5 christos }
121 1.1 jruoho
122 1.1.1.5 christos /*
123 1.1.1.5 christos * Only interested in subtrees that could possibly contain
124 1.1.1.5 christos * expressions that can be evaluated at this time
125 1.1.1.5 christos */
126 1.1.1.5 christos if ((!(Op->Asl.CompileFlags & NODE_COMPILE_TIME_CONST)) ||
127 1.1.1.5 christos (Op->Asl.CompileFlags & NODE_IS_TARGET))
128 1.1 jruoho {
129 1.1.1.5 christos return (AE_OK);
130 1.1 jruoho }
131 1.1 jruoho
132 1.1.1.5 christos /* Create a new walk state */
133 1.1 jruoho
134 1.1.1.5 christos WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);
135 1.1.1.5 christos if (!WalkState)
136 1.1 jruoho {
137 1.1.1.5 christos return (AE_NO_MEMORY);
138 1.1 jruoho }
139 1.1 jruoho
140 1.1.1.5 christos WalkState->NextOp = NULL;
141 1.1.1.5 christos WalkState->Params = NULL;
142 1.1 jruoho
143 1.1.1.5 christos /*
144 1.1.1.5 christos * Examine the entire subtree -- all nodes must be constants
145 1.1.1.5 christos * or type 3/4/5 opcodes
146 1.1.1.5 christos */
147 1.1.1.5 christos Status = TrWalkParseTree (Op, ASL_WALK_VISIT_DOWNWARD,
148 1.1.1.5 christos OpcAmlCheckForConstant, NULL, WalkState);
149 1.1 jruoho
150 1.1.1.5 christos /*
151 1.1.1.5 christos * Did we find an entire subtree that contains all constants
152 1.1.1.5 christos * and type 3/4/5 opcodes?
153 1.1.1.5 christos */
154 1.1.1.5 christos switch (Status)
155 1.1.1.5 christos {
156 1.1.1.5 christos case AE_OK:
157 1.1 jruoho
158 1.1.1.5 christos /* Simple case, like Add(3,4) -> 7 */
159 1.1 jruoho
160 1.1.1.5 christos Status = TrSimpleConstantReduction (Op, WalkState);
161 1.1.1.5 christos break;
162 1.1 jruoho
163 1.1.1.5 christos case AE_CTRL_RETURN_VALUE:
164 1.1 jruoho
165 1.1.1.5 christos /* More complex case, like Add(3,4,Local0) -> Store(7,Local0) */
166 1.1 jruoho
167 1.1.1.5 christos Status = TrTransformToStoreOp (Op, WalkState);
168 1.1.1.5 christos break;
169 1.1 jruoho
170 1.1.1.5 christos case AE_TYPE:
171 1.1.1.5 christos
172 1.1.1.5 christos AcpiDsDeleteWalkState (WalkState);
173 1.1.1.5 christos return (AE_OK);
174 1.1.1.5 christos
175 1.1.1.5 christos default:
176 1.1.1.5 christos AcpiDsDeleteWalkState (WalkState);
177 1.1.1.5 christos break;
178 1.1.1.5 christos }
179 1.1 jruoho
180 1.1 jruoho if (ACPI_FAILURE (Status))
181 1.1 jruoho {
182 1.1.1.5 christos DbgPrint (ASL_PARSE_OUTPUT, "Cannot resolve, %s\n",
183 1.1.1.5 christos AcpiFormatException (Status));
184 1.1.1.5 christos
185 1.1.1.5 christos /* We could not resolve the subtree for some reason */
186 1.1.1.5 christos
187 1.1.1.5 christos AslError (ASL_ERROR, ASL_MSG_CONSTANT_EVALUATION, Op,
188 1.1.1.5 christos (char *) AcpiFormatException (Status));
189 1.1.1.5 christos
190 1.1.1.5 christos /* Set the subtree value to ZERO anyway. Eliminates further errors */
191 1.1.1.5 christos
192 1.1.1.5 christos OpcUpdateIntegerNode (Op, 0);
193 1.1 jruoho }
194 1.1 jruoho
195 1.1.1.5 christos /* Abort the walk of this subtree, we are done with it */
196 1.1.1.5 christos
197 1.1.1.5 christos 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.1.7 christos * DESCRIPTION: Check one Op for a reducible type 3/4/5 AML opcode.
210 1.1.1.7 christos * This is performed via a downward walk of the parse subtree.
211 1.1 jruoho *
212 1.1 jruoho ******************************************************************************/
213 1.1 jruoho
214 1.1 jruoho static ACPI_STATUS
215 1.1 jruoho OpcAmlCheckForConstant (
216 1.1 jruoho ACPI_PARSE_OBJECT *Op,
217 1.1 jruoho UINT32 Level,
218 1.1 jruoho void *Context)
219 1.1 jruoho {
220 1.1 jruoho ACPI_WALK_STATE *WalkState = Context;
221 1.1.1.5 christos ACPI_STATUS Status = AE_OK;
222 1.1.1.7 christos ACPI_PARSE_OBJECT *NextOp;
223 1.1.1.7 christos const ACPI_OPCODE_INFO *OpInfo;
224 1.1 jruoho
225 1.1 jruoho
226 1.1 jruoho WalkState->Op = Op;
227 1.1 jruoho WalkState->Opcode = Op->Common.AmlOpcode;
228 1.1 jruoho WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
229 1.1 jruoho
230 1.1 jruoho DbgPrint (ASL_PARSE_OUTPUT, "[%.4d] Opcode: %12.12s ",
231 1.1.1.5 christos Op->Asl.LogicalLineNumber, Op->Asl.ParseOpName);
232 1.1.1.5 christos
233 1.1.1.5 christos /*
234 1.1.1.3 christos * These opcodes do not appear in the OpcodeInfo table, but
235 1.1.1.3 christos * they represent constants, so abort the constant walk now.
236 1.1.1.3 christos */
237 1.1.1.3 christos if ((WalkState->Opcode == AML_RAW_DATA_BYTE) ||
238 1.1.1.3 christos (WalkState->Opcode == AML_RAW_DATA_WORD) ||
239 1.1.1.3 christos (WalkState->Opcode == AML_RAW_DATA_DWORD) ||
240 1.1.1.3 christos (WalkState->Opcode == AML_RAW_DATA_QWORD))
241 1.1.1.3 christos {
242 1.1.1.5 christos DbgPrint (ASL_PARSE_OUTPUT, "RAW DATA");
243 1.1.1.5 christos Status = AE_TYPE;
244 1.1.1.5 christos goto CleanupAndExit;
245 1.1.1.3 christos }
246 1.1.1.3 christos
247 1.1.1.7 christos /*
248 1.1.1.7 christos * Search upwards for a possible Name() operator. This is done
249 1.1.1.7 christos * because a type 3/4/5 opcode within a Name() expression
250 1.1.1.7 christos * MUST be reduced to a simple constant.
251 1.1.1.7 christos */
252 1.1.1.7 christos NextOp = Op->Asl.Parent;
253 1.1.1.7 christos while (NextOp)
254 1.1.1.7 christos {
255 1.1.1.7 christos /* Finished if we find a Name() opcode */
256 1.1.1.7 christos
257 1.1.1.7 christos if (NextOp->Asl.AmlOpcode == AML_NAME_OP)
258 1.1.1.7 christos {
259 1.1.1.7 christos break;
260 1.1.1.7 christos }
261 1.1.1.7 christos
262 1.1.1.7 christos /*
263 1.1.1.7 christos * Any "deferred" opcodes contain one or more TermArg parameters,
264 1.1.1.7 christos * and thus are not required to be folded to constants at compile
265 1.1.1.7 christos * time. This affects things like Buffer() and Package() objects.
266 1.1.1.7 christos * We just ignore them here. However, any sub-expressions can and
267 1.1.1.7 christos * will still be typechecked. Note: These are called the
268 1.1.1.7 christos * "deferred" opcodes in the AML interpreter.
269 1.1.1.7 christos */
270 1.1.1.7 christos OpInfo = AcpiPsGetOpcodeInfo (NextOp->Common.AmlOpcode);
271 1.1.1.7 christos if (OpInfo->Flags & AML_DEFER)
272 1.1.1.7 christos {
273 1.1.1.7 christos NextOp = NULL;
274 1.1.1.7 christos break;
275 1.1.1.7 christos }
276 1.1.1.7 christos
277 1.1.1.7 christos NextOp = NextOp->Asl.Parent;
278 1.1.1.7 christos }
279 1.1.1.7 christos
280 1.1.1.5 christos /* Type 3/4/5 opcodes have the AML_CONSTANT flag set */
281 1.1.1.5 christos
282 1.1 jruoho if (!(WalkState->OpInfo->Flags & AML_CONSTANT))
283 1.1 jruoho {
284 1.1.1.7 christos /*
285 1.1.1.7 christos * From the ACPI specification:
286 1.1.1.7 christos *
287 1.1.1.7 christos * "The Type 3/4/5 opcodes return a value and can be used in an
288 1.1.1.7 christos * expression that evaluates to a constant. These opcodes may be
289 1.1.1.7 christos * evaluated at ASL compile-time. To ensure that these opcodes
290 1.1.1.7 christos * will evaluate to a constant, the following rules apply: The
291 1.1.1.7 christos * term cannot have a destination (target) operand, and must have
292 1.1.1.7 christos * either a Type3Opcode, Type4Opcode, Type5Opcode, ConstExprTerm,
293 1.1.1.7 christos * Integer, BufferTerm, Package, or String for all arguments."
294 1.1.1.7 christos */
295 1.1.1.7 christos
296 1.1.1.7 christos /*
297 1.1.1.7 christos * The value (second) operand for the Name() operator MUST
298 1.1.1.7 christos * reduce to a single constant, as per the ACPI specification
299 1.1.1.7 christos * (the operand is a DataObject). This also implies that there
300 1.1.1.7 christos * can be no target operand. Name() is the only ASL operator
301 1.1.1.7 christos * with a "DataObject" as an operand and is thus special-
302 1.1.1.7 christos * cased here.
303 1.1.1.7 christos */
304 1.1.1.7 christos if (NextOp) /* Inspect a Name() operator */
305 1.1.1.7 christos {
306 1.1.1.7 christos /* Error if there is a target operand */
307 1.1.1.7 christos
308 1.1.1.7 christos if (Op->Asl.CompileFlags & NODE_IS_TARGET)
309 1.1.1.7 christos {
310 1.1.1.7 christos AslError (ASL_ERROR, ASL_MSG_INVALID_TARGET, Op, NULL);
311 1.1.1.7 christos Status = AE_TYPE;
312 1.1.1.7 christos }
313 1.1.1.7 christos
314 1.1.1.7 christos /* Error if expression cannot be reduced (folded) */
315 1.1.1.7 christos
316 1.1.1.7 christos if (!(NextOp->Asl.CompileFlags & NODE_COULD_NOT_REDUCE))
317 1.1.1.7 christos {
318 1.1.1.7 christos /* Ensure only one error message per statement */
319 1.1.1.7 christos
320 1.1.1.7 christos NextOp->Asl.CompileFlags |= NODE_COULD_NOT_REDUCE;
321 1.1.1.7 christos DbgPrint (ASL_PARSE_OUTPUT,
322 1.1.1.7 christos "**** Could not reduce operands for NAME opcode ****\n");
323 1.1.1.7 christos
324 1.1.1.7 christos AslError (ASL_ERROR, ASL_MSG_CONSTANT_REQUIRED, Op,
325 1.1.1.7 christos "Constant is required for Name operator");
326 1.1.1.7 christos Status = AE_TYPE;
327 1.1.1.7 christos }
328 1.1.1.7 christos }
329 1.1.1.7 christos
330 1.1.1.7 christos if (ACPI_FAILURE (Status))
331 1.1.1.7 christos {
332 1.1.1.7 christos goto CleanupAndExit;
333 1.1.1.7 christos }
334 1.1.1.7 christos
335 1.1.1.7 christos /* This is not a 3/4/5 opcode, but maybe can convert to STORE */
336 1.1 jruoho
337 1.1 jruoho if (Op->Asl.CompileFlags & NODE_IS_TARGET)
338 1.1 jruoho {
339 1.1 jruoho DbgPrint (ASL_PARSE_OUTPUT,
340 1.1.1.5 christos "**** Valid Target, transform to Store ****\n");
341 1.1.1.5 christos return (AE_CTRL_RETURN_VALUE);
342 1.1 jruoho }
343 1.1 jruoho
344 1.1.1.5 christos /* Expression cannot be reduced */
345 1.1 jruoho
346 1.1.1.5 christos DbgPrint (ASL_PARSE_OUTPUT,
347 1.1.1.7 christos "**** Not a Type 3/4/5 opcode or cannot reduce/fold (%s) ****\n",
348 1.1.1.5 christos Op->Asl.ParseOpName);
349 1.1 jruoho
350 1.1.1.5 christos Status = AE_TYPE;
351 1.1.1.5 christos goto CleanupAndExit;
352 1.1 jruoho }
353 1.1 jruoho
354 1.1.1.7 christos /*
355 1.1.1.7 christos * TBD: Ignore buffer constants for now. The problem is that these
356 1.1.1.7 christos * constants have been transformed into RAW_DATA at this point, from
357 1.1.1.7 christos * the parse tree transform process which currently happens before
358 1.1.1.7 christos * the constant folding process. We may need to defer this transform
359 1.1.1.7 christos * for buffer until after the constant folding.
360 1.1.1.7 christos */
361 1.1.1.7 christos if (WalkState->Opcode == AML_BUFFER_OP)
362 1.1.1.7 christos {
363 1.1.1.7 christos DbgPrint (ASL_PARSE_OUTPUT,
364 1.1.1.7 christos "\nBuffer constant reduction is not supported yet\n");
365 1.1.1.7 christos
366 1.1.1.7 christos if (NextOp) /* Found a Name() operator, error */
367 1.1.1.7 christos {
368 1.1.1.7 christos AslError (ASL_ERROR, ASL_MSG_UNSUPPORTED, Op,
369 1.1.1.7 christos "Buffer expression cannot be reduced");
370 1.1.1.7 christos }
371 1.1.1.7 christos
372 1.1.1.7 christos Status = AE_TYPE;
373 1.1.1.7 christos goto CleanupAndExit;
374 1.1.1.7 christos }
375 1.1.1.7 christos
376 1.1.1.7 christos
377 1.1 jruoho /* Debug output */
378 1.1 jruoho
379 1.1 jruoho DbgPrint (ASL_PARSE_OUTPUT, "TYPE_345");
380 1.1 jruoho
381 1.1 jruoho if (Op->Asl.CompileFlags & NODE_IS_TARGET)
382 1.1 jruoho {
383 1.1.1.5 christos if (Op->Asl.ParseOpcode == PARSEOP_ZERO)
384 1.1.1.5 christos {
385 1.1.1.5 christos DbgPrint (ASL_PARSE_OUTPUT, "%-16s", " NULL TARGET");
386 1.1.1.5 christos }
387 1.1.1.5 christos else
388 1.1.1.5 christos {
389 1.1.1.5 christos DbgPrint (ASL_PARSE_OUTPUT, "%-16s", " VALID TARGET");
390 1.1.1.5 christos }
391 1.1 jruoho }
392 1.1.1.7 christos
393 1.1 jruoho if (Op->Asl.CompileFlags & NODE_IS_TERM_ARG)
394 1.1 jruoho {
395 1.1.1.5 christos DbgPrint (ASL_PARSE_OUTPUT, "%-16s", " TERMARG");
396 1.1 jruoho }
397 1.1 jruoho
398 1.1.1.5 christos CleanupAndExit:
399 1.1.1.5 christos
400 1.1.1.5 christos /* Dump the node compile flags also */
401 1.1.1.5 christos
402 1.1.1.5 christos TrPrintNodeCompileFlags (Op->Asl.CompileFlags);
403 1.1.1.3 christos DbgPrint (ASL_PARSE_OUTPUT, "\n");
404 1.1.1.5 christos return (Status);
405 1.1 jruoho }
406 1.1 jruoho
407 1.1 jruoho
408 1.1 jruoho /*******************************************************************************
409 1.1 jruoho *
410 1.1.1.5 christos * FUNCTION: TrSimpleConstantReduction
411 1.1 jruoho *
412 1.1.1.5 christos * PARAMETERS: Op - Parent operator to be transformed
413 1.1.1.5 christos * WalkState - Current walk state
414 1.1 jruoho *
415 1.1 jruoho * RETURN: Status
416 1.1 jruoho *
417 1.1.1.5 christos * DESCRIPTION: Reduce an entire AML operation to a single constant. The
418 1.1.1.5 christos * operation must not have a target operand.
419 1.1.1.5 christos *
420 1.1.1.5 christos * Add (32,64) --> 96
421 1.1 jruoho *
422 1.1 jruoho ******************************************************************************/
423 1.1 jruoho
424 1.1.1.5 christos static ACPI_STATUS
425 1.1.1.5 christos TrSimpleConstantReduction (
426 1.1 jruoho ACPI_PARSE_OBJECT *Op,
427 1.1.1.5 christos ACPI_WALK_STATE *WalkState)
428 1.1 jruoho {
429 1.1 jruoho ACPI_PARSE_OBJECT *RootOp;
430 1.1 jruoho ACPI_PARSE_OBJECT *OriginalParentOp;
431 1.1.1.5 christos ACPI_OPERAND_OBJECT *ObjDesc;
432 1.1.1.5 christos ACPI_STATUS Status;
433 1.1 jruoho
434 1.1 jruoho
435 1.1.1.5 christos DbgPrint (ASL_PARSE_OUTPUT,
436 1.1.1.5 christos "Simple subtree constant reduction, operator to constant\n");
437 1.1.1.5 christos
438 1.1.1.5 christos /* Allocate a new temporary root for this subtree */
439 1.1.1.5 christos
440 1.1.1.5 christos RootOp = TrAllocateNode (PARSEOP_INTEGER);
441 1.1.1.5 christos if (!RootOp)
442 1.1 jruoho {
443 1.1.1.5 christos return (AE_NO_MEMORY);
444 1.1 jruoho }
445 1.1 jruoho
446 1.1.1.5 christos RootOp->Common.AmlOpcode = AML_INT_EVAL_SUBTREE_OP;
447 1.1 jruoho
448 1.1.1.5 christos OriginalParentOp = Op->Common.Parent;
449 1.1.1.5 christos Op->Common.Parent = RootOp;
450 1.1 jruoho
451 1.1.1.5 christos /* Hand off the subtree to the AML interpreter */
452 1.1 jruoho
453 1.1.1.5 christos WalkState->CallerReturnDesc = &ObjDesc;
454 1.1.1.5 christos
455 1.1.1.5 christos Status = TrWalkParseTree (Op, ASL_WALK_VISIT_TWICE,
456 1.1.1.5 christos OpcAmlEvaluationWalk1, OpcAmlEvaluationWalk2, WalkState);
457 1.1.1.5 christos
458 1.1.1.5 christos /* Restore original parse tree */
459 1.1 jruoho
460 1.1.1.5 christos Op->Common.Parent = OriginalParentOp;
461 1.1.1.5 christos
462 1.1.1.5 christos if (ACPI_FAILURE (Status))
463 1.1.1.5 christos {
464 1.1.1.5 christos DbgPrint (ASL_PARSE_OUTPUT,
465 1.1.1.5 christos "Constant Subtree evaluation(1), %s\n",
466 1.1.1.5 christos AcpiFormatException (Status));
467 1.1.1.5 christos return (Status);
468 1.1 jruoho }
469 1.1 jruoho
470 1.1.1.5 christos /* Get the final result */
471 1.1 jruoho
472 1.1.1.5 christos Status = AcpiDsResultPop (&ObjDesc, WalkState);
473 1.1.1.5 christos if (ACPI_FAILURE (Status))
474 1.1 jruoho {
475 1.1.1.5 christos DbgPrint (ASL_PARSE_OUTPUT,
476 1.1.1.5 christos "Constant Subtree evaluation(2), %s\n",
477 1.1.1.5 christos AcpiFormatException (Status));
478 1.1.1.5 christos return (Status);
479 1.1 jruoho }
480 1.1 jruoho
481 1.1.1.6 christos /* Disconnect any existing children, install new constant */
482 1.1.1.6 christos
483 1.1.1.6 christos Op->Asl.Child = NULL;
484 1.1.1.5 christos TrInstallReducedConstant (Op, ObjDesc);
485 1.1 jruoho
486 1.1.1.5 christos UtSetParseOpName (Op);
487 1.1.1.5 christos return (AE_OK);
488 1.1.1.5 christos }
489 1.1.1.5 christos
490 1.1.1.5 christos
491 1.1.1.5 christos /*******************************************************************************
492 1.1.1.5 christos *
493 1.1.1.5 christos * FUNCTION: TrTransformToStoreOp
494 1.1.1.5 christos *
495 1.1.1.5 christos * PARAMETERS: Op - Parent operator to be transformed
496 1.1.1.5 christos * WalkState - Current walk state
497 1.1.1.5 christos *
498 1.1.1.5 christos * RETURN: Status
499 1.1.1.5 christos *
500 1.1.1.5 christos * DESCRIPTION: Transforms a single AML operation with a constant and target
501 1.1.1.5 christos * to a simple store operation:
502 1.1.1.5 christos *
503 1.1.1.5 christos * Add (32,64,DATA) --> Store (96,DATA)
504 1.1.1.5 christos *
505 1.1.1.5 christos ******************************************************************************/
506 1.1.1.5 christos
507 1.1.1.5 christos static ACPI_STATUS
508 1.1.1.5 christos TrTransformToStoreOp (
509 1.1.1.5 christos ACPI_PARSE_OBJECT *Op,
510 1.1.1.5 christos ACPI_WALK_STATE *WalkState)
511 1.1.1.5 christos {
512 1.1.1.5 christos ACPI_PARSE_OBJECT *OriginalTarget;
513 1.1.1.5 christos ACPI_PARSE_OBJECT *NewTarget;
514 1.1.1.5 christos ACPI_PARSE_OBJECT *Child1;
515 1.1.1.5 christos ACPI_PARSE_OBJECT *Child2;
516 1.1.1.5 christos ACPI_OPERAND_OBJECT *ObjDesc;
517 1.1.1.5 christos ACPI_PARSE_OBJECT *NewParent;
518 1.1.1.5 christos ACPI_PARSE_OBJECT *OriginalParent;
519 1.1.1.5 christos ACPI_STATUS Status;
520 1.1.1.5 christos
521 1.1.1.5 christos
522 1.1.1.5 christos DbgPrint (ASL_PARSE_OUTPUT,
523 1.1.1.5 christos "Reduction/Transform to StoreOp: Store(Constant, Target)\n");
524 1.1.1.5 christos
525 1.1.1.5 christos /* Extract the operands */
526 1.1.1.5 christos
527 1.1.1.5 christos Child1 = Op->Asl.Child;
528 1.1.1.5 christos Child2 = Child1->Asl.Next;
529 1.1 jruoho
530 1.1 jruoho /*
531 1.1.1.5 christos * Special case for DIVIDE -- it has two targets. The first
532 1.1.1.5 christos * is for the remainder and if present, we will not attempt
533 1.1.1.5 christos * to reduce the expression.
534 1.1 jruoho */
535 1.1.1.5 christos if (Op->Asl.ParseOpcode == PARSEOP_DIVIDE)
536 1.1 jruoho {
537 1.1.1.5 christos Child2 = Child2->Asl.Next;
538 1.1.1.5 christos if (Child2->Asl.ParseOpcode != PARSEOP_ZERO)
539 1.1 jruoho {
540 1.1.1.5 christos DbgPrint (ASL_PARSE_OUTPUT,
541 1.1.1.5 christos "Cannot reduce DIVIDE - has two targets\n\n");
542 1.1 jruoho return (AE_OK);
543 1.1 jruoho }
544 1.1.1.5 christos }
545 1.1.1.5 christos
546 1.1.1.5 christos /*
547 1.1.1.5 christos * Create a NULL (zero) target so that we can use the
548 1.1.1.5 christos * interpreter to evaluate the expression.
549 1.1.1.5 christos */
550 1.1.1.5 christos NewTarget = TrCreateNullTarget ();
551 1.1.1.5 christos NewTarget->Common.AmlOpcode = AML_INT_NAMEPATH_OP;
552 1.1 jruoho
553 1.1.1.5 christos /* Handle one-operand cases (NOT, TOBCD, etc.) */
554 1.1 jruoho
555 1.1.1.5 christos if (!Child2->Asl.Next)
556 1.1 jruoho {
557 1.1.1.5 christos Child2 = Child1;
558 1.1.1.5 christos }
559 1.1 jruoho
560 1.1.1.5 christos /* Link in new NULL target as the last operand */
561 1.1 jruoho
562 1.1.1.5 christos OriginalTarget = Child2->Asl.Next;
563 1.1.1.5 christos Child2->Asl.Next = NewTarget;
564 1.1.1.5 christos NewTarget->Asl.Parent = OriginalTarget->Asl.Parent;
565 1.1 jruoho
566 1.1.1.5 christos NewParent = TrAllocateNode (PARSEOP_INTEGER);
567 1.1.1.5 christos NewParent->Common.AmlOpcode = AML_INT_EVAL_SUBTREE_OP;
568 1.1 jruoho
569 1.1.1.5 christos OriginalParent = Op->Common.Parent;
570 1.1.1.5 christos Op->Common.Parent = NewParent;
571 1.1 jruoho
572 1.1.1.5 christos /* Hand off the subtree to the AML interpreter */
573 1.1 jruoho
574 1.1.1.5 christos WalkState->CallerReturnDesc = &ObjDesc;
575 1.1 jruoho
576 1.1.1.5 christos Status = TrWalkParseTree (Op, ASL_WALK_VISIT_TWICE,
577 1.1.1.5 christos OpcAmlEvaluationWalk1, OpcAmlEvaluationWalk2, WalkState);
578 1.1.1.5 christos if (ACPI_FAILURE (Status))
579 1.1.1.5 christos {
580 1.1.1.5 christos DbgPrint (ASL_PARSE_OUTPUT,
581 1.1.1.5 christos "Constant Subtree evaluation(3), %s\n",
582 1.1.1.5 christos AcpiFormatException (Status));
583 1.1.1.5 christos goto EvalError;
584 1.1.1.5 christos }
585 1.1 jruoho
586 1.1.1.5 christos /* Get the final result */
587 1.1 jruoho
588 1.1.1.5 christos Status = AcpiDsResultPop (&ObjDesc, WalkState);
589 1.1.1.5 christos if (ACPI_FAILURE (Status))
590 1.1.1.5 christos {
591 1.1.1.5 christos DbgPrint (ASL_PARSE_OUTPUT,
592 1.1.1.5 christos "Constant Subtree evaluation(4), %s\n",
593 1.1.1.5 christos AcpiFormatException (Status));
594 1.1.1.5 christos goto EvalError;
595 1.1.1.5 christos }
596 1.1 jruoho
597 1.1.1.6 christos /* Truncate any subtree expressions, they have been evaluated */
598 1.1.1.6 christos
599 1.1.1.6 christos Child1->Asl.Child = NULL;
600 1.1.1.6 christos
601 1.1.1.5 christos /* Folded constant is in ObjDesc, store into Child1 */
602 1.1.1.3 christos
603 1.1.1.5 christos TrInstallReducedConstant (Child1, ObjDesc);
604 1.1.1.3 christos
605 1.1.1.5 christos /* Convert operator to STORE */
606 1.1 jruoho
607 1.1.1.5 christos Op->Asl.ParseOpcode = PARSEOP_STORE;
608 1.1.1.5 christos Op->Asl.AmlOpcode = AML_STORE_OP;
609 1.1.1.5 christos UtSetParseOpName (Op);
610 1.1.1.5 christos Op->Common.Parent = OriginalParent;
611 1.1 jruoho
612 1.1.1.5 christos /* First child is the folded constant */
613 1.1 jruoho
614 1.1.1.5 christos /* Second child will be the target */
615 1.1 jruoho
616 1.1.1.5 christos Child1->Asl.Next = OriginalTarget;
617 1.1.1.5 christos return (AE_OK);
618 1.1 jruoho
619 1.1 jruoho
620 1.1.1.5 christos EvalError:
621 1.1.1.5 christos
622 1.1.1.5 christos /* Restore original links */
623 1.1.1.5 christos
624 1.1.1.5 christos Op->Common.Parent = OriginalParent;
625 1.1.1.5 christos Child2->Asl.Next = OriginalTarget;
626 1.1.1.5 christos return (Status);
627 1.1.1.5 christos }
628 1.1.1.5 christos
629 1.1.1.5 christos
630 1.1.1.5 christos /*******************************************************************************
631 1.1.1.5 christos *
632 1.1.1.5 christos * FUNCTION: TrInstallReducedConstant
633 1.1.1.5 christos *
634 1.1.1.5 christos * PARAMETERS: Op - Parent operator to be transformed
635 1.1.1.5 christos * ObjDesc - Reduced constant to be installed
636 1.1.1.5 christos *
637 1.1.1.5 christos * RETURN: None
638 1.1.1.5 christos *
639 1.1.1.5 christos * DESCRIPTION: Transform the original operator to a simple constant.
640 1.1.1.5 christos * Handles Integers, Strings, and Buffers.
641 1.1.1.5 christos *
642 1.1.1.5 christos ******************************************************************************/
643 1.1 jruoho
644 1.1.1.5 christos static void
645 1.1.1.5 christos TrInstallReducedConstant (
646 1.1.1.5 christos ACPI_PARSE_OBJECT *Op,
647 1.1.1.5 christos ACPI_OPERAND_OBJECT *ObjDesc)
648 1.1.1.5 christos {
649 1.1.1.6 christos ACPI_PARSE_OBJECT *LengthOp;
650 1.1.1.6 christos ACPI_PARSE_OBJECT *DataOp;
651 1.1 jruoho
652 1.1 jruoho
653 1.1.1.5 christos TotalFolds++;
654 1.1.1.5 christos AslError (ASL_OPTIMIZATION, ASL_MSG_CONSTANT_FOLDED, Op,
655 1.1.1.5 christos Op->Asl.ParseOpName);
656 1.1 jruoho
657 1.1.1.5 christos /*
658 1.1.1.5 christos * Because we know we executed type 3/4/5 opcodes above, we know that
659 1.1.1.5 christos * the result must be either an Integer, String, or Buffer.
660 1.1.1.5 christos */
661 1.1.1.5 christos switch (ObjDesc->Common.Type)
662 1.1.1.5 christos {
663 1.1.1.5 christos case ACPI_TYPE_INTEGER:
664 1.1 jruoho
665 1.1.1.5 christos OpcUpdateIntegerNode (Op, ObjDesc->Integer.Value);
666 1.1 jruoho
667 1.1.1.5 christos DbgPrint (ASL_PARSE_OUTPUT,
668 1.1.1.5 christos "Constant expression reduced to (%s) %8.8X%8.8X\n\n",
669 1.1.1.5 christos Op->Asl.ParseOpName,
670 1.1.1.5 christos ACPI_FORMAT_UINT64 (Op->Common.Value.Integer));
671 1.1.1.5 christos break;
672 1.1 jruoho
673 1.1.1.5 christos case ACPI_TYPE_STRING:
674 1.1 jruoho
675 1.1.1.5 christos Op->Asl.ParseOpcode = PARSEOP_STRING_LITERAL;
676 1.1.1.5 christos Op->Common.AmlOpcode = AML_STRING_OP;
677 1.1.1.6 christos Op->Asl.AmlLength = strlen (ObjDesc->String.Pointer) + 1;
678 1.1.1.5 christos Op->Common.Value.String = ObjDesc->String.Pointer;
679 1.1.1.5 christos
680 1.1.1.5 christos DbgPrint (ASL_PARSE_OUTPUT,
681 1.1.1.5 christos "Constant expression reduced to (STRING) %s\n\n",
682 1.1.1.5 christos Op->Common.Value.String);
683 1.1.1.5 christos break;
684 1.1 jruoho
685 1.1.1.5 christos case ACPI_TYPE_BUFFER:
686 1.1.1.6 christos /*
687 1.1.1.6 christos * Create a new parse subtree of the form:
688 1.1.1.6 christos *
689 1.1.1.6 christos * BUFFER (Buffer AML opcode)
690 1.1.1.6 christos * INTEGER (Buffer length in bytes)
691 1.1.1.6 christos * RAW_DATA (Buffer byte data)
692 1.1.1.6 christos */
693 1.1.1.5 christos Op->Asl.ParseOpcode = PARSEOP_BUFFER;
694 1.1.1.5 christos Op->Common.AmlOpcode = AML_BUFFER_OP;
695 1.1.1.5 christos Op->Asl.CompileFlags = NODE_AML_PACKAGE;
696 1.1.1.5 christos UtSetParseOpName (Op);
697 1.1 jruoho
698 1.1.1.5 christos /* Child node is the buffer length */
699 1.1 jruoho
700 1.1.1.6 christos LengthOp = TrAllocateNode (PARSEOP_INTEGER);
701 1.1 jruoho
702 1.1.1.6 christos LengthOp->Asl.AmlOpcode = AML_DWORD_OP;
703 1.1.1.6 christos LengthOp->Asl.Value.Integer = ObjDesc->Buffer.Length;
704 1.1.1.6 christos LengthOp->Asl.Parent = Op;
705 1.1.1.6 christos (void) OpcSetOptimalIntegerSize (LengthOp);
706 1.1.1.5 christos
707 1.1.1.6 christos Op->Asl.Child = LengthOp;
708 1.1.1.5 christos
709 1.1.1.6 christos /* Next child is the raw buffer data */
710 1.1.1.5 christos
711 1.1.1.6 christos DataOp = TrAllocateNode (PARSEOP_RAW_DATA);
712 1.1.1.6 christos DataOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER;
713 1.1.1.6 christos DataOp->Asl.AmlLength = ObjDesc->Buffer.Length;
714 1.1.1.6 christos DataOp->Asl.Value.String = (char *) ObjDesc->Buffer.Pointer;
715 1.1.1.6 christos DataOp->Asl.Parent = Op;
716 1.1.1.5 christos
717 1.1.1.6 christos LengthOp->Asl.Next = DataOp;
718 1.1.1.5 christos
719 1.1.1.5 christos DbgPrint (ASL_PARSE_OUTPUT,
720 1.1.1.5 christos "Constant expression reduced to (BUFFER) length %X\n\n",
721 1.1.1.5 christos ObjDesc->Buffer.Length);
722 1.1.1.5 christos break;
723 1.1.1.5 christos
724 1.1.1.5 christos default:
725 1.1.1.5 christos break;
726 1.1.1.5 christos }
727 1.1 jruoho }
728 1.1 jruoho
729 1.1.1.3 christos
730 1.1.1.3 christos /*******************************************************************************
731 1.1.1.3 christos *
732 1.1.1.3 christos * FUNCTION: OpcUpdateIntegerNode
733 1.1.1.3 christos *
734 1.1.1.3 christos * PARAMETERS: Op - Current parse object
735 1.1.1.5 christos * Value - Value for the integer op
736 1.1.1.3 christos *
737 1.1.1.3 christos * RETURN: None
738 1.1.1.3 christos *
739 1.1.1.5 christos * DESCRIPTION: Update node to the correct Integer type and value
740 1.1.1.3 christos *
741 1.1.1.3 christos ******************************************************************************/
742 1.1.1.3 christos
743 1.1.1.3 christos static void
744 1.1.1.3 christos OpcUpdateIntegerNode (
745 1.1.1.3 christos ACPI_PARSE_OBJECT *Op,
746 1.1.1.3 christos UINT64 Value)
747 1.1.1.3 christos {
748 1.1.1.3 christos
749 1.1.1.3 christos Op->Common.Value.Integer = Value;
750 1.1.1.3 christos
751 1.1.1.3 christos /*
752 1.1.1.3 christos * The AmlLength is used by the parser to indicate a constant,
753 1.1.1.3 christos * (if non-zero). Length is either (1/2/4/8)
754 1.1.1.3 christos */
755 1.1.1.3 christos switch (Op->Asl.AmlLength)
756 1.1.1.3 christos {
757 1.1.1.3 christos case 1:
758 1.1.1.3 christos
759 1.1.1.3 christos TrUpdateNode (PARSEOP_BYTECONST, Op);
760 1.1.1.3 christos Op->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
761 1.1.1.3 christos break;
762 1.1.1.3 christos
763 1.1.1.3 christos case 2:
764 1.1.1.3 christos
765 1.1.1.3 christos TrUpdateNode (PARSEOP_WORDCONST, Op);
766 1.1.1.3 christos Op->Asl.AmlOpcode = AML_RAW_DATA_WORD;
767 1.1.1.3 christos break;
768 1.1.1.3 christos
769 1.1.1.3 christos case 4:
770 1.1.1.3 christos
771 1.1.1.3 christos TrUpdateNode (PARSEOP_DWORDCONST, Op);
772 1.1.1.3 christos Op->Asl.AmlOpcode = AML_RAW_DATA_DWORD;
773 1.1.1.3 christos break;
774 1.1.1.3 christos
775 1.1.1.3 christos case 8:
776 1.1.1.3 christos
777 1.1.1.3 christos TrUpdateNode (PARSEOP_QWORDCONST, Op);
778 1.1.1.3 christos Op->Asl.AmlOpcode = AML_RAW_DATA_QWORD;
779 1.1.1.3 christos break;
780 1.1.1.3 christos
781 1.1.1.3 christos case 0:
782 1.1.1.3 christos default:
783 1.1.1.3 christos
784 1.1.1.3 christos OpcSetOptimalIntegerSize (Op);
785 1.1.1.3 christos TrUpdateNode (PARSEOP_INTEGER, Op);
786 1.1.1.3 christos break;
787 1.1.1.3 christos }
788 1.1.1.3 christos
789 1.1.1.3 christos Op->Asl.AmlLength = 0;
790 1.1.1.3 christos }
791 1.1.1.5 christos
792 1.1.1.5 christos
793 1.1.1.5 christos /*******************************************************************************
794 1.1.1.5 christos *
795 1.1.1.5 christos * FUNCTION: OpcAmlEvaluationWalk1
796 1.1.1.5 christos *
797 1.1.1.5 christos * PARAMETERS: ASL_WALK_CALLBACK
798 1.1.1.5 christos *
799 1.1.1.5 christos * RETURN: Status
800 1.1.1.5 christos *
801 1.1.1.5 christos * DESCRIPTION: Descending callback for AML execution of constant subtrees
802 1.1.1.5 christos *
803 1.1.1.5 christos ******************************************************************************/
804 1.1.1.5 christos
805 1.1.1.5 christos static ACPI_STATUS
806 1.1.1.5 christos OpcAmlEvaluationWalk1 (
807 1.1.1.5 christos ACPI_PARSE_OBJECT *Op,
808 1.1.1.5 christos UINT32 Level,
809 1.1.1.5 christos void *Context)
810 1.1.1.5 christos {
811 1.1.1.5 christos ACPI_WALK_STATE *WalkState = Context;
812 1.1.1.5 christos ACPI_STATUS Status;
813 1.1.1.5 christos ACPI_PARSE_OBJECT *OutOp;
814 1.1.1.5 christos
815 1.1.1.5 christos
816 1.1.1.5 christos WalkState->Op = Op;
817 1.1.1.5 christos WalkState->Opcode = Op->Common.AmlOpcode;
818 1.1.1.5 christos WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
819 1.1.1.5 christos
820 1.1.1.5 christos /* Copy child pointer to Arg for compatibility with Interpreter */
821 1.1.1.5 christos
822 1.1.1.5 christos if (Op->Asl.Child)
823 1.1.1.5 christos {
824 1.1.1.5 christos Op->Common.Value.Arg = Op->Asl.Child;
825 1.1.1.5 christos }
826 1.1.1.5 christos
827 1.1.1.5 christos /* Call AML dispatcher */
828 1.1.1.5 christos
829 1.1.1.5 christos Status = AcpiDsExecBeginOp (WalkState, &OutOp);
830 1.1.1.5 christos if (ACPI_FAILURE (Status))
831 1.1.1.5 christos {
832 1.1.1.5 christos DbgPrint (ASL_PARSE_OUTPUT,
833 1.1.1.5 christos "%s Constant interpretation failed (1) - %s\n",
834 1.1.1.5 christos Op->Asl.ParseOpName, AcpiFormatException (Status));
835 1.1.1.5 christos }
836 1.1.1.5 christos
837 1.1.1.5 christos return (Status);
838 1.1.1.5 christos }
839 1.1.1.5 christos
840 1.1.1.5 christos
841 1.1.1.5 christos /*******************************************************************************
842 1.1.1.5 christos *
843 1.1.1.5 christos * FUNCTION: OpcAmlEvaluationWalk2
844 1.1.1.5 christos *
845 1.1.1.5 christos * PARAMETERS: ASL_WALK_CALLBACK
846 1.1.1.5 christos *
847 1.1.1.5 christos * RETURN: Status
848 1.1.1.5 christos *
849 1.1.1.5 christos * DESCRIPTION: Ascending callback for AML execution of constant subtrees
850 1.1.1.5 christos *
851 1.1.1.5 christos ******************************************************************************/
852 1.1.1.5 christos
853 1.1.1.5 christos static ACPI_STATUS
854 1.1.1.5 christos OpcAmlEvaluationWalk2 (
855 1.1.1.5 christos ACPI_PARSE_OBJECT *Op,
856 1.1.1.5 christos UINT32 Level,
857 1.1.1.5 christos void *Context)
858 1.1.1.5 christos {
859 1.1.1.5 christos ACPI_WALK_STATE *WalkState = Context;
860 1.1.1.5 christos ACPI_STATUS Status;
861 1.1.1.5 christos
862 1.1.1.5 christos
863 1.1.1.5 christos WalkState->Op = Op;
864 1.1.1.5 christos WalkState->Opcode = Op->Common.AmlOpcode;
865 1.1.1.5 christos WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
866 1.1.1.5 christos
867 1.1.1.5 christos /* Copy child pointer to Arg for compatibility with Interpreter */
868 1.1.1.5 christos
869 1.1.1.5 christos if (Op->Asl.Child)
870 1.1.1.5 christos {
871 1.1.1.5 christos Op->Common.Value.Arg = Op->Asl.Child;
872 1.1.1.5 christos }
873 1.1.1.5 christos
874 1.1.1.5 christos /* Call AML dispatcher */
875 1.1.1.5 christos
876 1.1.1.5 christos Status = AcpiDsExecEndOp (WalkState);
877 1.1.1.5 christos if (ACPI_FAILURE (Status))
878 1.1.1.5 christos {
879 1.1.1.5 christos DbgPrint (ASL_PARSE_OUTPUT,
880 1.1.1.5 christos "%s: Constant interpretation failed (2) - %s\n",
881 1.1.1.5 christos Op->Asl.ParseOpName, AcpiFormatException (Status));
882 1.1.1.5 christos }
883 1.1.1.5 christos
884 1.1.1.5 christos return (Status);
885 1.1.1.5 christos }
886