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