diff options
Diffstat (limited to 'source/compiler/dtfield.c')
-rw-r--r-- | source/compiler/dtfield.c | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/source/compiler/dtfield.c b/source/compiler/dtfield.c index a34b8e16a0f12..49bae7221266c 100644 --- a/source/compiler/dtfield.c +++ b/source/compiler/dtfield.c @@ -370,10 +370,10 @@ DtCompileInteger ( * FUNCTION: DtNormalizeBuffer * * PARAMETERS: Buffer - Input buffer - * Count - Output the count of hex number in + * Count - Output the count of hex numbers in * the Buffer * - * RETURN: The normalized buffer, freed by caller + * RETURN: The normalized buffer, must be freed by caller * * DESCRIPTION: [1A,2B,3C,4D] or 1A, 2B, 3C, 4D will be normalized * to 1A 2B 3C 4D @@ -457,36 +457,38 @@ DtCompileBuffer ( DT_FIELD *Field, UINT32 ByteLength) { + char *Substring; ACPI_STATUS Status; - char Hex[3]; - UINT64 Value; - UINT32 i; UINT32 Count; + UINT32 i; /* Allow several different types of value separators */ StringValue = DtNormalizeBuffer (StringValue, &Count); + Substring = StringValue; - Hex[2] = 0; - for (i = 0; i < Count; i++) + /* Each element of StringValue is now three chars (2 hex + 1 space) */ + + for (i = 0; i < Count; i++, Substring += 3) { - /* Each element of StringValue is three chars */ + /* Check for byte value too long */ - Hex[0] = StringValue[(3 * i)]; - Hex[1] = StringValue[(3 * i) + 1]; + if (*(&Substring[2]) && + (*(&Substring[2]) != ' ')) + { + DtError (ASL_ERROR, ASL_MSG_BUFFER_ELEMENT, Field, Substring); + goto Exit; + } - /* Convert one hex byte */ + /* Convert two ASCII characters to one hex byte */ - Value = 0; - Status = DtStrtoul64 (Hex, &Value); + Status = AcpiUtAsciiToHexByte (Substring, &Buffer[i]); if (ACPI_FAILURE (Status)) { - DtError (ASL_ERROR, ASL_MSG_BUFFER_ELEMENT, Field, MsgBuffer); + DtError (ASL_ERROR, ASL_MSG_BUFFER_ELEMENT, Field, Substring); goto Exit; } - - Buffer[i] = (UINT8) Value; } Exit: @@ -499,13 +501,13 @@ Exit: * * FUNCTION: DtCompileFlag * - * PARAMETERS: Buffer - Output buffer - * Field - Field to be compiled - * Info - Flag info + * PARAMETERS: Buffer - Output buffer + * Field - Field to be compiled + * Info - Flag info * - * RETURN: + * RETURN: None * - * DESCRIPTION: Compile a flag + * DESCRIPTION: Compile a flag field. Handles flags up to 64 bits. * *****************************************************************************/ @@ -521,7 +523,8 @@ DtCompileFlag ( ACPI_STATUS Status; - Status = DtStrtoul64 (Field->Value, &Value); + Status = AcpiUtStrtoul64 (Field->Value, + (ACPI_STRTOUL_64BIT | ACPI_STRTOUL_BASE16), &Value); if (ACPI_FAILURE (Status)) { DtError (ASL_ERROR, ASL_MSG_INVALID_HEX_INTEGER, Field, NULL); |