VirtualBox

Changeset 32192 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Sep 2, 2010 12:32:20 PM (14 years ago)
Author:
vboxsync
Message:

USB-win: Map URB cancellation to endpoint abort like Darwin/Solaris.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/USB/win/USBProxyDevice-win.cpp

    r31890 r32192  
    404404 * Aborts a pipe/endpoint (cancels all outstanding URBs on the endpoint).
    405405 */
    406 static bool usbProxyWinAbortEndPt(PUSBPROXYDEV pProxyDev, unsigned int ep)
     406static int usbProxyWinAbortEndPt(PUSBPROXYDEV pProxyDev, unsigned int ep)
    407407{
    408408    PPRIV_USBW32 pPriv = (PPRIV_USBW32)pProxyDev->Backend.pv;
    409409    USBSUP_CLEAR_ENDPOINT in;
    410410    DWORD cbReturned;
     411    int  rc;
    411412
    412413    Assert(pPriv);
     
    417418    cbReturned = 0;
    418419    if (DeviceIoControl(pPriv->hDev, SUPUSB_IOCTL_USB_ABORT_ENDPOINT, &in, sizeof(in), NULL, 0, &cbReturned, NULL))
    419         return true;
    420 
    421     if (    GetLastError() == ERROR_INVALID_HANDLE_STATE
    422         ||  GetLastError() == ERROR_BAD_COMMAND)
     420        return VINF_SUCCESS;
     421
     422    rc = GetLastError();
     423    if (    rc == ERROR_INVALID_HANDLE_STATE
     424        ||  rc == ERROR_BAD_COMMAND)
    423425    {
    424426        Log(("usbproxy: device %x unplugged!!\n", pPriv->hDev));
     
    427429    else
    428430        AssertMsgFailed(("lasterr=%d\n", GetLastError()));
    429     return false;
     431    return RTErrConvertFromWin32(rc);
    430432}
    431433
     
    735737
    736738/**
    737  * Cancel an in-flight URB.
     739 * Cancels an in-flight URB.
     740 *
     741 * The URB requires reaping, so we don't change its state.
     742 *
     743 * @remark  There isn't a way to cancel a specific URB on Windows.
     744 *          on darwin. The interface only supports the aborting of
     745 *          all URBs pending on an endpoint. Luckily that is usually
     746 *          exactly what the guest wants to do.
    738747 */
    739748static void usbProxyWinUrbCancel(PVUSBURB pUrb)
     
    742751    PPRIV_USBW32      pPriv     = (PPRIV_USBW32)pProxyDev->Backend.pv;
    743752    PQUEUED_URB       pQUrbWin  = (PQUEUED_URB)pUrb->Dev.pvPrivate;
     753    int                     rc;
     754    USBSUP_CLEAR_ENDPOINT   in;
     755    DWORD                   cbReturned;
    744756    Assert(pQUrbWin);
    745757
    746     /*
    747      * We've no way of canceling it, so we'll have to wait till
    748      * it's ripe and can be reaped. The caller will deal with this.
    749      */
    750     pQUrbWin->fCancelled = TRUE;
    751     Log(("Cancel urb %p\n", pUrb));
    752 
    753     /* Note CancelIoEx can cancel all pending IO requests for a file handle or a specific overlapped request.
    754      * Unfortunately Vista+ only.
    755      */
     758    in.bEndpoint = pUrb->EndPt | (pUrb->enmDir == VUSBDIRECTION_IN ? 0x80 : 0);
     759    Log(("Cancel urb %p, endpoint %x\n", pUrb, in.bEndpoint));
     760
     761    cbReturned = 0;
     762    if (DeviceIoControl(pPriv->hDev, SUPUSB_IOCTL_USB_ABORT_ENDPOINT, &in, sizeof(in), NULL, 0, &cbReturned, NULL))
     763        return;
     764   
     765    rc = GetLastError();
     766    if (    rc == ERROR_INVALID_HANDLE_STATE
     767        ||  rc == ERROR_BAD_COMMAND)
     768    {
     769        Log(("usbproxy: device %x unplugged!!\n", pPriv->hDev));
     770        pProxyDev->fDetached = true;
     771    }
     772    else
     773        AssertMsgFailed(("lasterr=%d\n", GetLastError()));
    756774}
    757775
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette