[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 12/13] mac_dbdma: create DBDMAState instead of passi
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PATCH 12/13] mac_dbdma: create DBDMAState instead of passing one array around |
Date: |
Thu, 10 Mar 2011 12:54:29 +0100 |
Signed-off-by: Juan Quintela <address@hidden>
---
hw/mac_dbdma.c | 45 +++++++++++++++++++++++++++------------------
1 files changed, 27 insertions(+), 18 deletions(-)
diff --git a/hw/mac_dbdma.c b/hw/mac_dbdma.c
index 5680fa9..c108aee 100644
--- a/hw/mac_dbdma.c
+++ b/hw/mac_dbdma.c
@@ -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);
--
1.7.4
- [Qemu-devel] [PATCH 02/13] pxa2xx_lcd: up field is used as a bool and migrated as an uint8_t, (continued)
- [Qemu-devel] [PATCH 02/13] pxa2xx_lcd: up field is used as a bool and migrated as an uint8_t, Juan Quintela, 2011/03/10
- [Qemu-devel] [PATCH 03/13] vmstate: port pxa2xx_lcd, Juan Quintela, 2011/03/10
- [Qemu-devel] [PATCH 05/13] vmstate: port max111x, Juan Quintela, 2011/03/10
- [Qemu-devel] [PATCH 04/13] max111x: input field is only used as uint8_t, Juan Quintela, 2011/03/10
- [Qemu-devel] [PATCH 07/13] vmstate: port nand, Juan Quintela, 2011/03/10
- [Qemu-devel] [PATCH 09/13] vmstate: port mac_nvram, Juan Quintela, 2011/03/10
- [Qemu-devel] [PATCH 10/13] piix4: create PIIX4State, Juan Quintela, 2011/03/10
- [Qemu-devel] [PATCH 06/13] nand: pin values are uint8_t, Juan Quintela, 2011/03/10
- [Qemu-devel] [PATCH 08/13] mac_nvram: size is a size, no need to be a target dependent type, Juan Quintela, 2011/03/10
- [Qemu-devel] [PATCH 13/13] vmstate: port mac_dbdma, Juan Quintela, 2011/03/10
- [Qemu-devel] [PATCH 12/13] mac_dbdma: create DBDMAState instead of passing one array around,
Juan Quintela <=
- [Qemu-devel] [PATCH 11/13] vmstate: port piix4, Juan Quintela, 2011/03/10