Import acpica-unix-20061109 from Intel.
[dragonfly.git] / sys / contrib / dev / acpica-unix-20061109 / interpreter / executer / exresop.c
1
2 /******************************************************************************
3  *
4  * Module Name: exresop - AML Interpreter operand/object resolution
5  *              $Revision: 1.93 $
6  *
7  *****************************************************************************/
8
9 /******************************************************************************
10  *
11  * 1. Copyright Notice
12  *
13  * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp.
14  * All rights reserved.
15  *
16  * 2. License
17  *
18  * 2.1. This is your license from Intel Corp. under its intellectual property
19  * rights.  You may have additional license terms from the party that provided
20  * you this software, covering your right to use that party's intellectual
21  * property rights.
22  *
23  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
24  * copy of the source code appearing in this file ("Covered Code") an
25  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
26  * base code distributed originally by Intel ("Original Intel Code") to copy,
27  * make derivatives, distribute, use and display any portion of the Covered
28  * Code in any form, with the right to sublicense such rights; and
29  *
30  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
31  * license (with the right to sublicense), under only those claims of Intel
32  * patents that are infringed by the Original Intel Code, to make, use, sell,
33  * offer to sell, and import the Covered Code and derivative works thereof
34  * solely to the minimum extent necessary to exercise the above copyright
35  * license, and in no event shall the patent license extend to any additions
36  * to or modifications of the Original Intel Code.  No other license or right
37  * is granted directly or by implication, estoppel or otherwise;
38  *
39  * The above copyright and patent license is granted only if the following
40  * conditions are met:
41  *
42  * 3. Conditions
43  *
44  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
45  * Redistribution of source code of any substantial portion of the Covered
46  * Code or modification with rights to further distribute source must include
47  * the above Copyright Notice, the above License, this list of Conditions,
48  * and the following Disclaimer and Export Compliance provision.  In addition,
49  * Licensee must cause all Covered Code to which Licensee contributes to
50  * contain a file documenting the changes Licensee made to create that Covered
51  * Code and the date of any change.  Licensee must include in that file the
52  * documentation of any changes made by any predecessor Licensee.  Licensee
53  * must include a prominent statement that the modification is derived,
54  * directly or indirectly, from Original Intel Code.
55  *
56  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
57  * Redistribution of source code of any substantial portion of the Covered
58  * Code or modification without rights to further distribute source must
59  * include the following Disclaimer and Export Compliance provision in the
60  * documentation and/or other materials provided with distribution.  In
61  * addition, Licensee may not authorize further sublicense of source of any
62  * portion of the Covered Code, and must include terms to the effect that the
63  * license from Licensee to its licensee is limited to the intellectual
64  * property embodied in the software Licensee provides to its licensee, and
65  * not to intellectual property embodied in modifications its licensee may
66  * make.
67  *
68  * 3.3. Redistribution of Executable. Redistribution in executable form of any
69  * substantial portion of the Covered Code or modification must reproduce the
70  * above Copyright Notice, and the following Disclaimer and Export Compliance
71  * provision in the documentation and/or other materials provided with the
72  * distribution.
73  *
74  * 3.4. Intel retains all right, title, and interest in and to the Original
75  * Intel Code.
76  *
77  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
78  * Intel shall be used in advertising or otherwise to promote the sale, use or
79  * other dealings in products derived from or relating to the Covered Code
80  * without prior written authorization from Intel.
81  *
82  * 4. Disclaimer and Export Compliance
83  *
84  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
85  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
86  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
87  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
88  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
89  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90  * PARTICULAR PURPOSE.
91  *
92  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
93  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
94  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
95  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
96  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
97  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
98  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99  * LIMITED REMEDY.
100  *
101  * 4.3. Licensee shall not export, either directly or indirectly, any of this
102  * software or system incorporating such software without first obtaining any
103  * required license or other approval from the U. S. Department of Commerce or
104  * any other agency or department of the United States Government.  In the
105  * event Licensee exports any such software from the United States or
106  * re-exports any such software from a foreign destination, Licensee shall
107  * ensure that the distribution and export/re-export of the software is in
108  * compliance with all laws, regulations, orders, or other restrictions of the
109  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
110  * any of its subsidiaries will export/re-export any technical data, process,
111  * software, or service, directly or indirectly, to any country for which the
112  * United States government or any agency thereof requires an export license,
113  * other governmental approval, or letter of assurance, without first obtaining
114  * such license, approval or letter.
115  *
116  *****************************************************************************/
117
118 #define __EXRESOP_C__
119
120 #include "acpi.h"
121 #include "amlcode.h"
122 #include "acparser.h"
123 #include "acinterp.h"
124 #include "acnamesp.h"
125
126
127 #define _COMPONENT          ACPI_EXECUTER
128         ACPI_MODULE_NAME    ("exresop")
129
130 /* Local prototypes */
131
132 static ACPI_STATUS
133 AcpiExCheckObjectType (
134     ACPI_OBJECT_TYPE        TypeNeeded,
135     ACPI_OBJECT_TYPE        ThisType,
136     void                    *Object);
137
138
139 /*******************************************************************************
140  *
141  * FUNCTION:    AcpiExCheckObjectType
142  *
143  * PARAMETERS:  TypeNeeded          Object type needed
144  *              ThisType            Actual object type
145  *              Object              Object pointer
146  *
147  * RETURN:      Status
148  *
149  * DESCRIPTION: Check required type against actual type
150  *
151  ******************************************************************************/
152
153 static ACPI_STATUS
154 AcpiExCheckObjectType (
155     ACPI_OBJECT_TYPE        TypeNeeded,
156     ACPI_OBJECT_TYPE        ThisType,
157     void                    *Object)
158 {
159     ACPI_FUNCTION_ENTRY ();
160
161
162     if (TypeNeeded == ACPI_TYPE_ANY)
163     {
164         /* All types OK, so we don't perform any typechecks */
165
166         return (AE_OK);
167     }
168
169     if (TypeNeeded == ACPI_TYPE_LOCAL_REFERENCE)
170     {
171         /*
172          * Allow the AML "Constant" opcodes (Zero, One, etc.) to be reference
173          * objects and thus allow them to be targets.  (As per the ACPI
174          * specification, a store to a constant is a noop.)
175          */
176         if ((ThisType == ACPI_TYPE_INTEGER) &&
177             (((ACPI_OPERAND_OBJECT *) Object)->Common.Flags & AOPOBJ_AML_CONSTANT))
178         {
179             return (AE_OK);
180         }
181     }
182
183     if (TypeNeeded != ThisType)
184     {
185         ACPI_ERROR ((AE_INFO,
186             "Needed type [%s], found [%s] %p",
187             AcpiUtGetTypeName (TypeNeeded),
188             AcpiUtGetTypeName (ThisType), Object));
189
190         return (AE_AML_OPERAND_TYPE);
191     }
192
193     return (AE_OK);
194 }
195
196
197 /*******************************************************************************
198  *
199  * FUNCTION:    AcpiExResolveOperands
200  *
201  * PARAMETERS:  Opcode              - Opcode being interpreted
202  *              StackPtr            - Pointer to the operand stack to be
203  *                                    resolved
204  *              WalkState           - Current state
205  *
206  * RETURN:      Status
207  *
208  * DESCRIPTION: Convert multiple input operands to the types required by the
209  *              target operator.
210  *
211  *      Each 5-bit group in ArgTypes represents one required
212  *      operand and indicates the required Type. The corresponding operand
213  *      will be converted to the required type if possible, otherwise we
214  *      abort with an exception.
215  *
216  ******************************************************************************/
217
218 ACPI_STATUS
219 AcpiExResolveOperands (
220     UINT16                  Opcode,
221     ACPI_OPERAND_OBJECT     **StackPtr,
222     ACPI_WALK_STATE         *WalkState)
223 {
224     ACPI_OPERAND_OBJECT     *ObjDesc;
225     ACPI_STATUS             Status = AE_OK;
226     UINT8                   ObjectType;
227     void                    *TempNode;
228     UINT32                  ArgTypes;
229     const ACPI_OPCODE_INFO  *OpInfo;
230     UINT32                  ThisArgType;
231     ACPI_OBJECT_TYPE        TypeNeeded;
232     UINT16                  TargetOp = 0;
233
234
235     ACPI_FUNCTION_TRACE_U32 (ExResolveOperands, Opcode);
236
237
238     OpInfo = AcpiPsGetOpcodeInfo (Opcode);
239     if (OpInfo->Class == AML_CLASS_UNKNOWN)
240     {
241         return_ACPI_STATUS (AE_AML_BAD_OPCODE);
242     }
243
244     ArgTypes = OpInfo->RuntimeArgs;
245     if (ArgTypes == ARGI_INVALID_OPCODE)
246     {
247         ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X",
248             Opcode));
249
250         return_ACPI_STATUS (AE_AML_INTERNAL);
251     }
252
253     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
254         "Opcode %X [%s] RequiredOperandTypes=%8.8X\n",
255         Opcode, OpInfo->Name, ArgTypes));
256
257     /*
258      * Normal exit is with (ArgTypes == 0) at end of argument list.
259      * Function will return an exception from within the loop upon
260      * finding an entry which is not (or cannot be converted
261      * to) the required type; if stack underflows; or upon
262      * finding a NULL stack entry (which should not happen).
263      */
264     while (GET_CURRENT_ARG_TYPE (ArgTypes))
265     {
266         if (!StackPtr || !*StackPtr)
267         {
268             ACPI_ERROR ((AE_INFO, "Null stack entry at %p",
269                 StackPtr));
270
271             return_ACPI_STATUS (AE_AML_INTERNAL);
272         }
273
274         /* Extract useful items */
275
276         ObjDesc = *StackPtr;
277
278         /* Decode the descriptor type */
279
280         switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
281         {
282         case ACPI_DESC_TYPE_NAMED:
283
284             /* Namespace Node */
285
286             ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
287
288             /*
289              * Resolve an alias object. The construction of these objects
290              * guarantees that there is only one level of alias indirection;
291              * thus, the attached object is always the aliased namespace node
292              */
293             if (ObjectType == ACPI_TYPE_LOCAL_ALIAS)
294             {
295                 ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc);
296                 *StackPtr = ObjDesc;
297                 ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
298             }
299             break;
300
301
302         case ACPI_DESC_TYPE_OPERAND:
303
304             /* ACPI internal object */
305
306             ObjectType = ACPI_GET_OBJECT_TYPE (ObjDesc);
307
308             /* Check for bad ACPI_OBJECT_TYPE */
309
310             if (!AcpiUtValidObjectType (ObjectType))
311             {
312                 ACPI_ERROR ((AE_INFO,
313                     "Bad operand object type [%X]",
314                     ObjectType));
315
316                 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
317             }
318
319             if (ObjectType == (UINT8) ACPI_TYPE_LOCAL_REFERENCE)
320             {
321                 /* Decode the Reference */
322
323                 OpInfo = AcpiPsGetOpcodeInfo (Opcode);
324                 if (OpInfo->Class == AML_CLASS_UNKNOWN)
325                 {
326                     return_ACPI_STATUS (AE_AML_BAD_OPCODE);
327                 }
328
329                 switch (ObjDesc->Reference.Opcode)
330                 {
331                 case AML_DEBUG_OP:
332                     TargetOp = AML_DEBUG_OP;
333
334                     /*lint -fallthrough */
335
336                 case AML_NAME_OP:
337                 case AML_INDEX_OP:
338                 case AML_REF_OF_OP:
339                 case AML_ARG_OP:
340                 case AML_LOCAL_OP:
341                 case AML_LOAD_OP: /* DdbHandle from LOAD_OP or LOAD_TABLE_OP */
342                 case AML_INT_NAMEPATH_OP: /* Reference to a named object */
343
344                     ACPI_DEBUG_ONLY_MEMBERS (ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
345                         "Operand is a Reference, RefOpcode [%s]\n",
346                         (AcpiPsGetOpcodeInfo (ObjDesc->Reference.Opcode))->Name)));
347                     break;
348
349                 default:
350                     ACPI_ERROR ((AE_INFO,
351                         "Operand is a Reference, Unknown Reference Opcode: %X",
352                         ObjDesc->Reference.Opcode));
353
354                     return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
355                 }
356             }
357             break;
358
359
360         default:
361
362             /* Invalid descriptor */
363
364             ACPI_ERROR ((AE_INFO,
365                 "Invalid descriptor %p [%s]",
366                 ObjDesc, AcpiUtGetDescriptorName (ObjDesc)));
367
368             return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
369         }
370
371         /* Get one argument type, point to the next */
372
373         ThisArgType = GET_CURRENT_ARG_TYPE (ArgTypes);
374         INCREMENT_ARG_LIST (ArgTypes);
375
376         /*
377          * Handle cases where the object does not need to be
378          * resolved to a value
379          */
380         switch (ThisArgType)
381         {
382         case ARGI_REF_OR_STRING:        /* Can be a String or Reference */
383
384             if ((ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND) &&
385                 (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_STRING))
386             {
387                 /*
388                  * String found - the string references a named object and
389                  * must be resolved to a node
390                  */
391                 goto NextOperand;
392             }
393
394             /*
395              * Else not a string - fall through to the normal Reference
396              * case below
397              */
398             /*lint -fallthrough */
399
400         case ARGI_REFERENCE:            /* References: */
401         case ARGI_INTEGER_REF:
402         case ARGI_OBJECT_REF:
403         case ARGI_DEVICE_REF:
404         case ARGI_TARGETREF:     /* Allows implicit conversion rules before store */
405         case ARGI_FIXED_TARGET:  /* No implicit conversion before store to target */
406         case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion  */
407
408             /*
409              * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE
410              * A Namespace Node is OK as-is
411              */
412             if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED)
413             {
414                 goto NextOperand;
415             }
416
417             Status = AcpiExCheckObjectType (ACPI_TYPE_LOCAL_REFERENCE,
418                             ObjectType, ObjDesc);
419             if (ACPI_FAILURE (Status))
420             {
421                 return_ACPI_STATUS (Status);
422             }
423
424             if (ObjDesc->Reference.Opcode == AML_NAME_OP)
425             {
426                 /* Convert a named reference to the actual named object */
427
428                 TempNode = ObjDesc->Reference.Object;
429                 AcpiUtRemoveReference (ObjDesc);
430                 (*StackPtr) = TempNode;
431             }
432             goto NextOperand;
433
434
435         case ARGI_DATAREFOBJ:  /* Store operator only */
436
437             /*
438              * We don't want to resolve IndexOp reference objects during
439              * a store because this would be an implicit DeRefOf operation.
440              * Instead, we just want to store the reference object.
441              * -- All others must be resolved below.
442              */
443             if ((Opcode == AML_STORE_OP) &&
444                 (ACPI_GET_OBJECT_TYPE (*StackPtr) == ACPI_TYPE_LOCAL_REFERENCE) &&
445                 ((*StackPtr)->Reference.Opcode == AML_INDEX_OP))
446             {
447                 goto NextOperand;
448             }
449             break;
450
451         default:
452             /* All cases covered above */
453             break;
454         }
455
456         /*
457          * Resolve this object to a value
458          */
459         Status = AcpiExResolveToValue (StackPtr, WalkState);
460         if (ACPI_FAILURE (Status))
461         {
462             return_ACPI_STATUS (Status);
463         }
464
465         /* Get the resolved object */
466
467         ObjDesc = *StackPtr;
468
469         /*
470          * Check the resulting object (value) type
471          */
472         switch (ThisArgType)
473         {
474         /*
475          * For the simple cases, only one type of resolved object
476          * is allowed
477          */
478         case ARGI_MUTEX:
479
480             /* Need an operand of type ACPI_TYPE_MUTEX */
481
482             TypeNeeded = ACPI_TYPE_MUTEX;
483             break;
484
485         case ARGI_EVENT:
486
487             /* Need an operand of type ACPI_TYPE_EVENT */
488
489             TypeNeeded = ACPI_TYPE_EVENT;
490             break;
491
492         case ARGI_PACKAGE:   /* Package */
493
494             /* Need an operand of type ACPI_TYPE_PACKAGE */
495
496             TypeNeeded = ACPI_TYPE_PACKAGE;
497             break;
498
499         case ARGI_ANYTYPE:
500
501             /* Any operand type will do */
502
503             TypeNeeded = ACPI_TYPE_ANY;
504             break;
505
506         case ARGI_DDBHANDLE:
507
508             /* Need an operand of type ACPI_TYPE_DDB_HANDLE */
509
510             TypeNeeded = ACPI_TYPE_LOCAL_REFERENCE;
511             break;
512
513
514         /*
515          * The more complex cases allow multiple resolved object types
516          */
517         case ARGI_INTEGER:
518
519             /*
520              * Need an operand of type ACPI_TYPE_INTEGER,
521              * But we can implicitly convert from a STRING or BUFFER
522              * Aka - "Implicit Source Operand Conversion"
523              */
524             Status = AcpiExConvertToInteger (ObjDesc, StackPtr, 16);
525             if (ACPI_FAILURE (Status))
526             {
527                 if (Status == AE_TYPE)
528                 {
529                     ACPI_ERROR ((AE_INFO,
530                         "Needed [Integer/String/Buffer], found [%s] %p",
531                         AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
532
533                     return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
534                 }
535
536                 return_ACPI_STATUS (Status);
537             }
538
539             if (ObjDesc != *StackPtr)
540             {
541                 AcpiUtRemoveReference (ObjDesc);
542             }
543             goto NextOperand;
544
545
546         case ARGI_BUFFER:
547
548             /*
549              * Need an operand of type ACPI_TYPE_BUFFER,
550              * But we can implicitly convert from a STRING or INTEGER
551              * Aka - "Implicit Source Operand Conversion"
552              */
553             Status = AcpiExConvertToBuffer (ObjDesc, StackPtr);
554             if (ACPI_FAILURE (Status))
555             {
556                 if (Status == AE_TYPE)
557                 {
558                     ACPI_ERROR ((AE_INFO,
559                         "Needed [Integer/String/Buffer], found [%s] %p",
560                         AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
561
562                     return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
563                 }
564
565                 return_ACPI_STATUS (Status);
566             }
567
568             if (ObjDesc != *StackPtr)
569             {
570                 AcpiUtRemoveReference (ObjDesc);
571             }
572             goto NextOperand;
573
574
575         case ARGI_STRING:
576
577             /*
578              * Need an operand of type ACPI_TYPE_STRING,
579              * But we can implicitly convert from a BUFFER or INTEGER
580              * Aka - "Implicit Source Operand Conversion"
581              */
582             Status = AcpiExConvertToString (ObjDesc, StackPtr,
583                         ACPI_IMPLICIT_CONVERT_HEX);
584             if (ACPI_FAILURE (Status))
585             {
586                 if (Status == AE_TYPE)
587                 {
588                     ACPI_ERROR ((AE_INFO,
589                         "Needed [Integer/String/Buffer], found [%s] %p",
590                         AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
591
592                     return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
593                 }
594
595                 return_ACPI_STATUS (Status);
596             }
597
598             if (ObjDesc != *StackPtr)
599             {
600                 AcpiUtRemoveReference (ObjDesc);
601             }
602             goto NextOperand;
603
604
605         case ARGI_COMPUTEDATA:
606
607             /* Need an operand of type INTEGER, STRING or BUFFER */
608
609             switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
610             {
611             case ACPI_TYPE_INTEGER:
612             case ACPI_TYPE_STRING:
613             case ACPI_TYPE_BUFFER:
614
615                 /* Valid operand */
616                break;
617
618             default:
619                 ACPI_ERROR ((AE_INFO,
620                     "Needed [Integer/String/Buffer], found [%s] %p",
621                     AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
622
623                 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
624             }
625             goto NextOperand;
626
627
628         case ARGI_BUFFER_OR_STRING:
629
630             /* Need an operand of type STRING or BUFFER */
631
632             switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
633             {
634             case ACPI_TYPE_STRING:
635             case ACPI_TYPE_BUFFER:
636
637                 /* Valid operand */
638                break;
639
640             case ACPI_TYPE_INTEGER:
641
642                 /* Highest priority conversion is to type Buffer */
643
644                 Status = AcpiExConvertToBuffer (ObjDesc, StackPtr);
645                 if (ACPI_FAILURE (Status))
646                 {
647                     return_ACPI_STATUS (Status);
648                 }
649
650                 if (ObjDesc != *StackPtr)
651                 {
652                     AcpiUtRemoveReference (ObjDesc);
653                 }
654                 break;
655
656             default:
657                 ACPI_ERROR ((AE_INFO,
658                     "Needed [Integer/String/Buffer], found [%s] %p",
659                     AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
660
661                 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
662             }
663             goto NextOperand;
664
665
666         case ARGI_DATAOBJECT:
667             /*
668              * ARGI_DATAOBJECT is only used by the SizeOf operator.
669              * Need a buffer, string, package, or RefOf reference.
670              *
671              * The only reference allowed here is a direct reference to
672              * a namespace node.
673              */
674             switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
675             {
676             case ACPI_TYPE_PACKAGE:
677             case ACPI_TYPE_STRING:
678             case ACPI_TYPE_BUFFER:
679             case ACPI_TYPE_LOCAL_REFERENCE:
680
681                 /* Valid operand */
682                 break;
683
684             default:
685                 ACPI_ERROR ((AE_INFO,
686                     "Needed [Buffer/String/Package/Reference], found [%s] %p",
687                     AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
688
689                 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
690             }
691             goto NextOperand;
692
693
694         case ARGI_COMPLEXOBJ:
695
696             /* Need a buffer or package or (ACPI 2.0) String */
697
698             switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
699             {
700             case ACPI_TYPE_PACKAGE:
701             case ACPI_TYPE_STRING:
702             case ACPI_TYPE_BUFFER:
703
704                 /* Valid operand */
705                 break;
706
707             default:
708                 ACPI_ERROR ((AE_INFO,
709                     "Needed [Buffer/String/Package], found [%s] %p",
710                     AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
711
712                 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
713             }
714             goto NextOperand;
715
716
717         case ARGI_REGION_OR_BUFFER: /* Used by Load() only */
718
719             /* Need an operand of type REGION or a BUFFER (which could be a resolved region field) */
720
721             switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
722             {
723             case ACPI_TYPE_BUFFER:
724             case ACPI_TYPE_REGION:
725
726                 /* Valid operand */
727                 break;
728
729             default:
730                 ACPI_ERROR ((AE_INFO,
731                     "Needed [Region/Buffer], found [%s] %p",
732                     AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
733
734                 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
735             }
736             goto NextOperand;
737
738
739         case ARGI_DATAREFOBJ:
740
741             /* Used by the Store() operator only */
742
743             switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
744             {
745             case ACPI_TYPE_INTEGER:
746             case ACPI_TYPE_PACKAGE:
747             case ACPI_TYPE_STRING:
748             case ACPI_TYPE_BUFFER:
749             case ACPI_TYPE_BUFFER_FIELD:
750             case ACPI_TYPE_LOCAL_REFERENCE:
751             case ACPI_TYPE_LOCAL_REGION_FIELD:
752             case ACPI_TYPE_LOCAL_BANK_FIELD:
753             case ACPI_TYPE_LOCAL_INDEX_FIELD:
754             case ACPI_TYPE_DDB_HANDLE:
755
756                 /* Valid operand */
757                 break;
758
759             default:
760
761                 if (AcpiGbl_EnableInterpreterSlack)
762                 {
763                     /*
764                      * Enable original behavior of Store(), allowing any and all
765                      * objects as the source operand.  The ACPI spec does not
766                      * allow this, however.
767                      */
768                     break;
769                 }
770
771                 if (TargetOp == AML_DEBUG_OP)
772                 {
773                     /* Allow store of any object to the Debug object */
774
775                     break;
776                 }
777
778                 ACPI_ERROR ((AE_INFO,
779                     "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p",
780                     AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
781
782                 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
783             }
784             goto NextOperand;
785
786
787         default:
788
789             /* Unknown type */
790
791             ACPI_ERROR ((AE_INFO,
792                 "Internal - Unknown ARGI (required operand) type %X",
793                 ThisArgType));
794
795             return_ACPI_STATUS (AE_BAD_PARAMETER);
796         }
797
798         /*
799          * Make sure that the original object was resolved to the
800          * required object type (Simple cases only).
801          */
802         Status = AcpiExCheckObjectType (TypeNeeded,
803                         ACPI_GET_OBJECT_TYPE (*StackPtr), *StackPtr);
804         if (ACPI_FAILURE (Status))
805         {
806             return_ACPI_STATUS (Status);
807         }
808
809 NextOperand:
810         /*
811          * If more operands needed, decrement StackPtr to point
812          * to next operand on stack
813          */
814         if (GET_CURRENT_ARG_TYPE (ArgTypes))
815         {
816             StackPtr--;
817         }
818     }
819
820     return_ACPI_STATUS (Status);
821 }
822
823