Sync ACPICA with Intel's version 20170831.
[dragonfly.git] / sys / contrib / dev / acpica / source / components / executer / exconvrt.c
blob8577a45e14ee46161730fdcac90942a969ced40e
1 /******************************************************************************
3 * Module Name: exconvrt - Object conversion routines
5 *****************************************************************************/
7 /******************************************************************************
9 * 1. Copyright Notice
11 * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp.
12 * All rights reserved.
14 * 2. License
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.
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
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;
37 * The above copyright and patent license is granted only if the following
38 * conditions are met:
40 * 3. Conditions
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.
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.
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.
72 * 3.4. Intel retains all right, title, and interest in and to the Original
73 * Intel Code.
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.
80 * 4. Disclaimer and Export Compliance
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.
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.
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.
114 *****************************************************************************
116 * Alternatively, you may choose to be licensed under the terms of the
117 * following license:
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
121 * are met:
122 * 1. Redistributions of source code must retain the above copyright
123 * notice, this list of conditions, and the following disclaimer,
124 * without modification.
125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 * substantially similar to the "NO WARRANTY" disclaimer below
127 * ("Disclaimer") and any redistribution must be conditioned upon
128 * including a substantially similar Disclaimer requirement for further
129 * binary redistribution.
130 * 3. Neither the names of the above-listed copyright holders nor the names
131 * of any contributors may be used to endorse or promote products derived
132 * from this software without specific prior written permission.
134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146 * Alternatively, you may choose to be licensed under the terms of the
147 * GNU General Public License ("GPL") version 2 as published by the Free
148 * Software Foundation.
150 *****************************************************************************/
152 #include "acpi.h"
153 #include "accommon.h"
154 #include "acinterp.h"
155 #include "amlcode.h"
158 #define _COMPONENT ACPI_EXECUTER
159 ACPI_MODULE_NAME ("exconvrt")
161 /* Local prototypes */
163 static UINT32
164 AcpiExConvertToAscii (
165 UINT64 Integer,
166 UINT16 Base,
167 UINT8 *String,
168 UINT8 MaxLength);
171 /*******************************************************************************
173 * FUNCTION: AcpiExConvertToInteger
175 * PARAMETERS: ObjDesc - Object to be converted. Must be an
176 * Integer, Buffer, or String
177 * ResultDesc - Where the new Integer object is returned
178 * ImplicitConversion - Used for string conversion
180 * RETURN: Status
182 * DESCRIPTION: Convert an ACPI Object to an integer.
184 ******************************************************************************/
186 ACPI_STATUS
187 AcpiExConvertToInteger (
188 ACPI_OPERAND_OBJECT *ObjDesc,
189 ACPI_OPERAND_OBJECT **ResultDesc,
190 UINT32 ImplicitConversion)
192 ACPI_OPERAND_OBJECT *ReturnDesc;
193 UINT8 *Pointer;
194 UINT64 Result;
195 UINT32 i;
196 UINT32 Count;
199 ACPI_FUNCTION_TRACE_PTR (ExConvertToInteger, ObjDesc);
202 switch (ObjDesc->Common.Type)
204 case ACPI_TYPE_INTEGER:
206 /* No conversion necessary */
208 *ResultDesc = ObjDesc;
209 return_ACPI_STATUS (AE_OK);
211 case ACPI_TYPE_BUFFER:
212 case ACPI_TYPE_STRING:
214 /* Note: Takes advantage of common buffer/string fields */
216 Pointer = ObjDesc->Buffer.Pointer;
217 Count = ObjDesc->Buffer.Length;
218 break;
220 default:
222 return_ACPI_STATUS (AE_TYPE);
226 * Convert the buffer/string to an integer. Note that both buffers and
227 * strings are treated as raw data - we don't convert ascii to hex for
228 * strings.
230 * There are two terminating conditions for the loop:
231 * 1) The size of an integer has been reached, or
232 * 2) The end of the buffer or string has been reached
234 Result = 0;
236 /* String conversion is different than Buffer conversion */
238 switch (ObjDesc->Common.Type)
240 case ACPI_TYPE_STRING:
242 * Convert string to an integer - for most cases, the string must be
243 * hexadecimal as per the ACPI specification. The only exception (as
244 * of ACPI 3.0) is that the ToInteger() operator allows both decimal
245 * and hexadecimal strings (hex prefixed with "0x").
247 * Explicit conversion is used only by ToInteger.
248 * All other string-to-integer conversions are implicit conversions.
250 if (ImplicitConversion)
252 Result = AcpiUtImplicitStrtoul64 (ACPI_CAST_PTR (char, Pointer));
254 else
256 Result = AcpiUtExplicitStrtoul64 (ACPI_CAST_PTR (char, Pointer));
258 break;
260 case ACPI_TYPE_BUFFER:
262 /* Check for zero-length buffer */
264 if (!Count)
266 return_ACPI_STATUS (AE_AML_BUFFER_LIMIT);
269 /* Transfer no more than an integer's worth of data */
271 if (Count > AcpiGbl_IntegerByteWidth)
273 Count = AcpiGbl_IntegerByteWidth;
277 * Convert buffer to an integer - we simply grab enough raw data
278 * from the buffer to fill an integer
280 for (i = 0; i < Count; i++)
283 * Get next byte and shift it into the Result.
284 * Little endian is used, meaning that the first byte of the buffer
285 * is the LSB of the integer
287 Result |= (((UINT64) Pointer[i]) << (i * 8));
289 break;
291 default:
293 /* No other types can get here */
295 break;
298 /* Create a new integer */
300 ReturnDesc = AcpiUtCreateIntegerObject (Result);
301 if (!ReturnDesc)
303 return_ACPI_STATUS (AE_NO_MEMORY);
306 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n",
307 ACPI_FORMAT_UINT64 (Result)));
309 /* Save the Result */
311 (void) AcpiExTruncateFor32bitTable (ReturnDesc);
312 *ResultDesc = ReturnDesc;
313 return_ACPI_STATUS (AE_OK);
317 /*******************************************************************************
319 * FUNCTION: AcpiExConvertToBuffer
321 * PARAMETERS: ObjDesc - Object to be converted. Must be an
322 * Integer, Buffer, or String
323 * ResultDesc - Where the new buffer object is returned
325 * RETURN: Status
327 * DESCRIPTION: Convert an ACPI Object to a Buffer
329 ******************************************************************************/
331 ACPI_STATUS
332 AcpiExConvertToBuffer (
333 ACPI_OPERAND_OBJECT *ObjDesc,
334 ACPI_OPERAND_OBJECT **ResultDesc)
336 ACPI_OPERAND_OBJECT *ReturnDesc;
337 UINT8 *NewBuf;
340 ACPI_FUNCTION_TRACE_PTR (ExConvertToBuffer, ObjDesc);
343 switch (ObjDesc->Common.Type)
345 case ACPI_TYPE_BUFFER:
347 /* No conversion necessary */
349 *ResultDesc = ObjDesc;
350 return_ACPI_STATUS (AE_OK);
353 case ACPI_TYPE_INTEGER:
355 * Create a new Buffer object.
356 * Need enough space for one integer
358 ReturnDesc = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth);
359 if (!ReturnDesc)
361 return_ACPI_STATUS (AE_NO_MEMORY);
364 /* Copy the integer to the buffer, LSB first */
366 NewBuf = ReturnDesc->Buffer.Pointer;
367 memcpy (NewBuf, &ObjDesc->Integer.Value, AcpiGbl_IntegerByteWidth);
368 break;
370 case ACPI_TYPE_STRING:
372 * Create a new Buffer object
373 * Size will be the string length
375 * NOTE: Add one to the string length to include the null terminator.
376 * The ACPI spec is unclear on this subject, but there is existing
377 * ASL/AML code that depends on the null being transferred to the new
378 * buffer.
380 ReturnDesc = AcpiUtCreateBufferObject ((ACPI_SIZE)
381 ObjDesc->String.Length + 1);
382 if (!ReturnDesc)
384 return_ACPI_STATUS (AE_NO_MEMORY);
387 /* Copy the string to the buffer */
389 NewBuf = ReturnDesc->Buffer.Pointer;
390 strncpy ((char *) NewBuf, (char *) ObjDesc->String.Pointer,
391 ObjDesc->String.Length);
392 break;
394 default:
396 return_ACPI_STATUS (AE_TYPE);
399 /* Mark buffer initialized */
401 ReturnDesc->Common.Flags |= AOPOBJ_DATA_VALID;
402 *ResultDesc = ReturnDesc;
403 return_ACPI_STATUS (AE_OK);
407 /*******************************************************************************
409 * FUNCTION: AcpiExConvertToAscii
411 * PARAMETERS: Integer - Value to be converted
412 * Base - ACPI_STRING_DECIMAL or ACPI_STRING_HEX
413 * String - Where the string is returned
414 * DataWidth - Size of data item to be converted, in bytes
416 * RETURN: Actual string length
418 * DESCRIPTION: Convert an ACPI Integer to a hex or decimal string
420 ******************************************************************************/
422 static UINT32
423 AcpiExConvertToAscii (
424 UINT64 Integer,
425 UINT16 Base,
426 UINT8 *String,
427 UINT8 DataWidth)
429 UINT64 Digit;
430 UINT32 i;
431 UINT32 j;
432 UINT32 k = 0;
433 UINT32 HexLength;
434 UINT32 DecimalLength;
435 UINT32 Remainder;
436 BOOLEAN SupressZeros;
439 ACPI_FUNCTION_ENTRY ();
442 switch (Base)
444 case 10:
446 /* Setup max length for the decimal number */
448 switch (DataWidth)
450 case 1:
452 DecimalLength = ACPI_MAX8_DECIMAL_DIGITS;
453 break;
455 case 4:
457 DecimalLength = ACPI_MAX32_DECIMAL_DIGITS;
458 break;
460 case 8:
461 default:
463 DecimalLength = ACPI_MAX64_DECIMAL_DIGITS;
464 break;
467 SupressZeros = TRUE; /* No leading zeros */
468 Remainder = 0;
470 for (i = DecimalLength; i > 0; i--)
472 /* Divide by nth factor of 10 */
474 Digit = Integer;
475 for (j = 0; j < i; j++)
477 (void) AcpiUtShortDivide (Digit, 10, &Digit, &Remainder);
480 /* Handle leading zeros */
482 if (Remainder != 0)
484 SupressZeros = FALSE;
487 if (!SupressZeros)
489 String[k] = (UINT8) (ACPI_ASCII_ZERO + Remainder);
490 k++;
493 break;
495 case 16:
497 /* HexLength: 2 ascii hex chars per data byte */
499 HexLength = ACPI_MUL_2 (DataWidth);
500 for (i = 0, j = (HexLength-1); i < HexLength; i++, j--)
502 /* Get one hex digit, most significant digits first */
504 String[k] = (UINT8)
505 AcpiUtHexToAsciiChar (Integer, ACPI_MUL_4 (j));
506 k++;
508 break;
510 default:
511 return (0);
515 * Since leading zeros are suppressed, we must check for the case where
516 * the integer equals 0
518 * Finally, null terminate the string and return the length
520 if (!k)
522 String [0] = ACPI_ASCII_ZERO;
523 k = 1;
526 String [k] = 0;
527 return ((UINT32) k);
531 /*******************************************************************************
533 * FUNCTION: AcpiExConvertToString
535 * PARAMETERS: ObjDesc - Object to be converted. Must be an
536 * Integer, Buffer, or String
537 * ResultDesc - Where the string object is returned
538 * Type - String flags (base and conversion type)
540 * RETURN: Status
542 * DESCRIPTION: Convert an ACPI Object to a string
544 ******************************************************************************/
546 ACPI_STATUS
547 AcpiExConvertToString (
548 ACPI_OPERAND_OBJECT *ObjDesc,
549 ACPI_OPERAND_OBJECT **ResultDesc,
550 UINT32 Type)
552 ACPI_OPERAND_OBJECT *ReturnDesc;
553 UINT8 *NewBuf;
554 UINT32 i;
555 UINT32 StringLength = 0;
556 UINT16 Base = 16;
557 UINT8 Separator = ',';
560 ACPI_FUNCTION_TRACE_PTR (ExConvertToString, ObjDesc);
563 switch (ObjDesc->Common.Type)
565 case ACPI_TYPE_STRING:
567 /* No conversion necessary */
569 *ResultDesc = ObjDesc;
570 return_ACPI_STATUS (AE_OK);
572 case ACPI_TYPE_INTEGER:
574 switch (Type)
576 case ACPI_EXPLICIT_CONVERT_DECIMAL:
578 /* Make room for maximum decimal number */
580 StringLength = ACPI_MAX_DECIMAL_DIGITS;
581 Base = 10;
582 break;
584 default:
586 /* Two hex string characters for each integer byte */
588 StringLength = ACPI_MUL_2 (AcpiGbl_IntegerByteWidth);
589 break;
593 * Create a new String
594 * Need enough space for one ASCII integer (plus null terminator)
596 ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength);
597 if (!ReturnDesc)
599 return_ACPI_STATUS (AE_NO_MEMORY);
602 NewBuf = ReturnDesc->Buffer.Pointer;
604 /* Convert integer to string */
606 StringLength = AcpiExConvertToAscii (
607 ObjDesc->Integer.Value, Base, NewBuf, AcpiGbl_IntegerByteWidth);
609 /* Null terminate at the correct place */
611 ReturnDesc->String.Length = StringLength;
612 NewBuf [StringLength] = 0;
613 break;
615 case ACPI_TYPE_BUFFER:
617 /* Setup string length, base, and separator */
619 switch (Type)
621 case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by ToDecimalString */
623 * From ACPI: "If Data is a buffer, it is converted to a string of
624 * decimal values separated by commas."
626 Base = 10;
629 * Calculate the final string length. Individual string values
630 * are variable length (include separator for each)
632 for (i = 0; i < ObjDesc->Buffer.Length; i++)
634 if (ObjDesc->Buffer.Pointer[i] >= 100)
636 StringLength += 4;
638 else if (ObjDesc->Buffer.Pointer[i] >= 10)
640 StringLength += 3;
642 else
644 StringLength += 2;
647 break;
649 case ACPI_IMPLICIT_CONVERT_HEX:
651 * From the ACPI spec:
652 *"The entire contents of the buffer are converted to a string of
653 * two-character hexadecimal numbers, each separated by a space."
655 Separator = ' ';
656 StringLength = (ObjDesc->Buffer.Length * 3);
657 break;
659 case ACPI_EXPLICIT_CONVERT_HEX: /* Used by ToHexString */
661 * From ACPI: "If Data is a buffer, it is converted to a string of
662 * hexadecimal values separated by commas."
664 StringLength = (ObjDesc->Buffer.Length * 3);
665 break;
667 default:
668 return_ACPI_STATUS (AE_BAD_PARAMETER);
672 * Create a new string object and string buffer
673 * (-1 because of extra separator included in StringLength from above)
674 * Allow creation of zero-length strings from zero-length buffers.
676 if (StringLength)
678 StringLength--;
681 ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength);
682 if (!ReturnDesc)
684 return_ACPI_STATUS (AE_NO_MEMORY);
687 NewBuf = ReturnDesc->Buffer.Pointer;
690 * Convert buffer bytes to hex or decimal values
691 * (separated by commas or spaces)
693 for (i = 0; i < ObjDesc->Buffer.Length; i++)
695 NewBuf += AcpiExConvertToAscii (
696 (UINT64) ObjDesc->Buffer.Pointer[i], Base, NewBuf, 1);
697 *NewBuf++ = Separator; /* each separated by a comma or space */
701 * Null terminate the string
702 * (overwrites final comma/space from above)
704 if (ObjDesc->Buffer.Length)
706 NewBuf--;
708 *NewBuf = 0;
709 break;
711 default:
713 return_ACPI_STATUS (AE_TYPE);
716 *ResultDesc = ReturnDesc;
717 return_ACPI_STATUS (AE_OK);
721 /*******************************************************************************
723 * FUNCTION: AcpiExConvertToTargetType
725 * PARAMETERS: DestinationType - Current type of the destination
726 * SourceDesc - Source object to be converted.
727 * ResultDesc - Where the converted object is returned
728 * WalkState - Current method state
730 * RETURN: Status
732 * DESCRIPTION: Implements "implicit conversion" rules for storing an object.
734 ******************************************************************************/
736 ACPI_STATUS
737 AcpiExConvertToTargetType (
738 ACPI_OBJECT_TYPE DestinationType,
739 ACPI_OPERAND_OBJECT *SourceDesc,
740 ACPI_OPERAND_OBJECT **ResultDesc,
741 ACPI_WALK_STATE *WalkState)
743 ACPI_STATUS Status = AE_OK;
746 ACPI_FUNCTION_TRACE (ExConvertToTargetType);
749 /* Default behavior */
751 *ResultDesc = SourceDesc;
754 * If required by the target,
755 * perform implicit conversion on the source before we store it.
757 switch (GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs))
759 case ARGI_SIMPLE_TARGET:
760 case ARGI_INTEGER_REF: /* Handles Increment, Decrement cases */
762 switch (DestinationType)
764 case ACPI_TYPE_LOCAL_REGION_FIELD:
766 * Named field can always handle conversions
768 break;
770 default:
772 /* No conversion allowed for these types */
774 if (DestinationType != SourceDesc->Common.Type)
776 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
777 "Explicit operator, will store (%s) over existing type (%s)\n",
778 AcpiUtGetObjectTypeName (SourceDesc),
779 AcpiUtGetTypeName (DestinationType)));
780 Status = AE_TYPE;
783 break;
785 case ARGI_TARGETREF:
786 case ARGI_STORE_TARGET:
788 switch (DestinationType)
790 case ACPI_TYPE_INTEGER:
791 case ACPI_TYPE_BUFFER_FIELD:
792 case ACPI_TYPE_LOCAL_BANK_FIELD:
793 case ACPI_TYPE_LOCAL_INDEX_FIELD:
795 * These types require an Integer operand. We can convert
796 * a Buffer or a String to an Integer if necessary.
798 Status = AcpiExConvertToInteger (SourceDesc, ResultDesc,
799 ACPI_IMPLICIT_CONVERSION);
800 break;
802 case ACPI_TYPE_STRING:
804 * The operand must be a String. We can convert an
805 * Integer or Buffer if necessary
807 Status = AcpiExConvertToString (SourceDesc, ResultDesc,
808 ACPI_IMPLICIT_CONVERT_HEX);
809 break;
811 case ACPI_TYPE_BUFFER:
813 * The operand must be a Buffer. We can convert an
814 * Integer or String if necessary
816 Status = AcpiExConvertToBuffer (SourceDesc, ResultDesc);
817 break;
819 default:
821 ACPI_ERROR ((AE_INFO,
822 "Bad destination type during conversion: 0x%X",
823 DestinationType));
824 Status = AE_AML_INTERNAL;
825 break;
827 break;
829 case ARGI_REFERENCE:
831 * CreateXxxxField cases - we are storing the field object into the name
833 break;
835 default:
837 ACPI_ERROR ((AE_INFO,
838 "Unknown Target type ID 0x%X AmlOpcode 0x%X DestType %s",
839 GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs),
840 WalkState->Opcode, AcpiUtGetTypeName (DestinationType)));
841 Status = AE_AML_INTERNAL;
845 * Source-to-Target conversion semantics:
847 * If conversion to the target type cannot be performed, then simply
848 * overwrite the target with the new object and type.
850 if (Status == AE_TYPE)
852 Status = AE_OK;
855 return_ACPI_STATUS (Status);