diff options
author | Bob Moore <robert.moore@intel.com> | 2016-03-23 21:40:33 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2016-04-04 21:53:33 -0400 |
commit | 3a05be7575a46cf3b16abb77e1072afa13307a1b (patch) | |
tree | 5a2db5243f2eb99315513b03171e10e8251a6377 | |
parent | 53c78d75d8a4615e5c2f1d9fe94f25e049f0e61b (diff) |
ACPICA: Utilities: Update for strtoul64 merger
ACPICA commit 795e136d2ac77c1c8b091fba019b5fe36a44a323
Fixes a problem with the merger of the two internal versions
of this function. Make the maximum integer width (32-bit or
64-bit) a parameter to the function so that it no longer
exclusively uses the integer width specified in the DSDT/SSDT.
ACPICA BZ 1260
Link: https://github.com/acpica/acpica/commit/795e136d
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>
-rw-r--r-- | drivers/acpi/acpica/acutils.h | 9 | ||||
-rw-r--r-- | drivers/acpi/acpica/dbconvert.c | 4 | ||||
-rw-r--r-- | drivers/acpi/acpica/exconvrt.c | 4 | ||||
-rw-r--r-- | drivers/acpi/acpica/nsconvert.c | 3 | ||||
-rw-r--r-- | drivers/acpi/acpica/utnonansi.c | 67 | ||||
-rw-r--r-- | tools/power/acpi/tools/acpidump/apdump.c | 3 | ||||
-rw-r--r-- | tools/power/acpi/tools/acpidump/apmain.c | 3 |
7 files changed, 57 insertions, 36 deletions
diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h index e43ab6f2ad7e..7422ff7bfb6d 100644 --- a/drivers/acpi/acpica/acutils.h +++ b/drivers/acpi/acpica/acutils.h | |||
@@ -175,7 +175,14 @@ void acpi_ut_strlwr(char *src_string); | |||
175 | 175 | ||
176 | int acpi_ut_stricmp(char *string1, char *string2); | 176 | int acpi_ut_stricmp(char *string1, char *string2); |
177 | 177 | ||
178 | acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer); | 178 | acpi_status |
179 | acpi_ut_strtoul64(char *string, | ||
180 | u32 base, u32 max_integer_byte_width, u64 *ret_integer); | ||
181 | |||
182 | /* Values for max_integer_byte_width above */ | ||
183 | |||
184 | #define ACPI_MAX32_BYTE_WIDTH 4 | ||
185 | #define ACPI_MAX64_BYTE_WIDTH 8 | ||
179 | 186 | ||
180 | /* | 187 | /* |
181 | * utglobal - Global data structures and procedures | 188 | * utglobal - Global data structures and procedures |
diff --git a/drivers/acpi/acpica/dbconvert.c b/drivers/acpi/acpica/dbconvert.c index 68f4e0f4b095..c79c5fb23fb6 100644 --- a/drivers/acpi/acpica/dbconvert.c +++ b/drivers/acpi/acpica/dbconvert.c | |||
@@ -277,7 +277,9 @@ acpi_db_convert_to_object(acpi_object_type type, | |||
277 | default: | 277 | default: |
278 | 278 | ||
279 | object->type = ACPI_TYPE_INTEGER; | 279 | object->type = ACPI_TYPE_INTEGER; |
280 | status = acpi_ut_strtoul64(string, 16, &object->integer.value); | 280 | status = |
281 | acpi_ut_strtoul64(string, 16, acpi_gbl_integer_byte_width, | ||
282 | &object->integer.value); | ||
281 | break; | 283 | break; |
282 | } | 284 | } |
283 | 285 | ||
diff --git a/drivers/acpi/acpica/exconvrt.c b/drivers/acpi/acpica/exconvrt.c index 0b9f2c13b98a..d0d16daa7ed5 100644 --- a/drivers/acpi/acpica/exconvrt.c +++ b/drivers/acpi/acpica/exconvrt.c | |||
@@ -124,7 +124,9 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc, | |||
124 | * of ACPI 3.0) is that the to_integer() operator allows both decimal | 124 | * of ACPI 3.0) is that the to_integer() operator allows both decimal |
125 | * and hexadecimal strings (hex prefixed with "0x"). | 125 | * and hexadecimal strings (hex prefixed with "0x"). |
126 | */ | 126 | */ |
127 | status = acpi_ut_strtoul64((char *)pointer, flags, &result); | 127 | status = acpi_ut_strtoul64((char *)pointer, flags, |
128 | acpi_gbl_integer_byte_width, | ||
129 | &result); | ||
128 | if (ACPI_FAILURE(status)) { | 130 | if (ACPI_FAILURE(status)) { |
129 | return_ACPI_STATUS(status); | 131 | return_ACPI_STATUS(status); |
130 | } | 132 | } |
diff --git a/drivers/acpi/acpica/nsconvert.c b/drivers/acpi/acpica/nsconvert.c index 878e8fb6a64c..256f56c583d6 100644 --- a/drivers/acpi/acpica/nsconvert.c +++ b/drivers/acpi/acpica/nsconvert.c | |||
@@ -79,7 +79,8 @@ acpi_ns_convert_to_integer(union acpi_operand_object *original_object, | |||
79 | /* String-to-Integer conversion */ | 79 | /* String-to-Integer conversion */ |
80 | 80 | ||
81 | status = acpi_ut_strtoul64(original_object->string.pointer, | 81 | status = acpi_ut_strtoul64(original_object->string.pointer, |
82 | ACPI_ANY_BASE, &value); | 82 | ACPI_ANY_BASE, |
83 | acpi_gbl_integer_byte_width, &value); | ||
83 | if (ACPI_FAILURE(status)) { | 84 | if (ACPI_FAILURE(status)) { |
84 | return (status); | 85 | return (status); |
85 | } | 86 | } |
diff --git a/drivers/acpi/acpica/utnonansi.c b/drivers/acpi/acpica/utnonansi.c index d5c3adf19bd0..3465fe2c5a5c 100644 --- a/drivers/acpi/acpica/utnonansi.c +++ b/drivers/acpi/acpica/utnonansi.c | |||
@@ -205,37 +205,41 @@ acpi_ut_safe_strncat(char *dest, | |||
205 | * | 205 | * |
206 | * FUNCTION: acpi_ut_strtoul64 | 206 | * FUNCTION: acpi_ut_strtoul64 |
207 | * | 207 | * |
208 | * PARAMETERS: string - Null terminated string | 208 | * PARAMETERS: string - Null terminated string |
209 | * base - Radix of the string: 16 or ACPI_ANY_BASE; | 209 | * base - Radix of the string: 16 or 10 or |
210 | * ACPI_ANY_BASE means 'in behalf of to_integer' | 210 | * ACPI_ANY_BASE |
211 | * ret_integer - Where the converted integer is returned | 211 | * max_integer_byte_width - Maximum allowable integer,in bytes: |
212 | * 4 or 8 (32 or 64 bits) | ||
213 | * ret_integer - Where the converted integer is | ||
214 | * returned | ||
212 | * | 215 | * |
213 | * RETURN: Status and Converted value | 216 | * RETURN: Status and Converted value |
214 | * | 217 | * |
215 | * DESCRIPTION: Convert a string into an unsigned value. Performs either a | 218 | * DESCRIPTION: Convert a string into an unsigned value. Performs either a |
216 | * 32-bit or 64-bit conversion, depending on the current mode | 219 | * 32-bit or 64-bit conversion, depending on the input integer |
217 | * of the interpreter. | 220 | * size (often the current mode of the interpreter). |
218 | * | 221 | * |
219 | * NOTES: acpi_gbl_integer_byte_width should be set to the proper width. | 222 | * NOTES: Negative numbers are not supported, as they are not supported |
223 | * by ACPI. | ||
224 | * | ||
225 | * acpi_gbl_integer_byte_width should be set to the proper width. | ||
220 | * For the core ACPICA code, this width depends on the DSDT | 226 | * For the core ACPICA code, this width depends on the DSDT |
221 | * version. For iASL, the default byte width is always 8. | 227 | * version. For iASL, the default byte width is always 8 for the |
228 | * parser, but error checking is performed later to flag cases | ||
229 | * where a 64-bit constant is defined in a 32-bit DSDT/SSDT. | ||
222 | * | 230 | * |
223 | * Does not support Octal strings, not needed at this time. | 231 | * Does not support Octal strings, not needed at this time. |
224 | * | 232 | * |
225 | * There is an earlier version of the function after this one, | ||
226 | * below. It is slightly different than this one, and the two | ||
227 | * may eventually may need to be merged. (01/2016). | ||
228 | * | ||
229 | ******************************************************************************/ | 233 | ******************************************************************************/ |
230 | 234 | ||
231 | acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer) | 235 | acpi_status |
236 | acpi_ut_strtoul64(char *string, | ||
237 | u32 base, u32 max_integer_byte_width, u64 *ret_integer) | ||
232 | { | 238 | { |
233 | u32 this_digit = 0; | 239 | u32 this_digit = 0; |
234 | u64 return_value = 0; | 240 | u64 return_value = 0; |
235 | u64 quotient; | 241 | u64 quotient; |
236 | u64 dividend; | 242 | u64 dividend; |
237 | u32 to_integer_op = (base == ACPI_ANY_BASE); | ||
238 | u32 mode32 = (acpi_gbl_integer_byte_width == 4); | ||
239 | u8 valid_digits = 0; | 243 | u8 valid_digits = 0; |
240 | u8 sign_of0x = 0; | 244 | u8 sign_of0x = 0; |
241 | u8 term = 0; | 245 | u8 term = 0; |
@@ -244,6 +248,7 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer) | |||
244 | 248 | ||
245 | switch (base) { | 249 | switch (base) { |
246 | case ACPI_ANY_BASE: | 250 | case ACPI_ANY_BASE: |
251 | case 10: | ||
247 | case 16: | 252 | case 16: |
248 | 253 | ||
249 | break; | 254 | break; |
@@ -265,9 +270,9 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer) | |||
265 | string++; | 270 | string++; |
266 | } | 271 | } |
267 | 272 | ||
268 | if (to_integer_op) { | 273 | if (base == ACPI_ANY_BASE) { |
269 | /* | 274 | /* |
270 | * Base equal to ACPI_ANY_BASE means 'ToInteger operation case'. | 275 | * Base equal to ACPI_ANY_BASE means 'Either decimal or hex'. |
271 | * We need to determine if it is decimal or hexadecimal. | 276 | * We need to determine if it is decimal or hexadecimal. |
272 | */ | 277 | */ |
273 | if ((*string == '0') && (tolower((int)*(string + 1)) == 'x')) { | 278 | if ((*string == '0') && (tolower((int)*(string + 1)) == 'x')) { |
@@ -284,7 +289,7 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer) | |||
284 | /* Any string left? Check that '0x' is not followed by white space. */ | 289 | /* Any string left? Check that '0x' is not followed by white space. */ |
285 | 290 | ||
286 | if (!(*string) || isspace((int)*string) || *string == '\t') { | 291 | if (!(*string) || isspace((int)*string) || *string == '\t') { |
287 | if (to_integer_op) { | 292 | if (base == ACPI_ANY_BASE) { |
288 | goto error_exit; | 293 | goto error_exit; |
289 | } else { | 294 | } else { |
290 | goto all_done; | 295 | goto all_done; |
@@ -292,10 +297,11 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer) | |||
292 | } | 297 | } |
293 | 298 | ||
294 | /* | 299 | /* |
295 | * Perform a 32-bit or 64-bit conversion, depending upon the current | 300 | * Perform a 32-bit or 64-bit conversion, depending upon the input |
296 | * execution mode of the interpreter | 301 | * byte width |
297 | */ | 302 | */ |
298 | dividend = (mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX; | 303 | dividend = (max_integer_byte_width <= ACPI_MAX32_BYTE_WIDTH) ? |
304 | ACPI_UINT32_MAX : ACPI_UINT64_MAX; | ||
299 | 305 | ||
300 | /* Main loop: convert the string to a 32- or 64-bit integer */ | 306 | /* Main loop: convert the string to a 32- or 64-bit integer */ |
301 | 307 | ||
@@ -323,7 +329,7 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer) | |||
323 | } | 329 | } |
324 | 330 | ||
325 | if (term) { | 331 | if (term) { |
326 | if (to_integer_op) { | 332 | if (base == ACPI_ANY_BASE) { |
327 | goto error_exit; | 333 | goto error_exit; |
328 | } else { | 334 | } else { |
329 | break; | 335 | break; |
@@ -338,12 +344,13 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer) | |||
338 | 344 | ||
339 | valid_digits++; | 345 | valid_digits++; |
340 | 346 | ||
341 | if (sign_of0x | 347 | if (sign_of0x && ((valid_digits > 16) || |
342 | && ((valid_digits > 16) | 348 | ((valid_digits > 8) |
343 | || ((valid_digits > 8) && mode32))) { | 349 | && (max_integer_byte_width <= |
350 | ACPI_MAX32_BYTE_WIDTH)))) { | ||
344 | /* | 351 | /* |
345 | * This is to_integer operation case. | 352 | * This is to_integer operation case. |
346 | * No any restrictions for string-to-integer conversion, | 353 | * No restrictions for string-to-integer conversion, |
347 | * see ACPI spec. | 354 | * see ACPI spec. |
348 | */ | 355 | */ |
349 | goto error_exit; | 356 | goto error_exit; |
@@ -355,7 +362,7 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer) | |||
355 | "ient, NULL); | 362 | "ient, NULL); |
356 | 363 | ||
357 | if (return_value > quotient) { | 364 | if (return_value > quotient) { |
358 | if (to_integer_op) { | 365 | if (base == ACPI_ANY_BASE) { |
359 | goto error_exit; | 366 | goto error_exit; |
360 | } else { | 367 | } else { |
361 | break; | 368 | break; |
@@ -378,7 +385,8 @@ all_done: | |||
378 | return_ACPI_STATUS(AE_OK); | 385 | return_ACPI_STATUS(AE_OK); |
379 | 386 | ||
380 | error_exit: | 387 | error_exit: |
381 | /* Base was set/validated above */ | 388 | |
389 | /* Base was set/validated above (10 or 16) */ | ||
382 | 390 | ||
383 | if (base == 10) { | 391 | if (base == 10) { |
384 | return_ACPI_STATUS(AE_BAD_DECIMAL_CONSTANT); | 392 | return_ACPI_STATUS(AE_BAD_DECIMAL_CONSTANT); |
@@ -388,8 +396,7 @@ error_exit: | |||
388 | } | 396 | } |
389 | 397 | ||
390 | #ifdef _OBSOLETE_FUNCTIONS | 398 | #ifdef _OBSOLETE_FUNCTIONS |
391 | /* TBD: use version in ACPICA main code base? */ | 399 | /* Removed: 01/2016 */ |
392 | /* DONE: 01/2016 */ | ||
393 | 400 | ||
394 | /******************************************************************************* | 401 | /******************************************************************************* |
395 | * | 402 | * |
diff --git a/tools/power/acpi/tools/acpidump/apdump.c b/tools/power/acpi/tools/acpidump/apdump.c index da44458d3b6c..9c2db0eb467f 100644 --- a/tools/power/acpi/tools/acpidump/apdump.c +++ b/tools/power/acpi/tools/acpidump/apdump.c | |||
@@ -286,7 +286,8 @@ int ap_dump_table_by_address(char *ascii_address) | |||
286 | 286 | ||
287 | /* Convert argument to an integer physical address */ | 287 | /* Convert argument to an integer physical address */ |
288 | 288 | ||
289 | status = acpi_ut_strtoul64(ascii_address, 0, &long_address); | 289 | status = acpi_ut_strtoul64(ascii_address, ACPI_ANY_BASE, |
290 | ACPI_MAX64_BYTE_WIDTH, &long_address); | ||
290 | if (ACPI_FAILURE(status)) { | 291 | if (ACPI_FAILURE(status)) { |
291 | acpi_log_error("%s: Could not convert to a physical address\n", | 292 | acpi_log_error("%s: Could not convert to a physical address\n", |
292 | ascii_address); | 293 | ascii_address); |
diff --git a/tools/power/acpi/tools/acpidump/apmain.c b/tools/power/acpi/tools/acpidump/apmain.c index c3c09152fac6..7692e6b887e1 100644 --- a/tools/power/acpi/tools/acpidump/apmain.c +++ b/tools/power/acpi/tools/acpidump/apmain.c | |||
@@ -209,7 +209,8 @@ static int ap_do_options(int argc, char **argv) | |||
209 | case 'r': /* Dump tables from specified RSDP */ | 209 | case 'r': /* Dump tables from specified RSDP */ |
210 | 210 | ||
211 | status = | 211 | status = |
212 | acpi_ut_strtoul64(acpi_gbl_optarg, 0, | 212 | acpi_ut_strtoul64(acpi_gbl_optarg, ACPI_ANY_BASE, |
213 | ACPI_MAX64_BYTE_WIDTH, | ||
213 | &gbl_rsdp_base); | 214 | &gbl_rsdp_base); |
214 | if (ACPI_FAILURE(status)) { | 215 | if (ACPI_FAILURE(status)) { |
215 | acpi_log_error | 216 | acpi_log_error |