Commit c4751176 authored by Bob Moore's avatar Bob Moore Committed by Rafael J. Wysocki

ACPICA: Update buffer-to-string conversions

Add "0x" prefix for hex values.
Provides compatibility with other ACPI implementations.
Signed-off-by: default avatarBob Moore <robert.moore@intel.com>
Signed-off-by: default avatarErik Schmauss <erik.schmauss@intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 9f4a2976
...@@ -323,7 +323,7 @@ acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, u8 data_width) ...@@ -323,7 +323,7 @@ acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, u8 data_width)
/* hex_length: 2 ascii hex chars per data byte */ /* hex_length: 2 ascii hex chars per data byte */
hex_length = ACPI_MUL_2(data_width); hex_length = (data_width * 2);
for (i = 0, j = (hex_length - 1); i < hex_length; i++, j--) { for (i = 0, j = (hex_length - 1); i < hex_length; i++, j--) {
/* Get one hex digit, most significant digits first */ /* Get one hex digit, most significant digits first */
...@@ -364,7 +364,8 @@ acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, u8 data_width) ...@@ -364,7 +364,8 @@ acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, u8 data_width)
* *
* RETURN: Status * RETURN: Status
* *
* DESCRIPTION: Convert an ACPI Object to a string * DESCRIPTION: Convert an ACPI Object to a string. Supports both implicit
* and explicit conversions and related rules.
* *
******************************************************************************/ ******************************************************************************/
...@@ -393,9 +394,11 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc, ...@@ -393,9 +394,11 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
switch (type) { switch (type) {
case ACPI_EXPLICIT_CONVERT_DECIMAL: case ACPI_EXPLICIT_CONVERT_DECIMAL:
/*
/* Make room for maximum decimal number */ * From to_decimal_string, integer source.
*
* Make room for the maximum decimal number size
*/
string_length = ACPI_MAX_DECIMAL_DIGITS; string_length = ACPI_MAX_DECIMAL_DIGITS;
base = 10; base = 10;
break; break;
...@@ -440,8 +443,10 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc, ...@@ -440,8 +443,10 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
switch (type) { switch (type) {
case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by to_decimal_string */ case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by to_decimal_string */
/* /*
* From ACPI: "If Data is a buffer, it is converted to a string of * Explicit conversion from the to_decimal_string ASL operator.
* decimal values separated by commas." *
* From ACPI: "If the input is a buffer, it is converted to a
* a string of decimal values separated by commas."
*/ */
base = 10; base = 10;
...@@ -462,20 +467,29 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc, ...@@ -462,20 +467,29 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
case ACPI_IMPLICIT_CONVERT_HEX: case ACPI_IMPLICIT_CONVERT_HEX:
/* /*
* Implicit buffer-to-string conversion
*
* From the ACPI spec: * From the ACPI spec:
*"The entire contents of the buffer are converted to a string of * "The entire contents of the buffer are converted to a string of
* two-character hexadecimal numbers, each separated by a space." * two-character hexadecimal numbers, each separated by a space."
*
* Each hex number is prefixed with 0x (11/2018)
*/ */
separator = ' '; separator = ' ';
string_length = (obj_desc->buffer.length * 3); string_length = (obj_desc->buffer.length * 5);
break; break;
case ACPI_EXPLICIT_CONVERT_HEX: /* Used by to_hex_string */ case ACPI_EXPLICIT_CONVERT_HEX:
/* /*
* Explicit conversion from the to_hex_string ASL operator.
*
* From ACPI: "If Data is a buffer, it is converted to a string of * From ACPI: "If Data is a buffer, it is converted to a string of
* hexadecimal values separated by commas." * hexadecimal values separated by commas."
*
* Each hex number is prefixed with 0x (11/2018)
*/ */
string_length = (obj_desc->buffer.length * 3); separator = ',';
string_length = (obj_desc->buffer.length * 5);
break; break;
default: default:
...@@ -504,10 +518,21 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc, ...@@ -504,10 +518,21 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
* (separated by commas or spaces) * (separated by commas or spaces)
*/ */
for (i = 0; i < obj_desc->buffer.length; i++) { for (i = 0; i < obj_desc->buffer.length; i++) {
if (base == 16) {
/* Emit 0x prefix for explict/implicit hex conversion */
*new_buf++ = '0';
*new_buf++ = 'x';
}
new_buf += acpi_ex_convert_to_ascii((u64) obj_desc-> new_buf += acpi_ex_convert_to_ascii((u64) obj_desc->
buffer.pointer[i], buffer.pointer[i],
base, new_buf, 1); base, new_buf, 1);
*new_buf++ = separator; /* each separated by a comma or space */
/* Each digit is separated by either a comma or space */
*new_buf++ = separator;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment