]> xenbits.xensource.com Git - xen.git/commitdiff
ioemu: Fix rtl8139 emulation so that reboot works correctly in 64-bit
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 9 Apr 2008 15:03:40 +0000 (16:03 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 9 Apr 2008 15:03:40 +0000 (16:03 +0100)
Windows VMs. Return an error if the guest OS tries to transmit a
packet with the transmitter disabled, so that it doesn't spin forever
waiting for it to complete.

Signed-off-by: Steven Smith <Steven.Smith@eu.citrix.com>
tools/ioemu/hw/rtl8139.c

index 42e25e8855cf4de43b7b9d6659ac1fd839721da4..f0414edc9124260efe460300a033ab66fde59a9f 100644 (file)
@@ -1416,6 +1416,8 @@ static uint32_t rtl8139_ChipCmd_read(RTL8139State *s)
 
 static void rtl8139_CpCmd_write(RTL8139State *s, uint32_t val)
 {
+    int i;
+
     val &= 0xffff;
 
     DEBUG_PRINT(("RTL8139C+ command register write(w) val=0x%04x\n", val));
@@ -1423,6 +1425,20 @@ static void rtl8139_CpCmd_write(RTL8139State *s, uint32_t val)
     /* mask unwriteable bits */
     val = SET_MASKED(val, 0xff84, s->CpCmd);
 
+    if (  (s->CpCmd & CPlusTxEnb) &&
+         !(val      & CPlusTxEnb) )
+    {
+        /* Reset TX status when the transmitter drops from C+ to
+           non-C+ mode.  Windows has a habit of turning off C+ and
+           then waiting for the TX requests to clear as part of shut
+           down, and you get stuck forever if there are old DTCRs in
+           the registers. */
+        for (i = 0; i < 4; i++)
+        {
+            s->TxStatus[i] = TxHostOwns;
+        }
+    }
+
     s->CpCmd = val;
 }
 
@@ -1765,6 +1781,7 @@ static int rtl8139_transmit_one(RTL8139State *s, int descriptor)
     {
         DEBUG_PRINT(("RTL8139: +++ cannot transmit from descriptor %d: transmitter disabled\n",
                      descriptor));
+        s->TxStatus[descriptor] = TxAborted | TxHostOwns;
         return 0;
     }
 
@@ -1772,6 +1789,7 @@ static int rtl8139_transmit_one(RTL8139State *s, int descriptor)
     {
         DEBUG_PRINT(("RTL8139: +++ cannot transmit from descriptor %d: owned by host (%08x)\n",
                      descriptor, s->TxStatus[descriptor]));
+        s->TxStatus[descriptor] = TxAborted | TxHostOwns;
         return 0;
     }