static int ahci_dma_rw_buf(IDEDMA *dma, int is_write)

{

    AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);

    IDEState *s = &ad->port.ifs[0];

    uint8_t *p = s->io_buffer + s->io_buffer_index;

    int l = s->io_buffer_size - s->io_buffer_index;



    if (ahci_populate_sglist(ad, &s->sg)) {

        return 0;

    }



    if (is_write) {

        dma_buf_read(p, l, &s->sg);

    } else {

        dma_buf_write(p, l, &s->sg);

    }



    /* update number of transferred bytes */

    ad->cur_cmd->status = cpu_to_le32(le32_to_cpu(ad->cur_cmd->status) + l);

    s->io_buffer_index += l;



    DPRINTF(ad->port_no, "len=%#x\n", l);



    return 1;

}

static int ahci_dma_rw_buf(IDEDMA *dma, int is_write)

{

    AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);

    IDEState *s = &ad->port.ifs[0];

    uint8_t *p = s->io_buffer + s->io_buffer_index;

    int l = s->io_buffer_size - s->io_buffer_index;



    if (ahci_populate_sglist(ad, &s->sg)) {

        return 0;

    }



    if (is_write) {

        dma_buf_read(p, l, &s->sg);

    } else {

        dma_buf_write(p, l, &s->sg);

    }



    

    ad->cur_cmd->status = cpu_to_le32(le32_to_cpu(ad->cur_cmd->status) + l);

    s->io_buffer_index += l;



    DPRINTF(ad->port_no, "len=%#x\n", l);



    return 1;

}

    if (ahci_populate_sglist(ad, &s->sg)) {
static int FUNC_0(IDEDMA *VAR_0, int VAR_1)

{

    AHCIDevice *ad = DO_UPCAST(AHCIDevice, VAR_0, VAR_0);

    IDEState *s = &ad->port.ifs[0];

    uint8_t *p = s->io_buffer + s->io_buffer_index;

    int VAR_2 = s->io_buffer_size - s->io_buffer_index;



    if (ahci_populate_sglist(ad, &s->sg)) {

        return 0;

    }



    if (VAR_1) {

        dma_buf_read(p, VAR_2, &s->sg);

    } else {

        dma_buf_write(p, VAR_2, &s->sg);

    }



    

    ad->cur_cmd->status = cpu_to_le32(le32_to_cpu(ad->cur_cmd->status) + VAR_2);

    s->io_buffer_index += VAR_2;



    DPRINTF(ad->port_no, "len=%#x\n", VAR_2);



    return 1;

}

static int FUNC_0(IDEDMA *VAR_0, int VAR_1)
{ AHCIDevice *ad = DO_UPCAST(AHCIDevice, VAR_0, VAR_0); IDEState *s = &ad->port.ifs[0]; uint8_t *p = s->io_buffer + s->io_buffer_index; int VAR_2 = s->io_buffer_size - s->io_buffer_index; if (ahci_populate_sglist(ad, &s->sg)) { return 0; } if (VAR_1) { dma_buf_read(p, VAR_2, &s->sg); } else { dma_buf_write(p, VAR_2, &s->sg); } ad->cur_cmd->status = cpu_to_le32(le32_to_cpu(ad->cur_cmd->status) + VAR_2); s->io_buffer_index += VAR_2; DPRINTF(ad->port_no, "len=%#x\n", VAR_2); return 1; }