Changeset 49814 in vbox for trunk/src/VBox/Devices/USB/solaris
- Timestamp:
- Dec 6, 2013 9:38:28 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 91156
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/USB/solaris/USBProxyDevice-solaris.cpp
r47497 r49814 38 38 #include <iprt/file.h> 39 39 #include <iprt/mem.h> 40 #include <iprt/pipe.h> 40 41 #include "../USBProxyDevice.h" 41 42 #include <VBox/usblib.h> … … 91 92 /** The tail of the landed solaris URBs. */ 92 93 PUSBPROXYURBSOL pTaxingTail; 94 /** Pipe handle for waiking up - writing end. */ 95 RTPIPE hPipeWakeupW; 96 /** Pipe handle for waiking up - reading end. */ 97 RTPIPE hPipeWakeupR; 93 98 } USBPROXYDEVSOL, *PUSBPROXYDEVSOL; 94 99 … … 309 314 pProxyDev->Backend.pv = pDevSol; 310 315 311 int Instance; 312 char *pszDevicePath = NULL; 313 rc = USBLibGetClientInfo(szDeviceIdent, &pszDevicePath, &Instance); 316 /* 317 * Create wakeup pipe. 318 */ 319 rc = RTPipeCreate(&pDevLnx->hPipeWakeupR, &pDevLnx->hPipeWakeupW, 0); 314 320 if (RT_SUCCESS(rc)) 315 321 { 316 pDevSol->pszDevicePath = pszDevicePath; 317 318 /* 319 * Open the client driver. 320 */ 321 RTFILE hFile; 322 rc = RTFileOpen(&hFile, pDevSol->pszDevicePath, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE); 322 int Instance; 323 char *pszDevicePath = NULL; 324 rc = USBLibGetClientInfo(szDeviceIdent, &pszDevicePath, &Instance); 323 325 if (RT_SUCCESS(rc)) 324 326 { 325 pDevSol->hFile = hFile; 326 pDevSol->pProxyDev = pProxyDev; 327 pDevSol->pszDevicePath = pszDevicePath; 327 328 328 329 /* 329 * Verify client driver version.330 * Open the client driver. 330 331 */ 331 VBOXUSBREQ_GET_VERSION GetVersionReq; 332 bzero(&GetVersionReq, sizeof(GetVersionReq)); 333 rc = usbProxySolarisIOCtl(pDevSol, VBOXUSB_IOCTL_GET_VERSION, &GetVersionReq, sizeof(GetVersionReq)); 332 RTFILE hFile; 333 rc = RTFileOpen(&hFile, pDevSol->pszDevicePath, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE); 334 334 if (RT_SUCCESS(rc)) 335 335 { 336 if ( GetVersionReq.u32Major == VBOXUSB_VERSION_MAJOR 337 && GetVersionReq.u32Minor >= VBOXUSB_VERSION_MINOR) 336 pDevSol->hFile = hFile; 337 pDevSol->pProxyDev = pProxyDev; 338 339 /* 340 * Verify client driver version. 341 */ 342 VBOXUSBREQ_GET_VERSION GetVersionReq; 343 bzero(&GetVersionReq, sizeof(GetVersionReq)); 344 rc = usbProxySolarisIOCtl(pDevSol, VBOXUSB_IOCTL_GET_VERSION, &GetVersionReq, sizeof(GetVersionReq)); 345 if (RT_SUCCESS(rc)) 338 346 { 339 /* 340 * Try & get the current cached config from Solaris. 341 */ 342 usbProxySolarisGetActiveConfig(pDevSol); 343 return VINF_SUCCESS; 347 if ( GetVersionReq.u32Major == VBOXUSB_VERSION_MAJOR 348 && GetVersionReq.u32Minor >= VBOXUSB_VERSION_MINOR) 349 { 350 /* 351 * Try & get the current cached config from Solaris. 352 */ 353 usbProxySolarisGetActiveConfig(pDevSol); 354 return VINF_SUCCESS; 355 } 356 else 357 { 358 LogRel((USBPROXY ":version mismatch! driver v%d.%d expecting ~v%d.%d\n", GetVersionReq.u32Major, 359 GetVersionReq.u32Minor, VBOXUSB_VERSION_MAJOR, VBOXUSB_VERSION_MINOR)); 360 rc = VERR_VERSION_MISMATCH; 361 } 344 362 } 345 363 else 346 364 { 347 LogRel((USBPROXY ":version mismatch! driver v%d.%d expecting ~v%d.%d\n", GetVersionReq.u32Major, 348 GetVersionReq.u32Minor, VBOXUSB_VERSION_MAJOR, VBOXUSB_VERSION_MINOR)); 349 rc = VERR_VERSION_MISMATCH; 365 LogRel((USBPROXY ":failed to query driver version. rc=%Rrc\n", rc)); 350 366 } 367 368 RTFileClose(pDevSol->hFile); 369 pDevSol->hFile = NIL_RTFILE; 370 pDevSol->pProxyDev = NULL; 351 371 } 352 372 else 353 { 354 LogRel((USBPROXY ":failed to query driver version. rc=%Rrc\n", rc)); 355 } 356 357 RTFileClose(pDevSol->hFile); 358 pDevSol->hFile = NIL_RTFILE; 359 pDevSol->pProxyDev = NULL; 373 LogRel((USBPROXY ":failed to open device. rc=%Rrc pszDevicePath=%s\n", rc, pDevSol->pszDevicePath)); 374 375 RTStrFree(pDevSol->pszDevicePath); 376 pDevSol->pszDevicePath = NULL; 360 377 } 361 378 else 362 LogRel((USBPROXY ":failed to open device. rc=%Rrc pszDevicePath=%s\n", rc, pDevSol->pszDevicePath)); 363 364 RTStrFree(pDevSol->pszDevicePath); 365 pDevSol->pszDevicePath = NULL; 366 } 367 else 368 { 369 LogRel((USBPROXY ":failed to get client info. rc=%Rrc pszDevicePath=%s\n", rc, pDevSol->pszDevicePath)); 370 if (rc == VERR_NOT_FOUND) 371 rc = VERR_OPEN_FAILED; 379 { 380 LogRel((USBPROXY ":failed to get client info. rc=%Rrc pszDevicePath=%s\n", rc, pDevSol->pszDevicePath)); 381 if (rc == VERR_NOT_FOUND) 382 rc = VERR_OPEN_FAILED; 383 } 384 RTPipeClose(pDevLnx->hPipeWakeupR); 385 RTPipeClose(pDevLnx->hPipeWakeupW); 372 386 } 373 387 … … 431 445 RTMemFree(pUrbSol); 432 446 } 447 448 RTPipeClose(pDevLnx->hPipeWakeupR); 449 RTPipeClose(pDevLnx->hPipeWakeupW); 433 450 434 451 RTStrFree(pDevSol->pszDevicePath); … … 703 720 for (;;) 704 721 { 705 struct pollfd pfd; 706 pfd.fd = RTFileToNative(pDevSol->hFile); 707 pfd.events = POLLIN; 708 pfd.revents = 0; 709 int rc = poll(&pfd, 1, cMillies); 722 int cMilliesWait = cMillies == RT_INDEFINITE_WAIT ? -1 : cMillies; 723 struct pollfd pfd[2]; 724 725 pfd[0].fd = RTFileToNative(pDevSol->hFile); 726 pfd[0].events = POLLIN; 727 pfd[0].revents = 0; 728 729 pfd[1].fd = RTPipeToNative(pDevSol->hWakeupPipeR); 730 pfd[1].events = POLLIN; 731 pfd[1].revents = 0; 732 733 int rc = poll(&pfd, 2, cMilliesWait); 710 734 if (rc > 0) 711 735 { 712 if (pfd .revents & POLLHUP)736 if (pfd[0].revents & POLLHUP) 713 737 { 714 738 LogRel((USBPROXY ":Reaping failed, USB Device '%s' disconnected!\n", pDevSol->pProxyDev->pUsbIns->pszName)); … … 716 740 usbProxySolarisCloseFile(pDevSol); 717 741 } 742 743 if (pfd[1].revents & POLLIN) 744 { 745 /* Got woken up, drain pipe. */ 746 uint8_t bRead; 747 size_t cbIgnored = 0; 748 RTPipeRead(pDevLnx->hPipeWakeupR, &bRead, 1, &cbIgnored); 749 750 /* 751 * It is possible that we got woken up and have an URB pending 752 * for completion. Do it on the way out. Otherwise return 753 * immediately to the caller. 754 */ 755 if (!(pfd[0].revents & POLLIN)) 756 return NULL; 757 } 758 718 759 break; 719 760 } … … 852 893 853 894 895 static DECLCALLBACK(int) usbProxySolarisWakeup(PUSBPROXYDEV pProxyDev) 896 { 897 PUSBPROXYDEVSOL pDevSol = (PUSBPROXYDEVSOL)pProxyDev->Backend.pv; 898 size_t cbIgnored; 899 900 LogFlowFunc(("pProxyDev=%p\n", pProxyDev)); 901 902 return RTPipeWrite(pDevSol->hPipeWakeupW, "", 1, &cbIgnored); 903 } 904 854 905 855 906 /** … … 871 922 usbProxySolarisUrbCancel, 872 923 usbProxySolarisUrbReap, 924 usbProxySolarisWakeup, 873 925 0 874 926 };
Note:
See TracChangeset
for help on using the changeset viewer.