Path: blob/main/sys/contrib/dev/acpica/components/executer/exconvrt.c
48521 views
/******************************************************************************1*2* Module Name: exconvrt - Object conversion routines3*4*****************************************************************************/56/******************************************************************************7*8* 1. Copyright Notice9*10* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.11* All rights reserved.12*13* 2. License14*15* 2.1. This is your license from Intel Corp. under its intellectual property16* rights. You may have additional license terms from the party that provided17* you this software, covering your right to use that party's intellectual18* property rights.19*20* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a21* copy of the source code appearing in this file ("Covered Code") an22* irrevocable, perpetual, worldwide license under Intel's copyrights in the23* base code distributed originally by Intel ("Original Intel Code") to copy,24* make derivatives, distribute, use and display any portion of the Covered25* Code in any form, with the right to sublicense such rights; and26*27* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent28* license (with the right to sublicense), under only those claims of Intel29* patents that are infringed by the Original Intel Code, to make, use, sell,30* offer to sell, and import the Covered Code and derivative works thereof31* solely to the minimum extent necessary to exercise the above copyright32* license, and in no event shall the patent license extend to any additions33* to or modifications of the Original Intel Code. No other license or right34* is granted directly or by implication, estoppel or otherwise;35*36* The above copyright and patent license is granted only if the following37* conditions are met:38*39* 3. Conditions40*41* 3.1. Redistribution of Source with Rights to Further Distribute Source.42* Redistribution of source code of any substantial portion of the Covered43* Code or modification with rights to further distribute source must include44* the above Copyright Notice, the above License, this list of Conditions,45* and the following Disclaimer and Export Compliance provision. In addition,46* Licensee must cause all Covered Code to which Licensee contributes to47* contain a file documenting the changes Licensee made to create that Covered48* Code and the date of any change. Licensee must include in that file the49* documentation of any changes made by any predecessor Licensee. Licensee50* must include a prominent statement that the modification is derived,51* directly or indirectly, from Original Intel Code.52*53* 3.2. Redistribution of Source with no Rights to Further Distribute Source.54* Redistribution of source code of any substantial portion of the Covered55* Code or modification without rights to further distribute source must56* include the following Disclaimer and Export Compliance provision in the57* documentation and/or other materials provided with distribution. In58* addition, Licensee may not authorize further sublicense of source of any59* portion of the Covered Code, and must include terms to the effect that the60* license from Licensee to its licensee is limited to the intellectual61* property embodied in the software Licensee provides to its licensee, and62* not to intellectual property embodied in modifications its licensee may63* make.64*65* 3.3. Redistribution of Executable. Redistribution in executable form of any66* substantial portion of the Covered Code or modification must reproduce the67* above Copyright Notice, and the following Disclaimer and Export Compliance68* provision in the documentation and/or other materials provided with the69* distribution.70*71* 3.4. Intel retains all right, title, and interest in and to the Original72* Intel Code.73*74* 3.5. Neither the name Intel nor any other trademark owned or controlled by75* Intel shall be used in advertising or otherwise to promote the sale, use or76* other dealings in products derived from or relating to the Covered Code77* without prior written authorization from Intel.78*79* 4. Disclaimer and Export Compliance80*81* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED82* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE83* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,84* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY85* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY86* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A87* PARTICULAR PURPOSE.88*89* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES90* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR91* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,92* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY93* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL94* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS95* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY96* LIMITED REMEDY.97*98* 4.3. Licensee shall not export, either directly or indirectly, any of this99* software or system incorporating such software without first obtaining any100* required license or other approval from the U. S. Department of Commerce or101* any other agency or department of the United States Government. In the102* event Licensee exports any such software from the United States or103* re-exports any such software from a foreign destination, Licensee shall104* ensure that the distribution and export/re-export of the software is in105* compliance with all laws, regulations, orders, or other restrictions of the106* U.S. Export Administration Regulations. Licensee agrees that neither it nor107* any of its subsidiaries will export/re-export any technical data, process,108* software, or service, directly or indirectly, to any country for which the109* United States government or any agency thereof requires an export license,110* other governmental approval, or letter of assurance, without first obtaining111* such license, approval or letter.112*113*****************************************************************************114*115* Alternatively, you may choose to be licensed under the terms of the116* following license:117*118* Redistribution and use in source and binary forms, with or without119* modification, are permitted provided that the following conditions120* are met:121* 1. Redistributions of source code must retain the above copyright122* notice, this list of conditions, and the following disclaimer,123* without modification.124* 2. Redistributions in binary form must reproduce at minimum a disclaimer125* substantially similar to the "NO WARRANTY" disclaimer below126* ("Disclaimer") and any redistribution must be conditioned upon127* including a substantially similar Disclaimer requirement for further128* binary redistribution.129* 3. Neither the names of the above-listed copyright holders nor the names130* of any contributors may be used to endorse or promote products derived131* from this software without specific prior written permission.132*133* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS134* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT135* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR136* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT137* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,138* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT139* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,140* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY141* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT142* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE143* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.144*145* Alternatively, you may choose to be licensed under the terms of the146* GNU General Public License ("GPL") version 2 as published by the Free147* Software Foundation.148*149*****************************************************************************/150151#include <contrib/dev/acpica/include/acpi.h>152#include <contrib/dev/acpica/include/accommon.h>153#include <contrib/dev/acpica/include/acinterp.h>154#include <contrib/dev/acpica/include/amlcode.h>155156157#define _COMPONENT ACPI_EXECUTER158ACPI_MODULE_NAME ("exconvrt")159160/* Local prototypes */161162static UINT32163AcpiExConvertToAscii (164UINT64 Integer,165UINT16 Base,166UINT8 *String,167UINT8 MaxLength,168BOOLEAN LeadingZeros);169170171/*******************************************************************************172*173* FUNCTION: AcpiExConvertToInteger174*175* PARAMETERS: ObjDesc - Object to be converted. Must be an176* Integer, Buffer, or String177* ResultDesc - Where the new Integer object is returned178* ImplicitConversion - Used for string conversion179*180* RETURN: Status181*182* DESCRIPTION: Convert an ACPI Object to an integer.183*184******************************************************************************/185186ACPI_STATUS187AcpiExConvertToInteger (188ACPI_OPERAND_OBJECT *ObjDesc,189ACPI_OPERAND_OBJECT **ResultDesc,190UINT32 ImplicitConversion)191{192ACPI_OPERAND_OBJECT *ReturnDesc;193UINT8 *Pointer;194UINT64 Result;195UINT32 i;196UINT32 Count;197198199ACPI_FUNCTION_TRACE_PTR (ExConvertToInteger, ObjDesc);200201202switch (ObjDesc->Common.Type)203{204case ACPI_TYPE_INTEGER:205206/* No conversion necessary */207208*ResultDesc = ObjDesc;209return_ACPI_STATUS (AE_OK);210211case ACPI_TYPE_BUFFER:212case ACPI_TYPE_STRING:213214/* Note: Takes advantage of common buffer/string fields */215216Pointer = ObjDesc->Buffer.Pointer;217Count = ObjDesc->Buffer.Length;218break;219220default:221222return_ACPI_STATUS (AE_TYPE);223}224225/*226* Convert the buffer/string to an integer. Note that both buffers and227* strings are treated as raw data - we don't convert ascii to hex for228* strings.229*230* There are two terminating conditions for the loop:231* 1) The size of an integer has been reached, or232* 2) The end of the buffer or string has been reached233*/234Result = 0;235236/* String conversion is different than Buffer conversion */237238switch (ObjDesc->Common.Type)239{240case ACPI_TYPE_STRING:241/*242* Convert string to an integer - for most cases, the string must be243* hexadecimal as per the ACPI specification. The only exception (as244* of ACPI 3.0) is that the ToInteger() operator allows both decimal245* and hexadecimal strings (hex prefixed with "0x").246*247* Explicit conversion is used only by ToInteger.248* All other string-to-integer conversions are implicit conversions.249*/250if (ImplicitConversion)251{252Result = AcpiUtImplicitStrtoul64 (ACPI_CAST_PTR (char, Pointer));253}254else255{256Result = AcpiUtExplicitStrtoul64 (ACPI_CAST_PTR (char, Pointer));257}258break;259260case ACPI_TYPE_BUFFER:261262/* Check for zero-length buffer */263264if (!Count)265{266return_ACPI_STATUS (AE_AML_BUFFER_LIMIT);267}268269/* Transfer no more than an integer's worth of data */270271if (Count > AcpiGbl_IntegerByteWidth)272{273Count = AcpiGbl_IntegerByteWidth;274}275276/*277* Convert buffer to an integer - we simply grab enough raw data278* from the buffer to fill an integer279*/280for (i = 0; i < Count; i++)281{282/*283* Get next byte and shift it into the Result.284* Little endian is used, meaning that the first byte of the buffer285* is the LSB of the integer286*/287Result |= (((UINT64) Pointer[i]) << (i * 8));288}289break;290291default:292293/* No other types can get here */294295break;296}297298/* Create a new integer */299300ReturnDesc = AcpiUtCreateIntegerObject (Result);301if (!ReturnDesc)302{303return_ACPI_STATUS (AE_NO_MEMORY);304}305306ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n",307ACPI_FORMAT_UINT64 (Result)));308309/* Save the Result */310311(void) AcpiExTruncateFor32bitTable (ReturnDesc);312*ResultDesc = ReturnDesc;313return_ACPI_STATUS (AE_OK);314}315316317/*******************************************************************************318*319* FUNCTION: AcpiExConvertToBuffer320*321* PARAMETERS: ObjDesc - Object to be converted. Must be an322* Integer, Buffer, or String323* ResultDesc - Where the new buffer object is returned324*325* RETURN: Status326*327* DESCRIPTION: Convert an ACPI Object to a Buffer328*329******************************************************************************/330331ACPI_STATUS332AcpiExConvertToBuffer (333ACPI_OPERAND_OBJECT *ObjDesc,334ACPI_OPERAND_OBJECT **ResultDesc)335{336ACPI_OPERAND_OBJECT *ReturnDesc;337UINT8 *NewBuf;338339340ACPI_FUNCTION_TRACE_PTR (ExConvertToBuffer, ObjDesc);341342343switch (ObjDesc->Common.Type)344{345case ACPI_TYPE_BUFFER:346347/* No conversion necessary */348349*ResultDesc = ObjDesc;350return_ACPI_STATUS (AE_OK);351352353case ACPI_TYPE_INTEGER:354/*355* Create a new Buffer object.356* Need enough space for one integer357*/358ReturnDesc = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth);359if (!ReturnDesc)360{361return_ACPI_STATUS (AE_NO_MEMORY);362}363364/* Copy the integer to the buffer, LSB first */365366NewBuf = ReturnDesc->Buffer.Pointer;367memcpy (NewBuf, &ObjDesc->Integer.Value, AcpiGbl_IntegerByteWidth);368break;369370case ACPI_TYPE_STRING:371/*372* Create a new Buffer object373* Size will be the string length374*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 existing377* ASL/AML code that depends on the null being transferred to the new378* buffer.379*/380ReturnDesc = AcpiUtCreateBufferObject ((ACPI_SIZE)381ObjDesc->String.Length + 1);382if (!ReturnDesc)383{384return_ACPI_STATUS (AE_NO_MEMORY);385}386387/* Copy the string to the buffer */388389NewBuf = ReturnDesc->Buffer.Pointer;390memcpy ((char *) NewBuf, (char *) ObjDesc->String.Pointer,391ObjDesc->String.Length);392break;393394default:395396return_ACPI_STATUS (AE_TYPE);397}398399/* Mark buffer initialized */400401ReturnDesc->Common.Flags |= AOPOBJ_DATA_VALID;402*ResultDesc = ReturnDesc;403return_ACPI_STATUS (AE_OK);404}405406407/*******************************************************************************408*409* FUNCTION: AcpiExConvertToAscii410*411* PARAMETERS: Integer - Value to be converted412* Base - ACPI_STRING_DECIMAL or ACPI_STRING_HEX413* String - Where the string is returned414* DataWidth - Size of data item to be converted, in bytes415* LeadingZeros - Allow leading zeros416*417* RETURN: Actual string length418*419* DESCRIPTION: Convert an ACPI Integer to a hex or decimal string420*421******************************************************************************/422423static UINT32424AcpiExConvertToAscii (425UINT64 Integer,426UINT16 Base,427UINT8 *String,428UINT8 DataWidth,429BOOLEAN LeadingZeros)430{431UINT64 Digit;432UINT32 i;433UINT32 j;434UINT32 k = 0;435UINT32 HexLength;436UINT32 DecimalLength;437UINT32 Remainder;438BOOLEAN SupressZeros = !LeadingZeros;439UINT8 HexChar;440441442ACPI_FUNCTION_ENTRY ();443444445switch (Base)446{447case 10:448449/* Setup max length for the decimal number */450451switch (DataWidth)452{453case 1:454455DecimalLength = ACPI_MAX8_DECIMAL_DIGITS;456break;457458case 4:459460DecimalLength = ACPI_MAX32_DECIMAL_DIGITS;461break;462463case 8:464default:465466DecimalLength = ACPI_MAX64_DECIMAL_DIGITS;467break;468}469470Remainder = 0;471472for (i = DecimalLength; i > 0; i--)473{474/* Divide by nth factor of 10 */475476Digit = Integer;477for (j = 0; j < i; j++)478{479(void) AcpiUtShortDivide (Digit, 10, &Digit, &Remainder);480}481482/* Handle leading zeros */483484if (Remainder != 0)485{486SupressZeros = FALSE;487}488489if (!SupressZeros)490{491String[k] = (UINT8) (ACPI_ASCII_ZERO + Remainder);492k++;493}494}495break;496497case 16:498499/* HexLength: 2 ascii hex chars per data byte */500501HexLength = (DataWidth * 2);502for (i = 0, j = (HexLength-1); i < HexLength; i++, j--)503{504/* Get one hex digit, most significant digits first */505506HexChar = (UINT8)507AcpiUtHexToAsciiChar (Integer, ACPI_MUL_4 (j));508509/* Supress leading zeros until the first non-zero character */510511if (HexChar == ACPI_ASCII_ZERO && SupressZeros)512{513continue;514}515516SupressZeros = FALSE;517String[k] = HexChar;518k++;519}520break;521522default:523return (0);524}525526/*527* Since leading zeros are suppressed, we must check for the case where528* the integer equals 0529*530* Finally, null terminate the string and return the length531*/532if (!k)533{534String [0] = ACPI_ASCII_ZERO;535k = 1;536}537538String [k] = 0;539return ((UINT32) k);540}541542543/*******************************************************************************544*545* FUNCTION: AcpiExConvertToString546*547* PARAMETERS: ObjDesc - Object to be converted. Must be an548* Integer, Buffer, or String549* ResultDesc - Where the string object is returned550* Type - String flags (base and conversion type)551*552* RETURN: Status553*554* DESCRIPTION: Convert an ACPI Object to a string. Supports both implicit555* and explicit conversions and related rules.556*557******************************************************************************/558559ACPI_STATUS560AcpiExConvertToString (561ACPI_OPERAND_OBJECT *ObjDesc,562ACPI_OPERAND_OBJECT **ResultDesc,563UINT32 Type)564{565ACPI_OPERAND_OBJECT *ReturnDesc;566UINT8 *NewBuf;567UINT32 i;568UINT32 StringLength = 0;569UINT16 Base = 16;570UINT8 Separator = ',';571BOOLEAN LeadingZeros;572573574ACPI_FUNCTION_TRACE_PTR (ExConvertToString, ObjDesc);575576577switch (ObjDesc->Common.Type)578{579case ACPI_TYPE_STRING:580581/* No conversion necessary */582583*ResultDesc = ObjDesc;584return_ACPI_STATUS (AE_OK);585586case ACPI_TYPE_INTEGER:587588switch (Type)589{590case ACPI_EXPLICIT_CONVERT_DECIMAL:591/*592* From ToDecimalString, integer source.593*594* Make room for the maximum decimal number size595*/596StringLength = ACPI_MAX_DECIMAL_DIGITS;597LeadingZeros = FALSE;598Base = 10;599break;600601case ACPI_EXPLICIT_CONVERT_HEX:602/*603* From ToHexString.604*605* Supress leading zeros and append "0x"606*/607StringLength = ACPI_MUL_2 (AcpiGbl_IntegerByteWidth) + 2;608LeadingZeros = FALSE;609break;610default:611612/* Two hex string characters for each integer byte */613614StringLength = ACPI_MUL_2 (AcpiGbl_IntegerByteWidth);615LeadingZeros = TRUE;616break;617}618619/*620* Create a new String621* Need enough space for one ASCII integer (plus null terminator)622*/623ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength);624if (!ReturnDesc)625{626return_ACPI_STATUS (AE_NO_MEMORY);627}628629NewBuf = ReturnDesc->Buffer.Pointer;630if (Type == ACPI_EXPLICIT_CONVERT_HEX)631{632/* Append "0x" prefix for explicit hex conversion */633634*NewBuf++ = '0';635*NewBuf++ = 'x';636}637638/* Convert integer to string */639640StringLength = AcpiExConvertToAscii (641ObjDesc->Integer.Value, Base, NewBuf, AcpiGbl_IntegerByteWidth, LeadingZeros);642643/* Null terminate at the correct place */644645ReturnDesc->String.Length = StringLength;646if (Type == ACPI_EXPLICIT_CONVERT_HEX)647{648/* Take "0x" prefix into account */649650ReturnDesc->String.Length += 2;651}652653NewBuf [StringLength] = 0;654break;655656case ACPI_TYPE_BUFFER:657658/* Setup string length, base, and separator */659660switch (Type)661{662case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by ToDecimalString */663/*664* Explicit conversion from the ToDecimalString ASL operator.665*666* From ACPI: "If the input is a buffer, it is converted to a667* a string of decimal values separated by commas."668*/669LeadingZeros = FALSE;670Base = 10;671672/*673* Calculate the final string length. Individual string values674* are variable length (include separator for each)675*/676for (i = 0; i < ObjDesc->Buffer.Length; i++)677{678if (ObjDesc->Buffer.Pointer[i] >= 100)679{680StringLength += 4;681}682else if (ObjDesc->Buffer.Pointer[i] >= 10)683{684StringLength += 3;685}686else687{688StringLength += 2;689}690}691break;692693case ACPI_IMPLICIT_CONVERT_HEX:694/*695* Implicit buffer-to-string conversion696*697* From the ACPI spec:698* "The entire contents of the buffer are converted to a string of699* two-character hexadecimal numbers, each separated by a space."700*701* Each hex number is prefixed with 0x (11/2018)702*/703LeadingZeros = TRUE;704Separator = ' ';705StringLength = (ObjDesc->Buffer.Length * 5);706break;707708case ACPI_EXPLICIT_CONVERT_HEX:709/*710* Explicit conversion from the ToHexString ASL operator.711*712* From ACPI: "If Data is a buffer, it is converted to a string of713* hexadecimal values separated by commas."714*715* Each hex number is prefixed with 0x (11/2018)716*/717LeadingZeros = TRUE;718Separator = ',';719StringLength = (ObjDesc->Buffer.Length * 5);720break;721722default:723return_ACPI_STATUS (AE_BAD_PARAMETER);724}725726/*727* Create a new string object and string buffer728* (-1 because of extra separator included in StringLength from above)729* Allow creation of zero-length strings from zero-length buffers.730*/731if (StringLength)732{733StringLength--;734}735736ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength);737if (!ReturnDesc)738{739return_ACPI_STATUS (AE_NO_MEMORY);740}741742NewBuf = ReturnDesc->Buffer.Pointer;743744/*745* Convert buffer bytes to hex or decimal values746* (separated by commas or spaces)747*/748for (i = 0; i < ObjDesc->Buffer.Length; i++)749{750if (Base == 16)751{752/* Emit 0x prefix for explicit/implicit hex conversion */753754*NewBuf++ = '0';755*NewBuf++ = 'x';756}757758NewBuf += AcpiExConvertToAscii (759(UINT64) ObjDesc->Buffer.Pointer[i], Base, NewBuf, 1, LeadingZeros);760761/* Each digit is separated by either a comma or space */762763*NewBuf++ = Separator;764}765766/*767* Null terminate the string768* (overwrites final comma/space from above)769*/770if (ObjDesc->Buffer.Length)771{772NewBuf--;773}774*NewBuf = 0;775break;776777default:778779return_ACPI_STATUS (AE_TYPE);780}781782*ResultDesc = ReturnDesc;783return_ACPI_STATUS (AE_OK);784}785786787/*******************************************************************************788*789* FUNCTION: AcpiExConvertToTargetType790*791* PARAMETERS: DestinationType - Current type of the destination792* SourceDesc - Source object to be converted.793* ResultDesc - Where the converted object is returned794* WalkState - Current method state795*796* RETURN: Status797*798* DESCRIPTION: Implements "implicit conversion" rules for storing an object.799*800******************************************************************************/801802ACPI_STATUS803AcpiExConvertToTargetType (804ACPI_OBJECT_TYPE DestinationType,805ACPI_OPERAND_OBJECT *SourceDesc,806ACPI_OPERAND_OBJECT **ResultDesc,807ACPI_WALK_STATE *WalkState)808{809ACPI_STATUS Status = AE_OK;810811812ACPI_FUNCTION_TRACE (ExConvertToTargetType);813814815/* Default behavior */816817*ResultDesc = SourceDesc;818819/*820* If required by the target,821* perform implicit conversion on the source before we store it.822*/823switch (GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs))824{825case ARGI_SIMPLE_TARGET:826case ARGI_FIXED_TARGET:827case ARGI_INTEGER_REF: /* Handles Increment, Decrement cases */828829switch (DestinationType)830{831case ACPI_TYPE_LOCAL_REGION_FIELD:832/*833* Named field can always handle conversions834*/835break;836837default:838839/* No conversion allowed for these types */840841if (DestinationType != SourceDesc->Common.Type)842{843ACPI_DEBUG_PRINT ((ACPI_DB_INFO,844"Explicit operator, will store (%s) over existing type (%s)\n",845AcpiUtGetObjectTypeName (SourceDesc),846AcpiUtGetTypeName (DestinationType)));847Status = AE_TYPE;848}849}850break;851852case ARGI_TARGETREF:853case ARGI_STORE_TARGET:854855switch (DestinationType)856{857case ACPI_TYPE_INTEGER:858case ACPI_TYPE_BUFFER_FIELD:859case ACPI_TYPE_LOCAL_BANK_FIELD:860case ACPI_TYPE_LOCAL_INDEX_FIELD:861/*862* These types require an Integer operand. We can convert863* a Buffer or a String to an Integer if necessary.864*/865Status = AcpiExConvertToInteger (SourceDesc, ResultDesc,866ACPI_IMPLICIT_CONVERSION);867break;868869case ACPI_TYPE_STRING:870/*871* The operand must be a String. We can convert an872* Integer or Buffer if necessary873*/874Status = AcpiExConvertToString (SourceDesc, ResultDesc,875ACPI_IMPLICIT_CONVERT_HEX);876break;877878case ACPI_TYPE_BUFFER:879/*880* The operand must be a Buffer. We can convert an881* Integer or String if necessary882*/883Status = AcpiExConvertToBuffer (SourceDesc, ResultDesc);884break;885886default:887888ACPI_ERROR ((AE_INFO,889"Bad destination type during conversion: 0x%X",890DestinationType));891Status = AE_AML_INTERNAL;892break;893}894break;895896case ARGI_REFERENCE:897/*898* CreateXxxxField cases - we are storing the field object into the name899*/900break;901902default:903904ACPI_ERROR ((AE_INFO,905"Unknown Target type ID 0x%X AmlOpcode 0x%X DestType %s",906GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs),907WalkState->Opcode, AcpiUtGetTypeName (DestinationType)));908Status = AE_AML_INTERNAL;909}910911/*912* Source-to-Target conversion semantics:913*914* If conversion to the target type cannot be performed, then simply915* overwrite the target with the new object and type.916*/917if (Status == AE_TYPE)918{919Status = AE_OK;920}921922return_ACPI_STATUS (Status);923}924925926