Example #1
0
UINT32
DtCompileBuffer (
    UINT8                   *Buffer,
    char                    *StringValue,
    DT_FIELD                *Field,
    UINT32                  ByteLength)
{
    char                    *Substring;
    ACPI_STATUS             Status;
    UINT32                  Count;
    UINT32                  i;


    /* Allow several different types of value separators */

    StringValue = DtNormalizeBuffer (StringValue, &Count);
    Substring = StringValue;

    /* Each element of StringValue is now three chars (2 hex + 1 space) */

    for (i = 0; i < Count; i++, Substring += 3)
    {
        /* Check for byte value too long */

        if (*(&Substring[2]) &&
           (*(&Substring[2]) != ' '))
        {
            DtError (ASL_ERROR, ASL_MSG_BUFFER_ELEMENT, Field, Substring);
            goto Exit;
        }

        /* Convert two ASCII characters to one hex byte */

        Status = AcpiUtAsciiToHexByte (Substring, &Buffer[i]);
        if (ACPI_FAILURE (Status))
        {
            DtError (ASL_ERROR, ASL_MSG_BUFFER_ELEMENT, Field, Substring);
            goto Exit;
        }
    }

Exit:
    ACPI_FREE (StringValue);
    return (ByteLength - Count);
}
Example #2
0
UINT32
DtCompileBuffer (
    UINT8                   *Buffer,
    char                    *StringValue,
    DT_FIELD                *Field,
    UINT32                  ByteLength)
{
    ACPI_STATUS             Status;
    char                    Hex[3];
    UINT64                  Value;
    UINT32                  i;
    UINT32                  Count;


    /* Allow several different types of value separators */

    StringValue = DtNormalizeBuffer (StringValue, &Count);

    Hex[2] = 0;
    for (i = 0; i < Count; i++)
    {
        /* Each element of StringValue is three chars */

        Hex[0] = StringValue[(3 * i)];
        Hex[1] = StringValue[(3 * i) + 1];

        /* Convert one hex byte */

        Value = 0;
        Status = DtStrtoul64 (Hex, &Value);
        if (ACPI_FAILURE (Status))
        {
            DtError (ASL_ERROR, ASL_MSG_BUFFER_ELEMENT, Field, MsgBuffer);
            goto Exit;
        }

        Buffer[i] = (UINT8) Value;
    }

Exit:
    ACPI_FREE (StringValue);
    return (ByteLength - Count);
}