From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.34) id 1BNXJT-0004Bj-Gd for qemu-devel@nongnu.org; Tue, 11 May 2004 09:28:51 -0400 Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.34) id 1BNXIq-0003te-Jc for qemu-devel@nongnu.org; Tue, 11 May 2004 09:28:45 -0400 Received: from [195.238.2.69] (helo=outmx014.isp.belgacom.be) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.34) id 1BNXFa-0002n6-MV for qemu-devel@nongnu.org; Tue, 11 May 2004 09:24:51 -0400 Received: from easynet.be (132.195-201-80.adsl.skynet.be [80.201.195.132]) by outmx014.isp.belgacom.be (8.12.11/8.12.11/Skynet-OUT-2.22) with ESMTP id i4BDOj1A008313 for ; Tue, 11 May 2004 15:24:45 +0200 (envelope-from ) Message-ID: <40A0E16D.6080400@easynet.be> Date: Tue, 11 May 2004 16:21:33 +0200 From: Mark Jonckheere MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Better floppy disk support 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 I propose some patches for better floppy disk support: 1. To make "tomsrtbt-2.0.103.ElTorito.288.img" bootable. The first one is in fdc.c. It removes the test in fd_init(), since it always forces the disk type to 1.44 MB, It is better to give the first call to fd_revalidate() a chance to decide if it is a 1.44 or 2.88 drive. 2. To make my standalone chntpw-disk bootable (google for bd000607.zip). Booting from bd000607.img gives a segmentation error. It seems that the bootcode on this floppy (syslinux-ldlinux) does a word-length (16-bit) INW at address 0x80 which was translated by function default_ioport_readw() in a call to default_ioport_readb(NULL, 0x80) and read_page(NULL, 0x81). The second function (in dma.c) needs a (dma_cont *) pointer as its first parameter and segfaults when it tries to dereference the NULL-pointer. To avoid this problem with word-length io-reads to two adjacent io-ports from different or undefined devices it is best to translate it into two readb calls each with its own opaque value. The function default_ioport_readw() is not the most logical place for doing this, it is better to do this upstream in the function cpu_inw(). I modified cpu_inw() and cpu_outw(), but the same problem could also happen with cpu_inl() and cpu_outl(). 3. To accept "--nics 0" as a legal argument. Sometimes it can be usefull to install software without ethernet support. I made a minor modification to accept 0 as a legal value for the argument --nics. Since the default value remains 1, nothing changes for current usage. greetings, Mark. diffs from cvs sources downloaded at 2004-05-10 11:41 (UTC) start here ---8<-------------------------------------------------------->8--- diff -wurb qemu/hw/fdc.c qemu-patched/hw/fdc.c --- qemu/hw/fdc.c Sat May 8 23:01:23 2004 +++ qemu-patched/hw/fdc.c Mon May 10 18:18:35 2004 @@ -94,9 +94,9 @@ { /* Drive */ drv->bs = bs; - if (bs) - drv->drive = FDRIVE_DRV_144; - else +// if (bs) +// drv->drive = FDRIVE_DRV_144; +// else drv->drive = FDRIVE_DRV_NONE; drv->drflags = 0; drv->perpendicular = 0; diff -wurb qemu/vl.c qemu-patched/vl.c --- qemu/vl.c Thu Apr 29 00:26:05 2004 +++ qemu-patched/vl.c Tue May 11 14:49:07 2004 @@ -133,19 +133,19 @@ #endif } -/* default is to make two byte accesses */ uint32_t default_ioport_readw(void *opaque, uint32_t address) { - uint32_t data; - data = ioport_read_table[0][address & (MAX_IOPORTS - 1)](opaque, address); - data |= ioport_read_table[0][(address + 1) & (MAX_IOPORTS - 1)](opaque, address + 1) << 8; - return data; +#ifdef DEBUG_UNUSED_IOPORT + fprintf(stderr, "inw: port=0x%04x\n", address); +#endif + return 0xffff; } void default_ioport_writew(void *opaque, uint32_t address, uint32_t data) { - ioport_write_table[0][address & (MAX_IOPORTS - 1)](opaque, address, data & 0xff); - ioport_write_table[0][(address + 1) & (MAX_IOPORTS - 1)](opaque, address + 1, (data >> 8) & 0xff); +#ifdef DEBUG_UNUSED_IOPORT + fprintf(stderr, "outw: port=0x%04x data=0x%04x\n", address, data); +#endif } uint32_t default_ioport_readl(void *opaque, uint32_t address) @@ -159,7 +159,7 @@ void default_ioport_writel(void *opaque, uint32_t address, uint32_t data) { #ifdef DEBUG_UNUSED_IOPORT - fprintf(stderr, "outl: port=0x%04x data=0x%02x\n", address, data); + fprintf(stderr, "outl: port=0x%04x data=0x%08x\n", address, data); #endif } @@ -279,8 +279,18 @@ void cpu_outw(CPUState *env, int addr, int val) { + IOPortWriteFunc *writefunc; + addr &= (MAX_IOPORTS - 1); - ioport_write_table[1][addr](ioport_opaque[addr], addr, val); + writefunc = ioport_write_table[1][addr]; + if ( writefunc != default_ioport_writew && + (ioport_write_table[0][addr] == ioport_write_table[0][addr + 1])) + writefunc(ioport_opaque[addr], addr, val); + else { + ioport_write_table[0][addr](ioport_opaque[addr], addr, val & 0xff); + ioport_write_table[0][addr + 1](ioport_opaque[addr + 1], + addr + 1, (val >> 8 ) & 0xff); + } } void cpu_outl(CPUState *env, int addr, int val) @@ -297,8 +307,16 @@ int cpu_inw(CPUState *env, int addr) { + IOPortReadFunc *readfunc; + addr &= (MAX_IOPORTS - 1); - return ioport_read_table[1][addr](ioport_opaque[addr], addr); + readfunc = ioport_read_table[1][addr]; + if ( readfunc != default_ioport_readw && + (ioport_read_table[0][addr] == ioport_read_table[0][addr + 1])) + return readfunc(ioport_opaque[addr], addr); + else + return ioport_read_table[0][addr](ioport_opaque[addr], addr) | + (ioport_read_table[0][addr+1](ioport_opaque[addr+1], addr+1) << 8); } int cpu_inl(CPUState *env, int addr) @@ -2008,7 +2026,7 @@ break; case 16: nb_nics = atoi(optarg); - if (nb_nics < 1 || nb_nics > MAX_NICS) { + if (nb_nics < 0 || nb_nics > MAX_NICS) { fprintf(stderr, "qemu: invalid number of network interfaces\n"); exit(1); } ---8<-------------------------------------------------------->8---