direct-io.hg

changeset 13574:b064775fba7d

[QEMU] Clear TD status field explicitly when it's fetched.

In current Qemu-dm, UHC will set some status bits of TD in status
updating stage, but never process the status bit if relevant condition
does not occur, leaving it as it is. When a TD is fetched with some
status bits are set to 1, it will return to Guest OS with these bits
set to 1 even this TD is executed successfully. Some Windows OS,
e.g. Windows 2000, will check status bits of TD in UHC interrupt
routine, treat it as a unsuccessful one if some status bits are set to
1 and discard the data. Other Windows OS just check USBSTS of UHC,
ignoring status field of TD unless the value of USBSTS indicates
occurrence of error.

With this patch, USB mouse/tablet in Windows 2000 works correctly.

Signed-off-by: Xinmei Huang <xinmei.huang@intel.com>
author kfraser@localhost.localdomain
date Wed Jan 24 10:44:32 2007 +0000 (2007-01-24)
parents c9ac0bace498
children c3b2443408f4
files tools/ioemu/hw/usb-uhci.c
line diff
     1.1 --- a/tools/ioemu/hw/usb-uhci.c	Wed Jan 24 10:38:17 2007 +0000
     1.2 +++ b/tools/ioemu/hw/usb-uhci.c	Wed Jan 24 10:44:32 2007 +0000
     1.3 @@ -43,9 +43,15 @@
     1.4  #define TD_CTRL_IOC     (1 << 24)
     1.5  #define TD_CTRL_ACTIVE  (1 << 23)
     1.6  #define TD_CTRL_STALL   (1 << 22)
     1.7 +#define TD_CTRL_BUFFER  (1 << 21)
     1.8  #define TD_CTRL_BABBLE  (1 << 20)
     1.9  #define TD_CTRL_NAK     (1 << 19)
    1.10  #define TD_CTRL_TIMEOUT (1 << 18)
    1.11 +#define TD_CTRL_BITSTUFF                                 \
    1.12 +                        (1 << 17)
    1.13 +#define TD_CTRL_MASK                                     \
    1.14 +    (TD_CTRL_BITSTUFF | TD_CTRL_TIMEOUT | TD_CTRL_NAK    \
    1.15 +     | TD_CTRL_BABBLE | TD_CTRL_BUFFER | TD_CTRL_STALL)
    1.16  
    1.17  #define UHCI_PORT_RESET (1 << 9)
    1.18  #define UHCI_PORT_LSDA  (1 << 8)
    1.19 @@ -428,6 +434,8 @@ static int uhci_handle_td(UHCIState *s, 
    1.20          ret = 1;
    1.21          goto out;
    1.22      }
    1.23 +    /* Clear TD's status field explicitly */
    1.24 +    td->ctrl = td->ctrl & (~TD_CTRL_MASK);
    1.25  
    1.26      /* TD is active */
    1.27      max_len = ((td->token >> 21) + 1) & 0x7ff;