static int megasas_build_sense(MegasasCmd *cmd, uint8_t *sense_ptr,

    uint8_t sense_len)

{

    uint32_t pa_hi = 0, pa_lo;

    target_phys_addr_t pa;



    if (sense_len > cmd->frame->header.sense_len) {

        sense_len = cmd->frame->header.sense_len;

    }

    if (sense_len) {

        pa_lo = le32_to_cpu(cmd->frame->pass.sense_addr_lo);

        if (megasas_frame_is_sense64(cmd)) {

            pa_hi = le32_to_cpu(cmd->frame->pass.sense_addr_hi);

        }

        pa = ((uint64_t) pa_hi << 32) | pa_lo;

        cpu_physical_memory_write(pa, sense_ptr, sense_len);

        cmd->frame->header.sense_len = sense_len;

    }

    return sense_len;

}

static int megasas_build_sense(MegasasCmd *cmd, uint8_t *sense_ptr,

    uint8_t sense_len)

{

    uint32_t pa_hi = 0, pa_lo;

    target_phys_addr_t pa;



    if (sense_len > cmd->frame->header.sense_len) {

        sense_len = cmd->frame->header.sense_len;

    }

    if (sense_len) {

        pa_lo = le32_to_cpu(cmd->frame->pass.sense_addr_lo);

        if (megasas_frame_is_sense64(cmd)) {

            pa_hi = le32_to_cpu(cmd->frame->pass.sense_addr_hi);

        }

        pa = ((uint64_t) pa_hi << 32) | pa_lo;

        cpu_physical_memory_write(pa, sense_ptr, sense_len);

        cmd->frame->header.sense_len = sense_len;

    }

    return sense_len;

}

static int FUNC_0(MegasasCmd *VAR_0, uint8_t *VAR_1,

    uint8_t VAR_2)

{

    uint32_t pa_hi = 0, pa_lo;

    target_phys_addr_t pa;



    if (VAR_2 > VAR_0->frame->header.VAR_2) {

        VAR_2 = VAR_0->frame->header.VAR_2;

    }

    if (VAR_2) {

        pa_lo = le32_to_cpu(VAR_0->frame->pass.sense_addr_lo);

        if (megasas_frame_is_sense64(VAR_0)) {

            pa_hi = le32_to_cpu(VAR_0->frame->pass.sense_addr_hi);

        }

        pa = ((uint64_t) pa_hi << 32) | pa_lo;

        cpu_physical_memory_write(pa, VAR_1, VAR_2);

        VAR_0->frame->header.VAR_2 = VAR_2;

    }

    return VAR_2;

}

static int FUNC_0(MegasasCmd *VAR_0, uint8_t *VAR_1,
uint8_t VAR_2)
{ uint32_t pa_hi = 0, pa_lo; target_phys_addr_t pa; if (VAR_2 > VAR_0->frame->header.VAR_2) { VAR_2 = VAR_0->frame->header.VAR_2; } if (VAR_2) { pa_lo = le32_to_cpu(VAR_0->frame->pass.sense_addr_lo); if (megasas_frame_is_sense64(VAR_0)) { pa_hi = le32_to_cpu(VAR_0->frame->pass.sense_addr_hi); } pa = ((uint64_t) pa_hi << 32) | pa_lo; cpu_physical_memory_write(pa, VAR_1, VAR_2); VAR_0->frame->header.VAR_2 = VAR_2; } return VAR_2; }