Merge from vendor branch HEIMDAL:
[dragonfly.git] / sys / contrib / dev / acpica / exconvrt.c
1 /******************************************************************************
2  *
3  * Module Name: exconvrt - Object conversion routines
4  *              $Revision: 49 $
5  *
6  *****************************************************************************/
7
8 /******************************************************************************
9  *
10  * 1. Copyright Notice
11  *
12  * Some or all of this work - Copyright (c) 1999 - 2003, 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 /* $DragonFly: src/sys/contrib/dev/acpica/Attic/exconvrt.c,v 1.1 2003/09/24 03:32:15 drhodus Exp $                                                               */
117
118
119 #define __EXCONVRT_C__
120
121 #include "acpi.h"
122 #include "acinterp.h"
123 #include "amlcode.h"
124
125
126 #define _COMPONENT          ACPI_EXECUTER
127         ACPI_MODULE_NAME    ("exconvrt")
128
129
130 /*******************************************************************************
131  *
132  * FUNCTION:    AcpiExConvertToInteger
133  *
134  * PARAMETERS:  *ObjDesc        - Object to be converted.  Must be an
135  *                                Integer, Buffer, or String
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  *              WalkState       - Current method state
279  *
280  * RETURN:      Status
281  *
282  * DESCRIPTION: Convert an ACPI Object to a Buffer
283  *
284  ******************************************************************************/
285
286 ACPI_STATUS
287 AcpiExConvertToBuffer (
288     ACPI_OPERAND_OBJECT     *ObjDesc,
289     ACPI_OPERAND_OBJECT     **ResultDesc,
290     ACPI_WALK_STATE         *WalkState)
291 {
292     ACPI_OPERAND_OBJECT     *RetDesc;
293     UINT32                  i;
294     UINT8                   *NewBuf;
295
296
297     ACPI_FUNCTION_TRACE_PTR ("ExConvertToBuffer", ObjDesc);
298
299
300     switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
301     {
302     case ACPI_TYPE_BUFFER:
303
304         /* No conversion necessary */
305
306         *ResultDesc = ObjDesc;
307         return_ACPI_STATUS (AE_OK);
308
309
310     case ACPI_TYPE_INTEGER:
311
312         /*
313          * Create a new Buffer object.
314          * Need enough space for one integer
315          */
316         RetDesc = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth);
317         if (!RetDesc)
318         {
319             return_ACPI_STATUS (AE_NO_MEMORY);
320         }
321
322         /* Copy the integer to the buffer */
323
324         NewBuf = RetDesc->Buffer.Pointer;
325         for (i = 0; i < AcpiGbl_IntegerByteWidth; i++)
326         {
327             NewBuf[i] = (UINT8) (ObjDesc->Integer.Value >> (i * 8));
328         }
329         break;
330
331
332     case ACPI_TYPE_STRING:
333
334         /*
335          * Create a new Buffer object
336          * Size will be the string length
337          */
338         RetDesc = AcpiUtCreateBufferObject ((ACPI_SIZE) ObjDesc->String.Length);
339         if (!RetDesc)
340         {
341             return_ACPI_STATUS (AE_NO_MEMORY);
342         }
343
344         /* Copy the string to the buffer */
345
346         NewBuf = RetDesc->Buffer.Pointer;
347         ACPI_STRNCPY ((char *) NewBuf, (char *) ObjDesc->String.Pointer,
348             ObjDesc->String.Length);
349         break;
350
351
352     default:
353         return_ACPI_STATUS (AE_TYPE);
354     }
355
356     /* Mark buffer initialized */
357
358     RetDesc->Common.Flags |= AOPOBJ_DATA_VALID;
359
360     /*
361      * If we are about to overwrite the original object on the operand stack,
362      * we must remove a reference on the original object because we are
363      * essentially removing it from the stack.
364      */
365     if (*ResultDesc == ObjDesc)
366     {
367         if (WalkState->Opcode != AML_STORE_OP)
368         {
369             AcpiUtRemoveReference (ObjDesc);
370         }
371     }
372
373     *ResultDesc = RetDesc;
374     return_ACPI_STATUS (AE_OK);
375 }
376
377
378 /*******************************************************************************
379  *
380  * FUNCTION:    AcpiExConvertAscii
381  *
382  * PARAMETERS:  Integer         - Value to be converted
383  *              Base            - 10 or 16
384  *              String          - Where the string is returned
385  *              DataWidth       - Size of data item to be converted
386  *
387  * RETURN:      Actual string length
388  *
389  * DESCRIPTION: Convert an ACPI Integer to a hex or decimal string
390  *
391  ******************************************************************************/
392
393 UINT32
394 AcpiExConvertToAscii (
395     ACPI_INTEGER            Integer,
396     UINT32                  Base,
397     UINT8                   *String,
398     UINT8                   DataWidth)
399 {
400     UINT32                  i;
401     UINT32                  j;
402     UINT32                  k = 0;
403     char                    HexDigit;
404     ACPI_INTEGER            Digit;
405     UINT32                  Remainder;
406     UINT32                  Length;
407     BOOLEAN                 LeadingZero;
408
409
410     ACPI_FUNCTION_ENTRY ();
411
412     if (DataWidth < sizeof (ACPI_INTEGER))
413     {
414         LeadingZero = FALSE;
415         Length = DataWidth;
416     }
417     else
418     {
419         LeadingZero = TRUE;
420         Length = sizeof (ACPI_INTEGER);
421     }
422
423
424     switch (Base)
425     {
426     case 10:
427
428         Remainder = 0;
429         for (i = ACPI_MAX_DECIMAL_DIGITS; i > 0 ; i--)
430         {
431             /* Divide by nth factor of 10 */
432
433             Digit = Integer;
434             for (j = 1; j < i; j++)
435             {
436                 (void) AcpiUtShortDivide (&Digit, 10, &Digit, &Remainder);
437             }
438
439             /* Create the decimal digit */
440
441             if (Digit != 0)
442             {
443                 LeadingZero = FALSE;
444             }
445
446             if (!LeadingZero)
447             {
448                 String[k] = (UINT8) (ACPI_ASCII_ZERO + Remainder);
449                 k++;
450             }
451         }
452         break;
453
454     case 16:
455
456         /* Copy the integer to the buffer */
457
458         for (i = 0, j = ((Length * 2) -1); i < (Length * 2); i++, j--)
459         {
460
461             HexDigit = AcpiUtHexToAsciiChar (Integer, (j * 4));
462             if (HexDigit != ACPI_ASCII_ZERO)
463             {
464                 LeadingZero = FALSE;
465             }
466
467             if (!LeadingZero)
468             {
469                 String[k] = (UINT8) HexDigit;
470                 k++;
471             }
472         }
473         break;
474
475     default:
476         break;
477     }
478
479     /*
480      * Since leading zeros are supressed, 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 (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  *              WalkState       - Current method state
503  *
504  * RETURN:      Status
505  *
506  * DESCRIPTION: Convert an ACPI Object to a string
507  *
508  ******************************************************************************/
509
510 ACPI_STATUS
511 AcpiExConvertToString (
512     ACPI_OPERAND_OBJECT     *ObjDesc,
513     ACPI_OPERAND_OBJECT     **ResultDesc,
514     UINT32                  Base,
515     UINT32                  MaxLength,
516     ACPI_WALK_STATE         *WalkState)
517 {
518     ACPI_OPERAND_OBJECT     *RetDesc;
519     UINT32                  i;
520     UINT32                  StringLength;
521     UINT8                   *NewBuf;
522     UINT8                   *Pointer;
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         if (MaxLength >= ObjDesc->String.Length)
533         {
534             *ResultDesc = ObjDesc;
535             return_ACPI_STATUS (AE_OK);
536         }
537         else
538         {
539             /* Must copy the string first and then truncate it */
540
541             return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
542         }
543
544
545     case ACPI_TYPE_INTEGER:
546
547         StringLength = AcpiGbl_IntegerByteWidth * 2;
548         if (Base == 10)
549         {
550             StringLength = ACPI_MAX_DECIMAL_DIGITS;
551         }
552
553         /*
554          * Create a new String
555          */
556         RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING);
557         if (!RetDesc)
558         {
559             return_ACPI_STATUS (AE_NO_MEMORY);
560         }
561
562         /* Need enough space for one ASCII integer plus null terminator */
563
564         NewBuf = ACPI_MEM_CALLOCATE ((ACPI_SIZE) StringLength + 1);
565         if (!NewBuf)
566         {
567             ACPI_REPORT_ERROR
568                 (("ExConvertToString: Buffer allocation failure\n"));
569             AcpiUtRemoveReference (RetDesc);
570             return_ACPI_STATUS (AE_NO_MEMORY);
571         }
572
573         /* Convert */
574
575         i = AcpiExConvertToAscii (ObjDesc->Integer.Value, Base, NewBuf, sizeof (ACPI_INTEGER));
576
577         /* Null terminate at the correct place */
578
579         if (MaxLength < i)
580         {
581             NewBuf[MaxLength] = 0;
582             RetDesc->String.Length = MaxLength;
583         }
584         else
585         {
586             NewBuf [i] = 0;
587             RetDesc->String.Length = i;
588         }
589
590         RetDesc->Buffer.Pointer = NewBuf;
591         break;
592
593
594     case ACPI_TYPE_BUFFER:
595
596         /* Find the string length */
597
598         Pointer = ObjDesc->Buffer.Pointer;
599         for (StringLength = 0; StringLength < ObjDesc->Buffer.Length; StringLength++)
600         {
601             /* Exit on null terminator */
602
603             if (!Pointer[StringLength])
604             {
605                 break;
606             }
607         }
608
609         if (MaxLength > ACPI_MAX_STRING_CONVERSION)
610         {
611             if (StringLength > ACPI_MAX_STRING_CONVERSION)
612             {
613                 return_ACPI_STATUS (AE_AML_STRING_LIMIT);
614             }
615         }
616
617         /*
618          * Create a new string object
619          */
620         RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING);
621         if (!RetDesc)
622         {
623             return_ACPI_STATUS (AE_NO_MEMORY);
624         }
625
626         /* String length is the lesser of the Max or the actual length */
627
628         if (MaxLength < StringLength)
629         {
630             StringLength = MaxLength;
631         }
632
633         NewBuf = ACPI_MEM_CALLOCATE ((ACPI_SIZE) StringLength + 1);
634         if (!NewBuf)
635         {
636             ACPI_REPORT_ERROR
637                 (("ExConvertToString: Buffer allocation failure\n"));
638             AcpiUtRemoveReference (RetDesc);
639             return_ACPI_STATUS (AE_NO_MEMORY);
640         }
641
642         /* Copy the appropriate number of buffer characters */
643
644         ACPI_MEMCPY (NewBuf, Pointer, StringLength);
645
646         /* Null terminate */
647
648         NewBuf [StringLength] = 0;
649         RetDesc->Buffer.Pointer = NewBuf;
650         RetDesc->String.Length = StringLength;
651         break;
652
653
654     default:
655         return_ACPI_STATUS (AE_TYPE);
656     }
657
658
659     /*
660      * If we are about to overwrite the original object on the operand stack,
661      * we must remove a reference on the original object because we are
662      * essentially removing it from the stack.
663      */
664     if (*ResultDesc == ObjDesc)
665     {
666         if (WalkState->Opcode != AML_STORE_OP)
667         {
668             AcpiUtRemoveReference (ObjDesc);
669         }
670     }
671
672     *ResultDesc = RetDesc;
673     return_ACPI_STATUS (AE_OK);
674 }
675
676
677 /*******************************************************************************
678  *
679  * FUNCTION:    AcpiExConvertToTargetType
680  *
681  * PARAMETERS:  DestinationType     - Current type of the destination
682  *              SourceDesc          - Source object to be converted.
683  *              WalkState           - Current method state
684  *
685  * RETURN:      Status
686  *
687  * DESCRIPTION: Implements "implicit conversion" rules for storing an object.
688  *
689  ******************************************************************************/
690
691 ACPI_STATUS
692 AcpiExConvertToTargetType (
693     ACPI_OBJECT_TYPE        DestinationType,
694     ACPI_OPERAND_OBJECT     *SourceDesc,
695     ACPI_OPERAND_OBJECT     **ResultDesc,
696     ACPI_WALK_STATE         *WalkState)
697 {
698     ACPI_STATUS             Status = AE_OK;
699
700
701     ACPI_FUNCTION_TRACE ("ExConvertToTargetType");
702
703
704     /* Default behavior */
705
706     *ResultDesc = SourceDesc;
707
708     /*
709      * If required by the target,
710      * perform implicit conversion on the source before we store it.
711      */
712     switch (GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs))
713     {
714     case ARGI_SIMPLE_TARGET:
715     case ARGI_FIXED_TARGET:
716     case ARGI_INTEGER_REF:      /* Handles Increment, Decrement cases */
717
718         switch (DestinationType)
719         {
720         case ACPI_TYPE_LOCAL_REGION_FIELD:
721             /*
722              * Named field can always handle conversions
723              */
724             break;
725
726         default:
727             /* No conversion allowed for these types */
728
729             if (DestinationType != ACPI_GET_OBJECT_TYPE (SourceDesc))
730             {
731                 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
732                     "Explicit operator, will store (%s) over existing type (%s)\n",
733                     AcpiUtGetObjectTypeName (SourceDesc),
734                     AcpiUtGetTypeName (DestinationType)));
735                 Status = AE_TYPE;
736             }
737         }
738         break;
739
740
741     case ARGI_TARGETREF:
742
743         switch (DestinationType)
744         {
745         case ACPI_TYPE_INTEGER:
746         case ACPI_TYPE_BUFFER_FIELD:
747         case ACPI_TYPE_LOCAL_BANK_FIELD:
748         case ACPI_TYPE_LOCAL_INDEX_FIELD:
749             /*
750              * These types require an Integer operand.  We can convert
751              * a Buffer or a String to an Integer if necessary.
752              */
753             Status = AcpiExConvertToInteger (SourceDesc, ResultDesc, WalkState);
754             break;
755
756
757         case ACPI_TYPE_STRING:
758
759             /*
760              * The operand must be a String.  We can convert an
761              * Integer or Buffer if necessary
762              */
763             Status = AcpiExConvertToString (SourceDesc, ResultDesc, 16, ACPI_UINT32_MAX, WalkState);
764             break;
765
766
767         case ACPI_TYPE_BUFFER:
768
769             /*
770              * The operand must be a Buffer.  We can convert an
771              * Integer or String if necessary
772              */
773             Status = AcpiExConvertToBuffer (SourceDesc, ResultDesc, WalkState);
774             break;
775
776
777         default:
778             Status = AE_AML_INTERNAL;
779             break;
780         }
781         break;
782
783
784     case ARGI_REFERENCE:
785         /*
786          * CreateXxxxField cases - we are storing the field object into the name
787          */
788         break;
789
790
791     default:
792         ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
793             "Unknown Target type ID 0x%X Op %s DestType %s\n",
794             GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs),
795             WalkState->OpInfo->Name, AcpiUtGetTypeName (DestinationType)));
796
797         Status = AE_AML_INTERNAL;
798     }
799
800     /*
801      * Source-to-Target conversion semantics:
802      *
803      * If conversion to the target type cannot be performed, then simply
804      * overwrite the target with the new object and type.
805      */
806     if (Status == AE_TYPE)
807     {
808         Status = AE_OK;
809     }
810
811     return_ACPI_STATUS (Status);
812 }
813
814