From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JVaSJ-0004Qg-8K for qemu-devel@nongnu.org; Sat, 01 Mar 2008 17:45:23 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JVaSH-0004QU-Qr for qemu-devel@nongnu.org; Sat, 01 Mar 2008 17:45:22 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JVaSH-0004QR-Kg for qemu-devel@nongnu.org; Sat, 01 Mar 2008 17:45:21 -0500 Received: from smtp3-g19.free.fr ([212.27.42.29]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JVaSH-0000dp-5h for qemu-devel@nongnu.org; Sat, 01 Mar 2008 17:45:21 -0500 Received: from smtp3-g19.free.fr (localhost.localdomain [127.0.0.1]) by smtp3-g19.free.fr (Postfix) with ESMTP id 1CBB617B54B for ; Sat, 1 Mar 2008 23:43:50 +0100 (CET) Received: from [127.0.0.1] (rob92-10-88-171-126-33.fbx.proxad.net [88.171.126.33]) by smtp3-g19.free.fr (Postfix) with ESMTP id DCE8617B52C for ; Sat, 1 Mar 2008 23:43:49 +0100 (CET) Message-ID: <47C9DC25.4030900@reactos.org> Date: Sat, 01 Mar 2008 23:43:49 +0100 From: =?ISO-8859-1?Q?Herv=E9_Poussineau?= MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------060306030002040409030907" Subject: [Qemu-devel] [PATCH] Let ESP SCSI adapter to be usable outside sun4m (v2) Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------060306030002040409030907 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Hi, At the moment, ESP SCSI adapter can only be used inside sun4m machines. Attached patch moves the declaration outside sun4m.h, so other machines=20 can also use it. Declaration has been added to a new file scsi.h. As Blue Swirl suggested, DMA access functions are sent to the init functi= on. Herv=E9 --------------060306030002040409030907 Content-Type: text/plain; name="esp_v2.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="esp_v2.patch" Index: Makefile.target =================================================================== RCS file: /sources/qemu/qemu/Makefile.target,v retrieving revision 1.246 diff -u -r1.246 Makefile.target --- Makefile.target 27 Feb 2008 17:53:27 -0000 1.246 +++ Makefile.target 1 Mar 2008 22:03:35 -0000 @@ -514,7 +514,7 @@ endif # SCSI layer -OBJS+= lsi53c895a.o +OBJS+= lsi53c895a.o esp.o # USB layer OBJS+= usb-ohci.o @@ -576,7 +576,7 @@ OBJS+= cirrus_vga.o parallel.o ptimer.o else OBJS+= sun4m.o tcx.o pcnet.o iommu.o m48t59.o slavio_intctl.o -OBJS+= slavio_timer.o slavio_serial.o slavio_misc.o fdc.o esp.o sparc32_dma.o +OBJS+= slavio_timer.o slavio_serial.o slavio_misc.o fdc.o sparc32_dma.o OBJS+= cs4231.o ptimer.o eccmemctl.o sbi.o sun4c_intctl.o endif endif Index: hw/esp.c =================================================================== RCS file: /sources/qemu/qemu/hw/esp.c,v retrieving revision 1.33 diff -u -r1.33 esp.c --- hw/esp.c 1 Jan 2008 17:06:38 -0000 1.33 +++ hw/esp.c 1 Mar 2008 22:23:03 -0000 @@ -24,9 +24,7 @@ #include "hw.h" #include "block.h" #include "scsi-disk.h" -#include "sun4m.h" -/* FIXME: Only needed for MAX_DISKS, which is probably wrong. */ -#include "sysemu.h" +#include "scsi.h" /* debug ESP card */ //#define DEBUG_ESP @@ -75,6 +73,9 @@ uint32_t dma_counter; uint8_t *async_buf; uint32_t async_len; + + espdma_memory_read_write dma_memory_read; + espdma_memory_read_write dma_memory_write; void *dma_opaque; }; @@ -152,7 +153,7 @@ target = s->wregs[ESP_WBUSID] & 7; DPRINTF("get_cmd: len %d target %d\n", dmalen, target); if (s->dma) { - espdma_memory_read(s->dma_opaque, buf, dmalen); + s->dma_memory_read(s->dma_opaque, buf, dmalen); } else { buf[0] = 0; memcpy(&buf[1], s->ti_buf, dmalen); @@ -236,7 +237,7 @@ s->ti_buf[0] = s->sense; s->ti_buf[1] = 0; if (s->dma) { - espdma_memory_write(s->dma_opaque, s->ti_buf, 2); + s->dma_memory_write(s->dma_opaque, s->ti_buf, 2); s->rregs[ESP_RSTAT] = STAT_IN | STAT_TC | STAT_ST; s->rregs[ESP_RINTR] = INTR_BS | INTR_FC; s->rregs[ESP_RSEQ] = SEQ_CD; @@ -269,7 +270,7 @@ len = s->dma_left; if (s->do_cmd) { DPRINTF("command len %d + %d\n", s->cmdlen, len); - espdma_memory_read(s->dma_opaque, &s->cmdbuf[s->cmdlen], len); + s->dma_memory_read(s->dma_opaque, &s->cmdbuf[s->cmdlen], len); s->ti_size = 0; s->cmdlen = 0; s->do_cmd = 0; @@ -284,9 +285,9 @@ len = s->async_len; } if (to_device) { - espdma_memory_read(s->dma_opaque, s->async_buf, len); + s->dma_memory_read(s->dma_opaque, s->async_buf, len); } else { - espdma_memory_write(s->dma_opaque, s->async_buf, len); + s->dma_memory_write(s->dma_opaque, s->async_buf, len); } s->dma_left -= len; s->async_buf += len; @@ -621,6 +622,8 @@ } void *esp_init(target_phys_addr_t espaddr, + espdma_memory_read_write dma_memory_read, + espdma_memory_read_write dma_memory_write, void *dma_opaque, qemu_irq irq, qemu_irq *reset) { ESPState *s; @@ -631,6 +634,8 @@ return NULL; s->irq = irq; + s->dma_memory_read = dma_memory_read; + s->dma_memory_write = dma_memory_write; s->dma_opaque = dma_opaque; esp_io_memory = cpu_register_io_memory(0, esp_mem_read, esp_mem_write, s); Index: hw/sun4m.c =================================================================== RCS file: /sources/qemu/qemu/hw/sun4m.c,v retrieving revision 1.85 diff -u -r1.85 sun4m.c --- hw/sun4m.c 29 Feb 2008 19:26:20 -0000 1.85 +++ hw/sun4m.c 1 Mar 2008 22:25:18 -0000 @@ -31,6 +31,7 @@ #include "net.h" #include "boards.h" #include "firmware_abi.h" +#include "scsi.h" //#define DEBUG_IRQ @@ -505,8 +506,9 @@ exit(1); } - main_esp = esp_init(hwdef->esp_base, espdma, *espdma_irq, - esp_reset); + main_esp = esp_init(hwdef->esp_base, + espdma_memory_read, espdma_memory_write, + espdma, *espdma_irq, esp_reset); for (i = 0; i < ESP_MAX_DEVS; i++) { index = drive_get_index(IF_SCSI, 0, i); @@ -653,8 +655,9 @@ exit(1); } - main_esp = esp_init(hwdef->esp_base, espdma, *espdma_irq, - esp_reset); + main_esp = esp_init(hwdef->esp_base, + espdma_memory_read, espdma_memory_write, + espdma, *espdma_irq, esp_reset); for (i = 0; i < ESP_MAX_DEVS; i++) { index = drive_get_index(IF_SCSI, 0, i); @@ -1158,8 +1161,9 @@ exit(1); } - main_esp = esp_init(hwdef->esp_base, espdma, *espdma_irq, - esp_reset); + main_esp = esp_init(hwdef->esp_base, + espdma_memory_read, espdma_memory_write, + espdma, *espdma_irq, esp_reset); for (i = 0; i < ESP_MAX_DEVS; i++) { index = drive_get_index(IF_SCSI, 0, i); Index: hw/sun4m.h =================================================================== RCS file: /sources/qemu/qemu/hw/sun4m.h,v retrieving revision 1.10 diff -u -r1.10 sun4m.h --- hw/sun4m.h 27 Jan 2008 09:49:28 -0000 1.10 +++ hw/sun4m.h 1 Mar 2008 22:01:28 -0000 @@ -59,12 +59,6 @@ CPUState *env); void slavio_set_power_fail(void *opaque, int power_failing); -/* esp.c */ -#define ESP_MAX_DEVS 7 -void esp_scsi_attach(void *opaque, BlockDriverState *bd, int id); -void *esp_init(target_phys_addr_t espaddr, - void *dma_opaque, qemu_irq irq, qemu_irq *reset); - /* cs4231.c */ void cs_init(target_phys_addr_t base, int irq, void *intctl); Index: hw/scsi.h =================================================================== --- hw/scsi.h 1 Jan 1970 00:00:00 -0000 +++ hw/scsi.h 1 Mar 2008 22:01:28 -0000 @@ -0,0 +1,8 @@ +/* esp.c */ +#define ESP_MAX_DEVS 7 +typedef void (*espdma_memory_read_write)(void *opaque, uint8_t *buf, int len); +void esp_scsi_attach(void *opaque, BlockDriverState *bd, int id); +void *esp_init(target_phys_addr_t espaddr, + espdma_memory_read_write dma_memory_read, + espdma_memory_read_write dma_memory_write, + void *dma_opaque, qemu_irq irq, qemu_irq *reset); --------------060306030002040409030907--