dsutils.c revision 77424
1/*******************************************************************************
2 *
3 * Module Name: dsutils - Dispatcher utilities
4 *              $Revision: 58 $
5 *
6 ******************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
13 * All rights reserved.
14 *
15 * 2. License
16 *
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights.  You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
20 * property rights.
21 *
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
28 *
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code.  No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
37 *
38 * The above copyright and patent license is granted only if the following
39 * conditions are met:
40 *
41 * 3. Conditions
42 *
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision.  In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change.  Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee.  Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
54 *
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution.  In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
65 * make.
66 *
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3.4. Intel retains all right, title, and interest in and to the Original
74 * Intel Code.
75 *
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
80 *
81 * 4. Disclaimer and Export Compliance
82 *
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89 * PARTICULAR PURPOSE.
90 *
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98 * LIMITED REMEDY.
99 *
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government.  In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
114 *
115 *****************************************************************************/
116
117#define __DSUTILS_C__
118
119#include "acpi.h"
120#include "acparser.h"
121#include "amlcode.h"
122#include "acdispat.h"
123#include "acinterp.h"
124#include "acnamesp.h"
125#include "acdebug.h"
126
127#define _COMPONENT          ACPI_DISPATCHER
128        MODULE_NAME         ("dsutils")
129
130
131/*******************************************************************************
132 *
133 * FUNCTION:    AcpiDsIsResultUsed
134 *
135 * PARAMETERS:  Op
136 *              ResultObj
137 *              WalkState
138 *
139 * RETURN:      Status
140 *
141 * DESCRIPTION: Check if a result object will be used by the parent
142 *
143 ******************************************************************************/
144
145BOOLEAN
146AcpiDsIsResultUsed (
147    ACPI_PARSE_OBJECT       *Op,
148    ACPI_WALK_STATE         *WalkState)
149{
150    ACPI_OPCODE_INFO        *ParentInfo;
151
152
153    FUNCTION_TRACE_PTR ("DsIsResultUsed", Op);
154
155
156    /* Must have both an Op and a Result Object */
157
158    if (!Op)
159    {
160        DEBUG_PRINTP (ACPI_ERROR, ("Null Op\n"));
161        return_VALUE (TRUE);
162    }
163
164
165    /*
166     * If there is no parent, the result can't possibly be used!
167     * (An executing method typically has no parent, since each
168     * method is parsed separately)  However, a method that is
169     * invoked from another method has a parent.
170     */
171    if (!Op->Parent)
172    {
173        return_VALUE (FALSE);
174    }
175
176
177    /*
178     * Get info on the parent.  The root Op is AML_SCOPE
179     */
180
181    ParentInfo = AcpiPsGetOpcodeInfo (Op->Parent->Opcode);
182    if (ACPI_GET_OP_TYPE (ParentInfo) != ACPI_OP_TYPE_OPCODE)
183    {
184        DEBUG_PRINTP (ACPI_ERROR, ("Unknown parent opcode. Op=%X\n", Op));
185        return_VALUE (FALSE);
186    }
187
188
189    /*
190     * Decide what to do with the result based on the parent.  If
191     * the parent opcode will not use the result, delete the object.
192     * Otherwise leave it as is, it will be deleted when it is used
193     * as an operand later.
194     */
195
196    switch (ACPI_GET_OP_CLASS (ParentInfo))
197    {
198    /*
199     * In these cases, the parent will never use the return object
200     */
201    case OPTYPE_CONTROL:        /* IF, ELSE, WHILE only */
202
203        switch (Op->Parent->Opcode)
204        {
205        case AML_RETURN_OP:
206
207            /* Never delete the return value associated with a return opcode */
208
209            DEBUG_PRINTP (TRACE_DISPATCH,
210                ("Result used, [RETURN] opcode=%X Op=%X\n", Op->Opcode, Op));
211            return_VALUE (TRUE);
212            break;
213
214        case AML_IF_OP:
215        case AML_WHILE_OP:
216
217            /*
218             * If we are executing the predicate AND this is the predicate op,
219             * we will use the return value!
220             */
221
222            if ((WalkState->ControlState->Common.State == CONTROL_PREDICATE_EXECUTING) &&
223                (WalkState->ControlState->Control.PredicateOp == Op))
224            {
225                DEBUG_PRINTP (TRACE_DISPATCH,
226                    ("Result used as a predicate, [IF/WHILE] opcode=%X Op=%X\n",
227                    Op->Opcode, Op));
228                return_VALUE (TRUE);
229            }
230
231            break;
232        }
233
234
235        /* Fall through to not used case below */
236
237
238    case OPTYPE_NAMED_OBJECT:   /* Scope, method, etc. */
239
240        /*
241         * These opcodes allow TermArg(s) as operands and therefore
242         * method calls.  The result is used.
243         */
244        if ((Op->Parent->Opcode == AML_REGION_OP)               ||
245            (Op->Parent->Opcode == AML_CREATE_FIELD_OP)         ||
246            (Op->Parent->Opcode == AML_CREATE_BIT_FIELD_OP)     ||
247            (Op->Parent->Opcode == AML_CREATE_BYTE_FIELD_OP)    ||
248            (Op->Parent->Opcode == AML_CREATE_WORD_FIELD_OP)    ||
249            (Op->Parent->Opcode == AML_CREATE_DWORD_FIELD_OP)   ||
250            (Op->Parent->Opcode == AML_CREATE_QWORD_FIELD_OP))
251        {
252            DEBUG_PRINTP (TRACE_DISPATCH,
253                ("Result used, [Region or CreateField] opcode=%X Op=%X\n",
254                Op->Opcode, Op));
255            return_VALUE (TRUE);
256        }
257
258        DEBUG_PRINTP (TRACE_DISPATCH,
259            ("Result not used, Parent opcode=%X Op=%X\n", Op->Opcode, Op));
260
261        return_VALUE (FALSE);
262        break;
263
264    /*
265     * In all other cases. the parent will actually use the return
266     * object, so keep it.
267     */
268    default:
269        break;
270    }
271
272    return_VALUE (TRUE);
273}
274
275
276/*******************************************************************************
277 *
278 * FUNCTION:    AcpiDsDeleteResultIfNotUsed
279 *
280 * PARAMETERS:  Op
281 *              ResultObj
282 *              WalkState
283 *
284 * RETURN:      Status
285 *
286 * DESCRIPTION: Used after interpretation of an opcode.  If there is an internal
287 *              result descriptor, check if the parent opcode will actually use
288 *              this result.  If not, delete the result now so that it will
289 *              not become orphaned.
290 *
291 ******************************************************************************/
292
293void
294AcpiDsDeleteResultIfNotUsed (
295    ACPI_PARSE_OBJECT       *Op,
296    ACPI_OPERAND_OBJECT     *ResultObj,
297    ACPI_WALK_STATE         *WalkState)
298{
299    ACPI_OPERAND_OBJECT     *ObjDesc;
300    ACPI_STATUS             Status;
301
302
303    FUNCTION_TRACE_PTR ("DsDeleteResultIfNotUsed", ResultObj);
304
305
306    if (!Op)
307    {
308        DEBUG_PRINTP (ACPI_ERROR, ("Null Op\n"));
309        return_VOID;
310    }
311
312    if (!ResultObj)
313    {
314        return_VOID;
315    }
316
317
318    if (!AcpiDsIsResultUsed (Op, WalkState))
319    {
320        /*
321         * Must pop the result stack (ObjDesc should be equal
322         *  to ResultObj)
323         */
324
325        Status = AcpiDsResultPop (&ObjDesc, WalkState);
326        if (ACPI_SUCCESS (Status))
327        {
328            AcpiUtRemoveReference (ResultObj);
329        }
330    }
331
332    return_VOID;
333}
334
335
336/*******************************************************************************
337 *
338 * FUNCTION:    AcpiDsCreateOperand
339 *
340 * PARAMETERS:  WalkState
341 *              Arg
342 *
343 * RETURN:      Status
344 *
345 * DESCRIPTION: Translate a parse tree object that is an argument to an AML
346 *              opcode to the equivalent interpreter object.  This may include
347 *              looking up a name or entering a new name into the internal
348 *              namespace.
349 *
350 ******************************************************************************/
351
352ACPI_STATUS
353AcpiDsCreateOperand (
354    ACPI_WALK_STATE         *WalkState,
355    ACPI_PARSE_OBJECT       *Arg,
356    UINT32                  ArgIndex)
357{
358    ACPI_STATUS             Status = AE_OK;
359    NATIVE_CHAR             *NameString;
360    UINT32                  NameLength;
361    ACPI_OBJECT_TYPE8       DataType;
362    ACPI_OPERAND_OBJECT     *ObjDesc;
363    ACPI_PARSE_OBJECT       *ParentOp;
364    UINT16                  Opcode;
365    UINT32                  Flags;
366    OPERATING_MODE          InterpreterMode;
367
368
369    FUNCTION_TRACE_PTR ("DsCreateOperand", Arg);
370
371
372    /* A valid name must be looked up in the namespace */
373
374    if ((Arg->Opcode == AML_INT_NAMEPATH_OP) &&
375        (Arg->Value.String))
376    {
377        DEBUG_PRINTP (TRACE_DISPATCH, ("Getting a name: Arg=%p\n", Arg));
378
379        /* Get the entire name string from the AML stream */
380
381        Status = AcpiExGetNameString (ACPI_TYPE_ANY, Arg->Value.Buffer,
382                        &NameString, &NameLength);
383
384        if (ACPI_FAILURE (Status))
385        {
386            return_ACPI_STATUS (Status);
387        }
388
389        /*
390         * All prefixes have been handled, and the name is
391         * in NameString
392         */
393
394        /*
395         * Differentiate between a namespace "create" operation
396         * versus a "lookup" operation (IMODE_LOAD_PASS2 vs.
397         * IMODE_EXECUTE) in order to support the creation of
398         * namespace objects during the execution of control methods.
399         */
400
401        ParentOp = Arg->Parent;
402        if ((AcpiPsIsNodeOp (ParentOp->Opcode)) &&
403            (ParentOp->Opcode != AML_INT_METHODCALL_OP) &&
404            (ParentOp->Opcode != AML_REGION_OP) &&
405            (ParentOp->Opcode != AML_INT_NAMEPATH_OP))
406        {
407            /* Enter name into namespace if not found */
408
409            InterpreterMode = IMODE_LOAD_PASS2;
410        }
411
412        else
413        {
414            /* Return a failure if name not found */
415
416            InterpreterMode = IMODE_EXECUTE;
417        }
418
419        Status = AcpiNsLookup (WalkState->ScopeInfo, NameString,
420                                ACPI_TYPE_ANY, InterpreterMode,
421                                NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE,
422                                WalkState,
423                                (ACPI_NAMESPACE_NODE **) &ObjDesc);
424
425        /* Free the namestring created above */
426
427        AcpiUtFree (NameString);
428
429        /*
430         * The only case where we pass through (ignore) a NOT_FOUND
431         * error is for the CondRefOf opcode.
432         */
433
434        if (Status == AE_NOT_FOUND)
435        {
436            if (ParentOp->Opcode == AML_COND_REF_OF_OP)
437            {
438                /*
439                 * For the Conditional Reference op, it's OK if
440                 * the name is not found;  We just need a way to
441                 * indicate this to the interpreter, set the
442                 * object to the root
443                 */
444                ObjDesc = (ACPI_OPERAND_OBJECT  *) AcpiGbl_RootNode;
445                Status = AE_OK;
446            }
447
448            else
449            {
450                /*
451                 * We just plain didn't find it -- which is a
452                 * very serious error at this point
453                 */
454                Status = AE_AML_NAME_NOT_FOUND;
455            }
456        }
457
458        /* Check status from the lookup */
459
460        if (ACPI_FAILURE (Status))
461        {
462            return_ACPI_STATUS (Status);
463        }
464
465        /* Put the resulting object onto the current object stack */
466
467        Status = AcpiDsObjStackPush (ObjDesc, WalkState);
468        if (ACPI_FAILURE (Status))
469        {
470            return_ACPI_STATUS (Status);
471        }
472        DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (ObjDesc, WalkState));
473    }
474
475
476    else
477    {
478        /* Check for null name case */
479
480        if (Arg->Opcode == AML_INT_NAMEPATH_OP)
481        {
482            /*
483             * If the name is null, this means that this is an
484             * optional result parameter that was not specified
485             * in the original ASL.  Create an Reference for a
486             * placeholder
487             */
488            Opcode = AML_ZERO_OP;       /* Has no arguments! */
489
490            DEBUG_PRINTP (TRACE_DISPATCH, ("Null namepath: Arg=%p\n", Arg));
491
492            /*
493             * TBD: [Investigate] anything else needed for the
494             * zero op lvalue?
495             */
496        }
497
498        else
499        {
500            Opcode = Arg->Opcode;
501        }
502
503
504        /* Get the data type of the argument */
505
506        DataType = AcpiDsMapOpcodeToDataType (Opcode, &Flags);
507        if (DataType == INTERNAL_TYPE_INVALID)
508        {
509            return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
510        }
511
512        if (Flags & OP_HAS_RETURN_VALUE)
513        {
514            DEBUG_PRINTP (TRACE_DISPATCH,
515                ("Argument previously created, already stacked \n"));
516
517            DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (WalkState->Operands [WalkState->NumOperands - 1], WalkState));
518
519            /*
520             * Use value that was already previously returned
521             * by the evaluation of this argument
522             */
523            Status = AcpiDsResultPopFromBottom (&ObjDesc, WalkState);
524            if (ACPI_FAILURE (Status))
525            {
526                /*
527                 * Only error is underflow, and this indicates
528                 * a missing or null operand!
529                 */
530                DEBUG_PRINTP (ACPI_ERROR, ("Missing or null operand, %s\n",
531                    AcpiUtFormatException (Status)));
532                return_ACPI_STATUS (Status);
533            }
534
535        }
536
537        else
538        {
539            /* Create an ACPI_INTERNAL_OBJECT for the argument */
540
541            ObjDesc = AcpiUtCreateInternalObject (DataType);
542            if (!ObjDesc)
543            {
544                return_ACPI_STATUS (AE_NO_MEMORY);
545            }
546
547            /* Initialize the new object */
548
549            Status = AcpiDsInitObjectFromOp (WalkState, Arg,
550                                                Opcode, &ObjDesc);
551            if (ACPI_FAILURE (Status))
552            {
553                AcpiUtDeleteObjectDesc (ObjDesc);
554                return_ACPI_STATUS (Status);
555            }
556       }
557
558        /* Put the operand object on the object stack */
559
560        Status = AcpiDsObjStackPush (ObjDesc, WalkState);
561        if (ACPI_FAILURE (Status))
562        {
563            return_ACPI_STATUS (Status);
564        }
565
566        DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (ObjDesc, WalkState));
567    }
568
569    return_ACPI_STATUS (AE_OK);
570}
571
572
573/*******************************************************************************
574 *
575 * FUNCTION:    AcpiDsCreateOperands
576 *
577 * PARAMETERS:  FirstArg            - First argument of a parser argument tree
578 *
579 * RETURN:      Status
580 *
581 * DESCRIPTION: Convert an operator's arguments from a parse tree format to
582 *              namespace objects and place those argument object on the object
583 *              stack in preparation for evaluation by the interpreter.
584 *
585 ******************************************************************************/
586
587ACPI_STATUS
588AcpiDsCreateOperands (
589    ACPI_WALK_STATE         *WalkState,
590    ACPI_PARSE_OBJECT       *FirstArg)
591{
592    ACPI_STATUS             Status = AE_OK;
593    ACPI_PARSE_OBJECT       *Arg;
594    UINT32                  ArgCount = 0;
595
596
597    FUNCTION_TRACE_PTR ("DsCreateOperands", FirstArg);
598
599    /* For all arguments in the list... */
600
601    Arg = FirstArg;
602    while (Arg)
603    {
604        Status = AcpiDsCreateOperand (WalkState, Arg, ArgCount);
605        if (ACPI_FAILURE (Status))
606        {
607            goto Cleanup;
608        }
609
610        DEBUG_PRINTP (TRACE_DISPATCH, ("Arg #%d (%p) done, Arg1=%p\n",
611            ArgCount, Arg, FirstArg));
612
613        /* Move on to next argument, if any */
614
615        Arg = Arg->Next;
616        ArgCount++;
617    }
618
619    return_ACPI_STATUS (Status);
620
621
622Cleanup:
623    /*
624     * We must undo everything done above; meaning that we must
625     * pop everything off of the operand stack and delete those
626     * objects
627     */
628
629    AcpiDsObjStackPopAndDelete (ArgCount, WalkState);
630
631    DEBUG_PRINTP (ACPI_ERROR, ("While creating Arg %d - %s\n",
632        (ArgCount + 1), AcpiUtFormatException (Status)));
633    return_ACPI_STATUS (Status);
634}
635
636
637/*******************************************************************************
638 *
639 * FUNCTION:    AcpiDsResolveOperands
640 *
641 * PARAMETERS:  WalkState           - Current walk state with operands on stack
642 *
643 * RETURN:      Status
644 *
645 * DESCRIPTION: Resolve all operands to their values.  Used to prepare
646 *              arguments to a control method invocation (a call from one
647 *              method to another.)
648 *
649 ******************************************************************************/
650
651ACPI_STATUS
652AcpiDsResolveOperands (
653    ACPI_WALK_STATE         *WalkState)
654{
655    UINT32                  i;
656    ACPI_STATUS             Status = AE_OK;
657
658
659    FUNCTION_TRACE_PTR ("DsResolveOperands", WalkState);
660
661
662    /*
663     * Attempt to resolve each of the valid operands
664     * Method arguments are passed by value, not by reference
665     */
666
667    /*
668     * TBD: [Investigate] Note from previous parser:
669     *   RefOf problem with AcpiExResolveToValue() conversion.
670     */
671
672    for (i = 0; i < WalkState->NumOperands; i++)
673    {
674        Status = AcpiExResolveToValue (&WalkState->Operands[i], WalkState);
675        if (ACPI_FAILURE (Status))
676        {
677            break;
678        }
679    }
680
681    return_ACPI_STATUS (Status);
682}
683
684
685/*******************************************************************************
686 *
687 * FUNCTION:    AcpiDsMapOpcodeToDataType
688 *
689 * PARAMETERS:  Opcode          - AML opcode to map
690 *              OutFlags        - Additional info about the opcode
691 *
692 * RETURN:      The ACPI type associated with the opcode
693 *
694 * DESCRIPTION: Convert a raw AML opcode to the associated ACPI data type,
695 *              if any.  If the opcode returns a value as part of the
696 *              intepreter execution, a flag is returned in OutFlags.
697 *
698 ******************************************************************************/
699
700ACPI_OBJECT_TYPE8
701AcpiDsMapOpcodeToDataType (
702    UINT16                  Opcode,
703    UINT32                  *OutFlags)
704{
705    ACPI_OBJECT_TYPE8       DataType = INTERNAL_TYPE_INVALID;
706    ACPI_OPCODE_INFO        *OpInfo;
707    UINT32                  Flags = 0;
708
709
710    PROC_NAME ("DsMapOpcodeToDataType");
711
712
713    OpInfo = AcpiPsGetOpcodeInfo (Opcode);
714    if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE)
715    {
716        /* Unknown opcode */
717
718        DEBUG_PRINTP (ACPI_ERROR, ("Unknown AML opcode: %x\n", Opcode));
719        return (DataType);
720    }
721
722    switch (ACPI_GET_OP_CLASS (OpInfo))
723    {
724
725    case OPTYPE_LITERAL:
726
727        switch (Opcode)
728        {
729        case AML_BYTE_OP:
730        case AML_WORD_OP:
731        case AML_DWORD_OP:
732
733            DataType = ACPI_TYPE_INTEGER;
734            break;
735
736
737        case AML_STRING_OP:
738
739            DataType = ACPI_TYPE_STRING;
740            break;
741
742        case AML_INT_NAMEPATH_OP:
743            DataType = INTERNAL_TYPE_REFERENCE;
744            break;
745
746        default:
747            DEBUG_PRINTP (ACPI_ERROR,
748                ("Unknown (type LITERAL) AML opcode: %x\n", Opcode));
749            break;
750        }
751        break;
752
753
754    case OPTYPE_DATA_TERM:
755
756        switch (Opcode)
757        {
758        case AML_BUFFER_OP:
759
760            DataType = ACPI_TYPE_BUFFER;
761            break;
762
763        case AML_PACKAGE_OP:
764
765            DataType = ACPI_TYPE_PACKAGE;
766            break;
767
768        default:
769            DEBUG_PRINTP (ACPI_ERROR,
770                ("Unknown (type DATA_TERM) AML opcode: %x\n", Opcode));
771            break;
772        }
773        break;
774
775
776    case OPTYPE_CONSTANT:
777    case OPTYPE_METHOD_ARGUMENT:
778    case OPTYPE_LOCAL_VARIABLE:
779
780        DataType = INTERNAL_TYPE_REFERENCE;
781        break;
782
783
784    case OPTYPE_MONADIC2:
785    case OPTYPE_MONADIC2R:
786    case OPTYPE_DYADIC2:
787    case OPTYPE_DYADIC2R:
788    case OPTYPE_DYADIC2S:
789    case OPTYPE_INDEX:
790    case OPTYPE_MATCH:
791    case OPTYPE_RETURN:
792
793        Flags = OP_HAS_RETURN_VALUE;
794        DataType = ACPI_TYPE_ANY;
795        break;
796
797    case OPTYPE_METHOD_CALL:
798
799        Flags = OP_HAS_RETURN_VALUE;
800        DataType = ACPI_TYPE_METHOD;
801        break;
802
803
804    case OPTYPE_NAMED_OBJECT:
805
806        DataType = AcpiDsMapNamedOpcodeToDataType (Opcode);
807        break;
808
809
810    case OPTYPE_DYADIC1:
811    case OPTYPE_CONTROL:
812
813        /* No mapping needed at this time */
814
815        break;
816
817
818    default:
819
820        DEBUG_PRINTP (ACPI_ERROR,
821            ("Unimplemented data type opcode: %x\n", Opcode));
822        break;
823    }
824
825    /* Return flags to caller if requested */
826
827    if (OutFlags)
828    {
829        *OutFlags = Flags;
830    }
831
832    return (DataType);
833}
834
835
836/*******************************************************************************
837 *
838 * FUNCTION:    AcpiDsMapNamedOpcodeToDataType
839 *
840 * PARAMETERS:  Opcode              - The Named AML opcode to map
841 *
842 * RETURN:      The ACPI type associated with the named opcode
843 *
844 * DESCRIPTION: Convert a raw Named AML opcode to the associated data type.
845 *              Named opcodes are a subsystem of the AML opcodes.
846 *
847 ******************************************************************************/
848
849ACPI_OBJECT_TYPE8
850AcpiDsMapNamedOpcodeToDataType (
851    UINT16                  Opcode)
852{
853    ACPI_OBJECT_TYPE8       DataType;
854
855
856    /* Decode Opcode */
857
858    switch (Opcode)
859    {
860    case AML_SCOPE_OP:
861        DataType = INTERNAL_TYPE_SCOPE;
862        break;
863
864    case AML_DEVICE_OP:
865        DataType = ACPI_TYPE_DEVICE;
866        break;
867
868    case AML_THERMAL_ZONE_OP:
869        DataType = ACPI_TYPE_THERMAL;
870        break;
871
872    case AML_METHOD_OP:
873        DataType = ACPI_TYPE_METHOD;
874        break;
875
876    case AML_POWER_RES_OP:
877        DataType = ACPI_TYPE_POWER;
878        break;
879
880    case AML_PROCESSOR_OP:
881        DataType = ACPI_TYPE_PROCESSOR;
882        break;
883
884    case AML_FIELD_OP:                              /* FieldOp */
885        DataType = INTERNAL_TYPE_FIELD_DEFN;
886        break;
887
888    case AML_INDEX_FIELD_OP:                        /* IndexFieldOp */
889        DataType = INTERNAL_TYPE_INDEX_FIELD_DEFN;
890        break;
891
892    case AML_BANK_FIELD_OP:                         /* BankFieldOp */
893        DataType = INTERNAL_TYPE_BANK_FIELD_DEFN;
894        break;
895
896    case AML_INT_NAMEDFIELD_OP:                     /* NO CASE IN ORIGINAL  */
897        DataType = ACPI_TYPE_ANY;
898        break;
899
900    case AML_NAME_OP:                               /* NameOp - special code in original */
901    case AML_INT_NAMEPATH_OP:
902        DataType = ACPI_TYPE_ANY;
903        break;
904
905    case AML_ALIAS_OP:
906        DataType = INTERNAL_TYPE_ALIAS;
907        break;
908
909    case AML_MUTEX_OP:
910        DataType = ACPI_TYPE_MUTEX;
911        break;
912
913    case AML_EVENT_OP:
914        DataType = ACPI_TYPE_EVENT;
915        break;
916
917    case AML_REGION_OP:
918        DataType = ACPI_TYPE_REGION;
919        break;
920
921
922    default:
923        DataType = ACPI_TYPE_ANY;
924        break;
925
926    }
927
928    return (DataType);
929}
930
931
932