提交 68238a9e 编写于 作者: A aurel32

Clean up rc4030 init function

At the moment, rc4030 init function is returning some function pointers.
Mark them non-static and define them in header file instead.
Export also a function to read/write DMA memory, it will be required by
the netcard.
Signed-off-by: NHervé Poussineau <hpoussin@reactos.org>
Signed-off-by: NAurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7072 c046a42c-6fe2-441c-8c8c-71466251a162
上级 c2c5104b
...@@ -28,9 +28,11 @@ extern void cpu_mips_clock_init(CPUState *); ...@@ -28,9 +28,11 @@ extern void cpu_mips_clock_init(CPUState *);
/* rc4030.c */ /* rc4030.c */
typedef struct rc4030DMAState *rc4030_dma; typedef struct rc4030DMAState *rc4030_dma;
typedef void (*rc4030_dma_function)(void *dma, uint8_t *buf, int len); void rc4030_dma_memory_rw(void *opaque, target_phys_addr_t addr, uint8_t *buf, int len, int is_write);
qemu_irq *rc4030_init(qemu_irq timer, qemu_irq jazz_bus, void rc4030_dma_read(void *dma, uint8_t *buf, int len);
rc4030_dma **dmas, void rc4030_dma_write(void *dma, uint8_t *buf, int len);
rc4030_dma_function *dma_read, rc4030_dma_function *dma_write);
void *rc4030_init(qemu_irq timer, qemu_irq jazz_bus,
qemu_irq **irqs, rc4030_dma **dmas);
#endif #endif
...@@ -133,7 +133,7 @@ void mips_jazz_init (ram_addr_t ram_size, int vga_ram_size, ...@@ -133,7 +133,7 @@ void mips_jazz_init (ram_addr_t ram_size, int vga_ram_size,
CPUState *env; CPUState *env;
qemu_irq *rc4030, *i8259; qemu_irq *rc4030, *i8259;
rc4030_dma *dmas; rc4030_dma *dmas;
rc4030_dma_function dma_read, dma_write; void* rc4030_opaque;
void *scsi_hba; void *scsi_hba;
int hd; int hd;
int s_rtc, s_dma_dummy; int s_rtc, s_dma_dummy;
...@@ -185,8 +185,7 @@ void mips_jazz_init (ram_addr_t ram_size, int vga_ram_size, ...@@ -185,8 +185,7 @@ void mips_jazz_init (ram_addr_t ram_size, int vga_ram_size,
cpu_mips_clock_init(env); cpu_mips_clock_init(env);
/* Chipset */ /* Chipset */
rc4030 = rc4030_init(env->irq[6], env->irq[3], rc4030_opaque = rc4030_init(env->irq[6], env->irq[3], &rc4030, &dmas);
&dmas, &dma_read, &dma_write);
s_dma_dummy = cpu_register_io_memory(0, dma_dummy_read, dma_dummy_write, NULL); s_dma_dummy = cpu_register_io_memory(0, dma_dummy_read, dma_dummy_write, NULL);
cpu_register_physical_memory(0x8000d000, 0x00001000, s_dma_dummy); cpu_register_physical_memory(0x8000d000, 0x00001000, s_dma_dummy);
...@@ -217,7 +216,7 @@ void mips_jazz_init (ram_addr_t ram_size, int vga_ram_size, ...@@ -217,7 +216,7 @@ void mips_jazz_init (ram_addr_t ram_size, int vga_ram_size,
/* SCSI adapter */ /* SCSI adapter */
scsi_hba = esp_init(0x80002000, 0, scsi_hba = esp_init(0x80002000, 0,
dma_read, dma_write, dmas[0], rc4030_dma_read, rc4030_dma_write, dmas[0],
rc4030[5], &esp_reset); rc4030[5], &esp_reset);
for (n = 0; n < ESP_MAX_DEVS; n++) { for (n = 0; n < ESP_MAX_DEVS; n++) {
hd = drive_get_index(IF_SCSI, 0, n); hd = drive_get_index(IF_SCSI, 0, n);
......
...@@ -675,7 +675,7 @@ static void rc4030_save(QEMUFile *f, void *opaque) ...@@ -675,7 +675,7 @@ static void rc4030_save(QEMUFile *f, void *opaque)
qemu_put_be32(f, s->itr); qemu_put_be32(f, s->itr);
} }
static void rc4030_dma_memory_rw(void *opaque, target_phys_addr_t addr, uint8_t *buf, int len, int is_write) void rc4030_dma_memory_rw(void *opaque, target_phys_addr_t addr, uint8_t *buf, int len, int is_write)
{ {
rc4030State *s = opaque; rc4030State *s = opaque;
target_phys_addr_t entry_addr; target_phys_addr_t entry_addr;
...@@ -766,13 +766,13 @@ struct rc4030DMAState { ...@@ -766,13 +766,13 @@ struct rc4030DMAState {
int n; int n;
}; };
static void rc4030_dma_read(void *dma, uint8_t *buf, int len) void rc4030_dma_read(void *dma, uint8_t *buf, int len)
{ {
rc4030_dma s = dma; rc4030_dma s = dma;
rc4030_do_dma(s->opaque, s->n, buf, len, 0); rc4030_do_dma(s->opaque, s->n, buf, len, 0);
} }
static void rc4030_dma_write(void *dma, uint8_t *buf, int len) void rc4030_dma_write(void *dma, uint8_t *buf, int len)
{ {
rc4030_dma s = dma; rc4030_dma s = dma;
rc4030_do_dma(s->opaque, s->n, buf, len, 1); rc4030_do_dma(s->opaque, s->n, buf, len, 1);
...@@ -795,18 +795,16 @@ static rc4030_dma *rc4030_allocate_dmas(void *opaque, int n) ...@@ -795,18 +795,16 @@ static rc4030_dma *rc4030_allocate_dmas(void *opaque, int n)
return s; return s;
} }
qemu_irq *rc4030_init(qemu_irq timer, qemu_irq jazz_bus, void *rc4030_init(qemu_irq timer, qemu_irq jazz_bus,
rc4030_dma **dmas, qemu_irq **irqs, rc4030_dma **dmas)
rc4030_dma_function *dma_read, rc4030_dma_function *dma_write)
{ {
rc4030State *s; rc4030State *s;
int s_chipset, s_jazzio; int s_chipset, s_jazzio;
s = qemu_mallocz(sizeof(rc4030State)); s = qemu_mallocz(sizeof(rc4030State));
*irqs = qemu_allocate_irqs(rc4030_irq_jazz_request, s, 16);
*dmas = rc4030_allocate_dmas(s, 4); *dmas = rc4030_allocate_dmas(s, 4);
*dma_read = rc4030_dma_read;
*dma_write = rc4030_dma_write;
s->periodic_timer = qemu_new_timer(vm_clock, rc4030_periodic_timer, s); s->periodic_timer = qemu_new_timer(vm_clock, rc4030_periodic_timer, s);
s->timer_irq = timer; s->timer_irq = timer;
...@@ -821,5 +819,5 @@ qemu_irq *rc4030_init(qemu_irq timer, qemu_irq jazz_bus, ...@@ -821,5 +819,5 @@ qemu_irq *rc4030_init(qemu_irq timer, qemu_irq jazz_bus,
s_jazzio = cpu_register_io_memory(0, jazzio_read, jazzio_write, s); s_jazzio = cpu_register_io_memory(0, jazzio_read, jazzio_write, s);
cpu_register_physical_memory(0xf0000000, 0x00001000, s_jazzio); cpu_register_physical_memory(0xf0000000, 0x00001000, s_jazzio);
return qemu_allocate_irqs(rc4030_irq_jazz_request, s, 16); return s;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册