diff options
-rwxr-xr-x | generate/msvc9/AcpiDump.vcproj | 4 | ||||
-rwxr-xr-x | generate/msvc9/AcpiSrc.vcproj | 4 | ||||
-rwxr-xr-x | generate/msvc9/AcpiXtract.vcproj | 4 | ||||
-rw-r--r-- | generate/unix/acpidump/Makefile | 1 | ||||
-rw-r--r-- | generate/unix/acpisrc/Makefile | 1 | ||||
-rw-r--r-- | generate/unix/acpixtract/Makefile | 1 | ||||
-rw-r--r-- | source/components/events/evgpeinit.c | 8 | ||||
-rw-r--r-- | source/components/utilities/utnonansi.c | 449 | ||||
-rw-r--r-- | source/include/acexcep.h | 6 | ||||
-rw-r--r-- | source/include/platform/acmsvc.h | 3 | ||||
-rw-r--r-- | source/tools/acpiexec/aeexec.c | 100 |
11 files changed, 284 insertions, 297 deletions
diff --git a/generate/msvc9/AcpiDump.vcproj b/generate/msvc9/AcpiDump.vcproj index 4880e7b04..683062476 100755 --- a/generate/msvc9/AcpiDump.vcproj +++ b/generate/msvc9/AcpiDump.vcproj @@ -345,6 +345,10 @@ > </File> <File + RelativePath="..\..\source\components\utilities\uthex.c" + > + </File> + <File RelativePath="..\..\source\components\utilities\utmath.c" > </File> diff --git a/generate/msvc9/AcpiSrc.vcproj b/generate/msvc9/AcpiSrc.vcproj index 9f1039a20..b3a498e3e 100755 --- a/generate/msvc9/AcpiSrc.vcproj +++ b/generate/msvc9/AcpiSrc.vcproj @@ -482,6 +482,10 @@ > </File> <File + RelativePath="..\..\source\components\utilities\uthex.c" + > + </File> + <File RelativePath="..\..\source\components\utilities\utmath.c" > </File> diff --git a/generate/msvc9/AcpiXtract.vcproj b/generate/msvc9/AcpiXtract.vcproj index 4670fc9aa..0c0b4edb0 100755 --- a/generate/msvc9/AcpiXtract.vcproj +++ b/generate/msvc9/AcpiXtract.vcproj @@ -246,6 +246,10 @@ > </File> <File + RelativePath="..\..\source\components\utilities\uthex.c" + > + </File> + <File RelativePath="..\..\source\components\utilities\utmath.c" > </File> diff --git a/generate/unix/acpidump/Makefile b/generate/unix/acpidump/Makefile index d6e19644c..702a3a004 100644 --- a/generate/unix/acpidump/Makefile +++ b/generate/unix/acpidump/Makefile @@ -44,6 +44,7 @@ OBJECTS = \ $(OBJDIR)/utdebug.o\ $(OBJDIR)/utexcep.o\ $(OBJDIR)/utglobal.o\ + $(OBJDIR)/uthex.o\ $(OBJDIR)/utmath.o\ $(OBJDIR)/utnonansi.o\ $(OBJDIR)/utprint.o\ diff --git a/generate/unix/acpisrc/Makefile b/generate/unix/acpisrc/Makefile index 93a9868cf..91e813bcb 100644 --- a/generate/unix/acpisrc/Makefile +++ b/generate/unix/acpisrc/Makefile @@ -43,6 +43,7 @@ OBJECTS = \ $(OBJDIR)/utdebug.o\ $(OBJDIR)/utexcep.o\ $(OBJDIR)/utglobal.o\ + $(OBJDIR)/uthex.o\ $(OBJDIR)/utmath.o\ $(OBJDIR)/utnonansi.o\ $(OBJDIR)/utprint.o\ diff --git a/generate/unix/acpixtract/Makefile b/generate/unix/acpixtract/Makefile index 272cbd091..4b29e6741 100644 --- a/generate/unix/acpixtract/Makefile +++ b/generate/unix/acpixtract/Makefile @@ -37,6 +37,7 @@ OBJECTS = \ $(OBJDIR)/utdebug.o\ $(OBJDIR)/utexcep.o\ $(OBJDIR)/utglobal.o\ + $(OBJDIR)/uthex.o\ $(OBJDIR)/utmath.o\ $(OBJDIR)/utnonansi.o\ $(OBJDIR)/utprint.o\ diff --git a/source/components/events/evgpeinit.c b/source/components/events/evgpeinit.c index 2ad478513..b3f7c7a6e 100644 --- a/source/components/events/evgpeinit.c +++ b/source/components/events/evgpeinit.c @@ -408,7 +408,9 @@ AcpiEvMatchGpeMethod ( ACPI_NAMESPACE_NODE *MethodNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); ACPI_GPE_WALK_INFO *WalkInfo = ACPI_CAST_PTR (ACPI_GPE_WALK_INFO, Context); ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_STATUS Status; UINT32 GpeNumber; + UINT64 TempGpeNumber; char Name[ACPI_NAME_SIZE + 1]; UINT8 Type; @@ -467,8 +469,9 @@ AcpiEvMatchGpeMethod ( /* 4) The last two characters of the name are the hex GPE Number */ - GpeNumber = strtoul (&Name[2], NULL, 16); - if (GpeNumber == ACPI_UINT32_MAX) + Status = AcpiUtStrtoul64 (&Name[2], 16, ACPI_MAX32_BYTE_WIDTH, + &TempGpeNumber); + if (ACPI_FAILURE (Status)) { /* Conversion failed; invalid method, just ignore it */ @@ -480,6 +483,7 @@ AcpiEvMatchGpeMethod ( /* Ensure that we have a valid GPE number for this GPE block */ + GpeNumber = (UINT32) TempGpeNumber; GpeEventInfo = AcpiEvLowGetGpeInfo (GpeNumber, WalkInfo->GpeBlock); if (!GpeEventInfo) { diff --git a/source/components/utilities/utnonansi.c b/source/components/utilities/utnonansi.c index 1e6512ea2..aea4cfc1b 100644 --- a/source/components/utilities/utnonansi.c +++ b/source/components/utilities/utnonansi.c @@ -120,6 +120,20 @@ #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utnonansi") +/* Local prototypes */ + +static ACPI_STATUS +AcpiUtStrtoulBase10 ( + char *String, + UINT32 MaxIntegerByteWidth, + UINT64 *RetInteger); + +static ACPI_STATUS +AcpiUtStrtoulBase16 ( + char *String, + UINT32 MaxIntegerByteWidth, + UINT64 *RetInteger); + /* * Non-ANSI C library functions - strlwr, strupr, stricmp, and a 64-bit @@ -316,10 +330,10 @@ AcpiUtSafeStrncat ( * * FUNCTION: AcpiUtStrtoul64 * - * PARAMETERS: String - Null terminated string + * PARAMETERS: String - Null terminated input string * Base - Radix of the string: 16 or 10 or * ACPI_ANY_BASE - * MaxIntegerByteWidth - Maximum allowable integer,in bytes: + * MaxIntegerByteWidth - Maximum allowable integer, in bytes: * 4 or 8 (32 or 64 bits) * RetInteger - Where the converted integer is * returned @@ -333,13 +347,24 @@ AcpiUtSafeStrncat ( * NOTES: Negative numbers are not supported, as they are not supported * by ACPI. * + * Supports only base 16 or base 10 strings/values. Does not + * support Octal strings, not needed at this time. + * * AcpiGbl_IntegerByteWidth should be set to the proper width. * For the core ACPICA code, this width depends on the DSDT * version. For iASL, the default byte width is always 8 for the * parser, but error checking is performed later to flag cases * where a 64-bit constant is defined in a 32-bit DSDT/SSDT. * - * Does not support Octal strings, not needed at this time. + * Unlike Clib, this function aborts with an error for any + * malformed input string. + * + * Currently used by: + * iASL/Preprocessor - Expression evaluation + * iASL/DataTableCompiler - Expression evaluation + * Debugger - input string conversion + * Interpreter - Implicit and explicit conversions + * Tools - acpidump, acpiexec * ******************************************************************************/ @@ -350,58 +375,52 @@ AcpiUtStrtoul64 ( UINT32 MaxIntegerByteWidth, UINT64 *RetInteger) { - UINT32 ThisDigit = 0; - UINT64 ReturnValue = 0; - UINT64 Quotient; - UINT64 Dividend; - UINT8 ValidDigits = 0; - UINT8 SignOf0x = 0; - UINT8 Term = 0; - - ACPI_FUNCTION_TRACE_STR (UtStrtoul64, String); - switch (Base) - { - case ACPI_ANY_BASE: - case 10: - case 16: + /* Parameter validation */ - break; - - default: + if (!String || !RetInteger) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + if ((Base != ACPI_ANY_BASE) && + (Base != 10) && + (Base != 16)) + { /* Invalid Base */ return_ACPI_STATUS (AE_BAD_PARAMETER); } - if (!String) + /* Skip over any white space at start of string */ + + while (isspace ((int) *String)) { - goto ErrorExit; + String++; } - /* Skip over any white space in the buffer */ - - while ((*String) && (isspace ((int) *String) || *String == '\t')) + if (*String == 0) { - String++; + return_ACPI_STATUS (AE_BAD_PARAMETER); } + /* Determine base if necessary (10 or 16) */ + if (Base == ACPI_ANY_BASE) { /* - * Base equal to ACPI_ANY_BASE means 'Either decimal or hex'. - * We need to determine if it is decimal or hexadecimal. + * (Base == ACPI_ANY_BASE) means "Either decimal or hex"; + * determine which one. + * NOTE: there is no octal or arbitary base support. */ - if ((*String == '0') && (tolower ((int) *(String + 1)) == 'x')) + if ((*String == '0') && + (tolower ((int) *(String + 1)) == 'x')) { - SignOf0x = 1; - Base = 16; + /* Found a "0x" prefix -- the string is hex */ - /* Skip over the leading '0x' */ - String += 2; + Base = 16; } else { @@ -409,331 +428,175 @@ AcpiUtStrtoul64 ( } } - /* Any string left? Check that '0x' is not followed by white space. */ + /* Perform the base 16 or 10 conversion */ - if (!(*String) || isspace ((int) *String) || *String == '\t') + if (Base == 16) { - if (Base == ACPI_ANY_BASE) - { - goto ErrorExit; - } - else - { - goto AllDone; - } + return (AcpiUtStrtoulBase16 (String, MaxIntegerByteWidth, RetInteger)); } + else + { + return (AcpiUtStrtoulBase10 (String, MaxIntegerByteWidth, RetInteger)); + } +} - /* - * Perform a 32-bit or 64-bit conversion, depending upon the input - * byte width - */ - Dividend = (MaxIntegerByteWidth <= ACPI_MAX32_BYTE_WIDTH) ? - ACPI_UINT32_MAX : ACPI_UINT64_MAX; - /* Main loop: convert the string to a 32- or 64-bit integer */ +/******************************************************************************* + * + * FUNCTION: AcpiUtStrtoulBase10 + * + * PARAMETERS: String - Null terminated input string + * MaxIntegerByteWidth - Maximum allowable integer, in bytes: + * 4 or 8 (32 or 64 bits) + * RetInteger - Where the converted integer is + * returned + * + * RETURN: Status + * + * DESCRIPTION: Performs a base 10 conversion of the input string to an + * integer value, either 32 or 64 bits. + * Note: String must be valid and non-null. + * + ******************************************************************************/ - while (*String) - { - if (isdigit ((int) *String)) - { - /* Convert ASCII 0-9 to Decimal value */ +static ACPI_STATUS +AcpiUtStrtoulBase10 ( + char *String, + UINT32 MaxIntegerByteWidth, + UINT64 *RetInteger) +{ + UINT32 ThisDigit; + UINT32 ValidDigits = 0; + UINT64 ReturnValue = 0; + UINT64 NextValue; - ThisDigit = ((UINT8) *String) - '0'; - } - else if (Base == 10) - { - /* Digit is out of range; possible in ToInteger case only */ - Term = 1; - } - else - { - ThisDigit = (UINT8) toupper ((int) *String); - if (isxdigit ((int) ThisDigit)) - { - /* Convert ASCII Hex char to value */ - - ThisDigit = ThisDigit - 'A' + 10; - } - else - { - Term = 1; - } - } + /* Main loop: convert each ASCII byte in the input string */ - if (Term) - { - if (Base == ACPI_ANY_BASE) - { - goto ErrorExit; - } - else - { - break; - } - } - else if ((ValidDigits == 0) && (ThisDigit == 0) && !SignOf0x) + while (*String) + { + /* Skip all leading zeros */ + + if ((ValidDigits == 0) && (*String == ACPI_ASCII_ZERO)) { - /* Skip zeros */ String++; continue; } - ValidDigits++; - - if (SignOf0x && ((ValidDigits > 16) || - ((ValidDigits > 8) && (MaxIntegerByteWidth <= ACPI_MAX32_BYTE_WIDTH)))) + ThisDigit = (UINT8) toupper ((int) *String); + if (!isdigit ((int) ThisDigit)) { - /* - * This is ToInteger operation case. - * No restrictions for string-to-integer conversion, - * see ACPI spec. - */ - goto ErrorExit; + /* Not ASCII 0-9, terminate */ + + return (AE_BAD_DECIMAL_CONSTANT); } - /* Divide the digit into the correct position */ + /* Convert and insert(add) the decimal digit */ + + NextValue = (ReturnValue * 10) + (ThisDigit - '0'); - (void) AcpiUtShortDivide ( - (Dividend - (UINT64) ThisDigit), Base, &Quotient, NULL); + /* Check for overflow (32 or 64 bit) */ - if (ReturnValue > Quotient) + if (((MaxIntegerByteWidth <= ACPI_MAX32_BYTE_WIDTH) && + (NextValue > ACPI_UINT32_MAX)) || + (NextValue < ReturnValue)) /* 64-bit overflow case */ { - if (Base == ACPI_ANY_BASE) - { - goto ErrorExit; - } - else - { - break; - } + return (AE_CONVERSION_OVERFLOW); } - ReturnValue *= Base; - ReturnValue += ThisDigit; + ReturnValue = NextValue; String++; + ValidDigits++; } - /* All done, normal exit */ - -AllDone: - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (ReturnValue))); - *RetInteger = ReturnValue; - return_ACPI_STATUS (AE_OK); - - -ErrorExit: - - /* Base was set/validated above (10 or 16) */ - - if (Base == 10) - { - return_ACPI_STATUS (AE_BAD_DECIMAL_CONSTANT); - } - else - { - return_ACPI_STATUS (AE_BAD_HEX_CONSTANT); - } + return (AE_OK); } -#ifdef _OBSOLETE_FUNCTIONS -/* Removed: 01/2016 */ - /******************************************************************************* * - * FUNCTION: strtoul64 + * FUNCTION: AcpiUtStrtoulBase16 * - * PARAMETERS: String - Null terminated string - * Terminater - Where a pointer to the terminating byte - * is returned - * Base - Radix of the string + * PARAMETERS: String - Null terminated input string + * MaxIntegerByteWidth - Maximum allowable integer, in bytes: + * 4 or 8 (32 or 64 bits) + * RetInteger - Where the converted integer is + * returned * - * RETURN: Converted value + * RETURN: Status * - * DESCRIPTION: Convert a string into an unsigned value. + * DESCRIPTION: Performs a base 16 conversion of the input string to an + * integer value, either 32 or 64 bits. + * Note: String must be valid and non-null. * ******************************************************************************/ -ACPI_STATUS -strtoul64 ( +static ACPI_STATUS +AcpiUtStrtoulBase16 ( char *String, - UINT32 Base, + UINT32 MaxIntegerByteWidth, UINT64 *RetInteger) { - UINT32 Index; - UINT32 Sign; + UINT32 ThisDigit; + UINT32 ValidDigits = 0; UINT64 ReturnValue = 0; - ACPI_STATUS Status = AE_OK; - - - *RetInteger = 0; - - switch (Base) - { - case 0: - case 8: - case 10: - case 16: - - break; - - default: - /* - * The specified Base parameter is not in the domain of - * this function: - */ - return (AE_BAD_PARAMETER); - } - /* Skip over any white space in the buffer: */ - - while (isspace ((int) *String) || *String == '\t') - { - ++String; - } - /* - * The buffer may contain an optional plus or minus sign. - * If it does, then skip over it but remember what is was: - */ - if (*String == '-') - { - Sign = ACPI_SIGN_NEGATIVE; - ++String; - } - else if (*String == '+') - { - ++String; - Sign = ACPI_SIGN_POSITIVE; - } - else - { - Sign = ACPI_SIGN_POSITIVE; - } + /* Allow "0x" prefix for all hex constants */ - /* - * If the input parameter Base is zero, then we need to - * determine if it is octal, decimal, or hexadecimal: - */ - if (Base == 0) + if ((*String == '0') && + (tolower ((int) *(String + 1)) == 'x')) { - if (*String == '0') - { - if (tolower ((int) *(++String)) == 'x') - { - Base = 16; - ++String; - } - else - { - Base = 8; - } - } - else + String += 2; /* Go past the 0x */ + if (*String == 0) { - Base = 10; + return (AE_BAD_HEX_CONSTANT); } } - /* - * For octal and hexadecimal bases, skip over the leading - * 0 or 0x, if they are present. - */ - if (Base == 8 && *String == '0') - { - String++; - } - - if (Base == 16 && - *String == '0' && - tolower ((int) *(++String)) == 'x') - { - String++; - } - - /* Main loop: convert the string to an unsigned long */ + /* Main loop: convert each ASCII byte in the input string */ while (*String) { - if (isdigit ((int) *String)) - { - Index = ((UINT8) *String) - '0'; - } - else - { - Index = (UINT8) toupper ((int) *String); - if (isupper ((int) Index)) - { - Index = Index - 'A' + 10; - } - else - { - goto ErrorExit; - } - } + /* Skip all leading zeros */ - if (Index >= Base) + if ((ValidDigits == 0) && (*String == ACPI_ASCII_ZERO)) { - goto ErrorExit; + String++; + continue; } - /* Check to see if value is out of range: */ + /* Check for overflow (32 or 64 bit) */ - if (ReturnValue > ((ACPI_UINT64_MAX - (UINT64) Index) / - (UINT64) Base)) + if ((ValidDigits > 16) || + ((ValidDigits > 8) && (MaxIntegerByteWidth <= ACPI_MAX32_BYTE_WIDTH))) { - goto ErrorExit; + /* + * This is ToInteger operation case. + * No restrictions for string-to-integer conversion, + * see ACPI spec. + */ + return (AE_CONVERSION_OVERFLOW); } - else + + ThisDigit = (UINT8) toupper ((int) *String); + if (!isxdigit ((int) ThisDigit)) { - ReturnValue *= Base; - ReturnValue += Index; - } + /* Not Hex ASCII A-F or 0-9, terminate */ - ++String; - } + return (AE_BAD_HEX_CONSTANT); + } + /* Convert and insert the hex digit */ - /* If a minus sign was present, then "the conversion is negated": */ + ThisDigit = AcpiUtAsciiCharToHex (ThisDigit); + ReturnValue = (ReturnValue << 4) | ThisDigit; - if (Sign == ACPI_SIGN_NEGATIVE) - { - ReturnValue = (ACPI_UINT32_MAX - ReturnValue) + 1; + String++; + ValidDigits++; } *RetInteger = ReturnValue; - return (Status); - - -ErrorExit: - switch (Base) - { - case 8: - - Status = AE_BAD_OCTAL_CONSTANT; - break; - - case 10: - - Status = AE_BAD_DECIMAL_CONSTANT; - break; - - case 16: - - Status = AE_BAD_HEX_CONSTANT; - break; - - default: - - /* Base validated above */ - - break; - } - - return (Status); + return (AE_OK); } -#endif diff --git a/source/include/acexcep.h b/source/include/acexcep.h index c5217295d..4ab007d1b 100644 --- a/source/include/acexcep.h +++ b/source/include/acexcep.h @@ -201,8 +201,9 @@ typedef 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_CONVERSION_OVERFLOW EXCEP_ENV (0x001F) -#define AE_CODE_ENV_MAX 0x001E +#define AE_CODE_ENV_MAX 0x001F /* @@ -336,7 +337,8 @@ static const ACPI_EXCEPTION_INFO AcpiGbl_ExceptionNames_Env[] = EXCEP_TXT ("AE_OWNER_ID_LIMIT", "There are no more Owner IDs available for ACPI tables or control methods"), 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_CONVERSION_OVERFLOW", "Overflow during string-to-integer conversion") }; static const ACPI_EXCEPTION_INFO AcpiGbl_ExceptionNames_Pgm[] = diff --git a/source/include/platform/acmsvc.h b/source/include/platform/acmsvc.h index 133f449ef..3b982ffed 100644 --- a/source/include/platform/acmsvc.h +++ b/source/include/platform/acmsvc.h @@ -221,6 +221,9 @@ /* warn C4131: uses old-style declarator (iASL compiler only) */ #pragma warning(disable:4131) +/* warn C4310: cast truncates constant value */ +#pragma warning(disable:4310) + #if _MSC_VER > 1200 /* Versions above VC++ 6 */ #pragma warning( disable : 4295 ) /* needed for acpredef.h array */ #endif diff --git a/source/tools/acpiexec/aeexec.c b/source/tools/acpiexec/aeexec.c index 452943dc3..84df25caf 100644 --- a/source/tools/acpiexec/aeexec.c +++ b/source/tools/acpiexec/aeexec.c @@ -160,6 +160,10 @@ static void AeTestSleepData ( void); +static void +AeTestStringConversions ( + void); + #if (!ACPI_REDUCED_HARDWARE) static void AfInstallGpeBlock ( @@ -658,6 +662,98 @@ AeTestSleepData ( } } +/****************************************************************************** + * + * FUNCTION: AeTestStringConversions + * + * DESCRIPTION: Exercise AcpiUtStrtoul64 + * + *****************************************************************************/ + +static void +AeTestStringConversions ( + void) +{ + UINT64 TempGpeNumber; + UINT64 Value; + ACPI_STATUS Status; + + + /* Check for GPE 2-digit values (_Lxx and _Exx) */ + + Status = AcpiUtStrtoul64 ("JK", 16, ACPI_MAX32_BYTE_WIDTH, + &TempGpeNumber); + ACPI_CHECK_STATUS (AcpiUtStrtoul64, Status, AE_BAD_HEX_CONSTANT); + + Status = AcpiUtStrtoul64 ("44", 16, ACPI_MAX32_BYTE_WIDTH, + &TempGpeNumber); + ACPI_CHECK_OK (AcpiUtStrtoul64, Status); + + Status = AcpiUtStrtoul64 ("8B", 16, ACPI_MAX32_BYTE_WIDTH, + &TempGpeNumber); + ACPI_CHECK_OK (AcpiUtStrtoul64, Status); + + Status = AcpiUtStrtoul64 ("CC", 16, ACPI_MAX32_BYTE_WIDTH, + &TempGpeNumber); + ACPI_CHECK_OK (AcpiUtStrtoul64, Status); + + Status = AcpiUtStrtoul64 ("DY", 16, ACPI_MAX32_BYTE_WIDTH, + &TempGpeNumber); + ACPI_CHECK_STATUS (AcpiUtStrtoul64, Status, AE_BAD_HEX_CONSTANT); + + /* Normal conversions */ + + Status = AcpiUtStrtoul64 ("0x", 0, ACPI_MAX64_BYTE_WIDTH, &Value); + ACPI_CHECK_STATUS (AcpiUtStrtoul64, Status, AE_BAD_HEX_CONSTANT); + + Status = AcpiUtStrtoul64 (" utututututu", 16, ACPI_MAX64_BYTE_WIDTH, &Value); + ACPI_CHECK_STATUS (AcpiUtStrtoul64, Status, AE_BAD_HEX_CONSTANT); + + Status = AcpiUtStrtoul64 (" ", 0, ACPI_MAX64_BYTE_WIDTH, &Value); + ACPI_CHECK_STATUS (AcpiUtStrtoul64, Status, AE_BAD_PARAMETER); + + Status = AcpiUtStrtoul64 ("", 0, ACPI_MAX64_BYTE_WIDTH, &Value); + ACPI_CHECK_STATUS (AcpiUtStrtoul64, Status, AE_BAD_PARAMETER); + + Status = AcpiUtStrtoul64 (NULL, 0, ACPI_MAX64_BYTE_WIDTH, &Value); + ACPI_CHECK_STATUS (AcpiUtStrtoul64, Status, AE_BAD_PARAMETER); + + Status = AcpiUtStrtoul64 ("0x 012345678AAAAAAAyyyy", 0, ACPI_MAX64_BYTE_WIDTH, &Value); + ACPI_CHECK_STATUS (AcpiUtStrtoul64, Status, AE_BAD_HEX_CONSTANT); + + Status = AcpiUtStrtoul64 ("0x012345678AAAAAAAyyyy", 0, ACPI_MAX64_BYTE_WIDTH, &Value); + ACPI_CHECK_STATUS (AcpiUtStrtoul64, Status, AE_BAD_HEX_CONSTANT); + + Status = AcpiUtStrtoul64 ("0123456789ABCDEF", 16, ACPI_MAX64_BYTE_WIDTH, &Value); + ACPI_CHECK_OK (AcpiUtStrtoul64, Status); + + Status = AcpiUtStrtoul64 ("0x0123456789ABCDEF", 0, ACPI_MAX64_BYTE_WIDTH, &Value); + ACPI_CHECK_OK (AcpiUtStrtoul64, Status); + + Status = AcpiUtStrtoul64 ("0x01WXYZ", 0, ACPI_MAX64_BYTE_WIDTH, &Value); + ACPI_CHECK_STATUS (AcpiUtStrtoul64, Status, AE_BAD_HEX_CONSTANT); + + Status = AcpiUtStrtoul64 ("0x01234567", 0, ACPI_MAX32_BYTE_WIDTH, &Value); + ACPI_CHECK_OK (AcpiUtStrtoul64, Status); + + Status = AcpiUtStrtoul64 ("012345678", 0, ACPI_MAX64_BYTE_WIDTH, &Value); + ACPI_CHECK_OK (AcpiUtStrtoul64, Status); + + Status = AcpiUtStrtoul64 ("012345678", 10, ACPI_MAX64_BYTE_WIDTH, &Value); + ACPI_CHECK_OK (AcpiUtStrtoul64, Status); + + /* Overflow */ + + Status = AcpiUtStrtoul64 ("01234567877777777777777777777777777", 10, ACPI_MAX32_BYTE_WIDTH, &Value); + ACPI_CHECK_STATUS (AcpiUtStrtoul64, Status, AE_CONVERSION_OVERFLOW); + + Status = AcpiUtStrtoul64 ("0x12345678AAAAAAAAAAAAAAAAAAAA", 16, ACPI_MAX64_BYTE_WIDTH, &Value); + ACPI_CHECK_STATUS (AcpiUtStrtoul64, Status, AE_CONVERSION_OVERFLOW); + + Status = AcpiUtStrtoul64 ("0x0000000012345678BBBBCCCC", 16, ACPI_MAX64_BYTE_WIDTH, &Value); + ACPI_CHECK_OK (AcpiUtStrtoul64, Status); +} + /****************************************************************************** * @@ -936,5 +1032,9 @@ AeMiscellaneousTests ( Status = AcpiReleaseGlobalLock (LockHandle2); ACPI_CHECK_OK (AcpiReleaseGlobalLock, Status); + /* Test conversion routines */ + + AeTestStringConversions (); + #endif /* !ACPI_REDUCED_HARDWARE */ } |