exresop.c revision 123315
167754Smsmith
267754Smsmith/******************************************************************************
367754Smsmith *
477424Smsmith * Module Name: exresop - AML Interpreter operand/object resolution
5123315Snjl *              $Revision: 65 $
667754Smsmith *
767754Smsmith *****************************************************************************/
867754Smsmith
967754Smsmith/******************************************************************************
1067754Smsmith *
1167754Smsmith * 1. Copyright Notice
1267754Smsmith *
13114237Snjl * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp.
1470243Smsmith * All rights reserved.
1567754Smsmith *
1667754Smsmith * 2. License
1767754Smsmith *
1867754Smsmith * 2.1. This is your license from Intel Corp. under its intellectual property
1967754Smsmith * rights.  You may have additional license terms from the party that provided
2067754Smsmith * you this software, covering your right to use that party's intellectual
2167754Smsmith * property rights.
2267754Smsmith *
2367754Smsmith * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
2467754Smsmith * copy of the source code appearing in this file ("Covered Code") an
2567754Smsmith * irrevocable, perpetual, worldwide license under Intel's copyrights in the
2667754Smsmith * base code distributed originally by Intel ("Original Intel Code") to copy,
2767754Smsmith * make derivatives, distribute, use and display any portion of the Covered
2867754Smsmith * Code in any form, with the right to sublicense such rights; and
2967754Smsmith *
3067754Smsmith * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
3167754Smsmith * license (with the right to sublicense), under only those claims of Intel
3267754Smsmith * patents that are infringed by the Original Intel Code, to make, use, sell,
3367754Smsmith * offer to sell, and import the Covered Code and derivative works thereof
3467754Smsmith * solely to the minimum extent necessary to exercise the above copyright
3567754Smsmith * license, and in no event shall the patent license extend to any additions
3667754Smsmith * to or modifications of the Original Intel Code.  No other license or right
3767754Smsmith * is granted directly or by implication, estoppel or otherwise;
3867754Smsmith *
3967754Smsmith * The above copyright and patent license is granted only if the following
4067754Smsmith * conditions are met:
4167754Smsmith *
4267754Smsmith * 3. Conditions
4367754Smsmith *
4467754Smsmith * 3.1. Redistribution of Source with Rights to Further Distribute Source.
4567754Smsmith * Redistribution of source code of any substantial portion of the Covered
4667754Smsmith * Code or modification with rights to further distribute source must include
4767754Smsmith * the above Copyright Notice, the above License, this list of Conditions,
4867754Smsmith * and the following Disclaimer and Export Compliance provision.  In addition,
4967754Smsmith * Licensee must cause all Covered Code to which Licensee contributes to
5067754Smsmith * contain a file documenting the changes Licensee made to create that Covered
5167754Smsmith * Code and the date of any change.  Licensee must include in that file the
5267754Smsmith * documentation of any changes made by any predecessor Licensee.  Licensee
5367754Smsmith * must include a prominent statement that the modification is derived,
5467754Smsmith * directly or indirectly, from Original Intel Code.
5567754Smsmith *
5667754Smsmith * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
5767754Smsmith * Redistribution of source code of any substantial portion of the Covered
5867754Smsmith * Code or modification without rights to further distribute source must
5967754Smsmith * include the following Disclaimer and Export Compliance provision in the
6067754Smsmith * documentation and/or other materials provided with distribution.  In
6167754Smsmith * addition, Licensee may not authorize further sublicense of source of any
6267754Smsmith * portion of the Covered Code, and must include terms to the effect that the
6367754Smsmith * license from Licensee to its licensee is limited to the intellectual
6467754Smsmith * property embodied in the software Licensee provides to its licensee, and
6567754Smsmith * not to intellectual property embodied in modifications its licensee may
6667754Smsmith * make.
6767754Smsmith *
6867754Smsmith * 3.3. Redistribution of Executable. Redistribution in executable form of any
6967754Smsmith * substantial portion of the Covered Code or modification must reproduce the
7067754Smsmith * above Copyright Notice, and the following Disclaimer and Export Compliance
7167754Smsmith * provision in the documentation and/or other materials provided with the
7267754Smsmith * distribution.
7367754Smsmith *
7467754Smsmith * 3.4. Intel retains all right, title, and interest in and to the Original
7567754Smsmith * Intel Code.
7667754Smsmith *
7767754Smsmith * 3.5. Neither the name Intel nor any other trademark owned or controlled by
7867754Smsmith * Intel shall be used in advertising or otherwise to promote the sale, use or
7967754Smsmith * other dealings in products derived from or relating to the Covered Code
8067754Smsmith * without prior written authorization from Intel.
8167754Smsmith *
8267754Smsmith * 4. Disclaimer and Export Compliance
8367754Smsmith *
8467754Smsmith * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
8567754Smsmith * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
8667754Smsmith * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
8767754Smsmith * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
8867754Smsmith * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
8967754Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
9067754Smsmith * PARTICULAR PURPOSE.
9167754Smsmith *
9267754Smsmith * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
9367754Smsmith * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
9467754Smsmith * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
9567754Smsmith * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
9667754Smsmith * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
9767754Smsmith * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
9867754Smsmith * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
9967754Smsmith * LIMITED REMEDY.
10067754Smsmith *
10167754Smsmith * 4.3. Licensee shall not export, either directly or indirectly, any of this
10267754Smsmith * software or system incorporating such software without first obtaining any
10367754Smsmith * required license or other approval from the U. S. Department of Commerce or
10467754Smsmith * any other agency or department of the United States Government.  In the
10567754Smsmith * event Licensee exports any such software from the United States or
10667754Smsmith * re-exports any such software from a foreign destination, Licensee shall
10767754Smsmith * ensure that the distribution and export/re-export of the software is in
10867754Smsmith * compliance with all laws, regulations, orders, or other restrictions of the
10967754Smsmith * U.S. Export Administration Regulations. Licensee agrees that neither it nor
11067754Smsmith * any of its subsidiaries will export/re-export any technical data, process,
11167754Smsmith * software, or service, directly or indirectly, to any country for which the
11267754Smsmith * United States government or any agency thereof requires an export license,
11367754Smsmith * other governmental approval, or letter of assurance, without first obtaining
11467754Smsmith * such license, approval or letter.
11567754Smsmith *
11667754Smsmith *****************************************************************************/
11767754Smsmith
11877424Smsmith#define __EXRESOP_C__
11967754Smsmith
12067754Smsmith#include "acpi.h"
12167754Smsmith#include "amlcode.h"
12267754Smsmith#include "acparser.h"
12367754Smsmith#include "acinterp.h"
12467754Smsmith
12567754Smsmith
12677424Smsmith#define _COMPONENT          ACPI_EXECUTER
12791116Smsmith        ACPI_MODULE_NAME    ("exresop")
12867754Smsmith
12967754Smsmith
13067754Smsmith/*******************************************************************************
13167754Smsmith *
13277424Smsmith * FUNCTION:    AcpiExCheckObjectType
13369746Smsmith *
13469746Smsmith * PARAMETERS:  TypeNeeded          Object type needed
13569746Smsmith *              ThisType            Actual object type
13669746Smsmith *              Object              Object pointer
13769746Smsmith *
13869746Smsmith * RETURN:      Status
13969746Smsmith *
14069746Smsmith * DESCRIPTION: Check required type against actual type
14169746Smsmith *
14269746Smsmith ******************************************************************************/
14369746Smsmith
14469746SmsmithACPI_STATUS
14577424SmsmithAcpiExCheckObjectType (
14669746Smsmith    ACPI_OBJECT_TYPE        TypeNeeded,
14769746Smsmith    ACPI_OBJECT_TYPE        ThisType,
14869746Smsmith    void                    *Object)
14969746Smsmith{
15091116Smsmith    ACPI_FUNCTION_NAME ("ExCheckObjectType");
15169746Smsmith
15283174Smsmith
15369746Smsmith    if (TypeNeeded == ACPI_TYPE_ANY)
15469746Smsmith    {
15569746Smsmith        /* All types OK, so we don't perform any typechecks */
15669746Smsmith
15769746Smsmith        return (AE_OK);
15869746Smsmith    }
15969746Smsmith
160107325Siwasaki    if (TypeNeeded == ACPI_TYPE_LOCAL_REFERENCE)
16199679Siwasaki    {
16299679Siwasaki        /*
16399679Siwasaki         * Allow the AML "Constant" opcodes (Zero, One, etc.) to be reference
16499679Siwasaki         * objects and thus allow them to be targets.  (As per the ACPI
16599679Siwasaki         * specification, a store to a constant is a noop.)
16699679Siwasaki         */
16799679Siwasaki        if ((ThisType == ACPI_TYPE_INTEGER) &&
16899679Siwasaki            (((ACPI_OPERAND_OBJECT *) Object)->Common.Flags & AOPOBJ_AML_CONSTANT))
16999679Siwasaki        {
17099679Siwasaki            return (AE_OK);
17199679Siwasaki        }
17299679Siwasaki    }
17399679Siwasaki
17469746Smsmith    if (TypeNeeded != ThisType)
17569746Smsmith    {
17699146Siwasaki        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
17782367Smsmith            "Needed [%s], found [%s] %p\n",
17877424Smsmith            AcpiUtGetTypeName (TypeNeeded),
17977424Smsmith            AcpiUtGetTypeName (ThisType), Object));
18069746Smsmith
18169746Smsmith        return (AE_AML_OPERAND_TYPE);
18269746Smsmith    }
18369746Smsmith
18469746Smsmith    return (AE_OK);
18569746Smsmith}
18669746Smsmith
18769746Smsmith
18869746Smsmith/*******************************************************************************
18969746Smsmith *
19077424Smsmith * FUNCTION:    AcpiExResolveOperands
19167754Smsmith *
19291116Smsmith * PARAMETERS:  Opcode              - Opcode being interpreted
19391116Smsmith *              StackPtr            - Pointer to the operand stack to be
19491116Smsmith *                                    resolved
19599679Siwasaki *              WalkState           - Current state
19667754Smsmith *
19767754Smsmith * RETURN:      Status
19867754Smsmith *
19991116Smsmith * DESCRIPTION: Convert multiple input operands to the types required by the
20091116Smsmith *              target operator.
20167754Smsmith *
20299679Siwasaki *      Each 5-bit group in ArgTypes represents one required
203102550Siwasaki *      operand and indicates the required Type. The corresponding operand
204102550Siwasaki *      will be converted to the required type if possible, otherwise we
20599679Siwasaki *      abort with an exception.
20667754Smsmith *
20767754Smsmith ******************************************************************************/
20867754Smsmith
20967754SmsmithACPI_STATUS
21077424SmsmithAcpiExResolveOperands (
21167754Smsmith    UINT16                  Opcode,
21267754Smsmith    ACPI_OPERAND_OBJECT     **StackPtr,
21367754Smsmith    ACPI_WALK_STATE         *WalkState)
21467754Smsmith{
21567754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
21667754Smsmith    ACPI_STATUS             Status = AE_OK;
21767754Smsmith    UINT8                   ObjectType;
21877424Smsmith    void                    *TempNode;
21967754Smsmith    UINT32                  ArgTypes;
22083174Smsmith    const ACPI_OPCODE_INFO  *OpInfo;
22167754Smsmith    UINT32                  ThisArgType;
22269746Smsmith    ACPI_OBJECT_TYPE        TypeNeeded;
22367754Smsmith
22467754Smsmith
22591116Smsmith    ACPI_FUNCTION_TRACE_U32 ("ExResolveOperands", Opcode);
22667754Smsmith
22767754Smsmith
22867754Smsmith    OpInfo = AcpiPsGetOpcodeInfo (Opcode);
22985756Smsmith    if (OpInfo->Class == AML_CLASS_UNKNOWN)
23067754Smsmith    {
23167754Smsmith        return_ACPI_STATUS (AE_AML_BAD_OPCODE);
23267754Smsmith    }
23367754Smsmith
23467754Smsmith    ArgTypes = OpInfo->RuntimeArgs;
23567754Smsmith    if (ArgTypes == ARGI_INVALID_OPCODE)
23667754Smsmith    {
23783174Smsmith        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - %X is not a valid AML opcode\n",
23877424Smsmith            Opcode));
23969746Smsmith
24069746Smsmith        return_ACPI_STATUS (AE_AML_INTERNAL);
24167754Smsmith    }
24267754Smsmith
24399146Siwasaki    ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode %X [%s] OperandTypes=%X \n",
24499146Siwasaki        Opcode, OpInfo->Name, ArgTypes));
24567754Smsmith
24677424Smsmith    /*
24777424Smsmith     * Normal exit is with (ArgTypes == 0) at end of argument list.
24867754Smsmith     * Function will return an exception from within the loop upon
24977424Smsmith     * finding an entry which is not (or cannot be converted
25077424Smsmith     * to) the required type; if stack underflows; or upon
25177424Smsmith     * finding a NULL stack entry (which should not happen).
25267754Smsmith     */
25367754Smsmith    while (GET_CURRENT_ARG_TYPE (ArgTypes))
25467754Smsmith    {
25567754Smsmith        if (!StackPtr || !*StackPtr)
25667754Smsmith        {
25785756Smsmith            ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null stack entry at %p\n",
25877424Smsmith                StackPtr));
25969746Smsmith
26069746Smsmith            return_ACPI_STATUS (AE_AML_INTERNAL);
26167754Smsmith        }
26267754Smsmith
26367754Smsmith        /* Extract useful items */
26467754Smsmith
26567754Smsmith        ObjDesc = *StackPtr;
26667754Smsmith
26767754Smsmith        /* Decode the descriptor type */
26867754Smsmith
26991116Smsmith        switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
27067754Smsmith        {
27191116Smsmith        case ACPI_DESC_TYPE_NAMED:
27291116Smsmith
27367754Smsmith            /* Node */
27467754Smsmith
27567754Smsmith            ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
27691116Smsmith            break;
27767754Smsmith
27891116Smsmith
27999679Siwasaki        case ACPI_DESC_TYPE_OPERAND:
28091116Smsmith
28167754Smsmith            /* ACPI internal object */
28267754Smsmith
28399679Siwasaki            ObjectType = ACPI_GET_OBJECT_TYPE (ObjDesc);
28467754Smsmith
28567754Smsmith            /* Check for bad ACPI_OBJECT_TYPE */
28667754Smsmith
287107325Siwasaki            if (!AcpiUtValidObjectType (ObjectType))
28867754Smsmith            {
28982367Smsmith                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Bad operand object type [%X]\n",
29067754Smsmith                    ObjectType));
29169746Smsmith
29269746Smsmith                return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
29367754Smsmith            }
29467754Smsmith
295107325Siwasaki            if (ObjectType == (UINT8) ACPI_TYPE_LOCAL_REFERENCE)
29667754Smsmith            {
29767754Smsmith                /*
29867754Smsmith                 * Decode the Reference
29967754Smsmith                 */
30067754Smsmith                OpInfo = AcpiPsGetOpcodeInfo (Opcode);
30185756Smsmith                if (OpInfo->Class == AML_CLASS_UNKNOWN)
30267754Smsmith                {
30367754Smsmith                    return_ACPI_STATUS (AE_AML_BAD_OPCODE);
30467754Smsmith                }
30567754Smsmith
30677424Smsmith                switch (ObjDesc->Reference.Opcode)
30767754Smsmith                {
30867754Smsmith                case AML_DEBUG_OP:
30967754Smsmith                case AML_NAME_OP:
31067754Smsmith                case AML_INDEX_OP:
311100966Siwasaki                case AML_REF_OF_OP:
31267754Smsmith                case AML_ARG_OP:
31367754Smsmith                case AML_LOCAL_OP:
314123315Snjl                case AML_LOAD_OP:   /* DdbHandle from LOAD_OP or LOAD_TABLE_OP */
31567754Smsmith
31699146Siwasaki                    ACPI_DEBUG_ONLY_MEMBERS (ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
31782367Smsmith                        "Reference Opcode: %s\n", OpInfo->Name)));
31867754Smsmith                    break;
31967754Smsmith
32067754Smsmith                default:
32191116Smsmith                    ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
322123315Snjl                        "Unknown Reference Opcode %X [%s]\n",
323123315Snjl                        ObjDesc->Reference.Opcode,
324123315Snjl                        (AcpiPsGetOpcodeInfo (ObjDesc->Reference.Opcode))->Name));
32567754Smsmith
32669746Smsmith                    return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
32767754Smsmith                }
32867754Smsmith            }
32991116Smsmith            break;
33067754Smsmith
33191116Smsmith
33291116Smsmith        default:
33391116Smsmith
33467754Smsmith            /* Invalid descriptor */
33567754Smsmith
33682367Smsmith            ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
337123315Snjl                    "Invalid descriptor %p [%s]\n",
338123315Snjl                    ObjDesc, AcpiUtGetDescriptorName (ObjDesc)));
33967754Smsmith
34069746Smsmith            return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
34167754Smsmith        }
34267754Smsmith
34367754Smsmith
34467754Smsmith        /*
34569746Smsmith         * Get one argument type, point to the next
34667754Smsmith         */
34767754Smsmith        ThisArgType = GET_CURRENT_ARG_TYPE (ArgTypes);
34867754Smsmith        INCREMENT_ARG_LIST (ArgTypes);
34967754Smsmith
35069746Smsmith        /*
35170243Smsmith         * Handle cases where the object does not need to be
35270243Smsmith         * resolved to a value
35369746Smsmith         */
35467754Smsmith        switch (ThisArgType)
35567754Smsmith        {
35691116Smsmith        case ARGI_REF_OR_STRING:        /* Can be a String or Reference */
35767754Smsmith
35899679Siwasaki            if ((ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND) &&
35991116Smsmith                (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_STRING))
36091116Smsmith            {
36191116Smsmith                /*
36291116Smsmith                 * String found - the string references a named object and must be
36391116Smsmith                 * resolved to a node
36491116Smsmith                 */
36591116Smsmith                goto NextOperand;
36691116Smsmith            }
36791116Smsmith
36891116Smsmith            /* Else not a string - fall through to the normal Reference case below */
36999679Siwasaki            /*lint -fallthrough */
37091116Smsmith
37191116Smsmith        case ARGI_REFERENCE:            /* References: */
37271867Smsmith        case ARGI_INTEGER_REF:
37371867Smsmith        case ARGI_OBJECT_REF:
37471867Smsmith        case ARGI_DEVICE_REF:
37591116Smsmith        case ARGI_TARGETREF:            /* Allows implicit conversion rules before store */
37671867Smsmith        case ARGI_FIXED_TARGET:         /* No implicit conversion before store to target */
37791116Smsmith        case ARGI_SIMPLE_TARGET:        /* Name, Local, or Arg - no implicit conversion  */
37867754Smsmith
379107325Siwasaki            /* Need an operand of type ACPI_TYPE_LOCAL_REFERENCE */
38067754Smsmith
38191116Smsmith            if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) /* Node (name) ptr OK as-is */
38267754Smsmith            {
38369746Smsmith                goto NextOperand;
38467754Smsmith            }
38567754Smsmith
386107325Siwasaki            Status = AcpiExCheckObjectType (ACPI_TYPE_LOCAL_REFERENCE,
38769746Smsmith                            ObjectType, ObjDesc);
38869746Smsmith            if (ACPI_FAILURE (Status))
38967754Smsmith            {
39069746Smsmith                return_ACPI_STATUS (Status);
39167754Smsmith            }
39267754Smsmith
39377424Smsmith            if (AML_NAME_OP == ObjDesc->Reference.Opcode)
39467754Smsmith            {
39567754Smsmith                /*
39667754Smsmith                 * Convert an indirect name ptr to direct name ptr and put
39767754Smsmith                 * it on the stack
39867754Smsmith                 */
39977424Smsmith                TempNode = ObjDesc->Reference.Object;
40077424Smsmith                AcpiUtRemoveReference (ObjDesc);
40177424Smsmith                (*StackPtr) = TempNode;
40267754Smsmith            }
40369746Smsmith            goto NextOperand;
40467754Smsmith
40567754Smsmith
40669746Smsmith        case ARGI_ANYTYPE:
40767754Smsmith
40869746Smsmith            /*
40969746Smsmith             * We don't want to resolve IndexOp reference objects during
41069746Smsmith             * a store because this would be an implicit DeRefOf operation.
41169746Smsmith             * Instead, we just want to store the reference object.
41269746Smsmith             * -- All others must be resolved below.
41369746Smsmith             */
41469746Smsmith            if ((Opcode == AML_STORE_OP) &&
415107325Siwasaki                (ACPI_GET_OBJECT_TYPE (*StackPtr) == ACPI_TYPE_LOCAL_REFERENCE) &&
41677424Smsmith                ((*StackPtr)->Reference.Opcode == AML_INDEX_OP))
41767754Smsmith            {
41869746Smsmith                goto NextOperand;
41967754Smsmith            }
42067754Smsmith            break;
42199679Siwasaki
42299679Siwasaki        default:
42399679Siwasaki            /* All cases covered above */
42499679Siwasaki            break;
42569746Smsmith        }
42667754Smsmith
42767754Smsmith
42869746Smsmith        /*
42969746Smsmith         * Resolve this object to a value
43069746Smsmith         */
43177424Smsmith        Status = AcpiExResolveToValue (StackPtr, WalkState);
43269746Smsmith        if (ACPI_FAILURE (Status))
43369746Smsmith        {
43469746Smsmith            return_ACPI_STATUS (Status);
43569746Smsmith        }
43667754Smsmith
437104470Siwasaki        /* Get the resolved object */
438104470Siwasaki
439104470Siwasaki        ObjDesc = *StackPtr;
440104470Siwasaki
44169746Smsmith        /*
44269746Smsmith         * Check the resulting object (value) type
44369746Smsmith         */
44469746Smsmith        switch (ThisArgType)
44569746Smsmith        {
44669746Smsmith        /*
44769746Smsmith         * For the simple cases, only one type of resolved object
44869746Smsmith         * is allowed
44969746Smsmith         */
45067754Smsmith        case ARGI_MUTEX:
45167754Smsmith
45267754Smsmith            /* Need an operand of type ACPI_TYPE_MUTEX */
45367754Smsmith
45469746Smsmith            TypeNeeded = ACPI_TYPE_MUTEX;
45567754Smsmith            break;
45667754Smsmith
45767754Smsmith        case ARGI_EVENT:
45867754Smsmith
45967754Smsmith            /* Need an operand of type ACPI_TYPE_EVENT */
46067754Smsmith
46169746Smsmith            TypeNeeded = ACPI_TYPE_EVENT;
46267754Smsmith            break;
46367754Smsmith
46467754Smsmith        case ARGI_PACKAGE:   /* Package */
46567754Smsmith
46667754Smsmith            /* Need an operand of type ACPI_TYPE_PACKAGE */
46767754Smsmith
46869746Smsmith            TypeNeeded = ACPI_TYPE_PACKAGE;
46969746Smsmith            break;
47067754Smsmith
47169746Smsmith        case ARGI_ANYTYPE:
47269746Smsmith
47369746Smsmith            /* Any operand type will do */
47469746Smsmith
47569746Smsmith            TypeNeeded = ACPI_TYPE_ANY;
47667754Smsmith            break;
47767754Smsmith
478123315Snjl        case ARGI_DDBHANDLE:
47967754Smsmith
480123315Snjl            /* Need an operand of type ACPI_TYPE_DDB_HANDLE */
481123315Snjl
482123315Snjl            TypeNeeded = ACPI_TYPE_LOCAL_REFERENCE;
483123315Snjl            break;
484123315Snjl
485123315Snjl
48669746Smsmith        /*
48769746Smsmith         * The more complex cases allow multiple resolved object types
48869746Smsmith         */
48971867Smsmith        case ARGI_INTEGER:   /* Number */
49071867Smsmith
49171867Smsmith            /*
49271867Smsmith             * Need an operand of type ACPI_TYPE_INTEGER,
49371867Smsmith             * But we can implicitly convert from a STRING or BUFFER
494104470Siwasaki             * Aka - "Implicit Source Operand Conversion"
49571867Smsmith             */
496104470Siwasaki            Status = AcpiExConvertToInteger (ObjDesc, StackPtr, WalkState);
49771867Smsmith            if (ACPI_FAILURE (Status))
49871867Smsmith            {
49971867Smsmith                if (Status == AE_TYPE)
50071867Smsmith                {
50191116Smsmith                    ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
50282367Smsmith                        "Needed [Integer/String/Buffer], found [%s] %p\n",
503104470Siwasaki                        AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
50471867Smsmith
50571867Smsmith                    return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
50671867Smsmith                }
50771867Smsmith
50871867Smsmith                return_ACPI_STATUS (Status);
50971867Smsmith            }
51071867Smsmith            goto NextOperand;
51171867Smsmith
51271867Smsmith
51371867Smsmith        case ARGI_BUFFER:
51471867Smsmith
51571867Smsmith            /*
51671867Smsmith             * Need an operand of type ACPI_TYPE_BUFFER,
51771867Smsmith             * But we can implicitly convert from a STRING or INTEGER
518104470Siwasaki             * Aka - "Implicit Source Operand Conversion"
51971867Smsmith             */
520104470Siwasaki            Status = AcpiExConvertToBuffer (ObjDesc, StackPtr, WalkState);
52171867Smsmith            if (ACPI_FAILURE (Status))
52271867Smsmith            {
52371867Smsmith                if (Status == AE_TYPE)
52471867Smsmith                {
52591116Smsmith                    ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
52682367Smsmith                        "Needed [Integer/String/Buffer], found [%s] %p\n",
527104470Siwasaki                        AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
52871867Smsmith
52971867Smsmith                    return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
53071867Smsmith                }
53171867Smsmith
53271867Smsmith                return_ACPI_STATUS (Status);
53371867Smsmith            }
53471867Smsmith            goto NextOperand;
53571867Smsmith
53671867Smsmith
53769746Smsmith        case ARGI_STRING:
53867754Smsmith
53971867Smsmith            /*
54071867Smsmith             * Need an operand of type ACPI_TYPE_STRING,
54171867Smsmith             * But we can implicitly convert from a BUFFER or INTEGER
542104470Siwasaki             * Aka - "Implicit Source Operand Conversion"
54371867Smsmith             */
544104470Siwasaki            Status = AcpiExConvertToString (ObjDesc, StackPtr, 16, ACPI_UINT32_MAX, WalkState);
54571867Smsmith            if (ACPI_FAILURE (Status))
54671867Smsmith            {
54771867Smsmith                if (Status == AE_TYPE)
54871867Smsmith                {
54991116Smsmith                    ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
55082367Smsmith                        "Needed [Integer/String/Buffer], found [%s] %p\n",
551104470Siwasaki                        AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
55267754Smsmith
55371867Smsmith                    return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
55471867Smsmith                }
55571867Smsmith
55671867Smsmith                return_ACPI_STATUS (Status);
55771867Smsmith            }
55871867Smsmith            goto NextOperand;
55971867Smsmith
56071867Smsmith
56171867Smsmith        case ARGI_COMPUTEDATA:
56271867Smsmith
56371867Smsmith            /* Need an operand of type INTEGER, STRING or BUFFER */
56471867Smsmith
565104470Siwasaki            switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
56667754Smsmith            {
56791116Smsmith            case ACPI_TYPE_INTEGER:
56891116Smsmith            case ACPI_TYPE_STRING:
56991116Smsmith            case ACPI_TYPE_BUFFER:
57091116Smsmith
57191116Smsmith                /* Valid operand */
57291116Smsmith               break;
57391116Smsmith
57491116Smsmith            default:
57591116Smsmith                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
57682367Smsmith                    "Needed [Integer/String/Buffer], found [%s] %p\n",
577104470Siwasaki                    AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
57867754Smsmith
57969746Smsmith                return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
58067754Smsmith            }
58169746Smsmith            goto NextOperand;
58267754Smsmith
58367754Smsmith
584114237Snjl        case ARGI_BUFFER_OR_STRING:
585114237Snjl
586114237Snjl            /* Need an operand of type STRING or BUFFER */
587114237Snjl
588114237Snjl            switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
589114237Snjl            {
590114237Snjl            case ACPI_TYPE_STRING:
591114237Snjl            case ACPI_TYPE_BUFFER:
592114237Snjl
593114237Snjl                /* Valid operand */
594114237Snjl               break;
595114237Snjl
596114237Snjl            case ACPI_TYPE_INTEGER:
597114237Snjl
598114237Snjl                /* Highest priority conversion is to type Buffer */
599114237Snjl
600114237Snjl                Status = AcpiExConvertToBuffer (ObjDesc, StackPtr, WalkState);
601114237Snjl                if (ACPI_FAILURE (Status))
602114237Snjl                {
603114237Snjl                    return_ACPI_STATUS (Status);
604114237Snjl                }
605114237Snjl                break;
606114237Snjl
607114237Snjl            default:
608114237Snjl                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
609114237Snjl                    "Needed [Integer/String/Buffer], found [%s] %p\n",
610114237Snjl                    AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
611114237Snjl
612114237Snjl                return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
613114237Snjl            }
614114237Snjl            goto NextOperand;
615114237Snjl
616114237Snjl
61767754Smsmith        case ARGI_DATAOBJECT:
61867754Smsmith            /*
61967754Smsmith             * ARGI_DATAOBJECT is only used by the SizeOf operator.
620104470Siwasaki             * Need a buffer, string, package, or RefOf reference.
62167754Smsmith             *
62291116Smsmith             * The only reference allowed here is a direct reference to
62391116Smsmith             * a namespace node.
62467754Smsmith             */
625104470Siwasaki            switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
62667754Smsmith            {
62791116Smsmith            case ACPI_TYPE_PACKAGE:
62891116Smsmith            case ACPI_TYPE_STRING:
62991116Smsmith            case ACPI_TYPE_BUFFER:
630107325Siwasaki            case ACPI_TYPE_LOCAL_REFERENCE:
63191116Smsmith
63291116Smsmith                /* Valid operand */
63391116Smsmith                break;
63491116Smsmith
63591116Smsmith            default:
63691116Smsmith                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
637114237Snjl                    "Needed [Buffer/String/Package/Reference], found [%s] %p\n",
638104470Siwasaki                    AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
63991116Smsmith
64091116Smsmith                return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
64191116Smsmith            }
64269746Smsmith            goto NextOperand;
64367754Smsmith
64467754Smsmith
64567754Smsmith        case ARGI_COMPLEXOBJ:
64667754Smsmith
64777424Smsmith            /* Need a buffer or package or (ACPI 2.0) String */
64867754Smsmith
649104470Siwasaki            switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
65067754Smsmith            {
65191116Smsmith            case ACPI_TYPE_PACKAGE:
65291116Smsmith            case ACPI_TYPE_STRING:
65391116Smsmith            case ACPI_TYPE_BUFFER:
65491116Smsmith
65591116Smsmith                /* Valid operand */
65691116Smsmith                break;
65791116Smsmith
65891116Smsmith            default:
65991116Smsmith                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
660114237Snjl                    "Needed [Buffer/String/Package], found [%s] %p\n",
661104470Siwasaki                    AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
66269746Smsmith
66369746Smsmith                return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
66467754Smsmith            }
66569746Smsmith            goto NextOperand;
66667754Smsmith
66767754Smsmith
668114237Snjl        case ARGI_REGION_OR_FIELD:
669114237Snjl
670114237Snjl            /* Need an operand of type ACPI_TYPE_REGION or a FIELD in a region */
671114237Snjl
672114237Snjl            switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
673114237Snjl            {
674114237Snjl            case ACPI_TYPE_REGION:
675114237Snjl            case ACPI_TYPE_LOCAL_REGION_FIELD:
676114237Snjl            case ACPI_TYPE_LOCAL_BANK_FIELD:
677114237Snjl            case ACPI_TYPE_LOCAL_INDEX_FIELD:
678114237Snjl
679114237Snjl                /* Valid operand */
680114237Snjl                break;
681114237Snjl
682114237Snjl            default:
683114237Snjl                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
684114237Snjl                    "Needed [Region/RegionField], found [%s] %p\n",
685114237Snjl                    AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
686114237Snjl
687114237Snjl                return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
688114237Snjl            }
689114237Snjl            goto NextOperand;
690114237Snjl
691114237Snjl
69269746Smsmith        default:
69367754Smsmith
69469746Smsmith            /* Unknown type */
69569746Smsmith
69682367Smsmith            ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
697104470Siwasaki                "Internal - Unknown ARGI (required operand) type %X\n",
69867754Smsmith                ThisArgType));
69967754Smsmith
70069746Smsmith            return_ACPI_STATUS (AE_BAD_PARAMETER);
70169746Smsmith        }
70267754Smsmith
70370243Smsmith        /*
70469746Smsmith         * Make sure that the original object was resolved to the
70569746Smsmith         * required object type (Simple cases only).
70669746Smsmith         */
70777424Smsmith        Status = AcpiExCheckObjectType (TypeNeeded,
70899679Siwasaki                        ACPI_GET_OBJECT_TYPE (*StackPtr), *StackPtr);
70969746Smsmith        if (ACPI_FAILURE (Status))
71069746Smsmith        {
71169746Smsmith            return_ACPI_STATUS (Status);
71269746Smsmith        }
71369746Smsmith
71469746SmsmithNextOperand:
71567754Smsmith        /*
71667754Smsmith         * If more operands needed, decrement StackPtr to point
71769746Smsmith         * to next operand on stack
71867754Smsmith         */
71967754Smsmith        if (GET_CURRENT_ARG_TYPE (ArgTypes))
72067754Smsmith        {
72167754Smsmith            StackPtr--;
72267754Smsmith        }
72367754Smsmith
72467754Smsmith    }   /* while (*Types) */
72567754Smsmith
72669746Smsmith    return_ACPI_STATUS (Status);
72767754Smsmith}
72867754Smsmith
72967754Smsmith
730