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