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