From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1ChfFr-0007Tj-QC for qemu-devel@nongnu.org; Thu, 23 Dec 2004 21:32:35 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1ChfFr-0007TX-9w for qemu-devel@nongnu.org; Thu, 23 Dec 2004 21:32:35 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1ChfFr-0007TU-74 for qemu-devel@nongnu.org; Thu, 23 Dec 2004 21:32:35 -0500 Received: from [195.238.3.70] (helo=outmx012.isp.belgacom.be) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Chf5C-0002yM-Io for qemu-devel@nongnu.org; Thu, 23 Dec 2004 21:21:34 -0500 Received: from outmx012.isp.belgacom.be (localhost [127.0.0.1]) by outmx012.isp.belgacom.be (8.12.11/8.12.11/Skynet-OUT-2.22) with ESMTP id iBO2LTje009396 for ; Fri, 24 Dec 2004 03:21:30 +0100 (envelope-from ) Received: from easynet.be (9.67-136-217.adsl.skynet.be [217.136.67.9]) by outmx012.isp.belgacom.be (8.12.11/8.12.11/Skynet-OUT-2.22) with ESMTP id iBO2LL2K009342 for ; Fri, 24 Dec 2004 03:21:22 +0100 (envelope-from ) Message-ID: <41CB7F4F.8010007@easynet.be> Date: Fri, 24 Dec 2004 03:30:39 +0100 From: Mark Jonckheere MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH] ne2000: Reset TXP bit after sending packet. 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 Hi, I had some problems to make the Crynwr packetdriver NE2000.COM talk to the host After recompiling hw/ne2000.c with "#define DEBUG_NE2000" uncommented I got the following trace: +++++++++++++++ ... NE2000: write addr=0x0 val=0x26 NE2000: Set IRQ line 9 to 1 (42 3f) NE2000: write addr=0xf val=0x00 NE2000: Set IRQ line 9 to 0 (42 00) NE2000: read addr=0x7 val=42 NE2000: read addr=0x4 val=01 NE2000: write addr=0x7 val=0x0a NE2000: Set IRQ line 9 to 0 (40 00) NE2000: write addr=0xf val=0x00 NE2000: Set IRQ line 9 to 0 (40 00) NE2000: read addr=0x7 val=40 NE2000: write addr=0xf val=0x3f NE2000: Set IRQ line 9 to 0 (40 3f) NE2000: read addr=0x0 val=26 NE2000: read addr=0x0 val=26 NE2000: read addr=0x0 val=26 NE2000: read addr=0x0 val=26 NE2000: read addr=0x0 val=26 NE2000: read addr=0x0 val=26 NE2000: read addr=0x0 val=26 NE2000: read addr=0x0 val=26 NE2000: read addr=0x0 val=26 NE2000: read addr=0x0 val=26 ... --------------- with these last lines repeated over 100000 times until time-out. a quick peek in the 8390.ASM source shows the following code around line 431 and 463: +++++++++++++++ tx_wait_l2: sti ; allow receive interrupts while waiting loadport ; Point at chip command register setport EN_CCMD ; .. in al, dx ; Get chip command state --> test al,ENC_TRANS ; Is transmitter still running? cli ; the rest of the code may not work with EI (?) jz tx_idle_0 ; Go if free dec ah jnz tx_wait_l2 ; wait 51.2 us (one ethernet slot time) --------------- +++++++++++++++ public send_pkt send_pkt: ;enter with ds:si -> packet, cx = packet length. ;exit with nc if ok, or else cy if error, dh set to error number. assume ds:nothing mkle LE_SP_E, cx, si, ds cli ;ne1000 checks the packet size at this point, which is probably more sensible. loadport ; Point at chip command register setport EN_CCMD ; .. pause_ ;ne1000 fails to check to see if the transmitter is still busy. in al, dx ; Get chip command state --> test al,ENC_TRANS ; Is transmitter still running? ifdef debug mov log_ccmd,al ; added - gft - 910607 endif ; ; Used to just go to tx_idle here if the transmitter was not running, however ; it is possible to get here with the transmission complete, but since ; interrupts are off when we get here it is also possible that a transmission ; JUST DID complete and has not yet had its interrupt acknowledge and errors ; recorded. Proceding here without checking will work, it just looses the ; error status from the last transmission if that transmission has not been ; acknowledged by the isr_tx code. ; ; Changed the jz tx_idle below to the following code - gft - 910607 ; ; jz tx_idle ; Go if free jnz tx_wait --------------- It is obvious that the driver refuses to start a new transmission because ENC_TRANS is still set in the command register. Since all other operating systems work correctly with this ne2000 virtual hardware it was possible that this is a bug in the Crynwr packet driver but the documentation file DP8390D.pdf that I downloaded from: mentions at page 19: +++++++++++++++ TRANSMIT PACKET This bit must be set to initiate transmission of a packet TXP is internally reset either after the transmission is completed or aborted This bit should be set only after the Transmit Byte Count and Transmit Page Start registers have been programmed. --------------- Since this bit was never reset in hw/ne2000.c, I propose the following patch: +++++++++++++++ diff -ur qemu/hw/ne2000.c qemu-patched/hw/ne2000.c --- qemu/hw/ne2000.c Sun Oct 3 15:56:00 2004 +++ qemu-patched/hw/ne2000.c Fri Dec 24 02:36:50 2004 @@ -268,6 +268,7 @@ /* signal end of transfert */ s->tsr = ENTSR_PTX; s->isr |= ENISR_TX; + s->cmd &= ~E8390_TRANS; ne2000_update_irq(s); } } --------------- With this patch applied I can use the packetdriver when I start qemu with option -isa with both slirp and tun/tap networking. When I try to use pci, the trace tells me the device is using interrupt 16 ??? Groeten, Mark. -- :wq