ia64/xen-unstable

changeset 17422:40c0dda6eae6

ioemu: Fix rtl8139 emulation so that reboot works correctly in 64-bit
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>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Apr 09 16:03:40 2008 +0100 (2008-04-09)
parents 70ebf23f8a43
children 5ffd167d7772
files tools/ioemu/hw/rtl8139.c
line diff
     1.1 --- a/tools/ioemu/hw/rtl8139.c	Wed Apr 09 16:02:49 2008 +0100
     1.2 +++ b/tools/ioemu/hw/rtl8139.c	Wed Apr 09 16:03:40 2008 +0100
     1.3 @@ -1416,6 +1416,8 @@ static uint32_t rtl8139_ChipCmd_read(RTL
     1.4  
     1.5  static void rtl8139_CpCmd_write(RTL8139State *s, uint32_t val)
     1.6  {
     1.7 +    int i;
     1.8 +
     1.9      val &= 0xffff;
    1.10  
    1.11      DEBUG_PRINT(("RTL8139C+ command register write(w) val=0x%04x\n", val));
    1.12 @@ -1423,6 +1425,20 @@ static void rtl8139_CpCmd_write(RTL8139S
    1.13      /* mask unwriteable bits */
    1.14      val = SET_MASKED(val, 0xff84, s->CpCmd);
    1.15  
    1.16 +    if (  (s->CpCmd & CPlusTxEnb) &&
    1.17 +         !(val      & CPlusTxEnb) )
    1.18 +    {
    1.19 +        /* Reset TX status when the transmitter drops from C+ to
    1.20 +           non-C+ mode.  Windows has a habit of turning off C+ and
    1.21 +           then waiting for the TX requests to clear as part of shut
    1.22 +           down, and you get stuck forever if there are old DTCRs in
    1.23 +           the registers. */
    1.24 +        for (i = 0; i < 4; i++)
    1.25 +        {
    1.26 +            s->TxStatus[i] = TxHostOwns;
    1.27 +        }
    1.28 +    }
    1.29 +
    1.30      s->CpCmd = val;
    1.31  }
    1.32  
    1.33 @@ -1765,6 +1781,7 @@ static int rtl8139_transmit_one(RTL8139S
    1.34      {
    1.35          DEBUG_PRINT(("RTL8139: +++ cannot transmit from descriptor %d: transmitter disabled\n",
    1.36                       descriptor));
    1.37 +        s->TxStatus[descriptor] = TxAborted | TxHostOwns;
    1.38          return 0;
    1.39      }
    1.40  
    1.41 @@ -1772,6 +1789,7 @@ static int rtl8139_transmit_one(RTL8139S
    1.42      {
    1.43          DEBUG_PRINT(("RTL8139: +++ cannot transmit from descriptor %d: owned by host (%08x)\n",
    1.44                       descriptor, s->TxStatus[descriptor]));
    1.45 +        s->TxStatus[descriptor] = TxAborted | TxHostOwns;
    1.46          return 0;
    1.47      }
    1.48