qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] ne2000: Reset TXP bit after sending packet.


From: Mark Jonckheere
Subject: [Qemu-devel] [PATCH] ne2000: Reset TXP bit after sending packet.
Date: Fri, 24 Dec 2004 03:30:39 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9) Gecko/20020408

Hi,

I had some problems to make the Crynwr packetdriver NE2000.COM
<http://crynwr.com/drivers/pktd11.zip> 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 <http://crynwr.com/drivers/pktd11a.zip>
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: <http://www.national.com/pf/DP/DP8390D.html> 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







reply via email to

[Prev in Thread] Current Thread [Next in Thread]