Skip to content

Commit

Permalink
ACPICA: Restructure/cleanup all string-to-integer conversion functions
Browse files Browse the repository at this point in the history
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/610046d444ad
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Bob Moore authored and Rafael J. Wysocki committed Oct 3, 2017
1 parent 81b7cb9 commit fe97d28
Show file tree
Hide file tree
Showing 16 changed files with 690 additions and 256 deletions.
1 change: 1 addition & 0 deletions drivers/acpi/acpica/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ acpi-y += \
utresrc.o \
utstate.o \
utstring.o \
utstrsuppt.o \
utstrtoul64.o \
utxface.o \
utxfinit.o \
Expand Down
6 changes: 2 additions & 4 deletions drivers/acpi/acpica/acinterp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
*/
Expand Down
31 changes: 25 additions & 6 deletions drivers/acpi/acpica/acutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions drivers/acpi/acpica/dbconvert.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/acpica/dswexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/acpica/exconcat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
30 changes: 18 additions & 12 deletions drivers/acpi/acpica/exconvrt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -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);

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/acpica/exmisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/acpica/exresop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions drivers/acpi/acpica/nsconvert.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Loading

0 comments on commit fe97d28

Please sign in to comment.