mac_dbdma: create DBDMAState instead of passing one array around
Signed-off-by: Juan Quintela <quintela@redhat.com>
This commit is contained in:
parent
9039d78e64
commit
c20df14b13
@ -165,6 +165,10 @@ typedef struct DBDMA_channel {
|
||||
int processing;
|
||||
} DBDMA_channel;
|
||||
|
||||
typedef struct {
|
||||
DBDMA_channel channels[DBDMA_CHANNELS];
|
||||
} DBDMAState;
|
||||
|
||||
#ifdef DEBUG_DBDMA
|
||||
static void dump_dbdma_cmd(dbdma_cmd *cmd)
|
||||
{
|
||||
@ -617,31 +621,34 @@ static void channel_run(DBDMA_channel *ch)
|
||||
}
|
||||
}
|
||||
|
||||
static void DBDMA_run (DBDMA_channel *ch)
|
||||
static void DBDMA_run(DBDMAState *s)
|
||||
{
|
||||
int channel;
|
||||
|
||||
for (channel = 0; channel < DBDMA_CHANNELS; channel++, ch++) {
|
||||
uint32_t status = ch->regs[DBDMA_STATUS];
|
||||
if (!ch->processing && (status & RUN) && (status & ACTIVE))
|
||||
channel_run(ch);
|
||||
for (channel = 0; channel < DBDMA_CHANNELS; channel++) {
|
||||
DBDMA_channel *ch = &s->channels[channel];
|
||||
uint32_t status = ch->regs[DBDMA_STATUS];
|
||||
if (!ch->processing && (status & RUN) && (status & ACTIVE)) {
|
||||
channel_run(ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void DBDMA_run_bh(void *opaque)
|
||||
{
|
||||
DBDMA_channel *ch = opaque;
|
||||
DBDMAState *s = opaque;
|
||||
|
||||
DBDMA_DPRINTF("DBDMA_run_bh\n");
|
||||
|
||||
DBDMA_run(ch);
|
||||
DBDMA_run(s);
|
||||
}
|
||||
|
||||
void DBDMA_register_channel(void *dbdma, int nchan, qemu_irq irq,
|
||||
DBDMA_rw rw, DBDMA_flush flush,
|
||||
void *opaque)
|
||||
{
|
||||
DBDMA_channel *ch = ( DBDMA_channel *)dbdma + nchan;
|
||||
DBDMAState *s = dbdma;
|
||||
DBDMA_channel *ch = &s->channels[nchan];
|
||||
|
||||
DBDMA_DPRINTF("DBDMA_register_channel 0x%x\n", nchan);
|
||||
|
||||
@ -700,7 +707,8 @@ static void dbdma_writel (void *opaque,
|
||||
target_phys_addr_t addr, uint32_t value)
|
||||
{
|
||||
int channel = addr >> DBDMA_CHANNEL_SHIFT;
|
||||
DBDMA_channel *ch = (DBDMA_channel *)opaque + channel;
|
||||
DBDMAState *s = opaque;
|
||||
DBDMA_channel *ch = &s->channels[channel];
|
||||
int reg = (addr - (channel << DBDMA_CHANNEL_SHIFT)) >> 2;
|
||||
|
||||
DBDMA_DPRINTF("writel 0x" TARGET_FMT_plx " <= 0x%08x\n", addr, value);
|
||||
@ -749,7 +757,8 @@ static uint32_t dbdma_readl (void *opaque, target_phys_addr_t addr)
|
||||
{
|
||||
uint32_t value;
|
||||
int channel = addr >> DBDMA_CHANNEL_SHIFT;
|
||||
DBDMA_channel *ch = (DBDMA_channel *)opaque + channel;
|
||||
DBDMAState *s = opaque;
|
||||
DBDMA_channel *ch = &s->channels[channel];
|
||||
int reg = (addr - (channel << DBDMA_CHANNEL_SHIFT)) >> 2;
|
||||
|
||||
value = ch->regs[reg];
|
||||
@ -803,17 +812,17 @@ static CPUReadMemoryFunc * const dbdma_read[] = {
|
||||
|
||||
static void dbdma_save(QEMUFile *f, void *opaque)
|
||||
{
|
||||
DBDMA_channel *s = opaque;
|
||||
DBDMAState *s = opaque;
|
||||
unsigned int i, j;
|
||||
|
||||
for (i = 0; i < DBDMA_CHANNELS; i++)
|
||||
for (j = 0; j < DBDMA_REGS; j++)
|
||||
qemu_put_be32s(f, &s[i].regs[j]);
|
||||
qemu_put_be32s(f, &s->channels[i].regs[j]);
|
||||
}
|
||||
|
||||
static int dbdma_load(QEMUFile *f, void *opaque, int version_id)
|
||||
{
|
||||
DBDMA_channel *s = opaque;
|
||||
DBDMAState *s = opaque;
|
||||
unsigned int i, j;
|
||||
|
||||
if (version_id != 2)
|
||||
@ -821,25 +830,25 @@ static int dbdma_load(QEMUFile *f, void *opaque, int version_id)
|
||||
|
||||
for (i = 0; i < DBDMA_CHANNELS; i++)
|
||||
for (j = 0; j < DBDMA_REGS; j++)
|
||||
qemu_get_be32s(f, &s[i].regs[j]);
|
||||
qemu_get_be32s(f, &s->channels[i].regs[j]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void dbdma_reset(void *opaque)
|
||||
{
|
||||
DBDMA_channel *s = opaque;
|
||||
DBDMAState *s = opaque;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < DBDMA_CHANNELS; i++)
|
||||
memset(s[i].regs, 0, DBDMA_SIZE);
|
||||
memset(s->channels[i].regs, 0, DBDMA_SIZE);
|
||||
}
|
||||
|
||||
void* DBDMA_init (int *dbdma_mem_index)
|
||||
{
|
||||
DBDMA_channel *s;
|
||||
DBDMAState *s;
|
||||
|
||||
s = qemu_mallocz(sizeof(DBDMA_channel) * DBDMA_CHANNELS);
|
||||
s = qemu_mallocz(sizeof(DBDMAState));
|
||||
|
||||
*dbdma_mem_index = cpu_register_io_memory(dbdma_read, dbdma_write, s,
|
||||
DEVICE_LITTLE_ENDIAN);
|
||||
|
Loading…
Reference in New Issue
Block a user