exresop.c revision 193267
1167140Sbms
2167140Sbms/******************************************************************************
3167140Sbms *
4167140Sbms * Module Name: exresop - AML Interpreter operand/object resolution
5167140Sbms *
6167140Sbms *****************************************************************************/
7167140Sbms
8167140Sbms/******************************************************************************
9167140Sbms *
10167140Sbms * 1. Copyright Notice
11167140Sbms *
12167140Sbms * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
13167140Sbms * All rights reserved.
14167140Sbms *
15167140Sbms * 2. License
16167140Sbms *
17167140Sbms * 2.1. This is your license from Intel Corp. under its intellectual property
18167140Sbms * rights.  You may have additional license terms from the party that provided
19167140Sbms * you this software, covering your right to use that party's intellectual
20167140Sbms * property rights.
21167140Sbms *
22167140Sbms * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23167140Sbms * copy of the source code appearing in this file ("Covered Code") an
24167140Sbms * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25167140Sbms * base code distributed originally by Intel ("Original Intel Code") to copy,
26167140Sbms * make derivatives, distribute, use and display any portion of the Covered
27167140Sbms * Code in any form, with the right to sublicense such rights; and
28167140Sbms *
29167140Sbms * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30167140Sbms * license (with the right to sublicense), under only those claims of Intel
31167140Sbms * patents that are infringed by the Original Intel Code, to make, use, sell,
32167140Sbms * offer to sell, and import the Covered Code and derivative works thereof
33167140Sbms * solely to the minimum extent necessary to exercise the above copyright
34167140Sbms * license, and in no event shall the patent license extend to any additions
35167140Sbms * to or modifications of the Original Intel Code.  No other license or right
36167140Sbms * is granted directly or by implication, estoppel or otherwise;
37167140Sbms *
38167140Sbms * The above copyright and patent license is granted only if the following
39167340Sbms * conditions are met:
40167340Sbms *
41167140Sbms * 3. Conditions
42167140Sbms *
43167140Sbms * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44167140Sbms * Redistribution of source code of any substantial portion of the Covered
45167140Sbms * Code or modification with rights to further distribute source must include
46167140Sbms * the above Copyright Notice, the above License, this list of Conditions,
47167140Sbms * and the following Disclaimer and Export Compliance provision.  In addition,
48167140Sbms * Licensee must cause all Covered Code to which Licensee contributes to
49167140Sbms * contain a file documenting the changes Licensee made to create that Covered
50167140Sbms * Code and the date of any change.  Licensee must include in that file the
51167140Sbms * documentation of any changes made by any predecessor Licensee.  Licensee
52167140Sbms * must include a prominent statement that the modification is derived,
53167140Sbms * directly or indirectly, from Original Intel Code.
54167140Sbms *
55167140Sbms * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56167140Sbms * Redistribution of source code of any substantial portion of the Covered
57167140Sbms * Code or modification without rights to further distribute source must
58167140Sbms * include the following Disclaimer and Export Compliance provision in the
59167340Sbms * documentation and/or other materials provided with distribution.  In
60167340Sbms * addition, Licensee may not authorize further sublicense of source of any
61167340Sbms * portion of the Covered Code, and must include terms to the effect that the
62167340Sbms * license from Licensee to its licensee is limited to the intellectual
63167512Sbms * property embodied in the software Licensee provides to its licensee, and
64167512Sbms * not to intellectual property embodied in modifications its licensee may
65167512Sbms * make.
66167512Sbms *
67167140Sbms * 3.3. Redistribution of Executable. Redistribution in executable form of any
68167140Sbms * substantial portion of the Covered Code or modification must reproduce the
69167149Sbms * above Copyright Notice, and the following Disclaimer and Export Compliance
70167140Sbms * provision in the documentation and/or other materials provided with the
71167340Sbms * distribution.
72167340Sbms *
73167340Sbms * 3.4. Intel retains all right, title, and interest in and to the Original
74167340Sbms * Intel Code.
75167140Sbms *
76167140Sbms * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77167140Sbms * Intel shall be used in advertising or otherwise to promote the sale, use or
78167140Sbms * other dealings in products derived from or relating to the Covered Code
79167140Sbms * without prior written authorization from Intel.
80167140Sbms *
81167341Sbms * 4. Disclaimer and Export Compliance
82167341Sbms *
83167140Sbms * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84167341Sbms * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85167512Sbms * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86167140Sbms * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87167140Sbms * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88167341Sbms * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89167341Sbms * PARTICULAR PURPOSE.
90167140Sbms *
91167140Sbms * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92167341Sbms * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93167340Sbms * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94167341Sbms * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95167340Sbms * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96167512Sbms * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97167140Sbms * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98167140Sbms * LIMITED REMEDY.
99167140Sbms *
100167149Sbms * 4.3. Licensee shall not export, either directly or indirectly, any of this
101167149Sbms * software or system incorporating such software without first obtaining any
102167140Sbms * required license or other approval from the U. S. Department of Commerce or
103167140Sbms * any other agency or department of the United States Government.  In the
104167140Sbms * event Licensee exports any such software from the United States or
105167140Sbms * re-exports any such software from a foreign destination, Licensee shall
106167140Sbms * ensure that the distribution and export/re-export of the software is in
107167140Sbms * compliance with all laws, regulations, orders, or other restrictions of the
108167140Sbms * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109167140Sbms * any of its subsidiaries will export/re-export any technical data, process,
110167140Sbms * software, or service, directly or indirectly, to any country for which the
111167140Sbms * United States government or any agency thereof requires an export license,
112167140Sbms * other governmental approval, or letter of assurance, without first obtaining
113167140Sbms * such license, approval or letter.
114167341Sbms *
115167340Sbms *****************************************************************************/
116167140Sbms
117167140Sbms#define __EXRESOP_C__
118167140Sbms
119167340Sbms#include "acpi.h"
120167341Sbms#include "accommon.h"
121167140Sbms#include "amlcode.h"
122167140Sbms#include "acparser.h"
123167140Sbms#include "acinterp.h"
124167140Sbms#include "acnamesp.h"
125167140Sbms
126167140Sbms
127167140Sbms#define _COMPONENT          ACPI_EXECUTER
128167512Sbms        ACPI_MODULE_NAME    ("exresop")
129167140Sbms
130167140Sbms/* Local prototypes */
131167140Sbms
132167140Sbmsstatic ACPI_STATUS
133167140SbmsAcpiExCheckObjectType (
134167140Sbms    ACPI_OBJECT_TYPE        TypeNeeded,
135167140Sbms    ACPI_OBJECT_TYPE        ThisType,
136167149Sbms    void                    *Object);
137167140Sbms
138167140Sbms
139167140Sbms/*******************************************************************************
140167140Sbms *
141167140Sbms * FUNCTION:    AcpiExCheckObjectType
142167140Sbms *
143167512Sbms * PARAMETERS:  TypeNeeded          Object type needed
144167140Sbms *              ThisType            Actual object type
145167340Sbms *              Object              Object pointer
146167140Sbms *
147167341Sbms * RETURN:      Status
148167140Sbms *
149167140Sbms * DESCRIPTION: Check required type against actual type
150167149Sbms *
151167140Sbms ******************************************************************************/
152167140Sbms
153167140Sbmsstatic ACPI_STATUS
154167140SbmsAcpiExCheckObjectType (
155167140Sbms    ACPI_OBJECT_TYPE        TypeNeeded,
156167512Sbms    ACPI_OBJECT_TYPE        ThisType,
157167140Sbms    void                    *Object)
158167140Sbms{
159167140Sbms    ACPI_FUNCTION_ENTRY ();
160167140Sbms
161167341Sbms
162167341Sbms    if (TypeNeeded == ACPI_TYPE_ANY)
163167341Sbms    {
164167140Sbms        /* All types OK, so we don't perform any typechecks */
165167140Sbms
166167140Sbms        return (AE_OK);
167167140Sbms    }
168167140Sbms
169167140Sbms    if (TypeNeeded == ACPI_TYPE_LOCAL_REFERENCE)
170167140Sbms    {
171167140Sbms        /*
172167140Sbms         * Allow the AML "Constant" opcodes (Zero, One, etc.) to be reference
173167340Sbms         * objects and thus allow them to be targets.  (As per the ACPI
174167340Sbms         * specification, a store to a constant is a noop.)
175167340Sbms         */
176167140Sbms        if ((ThisType == ACPI_TYPE_INTEGER) &&
177167140Sbms            (((ACPI_OPERAND_OBJECT *) Object)->Common.Flags & AOPOBJ_AML_CONSTANT))
178167140Sbms        {
179167140Sbms            return (AE_OK);
180167140Sbms        }
181167140Sbms    }
182167512Sbms
183167512Sbms    if (TypeNeeded != ThisType)
184167512Sbms    {
185167140Sbms        ACPI_ERROR ((AE_INFO,
186167140Sbms            "Needed type [%s], found [%s] %p",
187167140Sbms            AcpiUtGetTypeName (TypeNeeded),
188167140Sbms            AcpiUtGetTypeName (ThisType), Object));
189167140Sbms
190167140Sbms        return (AE_AML_OPERAND_TYPE);
191167149Sbms    }
192167149Sbms
193167149Sbms    return (AE_OK);
194167140Sbms}
195167140Sbms
196167140Sbms
197167140Sbms/*******************************************************************************
198167140Sbms *
199167140Sbms * FUNCTION:    AcpiExResolveOperands
200167140Sbms *
201167140Sbms * PARAMETERS:  Opcode              - Opcode being interpreted
202167140Sbms *              StackPtr            - Pointer to the operand stack to be
203167140Sbms *                                    resolved
204167140Sbms *              WalkState           - Current state
205167140Sbms *
206167340Sbms * RETURN:      Status
207167340Sbms *
208167340Sbms * DESCRIPTION: Convert multiple input operands to the types required by the
209167512Sbms *              target operator.
210167512Sbms *
211167512Sbms *      Each 5-bit group in ArgTypes represents one required
212167512Sbms *      operand and indicates the required Type. The corresponding operand
213167512Sbms *      will be converted to the required type if possible, otherwise we
214167512Sbms *      abort with an exception.
215167512Sbms *
216167140Sbms ******************************************************************************/
217167140Sbms
218167140SbmsACPI_STATUS
219167140SbmsAcpiExResolveOperands (
220167140Sbms    UINT16                  Opcode,
221167140Sbms    ACPI_OPERAND_OBJECT     **StackPtr,
222167140Sbms    ACPI_WALK_STATE         *WalkState)
223167140Sbms{
224167140Sbms    ACPI_OPERAND_OBJECT     *ObjDesc;
225167140Sbms    ACPI_STATUS             Status = AE_OK;
226167140Sbms    UINT8                   ObjectType;
227167140Sbms    UINT32                  ArgTypes;
228167140Sbms    const ACPI_OPCODE_INFO  *OpInfo;
229167140Sbms    UINT32                  ThisArgType;
230167140Sbms    ACPI_OBJECT_TYPE        TypeNeeded;
231167140Sbms    UINT16                  TargetOp = 0;
232167140Sbms
233167140Sbms
234167140Sbms    ACPI_FUNCTION_TRACE_U32 (ExResolveOperands, Opcode);
235167140Sbms
236167140Sbms
237167140Sbms    OpInfo = AcpiPsGetOpcodeInfo (Opcode);
238167140Sbms    if (OpInfo->Class == AML_CLASS_UNKNOWN)
239167140Sbms    {
240167140Sbms        return_ACPI_STATUS (AE_AML_BAD_OPCODE);
241167140Sbms    }
242167140Sbms
243167140Sbms    ArgTypes = OpInfo->RuntimeArgs;
244167140Sbms    if (ArgTypes == ARGI_INVALID_OPCODE)
245167149Sbms    {
246167149Sbms        ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X",
247167149Sbms            Opcode));
248167149Sbms
249167149Sbms        return_ACPI_STATUS (AE_AML_INTERNAL);
250167149Sbms    }
251167149Sbms
252167149Sbms    ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
253167149Sbms        "Opcode %X [%s] RequiredOperandTypes=%8.8X\n",
254167140Sbms        Opcode, OpInfo->Name, ArgTypes));
255167140Sbms
256167140Sbms    /*
257167140Sbms     * Normal exit is with (ArgTypes == 0) at end of argument list.
258167140Sbms     * Function will return an exception from within the loop upon
259167140Sbms     * finding an entry which is not (or cannot be converted
260167140Sbms     * to) the required type; if stack underflows; or upon
261167140Sbms     * finding a NULL stack entry (which should not happen).
262167140Sbms     */
263167140Sbms    while (GET_CURRENT_ARG_TYPE (ArgTypes))
264167140Sbms    {
265167140Sbms        if (!StackPtr || !*StackPtr)
266167140Sbms        {
267167341Sbms            ACPI_ERROR ((AE_INFO, "Null stack entry at %p",
268167341Sbms                StackPtr));
269167341Sbms
270167341Sbms            return_ACPI_STATUS (AE_AML_INTERNAL);
271167341Sbms        }
272167341Sbms
273167341Sbms        /* Extract useful items */
274167341Sbms
275167341Sbms        ObjDesc = *StackPtr;
276167140Sbms
277167140Sbms        /* Decode the descriptor type */
278167140Sbms
279167140Sbms        switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
280167140Sbms        {
281167140Sbms        case ACPI_DESC_TYPE_NAMED:
282167140Sbms
283167140Sbms            /* Namespace Node */
284167140Sbms
285167140Sbms            ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
286167140Sbms
287167140Sbms            /*
288167140Sbms             * Resolve an alias object. The construction of these objects
289167140Sbms             * guarantees that there is only one level of alias indirection;
290167140Sbms             * thus, the attached object is always the aliased namespace node
291167140Sbms             */
292167140Sbms            if (ObjectType == ACPI_TYPE_LOCAL_ALIAS)
293167140Sbms            {
294167140Sbms                ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc);
295167140Sbms                *StackPtr = ObjDesc;
296167140Sbms                ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
297167140Sbms            }
298167140Sbms            break;
299167140Sbms
300167140Sbms
301167140Sbms        case ACPI_DESC_TYPE_OPERAND:
302167140Sbms
303167140Sbms            /* ACPI internal object */
304167140Sbms
305167340Sbms            ObjectType = ObjDesc->Common.Type;
306167340Sbms
307167340Sbms            /* Check for bad ACPI_OBJECT_TYPE */
308167340Sbms
309167340Sbms            if (!AcpiUtValidObjectType (ObjectType))
310167340Sbms            {
311167140Sbms                ACPI_ERROR ((AE_INFO,
312167340Sbms                    "Bad operand object type [%X]", ObjectType));
313167140Sbms
314167140Sbms                return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
315167140Sbms            }
316167140Sbms
317167140Sbms            if (ObjectType == (UINT8) ACPI_TYPE_LOCAL_REFERENCE)
318167140Sbms            {
319167140Sbms                /* Validate the Reference */
320167140Sbms
321167340Sbms                switch (ObjDesc->Reference.Class)
322167340Sbms                {
323167340Sbms                case ACPI_REFCLASS_DEBUG:
324167340Sbms
325167340Sbms                    TargetOp = AML_DEBUG_OP;
326167340Sbms
327167340Sbms                    /*lint -fallthrough */
328167340Sbms
329167340Sbms                case ACPI_REFCLASS_ARG:
330167340Sbms                case ACPI_REFCLASS_LOCAL:
331167340Sbms                case ACPI_REFCLASS_INDEX:
332167340Sbms                case ACPI_REFCLASS_REFOF:
333167340Sbms                case ACPI_REFCLASS_TABLE:    /* DdbHandle from LOAD_OP or LOAD_TABLE_OP */
334167340Sbms                case ACPI_REFCLASS_NAME:     /* Reference to a named object */
335167340Sbms
336167340Sbms                    ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
337167340Sbms                        "Operand is a Reference, Class [%s] %2.2X\n",
338167340Sbms                        AcpiUtGetReferenceName (ObjDesc),
339167340Sbms                        ObjDesc->Reference.Class));
340167340Sbms                    break;
341167340Sbms
342167340Sbms                default:
343167340Sbms
344167340Sbms                    ACPI_ERROR ((AE_INFO,
345167340Sbms                        "Unknown Reference Class %2.2X in %p",
346167340Sbms                        ObjDesc->Reference.Class, ObjDesc));
347167340Sbms
348167340Sbms                    return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
349167340Sbms                }
350167340Sbms            }
351167340Sbms            break;
352167340Sbms
353167340Sbms
354167340Sbms        default:
355167340Sbms
356167140Sbms            /* Invalid descriptor */
357167140Sbms
358167140Sbms            ACPI_ERROR ((AE_INFO, "Invalid descriptor %p [%s]",
359167140Sbms                ObjDesc, AcpiUtGetDescriptorName (ObjDesc)));
360167140Sbms
361167140Sbms            return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
362167140Sbms        }
363167140Sbms
364167140Sbms        /* Get one argument type, point to the next */
365167140Sbms
366167140Sbms        ThisArgType = GET_CURRENT_ARG_TYPE (ArgTypes);
367        INCREMENT_ARG_LIST (ArgTypes);
368
369        /*
370         * Handle cases where the object does not need to be
371         * resolved to a value
372         */
373        switch (ThisArgType)
374        {
375        case ARGI_REF_OR_STRING:        /* Can be a String or Reference */
376
377            if ((ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND) &&
378                (ObjDesc->Common.Type == ACPI_TYPE_STRING))
379            {
380                /*
381                 * String found - the string references a named object and
382                 * must be resolved to a node
383                 */
384                goto NextOperand;
385            }
386
387            /*
388             * Else not a string - fall through to the normal Reference
389             * case below
390             */
391            /*lint -fallthrough */
392
393        case ARGI_REFERENCE:            /* References: */
394        case ARGI_INTEGER_REF:
395        case ARGI_OBJECT_REF:
396        case ARGI_DEVICE_REF:
397        case ARGI_TARGETREF:     /* Allows implicit conversion rules before store */
398        case ARGI_FIXED_TARGET:  /* No implicit conversion before store to target */
399        case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion  */
400
401            /*
402             * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE
403             * A Namespace Node is OK as-is
404             */
405            if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED)
406            {
407                goto NextOperand;
408            }
409
410            Status = AcpiExCheckObjectType (ACPI_TYPE_LOCAL_REFERENCE,
411                            ObjectType, ObjDesc);
412            if (ACPI_FAILURE (Status))
413            {
414                return_ACPI_STATUS (Status);
415            }
416            goto NextOperand;
417
418
419        case ARGI_DATAREFOBJ:  /* Store operator only */
420
421            /*
422             * We don't want to resolve IndexOp reference objects during
423             * a store because this would be an implicit DeRefOf operation.
424             * Instead, we just want to store the reference object.
425             * -- All others must be resolved below.
426             */
427            if ((Opcode == AML_STORE_OP) &&
428                ((*StackPtr)->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
429                ((*StackPtr)->Reference.Class == ACPI_REFCLASS_INDEX))
430            {
431                goto NextOperand;
432            }
433            break;
434
435        default:
436            /* All cases covered above */
437            break;
438        }
439
440        /*
441         * Resolve this object to a value
442         */
443        Status = AcpiExResolveToValue (StackPtr, WalkState);
444        if (ACPI_FAILURE (Status))
445        {
446            return_ACPI_STATUS (Status);
447        }
448
449        /* Get the resolved object */
450
451        ObjDesc = *StackPtr;
452
453        /*
454         * Check the resulting object (value) type
455         */
456        switch (ThisArgType)
457        {
458        /*
459         * For the simple cases, only one type of resolved object
460         * is allowed
461         */
462        case ARGI_MUTEX:
463
464            /* Need an operand of type ACPI_TYPE_MUTEX */
465
466            TypeNeeded = ACPI_TYPE_MUTEX;
467            break;
468
469        case ARGI_EVENT:
470
471            /* Need an operand of type ACPI_TYPE_EVENT */
472
473            TypeNeeded = ACPI_TYPE_EVENT;
474            break;
475
476        case ARGI_PACKAGE:   /* Package */
477
478            /* Need an operand of type ACPI_TYPE_PACKAGE */
479
480            TypeNeeded = ACPI_TYPE_PACKAGE;
481            break;
482
483        case ARGI_ANYTYPE:
484
485            /* Any operand type will do */
486
487            TypeNeeded = ACPI_TYPE_ANY;
488            break;
489
490        case ARGI_DDBHANDLE:
491
492            /* Need an operand of type ACPI_TYPE_DDB_HANDLE */
493
494            TypeNeeded = ACPI_TYPE_LOCAL_REFERENCE;
495            break;
496
497
498        /*
499         * The more complex cases allow multiple resolved object types
500         */
501        case ARGI_INTEGER:
502
503            /*
504             * Need an operand of type ACPI_TYPE_INTEGER,
505             * But we can implicitly convert from a STRING or BUFFER
506             * Aka - "Implicit Source Operand Conversion"
507             */
508            Status = AcpiExConvertToInteger (ObjDesc, StackPtr, 16);
509            if (ACPI_FAILURE (Status))
510            {
511                if (Status == AE_TYPE)
512                {
513                    ACPI_ERROR ((AE_INFO,
514                        "Needed [Integer/String/Buffer], found [%s] %p",
515                        AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
516
517                    return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
518                }
519
520                return_ACPI_STATUS (Status);
521            }
522
523            if (ObjDesc != *StackPtr)
524            {
525                AcpiUtRemoveReference (ObjDesc);
526            }
527            goto NextOperand;
528
529
530        case ARGI_BUFFER:
531
532            /*
533             * Need an operand of type ACPI_TYPE_BUFFER,
534             * But we can implicitly convert from a STRING or INTEGER
535             * Aka - "Implicit Source Operand Conversion"
536             */
537            Status = AcpiExConvertToBuffer (ObjDesc, StackPtr);
538            if (ACPI_FAILURE (Status))
539            {
540                if (Status == AE_TYPE)
541                {
542                    ACPI_ERROR ((AE_INFO,
543                        "Needed [Integer/String/Buffer], found [%s] %p",
544                        AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
545
546                    return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
547                }
548
549                return_ACPI_STATUS (Status);
550            }
551
552            if (ObjDesc != *StackPtr)
553            {
554                AcpiUtRemoveReference (ObjDesc);
555            }
556            goto NextOperand;
557
558
559        case ARGI_STRING:
560
561            /*
562             * Need an operand of type ACPI_TYPE_STRING,
563             * But we can implicitly convert from a BUFFER or INTEGER
564             * Aka - "Implicit Source Operand Conversion"
565             */
566            Status = AcpiExConvertToString (ObjDesc, StackPtr,
567                        ACPI_IMPLICIT_CONVERT_HEX);
568            if (ACPI_FAILURE (Status))
569            {
570                if (Status == AE_TYPE)
571                {
572                    ACPI_ERROR ((AE_INFO,
573                        "Needed [Integer/String/Buffer], found [%s] %p",
574                        AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
575
576                    return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
577                }
578
579                return_ACPI_STATUS (Status);
580            }
581
582            if (ObjDesc != *StackPtr)
583            {
584                AcpiUtRemoveReference (ObjDesc);
585            }
586            goto NextOperand;
587
588
589        case ARGI_COMPUTEDATA:
590
591            /* Need an operand of type INTEGER, STRING or BUFFER */
592
593            switch (ObjDesc->Common.Type)
594            {
595            case ACPI_TYPE_INTEGER:
596            case ACPI_TYPE_STRING:
597            case ACPI_TYPE_BUFFER:
598
599                /* Valid operand */
600               break;
601
602            default:
603                ACPI_ERROR ((AE_INFO,
604                    "Needed [Integer/String/Buffer], found [%s] %p",
605                    AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
606
607                return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
608            }
609            goto NextOperand;
610
611
612        case ARGI_BUFFER_OR_STRING:
613
614            /* Need an operand of type STRING or BUFFER */
615
616            switch (ObjDesc->Common.Type)
617            {
618            case ACPI_TYPE_STRING:
619            case ACPI_TYPE_BUFFER:
620
621                /* Valid operand */
622               break;
623
624            case ACPI_TYPE_INTEGER:
625
626                /* Highest priority conversion is to type Buffer */
627
628                Status = AcpiExConvertToBuffer (ObjDesc, StackPtr);
629                if (ACPI_FAILURE (Status))
630                {
631                    return_ACPI_STATUS (Status);
632                }
633
634                if (ObjDesc != *StackPtr)
635                {
636                    AcpiUtRemoveReference (ObjDesc);
637                }
638                break;
639
640            default:
641                ACPI_ERROR ((AE_INFO,
642                    "Needed [Integer/String/Buffer], found [%s] %p",
643                    AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
644
645                return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
646            }
647            goto NextOperand;
648
649
650        case ARGI_DATAOBJECT:
651            /*
652             * ARGI_DATAOBJECT is only used by the SizeOf operator.
653             * Need a buffer, string, package, or RefOf reference.
654             *
655             * The only reference allowed here is a direct reference to
656             * a namespace node.
657             */
658            switch (ObjDesc->Common.Type)
659            {
660            case ACPI_TYPE_PACKAGE:
661            case ACPI_TYPE_STRING:
662            case ACPI_TYPE_BUFFER:
663            case ACPI_TYPE_LOCAL_REFERENCE:
664
665                /* Valid operand */
666                break;
667
668            default:
669                ACPI_ERROR ((AE_INFO,
670                    "Needed [Buffer/String/Package/Reference], found [%s] %p",
671                    AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
672
673                return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
674            }
675            goto NextOperand;
676
677
678        case ARGI_COMPLEXOBJ:
679
680            /* Need a buffer or package or (ACPI 2.0) String */
681
682            switch (ObjDesc->Common.Type)
683            {
684            case ACPI_TYPE_PACKAGE:
685            case ACPI_TYPE_STRING:
686            case ACPI_TYPE_BUFFER:
687
688                /* Valid operand */
689                break;
690
691            default:
692                ACPI_ERROR ((AE_INFO,
693                    "Needed [Buffer/String/Package], found [%s] %p",
694                    AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
695
696                return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
697            }
698            goto NextOperand;
699
700
701        case ARGI_REGION_OR_BUFFER: /* Used by Load() only */
702
703            /* Need an operand of type REGION or a BUFFER (which could be a resolved region field) */
704
705            switch (ObjDesc->Common.Type)
706            {
707            case ACPI_TYPE_BUFFER:
708            case ACPI_TYPE_REGION:
709
710                /* Valid operand */
711                break;
712
713            default:
714                ACPI_ERROR ((AE_INFO,
715                    "Needed [Region/Buffer], found [%s] %p",
716                    AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
717
718                return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
719            }
720            goto NextOperand;
721
722
723        case ARGI_DATAREFOBJ:
724
725            /* Used by the Store() operator only */
726
727            switch (ObjDesc->Common.Type)
728            {
729            case ACPI_TYPE_INTEGER:
730            case ACPI_TYPE_PACKAGE:
731            case ACPI_TYPE_STRING:
732            case ACPI_TYPE_BUFFER:
733            case ACPI_TYPE_BUFFER_FIELD:
734            case ACPI_TYPE_LOCAL_REFERENCE:
735            case ACPI_TYPE_LOCAL_REGION_FIELD:
736            case ACPI_TYPE_LOCAL_BANK_FIELD:
737            case ACPI_TYPE_LOCAL_INDEX_FIELD:
738            case ACPI_TYPE_DDB_HANDLE:
739
740                /* Valid operand */
741                break;
742
743            default:
744
745                if (AcpiGbl_EnableInterpreterSlack)
746                {
747                    /*
748                     * Enable original behavior of Store(), allowing any and all
749                     * objects as the source operand.  The ACPI spec does not
750                     * allow this, however.
751                     */
752                    break;
753                }
754
755                if (TargetOp == AML_DEBUG_OP)
756                {
757                    /* Allow store of any object to the Debug object */
758
759                    break;
760                }
761
762                ACPI_ERROR ((AE_INFO,
763                    "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p",
764                    AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
765
766                return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
767            }
768            goto NextOperand;
769
770
771        default:
772
773            /* Unknown type */
774
775            ACPI_ERROR ((AE_INFO,
776                "Internal - Unknown ARGI (required operand) type %X",
777                ThisArgType));
778
779            return_ACPI_STATUS (AE_BAD_PARAMETER);
780        }
781
782        /*
783         * Make sure that the original object was resolved to the
784         * required object type (Simple cases only).
785         */
786        Status = AcpiExCheckObjectType (TypeNeeded,
787                        (*StackPtr)->Common.Type, *StackPtr);
788        if (ACPI_FAILURE (Status))
789        {
790            return_ACPI_STATUS (Status);
791        }
792
793NextOperand:
794        /*
795         * If more operands needed, decrement StackPtr to point
796         * to next operand on stack
797         */
798        if (GET_CURRENT_ARG_TYPE (ArgTypes))
799        {
800            StackPtr--;
801        }
802    }
803
804    ACPI_DUMP_OPERANDS (WalkState->Operands,
805        AcpiPsGetOpcodeName (Opcode), WalkState->NumOperands);
806
807    return_ACPI_STATUS (Status);
808}
809
810
811