xref: /haiku/src/add-ons/kernel/bus_managers/acpi/acpica/components/executer/exconvrt.c (revision a3e794ae459fec76826407f8ba8c94cd3535f128)
1 /******************************************************************************
2  *
3  * Module Name: exconvrt - Object conversion routines
4  *
5  *****************************************************************************/
6 
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2016, 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 #include "acpi.h"
117 #include "accommon.h"
118 #include "acinterp.h"
119 #include "amlcode.h"
120 
121 
122 #define _COMPONENT          ACPI_EXECUTER
123         ACPI_MODULE_NAME    ("exconvrt")
124 
125 /* Local prototypes */
126 
127 static UINT32
128 AcpiExConvertToAscii (
129     UINT64                  Integer,
130     UINT16                  Base,
131     UINT8                   *String,
132     UINT8                   MaxLength);
133 
134 
135 /*******************************************************************************
136  *
137  * FUNCTION:    AcpiExConvertToInteger
138  *
139  * PARAMETERS:  ObjDesc         - Object to be converted. Must be an
140  *                                Integer, Buffer, or String
141  *              ResultDesc      - Where the new Integer object is returned
142  *              Flags           - Used for string conversion
143  *
144  * RETURN:      Status
145  *
146  * DESCRIPTION: Convert an ACPI Object to an integer.
147  *
148  ******************************************************************************/
149 
150 ACPI_STATUS
151 AcpiExConvertToInteger (
152     ACPI_OPERAND_OBJECT     *ObjDesc,
153     ACPI_OPERAND_OBJECT     **ResultDesc,
154     UINT32                  Flags)
155 {
156     ACPI_OPERAND_OBJECT     *ReturnDesc;
157     UINT8                   *Pointer;
158     UINT64                  Result;
159     UINT32                  i;
160     UINT32                  Count;
161     ACPI_STATUS             Status;
162 
163 
164     ACPI_FUNCTION_TRACE_PTR (ExConvertToInteger, ObjDesc);
165 
166 
167     switch (ObjDesc->Common.Type)
168     {
169     case ACPI_TYPE_INTEGER:
170 
171         /* No conversion necessary */
172 
173         *ResultDesc = ObjDesc;
174         return_ACPI_STATUS (AE_OK);
175 
176     case ACPI_TYPE_BUFFER:
177     case ACPI_TYPE_STRING:
178 
179         /* Note: Takes advantage of common buffer/string fields */
180 
181         Pointer = ObjDesc->Buffer.Pointer;
182         Count   = ObjDesc->Buffer.Length;
183         break;
184 
185     default:
186 
187         return_ACPI_STATUS (AE_TYPE);
188     }
189 
190     /*
191      * Convert the buffer/string to an integer. Note that both buffers and
192      * strings are treated as raw data - we don't convert ascii to hex for
193      * strings.
194      *
195      * There are two terminating conditions for the loop:
196      * 1) The size of an integer has been reached, or
197      * 2) The end of the buffer or string has been reached
198      */
199     Result = 0;
200 
201     /* String conversion is different than Buffer conversion */
202 
203     switch (ObjDesc->Common.Type)
204     {
205     case ACPI_TYPE_STRING:
206         /*
207          * Convert string to an integer - for most cases, the string must be
208          * hexadecimal as per the ACPI specification. The only exception (as
209          * of ACPI 3.0) is that the ToInteger() operator allows both decimal
210          * and hexadecimal strings (hex prefixed with "0x").
211          */
212         Status = AcpiUtStrtoul64 ((char *) Pointer, Flags, &Result);
213         if (ACPI_FAILURE (Status))
214         {
215             return_ACPI_STATUS (Status);
216         }
217         break;
218 
219     case ACPI_TYPE_BUFFER:
220 
221         /* Check for zero-length buffer */
222 
223         if (!Count)
224         {
225             return_ACPI_STATUS (AE_AML_BUFFER_LIMIT);
226         }
227 
228         /* Transfer no more than an integer's worth of data */
229 
230         if (Count > AcpiGbl_IntegerByteWidth)
231         {
232             Count = AcpiGbl_IntegerByteWidth;
233         }
234 
235         /*
236          * Convert buffer to an integer - we simply grab enough raw data
237          * from the buffer to fill an integer
238          */
239         for (i = 0; i < Count; i++)
240         {
241             /*
242              * Get next byte and shift it into the Result.
243              * Little endian is used, meaning that the first byte of the buffer
244              * is the LSB of the integer
245              */
246             Result |= (((UINT64) Pointer[i]) << (i * 8));
247         }
248         break;
249 
250     default:
251 
252         /* No other types can get here */
253 
254         break;
255     }
256 
257     /* Create a new integer */
258 
259     ReturnDesc = AcpiUtCreateIntegerObject (Result);
260     if (!ReturnDesc)
261     {
262         return_ACPI_STATUS (AE_NO_MEMORY);
263     }
264 
265     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n",
266         ACPI_FORMAT_UINT64 (Result)));
267 
268     /* Save the Result */
269 
270     (void) AcpiExTruncateFor32bitTable (ReturnDesc);
271     *ResultDesc = ReturnDesc;
272     return_ACPI_STATUS (AE_OK);
273 }
274 
275 
276 /*******************************************************************************
277  *
278  * FUNCTION:    AcpiExConvertToBuffer
279  *
280  * PARAMETERS:  ObjDesc         - Object to be converted. Must be an
281  *                                Integer, Buffer, or String
282  *              ResultDesc      - Where the new buffer object is returned
283  *
284  * RETURN:      Status
285  *
286  * DESCRIPTION: Convert an ACPI Object to a Buffer
287  *
288  ******************************************************************************/
289 
290 ACPI_STATUS
291 AcpiExConvertToBuffer (
292     ACPI_OPERAND_OBJECT     *ObjDesc,
293     ACPI_OPERAND_OBJECT     **ResultDesc)
294 {
295     ACPI_OPERAND_OBJECT     *ReturnDesc;
296     UINT8                   *NewBuf;
297 
298 
299     ACPI_FUNCTION_TRACE_PTR (ExConvertToBuffer, ObjDesc);
300 
301 
302     switch (ObjDesc->Common.Type)
303     {
304     case ACPI_TYPE_BUFFER:
305 
306         /* No conversion necessary */
307 
308         *ResultDesc = ObjDesc;
309         return_ACPI_STATUS (AE_OK);
310 
311 
312     case ACPI_TYPE_INTEGER:
313         /*
314          * Create a new Buffer object.
315          * Need enough space for one integer
316          */
317         ReturnDesc = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth);
318         if (!ReturnDesc)
319         {
320             return_ACPI_STATUS (AE_NO_MEMORY);
321         }
322 
323         /* Copy the integer to the buffer, LSB first */
324 
325         NewBuf = ReturnDesc->Buffer.Pointer;
326         memcpy (NewBuf, &ObjDesc->Integer.Value, AcpiGbl_IntegerByteWidth);
327         break;
328 
329     case ACPI_TYPE_STRING:
330         /*
331          * Create a new Buffer object
332          * Size will be the string length
333          *
334          * NOTE: Add one to the string length to include the null terminator.
335          * The ACPI spec is unclear on this subject, but there is existing
336          * ASL/AML code that depends on the null being transferred to the new
337          * buffer.
338          */
339         ReturnDesc = AcpiUtCreateBufferObject ((ACPI_SIZE)
340             ObjDesc->String.Length + 1);
341         if (!ReturnDesc)
342         {
343             return_ACPI_STATUS (AE_NO_MEMORY);
344         }
345 
346         /* Copy the string to the buffer */
347 
348         NewBuf = ReturnDesc->Buffer.Pointer;
349         strncpy ((char *) NewBuf, (char *) ObjDesc->String.Pointer,
350             ObjDesc->String.Length);
351         break;
352 
353     default:
354 
355         return_ACPI_STATUS (AE_TYPE);
356     }
357 
358     /* Mark buffer initialized */
359 
360     ReturnDesc->Common.Flags |= AOPOBJ_DATA_VALID;
361     *ResultDesc = ReturnDesc;
362     return_ACPI_STATUS (AE_OK);
363 }
364 
365 
366 /*******************************************************************************
367  *
368  * FUNCTION:    AcpiExConvertToAscii
369  *
370  * PARAMETERS:  Integer         - Value to be converted
371  *              Base            - ACPI_STRING_DECIMAL or ACPI_STRING_HEX
372  *              String          - Where the string is returned
373  *              DataWidth       - Size of data item to be converted, in bytes
374  *
375  * RETURN:      Actual string length
376  *
377  * DESCRIPTION: Convert an ACPI Integer to a hex or decimal string
378  *
379  ******************************************************************************/
380 
381 static UINT32
382 AcpiExConvertToAscii (
383     UINT64                  Integer,
384     UINT16                  Base,
385     UINT8                   *String,
386     UINT8                   DataWidth)
387 {
388     UINT64                  Digit;
389     UINT32                  i;
390     UINT32                  j;
391     UINT32                  k = 0;
392     UINT32                  HexLength;
393     UINT32                  DecimalLength;
394     UINT32                  Remainder;
395     BOOLEAN                 SupressZeros;
396 
397 
398     ACPI_FUNCTION_ENTRY ();
399 
400 
401     switch (Base)
402     {
403     case 10:
404 
405         /* Setup max length for the decimal number */
406 
407         switch (DataWidth)
408         {
409         case 1:
410 
411             DecimalLength = ACPI_MAX8_DECIMAL_DIGITS;
412             break;
413 
414         case 4:
415 
416             DecimalLength = ACPI_MAX32_DECIMAL_DIGITS;
417             break;
418 
419         case 8:
420         default:
421 
422             DecimalLength = ACPI_MAX64_DECIMAL_DIGITS;
423             break;
424         }
425 
426         SupressZeros = TRUE;     /* No leading zeros */
427         Remainder = 0;
428 
429         for (i = DecimalLength; i > 0; i--)
430         {
431             /* Divide by nth factor of 10 */
432 
433             Digit = Integer;
434             for (j = 0; j < i; j++)
435             {
436                 (void) AcpiUtShortDivide (Digit, 10, &Digit, &Remainder);
437             }
438 
439             /* Handle leading zeros */
440 
441             if (Remainder != 0)
442             {
443                 SupressZeros = FALSE;
444             }
445 
446             if (!SupressZeros)
447             {
448                 String[k] = (UINT8) (ACPI_ASCII_ZERO + Remainder);
449                 k++;
450             }
451         }
452         break;
453 
454     case 16:
455 
456         /* HexLength: 2 ascii hex chars per data byte */
457 
458         HexLength = ACPI_MUL_2 (DataWidth);
459         for (i = 0, j = (HexLength-1); i < HexLength; i++, j--)
460         {
461             /* Get one hex digit, most significant digits first */
462 
463             String[k] = (UINT8)
464                 AcpiUtHexToAsciiChar (Integer, ACPI_MUL_4 (j));
465             k++;
466         }
467         break;
468 
469     default:
470         return (0);
471     }
472 
473     /*
474      * Since leading zeros are suppressed, we must check for the case where
475      * the integer equals 0
476      *
477      * Finally, null terminate the string and return the length
478      */
479     if (!k)
480     {
481         String [0] = ACPI_ASCII_ZERO;
482         k = 1;
483     }
484 
485     String [k] = 0;
486     return ((UINT32) k);
487 }
488 
489 
490 /*******************************************************************************
491  *
492  * FUNCTION:    AcpiExConvertToString
493  *
494  * PARAMETERS:  ObjDesc         - Object to be converted. Must be an
495  *                                Integer, Buffer, or String
496  *              ResultDesc      - Where the string object is returned
497  *              Type            - String flags (base and conversion type)
498  *
499  * RETURN:      Status
500  *
501  * DESCRIPTION: Convert an ACPI Object to a string
502  *
503  ******************************************************************************/
504 
505 ACPI_STATUS
506 AcpiExConvertToString (
507     ACPI_OPERAND_OBJECT     *ObjDesc,
508     ACPI_OPERAND_OBJECT     **ResultDesc,
509     UINT32                  Type)
510 {
511     ACPI_OPERAND_OBJECT     *ReturnDesc;
512     UINT8                   *NewBuf;
513     UINT32                  i;
514     UINT32                  StringLength = 0;
515     UINT16                  Base = 16;
516     UINT8                   Separator = ',';
517 
518 
519     ACPI_FUNCTION_TRACE_PTR (ExConvertToString, ObjDesc);
520 
521 
522     switch (ObjDesc->Common.Type)
523     {
524     case ACPI_TYPE_STRING:
525 
526         /* No conversion necessary */
527 
528         *ResultDesc = ObjDesc;
529         return_ACPI_STATUS (AE_OK);
530 
531     case ACPI_TYPE_INTEGER:
532 
533         switch (Type)
534         {
535         case ACPI_EXPLICIT_CONVERT_DECIMAL:
536 
537             /* Make room for maximum decimal number */
538 
539             StringLength = ACPI_MAX_DECIMAL_DIGITS;
540             Base = 10;
541             break;
542 
543         default:
544 
545             /* Two hex string characters for each integer byte */
546 
547             StringLength = ACPI_MUL_2 (AcpiGbl_IntegerByteWidth);
548             break;
549         }
550 
551         /*
552          * Create a new String
553          * Need enough space for one ASCII integer (plus null terminator)
554          */
555         ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength);
556         if (!ReturnDesc)
557         {
558             return_ACPI_STATUS (AE_NO_MEMORY);
559         }
560 
561         NewBuf = ReturnDesc->Buffer.Pointer;
562 
563         /* Convert integer to string */
564 
565         StringLength = AcpiExConvertToAscii (
566             ObjDesc->Integer.Value, Base, NewBuf, AcpiGbl_IntegerByteWidth);
567 
568         /* Null terminate at the correct place */
569 
570         ReturnDesc->String.Length = StringLength;
571         NewBuf [StringLength] = 0;
572         break;
573 
574     case ACPI_TYPE_BUFFER:
575 
576         /* Setup string length, base, and separator */
577 
578         switch (Type)
579         {
580         case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by ToDecimalString */
581             /*
582              * From ACPI: "If Data is a buffer, it is converted to a string of
583              * decimal values separated by commas."
584              */
585             Base = 10;
586 
587             /*
588              * Calculate the final string length. Individual string values
589              * are variable length (include separator for each)
590              */
591             for (i = 0; i < ObjDesc->Buffer.Length; i++)
592             {
593                 if (ObjDesc->Buffer.Pointer[i] >= 100)
594                 {
595                     StringLength += 4;
596                 }
597                 else if (ObjDesc->Buffer.Pointer[i] >= 10)
598                 {
599                     StringLength += 3;
600                 }
601                 else
602                 {
603                     StringLength += 2;
604                 }
605             }
606             break;
607 
608         case ACPI_IMPLICIT_CONVERT_HEX:
609             /*
610              * From the ACPI spec:
611              *"The entire contents of the buffer are converted to a string of
612              * two-character hexadecimal numbers, each separated by a space."
613              */
614             Separator = ' ';
615             StringLength = (ObjDesc->Buffer.Length * 3);
616             break;
617 
618         case ACPI_EXPLICIT_CONVERT_HEX:     /* Used by ToHexString */
619             /*
620              * From ACPI: "If Data is a buffer, it is converted to a string of
621              * hexadecimal values separated by commas."
622              */
623             StringLength = (ObjDesc->Buffer.Length * 3);
624             break;
625 
626         default:
627             return_ACPI_STATUS (AE_BAD_PARAMETER);
628         }
629 
630         /*
631          * Create a new string object and string buffer
632          * (-1 because of extra separator included in StringLength from above)
633          * Allow creation of zero-length strings from zero-length buffers.
634          */
635         if (StringLength)
636         {
637             StringLength--;
638         }
639 
640         ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength);
641         if (!ReturnDesc)
642         {
643             return_ACPI_STATUS (AE_NO_MEMORY);
644         }
645 
646         NewBuf = ReturnDesc->Buffer.Pointer;
647 
648         /*
649          * Convert buffer bytes to hex or decimal values
650          * (separated by commas or spaces)
651          */
652         for (i = 0; i < ObjDesc->Buffer.Length; i++)
653         {
654             NewBuf += AcpiExConvertToAscii (
655                 (UINT64) ObjDesc->Buffer.Pointer[i], Base, NewBuf, 1);
656             *NewBuf++ = Separator; /* each separated by a comma or space */
657         }
658 
659         /*
660          * Null terminate the string
661          * (overwrites final comma/space from above)
662          */
663         if (ObjDesc->Buffer.Length)
664         {
665             NewBuf--;
666         }
667         *NewBuf = 0;
668         break;
669 
670     default:
671 
672         return_ACPI_STATUS (AE_TYPE);
673     }
674 
675     *ResultDesc = ReturnDesc;
676     return_ACPI_STATUS (AE_OK);
677 }
678 
679 
680 /*******************************************************************************
681  *
682  * FUNCTION:    AcpiExConvertToTargetType
683  *
684  * PARAMETERS:  DestinationType     - Current type of the destination
685  *              SourceDesc          - Source object to be converted.
686  *              ResultDesc          - Where the converted object is returned
687  *              WalkState           - Current method state
688  *
689  * RETURN:      Status
690  *
691  * DESCRIPTION: Implements "implicit conversion" rules for storing an object.
692  *
693  ******************************************************************************/
694 
695 ACPI_STATUS
696 AcpiExConvertToTargetType (
697     ACPI_OBJECT_TYPE        DestinationType,
698     ACPI_OPERAND_OBJECT     *SourceDesc,
699     ACPI_OPERAND_OBJECT     **ResultDesc,
700     ACPI_WALK_STATE         *WalkState)
701 {
702     ACPI_STATUS             Status = AE_OK;
703 
704 
705     ACPI_FUNCTION_TRACE (ExConvertToTargetType);
706 
707 
708     /* Default behavior */
709 
710     *ResultDesc = SourceDesc;
711 
712     /*
713      * If required by the target,
714      * perform implicit conversion on the source before we store it.
715      */
716     switch (GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs))
717     {
718     case ARGI_SIMPLE_TARGET:
719     case ARGI_FIXED_TARGET:
720     case ARGI_INTEGER_REF:      /* Handles Increment, Decrement cases */
721 
722         switch (DestinationType)
723         {
724         case ACPI_TYPE_LOCAL_REGION_FIELD:
725             /*
726              * Named field can always handle conversions
727              */
728             break;
729 
730         default:
731 
732             /* No conversion allowed for these types */
733 
734             if (DestinationType != SourceDesc->Common.Type)
735             {
736                 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
737                     "Explicit operator, will store (%s) over existing type (%s)\n",
738                     AcpiUtGetObjectTypeName (SourceDesc),
739                     AcpiUtGetTypeName (DestinationType)));
740                 Status = AE_TYPE;
741             }
742         }
743         break;
744 
745     case ARGI_TARGETREF:
746     case ARGI_STORE_TARGET:
747 
748         switch (DestinationType)
749         {
750         case ACPI_TYPE_INTEGER:
751         case ACPI_TYPE_BUFFER_FIELD:
752         case ACPI_TYPE_LOCAL_BANK_FIELD:
753         case ACPI_TYPE_LOCAL_INDEX_FIELD:
754             /*
755              * These types require an Integer operand. We can convert
756              * a Buffer or a String to an Integer if necessary.
757              */
758             Status = AcpiExConvertToInteger (SourceDesc, ResultDesc, 16);
759             break;
760 
761         case ACPI_TYPE_STRING:
762             /*
763              * The operand must be a String. We can convert an
764              * Integer or Buffer if necessary
765              */
766             Status = AcpiExConvertToString (SourceDesc, ResultDesc,
767                 ACPI_IMPLICIT_CONVERT_HEX);
768             break;
769 
770         case ACPI_TYPE_BUFFER:
771             /*
772              * The operand must be a Buffer. We can convert an
773              * Integer or String if necessary
774              */
775             Status = AcpiExConvertToBuffer (SourceDesc, ResultDesc);
776             break;
777 
778         default:
779 
780             ACPI_ERROR ((AE_INFO,
781                 "Bad destination type during conversion: 0x%X",
782                 DestinationType));
783             Status = AE_AML_INTERNAL;
784             break;
785         }
786         break;
787 
788     case ARGI_REFERENCE:
789         /*
790          * CreateXxxxField cases - we are storing the field object into the name
791          */
792         break;
793 
794     default:
795 
796         ACPI_ERROR ((AE_INFO,
797             "Unknown Target type ID 0x%X AmlOpcode 0x%X DestType %s",
798             GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs),
799             WalkState->Opcode, AcpiUtGetTypeName (DestinationType)));
800         Status = AE_AML_INTERNAL;
801     }
802 
803     /*
804      * Source-to-Target conversion semantics:
805      *
806      * If conversion to the target type cannot be performed, then simply
807      * overwrite the target with the new object and type.
808      */
809     if (Status == AE_TYPE)
810     {
811         Status = AE_OK;
812     }
813 
814     return_ACPI_STATUS (Status);
815 }
816