aslfold.c revision 240716
1118611Snjl
2118611Snjl/******************************************************************************
3118611Snjl *
4118611Snjl * Module Name: aslfold - Constant folding
5118611Snjl *
6118611Snjl *****************************************************************************/
7118611Snjl
8217365Sjkim/*
9229989Sjkim * Copyright (C) 2000 - 2012, Intel Corp.
10118611Snjl * All rights reserved.
11118611Snjl *
12217365Sjkim * Redistribution and use in source and binary forms, with or without
13217365Sjkim * modification, are permitted provided that the following conditions
14217365Sjkim * are met:
15217365Sjkim * 1. Redistributions of source code must retain the above copyright
16217365Sjkim *    notice, this list of conditions, and the following disclaimer,
17217365Sjkim *    without modification.
18217365Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19217365Sjkim *    substantially similar to the "NO WARRANTY" disclaimer below
20217365Sjkim *    ("Disclaimer") and any redistribution must be conditioned upon
21217365Sjkim *    including a substantially similar Disclaimer requirement for further
22217365Sjkim *    binary redistribution.
23217365Sjkim * 3. Neither the names of the above-listed copyright holders nor the names
24217365Sjkim *    of any contributors may be used to endorse or promote products derived
25217365Sjkim *    from this software without specific prior written permission.
26118611Snjl *
27217365Sjkim * Alternatively, this software may be distributed under the terms of the
28217365Sjkim * GNU General Public License ("GPL") version 2 as published by the Free
29217365Sjkim * Software Foundation.
30118611Snjl *
31217365Sjkim * NO WARRANTY
32217365Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33217365Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34217365Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35217365Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36217365Sjkim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37217365Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38217365Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39217365Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40217365Sjkim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41217365Sjkim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42217365Sjkim * POSSIBILITY OF SUCH DAMAGES.
43217365Sjkim */
44118611Snjl
45118611Snjl
46151937Sjkim#include <contrib/dev/acpica/compiler/aslcompiler.h>
47118611Snjl#include "aslcompiler.y.h"
48193529Sjkim#include <contrib/dev/acpica/include/amlcode.h>
49118611Snjl
50193529Sjkim#include <contrib/dev/acpica/include/acdispat.h>
51193529Sjkim#include <contrib/dev/acpica/include/acparser.h>
52118611Snjl
53118611Snjl#define _COMPONENT          ACPI_COMPILER
54118611Snjl        ACPI_MODULE_NAME    ("aslfold")
55118611Snjl
56151937Sjkim/* Local prototypes */
57118611Snjl
58151937Sjkimstatic ACPI_STATUS
59151937SjkimOpcAmlEvaluationWalk1 (
60151937Sjkim    ACPI_PARSE_OBJECT       *Op,
61151937Sjkim    UINT32                  Level,
62151937Sjkim    void                    *Context);
63151937Sjkim
64151937Sjkimstatic ACPI_STATUS
65151937SjkimOpcAmlEvaluationWalk2 (
66151937Sjkim    ACPI_PARSE_OBJECT       *Op,
67151937Sjkim    UINT32                  Level,
68151937Sjkim    void                    *Context);
69151937Sjkim
70151937Sjkimstatic ACPI_STATUS
71151937SjkimOpcAmlCheckForConstant (
72151937Sjkim    ACPI_PARSE_OBJECT       *Op,
73151937Sjkim    UINT32                  Level,
74151937Sjkim    void                    *Context);
75151937Sjkim
76239340Sjkimstatic void
77239340SjkimOpcUpdateIntegerNode (
78239340Sjkim    ACPI_PARSE_OBJECT       *Op,
79239340Sjkim    UINT64                  Value);
80151937Sjkim
81239340Sjkim
82118611Snjl/*******************************************************************************
83118611Snjl *
84118611Snjl * FUNCTION:    OpcAmlEvaluationWalk1
85118611Snjl *
86118611Snjl * PARAMETERS:  ASL_WALK_CALLBACK
87118611Snjl *
88118611Snjl * RETURN:      Status
89118611Snjl *
90118611Snjl * DESCRIPTION: Descending callback for AML execution of constant subtrees
91118611Snjl *
92118611Snjl ******************************************************************************/
93118611Snjl
94151937Sjkimstatic ACPI_STATUS
95118611SnjlOpcAmlEvaluationWalk1 (
96118611Snjl    ACPI_PARSE_OBJECT       *Op,
97118611Snjl    UINT32                  Level,
98118611Snjl    void                    *Context)
99118611Snjl{
100118611Snjl    ACPI_WALK_STATE         *WalkState = Context;
101118611Snjl    ACPI_STATUS             Status;
102118611Snjl    ACPI_PARSE_OBJECT       *OutOp;
103118611Snjl
104118611Snjl
105118611Snjl    WalkState->Op = Op;
106118611Snjl    WalkState->Opcode = Op->Common.AmlOpcode;
107118611Snjl    WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
108118611Snjl
109118611Snjl    /* Copy child pointer to Arg for compatibility with Interpreter */
110118611Snjl
111118611Snjl    if (Op->Asl.Child)
112118611Snjl    {
113118611Snjl        Op->Common.Value.Arg = Op->Asl.Child;
114118611Snjl    }
115118611Snjl
116118611Snjl    /* Call AML dispatcher */
117118611Snjl
118118611Snjl    Status = AcpiDsExecBeginOp (WalkState, &OutOp);
119118611Snjl    if (ACPI_FAILURE (Status))
120118611Snjl    {
121118611Snjl        AcpiOsPrintf ("Constant interpretation failed - %s\n",
122118611Snjl                        AcpiFormatException (Status));
123118611Snjl    }
124118611Snjl
125118611Snjl    return (Status);
126118611Snjl}
127118611Snjl
128118611Snjl
129118611Snjl/*******************************************************************************
130118611Snjl *
131118611Snjl * FUNCTION:    OpcAmlEvaluationWalk2
132118611Snjl *
133118611Snjl * PARAMETERS:  ASL_WALK_CALLBACK
134118611Snjl *
135118611Snjl * RETURN:      Status
136118611Snjl *
137118611Snjl * DESCRIPTION: Ascending callback for AML execution of constant subtrees
138118611Snjl *
139118611Snjl ******************************************************************************/
140118611Snjl
141151937Sjkimstatic ACPI_STATUS
142118611SnjlOpcAmlEvaluationWalk2 (
143118611Snjl    ACPI_PARSE_OBJECT       *Op,
144118611Snjl    UINT32                  Level,
145118611Snjl    void                    *Context)
146118611Snjl{
147118611Snjl    ACPI_WALK_STATE         *WalkState = Context;
148118611Snjl    ACPI_STATUS             Status;
149118611Snjl
150118611Snjl
151118611Snjl    WalkState->Op = Op;
152118611Snjl    WalkState->Opcode = Op->Common.AmlOpcode;
153118611Snjl    WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
154118611Snjl
155118611Snjl    /* Copy child pointer to Arg for compatibility with Interpreter */
156118611Snjl
157118611Snjl    if (Op->Asl.Child)
158118611Snjl    {
159118611Snjl        Op->Common.Value.Arg = Op->Asl.Child;
160118611Snjl    }
161118611Snjl
162118611Snjl    /* Call AML dispatcher */
163118611Snjl
164118611Snjl    Status = AcpiDsExecEndOp (WalkState);
165118611Snjl    if (ACPI_FAILURE (Status))
166118611Snjl    {
167118611Snjl        AcpiOsPrintf ("Constant interpretation failed - %s\n",
168118611Snjl                        AcpiFormatException (Status));
169118611Snjl    }
170118611Snjl
171118611Snjl    return (Status);
172118611Snjl}
173118611Snjl
174118611Snjl
175118611Snjl/*******************************************************************************
176118611Snjl *
177118611Snjl * FUNCTION:    OpcAmlCheckForConstant
178118611Snjl *
179118611Snjl * PARAMETERS:  ASL_WALK_CALLBACK
180118611Snjl *
181118611Snjl * RETURN:      Status
182118611Snjl *
183118611Snjl * DESCRIPTION: Check one Op for a type 3/4/5 AML opcode
184118611Snjl *
185118611Snjl ******************************************************************************/
186118611Snjl
187151937Sjkimstatic ACPI_STATUS
188118611SnjlOpcAmlCheckForConstant (
189118611Snjl    ACPI_PARSE_OBJECT       *Op,
190118611Snjl    UINT32                  Level,
191118611Snjl    void                    *Context)
192118611Snjl{
193118611Snjl    ACPI_WALK_STATE         *WalkState = Context;
194118611Snjl
195118611Snjl
196118611Snjl    WalkState->Op = Op;
197118611Snjl    WalkState->Opcode = Op->Common.AmlOpcode;
198118611Snjl    WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
199118611Snjl
200118611Snjl    DbgPrint (ASL_PARSE_OUTPUT, "[%.4d] Opcode: %12.12s ",
201118611Snjl                Op->Asl.LogicalLineNumber, Op->Asl.ParseOpName);
202118611Snjl
203240716Sjkim    /*
204240716Sjkim     * These opcodes do not appear in the OpcodeInfo table, but
205240716Sjkim     * they represent constants, so abort the constant walk now.
206240716Sjkim     */
207240716Sjkim    if ((WalkState->Opcode == AML_RAW_DATA_BYTE) ||
208240716Sjkim        (WalkState->Opcode == AML_RAW_DATA_WORD) ||
209240716Sjkim        (WalkState->Opcode == AML_RAW_DATA_DWORD) ||
210240716Sjkim        (WalkState->Opcode == AML_RAW_DATA_QWORD))
211240716Sjkim    {
212240716Sjkim        WalkState->WalkType = ACPI_WALK_CONST_OPTIONAL;
213240716Sjkim        return (AE_TYPE);
214240716Sjkim    }
215240716Sjkim
216118611Snjl    if (!(WalkState->OpInfo->Flags & AML_CONSTANT))
217118611Snjl    {
218118611Snjl        /* The opcode is not a Type 3/4/5 opcode */
219118611Snjl
220118611Snjl        if (Op->Asl.CompileFlags & NODE_IS_TARGET)
221118611Snjl        {
222151937Sjkim            DbgPrint (ASL_PARSE_OUTPUT,
223151937Sjkim                "**** Valid Target, cannot reduce ****\n");
224118611Snjl        }
225118611Snjl        else
226118611Snjl        {
227151937Sjkim            DbgPrint (ASL_PARSE_OUTPUT,
228151937Sjkim                "**** Not a Type 3/4/5 opcode ****\n");
229118611Snjl        }
230118611Snjl
231118611Snjl        if (WalkState->WalkType == ACPI_WALK_CONST_OPTIONAL)
232118611Snjl        {
233118611Snjl            /*
234118611Snjl             * We are looking at at normal expression to see if it can be
235239340Sjkim             * reduced. It can't. No error
236118611Snjl             */
237118611Snjl            return (AE_TYPE);
238118611Snjl        }
239118611Snjl
240118611Snjl        /*
241118611Snjl         * This is an expression that MUST reduce to a constant, and it
242239340Sjkim         * can't be reduced. This is an error
243118611Snjl         */
244118611Snjl        if (Op->Asl.CompileFlags & NODE_IS_TARGET)
245118611Snjl        {
246151937Sjkim            AslError (ASL_ERROR, ASL_MSG_INVALID_TARGET, Op,
247151937Sjkim                Op->Asl.ParseOpName);
248118611Snjl        }
249118611Snjl        else
250118611Snjl        {
251151937Sjkim            AslError (ASL_ERROR, ASL_MSG_INVALID_CONSTANT_OP, Op,
252151937Sjkim                Op->Asl.ParseOpName);
253118611Snjl        }
254118611Snjl
255118611Snjl        return (AE_TYPE);
256118611Snjl    }
257118611Snjl
258118611Snjl    /* Debug output */
259118611Snjl
260118611Snjl    DbgPrint (ASL_PARSE_OUTPUT, "TYPE_345");
261118611Snjl
262118611Snjl    if (Op->Asl.CompileFlags & NODE_IS_TARGET)
263118611Snjl    {
264118611Snjl        DbgPrint (ASL_PARSE_OUTPUT, " TARGET");
265118611Snjl    }
266118611Snjl    if (Op->Asl.CompileFlags & NODE_IS_TERM_ARG)
267118611Snjl    {
268118611Snjl        DbgPrint (ASL_PARSE_OUTPUT, " TERMARG");
269118611Snjl    }
270240716Sjkim
271118611Snjl    DbgPrint (ASL_PARSE_OUTPUT, "\n");
272118611Snjl    return (AE_OK);
273118611Snjl}
274118611Snjl
275118611Snjl
276118611Snjl/*******************************************************************************
277118611Snjl *
278118611Snjl * FUNCTION:    OpcAmlConstantWalk
279118611Snjl *
280118611Snjl * PARAMETERS:  ASL_WALK_CALLBACK
281118611Snjl *
282118611Snjl * RETURN:      Status
283118611Snjl *
284118611Snjl * DESCRIPTION: Reduce an Op and its subtree to a constant if possible
285118611Snjl *
286118611Snjl ******************************************************************************/
287118611Snjl
288118611SnjlACPI_STATUS
289118611SnjlOpcAmlConstantWalk (
290118611Snjl    ACPI_PARSE_OBJECT       *Op,
291118611Snjl    UINT32                  Level,
292118611Snjl    void                    *Context)
293118611Snjl{
294118611Snjl    ACPI_WALK_STATE         *WalkState;
295118611Snjl    ACPI_STATUS             Status = AE_OK;
296118611Snjl    ACPI_OPERAND_OBJECT     *ObjDesc;
297118611Snjl    ACPI_PARSE_OBJECT       *RootOp;
298118611Snjl    ACPI_PARSE_OBJECT       *OriginalParentOp;
299118611Snjl    UINT8                   WalkType;
300118611Snjl
301118611Snjl
302118611Snjl    /*
303118611Snjl     * Only interested in subtrees that could possibly contain
304118611Snjl     * expressions that can be evaluated at this time
305118611Snjl     */
306118611Snjl    if ((!(Op->Asl.CompileFlags & NODE_COMPILE_TIME_CONST)) ||
307118611Snjl          (Op->Asl.CompileFlags & NODE_IS_TARGET))
308118611Snjl    {
309118611Snjl        return (AE_OK);
310118611Snjl    }
311118611Snjl
312151937Sjkim    /* Set the walk type based on the reduction used for this op */
313151937Sjkim
314118611Snjl    if (Op->Asl.CompileFlags & NODE_IS_TERM_ARG)
315118611Snjl    {
316118611Snjl        /* Op is a TermArg, constant folding is merely optional */
317118611Snjl
318118611Snjl        if (!Gbl_FoldConstants)
319118611Snjl        {
320118611Snjl            return (AE_CTRL_DEPTH);
321118611Snjl        }
322118611Snjl
323118611Snjl        WalkType = ACPI_WALK_CONST_OPTIONAL;
324118611Snjl    }
325118611Snjl    else
326118611Snjl    {
327118611Snjl        /* Op is a DataObject, the expression MUST reduced to a constant */
328118611Snjl
329118611Snjl        WalkType = ACPI_WALK_CONST_REQUIRED;
330118611Snjl    }
331118611Snjl
332118611Snjl    /* Create a new walk state */
333118611Snjl
334118611Snjl    WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);
335118611Snjl    if (!WalkState)
336118611Snjl    {
337118611Snjl        return AE_NO_MEMORY;
338118611Snjl    }
339118611Snjl
340239340Sjkim    WalkState->NextOp = NULL;
341239340Sjkim    WalkState->Params = NULL;
342239340Sjkim    WalkState->WalkType = WalkType;
343239340Sjkim    WalkState->CallerReturnDesc = &ObjDesc;
344118611Snjl
345151937Sjkim    /*
346151937Sjkim     * Examine the entire subtree -- all nodes must be constants
347151937Sjkim     * or type 3/4/5 opcodes
348151937Sjkim     */
349118611Snjl    Status = TrWalkParseTree (Op, ASL_WALK_VISIT_DOWNWARD,
350239340Sjkim        OpcAmlCheckForConstant, NULL, WalkState);
351118611Snjl
352118611Snjl    /*
353118611Snjl     * Did we find an entire subtree that contains all constants and type 3/4/5
354118611Snjl     * opcodes?  (Only AE_OK or AE_TYPE returned from above)
355118611Snjl     */
356118611Snjl    if (Status == AE_TYPE)
357118611Snjl    {
358118611Snjl        /* Subtree cannot be reduced to a constant */
359118611Snjl
360118611Snjl        if (WalkState->WalkType == ACPI_WALK_CONST_OPTIONAL)
361118611Snjl        {
362118611Snjl            AcpiDsDeleteWalkState (WalkState);
363118611Snjl            return (AE_OK);
364118611Snjl        }
365118611Snjl
366118611Snjl        /* Don't descend any further, and use a default "constant" value */
367118611Snjl
368118611Snjl        Status = AE_CTRL_DEPTH;
369118611Snjl    }
370118611Snjl    else
371118611Snjl    {
372118611Snjl        /* Subtree can be reduced */
373118611Snjl
374118611Snjl        /* Allocate a new temporary root for this subtree */
375118611Snjl
376118611Snjl        RootOp = TrAllocateNode (PARSEOP_INTEGER);
377118611Snjl        if (!RootOp)
378118611Snjl        {
379118611Snjl            return (AE_NO_MEMORY);
380118611Snjl        }
381118611Snjl
382118611Snjl        RootOp->Common.AmlOpcode = AML_INT_EVAL_SUBTREE_OP;
383118611Snjl
384118611Snjl        OriginalParentOp = Op->Common.Parent;
385118611Snjl        Op->Common.Parent = RootOp;
386118611Snjl
387151937Sjkim        /* Hand off the subtree to the AML interpreter */
388151937Sjkim
389151937Sjkim        Status = TrWalkParseTree (Op, ASL_WALK_VISIT_TWICE,
390239340Sjkim            OpcAmlEvaluationWalk1, OpcAmlEvaluationWalk2, WalkState);
391118611Snjl        Op->Common.Parent = OriginalParentOp;
392118611Snjl
393118611Snjl        /* TBD: we really *should* release the RootOp node */
394118611Snjl
395118611Snjl        if (ACPI_SUCCESS (Status))
396118611Snjl        {
397118611Snjl            TotalFolds++;
398118611Snjl
399118611Snjl            /* Get the final result */
400118611Snjl
401118611Snjl            Status = AcpiDsResultPop (&ObjDesc, WalkState);
402118611Snjl        }
403239340Sjkim
404239340Sjkim        /* Check for error from the ACPICA core */
405239340Sjkim
406239340Sjkim        if (ACPI_FAILURE (Status))
407239340Sjkim        {
408239340Sjkim            AslCoreSubsystemError (Op, Status,
409239340Sjkim                "Failure during constant evaluation", FALSE);
410239340Sjkim        }
411118611Snjl    }
412118611Snjl
413118611Snjl    if (ACPI_FAILURE (Status))
414118611Snjl    {
415118611Snjl        /* We could not resolve the subtree for some reason */
416118611Snjl
417151937Sjkim        AslError (ASL_ERROR, ASL_MSG_CONSTANT_EVALUATION, Op,
418151937Sjkim            Op->Asl.ParseOpName);
419118611Snjl
420239340Sjkim        /* Set the subtree value to ZERO anyway. Eliminates further errors */
421118611Snjl
422239340Sjkim        OpcUpdateIntegerNode (Op, 0);
423118611Snjl    }
424118611Snjl    else
425118611Snjl    {
426151937Sjkim        AslError (ASL_OPTIMIZATION, ASL_MSG_CONSTANT_FOLDED, Op,
427151937Sjkim            Op->Asl.ParseOpName);
428118611Snjl
429118611Snjl        /*
430118611Snjl         * Because we know we executed type 3/4/5 opcodes above, we know that
431118611Snjl         * the result must be either an Integer, String, or Buffer.
432118611Snjl         */
433193529Sjkim        switch (ObjDesc->Common.Type)
434118611Snjl        {
435118611Snjl        case ACPI_TYPE_INTEGER:
436118611Snjl
437239340Sjkim            OpcUpdateIntegerNode (Op, ObjDesc->Integer.Value);
438118611Snjl
439151937Sjkim            DbgPrint (ASL_PARSE_OUTPUT,
440239340Sjkim                "Constant expression reduced to (%s) %8.8X%8.8X\n",
441239340Sjkim                Op->Asl.ParseOpName,
442239340Sjkim                ACPI_FORMAT_UINT64 (Op->Common.Value.Integer));
443118611Snjl            break;
444118611Snjl
445118611Snjl
446118611Snjl        case ACPI_TYPE_STRING:
447118611Snjl
448239340Sjkim            Op->Asl.ParseOpcode = PARSEOP_STRING_LITERAL;
449239340Sjkim            Op->Common.AmlOpcode = AML_STRING_OP;
450239340Sjkim            Op->Asl.AmlLength = ACPI_STRLEN (ObjDesc->String.Pointer) + 1;
451118611Snjl            Op->Common.Value.String = ObjDesc->String.Pointer;
452118611Snjl
453151937Sjkim            DbgPrint (ASL_PARSE_OUTPUT,
454151937Sjkim                "Constant expression reduced to (STRING) %s\n",
455118611Snjl                Op->Common.Value.String);
456118611Snjl
457118611Snjl            break;
458118611Snjl
459118611Snjl
460118611Snjl        case ACPI_TYPE_BUFFER:
461118611Snjl
462239340Sjkim            Op->Asl.ParseOpcode = PARSEOP_BUFFER;
463239340Sjkim            Op->Common.AmlOpcode = AML_BUFFER_OP;
464239340Sjkim            Op->Asl.CompileFlags = NODE_AML_PACKAGE;
465118611Snjl            UtSetParseOpName (Op);
466118611Snjl
467118611Snjl            /* Child node is the buffer length */
468118611Snjl
469118611Snjl            RootOp = TrAllocateNode (PARSEOP_INTEGER);
470118611Snjl
471239340Sjkim            RootOp->Asl.AmlOpcode = AML_DWORD_OP;
472118611Snjl            RootOp->Asl.Value.Integer = ObjDesc->Buffer.Length;
473239340Sjkim            RootOp->Asl.Parent = Op;
474118611Snjl
475118611Snjl            (void) OpcSetOptimalIntegerSize (RootOp);
476118611Snjl
477118611Snjl            Op->Asl.Child = RootOp;
478118611Snjl            Op = RootOp;
479118611Snjl            UtSetParseOpName (Op);
480118611Snjl
481118611Snjl            /* Peer to the child is the raw buffer data */
482118611Snjl
483118611Snjl            RootOp = TrAllocateNode (PARSEOP_RAW_DATA);
484239340Sjkim            RootOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER;
485239340Sjkim            RootOp->Asl.AmlLength = ObjDesc->Buffer.Length;
486239340Sjkim            RootOp->Asl.Value.String = (char *) ObjDesc->Buffer.Pointer;
487239340Sjkim            RootOp->Asl.Parent = Op->Asl.Parent;
488118611Snjl
489118611Snjl            Op->Asl.Next = RootOp;
490118611Snjl            Op = RootOp;
491118611Snjl
492151937Sjkim            DbgPrint (ASL_PARSE_OUTPUT,
493151937Sjkim                "Constant expression reduced to (BUFFER) length %X\n",
494118611Snjl                ObjDesc->Buffer.Length);
495118611Snjl            break;
496118611Snjl
497118611Snjl
498118611Snjl        default:
499118611Snjl            printf ("Unsupported return type: %s\n",
500239340Sjkim                AcpiUtGetObjectTypeName (ObjDesc));
501118611Snjl            break;
502118611Snjl        }
503118611Snjl    }
504118611Snjl
505118611Snjl    UtSetParseOpName (Op);
506118611Snjl    Op->Asl.Child = NULL;
507118611Snjl
508118611Snjl    AcpiDsDeleteWalkState (WalkState);
509118611Snjl    return (AE_CTRL_DEPTH);
510118611Snjl}
511118611Snjl
512239340Sjkim
513239340Sjkim/*******************************************************************************
514239340Sjkim *
515239340Sjkim * FUNCTION:    OpcUpdateIntegerNode
516239340Sjkim *
517239340Sjkim * PARAMETERS:  Op                  - Current parse object
518239340Sjkim *
519239340Sjkim * RETURN:      None
520239340Sjkim *
521239340Sjkim * DESCRIPTION: Update node to the correct integer type.
522239340Sjkim *
523239340Sjkim ******************************************************************************/
524239340Sjkim
525239340Sjkimstatic void
526239340SjkimOpcUpdateIntegerNode (
527239340Sjkim    ACPI_PARSE_OBJECT       *Op,
528239340Sjkim    UINT64                  Value)
529239340Sjkim{
530239340Sjkim
531239340Sjkim    Op->Common.Value.Integer = Value;
532239340Sjkim
533239340Sjkim    /*
534239340Sjkim     * The AmlLength is used by the parser to indicate a constant,
535239340Sjkim     * (if non-zero). Length is either (1/2/4/8)
536239340Sjkim     */
537239340Sjkim    switch (Op->Asl.AmlLength)
538239340Sjkim    {
539239340Sjkim    case 1:
540239340Sjkim        TrUpdateNode (PARSEOP_BYTECONST, Op);
541239340Sjkim        Op->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
542239340Sjkim        break;
543239340Sjkim
544239340Sjkim    case 2:
545239340Sjkim        TrUpdateNode (PARSEOP_WORDCONST, Op);
546239340Sjkim        Op->Asl.AmlOpcode = AML_RAW_DATA_WORD;
547239340Sjkim        break;
548239340Sjkim
549239340Sjkim    case 4:
550239340Sjkim        TrUpdateNode (PARSEOP_DWORDCONST, Op);
551239340Sjkim        Op->Asl.AmlOpcode = AML_RAW_DATA_DWORD;
552239340Sjkim        break;
553239340Sjkim
554239340Sjkim    case 8:
555239340Sjkim        TrUpdateNode (PARSEOP_QWORDCONST, Op);
556239340Sjkim        Op->Asl.AmlOpcode = AML_RAW_DATA_QWORD;
557239340Sjkim        break;
558239340Sjkim
559239340Sjkim    case 0:
560239340Sjkim    default:
561239340Sjkim        OpcSetOptimalIntegerSize (Op);
562239340Sjkim        TrUpdateNode (PARSEOP_INTEGER, Op);
563239340Sjkim        break;
564239340Sjkim    }
565239340Sjkim
566239340Sjkim    Op->Asl.AmlLength = 0;
567239340Sjkim}
568