xref: /titanic_41/usr/src/uts/intel/io/acpica/executer/exconvrt.c (revision 88447a05f537aabe9a1bc3d5313f22581ec992a7)
1 /******************************************************************************
2  *
3  * Module Name: exconvrt - Object conversion routines
4  *              $Revision: 1.75 $
5  *
6  *****************************************************************************/
7 
8 /******************************************************************************
9  *
10  * 1. Copyright Notice
11  *
12  * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp.
13  * All rights reserved.
14  *
15  * 2. License
16  *
17  * 2.1. This is your license from Intel Corp. under its intellectual property
18  * rights.  You may have additional license terms from the party that provided
19  * you this software, covering your right to use that party's intellectual
20  * property rights.
21  *
22  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23  * copy of the source code appearing in this file ("Covered Code") an
24  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25  * base code distributed originally by Intel ("Original Intel Code") to copy,
26  * make derivatives, distribute, use and display any portion of the Covered
27  * Code in any form, with the right to sublicense such rights; and
28  *
29  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30  * license (with the right to sublicense), under only those claims of Intel
31  * patents that are infringed by the Original Intel Code, to make, use, sell,
32  * offer to sell, and import the Covered Code and derivative works thereof
33  * solely to the minimum extent necessary to exercise the above copyright
34  * license, and in no event shall the patent license extend to any additions
35  * to or modifications of the Original Intel Code.  No other license or right
36  * is granted directly or by implication, estoppel or otherwise;
37  *
38  * The above copyright and patent license is granted only if the following
39  * conditions are met:
40  *
41  * 3. Conditions
42  *
43  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44  * Redistribution of source code of any substantial portion of the Covered
45  * Code or modification with rights to further distribute source must include
46  * the above Copyright Notice, the above License, this list of Conditions,
47  * and the following Disclaimer and Export Compliance provision.  In addition,
48  * Licensee must cause all Covered Code to which Licensee contributes to
49  * contain a file documenting the changes Licensee made to create that Covered
50  * Code and the date of any change.  Licensee must include in that file the
51  * documentation of any changes made by any predecessor Licensee.  Licensee
52  * must include a prominent statement that the modification is derived,
53  * directly or indirectly, from Original Intel Code.
54  *
55  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56  * Redistribution of source code of any substantial portion of the Covered
57  * Code or modification without rights to further distribute source must
58  * include the following Disclaimer and Export Compliance provision in the
59  * documentation and/or other materials provided with distribution.  In
60  * addition, Licensee may not authorize further sublicense of source of any
61  * portion of the Covered Code, and must include terms to the effect that the
62  * license from Licensee to its licensee is limited to the intellectual
63  * property embodied in the software Licensee provides to its licensee, and
64  * not to intellectual property embodied in modifications its licensee may
65  * make.
66  *
67  * 3.3. Redistribution of Executable. Redistribution in executable form of any
68  * substantial portion of the Covered Code or modification must reproduce the
69  * above Copyright Notice, and the following Disclaimer and Export Compliance
70  * provision in the documentation and/or other materials provided with the
71  * distribution.
72  *
73  * 3.4. Intel retains all right, title, and interest in and to the Original
74  * Intel Code.
75  *
76  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77  * Intel shall be used in advertising or otherwise to promote the sale, use or
78  * other dealings in products derived from or relating to the Covered Code
79  * without prior written authorization from Intel.
80  *
81  * 4. Disclaimer and Export Compliance
82  *
83  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89  * PARTICULAR PURPOSE.
90  *
91  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98  * LIMITED REMEDY.
99  *
100  * 4.3. Licensee shall not export, either directly or indirectly, any of this
101  * software or system incorporating such software without first obtaining any
102  * required license or other approval from the U. S. Department of Commerce or
103  * any other agency or department of the United States Government.  In the
104  * event Licensee exports any such software from the United States or
105  * re-exports any such software from a foreign destination, Licensee shall
106  * ensure that the distribution and export/re-export of the software is in
107  * compliance with all laws, regulations, orders, or other restrictions of the
108  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109  * any of its subsidiaries will export/re-export any technical data, process,
110  * software, or service, directly or indirectly, to any country for which the
111  * United States government or any agency thereof requires an export license,
112  * other governmental approval, or letter of assurance, without first obtaining
113  * such license, approval or letter.
114  *
115  *****************************************************************************/
116 
117 
118 #define __EXCONVRT_C__
119 
120 #include "acpi.h"
121 #include "acinterp.h"
122 #include "amlcode.h"
123 
124 
125 #define _COMPONENT          ACPI_EXECUTER
126         ACPI_MODULE_NAME    ("exconvrt")
127 
128 /* Local prototypes */
129 
130 static UINT32
131 AcpiExConvertToAscii (
132     ACPI_INTEGER            Integer,
133     UINT16                  Base,
134     UINT8                   *String,
135     UINT8                   MaxLength);
136 
137 
138 /*******************************************************************************
139  *
140  * FUNCTION:    AcpiExConvertToInteger
141  *
142  * PARAMETERS:  ObjDesc         - Object to be converted. Must be an
143  *                                Integer, Buffer, or String
144  *              ResultDesc      - Where the new Integer object is returned
145  *              Flags           - Used for string conversion
146  *
147  * RETURN:      Status
148  *
149  * DESCRIPTION: Convert an ACPI Object to an integer.
150  *
151  ******************************************************************************/
152 
153 ACPI_STATUS
154 AcpiExConvertToInteger (
155     ACPI_OPERAND_OBJECT     *ObjDesc,
156     ACPI_OPERAND_OBJECT     **ResultDesc,
157     UINT32                  Flags)
158 {
159     ACPI_OPERAND_OBJECT     *ReturnDesc;
160     UINT8                   *Pointer;
161     ACPI_INTEGER            Result;
162     UINT32                  i;
163     UINT32                  Count;
164     ACPI_STATUS             Status;
165 
166 
167     ACPI_FUNCTION_TRACE_PTR (ExConvertToInteger, ObjDesc);
168 
169 
170     switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
171     {
172     case ACPI_TYPE_INTEGER:
173 
174         /* No conversion necessary */
175 
176         *ResultDesc = ObjDesc;
177         return_ACPI_STATUS (AE_OK);
178 
179     case ACPI_TYPE_BUFFER:
180     case ACPI_TYPE_STRING:
181 
182         /* Note: Takes advantage of common buffer/string fields */
183 
184         Pointer = ObjDesc->Buffer.Pointer;
185         Count   = ObjDesc->Buffer.Length;
186         break;
187 
188     default:
189         return_ACPI_STATUS (AE_TYPE);
190     }
191 
192     /*
193      * Convert the buffer/string to an integer. Note that both buffers and
194      * strings are treated as raw data - we don't convert ascii to hex for
195      * strings.
196      *
197      * There are two terminating conditions for the loop:
198      * 1) The size of an integer has been reached, or
199      * 2) The end of the buffer or string has been reached
200      */
201     Result = 0;
202 
203     /* String conversion is different than Buffer conversion */
204 
205     switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
206     {
207     case ACPI_TYPE_STRING:
208 
209         /*
210          * Convert string to an integer - for most cases, the string must be
211          * hexadecimal as per the ACPI specification. The only exception (as
212          * of ACPI 3.0) is that the ToInteger() operator allows both decimal
213          * and hexadecimal strings (hex prefixed with "0x").
214          */
215         Status = AcpiUtStrtoul64 ((char *) Pointer, Flags, &Result);
216         if (ACPI_FAILURE (Status))
217         {
218             return_ACPI_STATUS (Status);
219         }
220         break;
221 
222 
223     case ACPI_TYPE_BUFFER:
224 
225         /* Check for zero-length buffer */
226 
227         if (!Count)
228         {
229             return_ACPI_STATUS (AE_AML_BUFFER_LIMIT);
230         }
231 
232         /* Transfer no more than an integer's worth of data */
233 
234         if (Count > AcpiGbl_IntegerByteWidth)
235         {
236             Count = AcpiGbl_IntegerByteWidth;
237         }
238 
239         /*
240          * Convert buffer to an integer - we simply grab enough raw data
241          * from the buffer to fill an integer
242          */
243         for (i = 0; i < Count; i++)
244         {
245             /*
246              * Get next byte and shift it into the Result.
247              * Little endian is used, meaning that the first byte of the buffer
248              * is the LSB of the integer
249              */
250             Result |= (((ACPI_INTEGER) Pointer[i]) << (i * 8));
251         }
252         break;
253 
254 
255     default:
256 
257         /* No other types can get here */
258         break;
259     }
260 
261     /* Create a new integer */
262 
263     ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
264     if (!ReturnDesc)
265     {
266         return_ACPI_STATUS (AE_NO_MEMORY);
267     }
268 
269     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n",
270         ACPI_FORMAT_UINT64 (Result)));
271 
272     /* Save the Result */
273 
274     ReturnDesc->Integer.Value = Result;
275     AcpiExTruncateFor32bitTable (ReturnDesc);
276     *ResultDesc = ReturnDesc;
277     return_ACPI_STATUS (AE_OK);
278 }
279 
280 
281 /*******************************************************************************
282  *
283  * FUNCTION:    AcpiExConvertToBuffer
284  *
285  * PARAMETERS:  ObjDesc         - Object to be converted. Must be an
286  *                                Integer, Buffer, or String
287  *              ResultDesc      - Where the new buffer object is returned
288  *
289  * RETURN:      Status
290  *
291  * DESCRIPTION: Convert an ACPI Object to a Buffer
292  *
293  ******************************************************************************/
294 
295 ACPI_STATUS
296 AcpiExConvertToBuffer (
297     ACPI_OPERAND_OBJECT     *ObjDesc,
298     ACPI_OPERAND_OBJECT     **ResultDesc)
299 {
300     ACPI_OPERAND_OBJECT     *ReturnDesc;
301     UINT8                   *NewBuf;
302 
303 
304     ACPI_FUNCTION_TRACE_PTR (ExConvertToBuffer, ObjDesc);
305 
306 
307     switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
308     {
309     case ACPI_TYPE_BUFFER:
310 
311         /* No conversion necessary */
312 
313         *ResultDesc = ObjDesc;
314         return_ACPI_STATUS (AE_OK);
315 
316 
317     case ACPI_TYPE_INTEGER:
318 
319         /*
320          * Create a new Buffer object.
321          * Need enough space for one integer
322          */
323         ReturnDesc = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth);
324         if (!ReturnDesc)
325         {
326             return_ACPI_STATUS (AE_NO_MEMORY);
327         }
328 
329         /* Copy the integer to the buffer, LSB first */
330 
331         NewBuf = ReturnDesc->Buffer.Pointer;
332         ACPI_MEMCPY (NewBuf,
333                         &ObjDesc->Integer.Value,
334                         AcpiGbl_IntegerByteWidth);
335         break;
336 
337 
338     case ACPI_TYPE_STRING:
339 
340         /*
341          * Create a new Buffer object
342          * Size will be the string length
343          *
344          * NOTE: Add one to the string length to include the null terminator.
345          * The ACPI spec is unclear on this subject, but there is existing
346          * ASL/AML code that depends on the null being transferred to the new
347          * buffer.
348          */
349         ReturnDesc = AcpiUtCreateBufferObject (
350                         (ACPI_SIZE) ObjDesc->String.Length + 1);
351         if (!ReturnDesc)
352         {
353             return_ACPI_STATUS (AE_NO_MEMORY);
354         }
355 
356         /* Copy the string to the buffer */
357 
358         NewBuf = ReturnDesc->Buffer.Pointer;
359         ACPI_STRNCPY ((char *) NewBuf, (char *) ObjDesc->String.Pointer,
360             ObjDesc->String.Length);
361         break;
362 
363 
364     default:
365         return_ACPI_STATUS (AE_TYPE);
366     }
367 
368     /* Mark buffer initialized */
369 
370     ReturnDesc->Common.Flags |= AOPOBJ_DATA_VALID;
371     *ResultDesc = ReturnDesc;
372     return_ACPI_STATUS (AE_OK);
373 }
374 
375 
376 /*******************************************************************************
377  *
378  * FUNCTION:    AcpiExConvertToAscii
379  *
380  * PARAMETERS:  Integer         - Value to be converted
381  *              Base            - ACPI_STRING_DECIMAL or ACPI_STRING_HEX
382  *              String          - Where the string is returned
383  *              DataWidth       - Size of data item to be converted, in bytes
384  *
385  * RETURN:      Actual string length
386  *
387  * DESCRIPTION: Convert an ACPI Integer to a hex or decimal string
388  *
389  ******************************************************************************/
390 
391 static UINT32
392 AcpiExConvertToAscii (
393     ACPI_INTEGER            Integer,
394     UINT16                  Base,
395     UINT8                   *String,
396     UINT8                   DataWidth)
397 {
398     ACPI_INTEGER            Digit;
399     UINT32                  i;
400     UINT32                  j;
401     UINT32                  k = 0;
402     UINT32                  HexLength;
403     UINT32                  DecimalLength;
404     UINT32                  Remainder;
405     BOOLEAN                 SupressZeros;
406 
407 
408     ACPI_FUNCTION_ENTRY ();
409 
410 
411     switch (Base)
412     {
413     case 10:
414 
415         /* Setup max length for the decimal number */
416 
417         switch (DataWidth)
418         {
419         case 1:
420             DecimalLength = ACPI_MAX8_DECIMAL_DIGITS;
421             break;
422 
423         case 4:
424             DecimalLength = ACPI_MAX32_DECIMAL_DIGITS;
425             break;
426 
427         case 8:
428         default:
429             DecimalLength = ACPI_MAX64_DECIMAL_DIGITS;
430             break;
431         }
432 
433         SupressZeros = TRUE;     /* No leading zeros */
434         Remainder = 0;
435 
436         for (i = DecimalLength; i > 0; i--)
437         {
438             /* Divide by nth factor of 10 */
439 
440             Digit = Integer;
441             for (j = 0; j < i; j++)
442             {
443                 (void) AcpiUtShortDivide (Digit, 10, &Digit, &Remainder);
444             }
445 
446             /* Handle leading zeros */
447 
448             if (Remainder != 0)
449             {
450                 SupressZeros = FALSE;
451             }
452 
453             if (!SupressZeros)
454             {
455                 String[k] = (UINT8) (ACPI_ASCII_ZERO + Remainder);
456                 k++;
457             }
458         }
459         break;
460 
461     case 16:
462 
463         /* HexLength: 2 ascii hex chars per data byte */
464 
465         HexLength = ACPI_MUL_2 (DataWidth);
466         for (i = 0, j = (HexLength-1); i < HexLength; i++, j--)
467         {
468             /* Get one hex digit, most significant digits first */
469 
470             String[k] = (UINT8) AcpiUtHexToAsciiChar (Integer, ACPI_MUL_4 (j));
471             k++;
472         }
473         break;
474 
475     default:
476         return (0);
477     }
478 
479     /*
480      * Since leading zeros are suppressed, we must check for the case where
481      * the integer equals 0
482      *
483      * Finally, null terminate the string and return the length
484      */
485     if (!k)
486     {
487         String [0] = ACPI_ASCII_ZERO;
488         k = 1;
489     }
490 
491     String [k] = 0;
492     return ((UINT32) k);
493 }
494 
495 
496 /*******************************************************************************
497  *
498  * FUNCTION:    AcpiExConvertToString
499  *
500  * PARAMETERS:  ObjDesc         - Object to be converted. Must be an
501  *                                Integer, Buffer, or String
502  *              ResultDesc      - Where the string object is returned
503  *              Type            - String flags (base and conversion type)
504  *
505  * RETURN:      Status
506  *
507  * DESCRIPTION: Convert an ACPI Object to a string
508  *
509  ******************************************************************************/
510 
511 ACPI_STATUS
512 AcpiExConvertToString (
513     ACPI_OPERAND_OBJECT     *ObjDesc,
514     ACPI_OPERAND_OBJECT     **ResultDesc,
515     UINT32                  Type)
516 {
517     ACPI_OPERAND_OBJECT     *ReturnDesc;
518     UINT8                   *NewBuf;
519     UINT32                  i;
520     UINT32                  StringLength = 0;
521     UINT16                  Base = 16;
522     UINT8                   Separator = ',';
523 
524 
525     ACPI_FUNCTION_TRACE_PTR (ExConvertToString, ObjDesc);
526 
527 
528     switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
529     {
530     case ACPI_TYPE_STRING:
531 
532         /* No conversion necessary */
533 
534         *ResultDesc = ObjDesc;
535         return_ACPI_STATUS (AE_OK);
536 
537 
538     case ACPI_TYPE_INTEGER:
539 
540         switch (Type)
541         {
542         case ACPI_EXPLICIT_CONVERT_DECIMAL:
543 
544             /* Make room for maximum decimal number */
545 
546             StringLength = ACPI_MAX_DECIMAL_DIGITS;
547             Base = 10;
548             break;
549 
550         default:
551 
552             /* Two hex string characters for each integer byte */
553 
554             StringLength = ACPI_MUL_2 (AcpiGbl_IntegerByteWidth);
555             break;
556         }
557 
558         /*
559          * Create a new String
560          * Need enough space for one ASCII integer (plus null terminator)
561          */
562         ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength);
563         if (!ReturnDesc)
564         {
565             return_ACPI_STATUS (AE_NO_MEMORY);
566         }
567 
568         NewBuf = ReturnDesc->Buffer.Pointer;
569 
570         /* Convert integer to string */
571 
572         StringLength = AcpiExConvertToAscii (ObjDesc->Integer.Value, Base,
573                             NewBuf, AcpiGbl_IntegerByteWidth);
574 
575         /* Null terminate at the correct place */
576 
577         ReturnDesc->String.Length = StringLength;
578         NewBuf [StringLength] = 0;
579         break;
580 
581 
582     case ACPI_TYPE_BUFFER:
583 
584         /* Setup string length, base, and separator */
585 
586         switch (Type)
587         {
588         case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by ToDecimalString */
589             /*
590              * From ACPI: "If Data is a buffer, it is converted to a string of
591              * decimal values separated by commas."
592              */
593             Base = 10;
594 
595             /*
596              * Calculate the final string length. Individual string values
597              * are variable length (include separator for each)
598              */
599             for (i = 0; i < ObjDesc->Buffer.Length; i++)
600             {
601                 if (ObjDesc->Buffer.Pointer[i] >= 100)
602                 {
603                     StringLength += 4;
604                 }
605                 else if (ObjDesc->Buffer.Pointer[i] >= 10)
606                 {
607                     StringLength += 3;
608                 }
609                 else
610                 {
611                     StringLength += 2;
612                 }
613             }
614             break;
615 
616         case ACPI_IMPLICIT_CONVERT_HEX:
617             /*
618              * From the ACPI spec:
619              *"The entire contents of the buffer are converted to a string of
620              * two-character hexadecimal numbers, each separated by a space."
621              */
622             Separator = ' ';
623             StringLength = (ObjDesc->Buffer.Length * 3);
624             break;
625 
626         case ACPI_EXPLICIT_CONVERT_HEX:     /* Used by ToHexString */
627             /*
628              * From ACPI: "If Data is a buffer, it is converted to a string of
629              * hexadecimal values separated by commas."
630              */
631             StringLength = (ObjDesc->Buffer.Length * 3);
632             break;
633 
634         default:
635             return_ACPI_STATUS (AE_BAD_PARAMETER);
636         }
637 
638         /*
639          * Create a new string object and string buffer
640          * (-1 because of extra separator included in StringLength from above)
641          */
642         ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) (StringLength - 1));
643         if (!ReturnDesc)
644         {
645             return_ACPI_STATUS (AE_NO_MEMORY);
646         }
647 
648         NewBuf = ReturnDesc->Buffer.Pointer;
649 
650         /*
651          * Convert buffer bytes to hex or decimal values
652          * (separated by commas or spaces)
653          */
654         for (i = 0; i < ObjDesc->Buffer.Length; i++)
655         {
656             NewBuf += AcpiExConvertToAscii (
657                         (ACPI_INTEGER) ObjDesc->Buffer.Pointer[i], Base,
658                         NewBuf, 1);
659             *NewBuf++ = Separator; /* each separated by a comma or space */
660         }
661 
662         /*
663          * Null terminate the string
664          * (overwrites final comma/space from above)
665          */
666         NewBuf--;
667         *NewBuf = 0;
668         break;
669 
670     default:
671         return_ACPI_STATUS (AE_TYPE);
672     }
673 
674     *ResultDesc = ReturnDesc;
675     return_ACPI_STATUS (AE_OK);
676 }
677 
678 
679 /*******************************************************************************
680  *
681  * FUNCTION:    AcpiExConvertToTargetType
682  *
683  * PARAMETERS:  DestinationType     - Current type of the destination
684  *              SourceDesc          - Source object to be converted.
685  *              ResultDesc          - Where the converted object is returned
686  *              WalkState           - Current method state
687  *
688  * RETURN:      Status
689  *
690  * DESCRIPTION: Implements "implicit conversion" rules for storing an object.
691  *
692  ******************************************************************************/
693 
694 ACPI_STATUS
695 AcpiExConvertToTargetType (
696     ACPI_OBJECT_TYPE        DestinationType,
697     ACPI_OPERAND_OBJECT     *SourceDesc,
698     ACPI_OPERAND_OBJECT     **ResultDesc,
699     ACPI_WALK_STATE         *WalkState)
700 {
701     ACPI_STATUS             Status = AE_OK;
702 
703 
704     ACPI_FUNCTION_TRACE (ExConvertToTargetType);
705 
706 
707     /* Default behavior */
708 
709     *ResultDesc = SourceDesc;
710 
711     /*
712      * If required by the target,
713      * perform implicit conversion on the source before we store it.
714      */
715     switch (GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs))
716     {
717     case ARGI_SIMPLE_TARGET:
718     case ARGI_FIXED_TARGET:
719     case ARGI_INTEGER_REF:      /* Handles Increment, Decrement cases */
720 
721         switch (DestinationType)
722         {
723         case ACPI_TYPE_LOCAL_REGION_FIELD:
724             /*
725              * Named field can always handle conversions
726              */
727             break;
728 
729         default:
730             /* No conversion allowed for these types */
731 
732             if (DestinationType != ACPI_GET_OBJECT_TYPE (SourceDesc))
733             {
734                 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
735                     "Explicit operator, will store (%s) over existing type (%s)\n",
736                     AcpiUtGetObjectTypeName (SourceDesc),
737                     AcpiUtGetTypeName (DestinationType)));
738                 Status = AE_TYPE;
739             }
740         }
741         break;
742 
743 
744     case ARGI_TARGETREF:
745 
746         switch (DestinationType)
747         {
748         case ACPI_TYPE_INTEGER:
749         case ACPI_TYPE_BUFFER_FIELD:
750         case ACPI_TYPE_LOCAL_BANK_FIELD:
751         case ACPI_TYPE_LOCAL_INDEX_FIELD:
752             /*
753              * These types require an Integer operand. We can convert
754              * a Buffer or a String to an Integer if necessary.
755              */
756             Status = AcpiExConvertToInteger (SourceDesc, ResultDesc,
757                         16);
758             break;
759 
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 
771         case ACPI_TYPE_BUFFER:
772             /*
773              * The operand must be a Buffer. We can convert an
774              * Integer or String if necessary
775              */
776             Status = AcpiExConvertToBuffer (SourceDesc, ResultDesc);
777             break;
778 
779 
780         default:
781             ACPI_ERROR ((AE_INFO, "Bad destination type during conversion: %X",
782                 DestinationType));
783             Status = AE_AML_INTERNAL;
784             break;
785         }
786         break;
787 
788 
789     case ARGI_REFERENCE:
790         /*
791          * CreateXxxxField cases - we are storing the field object into the name
792          */
793         break;
794 
795 
796     default:
797         ACPI_ERROR ((AE_INFO,
798             "Unknown Target type ID 0x%X AmlOpcode %X DestType %s",
799             GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs),
800             WalkState->Opcode, AcpiUtGetTypeName (DestinationType)));
801         Status = AE_AML_INTERNAL;
802     }
803 
804     /*
805      * Source-to-Target conversion semantics:
806      *
807      * If conversion to the target type cannot be performed, then simply
808      * overwrite the target with the new object and type.
809      */
810     if (Status == AE_TYPE)
811     {
812         Status = AE_OK;
813     }
814 
815     return_ACPI_STATUS (Status);
816 }
817 
818 
819