static void stream_process_mem2s(struct Stream *s,

                                 StreamSlave *tx_dev)

{

    uint32_t prev_d;

    unsigned char txbuf[16 * 1024];

    unsigned int txlen;

    uint32_t app[6];



    if (!stream_running(s) || stream_idle(s)) {

        return;

    }



    while (1) {

        stream_desc_load(s, s->regs[R_CURDESC]);



        if (s->desc.status & SDESC_STATUS_COMPLETE) {

            s->regs[R_DMASR] |= DMASR_HALTED;

            break;

        }



        if (stream_desc_sof(&s->desc)) {

            s->pos = 0;

            memcpy(app, s->desc.app, sizeof app);

        }



        txlen = s->desc.control & SDESC_CTRL_LEN_MASK;

        if ((txlen + s->pos) > sizeof txbuf) {

            hw_error("%s: too small internal txbuf! %d\n", __func__,

                     txlen + s->pos);

        }



        cpu_physical_memory_read(s->desc.buffer_address,

                                 txbuf + s->pos, txlen);

        s->pos += txlen;



        if (stream_desc_eof(&s->desc)) {

            stream_push(tx_dev, txbuf, s->pos, app);

            s->pos = 0;

            stream_complete(s);

        }



        /* Update the descriptor.  */

        s->desc.status = txlen | SDESC_STATUS_COMPLETE;

        stream_desc_store(s, s->regs[R_CURDESC]);



        /* Advance.  */

        prev_d = s->regs[R_CURDESC];

        s->regs[R_CURDESC] = s->desc.nxtdesc;

        if (prev_d == s->regs[R_TAILDESC]) {

            s->regs[R_DMASR] |= DMASR_IDLE;

            break;

        }

    }

}

static void stream_process_mem2s(struct Stream *s,

                                 StreamSlave *tx_dev)

{

    uint32_t prev_d;

    unsigned char txbuf[16 * 1024];

    unsigned int txlen;

    uint32_t app[6];



    if (!stream_running(s) || stream_idle(s)) {

        return;

    }



    while (1) {

        stream_desc_load(s, s->regs[R_CURDESC]);



        if (s->desc.status & SDESC_STATUS_COMPLETE) {

            s->regs[R_DMASR] |= DMASR_HALTED;

            break;

        }



        if (stream_desc_sof(&s->desc)) {

            s->pos = 0;

            memcpy(app, s->desc.app, sizeof app);

        }



        txlen = s->desc.control & SDESC_CTRL_LEN_MASK;

        if ((txlen + s->pos) > sizeof txbuf) {

            hw_error("%s: too small internal txbuf! %d\n", __func__,

                     txlen + s->pos);

        }



        cpu_physical_memory_read(s->desc.buffer_address,

                                 txbuf + s->pos, txlen);

        s->pos += txlen;



        if (stream_desc_eof(&s->desc)) {

            stream_push(tx_dev, txbuf, s->pos, app);

            s->pos = 0;

            stream_complete(s);

        }



        

        s->desc.status = txlen | SDESC_STATUS_COMPLETE;

        stream_desc_store(s, s->regs[R_CURDESC]);



        

        prev_d = s->regs[R_CURDESC];

        s->regs[R_CURDESC] = s->desc.nxtdesc;

        if (prev_d == s->regs[R_TAILDESC]) {

            s->regs[R_DMASR] |= DMASR_IDLE;

            break;

        }

    }

}

static void FUNC_0(struct Stream *VAR_0,

                                 StreamSlave *VAR_1)

{

    uint32_t prev_d;

    unsigned char VAR_2[16 * 1024];

    unsigned int VAR_3;

    uint32_t app[6];



    if (!stream_running(VAR_0) || stream_idle(VAR_0)) {

        return;

    }



    while (1) {

        stream_desc_load(VAR_0, VAR_0->regs[R_CURDESC]);



        if (VAR_0->desc.status & SDESC_STATUS_COMPLETE) {

            VAR_0->regs[R_DMASR] |= DMASR_HALTED;

            break;

        }



        if (stream_desc_sof(&VAR_0->desc)) {

            VAR_0->pos = 0;

            memcpy(app, VAR_0->desc.app, sizeof app);

        }



        VAR_3 = VAR_0->desc.control & SDESC_CTRL_LEN_MASK;

        if ((VAR_3 + VAR_0->pos) > sizeof VAR_2) {

            hw_error("%VAR_0: too small internal VAR_2! %d\n", __func__,

                     VAR_3 + VAR_0->pos);

        }



        cpu_physical_memory_read(VAR_0->desc.buffer_address,

                                 VAR_2 + VAR_0->pos, VAR_3);

        VAR_0->pos += VAR_3;



        if (stream_desc_eof(&VAR_0->desc)) {

            stream_push(VAR_1, VAR_2, VAR_0->pos, app);

            VAR_0->pos = 0;

            stream_complete(VAR_0);

        }



        

        VAR_0->desc.status = VAR_3 | SDESC_STATUS_COMPLETE;

        stream_desc_store(VAR_0, VAR_0->regs[R_CURDESC]);



        

        prev_d = VAR_0->regs[R_CURDESC];

        VAR_0->regs[R_CURDESC] = VAR_0->desc.nxtdesc;

        if (prev_d == VAR_0->regs[R_TAILDESC]) {

            VAR_0->regs[R_DMASR] |= DMASR_IDLE;

            break;

        }

    }

}

static void FUNC_0(struct Stream *VAR_0,
StreamSlave *VAR_1)
{ uint32_t prev_d; unsigned char VAR_2[16 * 1024]; unsigned int VAR_3; uint32_t app[6]; if (!stream_running(VAR_0) || stream_idle(VAR_0)) { return; } while (1) { stream_desc_load(VAR_0, VAR_0->regs[R_CURDESC]); if (VAR_0->desc.status & SDESC_STATUS_COMPLETE) { VAR_0->regs[R_DMASR] |= DMASR_HALTED; break; } if (stream_desc_sof(&VAR_0->desc)) { VAR_0->pos = 0; memcpy(app, VAR_0->desc.app, sizeof app); } VAR_3 = VAR_0->desc.control & SDESC_CTRL_LEN_MASK; if ((VAR_3 + VAR_0->pos) > sizeof VAR_2) { hw_error("%VAR_0: too small internal VAR_2! %d\n", __func__,
VAR_3 + VAR_0->pos); } cpu_physical_memory_read(VAR_0->desc.buffer_address,
VAR_2 + VAR_0->pos, VAR_3); VAR_0->pos += VAR_3; if (stream_desc_eof(&VAR_0->desc)) { stream_push(VAR_1, VAR_2, VAR_0->pos, app); VAR_0->pos = 0; stream_complete(VAR_0); } VAR_0->desc.status = VAR_3 | SDESC_STATUS_COMPLETE; stream_desc_store(VAR_0, VAR_0->regs[R_CURDESC]); prev_d = VAR_0->regs[R_CURDESC]; VAR_0->regs[R_CURDESC] = VAR_0->desc.nxtdesc; if (prev_d == VAR_0->regs[R_TAILDESC]) { VAR_0->regs[R_DMASR] |= DMASR_IDLE; break; } } }