diff options
Diffstat (limited to 'sys/contrib/dev/acpica/exconvrt.c')
-rw-r--r-- | sys/contrib/dev/acpica/exconvrt.c | 64 |
1 files changed, 37 insertions, 27 deletions
diff --git a/sys/contrib/dev/acpica/exconvrt.c b/sys/contrib/dev/acpica/exconvrt.c index f5937f1..3b175ae 100644 --- a/sys/contrib/dev/acpica/exconvrt.c +++ b/sys/contrib/dev/acpica/exconvrt.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exconvrt - Object conversion routines - * $Revision: 44 $ + * $Revision: 49 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp. * All rights reserved. * * 2. License @@ -310,7 +310,7 @@ AcpiExConvertToBuffer ( /* * Create a new Buffer object. - * Need enough space for one integer + * Need enough space for one integer */ RetDesc = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth); if (!RetDesc) @@ -334,7 +334,7 @@ AcpiExConvertToBuffer ( * Create a new Buffer object * Size will be the string length */ - RetDesc = AcpiUtCreateBufferObject (ObjDesc->String.Length); + RetDesc = AcpiUtCreateBufferObject ((ACPI_SIZE) ObjDesc->String.Length); if (!RetDesc) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -343,7 +343,7 @@ AcpiExConvertToBuffer ( /* Copy the string to the buffer */ NewBuf = RetDesc->Buffer.Pointer; - ACPI_STRNCPY ((char *) NewBuf, (char *) ObjDesc->String.Pointer, + ACPI_STRNCPY ((char *) NewBuf, (char *) ObjDesc->String.Pointer, ObjDesc->String.Length); break; @@ -381,6 +381,7 @@ AcpiExConvertToBuffer ( * PARAMETERS: Integer - Value to be converted * Base - 10 or 16 * String - Where the string is returned + * DataWidth - Size of data item to be converted * * RETURN: Actual string length * @@ -392,7 +393,8 @@ UINT32 AcpiExConvertToAscii ( ACPI_INTEGER Integer, UINT32 Base, - UINT8 *String) + UINT8 *String, + UINT8 DataWidth) { UINT32 i; UINT32 j; @@ -400,12 +402,23 @@ AcpiExConvertToAscii ( char HexDigit; ACPI_INTEGER Digit; UINT32 Remainder; - UINT32 Length = sizeof (ACPI_INTEGER); - BOOLEAN LeadingZero = TRUE; + UINT32 Length; + BOOLEAN LeadingZero; ACPI_FUNCTION_ENTRY (); + if (DataWidth < sizeof (ACPI_INTEGER)) + { + LeadingZero = FALSE; + Length = DataWidth; + } + else + { + LeadingZero = TRUE; + Length = sizeof (ACPI_INTEGER); + } + switch (Base) { @@ -473,8 +486,8 @@ AcpiExConvertToAscii ( String [0] = ACPI_ASCII_ZERO; k = 1; } - String [k] = 0; + String [k] = 0; return (k); } @@ -503,7 +516,6 @@ AcpiExConvertToString ( { ACPI_OPERAND_OBJECT *RetDesc; UINT32 i; - UINT32 Index; UINT32 StringLength; UINT8 *NewBuf; UINT8 *Pointer; @@ -559,7 +571,7 @@ AcpiExConvertToString ( /* Convert */ - i = AcpiExConvertToAscii (ObjDesc->Integer.Value, Base, NewBuf); + i = AcpiExConvertToAscii (ObjDesc->Integer.Value, Base, NewBuf, sizeof (ACPI_INTEGER)); /* Null terminate at the correct place */ @@ -580,10 +592,17 @@ AcpiExConvertToString ( case ACPI_TYPE_BUFFER: - StringLength = ObjDesc->Buffer.Length * 3; - if (Base == 10) + /* Find the string length */ + + Pointer = ObjDesc->Buffer.Pointer; + for (StringLength = 0; StringLength < ObjDesc->Buffer.Length; StringLength++) { - StringLength = ObjDesc->Buffer.Length * 4; + /* Exit on null terminator */ + + if (!Pointer[StringLength]) + { + break; + } } if (MaxLength > ACPI_MAX_STRING_CONVERSION) @@ -619,24 +638,15 @@ AcpiExConvertToString ( return_ACPI_STATUS (AE_NO_MEMORY); } - /* - * Convert each byte of the buffer to two ASCII characters plus a space. - */ - Pointer = ObjDesc->Buffer.Pointer; - Index = 0; - for (i = 0, Index = 0; i < ObjDesc->Buffer.Length; i++) - { - Index = AcpiExConvertToAscii ((ACPI_INTEGER) Pointer[i], Base, &NewBuf[Index]); + /* Copy the appropriate number of buffer characters */ - NewBuf[Index] = ' '; - Index++; - } + ACPI_MEMCPY (NewBuf, Pointer, StringLength); /* Null terminate */ - NewBuf [Index-1] = 0; + NewBuf [StringLength] = 0; RetDesc->Buffer.Pointer = NewBuf; - RetDesc->String.Length = (UINT32) ACPI_STRLEN ((char *) NewBuf); + RetDesc->String.Length = StringLength; break; |