Skip to contentSkip to conversation

rc4030 chipset: enhancements

PATCH New Hervé Poussineau 1 participant 1 message Mar 15, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rc4030 chipset: enhancements

Hi,

rc4030 chipset contains the DMA controller. Some devices (like the Jazz netcard[1]) need to access the DMA memory without using a DMA channel. The chosen prototype "void (*memory_rw)(void *opaque, target_phys_addr_t addr, uint8_t *buf, int len, int is_write);" is quite similar to cpu_physical_memory_rw(). Document also some registers and remove one hack.

I also put all returned functions/pointers by the rc4030 init function to a structure to not add two new output parameters to the init function.

Changes have been tested on Linux, NetBSD, and Windows NT/MIPS.

Hervé

[1] patch on the way

mips.h +15 -4
Index: hw/mips.h
===================================================================
@@ -29,9 +29,20 @@
 
 /* rc4030.c */
 typedef struct rc4030DMAState *rc4030_dma;
-typedef void (*rc4030_dma_function)(void *dma, uint8_t *buf, int len);
-qemu_irq *rc4030_init(qemu_irq timer, qemu_irq jazz_bus,
-                      rc4030_dma **dmas,
-                      rc4030_dma_function *dma_read, rc4030_dma_function *dma_write);
+struct rc4030_pointers
+{
+    /* DMA memory access */
+    void (*memory_rw)(void *opaque, target_phys_addr_t addr, uint8_t *buf, int len, int is_write);
+    void* mem_opaque;
 
+    /* DMA channels */
+    rc4030_dma *dmas;
+    void (*dma_read)(void *dma, uint8_t *buf, int len);
+    void (*dma_write)(void *dma, uint8_t *buf, int len);
+
+    /* IRQ */
+    qemu_irq *irqs;
+};
+void rc4030_init(qemu_irq timer, qemu_irq jazz_bus, struct rc4030_pointers* pointers);
+
 #endif
mips_jazz.c +11 -13
Index: hw/mips_jazz.c
===================================================================
@@ -132,9 +132,8 @@
     unsigned long bios_offset;
     int bios_size, n;
     CPUState *env;
-    qemu_irq *rc4030, *i8259;
-    rc4030_dma *dmas;
-    rc4030_dma_function dma_read, dma_write;
+    qemu_irq *i8259;
+    struct rc4030_pointers rc4030;
     void *scsi_hba;
     int hd;
     int s_rtc, s_dma_dummy;
@@ -183,8 +182,7 @@
     cpu_mips_clock_init(env);
 
     /* Chipset */
-    rc4030 = rc4030_init(env->irq[6], env->irq[3],
-                         &dmas, &dma_read, &dma_write);
+    rc4030_init(env->irq[6], env->irq[3], &rc4030);
     s_dma_dummy = cpu_register_io_memory(0, dma_dummy_read, dma_dummy_write, NULL);
     cpu_register_physical_memory(0x8000d000, 0x00001000, s_dma_dummy);
 
@@ -202,7 +200,7 @@
     switch (jazz_model) {
     case JAZZ_MAGNUM:
         g364fb_mm_init(phys_ram_base + ram_size, ram_size, vga_ram_size,
-                        0x40000000, 0x60000000, 0, rc4030[3]);
+                        0x40000000, 0x60000000, 0, rc4030.irqs[3]);
         break;
     case JAZZ_PICA61:
         isa_vga_mm_init(phys_ram_base + ram_size, ram_size, vga_ram_size,
@@ -217,8 +215,8 @@
 
     /* SCSI adapter */
     scsi_hba = esp_init(0x80002000, 0,
-                        dma_read, dma_write, dmas[0],
-                        rc4030[5], &esp_reset);
+                        rc4030.dma_read, rc4030.dma_write, rc4030.dmas[0],
+                        rc4030.irqs[5], &esp_reset);
     for (n = 0; n < ESP_MAX_DEVS; n++) {
         hd = drive_get_index(IF_SCSI, 0, n);
         if (hd != -1) {
@@ -238,7 +236,7 @@
         else
             fds[n] = NULL;
     }
-    fdctrl_init(rc4030[1], 0, 1, 0x80003000, fds);
+    fdctrl_init(rc4030.irqs[1], 0, 1, 0x80003000, fds);
 
     /* Real time clock */
     rtc_init(0x70, i8259[8], 1980);
@@ -246,17 +244,17 @@
     cpu_register_physical_memory(0x80004000, 0x00001000, s_rtc);
 
     /* Keyboard (i8042) */
-    i8042_mm_init(rc4030[6], rc4030[7], 0x80005000, 0x1000, 0x1);
+    i8042_mm_init(rc4030.irqs[6], rc4030.irqs[7], 0x80005000, 0x1000, 0x1);
 
     /* Serial ports */
     if (serial_hds[0])
-        serial_mm_init(0x80006000, 0, rc4030[8], 8000000/16, serial_hds[0], 1);
+        serial_mm_init(0x80006000, 0, rc4030.irqs[8], 8000000/16, serial_hds[0], 1);
     if (serial_hds[1])
-        serial_mm_init(0x80007000, 0, rc4030[9], 8000000/16, serial_hds[1], 1);
+        serial_mm_init(0x80007000, 0, rc4030.irqs[9], 8000000/16, serial_hds[1], 1);
 
     /* Parallel port */
     if (parallel_hds[0])
-        parallel_mm_init(0x80008000, 0, rc4030[0], parallel_hds[0]);
+        parallel_mm_init(0x80008000, 0, rc4030.irqs[0], parallel_hds[0]);
 
     /* Sound card */
     /* FIXME: missing Jazz sound at 0x8000c000, rc4030[2] */
rc4030.c +77 -58

317 lines not on this page · raw message