FreeBSD/sys/contrib/dev/acpica/components/executer/exconvrt.c
/*******************************************************************************
 *
 * FUNCTION:    AcpiExConvertToTargetType
 *
 * PARAMETERS:  DestinationType     - Current type of the destination
 *              SourceDesc          - Source object to be converted.
 *              ResultDesc          - Where the converted object is returned
 *              WalkState           - Current method state
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Implements "implicit conversion" rules for storing an object.
 *
 ******************************************************************************/
AcpiExConvertToTargetType
PARAMETERS:  DestinationType     - Current type of the destination
SourceDesc          - Source object to be converted.
ResultDesc          - Where the converted object is returned
WalkState           - Current method state

Status

Implements "implicit conversion" rules for storing an object.
AcpiExConvertToTargetType PARAMETERS : DestinationType - Current type of the destination SourceDesc - Source object to be converted . ResultDesc - Where the converted object is returned WalkState - Current method state Status Implements " implicit conversion " rules for storing an object .
ACPI_STATUS
AcpiExConvertToTargetType (
    ACPI_OBJECT_TYPE        DestinationType,
    ACPI_OPERAND_OBJECT     *SourceDesc,
    ACPI_OPERAND_OBJECT     **ResultDesc,
    ACPI_WALK_STATE         *WalkState)
{
    ACPI_STATUS             Status = AE_OK;
    ACPI_FUNCTION_TRACE (ExConvertToTargetType);
    *ResultDesc = SourceDesc;
    switch (GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs))
    {
    case ARGI_SIMPLE_TARGET:
    case ARGI_FIXED_TARGET:
    case ARGI_INTEGER_REF:      
        switch (DestinationType)
        {
        case ACPI_TYPE_LOCAL_REGION_FIELD:
            break;
        default:
            if (DestinationType != SourceDesc->Common.Type)
            {
                ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
                    "Explicit operator, will store (%s) over existing type (%s)\n",
                    AcpiUtGetObjectTypeName (SourceDesc),
                    AcpiUtGetTypeName (DestinationType)));
                Status = AE_TYPE;
            }
        }
        break;
    case ARGI_TARGETREF:
    case ARGI_STORE_TARGET:
        switch (DestinationType)
        {
        case ACPI_TYPE_INTEGER:
        case ACPI_TYPE_BUFFER_FIELD:
        case ACPI_TYPE_LOCAL_BANK_FIELD:
        case ACPI_TYPE_LOCAL_INDEX_FIELD:
            Status = AcpiExConvertToInteger (SourceDesc, ResultDesc, 16);
            break;
        case ACPI_TYPE_STRING:
            Status = AcpiExConvertToString (SourceDesc, ResultDesc,
                ACPI_IMPLICIT_CONVERT_HEX);
            break;
        case ACPI_TYPE_BUFFER:
            Status = AcpiExConvertToBuffer (SourceDesc, ResultDesc);
            break;
        default:
            ACPI_ERROR ((AE_INFO,
                "Bad destination type during conversion: 0x%X",
                DestinationType));
            Status = AE_AML_INTERNAL;
            break;
        }
        break;
    case ARGI_REFERENCE:
        break;
    default:
        ACPI_ERROR ((AE_INFO,
            "Unknown Target type ID 0x%X AmlOpcode 0x%X DestType %s",
            GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs),
            WalkState->Opcode, AcpiUtGetTypeName (DestinationType)));
        Status = AE_AML_INTERNAL;
    }
    if (Status == AE_TYPE)
    {
        Status = AE_OK;
    }
    return_ACPI_STATUS (Status);
}
ACPI_STATUS AcpiExConvertToTargetType ( ACPI_OBJECT_TYPE DestinationType , ACPI_OPERAND_OBJECT * SourceDesc , ACPI_OPERAND_OBJECT * * ResultDesc , ACPI_WALK_STATE * WalkState ) { ACPI_STATUS Status = AE_OK ; ACPI_FUNCTION_TRACE ( ExConvertToTargetType ) ; * ResultDesc = SourceDesc ; switch ( GET_CURRENT_ARG_TYPE ( WalkState -> OpInfo -> RuntimeArgs ) ) { case ARGI_SIMPLE_TARGET : case ARGI_FIXED_TARGET : case ARGI_INTEGER_REF : switch ( DestinationType ) { case ACPI_TYPE_LOCAL_REGION_FIELD : break ; default : if ( DestinationType != SourceDesc -> Common . Type ) { ACPI_DEBUG_PRINT ( ( ACPI_DB_INFO , " \n " , AcpiUtGetObjectTypeName ( SourceDesc ) , AcpiUtGetTypeName ( DestinationType ) ) ) ; Status = AE_TYPE ; } } break ; case ARGI_TARGETREF : case ARGI_STORE_TARGET : switch ( DestinationType ) { case ACPI_TYPE_INTEGER : case ACPI_TYPE_BUFFER_FIELD : case ACPI_TYPE_LOCAL_BANK_FIELD : case ACPI_TYPE_LOCAL_INDEX_FIELD : Status = AcpiExConvertToInteger ( SourceDesc , ResultDesc , 16 ) ; break ; case ACPI_TYPE_STRING : Status = AcpiExConvertToString ( SourceDesc , ResultDesc , ACPI_IMPLICIT_CONVERT_HEX ) ; break ; case ACPI_TYPE_BUFFER : Status = AcpiExConvertToBuffer ( SourceDesc , ResultDesc ) ; break ; default : ACPI_ERROR ( ( AE_INFO , " " , DestinationType ) ) ; Status = AE_AML_INTERNAL ; break ; } break ; case ARGI_REFERENCE : break ; default : ACPI_ERROR ( ( AE_INFO , " " , GET_CURRENT_ARG_TYPE ( WalkState -> OpInfo -> RuntimeArgs ) , WalkState -> Opcode , AcpiUtGetTypeName ( DestinationType ) ) ) ; Status = AE_AML_INTERNAL ; } if ( Status == AE_TYPE ) { Status = AE_OK ; } return_ACPI_STATUS ( Status ) ; }
FUNCTION:    AcpiExConvertToTargetType
 PARAMETERS:  DestinationType     - Current type of the destination
              SourceDesc          - Source object to be converted.
FUNCTION : AcpiExConvertToTargetType PARAMETERS : DestinationType - Current type of the destination SourceDesc - Source object to be converted .
/* Default behavior */ /*
     * If required by the target,
     * perform implicit conversion on the source before we store it.
     */ /* Handles Increment, Decrement cases */ /*
             * Named field can always handle conversions
             */ /* No conversion allowed for these types */ /*
             * These types require an Integer operand. We can convert
             * a Buffer or a String to an Integer if necessary.
             */ /*
             * The operand must be a String. We can convert an
             * Integer or Buffer if necessary
             */ /*
             * The operand must be a Buffer. We can convert an
             * Integer or String if necessary
             */ /*
         * CreateXxxxField cases - we are storing the field object into the name
         */ /*
     * Source-to-Target conversion semantics:
     *
     * If conversion to the target type cannot be performed, then simply
     * overwrite the target with the new object and type.
     */