static void load_word(DBDMA_channel *ch, int key, uint32_t addr,

                     uint16_t len)

{

    dbdma_cmd *current = &ch->current;

    uint32_t val;



    DBDMA_DPRINTF("load_word\n");



    /* only implements KEY_SYSTEM */



    if (key != KEY_SYSTEM) {

        printf("DBDMA: LOAD_WORD, unimplemented key %x\n", key);

        kill_channel(ch);

        return;

    }



    cpu_physical_memory_read(addr, (uint8_t*)&val, len);



    if (len == 2)

        val = (val << 16) | (current->cmd_dep & 0x0000ffff);

    else if (len == 1)

        val = (val << 24) | (current->cmd_dep & 0x00ffffff);



    current->cmd_dep = val;



    if (conditional_wait(ch))

        goto wait;



    current->xfer_status = cpu_to_le16(be32_to_cpu(ch->regs[DBDMA_STATUS]));

    dbdma_cmdptr_save(ch);

    ch->regs[DBDMA_STATUS] &= cpu_to_be32(~FLUSH);



    conditional_interrupt(ch);

    next(ch);



wait:

    qemu_bh_schedule(dbdma_bh);

}

static void load_word(DBDMA_channel *ch, int key, uint32_t addr,

                     uint16_t len)

{

    dbdma_cmd *current = &ch->current;

    uint32_t val;



    DBDMA_DPRINTF("load_word\n");



    



    if (key != KEY_SYSTEM) {

        printf("DBDMA: LOAD_WORD, unimplemented key %x\n", key);

        kill_channel(ch);

        return;

    }



    cpu_physical_memory_read(addr, (uint8_t*)&val, len);



    if (len == 2)

        val = (val << 16) | (current->cmd_dep & 0x0000ffff);

    else if (len == 1)

        val = (val << 24) | (current->cmd_dep & 0x00ffffff);



    current->cmd_dep = val;



    if (conditional_wait(ch))

        goto wait;



    current->xfer_status = cpu_to_le16(be32_to_cpu(ch->regs[DBDMA_STATUS]));

    dbdma_cmdptr_save(ch);

    ch->regs[DBDMA_STATUS] &= cpu_to_be32(~FLUSH);



    conditional_interrupt(ch);

    next(ch);



wait:

    qemu_bh_schedule(dbdma_bh);

}

static void FUNC_0(DBDMA_channel *VAR_0, int VAR_1, uint32_t VAR_2,

                     uint16_t VAR_3)

{

    dbdma_cmd *current = &VAR_0->current;

    uint32_t val;



    DBDMA_DPRINTF("FUNC_0\n");



    



    if (VAR_1 != KEY_SYSTEM) {

        printf("DBDMA: LOAD_WORD, unimplemented VAR_1 %x\n", VAR_1);

        kill_channel(VAR_0);

        return;

    }



    cpu_physical_memory_read(VAR_2, (uint8_t*)&val, VAR_3);



    if (VAR_3 == 2)

        val = (val << 16) | (current->cmd_dep & 0x0000ffff);

    else if (VAR_3 == 1)

        val = (val << 24) | (current->cmd_dep & 0x00ffffff);



    current->cmd_dep = val;



    if (conditional_wait(VAR_0))

        goto wait;



    current->xfer_status = cpu_to_le16(be32_to_cpu(VAR_0->regs[DBDMA_STATUS]));

    dbdma_cmdptr_save(VAR_0);

    VAR_0->regs[DBDMA_STATUS] &= cpu_to_be32(~FLUSH);



    conditional_interrupt(VAR_0);

    next(VAR_0);



wait:

    qemu_bh_schedule(dbdma_bh);

}

static void FUNC_0(DBDMA_channel *VAR_0, int VAR_1, uint32_t VAR_2,
uint16_t VAR_3)
{ dbdma_cmd *current = &VAR_0->current; uint32_t val; DBDMA_DPRINTF("FUNC_0\n"); if (VAR_1 != KEY_SYSTEM) { printf("DBDMA: LOAD_WORD, unimplemented VAR_1 %x\n", VAR_1); kill_channel(VAR_0); return; } cpu_physical_memory_read(VAR_2, (uint8_t*)&val, VAR_3); if (VAR_3 == 2)
val = (val << 16) | (current->cmd_dep & 0x0000ffff); else if (VAR_3 == 1)
val = (val << 24) | (current->cmd_dep & 0x00ffffff); current->cmd_dep = val; if (conditional_wait(VAR_0))
goto wait; current->xfer_status = cpu_to_le16(be32_to_cpu(VAR_0->regs[DBDMA_STATUS])); dbdma_cmdptr_save(VAR_0); VAR_0->regs[DBDMA_STATUS] &= cpu_to_be32(~FLUSH); conditional_interrupt(VAR_0); next(VAR_0); wait:
qemu_bh_schedule(dbdma_bh); }