MIPS: DMA support for RC4030 chipset
PATCH 1/1 MIPS: DMA support for RC4030 chipset
Hi,
Attached patch implements DMA support to RC4030 chipset and simplifies jazz IO part (at 0xf0000000), where registers contain 16 bit values. The patch also wires DMA for the SCSI adapter in the Jazz emulation (Mips Magnum 4000 and Acer Pica 61).
Please apply
Hervé
dex: hw/mips.h
===================================================================
mips.h +3 -1
@@ -27,6 +27,8 @@extern void cpu_mips_clock_init (CPUState *);/* rc4030.c */ -qemu_irq *rc4030_init (qemu_irq timer,qemu_irq jazz_bus); +typedef void (*dma_function )(void *opaque,int channel,uint8_t *buf,int len,int is_write); +qemu_irq *rc4030_init (qemu_irq timer,qemu_irq jazz_bus,void **dma_opaque, +dma_function *dma_func);#endif
mips_jazz.c +27 -6
@@ -1,7 +1,7 @@/* * QEMU MIPS Jazz support * -* Copyright (c) 2007-2008 Hervé Poussineau +* Copyright (c) 2007-2008 Herve Poussineau * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal
@@ -45,6 +45,13 @@ JAZZ_PICA61, }; +typedef struct jazzState +{ +/* DMA */ +void *dma_opaque; +dma_function dma_func; +}jazzState ; +static void main_cpu_reset (void *opaque) {CPUState *env = opaque;
@@ -102,14 +109,17 @@ }#endif +#define JAZZ_SCSI_DMA 0void espdma_memory_read (void *opaque,uint8_t *buf,int len) { -printf ("espdma_memory_read(buf %p, len %d) not implemented\n" , buf, len); +jazzState *s = opaque; + (*s->dma_func)(s->dma_opaque,JAZZ_SCSI_DMA , buf, len,0 ); }void espdma_memory_write (void *opaque,uint8_t *buf,int len) { -printf ("espdma_memory_write(buf %p, len %d) not implemented\n" , buf, len); +jazzState *s = opaque; + (*s->dma_func)(s->dma_opaque,JAZZ_SCSI_DMA , buf, len,1 ); }#define MAGNUM_BIOS_SIZE_MAX 0x7e000
@@ -131,7 +141,13 @@PITState *pit;BlockDriverState *fds[MAX_FD ];qemu_irq esp_reset; +jazzState *s; +/* allocate state */ + s =qemu_mallocz (sizeof (jazzState)); +if (!s) +return ; +/* init CPUs */ if (cpu_model ==NULL ) {#ifdef TARGET_MIPS64
@@ -153,7 +169,9 @@/* load the BIOS image. */ bios_offset = ram_size + vga_ram_size; -snprintf (buf,sizeof (buf),"%s/%s" , bios_dir,BIOS_FILENAME ); +if (bios_name ==NULL ) + bios_name =BIOS_FILENAME ; +snprintf (buf,sizeof (buf),"%s/%s" , bios_dir, bios_name); bios_size =load_image (buf, phys_ram_base + bios_offset);if (bios_size <0 || bios_size >MAGNUM_BIOS_SIZE ) { fprintf(stderr, "qemu: Could not load MIPS bios '%s'\n",
@@ -171,7 +189,8 @@cpu_mips_clock_init (env);/* Chipset */ - rc4030 =rc4030_init (env->irq[6 ], env->irq[3 ]); + rc4030 =rc4030_init (env->irq[6 ], env->irq[3 ], + &s->dma_opaque, &s->dma_func);/* ISA devices */ i8259 =i8259_init (env->irq[4 ]);
@@ -200,7 +219,7 @@/* SCSI adapter */ scsi_hba =esp_init (0x80002000 ,0 , - espdma_memory_read, espdma_memory_write,NULL , + espdma_memory_read, espdma_memory_write, s, rc4030[5 ], &esp_reset);for (n =0 ; n <ESP_MAX_DEVS ; n++) { hd =drive_get_index (IF_SCSI ,0 , n);
@@ -278,6 +297,7 @@ .init = mips_magnum_init, .ram_require = MAGNUM_BIOS_SIZE + VGA_RAM_SIZE, .nodisk_ok = 1, + .use_scsi = 1, .max_cpus = 1, };
@@ -287,5 +307,6 @@ .init = mips_pica61_init, .ram_require = MAGNUM_BIOS_SIZE + VGA_RAM_SIZE, .nodisk_ok = 1, + .use_scsi = 1, .max_cpus = 1, };
rc4030.c +168 -80
455 lines not on this page · raw message
Quoted 6 lines · Hervé Poussineau
Hi,
Attached patch implements DMA support to RC4030 chipset and simplifies jazz
IO part (at0xf0000000), where registers contain 16 bit values.
The patch also wires DMA for the SCSI adapter in the Jazz emulation (Mips
Magnum 4000 and Acer Pica 61).
I'd move espdma_memory_read & write to rc4030.c, that way the opaque passed to esp_init could be directly rc4030State type.
Allocating a new dma_table every time the table changes seems wasteful, you could read the entry from memory as needed.