xref: /freebsd/sys/contrib/dev/acpica/components/executer/exresop.c (revision 193d9e768ba63fcfb187cfd17f461f7d41345048)
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 - 2017, 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 <contrib/dev/acpica/include/acpi.h>
153 #include <contrib/dev/acpica/include/accommon.h>
154 #include <contrib/dev/acpica/include/amlcode.h>
155 #include <contrib/dev/acpica/include/acparser.h>
156 #include <contrib/dev/acpica/include/acinterp.h>
157 #include <contrib/dev/acpica/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_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion  */
433         case ARGI_STORE_TARGET:
434 
435             /*
436              * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE
437              * A Namespace Node is OK as-is
438              */
439             if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED)
440             {
441                 goto NextOperand;
442             }
443 
444             Status = AcpiExCheckObjectType (
445                 ACPI_TYPE_LOCAL_REFERENCE, ObjectType, ObjDesc);
446             if (ACPI_FAILURE (Status))
447             {
448                 return_ACPI_STATUS (Status);
449             }
450             goto NextOperand;
451 
452         case ARGI_DATAREFOBJ:  /* Store operator only */
453             /*
454              * We don't want to resolve IndexOp reference objects during
455              * a store because this would be an implicit DeRefOf operation.
456              * Instead, we just want to store the reference object.
457              * -- All others must be resolved below.
458              */
459             if ((Opcode == AML_STORE_OP) &&
460                 ((*StackPtr)->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
461                 ((*StackPtr)->Reference.Class == ACPI_REFCLASS_INDEX))
462             {
463                 goto NextOperand;
464             }
465             break;
466 
467         default:
468 
469             /* All cases covered above */
470 
471             break;
472         }
473 
474         /*
475          * Resolve this object to a value
476          */
477         Status = AcpiExResolveToValue (StackPtr, WalkState);
478         if (ACPI_FAILURE (Status))
479         {
480             return_ACPI_STATUS (Status);
481         }
482 
483         /* Get the resolved object */
484 
485         ObjDesc = *StackPtr;
486 
487         /*
488          * Check the resulting object (value) type
489          */
490         switch (ThisArgType)
491         {
492         /*
493          * For the simple cases, only one type of resolved object
494          * is allowed
495          */
496         case ARGI_MUTEX:
497 
498             /* Need an operand of type ACPI_TYPE_MUTEX */
499 
500             TypeNeeded = ACPI_TYPE_MUTEX;
501             break;
502 
503         case ARGI_EVENT:
504 
505             /* Need an operand of type ACPI_TYPE_EVENT */
506 
507             TypeNeeded = ACPI_TYPE_EVENT;
508             break;
509 
510         case ARGI_PACKAGE:   /* Package */
511 
512             /* Need an operand of type ACPI_TYPE_PACKAGE */
513 
514             TypeNeeded = ACPI_TYPE_PACKAGE;
515             break;
516 
517         case ARGI_ANYTYPE:
518 
519             /* Any operand type will do */
520 
521             TypeNeeded = ACPI_TYPE_ANY;
522             break;
523 
524         case ARGI_DDBHANDLE:
525 
526             /* Need an operand of type ACPI_TYPE_DDB_HANDLE */
527 
528             TypeNeeded = ACPI_TYPE_LOCAL_REFERENCE;
529             break;
530 
531 
532         /*
533          * The more complex cases allow multiple resolved object types
534          */
535         case ARGI_INTEGER:
536 
537             /*
538              * Need an operand of type ACPI_TYPE_INTEGER, but we can
539              * implicitly convert from a STRING or BUFFER.
540              *
541              * Known as "Implicit Source Operand Conversion"
542              */
543             Status = AcpiExConvertToInteger (ObjDesc, StackPtr,
544                 ACPI_STRTOUL_BASE16);
545             if (ACPI_FAILURE (Status))
546             {
547                 if (Status == AE_TYPE)
548                 {
549                     ACPI_ERROR ((AE_INFO,
550                         "Needed [Integer/String/Buffer], found [%s] %p",
551                         AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
552 
553                     return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
554                 }
555 
556                 return_ACPI_STATUS (Status);
557             }
558 
559             if (ObjDesc != *StackPtr)
560             {
561                 AcpiUtRemoveReference (ObjDesc);
562             }
563             goto NextOperand;
564 
565         case ARGI_BUFFER:
566             /*
567              * Need an operand of type ACPI_TYPE_BUFFER,
568              * But we can implicitly convert from a STRING or INTEGER
569              * Aka - "Implicit Source Operand Conversion"
570              */
571             Status = AcpiExConvertToBuffer (ObjDesc, StackPtr);
572             if (ACPI_FAILURE (Status))
573             {
574                 if (Status == AE_TYPE)
575                 {
576                     ACPI_ERROR ((AE_INFO,
577                         "Needed [Integer/String/Buffer], found [%s] %p",
578                         AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
579 
580                     return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
581                 }
582 
583                 return_ACPI_STATUS (Status);
584             }
585 
586             if (ObjDesc != *StackPtr)
587             {
588                 AcpiUtRemoveReference (ObjDesc);
589             }
590             goto NextOperand;
591 
592         case ARGI_STRING:
593             /*
594              * Need an operand of type ACPI_TYPE_STRING,
595              * But we can implicitly convert from a BUFFER or INTEGER
596              * Aka - "Implicit Source Operand Conversion"
597              */
598             Status = AcpiExConvertToString (
599                 ObjDesc, StackPtr, ACPI_IMPLICIT_CONVERT_HEX);
600             if (ACPI_FAILURE (Status))
601             {
602                 if (Status == AE_TYPE)
603                 {
604                     ACPI_ERROR ((AE_INFO,
605                         "Needed [Integer/String/Buffer], found [%s] %p",
606                         AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
607 
608                     return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
609                 }
610 
611                 return_ACPI_STATUS (Status);
612             }
613 
614             if (ObjDesc != *StackPtr)
615             {
616                 AcpiUtRemoveReference (ObjDesc);
617             }
618             goto NextOperand;
619 
620         case ARGI_COMPUTEDATA:
621 
622             /* Need an operand of type INTEGER, STRING or BUFFER */
623 
624             switch (ObjDesc->Common.Type)
625             {
626             case ACPI_TYPE_INTEGER:
627             case ACPI_TYPE_STRING:
628             case ACPI_TYPE_BUFFER:
629 
630                 /* Valid operand */
631                break;
632 
633             default:
634                 ACPI_ERROR ((AE_INFO,
635                     "Needed [Integer/String/Buffer], found [%s] %p",
636                     AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
637 
638                 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
639             }
640             goto NextOperand;
641 
642         case ARGI_BUFFER_OR_STRING:
643 
644             /* Need an operand of type STRING or BUFFER */
645 
646             switch (ObjDesc->Common.Type)
647             {
648             case ACPI_TYPE_STRING:
649             case ACPI_TYPE_BUFFER:
650 
651                 /* Valid operand */
652                break;
653 
654             case ACPI_TYPE_INTEGER:
655 
656                 /* Highest priority conversion is to type Buffer */
657 
658                 Status = AcpiExConvertToBuffer (ObjDesc, StackPtr);
659                 if (ACPI_FAILURE (Status))
660                 {
661                     return_ACPI_STATUS (Status);
662                 }
663 
664                 if (ObjDesc != *StackPtr)
665                 {
666                     AcpiUtRemoveReference (ObjDesc);
667                 }
668                 break;
669 
670             default:
671                 ACPI_ERROR ((AE_INFO,
672                     "Needed [Integer/String/Buffer], found [%s] %p",
673                     AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
674 
675                 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
676             }
677             goto NextOperand;
678 
679         case ARGI_DATAOBJECT:
680             /*
681              * ARGI_DATAOBJECT is only used by the SizeOf operator.
682              * Need a buffer, string, package, or RefOf reference.
683              *
684              * The only reference allowed here is a direct reference to
685              * a namespace node.
686              */
687             switch (ObjDesc->Common.Type)
688             {
689             case ACPI_TYPE_PACKAGE:
690             case ACPI_TYPE_STRING:
691             case ACPI_TYPE_BUFFER:
692             case ACPI_TYPE_LOCAL_REFERENCE:
693 
694                 /* Valid operand */
695                 break;
696 
697             default:
698 
699                 ACPI_ERROR ((AE_INFO,
700                     "Needed [Buffer/String/Package/Reference], found [%s] %p",
701                     AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
702 
703                 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
704             }
705             goto NextOperand;
706 
707         case ARGI_COMPLEXOBJ:
708 
709             /* Need a buffer or package or (ACPI 2.0) String */
710 
711             switch (ObjDesc->Common.Type)
712             {
713             case ACPI_TYPE_PACKAGE:
714             case ACPI_TYPE_STRING:
715             case ACPI_TYPE_BUFFER:
716 
717                 /* Valid operand */
718                 break;
719 
720             default:
721 
722                 ACPI_ERROR ((AE_INFO,
723                     "Needed [Buffer/String/Package], found [%s] %p",
724                     AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
725 
726                 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
727             }
728             goto NextOperand;
729 
730         case ARGI_REGION_OR_BUFFER: /* Used by Load() only */
731 
732             /*
733              * Need an operand of type REGION or a BUFFER
734              * (which could be a resolved region field)
735              */
736             switch (ObjDesc->Common.Type)
737             {
738             case ACPI_TYPE_BUFFER:
739             case ACPI_TYPE_REGION:
740 
741                 /* Valid operand */
742                 break;
743 
744             default:
745 
746                 ACPI_ERROR ((AE_INFO,
747                     "Needed [Region/Buffer], found [%s] %p",
748                     AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
749 
750                 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
751             }
752             goto NextOperand;
753 
754         case ARGI_DATAREFOBJ:
755 
756             /* Used by the Store() operator only */
757 
758             switch (ObjDesc->Common.Type)
759             {
760             case ACPI_TYPE_INTEGER:
761             case ACPI_TYPE_PACKAGE:
762             case ACPI_TYPE_STRING:
763             case ACPI_TYPE_BUFFER:
764             case ACPI_TYPE_BUFFER_FIELD:
765             case ACPI_TYPE_LOCAL_REFERENCE:
766             case ACPI_TYPE_LOCAL_REGION_FIELD:
767             case ACPI_TYPE_LOCAL_BANK_FIELD:
768             case ACPI_TYPE_LOCAL_INDEX_FIELD:
769             case ACPI_TYPE_DDB_HANDLE:
770 
771                 /* Valid operand */
772                 break;
773 
774             default:
775 
776                 if (AcpiGbl_EnableInterpreterSlack)
777                 {
778                     /*
779                      * Enable original behavior of Store(), allowing any
780                      * and all objects as the source operand. The ACPI
781                      * spec does not allow this, however.
782                      */
783                     break;
784                 }
785 
786                 if (TargetOp == AML_DEBUG_OP)
787                 {
788                     /* Allow store of any object to the Debug object */
789 
790                     break;
791                 }
792 
793                 ACPI_ERROR ((AE_INFO,
794                     "Needed Integer/Buffer/String/Package/Ref/Ddb]"
795                     ", found [%s] %p",
796                     AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
797 
798                 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
799             }
800             goto NextOperand;
801 
802         default:
803 
804             /* Unknown type */
805 
806             ACPI_ERROR ((AE_INFO,
807                 "Internal - Unknown ARGI (required operand) type 0x%X",
808                 ThisArgType));
809 
810             return_ACPI_STATUS (AE_BAD_PARAMETER);
811         }
812 
813         /*
814          * Make sure that the original object was resolved to the
815          * required object type (Simple cases only).
816          */
817         Status = AcpiExCheckObjectType (
818             TypeNeeded, (*StackPtr)->Common.Type, *StackPtr);
819         if (ACPI_FAILURE (Status))
820         {
821             return_ACPI_STATUS (Status);
822         }
823 
824 NextOperand:
825         /*
826          * If more operands needed, decrement StackPtr to point
827          * to next operand on stack
828          */
829         if (GET_CURRENT_ARG_TYPE (ArgTypes))
830         {
831             StackPtr--;
832         }
833     }
834 
835     ACPI_DUMP_OPERANDS (WalkState->Operands,
836         AcpiPsGetOpcodeName (Opcode), WalkState->NumOperands);
837 
838     return_ACPI_STATUS (Status);
839 }
840