src/add-ons/kernel/bus_managers/acpi/acpica/components/executer/exconvrt.c
/*******************************************************************************
 *
 * FUNCTION:    AcpiExConvertToBuffer
 *
 * PARAMETERS:  ObjDesc         - Object to be converted. Must be an
 *                                Integer, Buffer, or String
 *              ResultDesc      - Where the new buffer object is returned
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Convert an ACPI Object to a Buffer
 *
 ******************************************************************************/
AcpiExConvertToBuffer
PARAMETERS:  ObjDesc         - Object to be converted. Must be an
Integer, Buffer, or String
ResultDesc      - Where the new buffer object is returned

Status

Convert an ACPI Object to a Buffer
AcpiExConvertToBuffer PARAMETERS : ObjDesc - Object to be converted . Must be an Integer Buffer or String ResultDesc - Where the new buffer object is returned Status Convert an ACPI Object to a Buffer
ACPI_STATUS
AcpiExConvertToBuffer (
    ACPI_OPERAND_OBJECT     *ObjDesc,
    ACPI_OPERAND_OBJECT     **ResultDesc)
{
    ACPI_OPERAND_OBJECT     *ReturnDesc;
    UINT8                   *NewBuf;
    ACPI_FUNCTION_TRACE_PTR (ExConvertToBuffer, ObjDesc);
    switch (ObjDesc->Common.Type)
    {
    case ACPI_TYPE_BUFFER:
        *ResultDesc = ObjDesc;
        return_ACPI_STATUS (AE_OK);
    case ACPI_TYPE_INTEGER:
        ReturnDesc = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth);
        if (!ReturnDesc)
        {
            return_ACPI_STATUS (AE_NO_MEMORY);
        }
        NewBuf = ReturnDesc->Buffer.Pointer;
        memcpy (NewBuf, &ObjDesc->Integer.Value, AcpiGbl_IntegerByteWidth);
        break;
    case ACPI_TYPE_STRING:
        ReturnDesc = AcpiUtCreateBufferObject ((ACPI_SIZE)
            ObjDesc->String.Length + 1);
        if (!ReturnDesc)
        {
            return_ACPI_STATUS (AE_NO_MEMORY);
        }
        NewBuf = ReturnDesc->Buffer.Pointer;
        strncpy ((char *) NewBuf, (char *) ObjDesc->String.Pointer,
            ObjDesc->String.Length);
        break;
    default:
        return_ACPI_STATUS (AE_TYPE);
    }
    ReturnDesc->Common.Flags |= AOPOBJ_DATA_VALID;
    *ResultDesc = ReturnDesc;
    return_ACPI_STATUS (AE_OK);
}
ACPI_STATUS AcpiExConvertToBuffer ( ACPI_OPERAND_OBJECT * ObjDesc , ACPI_OPERAND_OBJECT * * ResultDesc ) { ACPI_OPERAND_OBJECT * ReturnDesc ; UINT8 * NewBuf ; ACPI_FUNCTION_TRACE_PTR ( ExConvertToBuffer , ObjDesc ) ; switch ( ObjDesc -> Common . Type ) { case ACPI_TYPE_BUFFER : * ResultDesc = ObjDesc ; return_ACPI_STATUS ( AE_OK ) ; case ACPI_TYPE_INTEGER : ReturnDesc = AcpiUtCreateBufferObject ( AcpiGbl_IntegerByteWidth ) ; if ( ! ReturnDesc ) { return_ACPI_STATUS ( AE_NO_MEMORY ) ; } NewBuf = ReturnDesc -> Buffer . Pointer ; memcpy ( NewBuf , & ObjDesc -> Integer . Value , AcpiGbl_IntegerByteWidth ) ; break ; case ACPI_TYPE_STRING : ReturnDesc = AcpiUtCreateBufferObject ( ( ACPI_SIZE ) ObjDesc -> String . Length + 1 ) ; if ( ! ReturnDesc ) { return_ACPI_STATUS ( AE_NO_MEMORY ) ; } NewBuf = ReturnDesc -> Buffer . Pointer ; strncpy ( ( char * ) NewBuf , ( char * ) ObjDesc -> String . Pointer , ObjDesc -> String . Length ) ; break ; default : return_ACPI_STATUS ( AE_TYPE ) ; } ReturnDesc -> Common . Flags |= AOPOBJ_DATA_VALID ; * ResultDesc = ReturnDesc ; return_ACPI_STATUS ( AE_OK ) ; }
FUNCTION:    AcpiExConvertToBuffer
 PARAMETERS:  ObjDesc         - Object to be converted.
FUNCTION : AcpiExConvertToBuffer PARAMETERS : ObjDesc - Object to be converted .
/* No conversion necessary */ /*
         * Create a new Buffer object.
         * Need enough space for one integer
         */ /* Copy the integer to the buffer, LSB first */ /*
         * Create a new Buffer object
         * Size will be the string length
         *
         * NOTE: Add one to the string length to include the null terminator.
         * The ACPI spec is unclear on this subject, but there is existing
         * ASL/AML code that depends on the null being transferred to the new
         * buffer.
         */ /* Copy the string to the buffer */ /* Mark buffer initialized */