static void lsi_do_dma(LSIState *s, int out)

{

    uint32_t count, id;

    target_phys_addr_t addr;

    SCSIDevice *dev;



    assert(s->current);

    if (!s->current->dma_len) {

        /* Wait until data is available.  */

        DPRINTF("DMA no data available\n");

        return;

    }



    id = (s->current->tag >> 8) & 0xf;

    dev = s->bus.devs[id];

    if (!dev) {

        lsi_bad_selection(s, id);

        return;

    }



    count = s->dbc;

    if (count > s->current->dma_len)

        count = s->current->dma_len;



    addr = s->dnad;

    /* both 40 and Table Indirect 64-bit DMAs store upper bits in dnad64 */

    if (lsi_dma_40bit(s) || lsi_dma_ti64bit(s))

        addr |= ((uint64_t)s->dnad64 << 32);

    else if (s->dbms)

        addr |= ((uint64_t)s->dbms << 32);

    else if (s->sbms)

        addr |= ((uint64_t)s->sbms << 32);



    DPRINTF("DMA addr=0x" TARGET_FMT_plx " len=%d\n", addr, count);

    s->csbc += count;

    s->dnad += count;

    s->dbc -= count;



    if (s->current->dma_buf == NULL) {

        s->current->dma_buf = dev->info->get_buf(dev, s->current->tag);

    }



    /* ??? Set SFBR to first data byte.  */

    if (out) {

        cpu_physical_memory_read(addr, s->current->dma_buf, count);

    } else {

        cpu_physical_memory_write(addr, s->current->dma_buf, count);

    }

    s->current->dma_len -= count;

    if (s->current->dma_len == 0) {

        s->current->dma_buf = NULL;

        if (out) {

            /* Write the data.  */

            dev->info->write_data(dev, s->current->tag);

        } else {

            /* Request any remaining data.  */

            dev->info->read_data(dev, s->current->tag);

        }

    } else {

        s->current->dma_buf += count;

        lsi_resume_script(s);

    }

}

static void lsi_do_dma(LSIState *s, int out)

{

    uint32_t count, id;

    target_phys_addr_t addr;

    SCSIDevice *dev;



    assert(s->current);

    if (!s->current->dma_len) {

        

        DPRINTF("DMA no data available\n");

        return;

    }



    id = (s->current->tag >> 8) & 0xf;

    dev = s->bus.devs[id];

    if (!dev) {

        lsi_bad_selection(s, id);

        return;

    }



    count = s->dbc;

    if (count > s->current->dma_len)

        count = s->current->dma_len;



    addr = s->dnad;

    

    if (lsi_dma_40bit(s) || lsi_dma_ti64bit(s))

        addr |= ((uint64_t)s->dnad64 << 32);

    else if (s->dbms)

        addr |= ((uint64_t)s->dbms << 32);

    else if (s->sbms)

        addr |= ((uint64_t)s->sbms << 32);



    DPRINTF("DMA addr=0x" TARGET_FMT_plx " len=%d\n", addr, count);

    s->csbc += count;

    s->dnad += count;

    s->dbc -= count;



    if (s->current->dma_buf == NULL) {

        s->current->dma_buf = dev->info->get_buf(dev, s->current->tag);

    }



    

    if (out) {

        cpu_physical_memory_read(addr, s->current->dma_buf, count);

    } else {

        cpu_physical_memory_write(addr, s->current->dma_buf, count);

    }

    s->current->dma_len -= count;

    if (s->current->dma_len == 0) {

        s->current->dma_buf = NULL;

        if (out) {

            

            dev->info->write_data(dev, s->current->tag);

        } else {

            

            dev->info->read_data(dev, s->current->tag);

        }

    } else {

        s->current->dma_buf += count;

        lsi_resume_script(s);

    }

}

    if (s->current->dma_buf == NULL) {         s->current->dma_buf = dev->info->get_buf(dev, s->current->tag);             dev->info->write_data(dev, s->current->tag);             dev->info->read_data(dev, s->current->tag);
static void FUNC_0(LSIState *VAR_0, int VAR_1)

{

    uint32_t count, id;

    target_phys_addr_t addr;

    SCSIDevice *dev;



    assert(VAR_0->current);

    if (!VAR_0->current->dma_len) {

        

        DPRINTF("DMA no data available\n");

        return;

    }



    id = (VAR_0->current->tag >> 8) & 0xf;

    dev = VAR_0->bus.devs[id];

    if (!dev) {

        lsi_bad_selection(VAR_0, id);

        return;

    }



    count = VAR_0->dbc;

    if (count > VAR_0->current->dma_len)

        count = VAR_0->current->dma_len;



    addr = VAR_0->dnad;

    

    if (lsi_dma_40bit(VAR_0) || lsi_dma_ti64bit(VAR_0))

        addr |= ((uint64_t)VAR_0->dnad64 << 32);

    else if (VAR_0->dbms)

        addr |= ((uint64_t)VAR_0->dbms << 32);

    else if (VAR_0->sbms)

        addr |= ((uint64_t)VAR_0->sbms << 32);



    DPRINTF("DMA addr=0x" TARGET_FMT_plx " len=%d\n", addr, count);

    VAR_0->csbc += count;

    VAR_0->dnad += count;

    VAR_0->dbc -= count;



    if (VAR_0->current->dma_buf == NULL) {

        VAR_0->current->dma_buf = dev->info->get_buf(dev, VAR_0->current->tag);

    }



    

    if (VAR_1) {

        cpu_physical_memory_read(addr, VAR_0->current->dma_buf, count);

    } else {

        cpu_physical_memory_write(addr, VAR_0->current->dma_buf, count);

    }

    VAR_0->current->dma_len -= count;

    if (VAR_0->current->dma_len == 0) {

        VAR_0->current->dma_buf = NULL;

        if (VAR_1) {

            

            dev->info->write_data(dev, VAR_0->current->tag);

        } else {

            

            dev->info->read_data(dev, VAR_0->current->tag);

        }

    } else {

        VAR_0->current->dma_buf += count;

        lsi_resume_script(VAR_0);

    }

}

static void FUNC_0(LSIState *VAR_0, int VAR_1)
{ uint32_t count, id; target_phys_addr_t addr; SCSIDevice *dev; assert(VAR_0->current); if (!VAR_0->current->dma_len) { DPRINTF("DMA no data available\n"); return; } id = (VAR_0->current->tag >> 8) & 0xf; dev = VAR_0->bus.devs[id]; if (!dev) { lsi_bad_selection(VAR_0, id); return; } count = VAR_0->dbc; if (count > VAR_0->current->dma_len)
count = VAR_0->current->dma_len; addr = VAR_0->dnad; if (lsi_dma_40bit(VAR_0) || lsi_dma_ti64bit(VAR_0))
addr |= ((uint64_t)VAR_0->dnad64 << 32); else if (VAR_0->dbms)
addr |= ((uint64_t)VAR_0->dbms << 32); else if (VAR_0->sbms)
addr |= ((uint64_t)VAR_0->sbms << 32); DPRINTF("DMA addr=0x" TARGET_FMT_plx " len=%d\n", addr, count); VAR_0->csbc += count; VAR_0->dnad += count; VAR_0->dbc -= count; if (VAR_0->current->dma_buf == NULL) { VAR_0->current->dma_buf = dev->info->get_buf(dev, VAR_0->current->tag); } if (VAR_1) { cpu_physical_memory_read(addr, VAR_0->current->dma_buf, count); } else { cpu_physical_memory_write(addr, VAR_0->current->dma_buf, count); } VAR_0->current->dma_len -= count; if (VAR_0->current->dma_len == 0) { VAR_0->current->dma_buf = NULL; if (VAR_1) { dev->info->write_data(dev, VAR_0->current->tag); } else { dev->info->read_data(dev, VAR_0->current->tag); } } else { VAR_0->current->dma_buf += count; lsi_resume_script(VAR_0); } }