Lines Matching +full:end +full:- +full:of +full:- +full:conversion

1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
4 * Module Name: exconvrt - Object conversion routines
6 * Copyright (C) 2000 - 2023, Intel Corp.
27 * PARAMETERS: obj_desc - Object to be converted. Must be an
29 * result_desc - Where the new Integer object is returned
30 * implicit_conversion - Used for string conversion
51 switch (obj_desc->common.type) { in acpi_ex_convert_to_integer()
54 /* No conversion necessary */ in acpi_ex_convert_to_integer()
62 /* Note: Takes advantage of common buffer/string fields */ in acpi_ex_convert_to_integer()
64 pointer = obj_desc->buffer.pointer; in acpi_ex_convert_to_integer()
65 count = obj_desc->buffer.length; in acpi_ex_convert_to_integer()
75 * strings are treated as raw data - we don't convert ascii to hex for in acpi_ex_convert_to_integer()
79 * 1) The size of an integer has been reached, or in acpi_ex_convert_to_integer()
80 * 2) The end of the buffer or string has been reached in acpi_ex_convert_to_integer()
84 /* String conversion is different than Buffer conversion */ in acpi_ex_convert_to_integer()
86 switch (obj_desc->common.type) { in acpi_ex_convert_to_integer()
89 * Convert string to an integer - for most cases, the string must be in acpi_ex_convert_to_integer()
91 * of ACPI 3.0) is that the to_integer() operator allows both decimal in acpi_ex_convert_to_integer()
94 * Explicit conversion is used only by to_integer. in acpi_ex_convert_to_integer()
95 * All other string-to-integer conversions are implicit conversions. in acpi_ex_convert_to_integer()
110 /* Check for zero-length buffer */ in acpi_ex_convert_to_integer()
116 /* Transfer no more than an integer's worth of data */ in acpi_ex_convert_to_integer()
123 * Convert buffer to an integer - we simply grab enough raw data in acpi_ex_convert_to_integer()
129 * Little endian is used, meaning that the first byte of the buffer in acpi_ex_convert_to_integer()
130 * is the LSB of the integer in acpi_ex_convert_to_integer()
164 * PARAMETERS: obj_desc - Object to be converted. Must be an
166 * result_desc - Where the new buffer object is returned
183 switch (obj_desc->common.type) { in acpi_ex_convert_to_buffer()
186 /* No conversion necessary */ in acpi_ex_convert_to_buffer()
204 new_buf = return_desc->buffer.pointer; in acpi_ex_convert_to_buffer()
205 memcpy(new_buf, &obj_desc->integer.value, in acpi_ex_convert_to_buffer()
220 obj_desc->string. in acpi_ex_convert_to_buffer()
228 new_buf = return_desc->buffer.pointer; in acpi_ex_convert_to_buffer()
229 strncpy((char *)new_buf, (char *)obj_desc->string.pointer, in acpi_ex_convert_to_buffer()
230 obj_desc->string.length); in acpi_ex_convert_to_buffer()
240 return_desc->common.flags |= AOPOBJ_DATA_VALID; in acpi_ex_convert_to_buffer()
249 * PARAMETERS: integer - Value to be converted
250 * base - ACPI_STRING_DECIMAL or ACPI_STRING_HEX
251 * string - Where the string is returned
252 * data_width - Size of data item to be converted, in bytes
253 * leading_zeros - Allow leading zeros
302 for (i = decimal_length; i > 0; i--) { in acpi_ex_convert_to_ascii()
304 /* Divide by nth factor of 10 */ in acpi_ex_convert_to_ascii()
330 for (i = 0, j = (hex_length - 1); i < hex_length; i++, j--) { in acpi_ex_convert_to_ascii()
337 /* Supress leading zeros until the first non-zero character */ in acpi_ex_convert_to_ascii()
372 * PARAMETERS: obj_desc - Object to be converted. Must be an
374 * result_desc - Where the string object is returned
375 * type - String flags (base and conversion type)
398 switch (obj_desc->common.type) { in acpi_ex_convert_to_string()
401 /* No conversion necessary */ in acpi_ex_convert_to_string()
449 new_buf = return_desc->buffer.pointer; in acpi_ex_convert_to_string()
452 /* Append "0x" prefix for explicit hex conversion */ in acpi_ex_convert_to_string()
461 acpi_ex_convert_to_ascii(obj_desc->integer.value, base, in acpi_ex_convert_to_string()
468 return_desc->string.length = string_length; in acpi_ex_convert_to_string()
473 return_desc->string.length += 2; in acpi_ex_convert_to_string()
486 * Explicit conversion from the to_decimal_string ASL operator. in acpi_ex_convert_to_string()
489 * a string of decimal values separated by commas." in acpi_ex_convert_to_string()
498 for (i = 0; i < obj_desc->buffer.length; i++) { in acpi_ex_convert_to_string()
499 if (obj_desc->buffer.pointer[i] >= 100) { in acpi_ex_convert_to_string()
501 } else if (obj_desc->buffer.pointer[i] >= 10) { in acpi_ex_convert_to_string()
511 * Implicit buffer-to-string conversion in acpi_ex_convert_to_string()
514 * "The entire contents of the buffer are converted to a string of in acpi_ex_convert_to_string()
515 * two-character hexadecimal numbers, each separated by a space." in acpi_ex_convert_to_string()
521 string_length = (obj_desc->buffer.length * 5); in acpi_ex_convert_to_string()
526 * Explicit conversion from the to_hex_string ASL operator. in acpi_ex_convert_to_string()
528 * From ACPI: "If Data is a buffer, it is converted to a string of in acpi_ex_convert_to_string()
535 string_length = (obj_desc->buffer.length * 5); in acpi_ex_convert_to_string()
544 * (-1 because of extra separator included in string_length from above) in acpi_ex_convert_to_string()
545 * Allow creation of zero-length strings from zero-length buffers. in acpi_ex_convert_to_string()
548 string_length--; in acpi_ex_convert_to_string()
557 new_buf = return_desc->buffer.pointer; in acpi_ex_convert_to_string()
563 for (i = 0; i < obj_desc->buffer.length; i++) { in acpi_ex_convert_to_string()
566 /* Emit 0x prefix for explicit/implicit hex conversion */ in acpi_ex_convert_to_string()
572 new_buf += acpi_ex_convert_to_ascii((u64) obj_desc-> in acpi_ex_convert_to_string()
586 if (obj_desc->buffer.length) { in acpi_ex_convert_to_string()
587 new_buf--; in acpi_ex_convert_to_string()
605 * PARAMETERS: destination_type - Current type of the destination
606 * source_desc - Source object to be converted.
607 * result_desc - Where the converted object is returned
608 * walk_state - Current method state
612 * DESCRIPTION: Implements "implicit conversion" rules for storing an object.
632 * perform implicit conversion on the source before we store it. in acpi_ex_convert_to_target_type()
634 switch (GET_CURRENT_ARG_TYPE(walk_state->op_info->runtime_args)) { in acpi_ex_convert_to_target_type()
648 /* No conversion allowed for these types */ in acpi_ex_convert_to_target_type()
650 if (destination_type != source_desc->common.type) { in acpi_ex_convert_to_target_type()
701 "Bad destination type during conversion: 0x%X", in acpi_ex_convert_to_target_type()
710 * create_xxxx_field cases - we are storing the field object into the name in acpi_ex_convert_to_target_type()
718 GET_CURRENT_ARG_TYPE(walk_state->op_info-> in acpi_ex_convert_to_target_type()
720 walk_state->opcode, in acpi_ex_convert_to_target_type()
726 * Source-to-Target conversion semantics: in acpi_ex_convert_to_target_type()
728 * If conversion to the target type cannot be performed, then simply in acpi_ex_convert_to_target_type()