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