VirtualBox

Changeset 59091 in vbox for trunk/src/VBox/Devices/USB


Ignore:
Timestamp:
Dec 11, 2015 2:29:16 PM (9 years ago)
Author:
vboxsync
Message:

USB/Solaris: Rewrite, cleanup and numerous bug fixes to get the Apple iPhone working.

File:
1 edited

Legend:

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

    r58778 r59091  
    212212    if (RT_UNLIKELY(pDevSol->hFile == NIL_RTFILE))
    213213    {
    214         LogFlow((USBPROXY ":usbProxySolarisIOCtl connection to driver gone!\n"));
     214        LogFlow((USBPROXY ":usbProxySolarisIOCtl: Connection to driver gone!\n"));
    215215        return VERR_VUSB_DEVICE_NOT_ATTACHED;
    216216    }
     
    232232                pDevSol->pProxyDev->fDetached = true;
    233233                usbProxySolarisCloseFile(pDevSol);
    234                 LogRel((USBPROXY ":Command %#x failed, USB Device '%s' disconnected!\n", Function, pDevSol->pProxyDev->pUsbIns->pszName));
     234                LogRel((USBPROXY ": Command %#x failed, USB Device '%s' disconnected!\n", Function,
     235                        pDevSol->pProxyDev->pUsbIns->pszName));
    235236            }
    236237            else
    237                 LogRel((USBPROXY ":Command %#x failed. Req.rc=%Rrc\n", Function, Req.rc));
     238                LogRel((USBPROXY ": Command %#x failed. Req.rc=%Rrc\n", Function, Req.rc));
    238239        }
    239240
     
    241242    }
    242243
    243     LogRel((USBPROXY ":Function %#x failed. rc=%Rrc\n", Function, rc));
     244    LogRel((USBPROXY ": Function %#x failed. rc=%Rrc\n", Function, rc));
    244245    return rc;
    245246}
     
    268269    {
    269270        if (rc != VERR_VUSB_DEVICE_NOT_ATTACHED)
    270             LogRel((USBPROXY ":Failed to get configuration. rc=%Rrc\n", rc));
     271            LogRel((USBPROXY ": Failed to get configuration. rc=%Rrc\n", rc));
    271272
    272273        pDevSol->pProxyDev->iActiveCfg = -1;
     
    290291    PUSBPROXYDEVSOL pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL);
    291292
    292     LogFlowFunc((USBPROXY ":usbProxySolarisOpen pProxyDev=%p pszAddress=%s pvBackend=%p\n", pProxyDev, pszAddress, pvBackend));
     293    LogFlowFunc((USBPROXY ":usbProxySolarisOpen: pProxyDev=%p pszAddress=%s pvBackend=%p\n", pProxyDev, pszAddress, pvBackend));
    293294
    294295    /*
     
    351352                                else
    352353                                {
    353                                     LogRel((USBPROXY ":version mismatch! driver v%d.%d expecting ~v%d.%d\n", GetVersionReq.u32Major,
     354                                    LogRel((USBPROXY ": Version mismatch, Driver v%d.%d expecting ~v%d.%d\n", GetVersionReq.u32Major,
    354355                                            GetVersionReq.u32Minor, VBOXUSB_VERSION_MAJOR, VBOXUSB_VERSION_MINOR));
    355356                                    rc = VERR_VERSION_MISMATCH;
     
    357358                            }
    358359                            else
    359                                 LogRel((USBPROXY ":failed to query driver version. rc=%Rrc\n", rc));
     360                                LogRel((USBPROXY ": Failed to query driver version. rc=%Rrc\n", rc));
    360361
    361362                            RTFileClose(pDevSol->hFile);
     
    364365                        }
    365366                        else
    366                             LogRel((USBPROXY ":failed to open device. rc=%Rrc pszDevicePath=%s\n", rc, pDevSol->pszDevicePath));
     367                            LogRel((USBPROXY ": Failed to open device. rc=%Rrc pszDevicePath=%s\n", rc, pDevSol->pszDevicePath));
    367368
    368369                        RTStrFree(pDevSol->pszDevicePath);
     
    371372                    else
    372373                    {
    373                         LogRel((USBPROXY ":failed to get client info. rc=%Rrc pszDevicePath=%s\n", rc, pDevSol->pszDevicePath));
     374                        LogRel((USBPROXY ": Failed to get client info. rc=%Rrc szDeviceIdent=%s\n", rc, szDeviceIdent));
    374375                        if (rc == VERR_NOT_FOUND)
    375376                            rc = VERR_OPEN_FAILED;
     
    382383            }
    383384            else
    384                 LogRel((USBPROXY ":RTCritSectInit failed. rc=%Rrc pszAddress=%s\n", rc, pszAddress));
     385                LogRel((USBPROXY ": RTCritSectInit failed. rc=%Rrc pszAddress=%s\n", rc, pszAddress));
    385386        }
    386387        else
    387             LogRel((USBPROXY ":RTStrAPrintf failed. rc=%Rrc pszAddress=%s\n", rc, pszAddress));
     388            LogRel((USBPROXY ": RTStrAPrintf failed. rc=%Rrc pszAddress=%s\n", rc, pszAddress));
    388389    }
    389390    else
    390         LogRel((USBPROXY ":USBLibInit failed. rc=%Rrc\n", rc));
     391        LogRel((USBPROXY ": USBLibInit failed. rc=%Rrc\n", rc));
    391392
    392393    USBLibTerm();
     
    451452static DECLCALLBACK(int) usbProxySolarisReset(PUSBPROXYDEV pProxyDev, bool fRootHubReset)
    452453{
    453     LogFlowFunc((USBPROXY ":usbProxySolarisReset pProxyDev=%s fRootHubReset=%d\n", pProxyDev->pUsbIns->pszName, fRootHubReset));
     454    LogFlowFunc((USBPROXY ": usbProxySolarisReset: pProxyDev=%s fRootHubReset=%d\n", pProxyDev->pUsbIns->pszName, fRootHubReset));
    454455
    455456    /** Pass all resets to the device. The Trekstor USB (1.1) stick requires this to work. */
     
    466467    }
    467468    else if (rc != VERR_VUSB_DEVICE_NOT_ATTACHED)
    468         LogRel((USBPROXY ":usbProxySolarisReset failed. rc=%d\n", rc));
     469        LogRel((USBPROXY ": usbProxySolarisReset: Failed! rc=%d\n", rc));
    469470
    470471    return rc;
     
    484485static DECLCALLBACK(int) usbProxySolarisSetConfig(PUSBPROXYDEV pProxyDev, int iCfg)
    485486{
    486     LogFlowFunc((USBPROXY ":usbProxySolarisSetConfig: pProxyDev=%p iCfg=%#x\n", pProxyDev, iCfg));
     487    LogFlowFunc((USBPROXY ": usbProxySolarisSetConfig: pProxyDev=%p iCfg=%#x\n", pProxyDev, iCfg));
    487488
    488489    PUSBPROXYDEVSOL pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL);
     
    494495    if (   RT_FAILURE(rc)
    495496        && rc != VERR_VUSB_DEVICE_NOT_ATTACHED)
    496         LogRel((USBPROXY ":usbProxySolarisSetConfig failed to switch configuration. rc=%Rrc\n", rc));
     497        LogRel((USBPROXY ": usbProxySolarisSetConfig: Failed! rc=%Rrc\n", rc));
    497498
    498499    return rc;
     
    533534 * @returns success indicator.
    534535 */
    535 static DECLCALLBACK(int) usbProxySolarisSetInterface(PUSBPROXYDEV pProxyDev, int iIf, int iAlt)
    536 {
    537     LogFlowFunc((USBPROXY ":usbProxySolarisSetInterface: pProxyDev=%p iIf=%d iAlt=%d\n", pProxyDev, iIf, iAlt));
     536static DECLCALLBACK(int) usbProxySolarisSetInterface(PUSBPROXYDEV pProxyDev, int bIf, int bAlt)
     537{
     538    LogFlowFunc((USBPROXY ": usbProxySolarisSetInterface: pProxyDev=%p bIf=%#x iAlt=%#x\n", pProxyDev, bIf, bAlt));
    538539
    539540    PUSBPROXYDEVSOL pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL);
     
    541542
    542543    VBOXUSBREQ_SET_INTERFACE SetInterfaceReq;
    543     SetInterfaceReq.bInterface = iIf;
    544     SetInterfaceReq.bAlternate = iAlt;
     544    SetInterfaceReq.bInterface = bIf;
     545    SetInterfaceReq.bAlternate = bAlt;
    545546    int rc = usbProxySolarisIOCtl(pDevSol, VBOXUSB_IOCTL_SET_INTERFACE, &SetInterfaceReq, sizeof(SetInterfaceReq));
    546547    if (   RT_FAILURE(rc)
    547548        && rc != VERR_VUSB_DEVICE_NOT_ATTACHED)
    548         LogRel((USBPROXY ":usbProxySolarisSetInterface failed to set interface. rc=%Rrc\n", rc));
     549        LogRel((USBPROXY ": usbProxySolarisSetInterface: Failed! rc=%Rrc\n", rc));
    549550
    550551    return rc;
     
    557558static DECLCALLBACK(int) usbProxySolarisClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int EndPt)
    558559{
    559     LogFlowFunc((USBPROXY ":usbProxySolarisClearHaltedEp pProxyDev=%p EndPt=%#x\n", pProxyDev, EndPt));
     560    LogFlowFunc((USBPROXY ": usbProxySolarisClearHaltedEp: pProxyDev=%p EndPt=%#x\n", pProxyDev, EndPt));
    560561
    561562    PUSBPROXYDEVSOL pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL);
     
    567568    if (   RT_FAILURE(rc)
    568569        && rc != VERR_VUSB_DEVICE_NOT_ATTACHED)
    569         LogRel((USBPROXY ":usbProxySolarisClearHaltedEp failed! rc=%Rrc\n", rc));
     570        LogRel((USBPROXY ": usbProxySolarisClearHaltedEp: Failed! rc=%Rrc\n", rc));
    570571
    571572    return rc;
     
    580581    PUSBPROXYDEVSOL pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL);
    581582
    582     LogFlowFunc((USBPROXY ": usbProxySolarisUrbQueue: pProxyDev=%s pUrb=%p EndPt=%#x enmDir=%d cbData=%d pvData=%p\n",
    583              pProxyDev->pUsbIns->pszName, pUrb, pUrb->EndPt, pUrb->enmDir, pUrb->cbData, pUrb->abData));
     583    LogFlowFunc((USBPROXY ": usbProxySolarisUrbQueue: pProxyDev=%s pUrb=%p pszDesc=%s EndPt=%#x enmDir=%d cbData=%d pvData=%p\n",
     584             pProxyDev->pUsbIns->pszName, pUrb, pUrb->pszDesc, pUrb->EndPt, pUrb->enmDir, pUrb->cbData, pUrb->abData));
    584585
    585586    PUSBPROXYURBSOL pUrbSol = usbProxySolarisUrbAlloc(pDevSol);
    586587    if (RT_UNLIKELY(!pUrbSol))
    587588    {
    588         LogRel((USBPROXY ":usbProxySolarisUrbQueue: Failed to allocate URB.\n"));
     589        LogRel((USBPROXY ": usbProxySolarisUrbQueue: Failed to allocate URB\n"));
    589590        return VERR_NO_MEMORY;
    590591    }
     
    605606    UrbReq.fShortOk     = !pUrb->fShortNotOk;
    606607    UrbReq.cbData       = pUrb->cbData;
    607     UrbReq.pvData       = pUrb->abData;
     608    UrbReq.pvData       = &pUrb->abData[0];
     609
     610    Log6((USBPROXY ": Sending: EndPt=%#x Dir=%d cbData=%u\n", pUrb->EndPt, pUrb->enmDir, pUrb->cbData));
     611
    608612    if (pUrb->enmType == VUSBXFERTYPE_ISOC)
    609613    {
     
    621625    {
    622626        if (pUrb->enmType == VUSBXFERTYPE_ISOC)
    623             LogFlow((USBPROXY ":usbProxySolarisUrbQueue success cbData=%d.\n", pUrb->cbData));
     627            LogFlow((USBPROXY ":usbProxySolarisUrbQueue: Success cbData=%d\n", pUrb->cbData));
    624628        pUrb->Dev.pvPrivate = pUrbSol;
    625629        return VINF_SUCCESS;
     
    627631
    628632    if (rc != VERR_VUSB_DEVICE_NOT_ATTACHED)
    629         LogRel((USBPROXY ":usbProxySolarisUrbQueue Failed!! pProxyDev=%s pUrb=%p EndPt=%#x bEndpoint=%#x enmType=%d enmDir=%d cbData=%u rc=%Rrc\n",
    630              pProxyDev->pUsbIns->pszName, pUrb, pUrb->EndPt, UrbReq.bEndpoint, pUrb->enmType, pUrb->enmDir, pUrb->cbData, rc));
     633    {
     634        LogRel((USBPROXY ": usbProxySolarisUrbQueue: Failed! pProxyDev=%s pUrb=%p EndPt=%#x bEndpoint=%#x enmType=%d "
     635                "enmDir=%d cbData=%u rc=%Rrc\n", pProxyDev->pUsbIns->pszName, pUrb, pUrb->EndPt,
     636                UrbReq.bEndpoint, pUrb->enmType, pUrb->enmDir, pUrb->cbData, rc));
     637    }
    631638
    632639    return rc;
     
    647654    AssertPtrReturn(pDevSol, VERR_INVALID_POINTER);
    648655
    649     LogFlowFunc((USBPROXY ":usbProxySolarisUrbCancel pUrb=%p pUrbSol=%p pDevSol=%p\n", pUrb, pUrbSol, pUrbSol->pDevSol));
     656    LogFlowFunc((USBPROXY ": usbProxySolarisUrbCancel: pUrb=%p pUrbSol=%p pDevSol=%p\n", pUrb, pUrbSol, pUrbSol->pDevSol));
    650657
    651658    /* Aborting the control pipe isn't supported, pretend success. */
     
    658665    if (   RT_FAILURE(rc)
    659666        && rc != VERR_VUSB_DEVICE_NOT_ATTACHED)
    660         LogRel((USBPROXY ":usbProxySolarisUrbCancel failed to abort pipe. rc=%Rrc\n", rc));
    661 
    662     LogFlow((USBPROXY ":usbProxySolarisUrbCancel: rc=%Rrc.\n", rc));
     667        LogRel((USBPROXY ": usbProxySolarisUrbCancel: Failed to abort pipe. rc=%Rrc\n", rc));
     668
     669    LogFlow((USBPROXY ": usbProxySolarisUrbCancel: returns rc=%Rrc\n", rc));
    663670    return rc;
    664671}
     
    675682static DECLCALLBACK(PVUSBURB) usbProxySolarisUrbReap(PUSBPROXYDEV pProxyDev, RTMSINTERVAL cMillies)
    676683{
    677     //LogFlowFunc((USBPROXY ":usbProxySolarisUrbReap pProxyDev=%p cMillies=%u\n", pProxyDev, cMillies));
     684    LogFlowFunc((USBPROXY ":usbProxySolarisUrbReap pProxyDev=%p cMillies=%u\n", pProxyDev, cMillies));
    678685
    679686    PUSBPROXYDEVSOL pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL);
     
    693700        {
    694701            int cMilliesWait = cMillies == RT_INDEFINITE_WAIT ? -1 : (int)cMillies;
    695             struct pollfd pfd[2];
    696 
    697             pfd[0].fd = RTFileToNative(pDevSol->hFile);
    698             pfd[0].events = POLLIN;
    699             pfd[0].revents = 0;
    700 
    701             pfd[1].fd = RTPipeToNative(pDevSol->hPipeWakeupR);
    702             pfd[1].events = POLLIN;
    703             pfd[1].revents = 0;
    704 
    705             int rc = poll(&pfd[0], 2, cMilliesWait);
     702
     703            struct pollfd aFd[2];
     704            size_t const  cFds = RT_ELEMENTS(aFd);
     705
     706            aFd[0].fd      = RTFileToNative(pDevSol->hFile);
     707            aFd[0].events  = POLLIN;
     708            aFd[0].revents = 0;
     709
     710            aFd[1].fd      = RTPipeToNative(pDevSol->hPipeWakeupR);
     711            aFd[1].events  = POLLIN;
     712            aFd[1].revents = 0;
     713
     714            int rc = poll(&aFd[0], cFds, cMilliesWait);
    706715            if (rc > 0)
    707716            {
    708                 if (pfd[0].revents & POLLHUP)
     717                if (aFd[0].revents & POLLHUP)
    709718                {
    710                     LogRel((USBPROXY ":Reaping failed, USB Device '%s' disconnected!\n", pDevSol->pProxyDev->pUsbIns->pszName));
     719                    LogRel((USBPROXY ": USB Device '%s' disconnected!\n", pDevSol->pProxyDev->pUsbIns->pszName));
    711720                    pProxyDev->fDetached = true;
    712721                    usbProxySolarisCloseFile(pDevSol);
    713722                }
    714723
    715                 if (pfd[1].revents & POLLIN)
     724                if (aFd[1].revents & POLLIN)
    716725                {
    717726                    /* Got woken up, drain pipe. */
     
    725734                     * immediately to the caller.
    726735                     */
    727                     if (!(pfd[0].revents & POLLIN))
     736                    if (!(aFd[0].revents & POLLIN))
    728737                        return NULL;
    729738                }
    730 
    731739                break;
    732740            }
    733 
    734             if (rc == 0)
    735             {
    736                 //LogFlow((USBPROXY ":usbProxySolarisUrbReap: Timed out\n"));
     741            else if (rc == 0)
    737742                return NULL;
    738             }
    739             else if (rc != EAGAIN)
     743            else if (errno != EAGAIN)
    740744            {
    741745                LogFlow((USBPROXY ":usbProxySolarisUrbReap Poll rc=%d errno=%d\n", rc, errno));
     
    751755     */
    752756    PVUSBURB pUrb = NULL;
    753     while (pDevSol->pTaxingHead)
     757    while (    pDevSol->pTaxingHead
     758           && !pUrb)
    754759    {
    755760        RTCritSectEnter(&pDevSol->CritSect);
     
    761766            if (pUrb)
    762767            {
     768                /*
     769                 * Remove it from the taxing list and move it to the free list.
     770                 */
    763771                pUrb->Dev.pvPrivate = NULL;
    764772                usbProxySolarisUrbFree(pDevSol, pUrbSol);
     
    779787static PVUSBURB usbProxySolarisUrbComplete(PUSBPROXYDEVSOL pDevSol)
    780788{
    781     LogFlowFunc((USBPROXY ":usbProxySolarisUrbComplete pDevSol=%p\n", pDevSol));
     789    LogFlowFunc((USBPROXY ": usbProxySolarisUrbComplete: pDevSol=%p\n", pDevSol));
    782790
    783791    VBOXUSBREQ_URB UrbReq;
     
    809817                    }
    810818
    811                     LogFlow((USBPROXY ":usbProxySolarisUrbComplete ISOC cbData=%d cbActPktSum=%d\n", pUrb->cbData, cbData));
     819                    LogFlow((USBPROXY ":usbProxySolarisUrbComplete: Isoc cbData=%d cbActPktSum=%d\n", pUrb->cbData, cbData));
    812820                    pUrb->cbData = cbData;
    813821                    pUrb->enmStatus = UrbReq.enmStatus;
     
    835843
    836844                /*
    837                  * Link it into the taxing list.
     845                 * Add to the tail of the taxing list.
    838846                 */
    839847                pUrbSol->pNext = NULL;
     
    847855                RTCritSectLeave(&pDevSol->CritSect);
    848856
    849                 LogFlow((USBPROXY "usbProxySolarisUrbComplete: cb=%d EndPt=%#x enmDir=%d enmStatus=%s (%d) \n",
    850                          pUrb->cbData, pUrb->EndPt, pUrb->enmDir, pUrb->enmStatus == VUSBSTATUS_OK ? "OK" : "** Failed **", pUrb->enmStatus));
    851 //                if (pUrb->cbData < 2049)
    852 //                    LogFlow((USBPROXY "%.*Rhxd\n", pUrb->cbData, pUrb->abData));
     857                Log6((USBPROXY ": Reaping: EndPt=%#x Dir=%d cbData=%u\n", pUrb->EndPt, pUrb->enmDir, pUrb->cbData));
     858                if (pUrb->cbData < 1024)
     859                    Log6(("%.*Rhxd\n", pUrb->cbData, pUrb->abData));
    853860                return pUrb;
    854861            }
     
    858865    {
    859866        if (rc != VERR_VUSB_DEVICE_NOT_ATTACHED)
    860             LogRel((USBPROXY ":Reaping URB failed. rc=%Rrc\n", rc));
     867            LogRel((USBPROXY ": Reaping URB failed. rc=%Rrc\n", rc));
    861868    }
    862869
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