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

ACPICA: Restructure/cleanup all string-to-integer conversion functions

ACPICA commit 610046d444ad781cc36673bf1f030abe50cbc61f

Improve adherence to ACPI spec for implicit and explicit conversions
Adds octal support for constants in ASL code
Adds integer overflow errors for constants during ASL compilation
Eliminates most of the existing complex flags parameters
Simplify support for implicit/explicit runtime conversions
Adds one new file, utilities/utstrsuppt.c

Link: https://github.com/acpica/acpica/commit/610046d444adSigned-off-by: default avatarBob Moore <robert.moore@intel.com>
Signed-off-by: default avatarLv Zheng <lv.zheng@intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 81b7cb92
......@@ -177,6 +177,7 @@ acpi-y += \
utresrc.o \
utstate.o \
utstring.o \
utstrsuppt.o \
utstrtoul64.o \
utxface.o \
utxfinit.o \
......
......@@ -101,7 +101,8 @@ typedef const struct acpi_exdump_info {
*/
acpi_status
acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
union acpi_operand_object **result_desc, u32 flags);
union acpi_operand_object **result_desc,
u32 implicit_conversion);
acpi_status
acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc,
......@@ -424,9 +425,6 @@ acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
struct acpi_walk_state *walk_state,
u8 implicit_conversion);
#define ACPI_IMPLICIT_CONVERSION TRUE
#define ACPI_NO_IMPLICIT_CONVERSION FALSE
/*
* exstoren - resolve/store object
*/
......
......@@ -141,6 +141,11 @@ extern const char *acpi_gbl_ptyp_decode[];
#define ACPI_MSG_SUFFIX \
acpi_os_printf (" (%8.8X/%s-%u)\n", ACPI_CA_VERSION, module_name, line_number)
/* Flags to indicate implicit or explicit string-to-integer conversion */
#define ACPI_IMPLICIT_CONVERSION TRUE
#define ACPI_NO_IMPLICIT_CONVERSION FALSE
/* Types for Resource descriptor entries */
#define ACPI_INVALID_RESOURCE 0
......@@ -197,15 +202,29 @@ void acpi_ut_strlwr(char *src_string);
int acpi_ut_stricmp(char *string1, char *string2);
acpi_status acpi_ut_strtoul64(char *string, u32 flags, u64 *ret_integer);
/*
* utstrsuppt - string-to-integer conversion support functions
*/
acpi_status acpi_ut_convert_octal_string(char *string, u64 *return_value);
acpi_status acpi_ut_convert_decimal_string(char *string, u64 *return_value_ptr);
acpi_status acpi_ut_convert_hex_string(char *string, u64 *return_value_ptr);
char acpi_ut_remove_leading_zeros(char **string);
u8 acpi_ut_detect_hex_prefix(char **string);
u8 acpi_ut_detect_octal_prefix(char **string);
/*
* Values for Flags above
* Note: LIMIT values correspond to acpi_gbl_integer_byte_width values (4/8)
* utstrtoul64 - string-to-integer conversion functions
*/
#define ACPI_STRTOUL_32BIT 0x04 /* 4 bytes */
#define ACPI_STRTOUL_64BIT 0x08 /* 8 bytes */
#define ACPI_STRTOUL_BASE16 0x10 /* Default: Base10/16 */
acpi_status acpi_ut_strtoul64(char *string, u64 *ret_integer);
u64 acpi_ut_explicit_strtoul64(char *string);
u64 acpi_ut_implicit_strtoul64(char *string);
/*
* utglobal - Global data structures and procedures
......
......@@ -277,10 +277,7 @@ acpi_db_convert_to_object(acpi_object_type type,
default:
object->type = ACPI_TYPE_INTEGER;
status = acpi_ut_strtoul64(string,
(acpi_gbl_integer_byte_width |
ACPI_STRTOUL_BASE16),
&object->integer.value);
status = acpi_ut_strtoul64(string, &object->integer.value);
break;
}
......
......@@ -134,7 +134,7 @@ acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state,
* object. Implicitly convert the argument if necessary.
*/
status = acpi_ex_convert_to_integer(obj_desc, &local_obj_desc,
ACPI_STRTOUL_BASE16);
ACPI_IMPLICIT_CONVERSION);
if (ACPI_FAILURE(status)) {
goto cleanup;
}
......
......@@ -156,7 +156,7 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
status =
acpi_ex_convert_to_integer(local_operand1, &temp_operand1,
ACPI_STRTOUL_BASE16);
ACPI_IMPLICIT_CONVERSION);
break;
case ACPI_TYPE_BUFFER:
......
......@@ -57,10 +57,10 @@ acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, u8 max_length);
*
* FUNCTION: acpi_ex_convert_to_integer
*
* PARAMETERS: obj_desc - Object to be converted. Must be an
* Integer, Buffer, or String
* result_desc - Where the new Integer object is returned
* flags - Used for string conversion
* PARAMETERS: obj_desc - Object to be converted. Must be an
* Integer, Buffer, or String
* result_desc - Where the new Integer object is returned
* implicit_conversion - Used for string conversion
*
* RETURN: Status
*
......@@ -70,14 +70,14 @@ acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, u8 max_length);
acpi_status
acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
union acpi_operand_object **result_desc, u32 flags)
union acpi_operand_object **result_desc,
u32 implicit_conversion)
{
union acpi_operand_object *return_desc;
u8 *pointer;
u64 result;
u32 i;
u32 count;
acpi_status status;
ACPI_FUNCTION_TRACE_PTR(ex_convert_to_integer, obj_desc);
......@@ -123,12 +123,18 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
* hexadecimal as per the ACPI specification. The only exception (as
* of ACPI 3.0) is that the to_integer() operator allows both decimal
* and hexadecimal strings (hex prefixed with "0x").
*
* Explicit conversion is used only by to_integer.
* All other string-to-integer conversions are implicit conversions.
*/
status = acpi_ut_strtoul64(ACPI_CAST_PTR(char, pointer),
(acpi_gbl_integer_byte_width |
flags), &result);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
if (implicit_conversion) {
result =
acpi_ut_implicit_strtoul64(ACPI_CAST_PTR
(char, pointer));
} else {
result =
acpi_ut_explicit_strtoul64(ACPI_CAST_PTR
(char, pointer));
}
break;
......@@ -631,7 +637,7 @@ acpi_ex_convert_to_target_type(acpi_object_type destination_type,
*/
status =
acpi_ex_convert_to_integer(source_desc, result_desc,
ACPI_STRTOUL_BASE16);
ACPI_IMPLICIT_CONVERSION);
break;
case ACPI_TYPE_STRING:
......
......@@ -330,7 +330,7 @@ acpi_ex_do_logical_op(u16 opcode,
case ACPI_TYPE_INTEGER:
status = acpi_ex_convert_to_integer(operand1, &local_operand1,
ACPI_STRTOUL_BASE16);
ACPI_IMPLICIT_CONVERSION);
break;
case ACPI_TYPE_STRING:
......
......@@ -415,7 +415,7 @@ acpi_ex_resolve_operands(u16 opcode,
* Known as "Implicit Source Operand Conversion"
*/
status = acpi_ex_convert_to_integer(obj_desc, stack_ptr,
ACPI_STRTOUL_BASE16);
ACPI_IMPLICIT_CONVERSION);
if (ACPI_FAILURE(status)) {
if (status == AE_TYPE) {
ACPI_ERROR((AE_INFO,
......
......@@ -78,8 +78,8 @@ acpi_ns_convert_to_integer(union acpi_operand_object *original_object,
/* String-to-Integer conversion */
status = acpi_ut_strtoul64(original_object->string.pointer,
acpi_gbl_integer_byte_width, &value);
status =
acpi_ut_strtoul64(original_object->string.pointer, &value);
if (ACPI_FAILURE(status)) {
return (status);
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -126,8 +126,12 @@ struct acpi_exception_info {
#define AE_NOT_CONFIGURED EXCEP_ENV (0x001C)
#define AE_ACCESS EXCEP_ENV (0x001D)
#define AE_IO_ERROR EXCEP_ENV (0x001E)
#define AE_NUMERIC_OVERFLOW EXCEP_ENV (0x001F)
#define AE_HEX_OVERFLOW EXCEP_ENV (0x0020)
#define AE_DECIMAL_OVERFLOW EXCEP_ENV (0x0021)
#define AE_OCTAL_OVERFLOW EXCEP_ENV (0x0022)
#define AE_CODE_ENV_MAX 0x001E
#define AE_CODE_ENV_MAX 0x0022
/*
* Programmer exceptions
......@@ -263,7 +267,15 @@ static const struct acpi_exception_info acpi_gbl_exception_names_env[] = {
EXCEP_TXT("AE_NOT_CONFIGURED",
"The interface is not part of the current subsystem configuration"),
EXCEP_TXT("AE_ACCESS", "Permission denied for the requested operation"),
EXCEP_TXT("AE_IO_ERROR", "An I/O error occurred")
EXCEP_TXT("AE_IO_ERROR", "An I/O error occurred"),
EXCEP_TXT("AE_NUMERIC_OVERFLOW",
"Overflow during string-to-integer conversion"),
EXCEP_TXT("AE_HEX_OVERFLOW",
"Overflow during ASCII hex-to-binary conversion"),
EXCEP_TXT("AE_DECIMAL_OVERFLOW",
"Overflow during ASCII decimal-to-binary conversion"),
EXCEP_TXT("AE_OCTAL_OVERFLOW",
"Overflow during ASCII octal-to-binary conversion")
};
static const struct acpi_exception_info acpi_gbl_exception_names_pgm[] = {
......
......@@ -39,6 +39,7 @@ TOOL_OBJS = \
utnonansi.o\
utprint.o\
utstring.o\
utstrsuppt.o\
utstrtoul64.o\
utxferror.o\
oslinuxtbl.o\
......
......@@ -287,8 +287,7 @@ int ap_dump_table_by_address(char *ascii_address)
/* Convert argument to an integer physical address */
status = acpi_ut_strtoul64(ascii_address, ACPI_STRTOUL_64BIT,
&long_address);
status = acpi_ut_strtoul64(ascii_address, &long_address);
if (ACPI_FAILURE(status)) {
fprintf(stderr, "%s: Could not convert to a physical address\n",
ascii_address);
......
......@@ -208,9 +208,7 @@ static int ap_do_options(int argc, char **argv)
case 'r': /* Dump tables from specified RSDP */
status =
acpi_ut_strtoul64(acpi_gbl_optarg,
ACPI_STRTOUL_64BIT,
&gbl_rsdp_base);
acpi_ut_strtoul64(acpi_gbl_optarg, &gbl_rsdp_base);
if (ACPI_FAILURE(status)) {
fprintf(stderr,
"%s: Could not convert to a physical address\n",
......
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