static void handle_ti(ESPState *s)

{

    uint32_t dmalen, minlen;



    if (s->dma && !s->dma_enabled) {

        s->dma_cb = handle_ti;

        return;

    }



    dmalen = s->rregs[ESP_TCLO];

    dmalen |= s->rregs[ESP_TCMID] << 8;

    dmalen |= s->rregs[ESP_TCHI] << 16;

    if (dmalen==0) {

      dmalen=0x10000;

    }

    s->dma_counter = dmalen;



    if (s->do_cmd)

        minlen = (dmalen < 32) ? dmalen : 32;

    else if (s->ti_size < 0)

        minlen = (dmalen < -s->ti_size) ? dmalen : -s->ti_size;

    else

        minlen = (dmalen < s->ti_size) ? dmalen : s->ti_size;

    trace_esp_handle_ti(minlen);

    if (s->dma) {

        s->dma_left = minlen;

        s->rregs[ESP_RSTAT] &= ~STAT_TC;

        esp_do_dma(s);

    }

    if (s->do_cmd) {

        trace_esp_handle_ti_cmd(s->cmdlen);

        s->ti_size = 0;

        s->cmdlen = 0;

        s->do_cmd = 0;

        do_cmd(s, s->cmdbuf);

    }

}

static void handle_ti(ESPState *s)

{

    uint32_t dmalen, minlen;



    if (s->dma && !s->dma_enabled) {

        s->dma_cb = handle_ti;

        return;

    }



    dmalen = s->rregs[ESP_TCLO];

    dmalen |= s->rregs[ESP_TCMID] << 8;

    dmalen |= s->rregs[ESP_TCHI] << 16;

    if (dmalen==0) {

      dmalen=0x10000;

    }

    s->dma_counter = dmalen;



    if (s->do_cmd)

        minlen = (dmalen < 32) ? dmalen : 32;

    else if (s->ti_size < 0)

        minlen = (dmalen < -s->ti_size) ? dmalen : -s->ti_size;

    else

        minlen = (dmalen < s->ti_size) ? dmalen : s->ti_size;

    trace_esp_handle_ti(minlen);

    if (s->dma) {

        s->dma_left = minlen;

        s->rregs[ESP_RSTAT] &= ~STAT_TC;

        esp_do_dma(s);

    }

    if (s->do_cmd) {

        trace_esp_handle_ti_cmd(s->cmdlen);

        s->ti_size = 0;

        s->cmdlen = 0;

        s->do_cmd = 0;

        do_cmd(s, s->cmdbuf);

    }

}

static void FUNC_0(ESPState *VAR_0)

{

    uint32_t dmalen, minlen;



    if (VAR_0->dma && !VAR_0->dma_enabled) {

        VAR_0->dma_cb = FUNC_0;

        return;

    }



    dmalen = VAR_0->rregs[ESP_TCLO];

    dmalen |= VAR_0->rregs[ESP_TCMID] << 8;

    dmalen |= VAR_0->rregs[ESP_TCHI] << 16;

    if (dmalen==0) {

      dmalen=0x10000;

    }

    VAR_0->dma_counter = dmalen;



    if (VAR_0->do_cmd)

        minlen = (dmalen < 32) ? dmalen : 32;

    else if (VAR_0->ti_size < 0)

        minlen = (dmalen < -VAR_0->ti_size) ? dmalen : -VAR_0->ti_size;

    else

        minlen = (dmalen < VAR_0->ti_size) ? dmalen : VAR_0->ti_size;

    trace_esp_handle_ti(minlen);

    if (VAR_0->dma) {

        VAR_0->dma_left = minlen;

        VAR_0->rregs[ESP_RSTAT] &= ~STAT_TC;

        esp_do_dma(VAR_0);

    }

    if (VAR_0->do_cmd) {

        trace_esp_handle_ti_cmd(VAR_0->cmdlen);

        VAR_0->ti_size = 0;

        VAR_0->cmdlen = 0;

        VAR_0->do_cmd = 0;

        do_cmd(VAR_0, VAR_0->cmdbuf);

    }

}

static void FUNC_0(ESPState *VAR_0)
{ uint32_t dmalen, minlen; if (VAR_0->dma && !VAR_0->dma_enabled) { VAR_0->dma_cb = FUNC_0; return; } dmalen = VAR_0->rregs[ESP_TCLO]; dmalen |= VAR_0->rregs[ESP_TCMID] << 8; dmalen |= VAR_0->rregs[ESP_TCHI] << 16; if (dmalen==0) { dmalen=0x10000; } VAR_0->dma_counter = dmalen; if (VAR_0->do_cmd)
minlen = (dmalen < 32) ? dmalen : 32; else if (VAR_0->ti_size < 0)
minlen = (dmalen < -VAR_0->ti_size) ? dmalen : -VAR_0->ti_size; else
minlen = (dmalen < VAR_0->ti_size) ? dmalen : VAR_0->ti_size; trace_esp_handle_ti(minlen); if (VAR_0->dma) { VAR_0->dma_left = minlen; VAR_0->rregs[ESP_RSTAT] &= ~STAT_TC; esp_do_dma(VAR_0); } if (VAR_0->do_cmd) { trace_esp_handle_ti_cmd(VAR_0->cmdlen); VAR_0->ti_size = 0; VAR_0->cmdlen = 0; VAR_0->do_cmd = 0; do_cmd(VAR_0, VAR_0->cmdbuf); } }