Changeset 59091 in vbox for trunk/src/VBox
- Timestamp:
- Dec 11, 2015 2:29:16 PM (9 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/USB/solaris/USBProxyDevice-solaris.cpp
r58778 r59091 212 212 if (RT_UNLIKELY(pDevSol->hFile == NIL_RTFILE)) 213 213 { 214 LogFlow((USBPROXY ":usbProxySolarisIOCtl connection to driver gone!\n"));214 LogFlow((USBPROXY ":usbProxySolarisIOCtl: Connection to driver gone!\n")); 215 215 return VERR_VUSB_DEVICE_NOT_ATTACHED; 216 216 } … … 232 232 pDevSol->pProxyDev->fDetached = true; 233 233 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)); 235 236 } 236 237 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)); 238 239 } 239 240 … … 241 242 } 242 243 243 LogRel((USBPROXY ": Function %#x failed. rc=%Rrc\n", Function, rc));244 LogRel((USBPROXY ": Function %#x failed. rc=%Rrc\n", Function, rc)); 244 245 return rc; 245 246 } … … 268 269 { 269 270 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)); 271 272 272 273 pDevSol->pProxyDev->iActiveCfg = -1; … … 290 291 PUSBPROXYDEVSOL pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL); 291 292 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)); 293 294 294 295 /* … … 351 352 else 352 353 { 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, 354 355 GetVersionReq.u32Minor, VBOXUSB_VERSION_MAJOR, VBOXUSB_VERSION_MINOR)); 355 356 rc = VERR_VERSION_MISMATCH; … … 357 358 } 358 359 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)); 360 361 361 362 RTFileClose(pDevSol->hFile); … … 364 365 } 365 366 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)); 367 368 368 369 RTStrFree(pDevSol->pszDevicePath); … … 371 372 else 372 373 { 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)); 374 375 if (rc == VERR_NOT_FOUND) 375 376 rc = VERR_OPEN_FAILED; … … 382 383 } 383 384 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)); 385 386 } 386 387 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)); 388 389 } 389 390 else 390 LogRel((USBPROXY ": USBLibInit failed. rc=%Rrc\n", rc));391 LogRel((USBPROXY ": USBLibInit failed. rc=%Rrc\n", rc)); 391 392 392 393 USBLibTerm(); … … 451 452 static DECLCALLBACK(int) usbProxySolarisReset(PUSBPROXYDEV pProxyDev, bool fRootHubReset) 452 453 { 453 LogFlowFunc((USBPROXY ": usbProxySolarisResetpProxyDev=%s fRootHubReset=%d\n", pProxyDev->pUsbIns->pszName, fRootHubReset));454 LogFlowFunc((USBPROXY ": usbProxySolarisReset: pProxyDev=%s fRootHubReset=%d\n", pProxyDev->pUsbIns->pszName, fRootHubReset)); 454 455 455 456 /** Pass all resets to the device. The Trekstor USB (1.1) stick requires this to work. */ … … 466 467 } 467 468 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)); 469 470 470 471 return rc; … … 484 485 static DECLCALLBACK(int) usbProxySolarisSetConfig(PUSBPROXYDEV pProxyDev, int iCfg) 485 486 { 486 LogFlowFunc((USBPROXY ": usbProxySolarisSetConfig: pProxyDev=%p iCfg=%#x\n", pProxyDev, iCfg));487 LogFlowFunc((USBPROXY ": usbProxySolarisSetConfig: pProxyDev=%p iCfg=%#x\n", pProxyDev, iCfg)); 487 488 488 489 PUSBPROXYDEVSOL pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL); … … 494 495 if ( RT_FAILURE(rc) 495 496 && 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)); 497 498 498 499 return rc; … … 533 534 * @returns success indicator. 534 535 */ 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));536 static DECLCALLBACK(int) usbProxySolarisSetInterface(PUSBPROXYDEV pProxyDev, int bIf, int bAlt) 537 { 538 LogFlowFunc((USBPROXY ": usbProxySolarisSetInterface: pProxyDev=%p bIf=%#x iAlt=%#x\n", pProxyDev, bIf, bAlt)); 538 539 539 540 PUSBPROXYDEVSOL pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL); … … 541 542 542 543 VBOXUSBREQ_SET_INTERFACE SetInterfaceReq; 543 SetInterfaceReq.bInterface = iIf;544 SetInterfaceReq.bAlternate = iAlt;544 SetInterfaceReq.bInterface = bIf; 545 SetInterfaceReq.bAlternate = bAlt; 545 546 int rc = usbProxySolarisIOCtl(pDevSol, VBOXUSB_IOCTL_SET_INTERFACE, &SetInterfaceReq, sizeof(SetInterfaceReq)); 546 547 if ( RT_FAILURE(rc) 547 548 && 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)); 549 550 550 551 return rc; … … 557 558 static DECLCALLBACK(int) usbProxySolarisClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int EndPt) 558 559 { 559 LogFlowFunc((USBPROXY ": usbProxySolarisClearHaltedEppProxyDev=%p EndPt=%#x\n", pProxyDev, EndPt));560 LogFlowFunc((USBPROXY ": usbProxySolarisClearHaltedEp: pProxyDev=%p EndPt=%#x\n", pProxyDev, EndPt)); 560 561 561 562 PUSBPROXYDEVSOL pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL); … … 567 568 if ( RT_FAILURE(rc) 568 569 && rc != VERR_VUSB_DEVICE_NOT_ATTACHED) 569 LogRel((USBPROXY ": usbProxySolarisClearHaltedEp failed! rc=%Rrc\n", rc));570 LogRel((USBPROXY ": usbProxySolarisClearHaltedEp: Failed! rc=%Rrc\n", rc)); 570 571 571 572 return rc; … … 580 581 PUSBPROXYDEVSOL pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL); 581 582 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)); 584 585 585 586 PUSBPROXYURBSOL pUrbSol = usbProxySolarisUrbAlloc(pDevSol); 586 587 if (RT_UNLIKELY(!pUrbSol)) 587 588 { 588 LogRel((USBPROXY ": usbProxySolarisUrbQueue: Failed to allocate URB.\n"));589 LogRel((USBPROXY ": usbProxySolarisUrbQueue: Failed to allocate URB\n")); 589 590 return VERR_NO_MEMORY; 590 591 } … … 605 606 UrbReq.fShortOk = !pUrb->fShortNotOk; 606 607 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 608 612 if (pUrb->enmType == VUSBXFERTYPE_ISOC) 609 613 { … … 621 625 { 622 626 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)); 624 628 pUrb->Dev.pvPrivate = pUrbSol; 625 629 return VINF_SUCCESS; … … 627 631 628 632 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 } 631 638 632 639 return rc; … … 647 654 AssertPtrReturn(pDevSol, VERR_INVALID_POINTER); 648 655 649 LogFlowFunc((USBPROXY ": usbProxySolarisUrbCancelpUrb=%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)); 650 657 651 658 /* Aborting the control pipe isn't supported, pretend success. */ … … 658 665 if ( RT_FAILURE(rc) 659 666 && 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)); 663 670 return rc; 664 671 } … … 675 682 static DECLCALLBACK(PVUSBURB) usbProxySolarisUrbReap(PUSBPROXYDEV pProxyDev, RTMSINTERVAL cMillies) 676 683 { 677 //LogFlowFunc((USBPROXY ":usbProxySolarisUrbReap pProxyDev=%p cMillies=%u\n", pProxyDev, cMillies));684 LogFlowFunc((USBPROXY ":usbProxySolarisUrbReap pProxyDev=%p cMillies=%u\n", pProxyDev, cMillies)); 678 685 679 686 PUSBPROXYDEVSOL pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL); … … 693 700 { 694 701 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); 706 715 if (rc > 0) 707 716 { 708 if ( pfd[0].revents & POLLHUP)717 if (aFd[0].revents & POLLHUP) 709 718 { 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)); 711 720 pProxyDev->fDetached = true; 712 721 usbProxySolarisCloseFile(pDevSol); 713 722 } 714 723 715 if ( pfd[1].revents & POLLIN)724 if (aFd[1].revents & POLLIN) 716 725 { 717 726 /* Got woken up, drain pipe. */ … … 725 734 * immediately to the caller. 726 735 */ 727 if (!( pfd[0].revents & POLLIN))736 if (!(aFd[0].revents & POLLIN)) 728 737 return NULL; 729 738 } 730 731 739 break; 732 740 } 733 734 if (rc == 0) 735 { 736 //LogFlow((USBPROXY ":usbProxySolarisUrbReap: Timed out\n")); 741 else if (rc == 0) 737 742 return NULL; 738 } 739 else if (rc != EAGAIN) 743 else if (errno != EAGAIN) 740 744 { 741 745 LogFlow((USBPROXY ":usbProxySolarisUrbReap Poll rc=%d errno=%d\n", rc, errno)); … … 751 755 */ 752 756 PVUSBURB pUrb = NULL; 753 while (pDevSol->pTaxingHead) 757 while ( pDevSol->pTaxingHead 758 && !pUrb) 754 759 { 755 760 RTCritSectEnter(&pDevSol->CritSect); … … 761 766 if (pUrb) 762 767 { 768 /* 769 * Remove it from the taxing list and move it to the free list. 770 */ 763 771 pUrb->Dev.pvPrivate = NULL; 764 772 usbProxySolarisUrbFree(pDevSol, pUrbSol); … … 779 787 static PVUSBURB usbProxySolarisUrbComplete(PUSBPROXYDEVSOL pDevSol) 780 788 { 781 LogFlowFunc((USBPROXY ": usbProxySolarisUrbCompletepDevSol=%p\n", pDevSol));789 LogFlowFunc((USBPROXY ": usbProxySolarisUrbComplete: pDevSol=%p\n", pDevSol)); 782 790 783 791 VBOXUSBREQ_URB UrbReq; … … 809 817 } 810 818 811 LogFlow((USBPROXY ":usbProxySolarisUrbComplete ISOCcbData=%d cbActPktSum=%d\n", pUrb->cbData, cbData));819 LogFlow((USBPROXY ":usbProxySolarisUrbComplete: Isoc cbData=%d cbActPktSum=%d\n", pUrb->cbData, cbData)); 812 820 pUrb->cbData = cbData; 813 821 pUrb->enmStatus = UrbReq.enmStatus; … … 835 843 836 844 /* 837 * Link it intothe taxing list.845 * Add to the tail of the taxing list. 838 846 */ 839 847 pUrbSol->pNext = NULL; … … 847 855 RTCritSectLeave(&pDevSol->CritSect); 848 856 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)); 853 860 return pUrb; 854 861 } … … 858 865 { 859 866 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)); 861 868 } 862 869 -
trunk/src/VBox/HostDrivers/VBoxUSB/solaris/USBLib-solaris.cpp
r57358 r59091 210 210 LogFlow((USBLIBR3 ":USBLibResetDevice pszDevicePath=%s\n", pszDevicePath)); 211 211 212 size_t cbReq = sizeof(VBOXUSBREQ_RESET_DEVICE) + strlen(pszDevicePath); 212 size_t cbPath = strlen(pszDevicePath) + 1; 213 size_t cbReq = sizeof(VBOXUSBREQ_RESET_DEVICE) + cbPath; 213 214 VBOXUSBREQ_RESET_DEVICE *pReq = (VBOXUSBREQ_RESET_DEVICE *)RTMemTmpAllocZ(cbReq); 214 215 if (RT_UNLIKELY(!pReq)) … … 216 217 217 218 pReq->fReattach = fReattach; 218 strcpy(pReq->szDevicePath, pszDevicePath); 219 if (strlcpy(pReq->szDevicePath, pszDevicePath, cbPath) >= cbPath) 220 { 221 LogRel((USBLIBR3 ":USBLibResetDevice buffer overflow. cbPath=%u pszDevicePath=%s\n", cbPath, pszDevicePath)); 222 return VERR_BUFFER_OVERFLOW; 223 } 219 224 220 225 int rc = usblibDoIOCtl(VBOXUSBMON_IOCTL_RESET_DEVICE, pReq, cbReq); -
trunk/src/VBox/HostDrivers/VBoxUSB/solaris/VBoxUSB-solaris.c
r58340 r59091 45 45 #include <iprt/path.h> 46 46 #include <iprt/thread.h> 47 #include <iprt/dbg.h> 47 48 48 49 #define USBDRV_MAJOR_VER 2 … … 51 52 #include <sys/strsun.h> 52 53 #include "usbai_private.h" 53 #include <sys/archsystm.h>54 #include <sys/disp.h>55 56 /** @todo review the locking here, verify assumptions about code executed57 * without the vboxusb_state_t::Mtx mutex */58 54 59 55 … … 66 62 #define DEVICE_DESC_DRV "VirtualBox USB" 67 63 68 /** Endpoint states */64 /** Endpoint states. */ 69 65 #define VBOXUSB_EP_INITIALIZED 0xa1fa1fa 70 66 #define VBOXUSB_EP_STATE_NONE RT_BIT(0) 71 67 #define VBOXUSB_EP_STATE_CLOSED RT_BIT(1) 72 68 #define VBOXUSB_EP_STATE_OPENED RT_BIT(2) 73 /** Polling states */74 #define VBOXUSB_POLL_OFF RT_BIT(0)75 #define VBOXUSB_POLL_ON RT_BIT(1)76 #define VBOXUSB_POLL_REAP_PENDING RT_BIT(2)77 #define VBOXUSB_POLL_DEV_UNPLUGGED RT_BIT(3)78 69 79 70 /** -=-=-=-=-=-=- Standard Specifics -=-=-=-=-=-=- */ 80 /** Max. supported endpoints */71 /** Max. supported endpoints. */ 81 72 #define VBOXUSB_MAX_ENDPOINTS 32 82 /** Size of USB Ctrl Xfer Header */83 #define VBOXUSB_CTRL_XFER_SIZE 0x0873 /** Size of USB Ctrl Xfer Header in bytes. */ 74 #define VBOXUSB_CTRL_XFER_SIZE 8 84 75 /** 85 76 * USB2.0 (Sec. 9-13) Bits 10..0 is the max packet size; for high speed Isoc/Intr, bits 12..11 is … … 87 78 */ 88 79 #define VBOXUSB_PKT_SIZE(pkt) (pkt & 0x07FF) * (1 + ((pkt >> 11) & 3)) 89 /** Endpoint Xfer Type */80 /** Endpoint Xfer Type. */ 90 81 #define VBOXUSB_XFER_TYPE(endp) ((endp)->EpDesc.bmAttributes & USB_EP_ATTR_MASK) 91 /** Endpoint Xfer Direction */82 /** Endpoint Xfer Direction. */ 92 83 #define VBOXUSB_XFER_DIR(endp) ((endp)->EpDesc.bEndpointAddress & USB_EP_DIR_IN) 84 /** Create an Endpoint index from an Endpoint address. */ 85 #define VBOXUSB_GET_EP_INDEX(epaddr) (((epaddr) & USB_EP_NUM_MASK) + \ 86 (((epaddr) & USB_EP_DIR_MASK) ? 16 : 0)) 87 93 88 94 89 /** -=-=-=-=-=-=- Tunable Parameters -=-=-=-=-=-=- */ … … 96 91 #define VBOXUSB_DRAIN_TIME 20 97 92 /** Ctrl Xfer timeout in seconds. */ 98 #define VBOXUSB_CTRL_XFER_TIMEOUT 10 99 /** Bulk Xfer timeout in seconds. */ 100 #define VBOXUSB_BULK_XFER_TIMEOUT 10 101 /** Intr Xfer timeout in seconds. */ 102 #define VBOXUSB_INTR_XFER_TIMEOUT 10 93 #define VBOXUSB_CTRL_XFER_TIMEOUT 15 103 94 /** Maximum URB queue length. */ 104 #define VBOXUSB_URB_QUEUE_SIZE 64105 /** Maximum asynchronous requests per pipe */95 #define VBOXUSB_URB_QUEUE_SIZE 512 96 /** Maximum asynchronous requests per pipe. */ 106 97 #define VBOXUSB_MAX_PIPE_ASYNC_REQS 2 107 98 108 /** For enabling global symbols while debugging 99 /** For enabling global symbols while debugging. **/ 109 100 #if defined(DEBUG_ramshankar) 110 101 # define LOCAL … … 201 192 typedef struct vboxusb_ep_t 202 193 { 203 uint_t fInitialized; /* Whether this Endpoint is initialized */ 204 uint_t EpState; /* Endpoint state */ 205 usb_ep_descr_t EpDesc; /* Endpoint descriptor */ 206 uchar_t uCfgValue; /* Configuration value */ 207 uchar_t uInterface; /* Interface number */ 208 uchar_t uAlt; /* Alternate number */ 209 usb_pipe_handle_t pPipe; /* Endpoint pipe handle */ 210 usb_pipe_policy_t PipePolicy; /* Endpoint policy */ 211 bool fIsocPolling; /* Whether Isoc. IN polling is enabled */ 212 list_t hIsocInUrbs; /* Isoc. IN inflight URBs */ 213 uint16_t cIsocInUrbs; /* Number of Isoc. IN inflight URBs */ 194 bool fInitialized; /* Whether this Endpoint is initialized */ 195 uint_t EpState; /* Endpoint state */ 196 usb_ep_descr_t EpDesc; /* Endpoint descriptor */ 197 usb_pipe_handle_t pPipe; /* Endpoint pipe handle */ 198 usb_pipe_policy_t PipePolicy; /* Endpoint policy */ 199 bool fIsocPolling; /* Whether Isoc. IN polling is enabled */ 200 list_t hIsocInUrbs; /* Isoc. IN inflight URBs */ 201 uint16_t cIsocInUrbs; /* Number of Isoc. IN inflight URBs */ 214 202 list_t hIsocInLandedReqs; /* Isoc. IN landed requests */ 215 203 uint16_t cbIsocInLandedReqs; /* Cumulative size of landed Isoc. IN requests */ 216 size_t cbMaxIsocData; /* Maximum size of Isoc. IN landed buffer */204 size_t cbMaxIsocData; /* Maximum size of Isoc. IN landed buffer */ 217 205 } vboxusb_ep_t; 218 206 … … 222 210 typedef struct vboxusb_isoc_req_t 223 211 { 224 mblk_t *pMsg; /* Pointer to the data buffer */225 uint32_t cIsocPkts; /* Number of Isoc pkts */226 VUSBISOC_PKT_DESC aIsocPkts[8]; /* Array of Isoc pkt descriptors */212 mblk_t *pMsg; /* Pointer to the data buffer */ 213 uint32_t cIsocPkts; /* Number of Isoc pkts */ 214 VUSBISOC_PKT_DESC aIsocPkts[8]; /* Array of Isoc pkt descriptors */ 227 215 list_node_t hListLink; 228 216 } vboxusb_isoc_req_t; … … 243 231 typedef struct vboxusb_urb_t 244 232 { 245 void *pvUrbR3; /* Userspace URB address (untouched, returned while reaping) */246 uint8_t bEndpoint; /* Endpoint address */247 VUSBXFERTYPE enmType; /* Xfer type */248 VUSBDIRECTION enmDir; /* Xfer direction */249 VUSBSTATUS enmStatus; /* URB status */250 bool fShortOk; /* Whether receiving less data than requested is acceptable.*/251 RTR3PTR pvDataR3; /* Userspace address of the original data buffer */252 size_t cbDataR3; /* Size of the data buffer */253 mblk_t *pMsg; /* Pointer to the data buffer */254 uint32_t cIsocPkts; /* Number of Isoc pkts */255 VUSBISOC_PKT_DESC aIsocPkts[8]; /* Array of Isoc pkt descriptors */256 VBOXUSB_URB_STATE enmState; /* Whether free/in-flight etc. */257 struct vboxusb_state_t *pState; /* Pointer to the device instance */258 list_node_t hListLink; /* List node link handle */233 void *pvUrbR3; /* Userspace URB address (untouched, returned while reaping) */ 234 uint8_t bEndpoint; /* Endpoint address */ 235 VUSBXFERTYPE enmType; /* Xfer type */ 236 VUSBDIRECTION enmDir; /* Xfer direction */ 237 VUSBSTATUS enmStatus; /* URB status */ 238 bool fShortOk; /* Whether receiving less data than requested is acceptable */ 239 RTR3PTR pvDataR3; /* Userspace address of the original data buffer */ 240 size_t cbDataR3; /* Size of the data buffer */ 241 mblk_t *pMsg; /* Pointer to the data buffer */ 242 uint32_t cIsocPkts; /* Number of Isoc pkts */ 243 VUSBISOC_PKT_DESC aIsocPkts[8]; /* Array of Isoc pkt descriptors */ 244 VBOXUSB_URB_STATE enmState; /* URB state (free/in-flight/landed). */ 245 struct vboxusb_state_t *pState; /* Pointer to the device instance */ 246 list_node_t hListLink; /* List node link handle */ 259 247 } vboxusb_urb_t; 260 248 … … 264 252 typedef struct vboxusb_power_t 265 253 { 266 uint_t PowerStates; /* Bit mask of the power states */267 int PowerBusy; /* Busycounter */268 bool fPowerWakeup; /* Whether remote power wakeup is enabled */269 bool fPowerRaise; /* Whether to raise the power level */270 uint8_t PowerLevel; /* Current power level */254 uint_t PowerStates; /* Bit mask of the power states */ 255 int PowerBusy; /* Busy reference counter */ 256 bool fPowerWakeup; /* Whether remote power wakeup is enabled */ 257 bool fPowerRaise; /* Whether to raise the power level */ 258 uint8_t PowerLevel; /* Current power level */ 271 259 } vboxusb_power_t; 272 260 … … 276 264 typedef struct vboxusb_state_t 277 265 { 278 dev_info_t *pDip; /* Per instance device info. */ 279 usb_client_dev_data_t *pDevDesc; /* Parsed & complete device descriptor */ 280 uint8_t DevState; /* Current USB Device state */ 281 bool fClosed; /* Whether the device (default control pipe) is closed */ 282 bool fRestoreCfg; /* Whether we changed configs to restore while tearing down */ 283 bool fGetCfgReqDone; /* First GET_CONFIG request has been circumvented */ 284 kmutex_t Mtx; /* Mutex state protection */ 285 usb_serialization_t StateMulti; /* State serialization */ 286 size_t cbMaxBulkXfer; /* Maximum bulk xfer size */ 287 vboxusb_ep_t aEps[VBOXUSB_MAX_ENDPOINTS]; /* All endpoints structures */ 288 list_t hUrbs; /* Handle to list of free/inflight URBs */ 289 list_t hLandedUrbs; /* Handle to list of landed URBs */ 290 uint16_t cInflightUrbs; /* Number of inflight URBs. */ 291 pollhead_t PollHead; /* Handle to pollhead for waking polling processes */ 292 int fPoll; /* Polling status flag */ 293 RTPROCESS Process; /* The process (id) of the session */ 294 VBOXUSBREQ_CLIENT_INFO ClientInfo; /* Registration data */ 295 vboxusb_power_t *pPower; /* Power Management */ 266 dev_info_t *pDip; /* Per instance device info. */ 267 usb_client_dev_data_t *pDevDesc; /* Parsed & complete device descriptor */ 268 uint8_t DevState; /* Current USB Device state */ 269 bool fDefaultPipeOpen; /* Whether the device (default control pipe) is closed */ 270 bool fPollPending; /* Whether the userland process' poll is pending */ 271 kmutex_t Mtx; /* Mutex state protection */ 272 usb_serialization_t StateMulti; /* State serialization */ 273 size_t cbMaxBulkXfer; /* Maximum bulk xfer size */ 274 vboxusb_ep_t aEps[VBOXUSB_MAX_ENDPOINTS]; /* Array of all endpoints structures */ 275 list_t hFreeUrbs; /* List of free URBs */ 276 list_t hInflightUrbs; /* List of inflight URBs */ 277 list_t hLandedUrbs; /* List of landed URBs */ 278 uint32_t cFreeUrbs; /* Number of free URBs */ 279 uint32_t cInflightUrbs; /* Number of inflight URBs */ 280 uint32_t cLandedUrbs; /* Number of landed URBs */ 281 pollhead_t PollHead; /* Handle to pollhead for waking polling processes */ 282 RTPROCESS Process; /* The process (pid) of the user session */ 283 VBOXUSBREQ_CLIENT_INFO ClientInfo; /* Registration data */ 284 vboxusb_power_t *pPower; /* Power Management */ 285 char szMfg[255]; /* Parsed manufacturer string */ 286 char szProduct[255]; /* Parsed product string */ 296 287 } vboxusb_state_t; 288 AssertCompileMemberSize(vboxusb_state_t, szMfg, USB_MAXSTRINGLEN); 289 AssertCompileMemberSize(vboxusb_state_t, szProduct, USB_MAXSTRINGLEN); 297 290 298 291 … … 300 293 * Internal Functions * 301 294 *********************************************************************************************************************************/ 302 LOCAL int vboxUSBSolarisInitEndPoint(vboxusb_state_t *pState, usb_ep_data_t *pEpData, uchar_t uCfgValue, 303 uchar_t uInterface, uchar_t uAlt); 304 LOCAL int vboxUSBSolarisInitAllEndPoints(vboxusb_state_t *pState); 305 LOCAL int vboxUSBSolarisInitEndPointsForConfig(vboxusb_state_t *pState, uint8_t uCfgIndex); 306 LOCAL int vboxUSBSolarisInitEndPointsForInterfaceAlt(vboxusb_state_t *pState, uint8_t uInterface, uint8_t uAlt); 307 LOCAL void vboxUSBSolarisDestroyAllEndPoints(vboxusb_state_t *pState); 308 LOCAL void vboxUSBSolarisDestroyEndPoint(vboxusb_state_t *pState, vboxusb_ep_t *pEp); 309 LOCAL void vboxUSBSolarisCloseAllPipes(vboxusb_state_t *pState, bool fControlPipe); 310 LOCAL int vboxUSBSolarisOpenPipe(vboxusb_state_t *pState, vboxusb_ep_t *pEp); 311 LOCAL void vboxUSBSolarisClosePipe(vboxusb_state_t *pState, vboxusb_ep_t *pEp); 312 LOCAL int vboxUSBSolarisCtrlXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *pUrb); 313 LOCAL void vboxUSBSolarisCtrlXferCompleted(usb_pipe_handle_t pPipe, usb_ctrl_req_t *pReq); 314 LOCAL int vboxUSBSolarisBulkXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *purb); 315 LOCAL void vboxUSBSolarisBulkXferCompleted(usb_pipe_handle_t pPipe, usb_bulk_req_t *pReq); 316 LOCAL int vboxUSBSolarisIntrXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *pUrb); 317 LOCAL void vboxUSBSolarisIntrXferCompleted(usb_pipe_handle_t pPipe, usb_intr_req_t *pReq); 318 LOCAL int vboxUSBSolarisIsocXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *pUrb); 319 LOCAL void vboxUSBSolarisIsocInXferCompleted(usb_pipe_handle_t pPipe, usb_isoc_req_t *pReq); 320 LOCAL void vboxUSBSolarisIsocInXferError(usb_pipe_handle_t pPipe, usb_isoc_req_t *pReq); 321 LOCAL void vboxUSBSolarisIsocOutXferCompleted(usb_pipe_handle_t pPipe, usb_isoc_req_t *pReq); 322 LOCAL vboxusb_urb_t *vboxUSBSolarisGetIsocInURB(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq); 323 LOCAL vboxusb_urb_t *vboxUSBSolarisQueueURB(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq, mblk_t *pMsg); 324 LOCAL inline void vboxUSBSolarisConcatMsg(vboxusb_urb_t *pUrb); 325 LOCAL inline VUSBSTATUS vboxUSBSolarisGetUrbStatus(usb_cr_t Status); 326 LOCAL inline void vboxUSBSolarisDeQueueURB(vboxusb_urb_t *pUrb, int URBStatus); 327 LOCAL inline void vboxUSBSolarisNotifyComplete(vboxusb_state_t *pState); 328 LOCAL int vboxUSBSolarisProcessIOCtl(int iFunction, void *pvState, int Mode, PVBOXUSBREQ pUSBReq, void *pvBuf, 329 size_t *pcbDataOut); 330 LOCAL bool vboxUSBSolarisIsUSBDevice(dev_info_t *pDip); 295 LOCAL int vboxUsbSolarisInitEp(vboxusb_state_t *pState, usb_ep_data_t *pEpData); 296 LOCAL int vboxUsbSolarisInitEpsForCfg(vboxusb_state_t *pState); 297 LOCAL int vboxUsbSolarisInitEpsForIfAlt(vboxusb_state_t *pState, uint8_t bIf, uint8_t bAlt); 298 LOCAL void vboxUsbSolarisDestroyAllEps(vboxusb_state_t *pState); 299 LOCAL void vboxUsbSolarisDestroyEp(vboxusb_state_t *pState, vboxusb_ep_t *pEp); 300 LOCAL void vboxUsbSolarisCloseAllPipes(vboxusb_state_t *pState, bool fControlPipe); 301 LOCAL int vboxUsbSolarisOpenPipe(vboxusb_state_t *pState, vboxusb_ep_t *pEp); 302 LOCAL void vboxUsbSolarisClosePipe(vboxusb_state_t *pState, vboxusb_ep_t *pEp); 303 LOCAL int vboxUsbSolarisCtrlXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *pUrb); 304 LOCAL void vboxUsbSolarisCtrlXferCompleted(usb_pipe_handle_t pPipe, usb_ctrl_req_t *pReq); 305 LOCAL int vboxUsbSolarisBulkXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *purb); 306 LOCAL void vboxUsbSolarisBulkXferCompleted(usb_pipe_handle_t pPipe, usb_bulk_req_t *pReq); 307 LOCAL int vboxUsbSolarisIntrXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *pUrb); 308 LOCAL void vboxUsbSolarisIntrXferCompleted(usb_pipe_handle_t pPipe, usb_intr_req_t *pReq); 309 LOCAL int vboxUsbSolarisIsocXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *pUrb); 310 LOCAL void vboxUsbSolarisIsocInXferCompleted(usb_pipe_handle_t pPipe, usb_isoc_req_t *pReq); 311 LOCAL void vboxUsbSolarisIsocInXferError(usb_pipe_handle_t pPipe, usb_isoc_req_t *pReq); 312 LOCAL void vboxUsbSolarisIsocOutXferCompleted(usb_pipe_handle_t pPipe, usb_isoc_req_t *pReq); 313 LOCAL vboxusb_urb_t *vboxUsbSolarisGetIsocInUrb(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq); 314 LOCAL vboxusb_urb_t *vboxUsbSolarisQueueUrb(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq, mblk_t *pMsg); 315 LOCAL VUSBSTATUS vboxUsbSolarisGetUrbStatus(usb_cr_t Status); 316 LOCAL void vboxUsbSolarisConcatMsg(vboxusb_urb_t *pUrb); 317 LOCAL void vboxUsbSolarisDeQueueUrb(vboxusb_urb_t *pUrb, int URBStatus); 318 LOCAL void vboxUsbSolarisNotifyComplete(vboxusb_state_t *pState); 319 LOCAL int vboxUsbSolarisProcessIOCtl(int iFunction, void *pvState, int Mode, PVBOXUSBREQ pUSBReq, void *pvBuf, 320 size_t *pcbDataOut); 321 LOCAL bool vboxUsbSolarisIsUSBDevice(dev_info_t *pDip); 331 322 332 323 /** @name Device Operation Hooks 333 324 * @{ */ 334 LOCAL int vboxUSBSolarisSendURB(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq, int Mode);335 LOCAL int vboxUSBSolarisReapURB(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq, int Mode);336 LOCAL int vboxUSBSolarisClearEndPoint(vboxusb_state_t *pState, uint8_t bEndpoint);337 LOCAL int vboxUSBSolarisSetConfig(vboxusb_state_t *pState, uint8_t bCfgValue);338 LOCAL int vboxUSBSolarisGetConfig(vboxusb_state_t *pState, uint8_t *pCfgValue);339 LOCAL int vboxUSBSolarisSetInterface(vboxusb_state_t *pState, uint8_t uInterface, uint8_t uAlt);340 LOCAL int vboxUSBSolarisCloseDevice(vboxusb_state_t *pState, VBOXUSB_RESET_LEVEL enmReset);341 LOCAL int vboxUSBSolarisAbortPipe(vboxusb_state_t *pState, uint8_t bEndpoint);342 LOCAL int vboxUSBSolarisGetConfigIndex(vboxusb_state_t *pState, uint_t uCfgValue);325 LOCAL int vboxUsbSolarisSendUrb(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq, int Mode); 326 LOCAL int vboxUsbSolarisReapUrb(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq, int Mode); 327 LOCAL int vboxUsbSolarisClearEndPoint(vboxusb_state_t *pState, uint8_t bEndpoint); 328 LOCAL int vboxUsbSolarisSetConfig(vboxusb_state_t *pState, uint8_t bCfgValue); 329 LOCAL int vboxUsbSolarisGetConfig(vboxusb_state_t *pState, uint8_t *pCfgValue); 330 LOCAL int vboxUsbSolarisSetInterface(vboxusb_state_t *pState, uint8_t bIf, uint8_t bAlt); 331 LOCAL int vboxUsbSolarisCloseDevice(vboxusb_state_t *pState, VBOXUSB_RESET_LEVEL enmReset); 332 LOCAL int vboxUsbSolarisAbortPipe(vboxusb_state_t *pState, uint8_t bEndpoint); 333 LOCAL int vboxUsbSolarisGetConfigIndex(vboxusb_state_t *pState, uint_t bCfgValue); 343 334 /** @} */ 344 335 345 336 /** @name Hotplug & Power Management Hooks 346 337 * @{ */ 347 LOCAL inline void vboxUSBSolarisNotifyHotplug(vboxusb_state_t *pState);348 LOCAL int vboxUSBSolarisDeviceDisconnected(dev_info_t *pDip);349 LOCAL int vboxUSBSolarisDeviceReconnected(dev_info_t *pDip);350 351 LOCAL int vboxUSBSolarisInitPower(vboxusb_state_t *pState);352 LOCAL void vboxUSBSolarisDestroyPower(vboxusb_state_t *pState);353 LOCAL int vboxUSBSolarisDeviceSuspend(vboxusb_state_t *pState);354 LOCAL void vboxUSBSolarisDeviceResume(vboxusb_state_t *pState);355 LOCAL void vboxUSBSolarisDeviceRestore(vboxusb_state_t *pState);356 LOCAL void vboxUSBSolarisPowerBusy(vboxusb_state_t *pState);357 LOCAL void vboxUSBSolarisPowerIdle(vboxusb_state_t *pState);338 LOCAL void vboxUsbSolarisNotifyUnplug(vboxusb_state_t *pState); 339 LOCAL int vboxUsbSolarisDeviceDisconnected(dev_info_t *pDip); 340 LOCAL int vboxUsbSolarisDeviceReconnected(dev_info_t *pDip); 341 342 LOCAL int vboxUsbSolarisInitPower(vboxusb_state_t *pState); 343 LOCAL void vboxUsbSolarisDestroyPower(vboxusb_state_t *pState); 344 LOCAL int vboxUsbSolarisDeviceSuspend(vboxusb_state_t *pState); 345 LOCAL void vboxUsbSolarisDeviceResume(vboxusb_state_t *pState); 346 LOCAL void vboxUsbSolarisDeviceRestore(vboxusb_state_t *pState); 347 LOCAL void vboxUsbSolarisPowerBusy(vboxusb_state_t *pState); 348 LOCAL void vboxUsbSolarisPowerIdle(vboxusb_state_t *pState); 358 349 /** @} */ 359 350 360 351 /** @name Monitor Hooks 361 352 * @{ */ 362 int VBoxUSBMonSolarisRegisterClient(dev_info_t *pClientDip, PVBOXUSB_CLIENT_INFO pClientInfo);363 int VBoxUSBMonSolarisUnregisterClient(dev_info_t *pClientDip);353 int VBoxUSBMonSolarisRegisterClient(dev_info_t *pClientDip, PVBOXUSB_CLIENT_INFO pClientInfo); 354 int VBoxUSBMonSolarisUnregisterClient(dev_info_t *pClientDip); 364 355 /** @} */ 365 356 366 357 /** @name Callbacks from Monitor 367 358 * @{ */ 368 LOCAL int vboxUSBSolarisSetConsumerCredentials(RTPROCESS Process, int Instance, void *pvReserved);359 LOCAL int vboxUsbSolarisSetConsumerCredentials(RTPROCESS Process, int Instance, void *pvReserved); 369 360 /** @} */ 370 361 … … 377 368 378 369 /** The default endpoint descriptor */ 379 static usb_ep_descr_t g_VBoxUSBSolarisDefaultEpDesc = {7, 5, 0, USB_EP_ATTR_CONTROL, 8, 0}; 380 381 /** Hotplug events */ 382 static usb_event_t g_VBoxUSBSolarisEvents = 383 { 384 vboxUSBSolarisDeviceDisconnected, 385 vboxUSBSolarisDeviceReconnected, 386 NULL, /* presuspend */ 387 NULL /* postresume */ 388 }; 370 static usb_ep_descr_t g_VBoxUSBSolarisDefaultEpDesc = { 7, 5, 0, USB_EP_ATTR_CONTROL, 8, 0 }; 371 372 /** Size of the usb_ep_data_t struct (used to index into data). */ 373 static size_t g_cbUsbEpData = ~0UL; 374 375 /** The offset of usb_ep_data_t::ep_desc. */ 376 static size_t g_offUsbEpDataDescr = ~0UL; 377 378 379 #ifdef LOG_ENABLED 380 /** 381 * Gets the description of an Endpoint's transfer type. 382 * 383 * @param pEp The Endpoint. 384 * @returns The type of the Endpoint. 385 */ 386 static const char *vboxUsbSolarisEpType(vboxusb_ep_t *pEp) 387 { 388 uint8_t uType = VBOXUSB_XFER_TYPE(pEp); 389 switch (uType) 390 { 391 case 0: return "CTRL"; 392 case 1: return "ISOC"; 393 case 2: return "BULK"; 394 default: return "INTR"; 395 } 396 } 397 398 399 /** 400 * Gets the description of an Endpoint's direction. 401 * 402 * @param pEp The Endpoint. 403 * @returns The direction of the Endpoint. 404 */ 405 static const char *vboxUsbSolarisEpDir(vboxusb_ep_t *pEp) 406 { 407 return VBOXUSB_XFER_DIR(pEp) == USB_EP_DIR_IN ? "IN " : "OUT"; 408 } 409 #endif 410 411 412 /** 413 * Caches device strings from the parsed device descriptors. 414 * 415 * @param pState The USB device instance. 416 * 417 * @remarks Must only be called after usb_get_dev_data(). 418 */ 419 static void vboxUsbSolarisGetDeviceStrings(vboxusb_state_t *pState) 420 { 421 AssertReturnVoid(pState); 422 AssertReturnVoid(pState->pDevDesc); 423 424 if (pState->pDevDesc->dev_product) 425 strlcpy(&pState->szMfg[0], pState->pDevDesc->dev_mfg, sizeof(pState->szMfg)); 426 else 427 strlcpy(&pState->szMfg[0], "<Unknown Manufacturer>", sizeof(pState->szMfg)); 428 429 if (pState->pDevDesc->dev_product) 430 strlcpy(&pState->szProduct[0], pState->pDevDesc->dev_product, sizeof(pState->szProduct)); 431 else 432 strlcpy(&pState->szProduct[0], "<Unnamed USB device>", sizeof(pState->szProduct)); 433 } 434 435 436 /** 437 * Queries the necessary symbols at runtime. 438 * 439 * @returns VBox status code. 440 */ 441 LOCAL int vboxUsbSolarisQuerySymbols(void) 442 { 443 RTDBGKRNLINFO hKrnlDbgInfo; 444 int rc = RTR0DbgKrnlInfoOpen(&hKrnlDbgInfo, 0 /* fFlags */); 445 if (RT_SUCCESS(rc)) 446 { 447 /* 448 * Query and sanitize the size of usb_ep_data_t struct. 449 */ 450 size_t cbPrevUsbEpData = g_cbUsbEpData; 451 rc = RTR0DbgKrnlInfoQuerySize(hKrnlDbgInfo, "usba", "usb_ep_data_t", &g_cbUsbEpData); 452 if (RT_FAILURE(rc)) 453 { 454 LogRel(("Failed to query size of \"usb_ep_data_t\" in the \"usba\" module, rc=%Rrc\n", rc)); 455 return rc; 456 } 457 if (g_cbUsbEpData > _4K) 458 { 459 LogRel(("Size of \"usb_ep_data_t\" (%u bytes) seems implausible, too paranoid to continue\n", g_cbUsbEpData)); 460 return VERR_MISMATCH; 461 } 462 463 /* 464 * Query and sanitizie the offset of usb_ep_data_t::ep_descr. 465 */ 466 size_t offPrevUsbEpDataDescr = g_offUsbEpDataDescr; 467 rc = RTR0DbgKrnlInfoQueryMember(hKrnlDbgInfo, "usba", "usb_ep_data_t", "ep_descr", &g_offUsbEpDataDescr); 468 if (RT_FAILURE(rc)) 469 { 470 LogRel(("Failed to query offset of usb_ep_data_t::ep_descr, rc=%Rrc\n", rc)); 471 return rc; 472 } 473 if (g_offUsbEpDataDescr > _4K - sizeof(usb_ep_descr_t)) 474 { 475 LogRel(("Offset of \"ep_desrc\" (%u) seems implausible, too paranoid to continue\n", g_offUsbEpDataDescr)); 476 return VERR_MISMATCH; 477 } 478 479 /* 480 * Log only when it changes / first time, since _init() seems to be called often (e.g. on failed attaches). 481 * cmn_err, CE_CONT and '!' is used to not show the message on console during boot each time. 482 */ 483 if ( cbPrevUsbEpData != g_cbUsbEpData 484 || offPrevUsbEpDataDescr != g_offUsbEpDataDescr) 485 { 486 cmn_err(CE_CONT, "!usba_ep_data_t is %lu bytes\n", g_cbUsbEpData); 487 cmn_err(CE_CONT, "!usba_ep_data_t::ep_descr @ 0x%lx (%ld)\n", g_offUsbEpDataDescr, g_offUsbEpDataDescr); 488 } 489 490 RTR0DbgKrnlInfoRelease(hKrnlDbgInfo); 491 } 492 } 389 493 390 494 … … 394 498 int _init(void) 395 499 { 396 LogFunc((DEVICE_NAME ": _init\n"));500 LogFunc((DEVICE_NAME ": _init\n")); 397 501 398 502 /* … … 403 507 pModCtl->mod_loadflags |= MOD_NOAUTOUNLOAD; 404 508 else 405 LogRel((DEVICE_NAME ": failed to disable autounloading!\n"));509 LogRel((DEVICE_NAME ": _init: failed to disable autounloading!\n")); 406 510 407 511 /* … … 411 515 if (RT_SUCCESS(rc)) 412 516 { 517 rc = vboxUsbSolarisQuerySymbols(); 518 if (RT_FAILURE(rc)) 519 return EINVAL; 520 413 521 rc = ddi_soft_state_init(&g_pVBoxUSBSolarisState, sizeof(vboxusb_state_t), 4 /* pre-alloc */); 414 522 if (!rc) … … 418 526 return rc; 419 527 420 LogRel((DEVICE_NAME ": mod_install failed! rc=%d\n", rc));528 LogRel((DEVICE_NAME ": _init: mod_install failed! rc=%d\n", rc)); 421 529 ddi_soft_state_fini(&g_pVBoxUSBSolarisState); 422 530 } 423 531 else 424 LogRel((DEVICE_NAME ": failed to initialize soft state.\n"));532 LogRel((DEVICE_NAME ": _init: failed to initialize soft state\n")); 425 533 426 534 RTR0Term(); 427 535 } 428 536 else 429 LogRel((DEVICE_NAME ": RTR0Init failed! rc=%d\n", rc));537 LogRel((DEVICE_NAME ": _init: RTR0Init failed! rc=%d\n", rc)); 430 538 return RTErrConvertToErrno(rc); 431 539 } … … 436 544 int rc; 437 545 438 LogFunc((DEVICE_NAME ": _fini\n"));546 LogFunc((DEVICE_NAME ": _fini\n")); 439 547 440 548 rc = mod_remove(&g_VBoxUSBSolarisModLinkage); … … 451 559 int _info(struct modinfo *pModInfo) 452 560 { 453 LogFunc((DEVICE_NAME ": _info\n"));561 LogFunc((DEVICE_NAME ": _info\n")); 454 562 455 563 return mod_info(&g_VBoxUSBSolarisModLinkage, pModInfo); … … 463 571 * @param enmCmd Attach type (ddi_attach_cmd_t) 464 572 * 465 * @returns corresponding solaris error code.573 * @returns Solaris error code. 466 574 */ 467 575 int VBoxUSBSolarisAttach(dev_info_t *pDip, ddi_attach_cmd_t enmCmd) 468 576 { 469 LogFunc((DEVICE_NAME ": VBoxUSBSolarisAttachpDip=%p enmCmd=%d\n", pDip, enmCmd));577 LogFunc((DEVICE_NAME ": VBoxUSBSolarisAttach: pDip=%p enmCmd=%d\n", pDip, enmCmd)); 470 578 471 579 int rc; … … 483 591 if (RT_LIKELY(pState)) 484 592 { 485 pState->pDip = pDip; 486 pState->pDevDesc = NULL; 487 pState->fClosed = false; 488 pState->fRestoreCfg = false; 489 pState->fGetCfgReqDone = false; 593 pState->pDip = pDip; 594 pState->pDevDesc = NULL; 595 pState->fPollPending = false; 596 pState->cInflightUrbs = 0; 597 pState->cFreeUrbs = 0; 598 pState->cLandedUrbs = 0; 599 pState->Process = NIL_RTPROCESS; 600 pState->pPower = NULL; 490 601 bzero(pState->aEps, sizeof(pState->aEps)); 491 list_create(&pState->hUrbs, sizeof(vboxusb_urb_t), offsetof(vboxusb_urb_t, hListLink)); 602 list_create(&pState->hFreeUrbs, sizeof(vboxusb_urb_t), offsetof(vboxusb_urb_t, hListLink)); 603 list_create(&pState->hInflightUrbs, sizeof(vboxusb_urb_t), offsetof(vboxusb_urb_t, hListLink)); 492 604 list_create(&pState->hLandedUrbs, sizeof(vboxusb_urb_t), offsetof(vboxusb_urb_t, hListLink)); 493 pState->cInflightUrbs = 0;494 pState->fPoll = VBOXUSB_POLL_OFF;495 pState->Process = NIL_RTPROCESS;496 pState->pPower = NULL;497 605 498 606 /* … … 500 608 * a non-USB device. So check if we are really binding to a USB device or not. 501 609 */ 502 if (vboxU SBSolarisIsUSBDevice(pState->pDip))610 if (vboxUsbSolarisIsUSBDevice(pState->pDip)) 503 611 { 504 612 /* … … 508 616 if (rc == USB_SUCCESS) 509 617 { 618 pState->fDefaultPipeOpen = true; 619 510 620 /* 511 621 * Parse out the entire descriptor. … … 514 624 if (rc == USB_SUCCESS) 515 625 { 626 /* 627 * Cache some device descriptor strings. 628 */ 629 vboxUsbSolarisGetDeviceStrings(pState); 516 630 #ifdef DEBUG_ramshankar 517 631 usb_print_descr_tree(pState->pDip, pState->pDevDesc); … … 530 644 if (rc == USB_SUCCESS) 531 645 { 532 Log((DEVICE_NAME ": VBoxUSBSolarisAttachcbMaxBulkXfer=%d\n", pState->cbMaxBulkXfer));646 Log((DEVICE_NAME ": VBoxUSBSolarisAttach: cbMaxBulkXfer=%d\n", pState->cbMaxBulkXfer)); 533 647 534 648 /* 535 * Initialize all endpoints.649 * Initialize the default endpoint. 536 650 */ 537 rc = vboxU SBSolarisInitAllEndPoints(pState);651 rc = vboxUsbSolarisInitEp(pState, NULL /* pEp */); 538 652 if (RT_SUCCESS(rc)) 539 653 { … … 546 660 * Initialize power management for the device. 547 661 */ 548 rc = vboxU SBSolarisInitPower(pState);662 rc = vboxUsbSolarisInitPower(pState); 549 663 if (RT_SUCCESS(rc)) 550 664 { 551 665 /* 552 * Update endpoints (descriptors)for the current config.666 * Initialize endpoints for the current config. 553 667 */ 554 vboxUSBSolarisInitEndPointsForConfig(pState, usb_get_current_cfgidx(pState->pDip)); 668 rc = vboxUsbSolarisInitEpsForCfg(pState); 669 AssertRC(rc); 555 670 556 671 /* … … 564 679 * Register hotplug callbacks. 565 680 */ 566 rc = usb_register_event_cbs(pState->pDip, &g_VBoxUSBSolarisEvents, 0 /* flags */); 681 rc = usb_register_hotplug_cbs(pState->pDip, &vboxUsbSolarisDeviceDisconnected, 682 &vboxUsbSolarisDeviceReconnected); 567 683 if (RT_LIKELY(rc == USB_SUCCESS)) 568 684 { … … 575 691 RTStrPrintf(pState->ClientInfo.szClientPath, 576 692 sizeof(pState->ClientInfo.szClientPath), 577 "/devices%s:%s", szDevicePath,DEVICE_NAME); 578 RTPathStripFilename(szDevicePath); 693 "/devices%s:%s", szDevicePath, DEVICE_NAME); 579 694 RTStrPrintf(pState->ClientInfo.szDeviceIdent, 580 695 sizeof(pState->ClientInfo.szDeviceIdent), … … 584 699 pState->pDevDesc->dev_descr->bcdDevice, szDevicePath); 585 700 pState->ClientInfo.Instance = instance; 586 pState->ClientInfo.pfnSetConsumerCredentials = &vboxU SBSolarisSetConsumerCredentials;701 pState->ClientInfo.pfnSetConsumerCredentials = &vboxUsbSolarisSetConsumerCredentials; 587 702 rc = VBoxUSBMonSolarisRegisterClient(pState->pDip, &pState->ClientInfo); 588 703 if (RT_SUCCESS(rc)) 589 704 { 590 LogRel((DEVICE_NAME ": Captured %s %#x:%#x:%d:%s\n", 591 pState->pDevDesc->dev_product ? pState->pDevDesc->dev_product 592 : "<Unnamed USB device>", 593 pState->pDevDesc->dev_descr->idVendor, 594 pState->pDevDesc->dev_descr->idProduct, 595 pState->pDevDesc->dev_descr->bcdDevice, 596 pState->ClientInfo.szClientPath)); 597 705 LogRel((DEVICE_NAME ": Captured %s %s (Ident=%s)\n", pState->szMfg, 706 pState->szProduct, pState->ClientInfo.szDeviceIdent)); 598 707 return DDI_SUCCESS; 599 708 } 600 else 601 { 602 LogRel((DEVICE_NAME ":VBoxUSBMonSolarisRegisterClient failed! rc=%d " 603 "path=%s instance=%d\n", rc, pState->ClientInfo.szClientPath, 604 instance)); 605 } 606 607 usb_unregister_event_cbs(pState->pDip, &g_VBoxUSBSolarisEvents); 709 710 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisRegisterClient failed! rc=%d " 711 "path=%s instance=%d\n", rc, pState->ClientInfo.szClientPath, 712 instance)); 713 714 usb_unregister_hotplug_cbs(pState->pDip); 608 715 } 609 716 else 610 LogRel((DEVICE_NAME ":VBoxUSBSolarisAttach failed to register hotplug " 611 "callbacks! rc=%d\n", rc)); 717 LogRel((DEVICE_NAME ": VBoxUSBSolarisAttach: Failed to register hotplug callbacks! rc=%d\n", rc)); 612 718 613 719 ddi_remove_minor_node(pState->pDip, NULL); 614 720 } 615 721 else 616 { 617 LogRel((DEVICE_NAME ":VBoxUSBSolarisAttach ddi_create_minor_node failed! rc=%d\n", 618 rc)); 619 } 722 LogRel((DEVICE_NAME ": VBoxUSBSolarisAttach: ddi_create_minor_node failed! rc=%d\n", rc)); 723 724 mutex_enter(&pState->Mtx); 725 vboxUsbSolarisDestroyPower(pState); 726 mutex_exit(&pState->Mtx); 620 727 } 621 728 else 622 { 623 LogRel((DEVICE_NAME ":VBoxUSBSolarisAttach failed to initialize power management! " 624 "rc=%d\n", rc)); 625 } 729 LogRel((DEVICE_NAME ": VBoxUSBSolarisAttach: Failed to init power management! rc=%d\n", rc)); 626 730 } 627 731 else 628 { 629 LogRel((DEVICE_NAME ":VBoxUSBSolarisAttach vboxUSBSolarisInitAllEndPoints failed! " 630 "rc=%d\n")); 631 } 732 LogRel((DEVICE_NAME ": VBoxUSBSolarisAttach: vboxUsbSolarisInitEp failed! rc=%d\n", rc)); 632 733 } 633 734 else 634 { 635 LogRel((DEVICE_NAME ":VBoxUSBSolarisAttach usb_pipe_get_max_bulk_transfer_size failed! " 636 "rc=%d\n", rc)); 637 } 735 LogRel((DEVICE_NAME ": VBoxUSBSolarisAttach: usb_pipe_get_max_bulk_transfer_size failed! rc=%d\n", rc)); 638 736 639 737 usb_fini_serialization(pState->StateMulti); … … 642 740 } 643 741 else 644 LogRel((DEVICE_NAME ": VBoxUSBSolarisAttach failed to get device descriptor. rc=%d\n", rc));742 LogRel((DEVICE_NAME ": VBoxUSBSolarisAttach: Failed to get device descriptor. rc=%d\n", rc)); 645 743 646 744 usb_client_detach(pState->pDip, NULL); 647 745 } 648 746 else 649 LogRel((DEVICE_NAME ": VBoxUSBSolarisAttachusb_client_attach failed! rc=%d\n", rc));747 LogRel((DEVICE_NAME ": VBoxUSBSolarisAttach: usb_client_attach failed! rc=%d\n", rc)); 650 748 } 651 749 else 652 750 { 653 751 /* This would appear on every boot if it were LogRel() */ 654 Log((DEVICE_NAME ": VBoxUSBSolarisAttach not a USB device.\n"));752 Log((DEVICE_NAME ": VBoxUSBSolarisAttach: Not a USB device\n")); 655 753 } 656 754 } 657 755 else 658 LogRel((DEVICE_NAME ": VBoxUSBSolarisAttach failed to get soft state\n", sizeof(*pState)));756 LogRel((DEVICE_NAME ": VBoxUSBSolarisAttach: Failed to get soft state\n", sizeof(*pState))); 659 757 660 758 ddi_soft_state_free(g_pVBoxUSBSolarisState, instance); 661 759 } 662 760 else 663 LogRel((DEVICE_NAME ": VBoxUSBSolarisAttach failed to alloc soft state. rc=%d\n", rc));761 LogRel((DEVICE_NAME ": VBoxUSBSolarisAttach: Failed to alloc soft state. rc=%d\n", rc)); 664 762 665 763 return DDI_FAILURE; … … 671 769 if (RT_UNLIKELY(!pState)) 672 770 { 673 LogRel((DEVICE_NAME ": VBoxUSBSolarisAttach DDI_RESUME: failed to get soft state on detach.\n"));771 LogRel((DEVICE_NAME ": VBoxUSBSolarisAttach: DDI_RESUME failed to get soft state on detach\n")); 674 772 return DDI_FAILURE; 675 773 } 676 774 677 vboxU SBSolarisDeviceResume(pState);775 vboxUsbSolarisDeviceResume(pState); 678 776 return DDI_SUCCESS; 679 777 } … … 691 789 * @param enmCmd Attach type (ddi_attach_cmd_t) 692 790 * 693 * @returns corresponding solaris error code.791 * @returns Solaris error code. 694 792 */ 695 793 int VBoxUSBSolarisDetach(dev_info_t *pDip, ddi_detach_cmd_t enmCmd) 696 794 { 697 LogFunc((DEVICE_NAME ": VBoxUSBSolarisDetachpDip=%p enmCmd=%d\n", pDip, enmCmd));795 LogFunc((DEVICE_NAME ": VBoxUSBSolarisDetach: pDip=%p enmCmd=%d\n", pDip, enmCmd)); 698 796 699 797 int instance = ddi_get_instance(pDip); … … 701 799 if (RT_UNLIKELY(!pState)) 702 800 { 703 LogRel((DEVICE_NAME ": VBoxUSBSolarisDetach failed to get soft state on detach.\n"));801 LogRel((DEVICE_NAME ": VBoxUSBSolarisDetach: Failed to get soft state on detach\n")); 704 802 return DDI_FAILURE; 705 803 } … … 718 816 * Notify userland if any that we're gone (while resetting device held by us). 719 817 */ 720 vboxUSBSolarisNotifyHotplug(pState); 818 mutex_enter(&pState->Mtx); 819 pState->DevState = USB_DEV_DISCONNECTED; 820 vboxUsbSolarisNotifyUnplug(pState); 821 mutex_exit(&pState->Mtx); 822 721 823 722 824 /* … … 724 826 * would otherwise block on the mutex. 725 827 */ 726 usb_unregister_event_cbs(pDip, &g_VBoxUSBSolarisEvents); 727 828 usb_unregister_hotplug_cbs(pDip); 728 829 729 830 /* 730 831 * Serialize: paranoid; drain other driver activity. 731 832 */ 732 usb_serialize_access(pState->StateMulti, USB_WAIT, 0 );833 usb_serialize_access(pState->StateMulti, USB_WAIT, 0 /* timeout */); 733 834 usb_release_access(pState->StateMulti); 734 835 mutex_enter(&pState->Mtx); 735 836 736 837 /* 737 * Close all endpoints.838 * Close all pipes. 738 839 */ 739 vboxU SBSolarisCloseAllPipes(pState, true /* ControlPipe */);740 pState->fClosed = true;840 vboxUsbSolarisCloseAllPipes(pState, true /* ControlPipe */); 841 Assert(!pState->fDefaultPipeOpen); 741 842 742 843 /* 743 * Deinitialize power, destroy endpoints.844 * Deinitialize power, destroy all endpoints. 744 845 */ 745 vboxU SBSolarisDestroyPower(pState);746 vboxU SBSolarisDestroyAllEndPoints(pState);846 vboxUsbSolarisDestroyPower(pState); 847 vboxUsbSolarisDestroyAllEps(pState); 747 848 748 849 /* 749 * Free up all URB s.850 * Free up all URB lists. 750 851 */ 751 852 vboxusb_urb_t *pUrb = NULL; 752 while ((pUrb = list_remove_head(&pState->h Urbs)) != NULL)853 while ((pUrb = list_remove_head(&pState->hFreeUrbs)) != NULL) 753 854 { 754 855 if (pUrb->pMsg) … … 756 857 RTMemFree(pUrb); 757 858 } 758 859 while ((pUrb = list_remove_head(&pState->hInflightUrbs)) != NULL) 860 { 861 if (pUrb->pMsg) 862 freemsg(pUrb->pMsg); 863 RTMemFree(pUrb); 864 } 759 865 while ((pUrb = list_remove_head(&pState->hLandedUrbs)) != NULL) 760 866 { … … 763 869 RTMemFree(pUrb); 764 870 } 871 pState->cFreeUrbs = 0; 872 pState->cLandedUrbs = 0; 765 873 pState->cInflightUrbs = 0; 766 list_destroy(&pState->hUrbs); 874 list_destroy(&pState->hFreeUrbs); 875 list_destroy(&pState->hInflightUrbs); 767 876 list_destroy(&pState->hLandedUrbs); 768 877 … … 784 893 ddi_remove_minor_node(pState->pDip, NULL); 785 894 786 LogRel((DEVICE_NAME ": Released %s %s\n", 787 pState->pDevDesc->dev_product ? pState->pDevDesc->dev_product : "<Unnamed USB device>", 895 LogRel((DEVICE_NAME ": Released %s %s (Ident=%s)\n", pState->szMfg, pState->szProduct, 788 896 pState->ClientInfo.szDeviceIdent)); 789 897 790 898 ddi_soft_state_free(g_pVBoxUSBSolarisState, instance); 791 899 pState = NULL; 792 793 900 return DDI_SUCCESS; 794 901 } … … 796 903 case DDI_SUSPEND: 797 904 { 798 int rc = vboxU SBSolarisDeviceSuspend(pState);905 int rc = vboxUsbSolarisDeviceSuspend(pState); 799 906 if (RT_SUCCESS(rc)) 800 907 return DDI_SUCCESS; … … 817 924 * @param ppvResult Where to store the requested info. 818 925 * 819 * @returns corresponding solaris error code.926 * @returns Solaris error code. 820 927 */ 821 928 int VBoxUSBSolarisGetInfo(dev_info_t *pDip, ddi_info_cmd_t enmCmd, void *pvArg, void **ppvResult) 822 929 { 823 LogFunc((DEVICE_NAME ": VBoxUSBSolarisGetInfo\n"));930 LogFunc((DEVICE_NAME ": VBoxUSBSolarisGetInfo\n")); 824 931 825 932 vboxusb_state_t *pState = NULL; … … 840 947 } 841 948 else 842 LogRel((DEVICE_NAME ": VBoxUSBSolarisGetInfo failed to get device state.\n"));949 LogRel((DEVICE_NAME ": VBoxUSBSolarisGetInfo: Failed to get device state\n")); 843 950 return DDI_FAILURE; 844 951 } … … 857 964 858 965 /** 859 * Callback invoked from the Monitor driver when a VM process tries to access 860 * this client instance. This determines which VM process will be allowed to 861 * open and access the USB device. 966 * Callback invoked from the VirtualBox USB Monitor driver when a VM process 967 * tries to access this USB client instance. 968 * 969 * This determines which VM process will be allowed to open and access this USB 970 * device. 862 971 * 863 972 * @returns VBox status code. … … 868 977 * @param pvReserved Reserved for future, unused. 869 978 */ 870 LOCAL int vboxU SBSolarisSetConsumerCredentials(RTPROCESS Process, int Instance, void *pvReserved)871 { 872 LogFunc((DEVICE_NAME ": vboxUSBSolarisSetConsumerCredentialsProcess=%u Instance=%d\n", Process, Instance));979 LOCAL int vboxUsbSolarisSetConsumerCredentials(RTPROCESS Process, int Instance, void *pvReserved) 980 { 981 LogFunc((DEVICE_NAME ": vboxUsbSolarisSetConsumerCredentials: Process=%u Instance=%d\n", Process, Instance)); 873 982 vboxusb_state_t *pState = ddi_get_soft_state(g_pVBoxUSBSolarisState, Instance); 874 983 if (!pState) 875 984 { 876 LogRel((DEVICE_NAME ": vboxUSBSolarisSetConsumerCredentials failed to get device state for instance %d\n", Instance));985 LogRel((DEVICE_NAME ": vboxUsbSolarisSetConsumerCredentials: Failed to get device state for instance %d\n", Instance)); 877 986 return VERR_INVALID_STATE; 878 987 } … … 885 994 else 886 995 { 887 LogRel((DEVICE_NAME ": vboxUSBSolarisSetConsumerCredentials failed! Process %u already has client open.\n",996 LogRel((DEVICE_NAME ": vboxUsbSolarisSetConsumerCredentials: Failed! Process %u already has client open\n", 888 997 pState->Process)); 889 998 rc = VERR_RESOURCE_BUSY; … … 898 1007 int VBoxUSBSolarisOpen(dev_t *pDev, int fFlag, int fType, cred_t *pCred) 899 1008 { 900 LogFunc((DEVICE_NAME ": VBoxUSBSolarisOpenpDev=%p fFlag=%d fType=%d pCred=%p\n", pDev, fFlag, fType, pCred));1009 LogFunc((DEVICE_NAME ": VBoxUSBSolarisOpen: pDev=%p fFlag=%d fType=%d pCred=%p\n", pDev, fFlag, fType, pCred)); 901 1010 902 1011 /* … … 913 1022 if (!pState) 914 1023 { 915 LogRel((DEVICE_NAME ": VBoxUSBSolarisOpen failed to get device state for instance %d\n", instance));1024 LogRel((DEVICE_NAME ": VBoxUSBSolarisOpen: Failed to get device state for instance %d\n", instance)); 916 1025 return ENXIO; 917 1026 } … … 925 1034 { 926 1035 if (pState->Process == NIL_RTPROCESS) 927 LogRel((DEVICE_NAME ": VBoxUSBSolarisOpen No prior information about authorized process.\n"));1036 LogRel((DEVICE_NAME ": VBoxUSBSolarisOpen: No prior information about authorized process\n")); 928 1037 else 929 LogRel((DEVICE_NAME ": VBoxUSBSolarisOpen Process %u is already using this device instance.\n", pState->Process));1038 LogRel((DEVICE_NAME ": VBoxUSBSolarisOpen: Process %u is already using this device instance\n", pState->Process)); 930 1039 931 1040 mutex_exit(&pState->Mtx); … … 933 1042 } 934 1043 935 pState->fPoll = VBOXUSB_POLL_ON;936 937 1044 mutex_exit(&pState->Mtx); 938 1045 … … 946 1053 int VBoxUSBSolarisClose(dev_t Dev, int fFlag, int fType, cred_t *pCred) 947 1054 { 948 LogFunc((DEVICE_NAME ": VBoxUSBSolarisCloseDev=%d fFlag=%d fType=%d pCred=%p\n", Dev, fFlag, fType, pCred));1055 LogFunc((DEVICE_NAME ": VBoxUSBSolarisClose: Dev=%d fFlag=%d fType=%d pCred=%p\n", Dev, fFlag, fType, pCred)); 949 1056 950 1057 int instance = getminor((dev_t)Dev); … … 952 1059 if (RT_UNLIKELY(!pState)) 953 1060 { 954 LogRel((DEVICE_NAME ": VBoxUSBSolarisClose failed to get device state for instance %d\n", instance));1061 LogRel((DEVICE_NAME ": VBoxUSBSolarisClose: Failed to get device state for instance %d\n", instance)); 955 1062 return ENXIO; 956 1063 } 957 1064 958 1065 mutex_enter(&pState->Mtx); 959 pState->fPoll = VBOXUSB_POLL_OFF;960 pState->Process = NIL_RTPROCESS;1066 pState->fPollPending = false; 1067 pState->Process = NIL_RTPROCESS; 961 1068 mutex_exit(&pState->Mtx); 962 1069 … … 967 1074 int VBoxUSBSolarisRead(dev_t Dev, struct uio *pUio, cred_t *pCred) 968 1075 { 969 LogFunc((DEVICE_NAME ": VBoxUSBSolarisRead\n"));1076 LogFunc((DEVICE_NAME ": VBoxUSBSolarisRead\n")); 970 1077 return ENOTSUP; 971 1078 } … … 974 1081 int VBoxUSBSolarisWrite(dev_t Dev, struct uio *pUio, cred_t *pCred) 975 1082 { 976 LogFunc((DEVICE_NAME ": VBoxUSBSolarisWrite\n"));1083 LogFunc((DEVICE_NAME ": VBoxUSBSolarisWrite\n")); 977 1084 return ENOTSUP; 978 1085 } … … 981 1088 int VBoxUSBSolarisPoll(dev_t Dev, short fEvents, int fAnyYet, short *pReqEvents, struct pollhead **ppPollHead) 982 1089 { 983 LogFunc((DEVICE_NAME ": VBoxUSBSolarisPollDev=%d fEvents=%d fAnyYet=%d pReqEvents=%p\n", Dev, fEvents, fAnyYet, pReqEvents));1090 LogFunc((DEVICE_NAME ": VBoxUSBSolarisPoll: Dev=%d fEvents=%d fAnyYet=%d pReqEvents=%p\n", Dev, fEvents, fAnyYet, pReqEvents)); 984 1091 985 1092 /* … … 990 1097 if (RT_UNLIKELY(!pState)) 991 1098 { 992 LogRel((DEVICE_NAME ": VBoxUSBSolarisPoll: no state data for %d\n", instance));1099 LogRel((DEVICE_NAME ": VBoxUSBSolarisPoll: No state data for %d\n", instance)); 993 1100 return ENXIO; 994 1101 } … … 997 1104 998 1105 /* 999 * "fEvents" HAS to be POLLIN. We won't bother to test it. The caller 1000 * must always requests input events. Disconnect event (POLLHUP) is invalid in "fEvents". 1106 * Disconnect event (POLLHUP) is invalid in "fEvents". 1001 1107 */ 1002 fEvents = 0; 1003 if (pState->fPoll & VBOXUSB_POLL_DEV_UNPLUGGED) 1004 { 1005 fEvents |= POLLHUP; 1006 pState->fPoll &= ~VBOXUSB_POLL_DEV_UNPLUGGED; 1007 } 1008 1009 if (pState->fPoll & VBOXUSB_POLL_REAP_PENDING) 1010 { 1011 fEvents |= POLLIN; 1012 pState->fPoll &= ~VBOXUSB_POLL_REAP_PENDING; 1013 } 1014 1015 if ( !fEvents 1016 && !fAnyYet) 1017 { 1018 *ppPollHead = &pState->PollHead; 1019 } 1020 1021 *pReqEvents = fEvents; 1108 if (pState->DevState == USB_DEV_DISCONNECTED) 1109 *pReqEvents |= POLLHUP; 1110 else if (pState->cLandedUrbs) 1111 *pReqEvents |= POLLIN; 1112 else 1113 { 1114 *pReqEvents = 0; 1115 if (!fAnyYet) 1116 { 1117 *ppPollHead = &pState->PollHead; 1118 pState->fPollPending = true; 1119 } 1120 } 1022 1121 1023 1122 mutex_exit(&pState->Mtx); … … 1029 1128 int VBoxUSBSolarisPower(dev_info_t *pDip, int Component, int Level) 1030 1129 { 1031 LogFunc((DEVICE_NAME ": VBoxUSBSolarisPowerpDip=%p Component=%d Level=%d\n", pDip, Component, Level));1130 LogFunc((DEVICE_NAME ": VBoxUSBSolarisPower: pDip=%p Component=%d Level=%d\n", pDip, Component, Level)); 1032 1131 1033 1132 int instance = ddi_get_instance(pDip); … … 1035 1134 if (RT_UNLIKELY(!pState)) 1036 1135 { 1037 LogRel((DEVICE_NAME ": VBoxUSBSolarisPower Failed! missing state.\n"));1136 LogRel((DEVICE_NAME ": VBoxUSBSolarisPower: Failed! State Gone\n")); 1038 1137 return DDI_FAILURE; 1039 1138 } … … 1065 1164 pState->pPower->PowerLevel = USB_DEV_OS_PWR_OFF; 1066 1165 mutex_exit(&pState->Mtx); 1067 rc = usb_set_device_pwrlvl3(pDip);1166 rc = USB_SUCCESS; /* usb_set_device_pwrlvl3(pDip); */ 1068 1167 mutex_enter(&pState->Mtx); 1069 1168 break; … … 1077 1176 pState->pPower->PowerLevel = USB_DEV_OS_FULL_PWR; 1078 1177 mutex_exit(&pState->Mtx); 1079 rc = usb_set_device_pwrlvl0(pDip);1178 rc = USB_SUCCESS; /* usb_set_device_pwrlvl0(pDip); */ 1080 1179 mutex_enter(&pState->Mtx); 1081 1180 break; … … 1087 1186 } 1088 1187 else 1089 Log((DEVICE_NAME ": USB_DEV_PWRSTATE_OK failed.\n"));1188 Log((DEVICE_NAME ": VBoxUSBSolarisPower: USB_DEV_PWRSTATE_OK failed\n")); 1090 1189 } 1091 1190 else … … 1108 1207 int VBoxUSBSolarisIOCtl(dev_t Dev, int Cmd, intptr_t pArg, int Mode, cred_t *pCred, int *pVal) 1109 1208 { 1110 /* LogFunc((DEVICE_NAME ":VBoxUSBSolarisIOCtlDev=%d Cmd=%d pArg=%p Mode=%d\n", Dev, Cmd, pArg)); */1209 /* LogFunc((DEVICE_NAME ": VBoxUSBSolarisIOCtl: Dev=%d Cmd=%d pArg=%p Mode=%d\n", Dev, Cmd, pArg)); */ 1111 1210 1112 1211 /* … … 1117 1216 if (RT_UNLIKELY(!pState)) 1118 1217 { 1119 LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: no state data for %d\n", instance));1218 LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: No state data for %d\n", instance)); 1120 1219 return EINVAL; 1121 1220 } … … 1127 1226 if (IOCPARM_LEN(Cmd) != sizeof(ReqWrap)) 1128 1227 { 1129 LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: bad request %#x size=%d expected=%d\n", Cmd, IOCPARM_LEN(Cmd),1228 LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: Bad request %#x size=%d expected=%d\n", Cmd, IOCPARM_LEN(Cmd), 1130 1229 sizeof(ReqWrap))); 1131 1230 return ENOTTY; … … 1135 1234 if (RT_UNLIKELY(rc)) 1136 1235 { 1137 LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: ddi_copyin failed to read header pArg=%p Cmd=%d. rc=%d .\n", pArg, Cmd, rc));1236 LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: ddi_copyin failed to read header pArg=%p Cmd=%d. rc=%d\n", pArg, Cmd, rc)); 1138 1237 return EINVAL; 1139 1238 } … … 1141 1240 if (ReqWrap.u32Magic != VBOXUSB_MAGIC) 1142 1241 { 1143 LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: bad magic %#x; pArg=%p Cmd=%d.\n", ReqWrap.u32Magic, pArg, Cmd));1242 LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: Bad magic %#x; pArg=%p Cmd=%d\n", ReqWrap.u32Magic, pArg, Cmd)); 1144 1243 return EINVAL; 1145 1244 } … … 1147 1246 || ReqWrap.cbData > _1M*16)) 1148 1247 { 1149 LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: bad size %#x; pArg=%p Cmd=%d.\n", ReqWrap.cbData, pArg, Cmd));1248 LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: Bad size %#x; pArg=%p Cmd=%d\n", ReqWrap.cbData, pArg, Cmd)); 1150 1249 return EINVAL; 1151 1250 } … … 1157 1256 if (RT_UNLIKELY(!pvBuf)) 1158 1257 { 1159 LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: RTMemTmpAlloc failed to alloc %d bytes.\n", ReqWrap.cbData));1258 LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: RTMemTmpAlloc failed to alloc %d bytes\n", ReqWrap.cbData)); 1160 1259 return ENOMEM; 1161 1260 } … … 1165 1264 { 1166 1265 RTMemTmpFree(pvBuf); 1167 LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: ddi_copyin failed;pvBuf=%p pArg=%p Cmd=%d. rc=%d\n", pvBuf, pArg, Cmd, rc));1266 LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: ddi_copyin failed! pvBuf=%p pArg=%p Cmd=%d. rc=%d\n", pvBuf, pArg, Cmd, rc)); 1168 1267 return EFAULT; 1169 1268 } … … 1172 1271 { 1173 1272 RTMemTmpFree(pvBuf); 1174 LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: invalid requestpvBuf=%p cbData=%d\n", pvBuf, ReqWrap.cbData));1273 LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: Invalid request! pvBuf=%p cbData=%d\n", pvBuf, ReqWrap.cbData)); 1175 1274 return EINVAL; 1176 1275 } … … 1180 1279 */ 1181 1280 size_t cbDataOut = 0; 1182 rc = vboxU SBSolarisProcessIOCtl(Cmd, pState, Mode, &ReqWrap, pvBuf, &cbDataOut);1281 rc = vboxUsbSolarisProcessIOCtl(Cmd, pState, Mode, &ReqWrap, pvBuf, &cbDataOut); 1183 1282 ReqWrap.rc = rc; 1184 1283 rc = 0; … … 1186 1285 if (RT_UNLIKELY(cbDataOut > ReqWrap.cbData)) 1187 1286 { 1188 LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: too much output data %d expected %d Truncating!\n", cbDataOut,1287 LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: Too much output data %d expected %d Truncating!\n", cbDataOut, 1189 1288 ReqWrap.cbData)); 1190 1289 cbDataOut = ReqWrap.cbData; … … 1207 1306 if (RT_UNLIKELY(rc)) 1208 1307 { 1209 LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: ddi_copyout failed;pvBuf=%p pArg=%p Cmd=%d. rc=%d\n", pvBuf, pArg,1308 LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: ddi_copyout failed! pvBuf=%p pArg=%p Cmd=%d. rc=%d\n", pvBuf, pArg, 1210 1309 Cmd, rc)); 1211 1310 rc = EFAULT; … … 1215 1314 else 1216 1315 { 1217 LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: ddi_copyout(1)failed;pReqWrap=%p pArg=%p Cmd=%d. rc=%d\n", &ReqWrap, pArg,1316 LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: ddi_copyout(1)failed! pReqWrap=%p pArg=%p Cmd=%d. rc=%d\n", &ReqWrap, pArg, 1218 1317 Cmd, rc)); 1219 1318 rc = EFAULT; … … 1238 1337 * @param pcbDataOut Where to store the IOCtl OUT data size. 1239 1338 */ 1240 LOCAL int vboxUSBSolarisProcessIOCtl(int iFunction, void *pvState, int Mode, PVBOXUSBREQ pUSBReq, void *pvBuf, size_t *pcbDataOut) 1241 { 1242 // LogFunc((DEVICE_NAME ":vboxUSBSolarisProcessIOCtl iFunction=%d pvState=%p pUSBReq=%p\n", iFunction, pvState, pUSBReq)); 1339 LOCAL int vboxUsbSolarisProcessIOCtl(int iFunction, void *pvState, int Mode, PVBOXUSBREQ pUSBReq, void *pvBuf, 1340 size_t *pcbDataOut) 1341 { 1342 /* LogFunc((DEVICE_NAME ": vboxUsbSolarisProcessIOCtl: iFunction=%d pvState=%p pUSBReq=%p\n", iFunction, pvState, pUSBReq)); */ 1243 1343 1244 1344 AssertPtrReturn(pvState, VERR_INVALID_PARAMETER); … … 1251 1351 if (cbData < (cbMin)) \ 1252 1352 { \ 1253 LogRel((DEVICE_NAME ": vboxUSBSolarisProcessIOCtl: " mnemonic ": cbData=%#zx (%zu) min is %#zx (%zu)\n", \1353 LogRel((DEVICE_NAME ": vboxUsbSolarisProcessIOCtl: " mnemonic ": cbData=%#zx (%zu) min is %#zx (%zu)\n", \ 1254 1354 cbData, cbData, (size_t)(cbMin), (size_t)(cbMin))); \ 1255 1355 return VERR_BUFFER_OVERFLOW; \ … … 1257 1357 if ((cbMin) != 0 && !VALID_PTR(pvBuf)) \ 1258 1358 { \ 1259 LogRel((DEVICE_NAME ": vboxUSBSolarisProcessIOCtl: " mnemonic ": Invalid pointer %p\n", pvBuf)); \1359 LogRel((DEVICE_NAME ": vboxUsbSolarisProcessIOCtl: " mnemonic ": Invalid pointer %p\n", pvBuf)); \ 1260 1360 return VERR_INVALID_PARAMETER; \ 1261 1361 } \ … … 1269 1369 1270 1370 PVBOXUSBREQ_URB pUrbReq = (PVBOXUSBREQ_URB)pvBuf; 1271 rc = vboxU SBSolarisSendURB(pState, pUrbReq, Mode);1371 rc = vboxUsbSolarisSendUrb(pState, pUrbReq, Mode); 1272 1372 *pcbDataOut = 0; 1273 Log((DEVICE_NAME ": vboxUSBSolarisProcessIOCtl: SEND_URB returned %d\n", rc));1373 Log((DEVICE_NAME ": vboxUsbSolarisProcessIOCtl: SEND_URB returned %d\n", rc)); 1274 1374 break; 1275 1375 } … … 1280 1380 1281 1381 PVBOXUSBREQ_URB pUrbReq = (PVBOXUSBREQ_URB)pvBuf; 1282 rc = vboxU SBSolarisReapURB(pState, pUrbReq, Mode);1382 rc = vboxUsbSolarisReapUrb(pState, pUrbReq, Mode); 1283 1383 *pcbDataOut = sizeof(VBOXUSBREQ_URB); 1284 Log((DEVICE_NAME ": vboxUSBSolarisProcessIOCtl: REAP_URB returned %d\n", rc));1384 Log((DEVICE_NAME ": vboxUsbSolarisProcessIOCtl: REAP_URB returned %d\n", rc)); 1285 1385 break; 1286 1386 } … … 1291 1391 1292 1392 PVBOXUSBREQ_CLEAR_EP pClearEpReq = (PVBOXUSBREQ_CLEAR_EP)pvBuf; 1293 rc = vboxU SBSolarisClearEndPoint(pState, pClearEpReq->bEndpoint);1393 rc = vboxUsbSolarisClearEndPoint(pState, pClearEpReq->bEndpoint); 1294 1394 *pcbDataOut = 0; 1295 Log((DEVICE_NAME ": vboxUSBSolarisProcessIOCtl: CLEAR_EP returned %d\n", rc));1395 Log((DEVICE_NAME ": vboxUsbSolarisProcessIOCtl: CLEAR_EP returned %d\n", rc)); 1296 1396 break; 1297 1397 } … … 1302 1402 1303 1403 PVBOXUSBREQ_SET_CONFIG pSetCfgReq = (PVBOXUSBREQ_SET_CONFIG)pvBuf; 1304 rc = vboxU SBSolarisSetConfig(pState, pSetCfgReq->bConfigValue);1404 rc = vboxUsbSolarisSetConfig(pState, pSetCfgReq->bConfigValue); 1305 1405 *pcbDataOut = 0; 1306 Log((DEVICE_NAME ": vboxUSBSolarisProcessIOCtl: SET_CONFIG returned %d\n", rc));1406 Log((DEVICE_NAME ": vboxUsbSolarisProcessIOCtl: SET_CONFIG returned %d\n", rc)); 1307 1407 break; 1308 1408 } … … 1313 1413 1314 1414 PVBOXUSBREQ_SET_INTERFACE pSetInterfaceReq = (PVBOXUSBREQ_SET_INTERFACE)pvBuf; 1315 rc = vboxU SBSolarisSetInterface(pState, pSetInterfaceReq->bInterface, pSetInterfaceReq->bAlternate);1415 rc = vboxUsbSolarisSetInterface(pState, pSetInterfaceReq->bInterface, pSetInterfaceReq->bAlternate); 1316 1416 *pcbDataOut = 0; 1317 Log((DEVICE_NAME ": vboxUSBSolarisProcessIOCtl: SET_INTERFACE returned %d\n", rc));1417 Log((DEVICE_NAME ": vboxUsbSolarisProcessIOCtl: SET_INTERFACE returned %d\n", rc)); 1318 1418 break; 1319 1419 } … … 1324 1424 1325 1425 PVBOXUSBREQ_CLOSE_DEVICE pCloseDeviceReq = (PVBOXUSBREQ_CLOSE_DEVICE)pvBuf; 1326 rc = vboxUSBSolarisCloseDevice(pState, pCloseDeviceReq->ResetLevel); 1426 if ( pCloseDeviceReq->ResetLevel != VBOXUSB_RESET_LEVEL_REATTACH 1427 || (Mode & FKIOCTL)) 1428 { 1429 rc = vboxUsbSolarisCloseDevice(pState, pCloseDeviceReq->ResetLevel); 1430 } 1431 else 1432 { 1433 /* Userland IOCtls are not allowed to perform a reattach of the device. */ 1434 rc = VERR_NOT_SUPPORTED; 1435 } 1327 1436 *pcbDataOut = 0; 1328 Log((DEVICE_NAME ": vboxUSBSolarisProcessIOCtl: CLOSE_DEVICE returned %d\n", rc));1437 Log((DEVICE_NAME ": vboxUsbSolarisProcessIOCtl: CLOSE_DEVICE returned %d\n", rc)); 1329 1438 break; 1330 1439 } … … 1335 1444 1336 1445 PVBOXUSBREQ_ABORT_PIPE pAbortPipeReq = (PVBOXUSBREQ_ABORT_PIPE)pvBuf; 1337 rc = vboxU SBSolarisAbortPipe(pState, pAbortPipeReq->bEndpoint);1446 rc = vboxUsbSolarisAbortPipe(pState, pAbortPipeReq->bEndpoint); 1338 1447 *pcbDataOut = 0; 1339 Log((DEVICE_NAME ": vboxUSBSolarisProcessIOCtl: ABORT_PIPE returned %d\n", rc));1448 Log((DEVICE_NAME ": vboxUsbSolarisProcessIOCtl: ABORT_PIPE returned %d\n", rc)); 1340 1449 break; 1341 1450 } … … 1346 1455 1347 1456 PVBOXUSBREQ_GET_CONFIG pGetCfgReq = (PVBOXUSBREQ_GET_CONFIG)pvBuf; 1348 rc = vboxU SBSolarisGetConfig(pState, &pGetCfgReq->bConfigValue);1457 rc = vboxUsbSolarisGetConfig(pState, &pGetCfgReq->bConfigValue); 1349 1458 *pcbDataOut = sizeof(VBOXUSBREQ_GET_CONFIG); 1350 Log((DEVICE_NAME ": vboxUSBSolarisProcessIOCtl: GET_CONFIG returned %d\n", rc));1459 Log((DEVICE_NAME ": vboxUsbSolarisProcessIOCtl: GET_CONFIG returned %d\n", rc)); 1351 1460 break; 1352 1461 } … … 1361 1470 *pcbDataOut = sizeof(VBOXUSBREQ_GET_VERSION); 1362 1471 rc = VINF_SUCCESS; 1363 Log((DEVICE_NAME ": vboxUSBSolarisProcessIOCtl: GET_VERSION returned %d\n", rc));1472 Log((DEVICE_NAME ": vboxUsbSolarisProcessIOCtl: GET_VERSION returned %d\n", rc)); 1364 1473 break; 1365 1474 } … … 1367 1476 default: 1368 1477 { 1369 LogRel((DEVICE_NAME ": solarisUSBProcessIOCtl: Unknown request %#x\n", iFunction));1478 LogRel((DEVICE_NAME ": vboxUsbSolarisProcessIOCtl: Unknown request %#x\n", iFunction)); 1370 1479 rc = VERR_NOT_SUPPORTED; 1371 1480 *pcbDataOut = 0; … … 1380 1489 1381 1490 /** 1382 * Initialize device power management functions.1491 * Initializes device power management. 1383 1492 * 1384 1493 * @param pState The USB device instance. … … 1386 1495 * @returns VBox status code. 1387 1496 */ 1388 LOCAL int vboxU SBSolarisInitPower(vboxusb_state_t *pState)1389 { 1390 LogFunc((DEVICE_NAME ": vboxUSBSolarisInitPowerpState=%p\n", pState));1497 LOCAL int vboxUsbSolarisInitPower(vboxusb_state_t *pState) 1498 { 1499 LogFunc((DEVICE_NAME ": vboxUsbSolarisInitPower: pState=%p\n", pState)); 1391 1500 1392 1501 int rc = usb_handle_remote_wakeup(pState->pDip, USB_REMOTE_WAKEUP_ENABLE); 1393 1502 if (rc == USB_SUCCESS) 1394 1503 { 1395 vboxusb_power_t *pPower = RTMemAlloc (sizeof(vboxusb_power_t));1504 vboxusb_power_t *pPower = RTMemAllocZ(sizeof(vboxusb_power_t)); 1396 1505 if (RT_LIKELY(pPower)) 1397 1506 { … … 1413 1522 if (rc != DDI_SUCCESS) 1414 1523 { 1415 LogRel((DEVICE_NAME ": vboxUSBSolarisInitPower failed to raise power level usb(%#x,%#x).\n",1524 LogRel((DEVICE_NAME ": vboxUsbSolarisInitPower: Failed to raise power level usb(%#x,%#x)\n", 1416 1525 pState->pDevDesc->dev_descr->idVendor, pState->pDevDesc->dev_descr->idProduct)); 1417 1526 } 1418 1527 } 1419 1528 else 1420 Log((DEVICE_NAME ": vboxUSBSolarisInitPower failed to create power components.\n"));1529 Log((DEVICE_NAME ": vboxUsbSolarisInitPower: Failed to create power components\n")); 1421 1530 1422 1531 return VINF_SUCCESS; … … 1427 1536 else 1428 1537 { 1429 Log((DEVICE_NAME ": vboxUSBSolarisInitPower failed to enable remote wakeup. No PM.\n"));1538 Log((DEVICE_NAME ": vboxUsbSolarisInitPower: Failed to enable remote wakeup, No PM!\n")); 1430 1539 rc = VINF_SUCCESS; 1431 1540 } … … 1436 1545 1437 1546 /** 1438 * Destroy device power management functions.1547 * Destroys device power management. 1439 1548 * 1440 1549 * @param pState The USB device instance. … … 1443 1552 * @returns VBox status code. 1444 1553 */ 1445 LOCAL void vboxU SBSolarisDestroyPower(vboxusb_state_t *pState)1446 { 1447 LogFunc((DEVICE_NAME ": vboxUSBSolarisDestroyPowerpState=%p\n", pState));1554 LOCAL void vboxUsbSolarisDestroyPower(vboxusb_state_t *pState) 1555 { 1556 LogFunc((DEVICE_NAME ": vboxUsbSolarisDestroyPower: pState=%p\n", pState)); 1448 1557 1449 1558 if (pState->pPower) 1450 1559 { 1451 1560 mutex_exit(&pState->Mtx); 1452 vboxU SBSolarisPowerBusy(pState);1561 vboxUsbSolarisPowerBusy(pState); 1453 1562 mutex_enter(&pState->Mtx); 1454 1563 … … 1460 1569 rc = pm_raise_power(pState->pDip, 0 /* component */, USB_DEV_OS_FULL_PWR); 1461 1570 if (rc != DDI_SUCCESS) 1462 Log((DEVICE_NAME ": vboxUSBSolarisDestroyPower raising power failed! rc=%d\n", rc));1571 Log((DEVICE_NAME ": vboxUsbSolarisDestroyPower: Raising power failed! rc=%d\n", rc)); 1463 1572 1464 1573 rc = usb_handle_remote_wakeup(pState->pDip, USB_REMOTE_WAKEUP_DISABLE); 1465 1574 if (rc != DDI_SUCCESS) 1466 Log((DEVICE_NAME ": vboxUSBSolarisDestroyPower failed to disable remote wakeup.\n"));1575 Log((DEVICE_NAME ": vboxUsbSolarisDestroyPower: Failed to disable remote wakeup\n")); 1467 1576 } 1468 1577 else … … 1471 1580 rc = pm_lower_power(pState->pDip, 0 /* component */, USB_DEV_OS_PWR_OFF); 1472 1581 if (rc != DDI_SUCCESS) 1473 Log((DEVICE_NAME ": vboxUSBSolarisDestroyPower lowering power failed! rc=%d\n", rc));1474 1475 vboxU SBSolarisPowerIdle(pState);1582 Log((DEVICE_NAME ": vboxUsbSolarisDestroyPower: Lowering power failed! rc=%d\n", rc)); 1583 1584 vboxUsbSolarisPowerIdle(pState); 1476 1585 mutex_enter(&pState->Mtx); 1477 1586 RTMemFree(pState->pPower); … … 1482 1591 1483 1592 /** 1484 * Convert Solaris' USBA URB status to VBox's USB URB status.1593 * Converts Solaris' USBA URB status to VBox's USB URB status. 1485 1594 * 1486 1595 * @param Status Solaris USBA USB URB status. … … 1488 1597 * @returns VBox USB URB status. 1489 1598 */ 1490 LOCAL inline VUSBSTATUS vboxUSBSolarisGetUrbStatus(usb_cr_t Status)1599 LOCAL VUSBSTATUS vboxUsbSolarisGetUrbStatus(usb_cr_t Status) 1491 1600 { 1492 1601 switch (Status) … … 1522 1631 1523 1632 /** 1524 * Convert Solaris' USBA error code to VBox's error code.1633 * Converts Solaris' USBA error code to VBox's error code. 1525 1634 * 1526 1635 * @param UsbRc Solaris USBA error code. … … 1528 1637 * @returns VBox error code. 1529 1638 */ 1530 static in line int vboxUSBSolarisToVBoxRC(int UsbRc)1639 static int vboxUsbSolarisToVBoxRC(int UsbRc) 1531 1640 { 1532 1641 switch (UsbRc) … … 1557 1666 1558 1667 /** 1559 * Convert Solaris' USBA device state to VBox's error code.1668 * Converts Solaris' USBA device state to VBox's error code. 1560 1669 * 1561 1670 * @param uDeviceState The USB device state to convert. … … 1563 1672 * @returns VBox error code. 1564 1673 */ 1565 static in line int vboxUSBSolarisDeviceState(uint8_t uDeviceState)1674 static int vboxUsbSolarisDeviceState(uint8_t uDeviceState) 1566 1675 { 1567 1676 switch (uDeviceState) … … 1577 1686 1578 1687 /** 1579 * Check if the device is a USB device.1688 * Checks if the device is a USB device. 1580 1689 * 1581 1690 * @param pDip Pointer to this device info. structure. … … 1583 1692 * @returns If this is really a USB device returns true, otherwise false. 1584 1693 */ 1585 LOCAL bool vboxU SBSolarisIsUSBDevice(dev_info_t *pDip)1694 LOCAL bool vboxUsbSolarisIsUSBDevice(dev_info_t *pDip) 1586 1695 { 1587 1696 int rc = DDI_FAILURE; … … 1597 1706 while (cCompatible--) 1598 1707 { 1599 Log((DEVICE_NAME ": vboxUSBSolarisIsUSBDevice compatible[%d]=%s\n", cCompatible, ppszCompatible[cCompatible]));1708 Log((DEVICE_NAME ": vboxUsbSolarisIsUSBDevice: Compatible[%d]=%s\n", cCompatible, ppszCompatible[cCompatible])); 1600 1709 if (!strncmp(ppszCompatible[cCompatible], "usb", 3)) 1601 1710 { 1602 Log((DEVICE_NAME ": vboxUSBSolarisIsUSBDevice verified device as USB. pszCompatible=%s\n",1711 Log((DEVICE_NAME ": vboxUsbSolarisIsUSBDevice: Verified device as USB. pszCompatible=%s\n", 1603 1712 ppszCompatible[cCompatible])); 1604 1713 ddi_prop_free(ppszCompatible); … … 1611 1720 } 1612 1721 else 1613 Log((DEVICE_NAME ": vboxUSBSolarisIsUSBDevice USB property lookup failed.rc=%d\n", rc));1722 Log((DEVICE_NAME ": vboxUsbSolarisIsUSBDevice: USB property lookup failed, rc=%d\n", rc)); 1614 1723 1615 1724 /* … … 1625 1734 while (cCompatible--) 1626 1735 { 1627 Log((DEVICE_NAME ": vboxUSBSolarisIsUSBDevice parent compatible[%d]=%s\n", cCompatible,1736 Log((DEVICE_NAME ": vboxUsbSolarisIsUSBDevice: Parent compatible[%d]=%s\n", cCompatible, 1628 1737 ppszCompatible[cCompatible])); 1629 1738 if (!strncmp(ppszCompatible[cCompatible], "usb", 3)) 1630 1739 { 1631 Log((DEVICE_NAME ": vboxUSBSolarisIsUSBDevice verified device as USB. parent pszCompatible=%s\n",1740 Log((DEVICE_NAME ": vboxUsbSolarisIsUSBDevice: Verified device as USB. parent pszCompatible=%s\n", 1632 1741 ppszCompatible[cCompatible])); 1633 1742 ddi_prop_free(ppszCompatible); … … 1640 1749 } 1641 1750 else 1642 Log((DEVICE_NAME ": vboxUSBSolarisIsUSBDeviceUSB parent property lookup failed. rc=%d\n", rc));1751 Log((DEVICE_NAME ": vboxUsbSolarisIsUSBDevice: USB parent property lookup failed. rc=%d\n", rc)); 1643 1752 } 1644 1753 else 1645 Log((DEVICE_NAME ": vboxUSBSolarisIsUSBDevice failed to obtain parent device for property lookup.\n"));1754 Log((DEVICE_NAME ": vboxUsbSolarisIsUSBDevice: Failed to obtain parent device for property lookup\n")); 1646 1755 1647 1756 return false; … … 1650 1759 1651 1760 /** 1652 * Submit a URB.1761 * Submits a URB. 1653 1762 * 1654 1763 * @param pState The USB device instance. … … 1658 1767 * @returns VBox error code. 1659 1768 */ 1660 LOCAL int vboxUSBSolarisSendURB(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq, int Mode) 1661 { 1662 uchar_t EndPtIndex = usb_get_ep_index(pUrbReq->bEndpoint); 1663 vboxusb_ep_t *pEp = &pState->aEps[EndPtIndex]; 1769 LOCAL int vboxUsbSolarisSendUrb(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq, int Mode) 1770 { 1771 int iEpIndex = VBOXUSB_GET_EP_INDEX(pUrbReq->bEndpoint); 1772 Assert(iEpIndex >= 0 && iEpIndex < RT_ELEMENTS(pState->aEps)); 1773 vboxusb_ep_t *pEp = &pState->aEps[iEpIndex]; 1664 1774 AssertPtrReturn(pEp, VERR_INVALID_POINTER); 1665 1666 /* LogFunc((DEVICE_NAME ":vboxUSBSolarisSendUrb pState=%p pUrbReq=%p bEndpoint=%#x[%d] enmDir=%#x enmType=%#x cbData=%d pvData=%p\n", 1667 pState, pUrbReq, pUrbReq->bEndpoint, EndPtIndex, pUrbReq->enmDir, pUrbReq->enmType, pUrbReq->cbData, pUrbReq->pvData)); */ 1775 Assert(pUrbReq); 1776 1777 #if 0 1778 LogFunc((DEVICE_NAME ": vboxUsbSolarisSendUrb: pState=%p pUrbReq=%p bEndpoint=%#x[%d] enmDir=%#x enmType=%#x " 1779 "cbData=%d pvData=%p\n", pState, pUrbReq, pUrbReq->bEndpoint, iEpIndex, pUrbReq->enmDir, 1780 pUrbReq->enmType, pUrbReq->cbData, pUrbReq->pvData)); 1781 #endif 1668 1782 1669 1783 if (RT_UNLIKELY(!pUrbReq->pvData)) 1670 1784 { 1671 LogRel((DEVICE_NAME ": vboxUSBSolarisSendUrb Invalid request. No data.\n"));1785 LogRel((DEVICE_NAME ": vboxUsbSolarisSendUrb: Invalid request - No data\n")); 1672 1786 return VERR_INVALID_POINTER; 1673 1787 } … … 1685 1799 if (RT_UNLIKELY(!pMsg)) 1686 1800 { 1687 LogRel((DEVICE_NAME ": vboxUSBSolarisSendUrb: failed to allocate %dbytes\n", pUrbReq->cbData));1801 LogRel((DEVICE_NAME ": vboxUsbSolarisSendUrb: Failed to allocate %u bytes\n", pUrbReq->cbData)); 1688 1802 return VERR_NO_MEMORY; 1689 1803 } … … 1692 1806 if (RT_UNLIKELY(rc)) 1693 1807 { 1694 LogRel((DEVICE_NAME ": vboxUSBSolarisSendUrb: ddi_copyin failed! rc=%d\n", rc));1808 LogRel((DEVICE_NAME ": vboxUsbSolarisSendUrb: ddi_copyin failed! rc=%d\n", rc)); 1695 1809 freemsg(pMsg); 1696 1810 return VERR_NO_MEMORY; … … 1701 1815 1702 1816 mutex_enter(&pState->Mtx); 1703 rc = vboxUSBSolarisDeviceState(pState->DevState); 1704 1705 if (pState->fClosed) /* Required for Isoc. IN Xfers which don't Xfer through the pipe after polling starts */ 1817 rc = vboxUsbSolarisDeviceState(pState->DevState); 1818 if (!pState->fDefaultPipeOpen) /* Required for Isoc. IN Xfers which don't Xfer through the pipe after polling starts */ 1706 1819 rc = VERR_VUSB_DEVICE_NOT_ATTACHED; 1707 1708 1820 if (RT_SUCCESS(rc)) 1709 1821 { … … 1711 1823 * Open the pipe if needed. 1712 1824 */ 1713 rc = vboxU SBSolarisOpenPipe(pState, pEp);1825 rc = vboxUsbSolarisOpenPipe(pState, pEp); 1714 1826 if (RT_UNLIKELY(RT_FAILURE(rc))) 1715 1827 { 1716 1828 mutex_exit(&pState->Mtx); 1717 1829 freemsg(pMsg); 1718 LogRel((DEVICE_NAME ": vboxUSBSolarisSendUrb OpenPipe failed.pState=%p pUrbReq=%p bEndpoint=%#x enmDir=%#x "1830 LogRel((DEVICE_NAME ": vboxUsbSolarisSendUrb: OpenPipe failed! pState=%p pUrbReq=%p bEndpoint=%#x enmDir=%#x " 1719 1831 "enmType=%#x cbData=%d pvData=%p rc=%d\n", pState, pUrbReq, pUrbReq->bEndpoint, pUrbReq->enmDir, 1720 1832 pUrbReq->enmType, pUrbReq->cbData, pUrbReq->pvData, rc)); … … 1726 1838 vboxusb_urb_t *pUrb = NULL; 1727 1839 if ( pUrbReq->enmType == VUSBXFERTYPE_ISOC 1728 && pUrbReq->enmDir == VUSBDIRECTION_IN)1729 pUrb = vboxU SBSolarisGetIsocInURB(pState, pUrbReq);1840 && pUrbReq->enmDir == VUSBDIRECTION_IN) 1841 pUrb = vboxUsbSolarisGetIsocInUrb(pState, pUrbReq); 1730 1842 else 1731 pUrb = vboxU SBSolarisQueueURB(pState, pUrbReq, pMsg);1843 pUrb = vboxUsbSolarisQueueUrb(pState, pUrbReq, pMsg); 1732 1844 1733 1845 if (RT_LIKELY(pUrb)) … … 1737 1849 case VUSBXFERTYPE_MSG: 1738 1850 { 1739 rc = vboxU SBSolarisCtrlXfer(pState, pEp, pUrb);1851 rc = vboxUsbSolarisCtrlXfer(pState, pEp, pUrb); 1740 1852 break; 1741 1853 } … … 1743 1855 case VUSBXFERTYPE_BULK: 1744 1856 { 1745 rc = vboxU SBSolarisBulkXfer(pState, pEp, pUrb);1857 rc = vboxUsbSolarisBulkXfer(pState, pEp, pUrb); 1746 1858 break; 1747 1859 } … … 1749 1861 case VUSBXFERTYPE_INTR: 1750 1862 { 1751 rc = vboxU SBSolarisIntrXfer(pState, pEp, pUrb);1863 rc = vboxUsbSolarisIntrXfer(pState, pEp, pUrb); 1752 1864 break; 1753 1865 } … … 1755 1867 case VUSBXFERTYPE_ISOC: 1756 1868 { 1757 rc = vboxU SBSolarisIsocXfer(pState, pEp, pUrb);1869 rc = vboxUsbSolarisIsocXfer(pState, pEp, pUrb); 1758 1870 break; 1759 1871 } … … 1761 1873 default: 1762 1874 { 1875 LogRelMax(5, (DEVICE_NAME ": vboxUsbSolarisSendUrb: URB type unsupported %d\n", pUrb->enmType)); 1763 1876 rc = VERR_NOT_SUPPORTED; 1764 1877 break; … … 1768 1881 if (RT_FAILURE(rc)) 1769 1882 { 1770 /** @todo We share the state mutex for protecting concurrent accesses to both1771 * the inflight URB list as well as pUrb->pMsg (data). Probably make this1772 * more fine grained later by having a different mutex for the URB if1773 * it's really worth the trouble. */1774 1883 mutex_enter(&pState->Mtx); 1775 if (pUrb->pMsg) 1776 { 1777 freemsg(pUrb->pMsg); 1778 pUrb->pMsg = NULL; 1779 } 1884 freemsg(pUrb->pMsg); 1885 pUrb->pMsg = NULL; 1886 pMsg = NULL; 1780 1887 1781 1888 if ( pUrb->enmType == VUSBXFERTYPE_ISOC … … 1787 1894 else 1788 1895 { 1789 pUrb->pMsg = NULL; 1896 /* 1897 * Xfer failed, move URB back to the free list. 1898 */ 1899 list_remove(&pState->hInflightUrbs, pUrb); 1900 Assert(pState->cInflightUrbs > 0); 1901 --pState->cInflightUrbs; 1902 1790 1903 pUrb->enmState = VBOXUSB_URB_STATE_FREE; 1904 Assert(!pUrb->pMsg); 1905 list_insert_head(&pState->hFreeUrbs, pUrb); 1906 ++pState->cFreeUrbs; 1791 1907 } 1792 1908 mutex_exit(&pState->Mtx); … … 1795 1911 else 1796 1912 { 1797 LogRel((DEVICE_NAME ": vboxUSBSolarisSendUrb failed to queue URB.\n"));1913 LogRel((DEVICE_NAME ": vboxUsbSolarisSendUrb: Failed to queue URB\n")); 1798 1914 rc = VERR_NO_MEMORY; 1799 } 1800 1801 if ( RT_FAILURE(rc) 1802 && pUrb) 1803 { 1804 if ( pUrb->enmType != VUSBXFERTYPE_ISOC 1805 || pUrb->enmDir != VUSBDIRECTION_IN) 1806 { 1807 mutex_enter(&pState->Mtx); 1808 pState->cInflightUrbs--; 1809 mutex_exit(&pState->Mtx); 1810 } 1915 freemsg(pMsg); 1811 1916 } 1812 1917 } … … 1822 1927 1823 1928 /** 1824 * Reap a completed/error'd URB.1929 * Reaps a completed URB. 1825 1930 * 1826 1931 * @param pState The USB device instance. … … 1830 1935 * @returns VBox error code. 1831 1936 */ 1832 LOCAL int vboxU SBSolarisReapURB(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq, int Mode)1833 { 1834 // LogFunc((DEVICE_NAME ":vboxUSBSolarisReapUrb pState=%p pUrbReq=%p\n", pState, pUrbReq)); 1937 LOCAL int vboxUsbSolarisReapUrb(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq, int Mode) 1938 { 1939 /* LogFunc((DEVICE_NAME ": vboxUsbSolarisReapUrb: pState=%p pUrbReq=%p\n", pState, pUrbReq)); */ 1835 1940 1836 1941 AssertPtrReturn(pUrbReq, VERR_INVALID_POINTER); … … 1838 1943 int rc = VINF_SUCCESS; 1839 1944 mutex_enter(&pState->Mtx); 1840 rc = vboxU SBSolarisDeviceState(pState->DevState);1841 if ( pState->fClosed)1945 rc = vboxUsbSolarisDeviceState(pState->DevState); 1946 if (!pState->fDefaultPipeOpen) 1842 1947 rc = VERR_VUSB_DEVICE_NOT_ATTACHED; 1843 1948 if (RT_SUCCESS(rc)) 1844 1949 { 1845 1950 vboxusb_urb_t *pUrb = list_remove_head(&pState->hLandedUrbs); 1951 if (pUrb) 1952 { 1953 Assert(pState->cLandedUrbs > 0); 1954 --pState->cLandedUrbs; 1955 } 1846 1956 1847 1957 /* … … 1860 1970 pUrbReq->enmDir = pUrb->enmDir; 1861 1971 pUrbReq->enmStatus = pUrb->enmStatus; 1972 pUrbReq->pvData = (void *)pUrb->pvDataR3; 1973 pUrbReq->cbData = pUrb->cbDataR3; 1862 1974 1863 1975 if (RT_LIKELY(pUrb->pMsg)) 1864 1976 { 1865 1977 /* 1866 * C hain copy the message back into the user buffer.1978 * Copy the message back into the user buffer. 1867 1979 */ 1868 1980 if (RT_LIKELY(pUrb->pvDataR3 != NIL_RTR3PTR)) 1869 1981 { 1870 size_t cbData = RT_MIN(msgdsize(pUrb->pMsg), pUrb->cbDataR3); 1982 Assert(!pUrb->pMsg->b_cont); /* We really should have a single message block always. */ 1983 size_t cbData = RT_MIN(MBLKL(pUrb->pMsg), pUrb->cbDataR3); 1871 1984 pUrbReq->cbData = cbData; 1872 pUrbReq->pvData = (void *)pUrb->pvDataR3; 1873 1874 /* 1875 * Paranoia: we should have a single message block almost always. 1876 */ 1877 if (RT_LIKELY( !pUrb->pMsg->b_cont 1878 && cbData)) 1985 1986 if (RT_LIKELY(cbData)) 1879 1987 { 1880 1988 rc = ddi_copyout(pUrb->pMsg->b_rptr, (void *)pUrbReq->pvData, cbData, Mode); 1881 1989 if (RT_UNLIKELY(rc)) 1882 1990 { 1883 LogRel((DEVICE_NAME ": vboxUSBSolarisReapUrbddi_copyout failed! rc=%d\n", rc));1991 LogRel((DEVICE_NAME ": vboxUsbSolarisReapUrb: ddi_copyout failed! rc=%d\n", rc)); 1884 1992 pUrbReq->enmStatus = VUSBSTATUS_INVALID; 1885 1993 } 1886 1994 } 1887 else 1888 { 1889 RTR3PTR pvDataR3 = pUrb->pvDataR3; 1890 mblk_t *pMsg = pUrb->pMsg; 1891 while (pMsg) 1892 { 1893 size_t cbMsg = MBLKL(pMsg); 1894 if (cbMsg > 0) 1895 { 1896 rc = ddi_copyout(pMsg->b_rptr, (void *)pvDataR3, cbMsg, Mode); 1897 if (RT_UNLIKELY(rc != 0)) 1898 { 1899 LogRel((DEVICE_NAME ":vboxUSBSolarisReapUrb ddi_copyout (2) failed! rc=%d\n", rc)); 1900 pUrbReq->enmStatus = VUSBSTATUS_INVALID; 1901 break; 1902 } 1903 } 1904 1905 pMsg = pMsg->b_cont; 1906 pvDataR3 += cbMsg; 1907 if ((pvDataR3 - pUrb->pvDataR3) >= cbData) 1908 break; 1909 } 1910 } 1911 1912 Log((DEVICE_NAME ":vboxUSBSolarisReapUrb pvUrbR3=%p pvDataR3=%p cbData=%d\n", pUrbReq->pvUrbR3, 1995 1996 Log((DEVICE_NAME ": vboxUsbSolarisReapUrb: pvUrbR3=%p pvDataR3=%p cbData=%d\n", pUrbReq->pvUrbR3, 1913 1997 pUrbReq->pvData, pUrbReq->cbData)); 1914 1998 } … … 1917 2001 pUrbReq->cbData = 0; 1918 2002 rc = VERR_INVALID_POINTER; 1919 Log ((DEVICE_NAME ":vboxUSBSolarisReapUrb missing pvDataR3!!\n"));2003 LogRel((DEVICE_NAME ": vboxUsbSolarisReapUrb: Missing pvDataR3!!\n")); 1920 2004 } 1921 2005 1922 2006 /* 1923 * Free buffer allocated in VBOXUSB_IOCTL_SEND_URB.2007 * Free buffer allocated in vboxUsbSolarisSendUrb or vboxUsbSolaris[Ctrl|Bulk|Intr]Xfer(). 1924 2008 */ 1925 2009 freemsg(pUrb->pMsg); … … 1928 2012 else 1929 2013 { 1930 if (pUrb->enmType == VUSBXFERTYPE_ISOC) 2014 if ( pUrb->enmType == VUSBXFERTYPE_ISOC 2015 && pUrb->enmDir == VUSBDIRECTION_IN) 1931 2016 { 1932 if (pUrb->enmDir == VUSBDIRECTION_OUT) 1933 pUrbReq->cbData = pUrb->cbDataR3; 1934 else 1935 { 1936 pUrbReq->enmStatus = VUSBSTATUS_INVALID; 1937 pUrbReq->cbData = 0; 1938 } 1939 } 1940 else 1941 { 1942 Log((DEVICE_NAME ":vboxUSBSolarisReapUrb missing message.\n")); 2017 pUrbReq->enmStatus = VUSBSTATUS_INVALID; 1943 2018 pUrbReq->cbData = 0; 1944 2019 } … … 1970 2045 { 1971 2046 /* 1972 * Add URB back to the head of the free/inflightlist.2047 * Add URB back to the free list. 1973 2048 */ 2049 Assert(!pUrb->pMsg); 1974 2050 pUrb->cbDataR3 = 0; 1975 2051 pUrb->pvDataR3 = NIL_RTR3PTR; 1976 2052 pUrb->enmState = VBOXUSB_URB_STATE_FREE; 1977 2053 mutex_enter(&pState->Mtx); 1978 list_insert_head(&pState->hUrbs, pUrb); 2054 list_insert_head(&pState->hFreeUrbs, pUrb); 2055 ++pState->cFreeUrbs; 1979 2056 mutex_exit(&pState->Mtx); 1980 2057 } 1981 2058 } 1982 2059 else 2060 { 1983 2061 pUrbReq->pvUrbR3 = NULL; 2062 pUrbReq->cbData = 0; 2063 pUrbReq->pvData = NULL; 2064 pUrbReq->enmStatus = VUSBSTATUS_INVALID; 2065 } 1984 2066 } 1985 2067 else … … 1991 2073 1992 2074 /** 1993 * Clear a pipe (CLEAR_FEATURE).2075 * Clears a pipe (CLEAR_FEATURE). 1994 2076 * 1995 2077 * @param pState The USB device instance. … … 1998 2080 * @returns VBox error code. 1999 2081 */ 2000 LOCAL int vboxUSBSolarisClearEndPoint(vboxusb_state_t *pState, uint8_t bEndpoint) 2001 { 2002 LogFunc((DEVICE_NAME ":vboxUSBSolarisClearEndPoint pState=%p bEndpoint=%#x\n", pState, bEndpoint)); 2003 2004 /* 2005 * Serialize access: single threaded per Endpoint, one request at a time. 2006 */ 2082 LOCAL int vboxUsbSolarisClearEndPoint(vboxusb_state_t *pState, uint8_t bEndpoint) 2083 { 2084 LogFunc((DEVICE_NAME ": vboxUsbSolarisClearEndPoint: pState=%p bEndpoint=%#x\n", pState, bEndpoint)); 2085 2007 2086 mutex_enter(&pState->Mtx); 2008 int rc = vboxU SBSolarisDeviceState(pState->DevState);2087 int rc = vboxUsbSolarisDeviceState(pState->DevState); 2009 2088 if (RT_SUCCESS(rc)) 2010 2089 { 2011 uchar_t EndPtIndex = usb_get_ep_index(bEndpoint); 2012 vboxusb_ep_t *pEp = &pState->aEps[EndPtIndex]; 2090 int iEpIndex = VBOXUSB_GET_EP_INDEX(bEndpoint); 2091 Assert(iEpIndex >= 0 && iEpIndex < RT_ELEMENTS(pState->aEps)); 2092 vboxusb_ep_t *pEp = &pState->aEps[iEpIndex]; 2013 2093 if (RT_LIKELY(pEp)) 2014 2094 { … … 2019 2099 { 2020 2100 mutex_exit(&pState->Mtx); 2021 #if 0 2022 /* 2023 * Asynchronous clear pipe. 2024 */ 2025 rc = usb_clr_feature(pState->pDip, USB_DEV_REQ_RCPT_EP, USB_EP_HALT, bEndpoint, 2026 USB_FLAGS_NOSLEEP, /* Asynchronous */ 2027 NULL, /* Completion callback */ 2028 NULL); /* Exception callback */ 2029 #endif 2101 2030 2102 /* 2031 2103 * Synchronous reset pipe. … … 2038 2110 mutex_enter(&pState->Mtx); 2039 2111 2040 Log((DEVICE_NAME ": vboxUSBSolarisClearEndPoint bEndpoint=%#x[%d] returns %d\n", bEndpoint, EndPtIndex, rc));2112 Log((DEVICE_NAME ": vboxUsbSolarisClearEndPoint: bEndpoint=%#x[%d] returns %d\n", bEndpoint, iEpIndex, rc)); 2041 2113 2042 2114 rc = VINF_SUCCESS; … … 2044 2116 else 2045 2117 { 2046 Log((DEVICE_NAME ": vboxUSBSolarisClearEndPoint not opened to be cleared. Faking success. bEndpoint=%#x.\n",2118 Log((DEVICE_NAME ": vboxUsbSolarisClearEndPoint: Not opened to be cleared. Faking success. bEndpoint=%#x\n", 2047 2119 bEndpoint)); 2048 2120 rc = VINF_SUCCESS; … … 2051 2123 else 2052 2124 { 2053 LogRel((DEVICE_NAME ":vboxUSBSolarisClearEndPoint Endpoint missing!! bEndpoint=%#x EndPtIndex=%d.\n", bEndpoint, 2054 EndPtIndex)); 2125 LogRel((DEVICE_NAME ": vboxUsbSolarisClearEndPoint: Endpoint missing! bEndpoint=%#x[%d]\n", bEndpoint, iEpIndex)); 2055 2126 rc = VERR_GENERAL_FAILURE; 2056 2127 } 2057 2128 } 2058 2129 else 2059 Log((DEVICE_NAME ": vboxUSBSolarisClearEndPoint device state=%d not online.\n", pState->DevState));2130 Log((DEVICE_NAME ": vboxUsbSolarisClearEndPoint: Device not online, state=%d\n", pState->DevState)); 2060 2131 2061 2132 mutex_exit(&pState->Mtx); … … 2065 2136 2066 2137 /** 2067 * Set configuration (SET_CONFIGURATION)2138 * Sets configuration (SET_CONFIGURATION) 2068 2139 * 2069 2140 * @param pState The USB device instance. 2070 * @param bC fgValue The Configuration value.2141 * @param bConfig The Configuration. 2071 2142 * 2072 2143 * @returns VBox error code. 2073 2144 */ 2074 LOCAL int vboxUSBSolarisSetConfig(vboxusb_state_t *pState, uint8_t bCfgValue) 2075 { 2076 LogFunc((DEVICE_NAME ":vboxUSBSolarisSetConfig pState=%p bCfgValue=%#x\n", pState, bCfgValue)); 2077 2078 /* 2079 * Serialize access: single threaded per Endpoint, one request at a time. 2080 */ 2145 LOCAL int vboxUsbSolarisSetConfig(vboxusb_state_t *pState, uint8_t bConfig) 2146 { 2147 LogFunc((DEVICE_NAME ": vboxUsbSolarisSetConfig: pState=%p bConfig=%u\n", pState, bConfig)); 2148 2081 2149 mutex_enter(&pState->Mtx); 2082 int rc = vboxU SBSolarisDeviceState(pState->DevState);2150 int rc = vboxUsbSolarisDeviceState(pState->DevState); 2083 2151 if (RT_SUCCESS(rc)) 2084 2152 { 2085 vboxUSBSolarisCloseAllPipes(pState, false /* ControlPipe */); 2086 int iCfgIndex = vboxUSBSolarisGetConfigIndex(pState, bCfgValue); 2087 2088 if (iCfgIndex >= 0) 2153 vboxUsbSolarisCloseAllPipes(pState, false /* ControlPipe */); 2154 int iCfgIndex = vboxUsbSolarisGetConfigIndex(pState, bConfig); 2155 2156 if ( iCfgIndex >= 0 2157 && iCfgIndex < pState->pDevDesc->dev_n_cfg) 2089 2158 { 2090 2159 /* … … 2097 2166 if (rc == USB_SUCCESS) 2098 2167 { 2099 pState->fRestoreCfg = true;2100 vboxUSBSolarisInitEndPointsForConfig(pState, iCfgIndex);2168 int rc2 = vboxUsbSolarisInitEpsForCfg(pState); 2169 AssertRC(rc2); NOREF(rc2); 2101 2170 rc = VINF_SUCCESS; 2102 2171 } 2103 2172 else 2104 2173 { 2105 LogRel((DEVICE_NAME ": vboxUSBSolarisSetConfig usb_set_cfg failed for iCfgIndex=%#x bCfgValue=%#xrc=%d\n",2106 iCfgIndex, bC fgValue, rc));2107 rc = vboxU SBSolarisToVBoxRC(rc);2174 LogRel((DEVICE_NAME ": vboxUsbSolarisSetConfig: usb_set_cfg failed for iCfgIndex=%#x bConfig=%u rc=%d\n", 2175 iCfgIndex, bConfig, rc)); 2176 rc = vboxUsbSolarisToVBoxRC(rc); 2108 2177 } 2109 2178 } 2110 2179 else 2111 2180 { 2112 LogRel((DEVICE_NAME ": vboxUSBSolarisSetConfig invalid iCfgIndex=%d bCfgValue=%#x\n", iCfgIndex, bCfgValue));2113 rc = VERR_ INVALID_HANDLE;2181 LogRel((DEVICE_NAME ": vboxUsbSolarisSetConfig: Invalid iCfgIndex=%d bConfig=%u\n", iCfgIndex, bConfig)); 2182 rc = VERR_OUT_OF_RANGE; 2114 2183 } 2115 2184 } … … 2122 2191 2123 2192 /** 2124 * Get configuration (GET_CONFIGURATION)2193 * Gets configuration (GET_CONFIGURATION) 2125 2194 * 2126 2195 * @param pState The USB device instance. 2127 * @param p CfgValue Where to store the configuration value.2196 * @param pbConfig Where to store the Configuration. 2128 2197 * 2129 2198 * @returns VBox error code. 2130 2199 */ 2131 LOCAL int vboxUSBSolarisGetConfig(vboxusb_state_t *pState, uint8_t *pCfgValue) 2132 { 2133 LogFunc((DEVICE_NAME ":vboxUSBSolarisGetConfig pState=%p pCfgValue=%p\n", pState, pCfgValue)); 2134 AssertPtrReturn(pCfgValue, VERR_INVALID_POINTER); 2135 2136 /* 2137 * Solaris keeps the currently active configuration for the first time. Thus for the first request 2138 * we simply pass the cached configuration back to the user. 2139 */ 2140 if (!pState->fGetCfgReqDone) 2141 { 2142 pState->fGetCfgReqDone = true; 2143 AssertPtrReturn(pState->pDevDesc, VERR_GENERAL_FAILURE); 2144 usb_cfg_data_t *pCurrCfg = pState->pDevDesc->dev_curr_cfg; 2145 if (pCurrCfg) 2146 { 2147 *pCfgValue = pCurrCfg->cfg_descr.bConfigurationValue; 2148 Log((DEVICE_NAME ":vboxUSBSolarisGetConfig cached config returned. CfgValue=%d\n", *pCfgValue)); 2149 return VINF_SUCCESS; 2150 } 2151 } 2200 LOCAL int vboxUsbSolarisGetConfig(vboxusb_state_t *pState, uint8_t *pbConfig) 2201 { 2202 LogFunc((DEVICE_NAME ": vboxUsbSolarisGetConfig: pState=%p pbConfig=%p\n", pState, pbConfig)); 2203 AssertPtrReturn(pbConfig, VERR_INVALID_POINTER); 2152 2204 2153 2205 /* 2154 2206 * Get Config synchronously. 2155 2207 */ 2156 uint_t bC fgValue;2157 int rc = usb_get_cfg(pState->pDip, &bC fgValue, USB_FLAGS_SLEEP);2208 uint_t bConfig; 2209 int rc = usb_get_cfg(pState->pDip, &bConfig, USB_FLAGS_SLEEP); 2158 2210 if (RT_LIKELY(rc == USB_SUCCESS)) 2159 2211 { 2160 *p CfgValue = bCfgValue;2212 *pbConfig = bConfig; 2161 2213 rc = VINF_SUCCESS; 2162 2214 } 2163 2215 else 2164 2216 { 2165 LogRel((DEVICE_NAME ": vboxUSBSolarisGetConfig failed.rc=%d\n", rc));2166 rc = vboxU SBSolarisToVBoxRC(rc);2167 } 2168 2169 Log((DEVICE_NAME ": vboxUSBSolarisGetConfig returns %d CfgValue=%d\n", rc, *pCfgValue));2217 LogRel((DEVICE_NAME ": vboxUsbSolarisGetConfig: Failed, rc=%d\n", rc)); 2218 rc = vboxUsbSolarisToVBoxRC(rc); 2219 } 2220 2221 Log((DEVICE_NAME ": vboxUsbSolarisGetConfig: Returns %d bConfig=%u\n", rc, *pbConfig)); 2170 2222 return rc; 2171 2223 } … … 2173 2225 2174 2226 /** 2175 * Set interface (SET_INTERFACE)2227 * Sets interface (SET_INTERFACE) and alternate. 2176 2228 * 2177 2229 * @param pState The USB device instance. 2178 * @param uInterface The Interface number.2179 * @param uAlt The Alternate setting number.2230 * @param bIf The Interface. 2231 * @param bAlt The Alternate setting. 2180 2232 * 2181 2233 * @returns VBox error code. 2182 2234 */ 2183 LOCAL int vboxUSBSolarisSetInterface(vboxusb_state_t *pState, uint8_t uInterface, uint8_t uAlt) 2184 { 2185 LogFunc((DEVICE_NAME ":vboxUSBSolarisSetInterface pState=%p uInterface=%#x uAlt=%#x\n", pState, uInterface, uAlt)); 2186 2187 /* 2188 * Serialize access: single threaded per Endpoint, one request at a time. 2189 */ 2235 LOCAL int vboxUsbSolarisSetInterface(vboxusb_state_t *pState, uint8_t bIf, uint8_t bAlt) 2236 { 2237 LogFunc((DEVICE_NAME ": vboxUsbSolarisSetInterface: pState=%p bIf=%#x bAlt=%#x\n", pState, bIf, bAlt)); 2238 2190 2239 mutex_enter(&pState->Mtx); 2191 int rc = vboxU SBSolarisDeviceState(pState->DevState);2240 int rc = vboxUsbSolarisDeviceState(pState->DevState); 2192 2241 if (RT_SUCCESS(rc)) 2193 2242 { 2194 vboxUSBSolarisCloseAllPipes(pState, false /* ControlPipe */);2195 2196 2243 /* 2197 2244 * Set Interface & Alt setting synchronously. 2198 2245 */ 2199 2246 mutex_exit(&pState->Mtx); 2200 rc = usb_set_alt_if(pState->pDip, uInterface, uAlt, USB_FLAGS_SLEEP, NULL /* callback */, NULL /* callback data */);2247 rc = usb_set_alt_if(pState->pDip, bIf, bAlt, USB_FLAGS_SLEEP, NULL /* callback */, NULL /* callback data */); 2201 2248 mutex_enter(&pState->Mtx); 2202 2249 2203 2250 if (rc == USB_SUCCESS) 2204 2251 { 2205 vboxUSBSolarisInitEndPointsForInterfaceAlt(pState, uInterface, uAlt); 2252 Log((DEVICE_NAME ": vboxUsbSolarisSetInterface: Success, bIf=%#x bAlt=%#x\n", bIf, bAlt, rc)); 2253 int rc2 = vboxUsbSolarisInitEpsForIfAlt(pState, bIf, bAlt); 2254 AssertRC(rc2); NOREF(rc2); 2206 2255 rc = VINF_SUCCESS; 2207 2256 } 2208 2257 else 2209 2258 { 2210 LogRel((DEVICE_NAME ":vboxUSBSolarisSetInterface usb_set_alt_if failed for uInterface=%#x bAlt=%#x rc=%d\n", 2211 uInterface, uAlt, rc)); 2212 rc = vboxUSBSolarisToVBoxRC(rc); 2259 LogRel((DEVICE_NAME ": vboxUsbSolarisSetInterface: usb_set_alt_if failed for bIf=%#x bAlt=%#x rc=%d\n", bIf, bAlt, rc)); 2260 rc = vboxUsbSolarisToVBoxRC(rc); 2213 2261 } 2214 2262 } … … 2221 2269 2222 2270 /** 2223 * Close the USB device and reset it if required.2271 * Closes the USB device and optionally resets it. 2224 2272 * 2225 2273 * @param pState The USB device instance. … … 2228 2276 * @returns VBox error code. 2229 2277 */ 2230 LOCAL int vboxUSBSolarisCloseDevice(vboxusb_state_t *pState, VBOXUSB_RESET_LEVEL enmReset) 2231 { 2232 Log((DEVICE_NAME ":vboxUSBSolarisCloseDevice pState=%p enmReset=%d\n", pState, enmReset)); 2233 2234 /* 2235 * Serialize access: single threaded per Endpoint, one request at a time. 2236 */ 2278 LOCAL int vboxUsbSolarisCloseDevice(vboxusb_state_t *pState, VBOXUSB_RESET_LEVEL enmReset) 2279 { 2280 LogFunc((DEVICE_NAME ": vboxUsbSolarisCloseDevice: pState=%p enmReset=%d\n", pState, enmReset)); 2281 2237 2282 mutex_enter(&pState->Mtx); 2238 int rc = vboxU SBSolarisDeviceState(pState->DevState);2283 int rc = vboxUsbSolarisDeviceState(pState->DevState); 2239 2284 2240 2285 if (enmReset == VBOXUSB_RESET_LEVEL_CLOSE) 2241 { 2242 vboxUSBSolarisCloseAllPipes(pState, true /* ControlPipe */); 2243 pState->fClosed = true; 2244 } 2286 vboxUsbSolarisCloseAllPipes(pState, true /* ControlPipe */); 2245 2287 else 2246 vboxUSBSolarisCloseAllPipes(pState, false /* ControlPipe */); 2247 2288 vboxUsbSolarisCloseAllPipes(pState, false /* ControlPipe */); 2248 2289 2249 2290 mutex_exit(&pState->Mtx); … … 2266 2307 } 2267 2308 2268 rc = vboxU SBSolarisToVBoxRC(rc);2269 } 2270 2271 Log((DEVICE_NAME ": vboxUSBSolarisCloseDevice returns %d\n", rc));2309 rc = vboxUsbSolarisToVBoxRC(rc); 2310 } 2311 2312 Log((DEVICE_NAME ": vboxUsbSolarisCloseDevice: Returns %d\n", rc)); 2272 2313 return rc; 2273 2314 } … … 2275 2316 2276 2317 /** 2277 * Abort pending requests and reset the pipe.2318 * Aborts pending requests and reset the pipe. 2278 2319 * 2279 2320 * @param pState The USB device instance. … … 2282 2323 * @returns VBox error code. 2283 2324 */ 2284 LOCAL int vboxUSBSolarisAbortPipe(vboxusb_state_t *pState, uint8_t bEndpoint) 2285 { 2286 LogFunc((DEVICE_NAME ":vboxUSBSolarisAbortPipe pState=%p bEndpoint=%#x\n", pState, bEndpoint)); 2287 2288 /* 2289 * Serialize access: single threaded per Endpoint, one request at a time. 2290 */ 2325 LOCAL int vboxUsbSolarisAbortPipe(vboxusb_state_t *pState, uint8_t bEndpoint) 2326 { 2327 LogFunc((DEVICE_NAME ": vboxUsbSolarisAbortPipe: pState=%p bEndpoint=%#x\n", pState, bEndpoint)); 2328 2291 2329 mutex_enter(&pState->Mtx); 2292 int rc = vboxU SBSolarisDeviceState(pState->DevState);2330 int rc = vboxUsbSolarisDeviceState(pState->DevState); 2293 2331 if (RT_SUCCESS(rc)) 2294 2332 { 2295 uchar_t EndPtIndex = usb_get_ep_index(bEndpoint); 2296 vboxusb_ep_t *pEp = &pState->aEps[EndPtIndex]; 2333 int iEpIndex = VBOXUSB_GET_EP_INDEX(bEndpoint); 2334 Assert(iEpIndex >= 0 && iEpIndex < RT_ELEMENTS(pState->aEps)); 2335 vboxusb_ep_t *pEp = &pState->aEps[iEpIndex]; 2297 2336 if (RT_LIKELY(pEp)) 2298 2337 { … … 2300 2339 { 2301 2340 /* 2302 * Default Endpoint; aborting requests not supported, fake success.2341 * Aborting requests not supported for the default control pipe. 2303 2342 */ 2304 2343 if ((pEp->EpDesc.bEndpointAddress & USB_EP_NUM_MASK) == 0) 2305 2344 { 2306 2345 mutex_exit(&pState->Mtx); 2307 LogRel((DEVICE_NAME ": vboxUSBSolarisAbortPipe Cannot reset control pipe.\n"));2346 LogRel((DEVICE_NAME ": vboxUsbSolarisAbortPipe: Cannot reset default control pipe\n")); 2308 2347 return VERR_NOT_SUPPORTED; 2309 2348 } 2310 2349 2311 /*2312 * Serialize access: single threaded per Endpoint, one request at a time.2313 */2314 2350 mutex_exit(&pState->Mtx); 2315 2351 usb_pipe_reset(pState->pDip, pEp->pPipe, 2316 USB_FLAGS_SLEEP,/* Synchronous */2317 NULL,/* Completion callback */2318 NULL); /* Callback data*/2352 USB_FLAGS_SLEEP, /* Synchronous */ 2353 NULL, /* Completion callback */ 2354 NULL); /* Callback's parameter */ 2319 2355 2320 2356 /* 2321 2357 * Allow pending async requests to complete. 2322 2358 */ 2359 /** @todo this is most likely not required. */ 2323 2360 rc = usb_pipe_drain_reqs(pState->pDip, pEp->pPipe, 2324 2361 USB_FLAGS_SLEEP, /* Synchronous */ 2325 2362 5, /* Timeout (seconds) */ 2326 2363 NULL, /* Completion callback */ 2327 NULL); /* Callback data*/2364 NULL); /* Callback's parameter */ 2328 2365 2329 2366 mutex_enter(&pState->Mtx); 2330 2367 2331 Log((DEVICE_NAME ": usb_pipe_drain_reqs returns %d\n", rc));2332 rc = vboxU SBSolarisToVBoxRC(rc);2368 Log((DEVICE_NAME ": vboxUsbSolarisAbortPipe: usb_pipe_drain_reqs returns %d\n", rc)); 2369 rc = vboxUsbSolarisToVBoxRC(rc); 2333 2370 } 2334 2371 else 2335 2372 { 2336 LogRel((DEVICE_NAME ": vboxUSBSolarisAbortPipepipe not open. bEndpoint=%#x\n", bEndpoint));2373 LogRel((DEVICE_NAME ": vboxUsbSolarisAbortPipe: pipe not open. bEndpoint=%#x\n", bEndpoint)); 2337 2374 rc = VERR_PIPE_IO_ERROR; 2338 2375 } … … 2340 2377 else 2341 2378 { 2342 LogRel((DEVICE_NAME ": vboxUSBSolarisAbortPipe invalid pipe index %d bEndpoint=%#x\n", EndPtIndex, bEndpoint));2379 LogRel((DEVICE_NAME ": vboxUsbSolarisAbortPipe: Invalid pipe bEndpoint=%#x[%d]\n", bEndpoint, iEpIndex)); 2343 2380 rc = VERR_INVALID_HANDLE; 2344 2381 } … … 2347 2384 mutex_exit(&pState->Mtx); 2348 2385 2349 LogFunc((DEVICE_NAME ": vboxUSBSolarisAbortPipe returns %d\n", rc));2386 LogFunc((DEVICE_NAME ": vboxUsbSolarisAbortPipe: Returns %d\n", rc)); 2350 2387 return rc; 2351 2388 } … … 2353 2390 2354 2391 /** 2355 * Initialize an endpoint.2392 * Initializes an Endpoint. 2356 2393 * 2357 2394 * @param pState The USB device instance. 2358 * @param pEpData The Endpoint data. 2359 * @param uCfgValue The Configuration value. 2360 * @param uInterface The Interface. 2361 * @param uAlt The Alternate setting. 2395 * @param pEpData The Endpoint data (NULL implies the default 2396 * endpoint). 2362 2397 * 2363 2398 * @returns VBox error code. 2364 2399 */ 2365 LOCAL int vboxUSBSolarisInitEndPoint(vboxusb_state_t *pState, usb_ep_data_t *pEpData, uchar_t uCfgValue, 2366 uchar_t uInterface, uchar_t uAlt) 2367 { 2368 LogFunc((DEVICE_NAME ":vboxUSBSolarisInitEndPoint pState=%p pEpData=%p CfgVal=%d Iface=%d Alt=%d", pState, 2369 pEpData, uCfgValue, uInterface, uAlt)); 2400 LOCAL int vboxUsbSolarisInitEp(vboxusb_state_t *pState, usb_ep_data_t *pEpData) 2401 { 2402 LogFunc((DEVICE_NAME ": vboxUsbSolarisInitEp: pState=%p pEpData=%p", pState, pEpData)); 2370 2403 2371 2404 /* … … 2374 2407 usb_ep_descr_t *pEpDesc = NULL; 2375 2408 vboxusb_ep_t *pEp = NULL; 2376 int EpIndex = 0;2409 int iEpIndex; 2377 2410 if (!pEpData) 2378 2411 { 2379 EpIndex = 0;2412 iEpIndex = 0; 2380 2413 pEpDesc = &g_VBoxUSBSolarisDefaultEpDesc; 2381 2414 } 2382 2415 else 2383 2416 { 2384 EpIndex = usb_get_ep_index(pEpData->ep_descr.bEndpointAddress);2385 pEpDesc = &pEpData->ep_descr;2386 } 2387 2388 pEp = &pState->aEps[EpIndex];2389 AssertRelease(pEp);2417 iEpIndex = VBOXUSB_GET_EP_INDEX(pEpData->ep_descr.bEndpointAddress); 2418 pEpDesc = (usb_ep_descr_t *)((uint8_t *)pEpData + g_offUsbEpDataDescr); 2419 } 2420 2421 Assert(iEpIndex >= 0 && iEpIndex < RT_ELEMENTS(pState->aEps)); 2422 pEp = &pState->aEps[iEpIndex]; 2390 2423 2391 2424 /* 2392 * Initialize the endpoint data structure.2425 * Initialize the endpoint. 2393 2426 */ 2394 2427 pEp->EpDesc = *pEpDesc; 2395 pEp->uCfgValue = uCfgValue; 2396 pEp->uInterface = uInterface; 2397 pEp->uAlt = uAlt; 2398 if (pEp->fInitialized != VBOXUSB_EP_INITIALIZED) 2428 if (!pEp->fInitialized) 2399 2429 { 2400 2430 pEp->pPipe = NULL; … … 2408 2438 pEp->cbIsocInLandedReqs = 0; 2409 2439 pEp->cbMaxIsocData = 0; 2410 pEp->fInitialized = VBOXUSB_EP_INITIALIZED; 2411 } 2412 Log((DEVICE_NAME ":vboxUSBSolarisInitEndPoint done. %s:[%d] bEndpoint=%#x\n", !pEpData ? "Default " : "Endpoint", 2413 EpIndex, pEp->EpDesc.bEndpointAddress)); 2440 pEp->fInitialized = true; 2441 } 2442 2443 Log((DEVICE_NAME ": vboxUsbSolarisInitEp: Success, %s[%2d] %s %s bEndpoint=%#x\n", !pEpData ? "Default " : "Endpoint", 2444 iEpIndex, vboxUsbSolarisEpType(pEp), vboxUsbSolarisEpDir(pEp), pEp->EpDesc.bEndpointAddress)); 2414 2445 return VINF_SUCCESS; 2415 2446 } … … 2417 2448 2418 2449 /** 2419 * Initialize all Endpoint structures. 2450 * Initializes Endpoints for the current configuration, all interfaces and 2451 * alternate setting 0 for each interface. 2420 2452 * 2421 2453 * @param pState The USB device instance. … … 2423 2455 * @returns VBox status code. 2424 2456 */ 2425 LOCAL int vboxUSBSolarisInitAllEndPoints(vboxusb_state_t *pState) 2426 { 2427 LogFunc((DEVICE_NAME ":vboxUSBSolarisInitAllEndPoints pState=%p\n", pState)); 2428 2429 /* 2430 * Initialize all Endpoints for all Alternate settings of all Interfaces of all Configs. 2431 */ 2432 int rc = vboxUSBSolarisInitEndPoint(pState, NULL /* pEp */, 0 /* uCfgValue */, 0 /* uInterface */, 0 /* uAlt */); 2433 2434 if (RT_SUCCESS(rc)) 2435 { 2436 /* 2437 * Initialize all Endpoints for all Alternate settings of all Interfaces of all Configs. 2438 */ 2439 for (uchar_t uCfgIndex = 0; uCfgIndex < pState->pDevDesc->dev_n_cfg; uCfgIndex++) 2440 { 2441 rc = vboxUSBSolarisInitEndPointsForConfig(pState, uCfgIndex); 2442 if (RT_FAILURE(rc)) 2457 LOCAL int vboxUsbSolarisInitEpsForCfg(vboxusb_state_t *pState) 2458 { 2459 uint_t uCfgIndex = usb_get_current_cfgidx(pState->pDip); 2460 if (uCfgIndex >= pState->pDevDesc->dev_n_cfg) 2461 { 2462 LogRel((DEVICE_NAME ": vboxUsbSolarisInitEpsForCfg: Invalid current config index %u\n", uCfgIndex)); 2463 return VERR_OUT_OF_RANGE; 2464 } 2465 2466 usb_cfg_data_t *pConfig = &pState->pDevDesc->dev_cfg[uCfgIndex]; 2467 uchar_t bConfig = pConfig->cfg_descr.bConfigurationValue; 2468 2469 LogFunc((DEVICE_NAME ": vboxUsbSolarisInitEpsForCfg: pState=%p bConfig=%u uCfgIndex=%u\n", pState, bConfig, uCfgIndex)); 2470 2471 const uint_t cIfs = pConfig->cfg_n_if; 2472 for (uchar_t uIf = 0; uIf < cIfs; uIf++) 2473 { 2474 usb_if_data_t *pIf = &pConfig->cfg_if[uIf]; 2475 const uint_t cAlts = pIf->if_n_alt; 2476 for (uchar_t uAlt = 0; uAlt < cAlts; uAlt++) 2477 { 2478 usb_alt_if_data_t *pAlt = &pIf->if_alt[uAlt]; 2479 if (pAlt->altif_descr.bAlternateSetting == 0) /* Refer USB 2.0 spec 9.6.5 "Interface" */ 2443 2480 { 2444 LogRel((DEVICE_NAME ":vboxUSBSolarisInitAllEndPoints: vboxUSBSolarisInitEndPoints uCfgIndex=%d failed. rc=%d\n", 2445 uCfgIndex, rc)); 2446 return rc; 2481 const uint_t cEps = pAlt->altif_n_ep; 2482 for (uchar_t uEp = 0; uEp < cEps; uEp++) 2483 { 2484 uint8_t *pbEpData = (uint8_t *)&pAlt->altif_ep[0]; 2485 usb_ep_data_t *pEpData = (usb_ep_data_t *)(pbEpData + uEp * g_cbUsbEpData); 2486 int rc = vboxUsbSolarisInitEp(pState, pEpData); 2487 if (RT_FAILURE(rc)) 2488 { 2489 LogRel((DEVICE_NAME ": vboxUsbSolarisInitEpsForCfg: Failed to init endpoint! " 2490 "bConfig=%u bIf=%#x bAlt=%#x\n", bConfig, pAlt->altif_descr.bInterfaceNumber, 2491 pAlt->altif_descr.bAlternateSetting)); 2492 return rc; 2493 } 2494 } 2495 break; /* move on to next interface. */ 2447 2496 } 2448 2497 } 2449 2498 } 2450 else 2451 LogRel((DEVICE_NAME ":vboxUSBSolarisInitAllEndPoints default Endpoint initialization failed!\n")); 2452 2453 return rc; 2454 } 2455 2456 2457 /** 2458 * Initialize Endpoints structures for the given Config. 2459 * 2460 * @param pState The USB device instance. 2461 * @param uCfgIndex The current Config. index. 2499 return VINF_SUCCESS; 2500 } 2501 2502 2503 /** 2504 * Initializes Endpoints for the given Interface & Alternate setting. 2505 * 2506 * @param pState The USB device instance. 2507 * @param bIf The Interface. 2508 * @param bAlt The Alterate. 2462 2509 * 2463 2510 * @returns VBox status code. 2464 2511 */ 2465 LOCAL int vboxUSBSolarisInitEndPointsForConfig(vboxusb_state_t *pState, uint8_t uCfgIndex) 2466 { 2467 LogFunc((DEVICE_NAME ":vboxUSBSolarisInitEndPointsForConfig pState=%p uCfgIndex=%d\n", pState, uCfgIndex)); 2468 usb_cfg_data_t *pConfig = &pState->pDevDesc->dev_cfg[uCfgIndex]; 2469 uchar_t uCfgValue = pConfig->cfg_descr.bConfigurationValue; 2470 2471 for (uchar_t uInterface = 0; uInterface < pConfig->cfg_n_if; uInterface++) 2472 { 2473 usb_if_data_t *pInterface = &pConfig->cfg_if[uInterface]; 2474 2475 for (uchar_t uAlt = 0; uAlt < pInterface->if_n_alt; uAlt++) 2476 { 2477 usb_alt_if_data_t *pAlt = &pInterface->if_alt[uAlt]; 2478 2479 for (uchar_t uEp = 0; uEp < pAlt->altif_n_ep; uEp++) 2480 { 2481 usb_ep_data_t *pEpData = &pAlt->altif_ep[uEp]; 2482 2483 int rc = vboxUSBSolarisInitEndPoint(pState, pEpData, uCfgValue, uInterface, uAlt); 2484 if (RT_FAILURE(rc)) 2485 { 2486 LogRel((DEVICE_NAME ":vboxUSBSolarisInitEndPointsForConfig: vboxUSBSolarisInitEndPoint failed! pEp=%p " 2487 "uCfgValue=%u uCfgIndex=%u uInterface=%u, uAlt=%u\n", uCfgValue, uCfgIndex, uInterface, uAlt)); 2488 return rc; 2489 } 2490 } 2491 } 2492 } 2493 return VINF_SUCCESS; 2494 } 2495 2496 2497 /** 2498 * Initialize Endpoints structures for the given Interface & Alternate setting. 2499 * 2500 * @param pState The USB device instance. 2501 * @param uInterface The interface being switched to. 2502 * @param uAlt The alt being switched to. 2503 * 2504 * @returns VBox status code. 2505 */ 2506 LOCAL int vboxUSBSolarisInitEndPointsForInterfaceAlt(vboxusb_state_t *pState, uint8_t uInterface, uint8_t uAlt) 2507 { 2508 LogFunc((DEVICE_NAME ":vboxUSBSolarisInitEndPointsForInterfaceAlt pState=%p uInterface=%d uAlt=%d\n", pState, uInterface, 2509 uAlt)); 2512 LOCAL int vboxUsbSolarisInitEpsForIfAlt(vboxusb_state_t *pState, uint8_t bIf, uint8_t bAlt) 2513 { 2514 LogFunc((DEVICE_NAME ": vboxUsbSolarisInitEpsForIfAlt: pState=%p bIf=%d uAlt=%d\n", pState, bIf, bAlt)); 2510 2515 2511 2516 /* Doesn't hurt to be paranoid */ 2512 2517 uint_t uCfgIndex = usb_get_current_cfgidx(pState->pDip); 2513 if ( RT_UNLIKELY(uCfgIndex >= pState->pDevDesc->dev_n_cfg))2514 { 2515 LogRel((DEVICE_NAME ": vboxUSBSolarisInitEndPointsForInterfaceAlt invalid current config index %d\n", uCfgIndex));2516 return VERR_ GENERAL_FAILURE;2518 if (uCfgIndex >= pState->pDevDesc->dev_n_cfg) 2519 { 2520 LogRel((DEVICE_NAME ": vboxUsbSolarisInitEpsForIfAlt: Invalid current config index %d\n", uCfgIndex)); 2521 return VERR_OUT_OF_RANGE; 2517 2522 } 2518 2523 2519 2524 usb_cfg_data_t *pConfig = &pState->pDevDesc->dev_cfg[uCfgIndex]; 2520 uchar_t uCfgValue = pConfig->cfg_descr.bConfigurationValue; 2521 usb_if_data_t *pInterface = &pConfig->cfg_if[uInterface]; 2522 2523 int rc = VINF_SUCCESS; 2524 if (RT_LIKELY(pInterface)) 2525 { 2526 usb_alt_if_data_t *pAlt = &pInterface->if_alt[uAlt]; 2527 if (RT_LIKELY(pAlt)) 2528 { 2529 for (uchar_t uEp = 0; uEp < pAlt->altif_n_ep; uEp++) 2525 for (uchar_t uIf = 0; uIf < pConfig->cfg_n_if; uIf++) 2526 { 2527 usb_if_data_t *pInterface = &pConfig->cfg_if[uIf]; 2528 const uint_t cAlts = pInterface->if_n_alt; 2529 for (uchar_t uAlt = 0; uAlt < cAlts; uAlt++) 2530 { 2531 usb_alt_if_data_t *pAlt = &pInterface->if_alt[uAlt]; 2532 if ( pAlt->altif_descr.bInterfaceNumber == bIf 2533 && pAlt->altif_descr.bAlternateSetting == bAlt) 2530 2534 { 2531 usb_ep_data_t *pEpData = &pAlt->altif_ep[uEp]; 2532 rc = vboxUSBSolarisInitEndPoint(pState, pEpData, uCfgValue, uInterface, uAlt); 2533 if (RT_FAILURE(rc)) 2535 const uint_t cEps = pAlt->altif_n_ep; 2536 for (uchar_t uEp = 0; uEp < cEps; uEp++) 2534 2537 { 2535 LogRel((DEVICE_NAME ":vboxUSBSolarisInitEndPointsForInterfaceAlt: vboxUSBSolarisInitEndPoint failed! pEp=%p " 2536 "uCfgValue=%u uCfgIndex=%u uInterface=%u, uAlt=%u\n", uCfgValue, uCfgIndex, uInterface, uAlt)); 2537 return rc; 2538 uint8_t *pbEpData = (uint8_t *)&pAlt->altif_ep[0]; 2539 usb_ep_data_t *pEpData = (usb_ep_data_t *)(pbEpData + uEp * g_cbUsbEpData); 2540 int rc = vboxUsbSolarisInitEp(pState, pEpData); 2541 if (RT_FAILURE(rc)) 2542 { 2543 uint8_t bCfgValue = pConfig->cfg_descr.bConfigurationValue; 2544 LogRel((DEVICE_NAME ": vboxUsbSolarisInitEpsForIfAlt: Failed to init endpoint! " 2545 "bCfgValue=%u bIf=%#x bAlt=%#x\n", bCfgValue, bIf, bAlt)); 2546 return rc; 2547 } 2538 2548 } 2549 return VINF_SUCCESS; 2539 2550 } 2540 2551 } 2541 else 2542 { 2543 LogRel((DEVICE_NAME ":vboxUSBSolarisInitEndPointsForInterfaceAlt missing alternate.\n")); 2544 rc = VERR_INVALID_POINTER; 2545 } 2546 } 2547 else 2548 { 2549 LogRel((DEVICE_NAME ":vboxUSBSolarisInitEndPointsForInterfaceAlt missing interface.\n")); 2550 rc = VERR_INVALID_POINTER; 2551 } 2552 2553 Log((DEVICE_NAME ":vboxUSBSolarisInitEndPointsForInterfaceAlt returns %d\n", rc)); 2554 return rc; 2555 } 2556 2557 2558 /** 2559 * Destroy all Endpoint Xfer structures. 2552 } 2553 return VERR_NOT_FOUND; 2554 } 2555 2556 2557 /** 2558 * Destroys all Endpoints. 2560 2559 * 2561 2560 * @param pState The USB device instance. 2561 * 2562 2562 * @remarks Requires the state mutex to be held. 2563 2563 * Call only from Detach() or similar as callbacks 2564 2564 */ 2565 LOCAL void vboxU SBSolarisDestroyAllEndPoints(vboxusb_state_t *pState)2566 { 2567 LogFunc((DEVICE_NAME ": vboxUSBSolarisDestroyAllEndPointspState=%p\n", pState));2565 LOCAL void vboxUsbSolarisDestroyAllEps(vboxusb_state_t *pState) 2566 { 2567 LogFunc((DEVICE_NAME ": vboxUsbSolarisDestroyAllEps: pState=%p\n", pState)); 2568 2568 2569 2569 Assert(mutex_owned(&pState->Mtx)); … … 2571 2571 { 2572 2572 vboxusb_ep_t *pEp = &pState->aEps[i]; 2573 if (pEp) 2574 { 2575 vboxUSBSolarisDestroyEndPoint(pState, pEp); 2576 pEp = NULL; 2577 } 2578 } 2579 } 2580 2581 2582 /** 2583 * Destroy an Endpoint. 2573 if (pEp->fInitialized) 2574 vboxUsbSolarisDestroyEp(pState, pEp); 2575 } 2576 } 2577 2578 2579 /** 2580 * Destroys an Endpoint. 2584 2581 * 2585 2582 * @param pState The USB device instance. 2586 2583 * @param pEp The Endpoint. 2584 * 2587 2585 * @remarks Requires the state mutex to be held. 2588 2586 */ 2589 LOCAL void vboxUSBSolarisDestroyEndPoint(vboxusb_state_t *pState, vboxusb_ep_t *pEp) 2590 { 2591 LogFunc((DEVICE_NAME ":vboxUSBSolarisDestroyEndPoint pState=%p pEp=%p\n", pState, pEp)); 2592 2587 LOCAL void vboxUsbSolarisDestroyEp(vboxusb_state_t *pState, vboxusb_ep_t *pEp) 2588 { 2589 LogFunc((DEVICE_NAME ": vboxUsbSolarisDestroyEp: pState=%p pEp=%p\n", pState, pEp)); 2590 2591 Assert(pEp->fInitialized); 2593 2592 Assert(mutex_owned(&pState->Mtx)); 2594 if (pEp->fInitialized == VBOXUSB_EP_INITIALIZED) 2595 { 2596 vboxusb_urb_t *pUrb = list_remove_head(&pEp->hIsocInUrbs); 2597 while (pUrb) 2598 { 2599 if (pUrb->pMsg) 2600 freemsg(pUrb->pMsg); 2601 RTMemFree(pUrb); 2602 pUrb = list_remove_head(&pEp->hIsocInUrbs); 2603 } 2604 pEp->cIsocInUrbs = 0; 2605 list_destroy(&pEp->hIsocInUrbs); 2606 2607 vboxusb_isoc_req_t *pIsocReq = list_remove_head(&pEp->hIsocInLandedReqs); 2608 while (pIsocReq) 2609 { 2610 kmem_free(pIsocReq, sizeof(vboxusb_isoc_req_t)); 2611 pIsocReq = list_remove_head(&pEp->hIsocInLandedReqs); 2612 } 2613 pEp->cbIsocInLandedReqs = 0; 2614 list_destroy(&pEp->hIsocInLandedReqs); 2615 2616 pEp->fInitialized = 0; 2617 } 2618 } 2619 2620 2621 /** 2622 * Close all non-default Endpoints and drains the default pipe. 2593 vboxusb_urb_t *pUrb = list_remove_head(&pEp->hIsocInUrbs); 2594 while (pUrb) 2595 { 2596 if (pUrb->pMsg) 2597 freemsg(pUrb->pMsg); 2598 RTMemFree(pUrb); 2599 pUrb = list_remove_head(&pEp->hIsocInUrbs); 2600 } 2601 pEp->cIsocInUrbs = 0; 2602 list_destroy(&pEp->hIsocInUrbs); 2603 2604 vboxusb_isoc_req_t *pIsocReq = list_remove_head(&pEp->hIsocInLandedReqs); 2605 while (pIsocReq) 2606 { 2607 kmem_free(pIsocReq, sizeof(vboxusb_isoc_req_t)); 2608 pIsocReq = list_remove_head(&pEp->hIsocInLandedReqs); 2609 } 2610 pEp->cbIsocInLandedReqs = 0; 2611 list_destroy(&pEp->hIsocInLandedReqs); 2612 2613 pEp->fInitialized = false; 2614 } 2615 2616 2617 /** 2618 * Closes all non-default pipes and drains the default pipe. 2623 2619 * 2624 2620 * @param pState The USB device instance. … … 2627 2623 * @remarks Requires the device state mutex to be held. 2628 2624 */ 2629 LOCAL void vboxU SBSolarisCloseAllPipes(vboxusb_state_t *pState, bool fDefault)2630 { 2631 LogFunc((DEVICE_NAME ": vboxUSBSolarisCloseAllPipespState=%p\n", pState));2625 LOCAL void vboxUsbSolarisCloseAllPipes(vboxusb_state_t *pState, bool fDefault) 2626 { 2627 LogFunc((DEVICE_NAME ": vboxUsbSolarisCloseAllPipes: pState=%p\n", pState)); 2632 2628 2633 2629 for (int i = 1; i < VBOXUSB_MAX_ENDPOINTS; i++) … … 2637 2633 && pEp->pPipe) 2638 2634 { 2639 Log((DEVICE_NAME ": vboxUSBSolarisCloseAllPipes closing[%d]\n", i));2640 vboxU SBSolarisClosePipe(pState, pEp);2635 Log((DEVICE_NAME ": vboxUsbSolarisCloseAllPipes: Closing[%d]\n", i)); 2636 vboxUsbSolarisClosePipe(pState, pEp); 2641 2637 } 2642 2638 } … … 2648 2644 && pEp->pPipe) 2649 2645 { 2650 vboxU SBSolarisClosePipe(pState, pEp);2651 Log((DEVICE_NAME ": vboxUSBSolarisCloseAllPipes closed default pipe.\n"));2652 } 2653 } 2654 } 2655 2656 2657 /** 2658 * Open the pipe foran Endpoint.2646 vboxUsbSolarisClosePipe(pState, pEp); 2647 Log((DEVICE_NAME ": vboxUsbSolarisCloseAllPipes: Closed default pipe\n")); 2648 } 2649 } 2650 } 2651 2652 2653 /** 2654 * Opens the pipe associated with an Endpoint. 2659 2655 * 2660 2656 * @param pState The USB device instance. … … 2664 2660 * @returns VBox status code. 2665 2661 */ 2666 LOCAL int vboxU SBSolarisOpenPipe(vboxusb_state_t *pState, vboxusb_ep_t *pEp)2662 LOCAL int vboxUsbSolarisOpenPipe(vboxusb_state_t *pState, vboxusb_ep_t *pEp) 2667 2663 { 2668 2664 Assert(mutex_owned(&pState->Mtx)); … … 2674 2670 return VINF_SUCCESS; 2675 2671 2676 2677 2672 /* 2678 2673 * Default Endpoint; already opened just copy the pipe handle. … … 2682 2677 pEp->pPipe = pState->pDevDesc->dev_default_ph; 2683 2678 pEp->EpState |= VBOXUSB_EP_STATE_OPENED; 2684 Log((DEVICE_NAME ": vboxUSBSolarisOpenPipe default pipe opened.\n"));2679 Log((DEVICE_NAME ": vboxUsbSolarisOpenPipe: Default pipe opened\n")); 2685 2680 return VINF_SUCCESS; 2686 2681 } … … 2694 2689 if (rc == USB_SUCCESS) 2695 2690 { 2696 LogFunc((DEVICE_NAME ": vboxUSBSolarisOpenPipe: Opened pipe.pState=%p pEp=%p\n", pState, pEp));2691 LogFunc((DEVICE_NAME ": vboxUsbSolarisOpenPipe: Opened pipe, pState=%p pEp=%p\n", pState, pEp)); 2697 2692 usb_pipe_set_private(pEp->pPipe, (usb_opaque_t)pEp); 2698 2693 … … 2719 2714 pEp->cbMaxIsocData = 400 * cbMax * 8; 2720 2715 } 2721 Log((DEVICE_NAME ":vboxUSBSolarisOpenPipe pEp=%p cbMaxIsocData=%u\n", pEp->cbMaxIsocData)); 2716 Log((DEVICE_NAME ": vboxUsbSolarisOpenPipe: bEndpoint=%#x cbMaxIsocData=%u\n", pEp->EpDesc.bEndpointAddress, 2717 pEp->cbMaxIsocData)); 2722 2718 } 2723 2719 … … 2727 2723 else 2728 2724 { 2729 LogRel((DEVICE_NAME ": vboxUSBSolarisOpenPipe failed! rc=%d pState=%p pEp=%p\n", rc, pState, pEp));2725 LogRel((DEVICE_NAME ": vboxUsbSolarisOpenPipe: Failed! rc=%d pState=%p pEp=%p\n", rc, pState, pEp)); 2730 2726 rc = VERR_BAD_PIPE; 2731 2727 } … … 2736 2732 2737 2733 /** 2738 * Close the pipe of theEndpoint.2734 * Closes the pipe associated with an Endpoint. 2739 2735 * 2740 2736 * @param pState The USB device instance. … … 2743 2739 * @remarks Requires the device state mutex to be held. 2744 2740 */ 2745 LOCAL void vboxU SBSolarisClosePipe(vboxusb_state_t *pState, vboxusb_ep_t *pEp)2746 { 2747 LogFunc((DEVICE_NAME ": vboxUSBSolarisClosePipepState=%p pEp=%p\n", pState, pEp));2741 LOCAL void vboxUsbSolarisClosePipe(vboxusb_state_t *pState, vboxusb_ep_t *pEp) 2742 { 2743 LogFunc((DEVICE_NAME ": vboxUsbSolarisClosePipe: pState=%p pEp=%p\n", pState, pEp)); 2748 2744 AssertPtr(pEp); 2749 2745 … … 2760 2756 usb_pipe_drain_reqs(pState->pDip, pEp->pPipe, 0, USB_FLAGS_SLEEP, NULL /* callback */, NULL /* callback arg. */); 2761 2757 mutex_enter(&pState->Mtx); 2762 Log((DEVICE_NAME ":vboxUSBSolarisClosePipe closed default pipe\n")); 2758 Log((DEVICE_NAME ": vboxUsbSolarisClosePipe: Closed default pipe\n")); 2759 pState->fDefaultPipeOpen = false; 2763 2760 } 2764 2761 else … … 2778 2775 * Non-default pipe: close it. 2779 2776 */ 2780 Log((DEVICE_NAME ": vboxUSBSolarisClosePipe pipe bmAttributes=%#x bEndpointAddress=%#x\n", pEp->EpDesc.bmAttributes,2777 Log((DEVICE_NAME ": vboxUsbSolarisClosePipe: Pipe bmAttributes=%#x bEndpoint=%#x\n", pEp->EpDesc.bmAttributes, 2781 2778 pEp->EpDesc.bEndpointAddress)); 2782 2779 mutex_exit(&pState->Mtx); … … 2790 2787 pEp->pPipe = NULL; 2791 2788 2792 Log((DEVICE_NAME ": vboxUSBSolarisClosePipe successful. pEp=%p\n", pEp));2789 Log((DEVICE_NAME ": vboxUsbSolarisClosePipe: Success, bEndpoint=%#x\n", pEp->EpDesc.bEndpointAddress)); 2793 2790 } 2794 2791 … … 2798 2795 2799 2796 /** 2800 * Find the Configuration index for the passed in Configuration value.2797 * Finds the Configuration index for the passed in Configuration value. 2801 2798 * 2802 2799 * @param pState The USB device instance. 2803 * @param uCfgValue The Configuration value.2800 * @param bConfig The Configuration. 2804 2801 * 2805 2802 * @returns The configuration index if found, otherwise -1. 2806 2803 */ 2807 LOCAL int vboxU SBSolarisGetConfigIndex(vboxusb_state_t *pState, uint_t uCfgValue)2804 LOCAL int vboxUsbSolarisGetConfigIndex(vboxusb_state_t *pState, uint_t bConfig) 2808 2805 { 2809 2806 for (int CfgIndex = 0; CfgIndex < pState->pDevDesc->dev_n_cfg; CfgIndex++) 2810 2807 { 2811 2808 usb_cfg_data_t *pConfig = &pState->pDevDesc->dev_cfg[CfgIndex]; 2812 if (pConfig->cfg_descr.bConfigurationValue == uCfgValue)2809 if (pConfig->cfg_descr.bConfigurationValue == bConfig) 2813 2810 return CfgIndex; 2814 2811 } … … 2826 2823 * @returns The allocated Isoc. In URB to be used. 2827 2824 */ 2828 LOCAL vboxusb_urb_t *vboxU SBSolarisGetIsocInURB(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq)2825 LOCAL vboxusb_urb_t *vboxUsbSolarisGetIsocInUrb(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq) 2829 2826 { 2830 2827 /* … … 2856 2853 } 2857 2854 else 2858 LogRel((DEVICE_NAME ": vboxUSBSolarisGetIsocInURB failed to alloc %d bytes.\n", sizeof(vboxusb_urb_t)));2855 LogRel((DEVICE_NAME ": vboxUsbSolarisGetIsocInUrb: Failed to alloc %d bytes\n", sizeof(vboxusb_urb_t))); 2859 2856 return pUrb; 2860 2857 } … … 2870 2867 * @returns The allocated URB to be used, or NULL upon failure. 2871 2868 */ 2872 LOCAL vboxusb_urb_t *vboxUSBSolarisQueueURB(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq, mblk_t *pMsg) 2873 { 2874 LogFunc((DEVICE_NAME ":vboxUSBSolarisQueueURB pState=%p pUrbReq=%p\n", pState, pUrbReq)); 2869 LOCAL vboxusb_urb_t *vboxUsbSolarisQueueUrb(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq, mblk_t *pMsg) 2870 { 2871 Assert(pUrbReq); 2872 LogFunc((DEVICE_NAME ": vboxUsbSolarisQueueUrb: pState=%p pUrbReq=%p\n", pState, pUrbReq)); 2875 2873 2876 2874 mutex_enter(&pState->Mtx); 2877 2875 2878 2876 /* 2879 * Discard oldest queued URB if we've queued max URBs and none of them have completed.2877 * Grab a URB from the free list. 2880 2878 */ 2881 if (pState->cInflightUrbs >= VBOXUSB_URB_QUEUE_SIZE) 2882 { 2883 vboxusb_urb_t *pUrb = list_head(&pState->hUrbs); 2884 if (RT_LIKELY(pUrb)) 2885 { 2886 if (pUrb->pMsg) 2887 { 2888 freemsg(pUrb->pMsg); 2889 pUrb->pMsg = NULL; 2890 } 2891 pUrb->enmState = VBOXUSB_URB_STATE_FREE; 2892 } 2893 } 2894 2895 vboxusb_urb_t *pUrb = list_head(&pState->hUrbs); 2896 if ( !pUrb 2897 || ( pUrb 2898 && pUrb->enmState != VBOXUSB_URB_STATE_FREE)) 2899 { 2879 vboxusb_urb_t *pUrb = list_remove_head(&pState->hFreeUrbs); 2880 if (pUrb) 2881 { 2882 Assert(pUrb->enmState == VBOXUSB_URB_STATE_FREE); 2883 Assert(!pUrb->pMsg); 2884 Assert(pState->cFreeUrbs > 0); 2885 --pState->cFreeUrbs; 2886 } 2887 else 2888 { 2889 /* 2890 * We can't discard "old" URBs. For instance, INTR IN URBs that don't complete as 2891 * they don't have a timeout can essentially take arbitrarily long to complete depending 2892 * on the device and it's not safe to discard them in case they -do- complete. However, 2893 * we also have to reasonably assume a device doesn't have too many pending URBs always. 2894 * 2895 * Thus we just use a large queue and simply refuse further transfers. This is not 2896 * a situation which normally ever happens as usually there are at most than 4 or 5 URBs 2897 * in-flight until we reap them. 2898 */ 2899 uint32_t const cTotalUrbs = pState->cInflightUrbs + pState->cFreeUrbs + pState->cLandedUrbs; 2900 if (cTotalUrbs >= VBOXUSB_URB_QUEUE_SIZE) 2901 { 2902 mutex_exit(&pState->Mtx); 2903 LogRelMax(5, (DEVICE_NAME ": vboxUsbSolarisQueueUrb: Max queue size %u reached, refusing further transfers", 2904 cTotalUrbs)); 2905 return NULL; 2906 } 2907 2908 /* 2909 * Allocate a new URB as we have no free URBs. 2910 */ 2900 2911 mutex_exit(&pState->Mtx); 2901 2912 pUrb = RTMemAllocZ(sizeof(vboxusb_urb_t)); 2902 2913 if (RT_UNLIKELY(!pUrb)) 2903 2914 { 2904 LogRel((DEVICE_NAME ": vboxUSBSolarisQueueURB failed to alloc %d bytes.\n", sizeof(vboxusb_urb_t)));2915 LogRel((DEVICE_NAME ": vboxUsbSolarisQueueUrb: Failed to alloc %d bytes\n", sizeof(vboxusb_urb_t))); 2905 2916 return NULL; 2906 2917 } 2907 2918 mutex_enter(&pState->Mtx); 2908 2919 } 2909 else 2910 { 2911 /* 2912 * Remove from head and move to tail so that when several URBs are reaped continuously we get to use 2913 * up each one free 'head'. 2914 */ 2915 Assert(pUrb && pUrb->enmState == VBOXUSB_URB_STATE_FREE); 2916 list_remove_head(&pState->hUrbs); 2917 } 2918 2919 list_insert_tail(&pState->hUrbs, pUrb); 2920 2921 /* 2922 * Add the URB to the inflight list. 2923 */ 2924 list_insert_tail(&pState->hInflightUrbs, pUrb); 2920 2925 ++pState->cInflightUrbs; 2921 2926 2922 pUrb->enmState = VBOXUSB_URB_STATE_INFLIGHT; 2923 2924 Assert(pUrb->pMsg == NULL); 2925 pUrb->pState = pState; 2926 Log((DEVICE_NAME ":vboxUSBSolarisQueueURB cInflightUrbs=%d\n", pState->cInflightUrbs)); 2927 2928 if (RT_LIKELY(pUrbReq)) 2929 { 2930 pUrb->pvUrbR3 = pUrbReq->pvUrbR3; 2931 pUrb->bEndpoint = pUrbReq->bEndpoint; 2932 pUrb->enmType = pUrbReq->enmType; 2933 pUrb->enmDir = pUrbReq->enmDir; 2934 pUrb->enmStatus = pUrbReq->enmStatus; 2935 pUrb->fShortOk = pUrbReq->fShortOk; 2936 pUrb->pvDataR3 = (RTR3PTR)pUrbReq->pvData; 2937 pUrb->cbDataR3 = pUrbReq->cbData; 2938 pUrb->cIsocPkts = pUrbReq->cIsocPkts; 2939 2940 if (pUrbReq->enmType == VUSBXFERTYPE_ISOC) 2941 { 2942 for (unsigned i = 0; i < pUrbReq->cIsocPkts; i++) 2943 pUrb->aIsocPkts[i].cbPkt = pUrbReq->aIsocPkts[i].cbPkt; 2944 } 2945 2946 pUrb->pMsg = pMsg; 2927 Assert(!pUrb->pMsg); 2928 pUrb->pMsg = pMsg; 2929 pUrb->pState = pState; 2930 pUrb->enmState = VBOXUSB_URB_STATE_INFLIGHT; 2931 pUrb->pvUrbR3 = pUrbReq->pvUrbR3; 2932 pUrb->bEndpoint = pUrbReq->bEndpoint; 2933 pUrb->enmType = pUrbReq->enmType; 2934 pUrb->enmDir = pUrbReq->enmDir; 2935 pUrb->enmStatus = pUrbReq->enmStatus; 2936 pUrb->fShortOk = pUrbReq->fShortOk; 2937 pUrb->pvDataR3 = (RTR3PTR)pUrbReq->pvData; 2938 pUrb->cbDataR3 = pUrbReq->cbData; 2939 pUrb->cIsocPkts = pUrbReq->cIsocPkts; 2940 if (pUrbReq->enmType == VUSBXFERTYPE_ISOC) 2941 { 2942 for (unsigned i = 0; i < pUrbReq->cIsocPkts; i++) 2943 pUrb->aIsocPkts[i].cbPkt = pUrbReq->aIsocPkts[i].cbPkt; 2947 2944 } 2948 2945 2949 2946 mutex_exit(&pState->Mtx); 2950 2951 2947 return pUrb; 2952 2948 } … … 2961 2957 * @remarks All pipes could be closed at this point (e.g. Device disconnected during inflight URBs) 2962 2958 */ 2963 LOCAL inline void vboxUSBSolarisDeQueueURB(vboxusb_urb_t *pUrb, int URBStatus)2964 { 2965 LogFunc((DEVICE_NAME ": vboxUSBSolarisDeQueuepUrb=%p\n", pUrb));2959 LOCAL void vboxUsbSolarisDeQueueUrb(vboxusb_urb_t *pUrb, int URBStatus) 2960 { 2961 LogFunc((DEVICE_NAME ": vboxUsbSolarisDeQueue: pUrb=%p\n", pUrb)); 2966 2962 AssertPtrReturnVoid(pUrb); 2967 2963 2968 pUrb->enmStatus = vboxUSBSolarisGetUrbStatus(URBStatus); 2964 pUrb->enmStatus = vboxUsbSolarisGetUrbStatus(URBStatus); 2965 if (pUrb->enmStatus != VUSBSTATUS_OK) 2966 Log((DEVICE_NAME ": vboxUsbSolarisDeQueueUrb: URB failed! URBStatus=%d bEndpoint=%#x\n", URBStatus, pUrb->bEndpoint)); 2969 2967 2970 2968 vboxusb_state_t *pState = pUrb->pState; … … 2975 2973 2976 2974 /* 2977 * Remove it from the inflight list & move it to landed list.2975 * Remove it from the inflight list & move it to the landed list. 2978 2976 */ 2979 list_remove(&pState->hUrbs, pUrb); 2977 list_remove(&pState->hInflightUrbs, pUrb); 2978 Assert(pState->cInflightUrbs > 0); 2980 2979 --pState->cInflightUrbs; 2980 2981 2981 list_insert_tail(&pState->hLandedUrbs, pUrb); 2982 2983 vboxUSBSolarisNotifyComplete(pUrb->pState); 2982 ++pState->cLandedUrbs; 2983 2984 vboxUsbSolarisNotifyComplete(pUrb->pState); 2984 2985 mutex_exit(&pState->Mtx); 2985 } 2986 else 2987 { 2988 Log((DEVICE_NAME ":vboxUSBSolarisDeQueue State Gone.\n")); 2989 freemsg(pUrb->pMsg); 2990 pUrb->pMsg = NULL; 2991 pUrb->enmStatus = VUSBSTATUS_INVALID; 2992 } 2986 return; 2987 } 2988 2989 /* Well, let's at least not leak memory... */ 2990 freemsg(pUrb->pMsg); 2991 pUrb->pMsg = NULL; 2992 pUrb->enmStatus = VUSBSTATUS_INVALID; 2993 2994 LogRel((DEVICE_NAME ": vboxUsbSolarisDeQueue: State Gone\n")); 2993 2995 } 2994 2996 … … 2999 3001 * @param pUrb The URB to move. 3000 3002 */ 3001 LOCAL inline void vboxUSBSolarisConcatMsg(vboxusb_urb_t *pUrb)3003 LOCAL void vboxUsbSolarisConcatMsg(vboxusb_urb_t *pUrb) 3002 3004 { 3003 3005 /* … … 3013 3015 pUrb->pMsg = pFullMsg; 3014 3016 } 3015 } 3016 } 3017 3018 3019 /** 3020 * User process poll wake up wrapper for asynchronous URB completion. 3017 else 3018 LogRel((DEVICE_NAME ": vboxUsbSolarisConcatMsg: Failed. Expect glitches due to truncated data!\n")); 3019 } 3020 } 3021 3022 3023 /** 3024 * Wakes up a user process signalling URB completion. 3021 3025 * 3022 3026 * @param pState The USB device instance. 3023 3027 * @remarks Requires the device state mutex to be held. 3024 3028 */ 3025 LOCAL inline void vboxUSBSolarisNotifyComplete(vboxusb_state_t *pState)3026 { 3027 if (pState->fPoll & VBOXUSB_POLL_ON)3029 LOCAL void vboxUsbSolarisNotifyComplete(vboxusb_state_t *pState) 3030 { 3031 if (pState->fPollPending) 3028 3032 { 3029 3033 pollhead_t *pPollHead = &pState->PollHead; 3030 pState->fPoll |= VBOXUSB_POLL_REAP_PENDING;3034 pState->fPollPending = false; 3031 3035 mutex_exit(&pState->Mtx); 3032 3036 pollwakeup(pPollHead, POLLIN); … … 3037 3041 3038 3042 /** 3039 * User process poll wake up wrapper for hotplug events.3043 * Wakes up a user process signalling a device unplug events. 3040 3044 * 3041 3045 * @param pState The USB device instance. 3042 3046 * @remarks Requires the device state mutex to be held. 3043 3047 */ 3044 LOCAL inline void vboxUSBSolarisNotifyHotplug(vboxusb_state_t *pState)3045 { 3046 if (pState->fPoll & VBOXUSB_POLL_ON)3048 LOCAL void vboxUsbSolarisNotifyUnplug(vboxusb_state_t *pState) 3049 { 3050 if (pState->fPollPending) 3047 3051 { 3048 3052 pollhead_t *pPollHead = &pState->PollHead; 3049 pState->fPoll |= VBOXUSB_POLL_DEV_UNPLUGGED;3053 pState->fPollPending = false; 3050 3054 mutex_exit(&pState->Mtx); 3051 3055 pollwakeup(pPollHead, POLLHUP); … … 3056 3060 3057 3061 /** 3058 * Perform a Control Xfer.3062 * Performs a Control Xfer. 3059 3063 * 3060 3064 * @param pState The USB device instance. … … 3063 3067 * 3064 3068 * @returns VBox status code. 3065 * @remarks Any errors, the caller should free pUrb->pMsg. 3066 */ 3067 LOCAL int vboxUSBSolarisCtrlXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *pUrb) 3068 { 3069 LogFunc((DEVICE_NAME ":vboxUSBSolarisCtrlXfer pState=%p pEp=%p pUrb=%p enmDir=%d cbData=%d\n", pState, pEp, pUrb, 3069 */ 3070 LOCAL int vboxUsbSolarisCtrlXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *pUrb) 3071 { 3072 LogFunc((DEVICE_NAME ": vboxUsbSolarisCtrlXfer: pState=%p pEp=%p pUrb=%p enmDir=%d cbData=%d\n", pState, pEp, pUrb, 3070 3073 pUrb->enmDir, pUrb->cbDataR3)); 3071 3074 3072 3075 AssertPtrReturn(pUrb->pMsg, VERR_INVALID_PARAMETER); 3073 uchar_t *pSetupData = pUrb->pMsg->b_rptr; 3074 size_t cbData = pUrb->cbDataR3 > VBOXUSB_CTRL_XFER_SIZE ? pUrb->cbDataR3 - VBOXUSB_CTRL_XFER_SIZE : 0; 3076 const size_t cbData = pUrb->cbDataR3 > VBOXUSB_CTRL_XFER_SIZE ? pUrb->cbDataR3 - VBOXUSB_CTRL_XFER_SIZE : 0; 3075 3077 3076 3078 /* 3077 3079 * Allocate a wrapper request. 3078 3080 */ 3079 int rc = VINF_SUCCESS; 3080 usb_ctrl_req_t *pReq = usb_alloc_ctrl_req(pState->pDip, cbData, USB_FLAGS_NOSLEEP); 3081 usb_ctrl_req_t *pReq = usb_alloc_ctrl_req(pState->pDip, cbData, USB_FLAGS_SLEEP); 3081 3082 if (RT_LIKELY(pReq)) 3082 3083 { 3084 uchar_t *pSetupData = pUrb->pMsg->b_rptr; 3085 3083 3086 /* 3084 3087 * Initialize the Ctrl Xfer Header. … … 3093 3096 && cbData) 3094 3097 { 3095 pUrb->pMsg->b_rptr += VBOXUSB_CTRL_XFER_SIZE; 3096 bcopy(pUrb->pMsg->b_rptr, pReq->ctrl_data->b_wptr, cbData); 3098 bcopy(pSetupData + VBOXUSB_CTRL_XFER_SIZE, pReq->ctrl_data->b_wptr, cbData); 3097 3099 pReq->ctrl_data->b_wptr += cbData; 3098 3100 } … … 3104 3106 * Initialize callbacks and timeouts. 3105 3107 */ 3106 usb_req_attrs_t fAttributes = USB_ATTRS_AUTOCLEARING; 3107 if ( pUrb->enmDir == VUSBDIRECTION_IN 3108 && pUrb->fShortOk) 3109 { 3110 fAttributes |= USB_ATTRS_SHORT_XFER_OK; 3111 } 3112 pReq->ctrl_cb = vboxUSBSolarisCtrlXferCompleted; 3113 pReq->ctrl_exc_cb = vboxUSBSolarisCtrlXferCompleted; 3108 pReq->ctrl_cb = vboxUsbSolarisCtrlXferCompleted; 3109 pReq->ctrl_exc_cb = vboxUsbSolarisCtrlXferCompleted; 3114 3110 pReq->ctrl_timeout = VBOXUSB_CTRL_XFER_TIMEOUT; 3115 pReq->ctrl_attributes = fAttributes; 3116 3111 pReq->ctrl_attributes = USB_ATTRS_AUTOCLEARING | USB_ATTRS_SHORT_XFER_OK; 3117 3112 pReq->ctrl_client_private = (usb_opaque_t)pUrb; 3118 3119 LogFunc((DEVICE_NAME ":vboxUSBSolarisCtrlXfer ctrl_wLength=%#RX16 cbData=%#zx fShortOk=%RTbool\n", pReq->ctrl_wLength,3120 cbData, !!(fAttributes & USB_ATTRS_SHORT_XFER_OK)));3121 Log((DEVICE_NAME ":vboxUSBSolarisCtrlXfer %.*Rhxd\n", VBOXUSB_CTRL_XFER_SIZE, pSetupData));3122 3113 3123 3114 /* 3124 3115 * Submit the request. 3125 3116 */ 3126 rc = usb_pipe_ctrl_xfer(pEp->pPipe, pReq, USB_FLAGS_NOSLEEP); 3127 3117 int rc = usb_pipe_ctrl_xfer(pEp->pPipe, pReq, USB_FLAGS_NOSLEEP); 3128 3118 if (RT_LIKELY(rc == USB_SUCCESS)) 3129 3119 return VINF_SUCCESS; 3130 else 3131 { 3132 LogRel((DEVICE_NAME ":vboxUSBSolarisCtrlXfer usb_pipe_ctrl_xfer failed! rc=%d\n", rc)); 3133 rc = VERR_PIPE_IO_ERROR; 3134 } 3120 3121 LogRel((DEVICE_NAME ": vboxUsbSolarisCtrlXfer: Request failed! bEndpoint=%#x rc=%d\n", pUrb->bEndpoint, rc)); 3135 3122 3136 3123 usb_free_ctrl_req(pReq); 3137 } 3138 else 3139 { 3140 LogRel((DEVICE_NAME ":vboxUSBSolarisCtrlXfer failed to alloc request.\n")); 3141 rc = VERR_NO_MEMORY; 3142 } 3143 3144 return rc; 3124 return VERR_PIPE_IO_ERROR; 3125 } 3126 3127 LogRel((DEVICE_NAME ": vboxUsbSolarisCtrlXfer: Failed to alloc request for %u bytes\n", cbData)); 3128 return VERR_NO_MEMORY; 3145 3129 } 3146 3130 … … 3152 3136 * @param pReq The Ctrl request. 3153 3137 */ 3154 LOCAL void vboxUSBSolarisCtrlXferCompleted(usb_pipe_handle_t pPipe, usb_ctrl_req_t *pReq) 3155 { 3156 LogFunc((DEVICE_NAME ":vboxUSBSolarisCtrlXferCompleted pPipe=%p pReq=%p\n", pPipe, pReq)); 3138 LOCAL void vboxUsbSolarisCtrlXferCompleted(usb_pipe_handle_t pPipe, usb_ctrl_req_t *pReq) 3139 { 3140 LogFunc((DEVICE_NAME ": vboxUsbSolarisCtrlXferCompleted: pPipe=%p pReq=%p\n", pPipe, pReq)); 3141 Assert(pReq); 3142 Assert(!(pReq->ctrl_cb_flags & USB_CB_INTR_CONTEXT)); 3157 3143 3158 3144 vboxusb_urb_t *pUrb = (vboxusb_urb_t *)pReq->ctrl_client_private; … … 3161 3147 /* 3162 3148 * Funky stuff: We need to reconstruct the header for control transfers. 3163 * Let us chain along the data and while we dequeue the URB we attempt to 3164 * concatenate the entire message there. 3149 * Let us chain along the data and concatenate the entire message. 3165 3150 */ 3166 3151 mblk_t *pSetupMsg = allocb(sizeof(VUSBSETUP), BPRI_MED); … … 3169 3154 VUSBSETUP SetupData; 3170 3155 SetupData.bmRequestType = pReq->ctrl_bmRequestType; 3171 SetupData.bRequest = pReq->ctrl_bRequest; 3172 SetupData.wValue = pReq->ctrl_wValue; 3173 SetupData.wIndex = pReq->ctrl_wIndex; 3174 SetupData.wLength = pReq->ctrl_wLength; 3156 SetupData.bRequest = pReq->ctrl_bRequest; 3157 SetupData.wValue = pReq->ctrl_wValue; 3158 SetupData.wIndex = pReq->ctrl_wIndex; 3159 SetupData.wLength = pReq->ctrl_wLength; 3160 3175 3161 bcopy(&SetupData, pSetupMsg->b_wptr, sizeof(VUSBSETUP)); 3176 3162 pSetupMsg->b_wptr += sizeof(VUSBSETUP); 3177 3163 3178 3164 /* 3179 * Should be safe to update pMsg here without the state mutex, see vboxUSBSolarisSendURB() 3180 * and vboxUSBSolarisQueueURB() as the URB state is (still) not VBOXUSB_URB_STATE_FREE. 3165 * Should be safe to update pMsg here without the state mutex as typically nobody else 3166 * touches this URB in the inflight list. 3167 * 3168 * The reason we choose to use vboxUsbSolarisConcatMsg here is that we don't assume the 3169 * message returned by Solaris is one contiguous chunk in 'pMsg->b_rptr'. 3181 3170 */ 3171 Assert(!pUrb->pMsg); 3182 3172 pUrb->pMsg = pSetupMsg; 3183 3173 pUrb->pMsg->b_cont = pReq->ctrl_data; 3184 3174 pReq->ctrl_data = NULL; 3185 vboxUSBSolarisConcatMsg(pUrb); 3186 3187 #ifdef DEBUG_ramshankar 3188 if ( pUrb->pMsg 3189 && pUrb->pMsg->b_cont == NULL) /* Concat succeeded */ 3190 { 3191 Log((DEVICE_NAME ":vboxUSBSolarisCtrlXferCompleted prepended header rc=%d cbData=%d.\n", 3192 pReq->ctrl_completion_reason, MBLKL(pUrb->pMsg))); 3193 Log((DEVICE_NAME ":%.*Rhxd\n", MBLKL(pUrb->pMsg), pUrb->pMsg->b_rptr)); 3194 } 3195 #endif 3196 3197 /* 3198 * Update the URB and move to landed list for reaping. 3199 */ 3200 vboxUSBSolarisDeQueueURB(pUrb, pReq->ctrl_completion_reason); 3175 vboxUsbSolarisConcatMsg(pUrb); 3201 3176 } 3202 3177 else 3203 { 3204 LogRel((DEVICE_NAME ":vboxUSBSolarisCtrlXferCompleted failed to alloc %d bytes for Setup Header.\n", 3205 sizeof(VUSBSETUP))); 3206 } 3178 LogRel((DEVICE_NAME ": vboxUsbSolarisCtrlXferCompleted: Failed to alloc %u bytes for header\n", sizeof(VUSBSETUP))); 3179 3180 /* 3181 * Update the URB and move to landed list for reaping. 3182 */ 3183 vboxUsbSolarisDeQueueUrb(pUrb, pReq->ctrl_completion_reason); 3207 3184 } 3208 3185 else 3209 LogRel((DEVICE_NAME ": vboxUSBSolarisCtrlXferCompleted Extreme error! missing private data.\n"));3186 LogRel((DEVICE_NAME ": vboxUsbSolarisCtrlXferCompleted: Extreme error! missing private data\n")); 3210 3187 3211 3188 usb_free_ctrl_req(pReq); … … 3214 3191 3215 3192 /** 3216 * Perform a Bulk Xfer.3193 * Performs a Bulk Xfer. 3217 3194 * 3218 3195 * @param pState The USB device instance. … … 3223 3200 * @remarks Any errors, the caller should free pUrb->pMsg. 3224 3201 */ 3225 LOCAL int vboxU SBSolarisBulkXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *pUrb)3226 { 3227 LogFunc((DEVICE_NAME ": vboxUSBSolarisBulkXferpState=%p pEp=%p pUrb=%p enmDir=%d cbData=%d\n", pState, pEp, pUrb,3202 LOCAL int vboxUsbSolarisBulkXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *pUrb) 3203 { 3204 LogFunc((DEVICE_NAME ": vboxUsbSolarisBulkXfer: pState=%p pEp=%p pUrb=%p enmDir=%d cbData=%d\n", pState, pEp, pUrb, 3228 3205 pUrb->enmDir, pUrb->cbDataR3)); 3229 3206 … … 3231 3208 * Allocate a wrapper request. 3232 3209 */ 3233 int rc = VINF_SUCCESS; 3234 usb_bulk_req_t *pReq = usb_alloc_bulk_req(pState->pDip, pUrb->enmDir == VUSBDIRECTION_IN ? pUrb->cbDataR3 : 0, 3235 USB_FLAGS_NOSLEEP); 3210 size_t const cbAlloc = pUrb->enmDir == VUSBDIRECTION_IN ? pUrb->cbDataR3 : 0; 3211 usb_bulk_req_t *pReq = usb_alloc_bulk_req(pState->pDip, cbAlloc, USB_FLAGS_SLEEP); 3236 3212 if (RT_LIKELY(pReq)) 3237 3213 { … … 3241 3217 usb_req_attrs_t fAttributes = USB_ATTRS_AUTOCLEARING; 3242 3218 if (pUrb->enmDir == VUSBDIRECTION_OUT) 3219 { 3243 3220 pReq->bulk_data = pUrb->pMsg; 3221 pUrb->pMsg = NULL; 3222 } 3244 3223 else if ( pUrb->enmDir == VUSBDIRECTION_IN 3245 3224 && pUrb->fShortOk) … … 3248 3227 } 3249 3228 3229 Assert(!pUrb->pMsg); 3250 3230 pReq->bulk_len = pUrb->cbDataR3; 3251 pReq->bulk_cb = vboxU SBSolarisBulkXferCompleted;3252 pReq->bulk_exc_cb = vboxU SBSolarisBulkXferCompleted;3253 pReq->bulk_timeout = VBOXUSB_BULK_XFER_TIMEOUT;3231 pReq->bulk_cb = vboxUsbSolarisBulkXferCompleted; 3232 pReq->bulk_exc_cb = vboxUsbSolarisBulkXferCompleted; 3233 pReq->bulk_timeout = 0; 3254 3234 pReq->bulk_attributes = fAttributes; 3255 3235 pReq->bulk_client_private = (usb_opaque_t)pUrb; … … 3258 3238 if (RT_UNLIKELY(pUrb->cbDataR3 > pState->cbMaxBulkXfer)) 3259 3239 { 3260 LogRel((DEVICE_NAME ": vboxUSBSolarisBulkXfer requesting %d bytes when only %d bytes supported by device\n",3240 LogRel((DEVICE_NAME ": vboxUsbSolarisBulkXfer: Requesting %d bytes when only %d bytes supported by device\n", 3261 3241 pUrb->cbDataR3, pState->cbMaxBulkXfer)); 3262 3242 } … … 3265 3245 * Submit the request. 3266 3246 */ 3267 rc = usb_pipe_bulk_xfer(pEp->pPipe, pReq, USB_FLAGS_NOSLEEP); 3268 3247 int rc = usb_pipe_bulk_xfer(pEp->pPipe, pReq, USB_FLAGS_NOSLEEP); 3269 3248 if (RT_LIKELY(rc == USB_SUCCESS)) 3270 3249 return VINF_SUCCESS; 3271 else 3272 { 3273 LogRel((DEVICE_NAME ":vboxUSBSolarisBulkXfer usb_pipe_bulk_xfer enmDir=%#x Ep=%#x failed! rc=%d\n", pUrb->enmDir, 3274 pUrb->bEndpoint, rc)); 3275 rc = VERR_PIPE_IO_ERROR; 3276 } 3277 3278 if (pUrb->enmDir == VUSBDIRECTION_OUT) /* pUrb->pMsg freed by caller */ 3279 pReq->bulk_data = NULL; 3250 3251 LogRel((DEVICE_NAME ": vboxUsbSolarisBulkXfer: Request failed! Ep=%#x rc=%d cbData=%u\n", pUrb->bEndpoint, rc, 3252 pReq->bulk_len)); 3280 3253 3281 3254 usb_free_bulk_req(pReq); 3282 } 3283 else 3284 { 3285 LogRel((DEVICE_NAME ":vboxUSBSolarisBulkXfer failed to alloc bulk request.\n")); 3286 rc = VERR_NO_MEMORY; 3287 } 3288 3289 return rc; 3255 return VERR_PIPE_IO_ERROR; 3256 } 3257 3258 LogRel((DEVICE_NAME ": vboxUsbSolarisBulkXfer: Failed to alloc bulk request\n")); 3259 return VERR_NO_MEMORY; 3290 3260 } 3291 3261 … … 3297 3267 * @param pReq The Bulk request. 3298 3268 */ 3299 LOCAL void vboxUSBSolarisBulkXferCompleted(usb_pipe_handle_t pPipe, usb_bulk_req_t *pReq) 3300 { 3301 LogFunc((DEVICE_NAME ":vboxUSBSolarisBulkXferCompleted pPipe=%p pReq=%p\n", pPipe, pReq)); 3269 LOCAL void vboxUsbSolarisBulkXferCompleted(usb_pipe_handle_t pPipe, usb_bulk_req_t *pReq) 3270 { 3271 LogFunc((DEVICE_NAME ": vboxUsbSolarisBulkXferCompleted: pPipe=%p pReq=%p\n", pPipe, pReq)); 3272 3273 Assert(pReq); 3274 Assert(!(pReq->bulk_cb_flags & USB_CB_INTR_CONTEXT)); 3302 3275 3303 3276 vboxusb_ep_t *pEp = (vboxusb_ep_t *)usb_pipe_get_private(pPipe); … … 3307 3280 if (RT_LIKELY(pUrb)) 3308 3281 { 3309 if (pUrb->enmDir == VUSBDIRECTION_OUT) 3282 Assert(!pUrb->pMsg); 3283 if ( pUrb->enmDir == VUSBDIRECTION_IN 3284 && pReq->bulk_data) 3285 { 3286 pUrb->pMsg = pReq->bulk_data; 3310 3287 pReq->bulk_data = NULL; 3311 else 3312 { 3313 if (pReq->bulk_completion_reason == USB_CR_OK) 3314 { 3315 pUrb->pMsg = pReq->bulk_data; 3316 pReq->bulk_data = NULL; 3317 vboxUSBSolarisConcatMsg(pUrb); 3318 } 3288 vboxUsbSolarisConcatMsg(pUrb); 3319 3289 } 3320 3321 Log((DEVICE_NAME ":vboxUSBSolarisBulkXferCompleted %s. rc=%d cbData=%d\n",3322 pReq->bulk_completion_reason != USB_CR_OK ? "failed URB" : "success",3323 pReq->bulk_completion_reason, pUrb->pMsg ? MBLKL(pUrb->pMsg) : 0));3324 3290 3325 3291 /* 3326 3292 * Update the URB and move to tail for reaping. 3327 3293 */ 3328 vboxUSBSolarisDeQueueURB(pUrb, pReq->bulk_completion_reason); 3329 usb_free_bulk_req(pReq); 3330 return; 3294 vboxUsbSolarisDeQueueUrb(pUrb, pReq->bulk_completion_reason); 3331 3295 } 3332 3296 else 3333 LogRel((DEVICE_NAME ": vboxUSBSolarisBulkXferCompleted Extreme error! private request data missing.\n"));3297 LogRel((DEVICE_NAME ": vboxUsbSolarisBulkXferCompleted: Extreme error! private request data missing!\n")); 3334 3298 } 3335 3299 else 3336 Log((DEVICE_NAME ": vboxUSBSolarisBulkXferCompleted Pipe Gone.\n"));3300 Log((DEVICE_NAME ": vboxUsbSolarisBulkXferCompleted: Pipe Gone!\n")); 3337 3301 3338 3302 usb_free_bulk_req(pReq); … … 3341 3305 3342 3306 /** 3343 * Perform an Interrupt Xfer.3307 * Performs an Interrupt Xfer. 3344 3308 * 3345 3309 * @param pState The USB device instance. … … 3350 3314 * @remarks Any errors, the caller should free pUrb->pMsg. 3351 3315 */ 3352 LOCAL int vboxU SBSolarisIntrXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *pUrb)3353 { 3354 LogFunc((DEVICE_NAME ": vboxUSBSolarisIntrXferpState=%p pEp=%p pUrb=%p enmDir=%d cbData=%d\n", pState, pEp, pUrb,3316 LOCAL int vboxUsbSolarisIntrXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *pUrb) 3317 { 3318 LogFunc((DEVICE_NAME ": vboxUsbSolarisIntrXfer: pState=%p pEp=%p pUrb=%p enmDir=%d cbData=%d\n", pState, pEp, pUrb, 3355 3319 pUrb->enmDir, pUrb->cbDataR3)); 3356 3320 3357 int rc = VINF_SUCCESS; 3358 usb_intr_req_t *pReq = usb_alloc_intr_req(pState->pDip, 0 /* length */, USB_FLAGS_NOSLEEP); 3321 usb_intr_req_t *pReq = usb_alloc_intr_req(pState->pDip, 0 /* length */, USB_FLAGS_SLEEP); 3359 3322 if (RT_LIKELY(pReq)) 3360 3323 { … … 3362 3325 * Initialize Intr Xfer, callbacks & timeouts. 3363 3326 */ 3327 usb_req_attrs_t fAttributes = USB_ATTRS_AUTOCLEARING; 3364 3328 if (pUrb->enmDir == VUSBDIRECTION_OUT) 3365 3329 { 3366 pReq->intr_data 3367 p Req->intr_attributes = USB_ATTRS_AUTOCLEARING;3330 pReq->intr_data = pUrb->pMsg; 3331 pUrb->pMsg = NULL; 3368 3332 } 3369 3333 else 3370 3334 { 3371 3335 Assert(pUrb->enmDir == VUSBDIRECTION_IN); 3372 pReq->intr_data = NULL; 3373 pReq->intr_attributes = USB_ATTRS_AUTOCLEARING | USB_ATTRS_ONE_XFER | (pUrb->fShortOk ? USB_ATTRS_SHORT_XFER_OK : 0); 3374 } 3375 3336 fAttributes |= USB_ATTRS_ONE_XFER; 3337 if (pUrb->fShortOk) 3338 fAttributes |= USB_ATTRS_SHORT_XFER_OK; 3339 } 3340 3341 Assert(!pUrb->pMsg); 3376 3342 pReq->intr_len = pUrb->cbDataR3; /* Not pEp->EpDesc.wMaxPacketSize */ 3377 pReq->intr_cb = vboxUSBSolarisIntrXferCompleted; 3378 pReq->intr_exc_cb = vboxUSBSolarisIntrXferCompleted; 3379 pReq->intr_timeout = VBOXUSB_INTR_XFER_TIMEOUT; 3343 pReq->intr_cb = vboxUsbSolarisIntrXferCompleted; 3344 pReq->intr_exc_cb = vboxUsbSolarisIntrXferCompleted; 3345 pReq->intr_timeout = 0; 3346 pReq->intr_attributes = fAttributes; 3380 3347 pReq->intr_client_private = (usb_opaque_t)pUrb; 3381 3348 … … 3383 3350 * Submit the request. 3384 3351 */ 3385 rc = usb_pipe_intr_xfer(pEp->pPipe, pReq, USB_FLAGS_NOSLEEP); 3386 3352 int rc = usb_pipe_intr_xfer(pEp->pPipe, pReq, USB_FLAGS_NOSLEEP); 3387 3353 if (RT_LIKELY(rc == USB_SUCCESS)) 3388 3354 return VINF_SUCCESS; 3389 else 3390 { 3391 LogRel((DEVICE_NAME ":vboxUSBSolarisIntrXfer usb_pipe_intr_xfer failed! rc=%d\n", rc)); 3392 rc = VERR_PIPE_IO_ERROR; 3393 } 3394 3395 pReq->intr_data = NULL; 3355 3356 LogRel((DEVICE_NAME ": vboxUsbSolarisIntrXfer: usb_pipe_intr_xfer failed! rc=%d bEndpoint=%#x\n", rc, pUrb->bEndpoint)); 3357 3396 3358 usb_free_intr_req(pReq); 3397 } 3398 else 3399 { 3400 LogRel((DEVICE_NAME ":vboxUSBSolarisIntrXfer failed to alloc intr request.\n")); 3401 rc = VERR_NO_MEMORY; 3402 } 3403 3404 return rc; 3359 return VERR_PIPE_IO_ERROR; 3360 } 3361 3362 LogRel((DEVICE_NAME ": vboxUsbSolarisIntrXfer: Failed to alloc intr request\n")); 3363 return VERR_NO_MEMORY; 3405 3364 } 3406 3365 … … 3412 3371 * @param pReq The Intr request. 3413 3372 */ 3414 LOCAL void vboxUSBSolarisIntrXferCompleted(usb_pipe_handle_t pPipe, usb_intr_req_t *pReq) 3415 { 3416 LogFunc((DEVICE_NAME ":vboxUSBSolarisIntrXferCompleted pPipe=%p pReq=%p\n", pPipe, pReq)); 3417 3418 vboxusb_ep_t *pEp = (vboxusb_ep_t *)usb_pipe_get_private(pPipe); 3419 if (RT_LIKELY(pEp)) 3420 { 3421 vboxusb_urb_t *pUrb = (vboxusb_urb_t *)pReq->intr_client_private; 3422 if (RT_LIKELY(pUrb)) 3423 { 3424 if (pUrb->enmDir == VUSBDIRECTION_OUT) 3425 pReq->intr_data = NULL; 3426 else 3427 { 3428 if (pReq->intr_completion_reason == USB_CR_OK) 3429 { 3430 pUrb->pMsg = pReq->intr_data; 3431 pReq->intr_data = NULL; 3432 } 3433 } 3434 3435 Log((DEVICE_NAME ":vboxUSBSolarisIntrXferCompleted rc=%d pMsg=%p enmDir=%#x\n", pReq->intr_completion_reason, 3436 pUrb->pMsg, pUrb->enmDir)); 3437 3438 /* 3439 * Update the URB and move to landed list for reaping. 3440 */ 3441 vboxUSBSolarisDeQueueURB(pUrb, pReq->intr_completion_reason); 3442 usb_free_intr_req(pReq); 3443 return; 3444 } 3445 else 3446 LogRel((DEVICE_NAME ":vboxUSBSolarisIntrXferCompleted Extreme error! private request data missing.\n")); 3373 LOCAL void vboxUsbSolarisIntrXferCompleted(usb_pipe_handle_t pPipe, usb_intr_req_t *pReq) 3374 { 3375 LogFunc((DEVICE_NAME ": vboxUsbSolarisIntrXferCompleted: pPipe=%p pReq=%p\n", pPipe, pReq)); 3376 3377 Assert(pReq); 3378 Assert(!(pReq->intr_cb_flags & USB_CB_INTR_CONTEXT)); 3379 3380 vboxusb_urb_t *pUrb = (vboxusb_urb_t *)pReq->intr_client_private; 3381 if (RT_LIKELY(pUrb)) 3382 { 3383 if ( pUrb->enmDir == VUSBDIRECTION_IN 3384 && pReq->intr_data) 3385 { 3386 pUrb->pMsg = pReq->intr_data; 3387 pReq->intr_data = NULL; 3388 vboxUsbSolarisConcatMsg(pUrb); 3389 } 3390 3391 /* 3392 * Update the URB and move to landed list for reaping. 3393 */ 3394 vboxUsbSolarisDeQueueUrb(pUrb, pReq->intr_completion_reason); 3447 3395 } 3448 3396 else 3449 Log ((DEVICE_NAME ":vboxUSBSolarisIntrXferCompleted Pipe Gone.\n"));3397 LogRel((DEVICE_NAME ": vboxUsbSolarisIntrXferCompleted: Extreme error! private request data missing\n")); 3450 3398 3451 3399 usb_free_intr_req(pReq); … … 3454 3402 3455 3403 /** 3456 * Perform an Isochronous Xfer.3404 * Performs an Isochronous Xfer. 3457 3405 * 3458 3406 * @param pState The USB device instance. … … 3463 3411 * @remarks Any errors, the caller should free pUrb->pMsg. 3464 3412 */ 3465 LOCAL int vboxU SBSolarisIsocXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *pUrb)3466 { 3467 // LogFunc((DEVICE_NAME ":vboxUSBSolarisIsocXfer pState=%p pEp=%p pUrb=%p\n", pState, pEp, pUrb)); 3413 LOCAL int vboxUsbSolarisIsocXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *pUrb) 3414 { 3415 /* LogFunc((DEVICE_NAME ": vboxUsbSolarisIsocXfer: pState=%p pEp=%p pUrb=%p\n", pState, pEp, pUrb)); */ 3468 3416 3469 3417 /* … … 3474 3422 if (pUrb->enmDir == VUSBDIRECTION_IN) 3475 3423 { 3476 Log((DEVICE_NAME ": vboxUSBSolarisIsocXfer Isoc. In queueing.\n"));3424 Log((DEVICE_NAME ": vboxUsbSolarisIsocXfer: Isoc. IN - Queueing\n")); 3477 3425 3478 3426 mutex_enter(&pState->Mtx); … … 3485 3433 { 3486 3434 mutex_exit(&pState->Mtx); 3487 Log((DEVICE_NAME ": vboxUSBSolarisIsocXferMax Isoc. data %d bytes queued\n", pEp->cbMaxIsocData));3435 Log((DEVICE_NAME ": vboxUsbSolarisIsocXfer: Max Isoc. data %d bytes queued\n", pEp->cbMaxIsocData)); 3488 3436 return VERR_TOO_MUCH_DATA; 3489 3437 } … … 3500 3448 int rc = VINF_SUCCESS; 3501 3449 usb_isoc_req_t *pReq = usb_alloc_isoc_req(pState->pDip, pUrb->cIsocPkts, cbData, USB_FLAGS_NOSLEEP); 3502 Log((DEVICE_NAME ": vboxUSBSolarisIsocXferenmDir=%#x cIsocPkts=%d aIsocPkts[0]=%d cbDataR3=%d\n", pUrb->enmDir,3450 Log((DEVICE_NAME ": vboxUsbSolarisIsocXfer: enmDir=%#x cIsocPkts=%d aIsocPkts[0]=%d cbDataR3=%d\n", pUrb->enmDir, 3503 3451 pUrb->cIsocPkts, pUrb->aIsocPkts[0].cbPkt, pUrb->cbDataR3)); 3504 3452 if (RT_LIKELY(pReq)) … … 3514 3462 pReq->isoc_data = pUrb->pMsg; 3515 3463 pReq->isoc_attributes = USB_ATTRS_AUTOCLEARING | USB_ATTRS_ISOC_XFER_ASAP; 3516 pReq->isoc_cb = vboxU SBSolarisIsocOutXferCompleted;3517 pReq->isoc_exc_cb = vboxU SBSolarisIsocOutXferCompleted;3464 pReq->isoc_cb = vboxUsbSolarisIsocOutXferCompleted; 3465 pReq->isoc_exc_cb = vboxUsbSolarisIsocOutXferCompleted; 3518 3466 pReq->isoc_client_private = (usb_opaque_t)pUrb; 3519 3467 } … … 3521 3469 { 3522 3470 pReq->isoc_attributes = USB_ATTRS_AUTOCLEARING | USB_ATTRS_ISOC_XFER_ASAP | USB_ATTRS_SHORT_XFER_OK; 3523 pReq->isoc_cb = vboxU SBSolarisIsocInXferCompleted;3524 pReq->isoc_exc_cb = vboxU SBSolarisIsocInXferError;3471 pReq->isoc_cb = vboxUsbSolarisIsocInXferCompleted; 3472 pReq->isoc_exc_cb = vboxUsbSolarisIsocInXferError; 3525 3473 pReq->isoc_client_private = (usb_opaque_t)pState; 3526 3474 } … … 3550 3498 else 3551 3499 { 3552 LogRel((DEVICE_NAME ": vboxUSBSolarisIsocXferusb_pipe_isoc_xfer failed! rc=%d\n", rc));3500 LogRel((DEVICE_NAME ": vboxUsbSolarisIsocXfer: usb_pipe_isoc_xfer failed! rc=%d\n", rc)); 3553 3501 rc = VERR_PIPE_IO_ERROR; 3554 3502 … … 3567 3515 } 3568 3516 3569 if (pUrb->enmDir == VUSBDIRECTION_OUT) /* pUrb->pMsg freed by caller */ 3570 pReq->isoc_data = NULL; 3517 if (pUrb->enmDir == VUSBDIRECTION_OUT) 3518 { 3519 freemsg(pUrb->pMsg); 3520 pUrb->pMsg = NULL; 3521 } 3571 3522 3572 3523 usb_free_isoc_req(pReq); … … 3574 3525 else 3575 3526 { 3576 LogRel((DEVICE_NAME ": vboxUSBSolarisIsocXfer failed to alloc isoc req for %d packets\n", pUrb->cIsocPkts));3527 LogRel((DEVICE_NAME ": vboxUsbSolarisIsocXfer: Failed to alloc isoc req for %d packets\n", pUrb->cIsocPkts)); 3577 3528 rc = VERR_NO_MEMORY; 3578 3529 } … … 3590 3541 * @remarks Completion callback executes in interrupt context! 3591 3542 */ 3592 LOCAL void vboxU SBSolarisIsocInXferCompleted(usb_pipe_handle_t pPipe, usb_isoc_req_t *pReq)3593 { 3594 // LogFunc((DEVICE_NAME ":vboxUSBSolarisIsocInXferCompleted pPipe=%p pReq=%p\n", pPipe, pReq)); 3543 LOCAL void vboxUsbSolarisIsocInXferCompleted(usb_pipe_handle_t pPipe, usb_isoc_req_t *pReq) 3544 { 3545 /* LogFunc((DEVICE_NAME ": vboxUsbSolarisIsocInXferCompleted: pPipe=%p pReq=%p\n", pPipe, pReq)); */ 3595 3546 3596 3547 vboxusb_state_t *pState = (vboxusb_state_t *)pReq->isoc_client_private; … … 3607 3558 if (pReq->isoc_error_count == pReq->isoc_pkts_count) 3608 3559 { 3609 Log((DEVICE_NAME ": vboxUSBSolarisIsocInXferCompleted stopping polling! Too many errors.\n"));3560 Log((DEVICE_NAME ": vboxUsbSolarisIsocInXferCompleted: Stopping polling! Too many errors\n")); 3610 3561 mutex_exit(&pState->Mtx); 3611 3562 usb_pipe_stop_isoc_polling(pPipe, USB_FLAGS_NOSLEEP); … … 3615 3566 #endif 3616 3567 3568 /** @todo Query and verify this at runtime. */ 3617 3569 AssertCompile(sizeof(VUSBISOC_PKT_DESC) == sizeof(usb_isoc_pkt_descr_t)); 3618 3619 3570 if (RT_LIKELY(pReq->isoc_data)) 3620 3571 { 3621 Log((DEVICE_NAME ": vboxUSBSolarisIsocInXferCompletedcIsocInUrbs=%d cbIsocInLandedReqs=%d\n", pEp->cIsocInUrbs,3572 Log((DEVICE_NAME ": vboxUsbSolarisIsocInXferCompleted: cIsocInUrbs=%d cbIsocInLandedReqs=%d\n", pEp->cIsocInUrbs, 3622 3573 pEp->cbIsocInLandedReqs)); 3623 3574 … … 3639 3590 { 3640 3591 pUrb->aIsocPkts[i].cbActPkt = pReq->isoc_pkt_descr[i].isoc_pkt_actual_length; 3641 pUrb->aIsocPkts[i].enmStatus = vboxU SBSolarisGetUrbStatus(pReq->isoc_pkt_descr[i].isoc_pkt_status);3592 pUrb->aIsocPkts[i].enmStatus = vboxUsbSolarisGetUrbStatus(pReq->isoc_pkt_descr[i].isoc_pkt_status); 3642 3593 } 3643 3594 … … 3650 3601 mutex_enter(&pState->Mtx); 3651 3602 list_insert_tail(&pState->hLandedUrbs, pUrb); 3652 vboxUSBSolarisNotifyComplete(pState); 3603 ++pState->cLandedUrbs; 3604 vboxUsbSolarisNotifyComplete(pState); 3653 3605 } 3654 3606 else … … 3657 3609 Reap time */ 3658 3610 pEp->cIsocInUrbs = 0; 3659 LogRel((DEVICE_NAME ": vboxUSBSolarisIsocInXferCompleted Extreme error! Isoc. counter b0rked!\n"));3611 LogRel((DEVICE_NAME ": vboxUsbSolarisIsocInXferCompleted: Extreme error! Isoc. counter borked!\n")); 3660 3612 } 3661 3613 … … 3665 3617 } 3666 3618 3667 #if 03668 /*3669 * If the maximum buffer size is reached, discard the oldest data.3670 */3671 if (pEp->cbIsocInLandedReqs + MBLKL(pReq->isoc_data) > pEp->cbMaxIsocData)3672 {3673 vboxusb_isoc_req_t *pOldReq = list_remove_head(&pEp->hIsocInLandedReqs);3674 if (RT_LIKELY(pOldReq))3675 {3676 pEp->cbIsocInLandedReqs -= MBLKL(pOldReq->pMsg);3677 kmem_free(pOldReq, sizeof(vboxusb_isoc_req_t));3678 }3679 }3680 3681 3619 mutex_exit(&pState->Mtx); 3682 3683 /*3684 * Buffer incoming data if the guest has not yet queued any Input URBs.3685 */3686 Log((DEVICE_NAME ":vboxUSBSolarisIsocInXferCompleted Buffering\n"));3687 vboxusb_isoc_req_t *pIsocReq = kmem_alloc(sizeof(vboxusb_isoc_req_t), KM_NOSLEEP);3688 if (RT_LIKELY(pIsocReq))3689 {3690 pIsocReq->pMsg = pReq->isoc_data;3691 pReq->isoc_data = NULL;3692 pIsocReq->cIsocPkts = pReq->isoc_pkts_count;3693 #if 03694 for (unsigned i = 0; i < pReq->isoc_pkts_count; i++)3695 {3696 pIsocReq->aIsocPkts[i].cbActPkt = pReq->isoc_pkt_descr[i].isoc_pkt_actual_length;3697 pIsocReq->aIsocPkts[i].enmStatus = vboxUSBSolarisGetUrbStatus(pReq->isoc_pkt_descr[i].isoc_pkt_status);3698 }3699 #else3700 bcopy(pReq->isoc_pkt_descr, pIsocReq->aIsocPkts, pReq->isoc_pkts_count * sizeof(VUSBISOC_PKT_DESC));3701 #endif3702 3703 mutex_enter(&pState->Mtx);3704 list_insert_tail(&pEp->hIsocInLandedReqs, pIsocReq);3705 pEp->cbIsocInLandedReqs += MBLKL(pIsocReq->pMsg);3706 mutex_exit(&pState->Mtx);3707 }3708 else3709 {3710 LogRel((DEVICE_NAME ":vboxUSBSolarisIsocInXferCompleted failed to alloc %d bytes for Isoc. queueing\n",3711 sizeof(vboxusb_isoc_req_t)));3712 }3713 3714 /*3715 * Drain the input URB buffer with the device buffer, queueing them with the landed URBs.3716 */3717 mutex_enter(&pState->Mtx);3718 while (pEp->cIsocInUrbs)3719 {3720 vboxusb_urb_t *pUrb = list_remove_head(&pEp->hIsocInUrbs);3721 if (RT_UNLIKELY(!pUrb))3722 break;3723 3724 vboxusb_isoc_req_t *pBuffReq = list_remove_head(&pEp->hIsocInLandedReqs);3725 if (!pBuffReq)3726 {3727 list_insert_head(&pEp->hIsocInUrbs, pUrb);3728 break;3729 }3730 3731 --pEp->cIsocInUrbs;3732 pEp->cbIsocInLandedReqs -= MBLKL(pBuffReq->pMsg);3733 mutex_exit(&pState->Mtx);3734 3735 #if 03736 for (unsigned i = 0; i < pBuffReq->cIsocPkts; i++)3737 {3738 pUrb->aIsocPkts[i].cbActPkt = pBuffReq->aIsocPkts[i].cbActPkt;3739 pUrb->aIsocPkts[i].enmStatus = pBuffReq->aIsocPkts[i].enmStatus;3740 }3741 #else3742 bcopy(pBuffReq->aIsocPkts, pUrb->aIsocPkts, pBuffReq->cIsocPkts * sizeof(VUSBISOC_PKT_DESC));3743 #endif3744 pUrb->pMsg = pBuffReq->pMsg;3745 pBuffReq->pMsg = NULL;3746 kmem_free(pBuffReq, sizeof(vboxusb_isoc_req_t));3747 3748 /*3749 * Move to landed list3750 */3751 mutex_enter(&pState->Mtx);3752 list_insert_tail(&pState->hLandedUrbs, pUrb);3753 vboxUSBSolarisNotifyComplete(pState);3754 }3755 #endif3756 3757 mutex_exit(&pState->Mtx);3758 usb_free_isoc_req(pReq);3759 return;3760 3620 } 3761 3621 else 3762 LogRel((DEVICE_NAME ": vboxUSBSolarisIsocInXferCompleted data missing.\n"));3622 LogRel((DEVICE_NAME ": vboxUsbSolarisIsocInXferCompleted: Data missing\n")); 3763 3623 } 3764 3624 else 3765 LogRel((DEVICE_NAME ": vboxUSBSolarisIsocInXferCompleted Pipe Gone.\n"));3625 LogRel((DEVICE_NAME ": vboxUsbSolarisIsocInXferCompleted: Pipe Gone\n")); 3766 3626 } 3767 3627 else 3768 Log((DEVICE_NAME ": vboxUSBSolarisIsocInXferCompleted State Gone.\n"));3628 Log((DEVICE_NAME ": vboxUsbSolarisIsocInXferCompleted: State Gone\n")); 3769 3629 3770 3630 usb_free_isoc_req(pReq); … … 3779 3639 * @remarks Completion callback executes in interrupt context! 3780 3640 */ 3781 LOCAL void vboxU SBSolarisIsocInXferError(usb_pipe_handle_t pPipe, usb_isoc_req_t *pReq)3782 { 3783 LogFunc((DEVICE_NAME ": vboxUSBSolarisIsocInXferErrorpPipe=%p pReq=%p\n", pPipe, pReq));3641 LOCAL void vboxUsbSolarisIsocInXferError(usb_pipe_handle_t pPipe, usb_isoc_req_t *pReq) 3642 { 3643 LogFunc((DEVICE_NAME ": vboxUsbSolarisIsocInXferError: pPipe=%p pReq=%p\n", pPipe, pReq)); 3784 3644 3785 3645 vboxusb_state_t *pState = (vboxusb_state_t *)pReq->isoc_client_private; 3786 3646 if (RT_UNLIKELY(!pState)) 3787 3647 { 3788 Log((DEVICE_NAME ": vboxUSBSolarisIsocInXferError State Gone.\n"));3648 Log((DEVICE_NAME ": vboxUsbSolarisIsocInXferError: State Gone\n")); 3789 3649 usb_free_isoc_req(pReq); 3790 3650 return; … … 3795 3655 if (RT_UNLIKELY(!pEp)) 3796 3656 { 3797 Log((DEVICE_NAME ": vboxUSBSolarisIsocInXferError Pipe Gone.\n"));3657 Log((DEVICE_NAME ": vboxUsbSolarisIsocInXferError: Pipe Gone\n")); 3798 3658 mutex_exit(&pState->Mtx); 3799 3659 usb_free_isoc_req(pReq); … … 3811 3671 mutex_exit(&pState->Mtx); 3812 3672 usb_pipe_isoc_xfer(pPipe, pReq, USB_FLAGS_NOSLEEP); 3813 Log((DEVICE_NAME ":vboxUSBSolarisIsocInXferError resubmitted Isoc. IN request due to immediately unavailable " 3814 "resources.\n")); 3815 3673 Log((DEVICE_NAME ": vboxUsbSolarisIsocInXferError: Resubmitted Isoc. IN request due to unavailable resources\n")); 3816 3674 return; 3817 3675 } … … 3828 3686 default: 3829 3687 { 3830 Log((DEVICE_NAME ": vboxUSBSolarisIsocInXferError stopping Isoc. In.polling due to rc=%d\n",3688 Log((DEVICE_NAME ": vboxUsbSolarisIsocInXferError: Stopping Isoc. IN polling due to rc=%d\n", 3831 3689 pReq->isoc_completion_reason)); 3832 3690 pEp->fIsocPolling = false; … … 3846 3704 { 3847 3705 --pEp->cIsocInUrbs; 3848 Log((DEVICE_NAME ": vboxUSBSolarisIsocInXferError Deleting last queued URB as it failed.\n"));3706 Log((DEVICE_NAME ": vboxUsbSolarisIsocInXferError: Deleting last queued URB as it failed\n")); 3849 3707 freemsg(pUrb->pMsg); 3850 3708 RTMemFree(pUrb); 3851 vboxU SBSolarisNotifyComplete(pState);3709 vboxUsbSolarisNotifyComplete(pState); 3852 3710 } 3853 3711 … … 3863 3721 * @remarks Completion callback executes in interrupt context! 3864 3722 */ 3865 LOCAL void vboxU SBSolarisIsocOutXferCompleted(usb_pipe_handle_t pPipe, usb_isoc_req_t *pReq)3866 { 3867 LogFunc((DEVICE_NAME ": vboxUSBSolarisIsocOutXferCompletedpPipe=%p pReq=%p\n", pPipe, pReq));3723 LOCAL void vboxUsbSolarisIsocOutXferCompleted(usb_pipe_handle_t pPipe, usb_isoc_req_t *pReq) 3724 { 3725 LogFunc((DEVICE_NAME ": vboxUsbSolarisIsocOutXferCompleted: pPipe=%p pReq=%p\n", pPipe, pReq)); 3868 3726 3869 3727 vboxusb_ep_t *pEp = (vboxusb_ep_t *)usb_pipe_get_private(pPipe); … … 3878 3736 cbActPkt += pReq->isoc_pkt_descr[i].isoc_pkt_actual_length; 3879 3737 pUrb->aIsocPkts[i].cbActPkt = pReq->isoc_pkt_descr[i].isoc_pkt_actual_length; 3880 pUrb->aIsocPkts[i].enmStatus = vboxU SBSolarisGetUrbStatus(pReq->isoc_pkt_descr[i].isoc_pkt_status);3738 pUrb->aIsocPkts[i].enmStatus = vboxUsbSolarisGetUrbStatus(pReq->isoc_pkt_descr[i].isoc_pkt_status); 3881 3739 } 3882 3740 3883 Log((DEVICE_NAME ": vboxUSBSolarisIsocOutXferCompletedcIsocPkts=%d cbData=%d cbActPkt=%d\n", pUrb->cIsocPkts,3741 Log((DEVICE_NAME ": vboxUsbSolarisIsocOutXferCompleted: cIsocPkts=%d cbData=%d cbActPkt=%d\n", pUrb->cIsocPkts, 3884 3742 pUrb->cbDataR3, cbActPkt)); 3885 3743 … … 3900 3758 * Update the URB and move to landed list for reaping. 3901 3759 */ 3902 vboxUSBSolarisDeQueueURB(pUrb, pReq->isoc_completion_reason); 3903 usb_free_isoc_req(pReq); 3904 return; 3760 vboxUsbSolarisDeQueueUrb(pUrb, pReq->isoc_completion_reason); 3905 3761 } 3906 3762 else 3907 Log((DEVICE_NAME ": vboxUSBSolarisIsocOutXferCompleted missing private data!?! Dropping OUT pUrb.\n"));3763 Log((DEVICE_NAME ": vboxUsbSolarisIsocOutXferCompleted: Missing private data!?! Dropping OUT pUrb\n")); 3908 3764 } 3909 3765 else 3910 Log((DEVICE_NAME ": vboxUSBSolarisIsocOutXferCompleted Pipe Gone.\n"));3766 Log((DEVICE_NAME ": vboxUsbSolarisIsocOutXferCompleted: Pipe Gone\n")); 3911 3767 3912 3768 usb_free_isoc_req(pReq); … … 3921 3777 * @returns Solaris USB error code. 3922 3778 */ 3923 LOCAL int vboxU SBSolarisDeviceDisconnected(dev_info_t *pDip)3924 { 3925 LogFunc((DEVICE_NAME ": vboxUSBSolarisDeviceDisconnectedpDip=%p\n", pDip));3779 LOCAL int vboxUsbSolarisDeviceDisconnected(dev_info_t *pDip) 3780 { 3781 LogFunc((DEVICE_NAME ": vboxUsbSolarisDeviceDisconnected: pDip=%p\n", pDip)); 3926 3782 3927 3783 int instance = ddi_get_instance(pDip); … … 3938 3794 pState->DevState = USB_DEV_DISCONNECTED; 3939 3795 3940 vboxU SBSolarisCloseAllPipes(pState, true /* ControlPipe */);3941 vboxU SBSolarisNotifyHotplug(pState);3796 vboxUsbSolarisCloseAllPipes(pState, true /* ControlPipe */); 3797 vboxUsbSolarisNotifyUnplug(pState); 3942 3798 3943 3799 mutex_exit(&pState->Mtx); … … 3947 3803 } 3948 3804 3949 LogRel((DEVICE_NAME ": vboxUSBSolarisDeviceDisconnected failed to get device state!\n"));3805 LogRel((DEVICE_NAME ": vboxUsbSolarisDeviceDisconnected: Failed to get device state!\n")); 3950 3806 return USB_FAILURE; 3951 3807 } … … 3959 3815 * @returns Solaris USB error code. 3960 3816 */ 3961 LOCAL int vboxU SBSolarisDeviceReconnected(dev_info_t *pDip)3962 { 3963 LogFunc((DEVICE_NAME ": vboxUSBSolarisDeviceReconnectedpDip=%p\n", pDip));3817 LOCAL int vboxUsbSolarisDeviceReconnected(dev_info_t *pDip) 3818 { 3819 LogFunc((DEVICE_NAME ": vboxUsbSolarisDeviceReconnected: pDip=%p\n", pDip)); 3964 3820 3965 3821 int instance = ddi_get_instance(pDip); … … 3968 3824 if (RT_LIKELY(pState)) 3969 3825 { 3970 vboxU SBSolarisDeviceRestore(pState);3826 vboxUsbSolarisDeviceRestore(pState); 3971 3827 return USB_SUCCESS; 3972 3828 } 3973 3829 3974 LogRel((DEVICE_NAME ": vboxUSBSolarisDeviceReconnected failed to get device state!\n"));3830 LogRel((DEVICE_NAME ": vboxUsbSolarisDeviceReconnected: Failed to get device state!\n")); 3975 3831 return USB_FAILURE; 3976 3832 } … … 3978 3834 3979 3835 /** 3980 * Restore device state after a reconnect or resume.3836 * Restores device state after a reconnect or resume. 3981 3837 * 3982 3838 * @param pState The USB device instance. 3983 3839 */ 3984 LOCAL void vboxU SBSolarisDeviceRestore(vboxusb_state_t *pState)3985 { 3986 LogFunc((DEVICE_NAME ": vboxUSBSolarisDeviceRestorepState=%p\n", pState));3840 LOCAL void vboxUsbSolarisDeviceRestore(vboxusb_state_t *pState) 3841 { 3842 LogFunc((DEVICE_NAME ": vboxUsbSolarisDeviceRestore: pState=%p\n", pState)); 3987 3843 AssertPtrReturnVoid(pState); 3988 3844 … … 3990 3846 * Raise device power. 3991 3847 */ 3992 vboxU SBSolarisPowerBusy(pState);3848 vboxUsbSolarisPowerBusy(pState); 3993 3849 int rc = pm_raise_power(pState->pDip, 0 /* component */, USB_DEV_OS_FULL_PWR); 3994 3850 … … 4010 3866 4011 3867 /* Do we need to inform userland here? */ 4012 vboxU SBSolarisPowerIdle(pState);4013 Log((DEVICE_NAME ": vboxUSBSolarisDeviceRestore not the same device.\n"));3868 vboxUsbSolarisPowerIdle(pState); 3869 Log((DEVICE_NAME ": vboxUsbSolarisDeviceRestore: Not the same device\n")); 4014 3870 return; 4015 3871 } … … 4029 3885 usb_release_access(pState->StateMulti); 4030 3886 4031 vboxU SBSolarisPowerIdle(pState);4032 } 4033 4034 4035 /** 4036 * Restore device state after a reconnect or resume.3887 vboxUsbSolarisPowerIdle(pState); 3888 } 3889 3890 3891 /** 3892 * Restores device state after a reconnect or resume. 4037 3893 * 4038 3894 * @param pState The USB device instance. … … 4040 3896 * @returns VBox status code. 4041 3897 */ 4042 LOCAL int vboxU SBSolarisDeviceSuspend(vboxusb_state_t *pState)4043 { 4044 LogFunc((DEVICE_NAME ": vboxUSBSolarisDeviceSuspendpState=%p\n", pState));3898 LOCAL int vboxUsbSolarisDeviceSuspend(vboxusb_state_t *pState) 3899 { 3900 LogFunc((DEVICE_NAME ": vboxUsbSolarisDeviceSuspend: pState=%p\n", pState)); 4045 3901 4046 3902 int rc = VERR_VUSB_DEVICE_IS_SUSPENDED; … … 4051 3907 case USB_DEV_SUSPENDED: 4052 3908 { 4053 LogRel((DEVICE_NAME ": vboxUSBSolarisDeviceSuspend: Invalid device state %d\n", pState->DevState));3909 LogRel((DEVICE_NAME ": vboxUsbSolarisDeviceSuspend: Invalid device state %d\n", pState->DevState)); 4054 3910 break; 4055 3911 } … … 4062 3918 pState->DevState = USB_DEV_DISCONNECTED; 4063 3919 3920 /** @todo this doesn't make sense when for e.g. an INTR IN URB with infinite 3921 * timeout is pending on the device. Fix suspend logic later. */ 4064 3922 /* 4065 3923 * Drain pending URBs. … … 4081 3939 { 4082 3940 pState->DevState = PreviousState; 4083 LogRel((DEVICE_NAME ":Cannot suspend, still have %d inflight URBs.\n", pState->cInflightUrbs)); 3941 LogRel((DEVICE_NAME ": Cannot suspend %s %s (Ident=%s), %d inflight URBs\n", pState->szMfg, pState->szProduct, 3942 pState->ClientInfo.szDeviceIdent, pState->cInflightUrbs)); 4084 3943 4085 3944 mutex_exit(&pState->Mtx); … … 4097 3956 mutex_enter(&pState->Mtx); 4098 3957 4099 vboxU SBSolarisCloseAllPipes(pState, true /* default pipe */);4100 vboxU SBSolarisNotifyHotplug(pState);3958 vboxUsbSolarisCloseAllPipes(pState, true /* default pipe */); 3959 vboxUsbSolarisNotifyUnplug(pState); 4101 3960 4102 3961 mutex_exit(&pState->Mtx); 4103 3962 usb_release_access(pState->StateMulti); 3963 3964 LogRel((DEVICE_NAME ": Suspended %s %s (Ident=%s)\n", pState->szMfg, pState->szProduct, 3965 pState->ClientInfo.szDeviceIdent)); 4104 3966 return VINF_SUCCESS; 4105 3967 } … … 4107 3969 4108 3970 mutex_exit(&pState->Mtx); 4109 Log((DEVICE_NAME ": vboxUSBSolarisDeviceSuspend returns %d\n", rc));3971 Log((DEVICE_NAME ": vboxUsbSolarisDeviceSuspend: Returns %d\n", rc)); 4110 3972 return rc; 4111 3973 } … … 4113 3975 4114 3976 /** 4115 * Restore device state after a reconnect or resume.3977 * Restores device state after a reconnect or resume. 4116 3978 * 4117 3979 * @param pState The USB device instance. 4118 3980 */ 4119 LOCAL void vboxU SBSolarisDeviceResume(vboxusb_state_t *pState)4120 { 4121 LogFunc((DEVICE_NAME ": vboxUSBSolarisDeviceResumepState=%p\n", pState));4122 return vboxU SBSolarisDeviceRestore(pState);4123 } 4124 4125 4126 /** 4127 * Flag the PM component as busy so the system will not manage it's power.3981 LOCAL void vboxUsbSolarisDeviceResume(vboxusb_state_t *pState) 3982 { 3983 LogFunc((DEVICE_NAME ": vboxUsbSolarisDeviceResume: pState=%p\n", pState)); 3984 return vboxUsbSolarisDeviceRestore(pState); 3985 } 3986 3987 3988 /** 3989 * Flags the PM component as busy so the system will not manage it's power. 4128 3990 * 4129 3991 * @param pState The USB device instance. 4130 3992 */ 4131 LOCAL void vboxU SBSolarisPowerBusy(vboxusb_state_t *pState)4132 { 4133 LogFunc((DEVICE_NAME ": vboxUSBSolarisPowerBusypState=%p\n", pState));3993 LOCAL void vboxUsbSolarisPowerBusy(vboxusb_state_t *pState) 3994 { 3995 LogFunc((DEVICE_NAME ": vboxUsbSolarisPowerBusy: pState=%p\n", pState)); 4134 3996 AssertPtrReturnVoid(pState); 4135 3997 … … 4143 4005 if (rc != DDI_SUCCESS) 4144 4006 { 4145 Log((DEVICE_NAME ": vboxUSBSolarisPowerBusy busy component failed! rc=%d\n", rc));4007 Log((DEVICE_NAME ": vboxUsbSolarisPowerBusy: Busy component failed! rc=%d\n", rc)); 4146 4008 mutex_enter(&pState->Mtx); 4147 4009 pState->pPower->PowerBusy--; … … 4155 4017 4156 4018 /** 4157 * Flag the PM component as idle so its power managed by the system.4019 * Flags the PM component as idle so its power managed by the system. 4158 4020 * 4159 4021 * @param pState The USB device instance. 4160 4022 */ 4161 LOCAL void vboxU SBSolarisPowerIdle(vboxusb_state_t *pState)4162 { 4163 LogFunc((DEVICE_NAME ": vboxUSBSolarisPowerIdlepState=%p\n", pState));4023 LOCAL void vboxUsbSolarisPowerIdle(vboxusb_state_t *pState) 4024 { 4025 LogFunc((DEVICE_NAME ": vboxUsbSolarisPowerIdle: pState=%p\n", pState)); 4164 4026 AssertPtrReturnVoid(pState); 4165 4027 … … 4175 4037 } 4176 4038 else 4177 Log((DEVICE_NAME ": vboxUSBSolarisPowerIdle idle component failed! rc=%d\n", rc));4178 } 4179 } 4180 4039 Log((DEVICE_NAME ": vboxUsbSolarisPowerIdle: Idle component failed! rc=%d\n", rc)); 4040 } 4041 } 4042 -
trunk/src/VBox/HostDrivers/VBoxUSB/solaris/VBoxUSBMon-solaris.c
r58340 r59091 172 172 /** Global Mutex. */ 173 173 static kmutex_t g_VBoxUSBMonSolarisMtx; 174 /** Number of userland clients that have kept us open. */175 static uint64_t g_cVBoxUSBMonSolarisClient = 0;176 174 /** Global list of client drivers registered with us. */ 177 175 vboxusbmon_client_t *g_pVBoxUSBMonSolarisClients = NULL; … … 204 202 int rc; 205 203 206 LogFunc((DEVICE_NAME ": _init\n"));204 LogFunc((DEVICE_NAME ": _init\n")); 207 205 208 206 g_pDip = NULL; … … 215 213 pModCtl->mod_loadflags |= MOD_NOAUTOUNLOAD; 216 214 else 217 LogRel((DEVICE_NAME ": failed to disable autounloading!\n"));215 LogRel((DEVICE_NAME ": _init: Failed to disable autounloading!\n")); 218 216 219 217 /* … … 237 235 return rc; 238 236 239 LogRel((DEVICE_NAME ": mod_install failed! rc=%d\n", rc));237 LogRel((DEVICE_NAME ": _init: mod_install failed! rc=%d\n", rc)); 240 238 ddi_soft_state_fini(&g_pVBoxUSBMonSolarisState); 241 239 } 242 240 else 243 LogRel((DEVICE_NAME ": ddi_soft_state_init failed! rc=%d\n", rc));241 LogRel((DEVICE_NAME ": _init: ddi_soft_state_init failed! rc=%d\n", rc)); 244 242 } 245 243 else 246 LogRel((DEVICE_NAME ": VBoxUSBFilterInit failed! rc=%d\n", rc));244 LogRel((DEVICE_NAME ": _init: VBoxUSBFilterInit failed! rc=%d\n", rc)); 247 245 248 246 mutex_destroy(&g_VBoxUSBMonSolarisMtx); … … 250 248 } 251 249 else 252 LogRel((DEVICE_NAME ": RTR0Init failed! rc=%d\n", rc));250 LogRel((DEVICE_NAME ": _init: RTR0Init failed! rc=%d\n", rc)); 253 251 254 252 return -1; … … 260 258 int rc; 261 259 262 LogFunc((DEVICE_NAME ": _fini\n"));260 LogFunc((DEVICE_NAME ": _fini\n")); 263 261 264 262 rc = mod_remove(&g_VBoxUSBMonSolarisModLinkage); … … 277 275 int _info(struct modinfo *pModInfo) 278 276 { 279 LogFunc((DEVICE_NAME ": _info\n"));277 LogFunc((DEVICE_NAME ": _info\n")); 280 278 281 279 return mod_info(&g_VBoxUSBMonSolarisModLinkage, pModInfo); … … 293 291 static int VBoxUSBMonSolarisAttach(dev_info_t *pDip, ddi_attach_cmd_t enmCmd) 294 292 { 295 LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisAttachpDip=%p enmCmd=%d\n", pDip, enmCmd));293 LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisAttach: pDip=%p enmCmd=%d\n", pDip, enmCmd)); 296 294 switch (enmCmd) 297 295 { … … 300 298 if (RT_UNLIKELY(g_pDip)) 301 299 { 302 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisAttach global instance already initialized.\n"));300 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisAttach: Global instance already initialized\n")); 303 301 return DDI_FAILURE; 304 302 } … … 310 308 if (rc == DDI_SUCCESS) 311 309 { 312 ddi_report_dev(pDip); 313 return rc; 310 rc = usb_register_dev_driver(g_pDip, VBoxUSBMonSolarisElectDriver); 311 if (rc == DDI_SUCCESS) 312 { 313 ddi_report_dev(pDip); 314 return DDI_SUCCESS; 315 } 316 317 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisAttach: Failed to register driver election callback! rc=%d\n", rc)); 314 318 } 315 319 else 316 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisAttachddi_create_minor_node failed! rc=%d\n", rc));320 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisAttach: ddi_create_minor_node failed! rc=%d\n", rc)); 317 321 return DDI_FAILURE; 318 322 } … … 340 344 static int VBoxUSBMonSolarisDetach(dev_info_t *pDip, ddi_detach_cmd_t enmCmd) 341 345 { 342 LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisDetach\n"));346 LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisDetach\n")); 343 347 344 348 switch (enmCmd) … … 359 363 mutex_exit(&g_VBoxUSBMonSolarisMtx); 360 364 365 usb_unregister_dev_driver(g_pDip); 366 361 367 ddi_remove_minor_node(pDip, NULL); 362 368 g_pDip = NULL; … … 390 396 int rc = DDI_SUCCESS; 391 397 392 LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisGetInfo\n"));398 LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisGetInfo\n")); 393 399 394 400 switch (enmCmd) … … 415 421 unsigned iOpenInstance; 416 422 417 LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisOpen\n"));423 LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisOpen\n")); 418 424 419 425 /* … … 428 434 if (!g_pDip) 429 435 { 430 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisOpen invalid state for opening.\n"));436 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisOpen: Invalid state for opening\n")); 431 437 return ENXIO; 432 438 } 433 434 mutex_enter(&g_VBoxUSBMonSolarisMtx);435 if (!g_cVBoxUSBMonSolarisClient)436 {437 mutex_exit(&g_VBoxUSBMonSolarisMtx);438 int rc = usb_register_dev_driver(g_pDip, VBoxUSBMonSolarisElectDriver);439 if (RT_UNLIKELY(rc != DDI_SUCCESS))440 {441 LogRel((DEVICE_NAME ":Failed to register driver election callback with USBA rc=%d\n", rc));442 return EINVAL;443 }444 Log((DEVICE_NAME ":Successfully registered election callback with USBA\n"));445 mutex_enter(&g_VBoxUSBMonSolarisMtx);446 }447 g_cVBoxUSBMonSolarisClient++;448 mutex_exit(&g_VBoxUSBMonSolarisMtx);449 439 450 440 for (iOpenInstance = 0; iOpenInstance < 4096; iOpenInstance++) … … 459 449 if (!pState) 460 450 { 461 LogRel((DEVICE_NAME ":VBoxUSBMonSolarisOpen: too many open instances.")); 462 mutex_enter(&g_VBoxUSBMonSolarisMtx); 463 g_cVBoxUSBMonSolarisClient--; 464 mutex_exit(&g_VBoxUSBMonSolarisMtx); 451 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisOpen: Too many open instances")); 465 452 return ENXIO; 466 453 } … … 479 466 { 480 467 vboxusbmon_state_t *pState = NULL; 481 482 LogFunc((DEVICE_NAME ":VBoxUSBMonSolarisClose\n")); 468 LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisClose\n")); 483 469 484 470 pState = ddi_get_soft_state(g_pVBoxUSBMonSolarisState, getminor(Dev)); 485 471 if (!pState) 486 472 { 487 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisClose: failed to get pState.\n"));473 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisClose: Failed to get state\n")); 488 474 return EFAULT; 489 475 } 490 491 mutex_enter(&g_VBoxUSBMonSolarisMtx);492 g_cVBoxUSBMonSolarisClient--;493 if (!g_cVBoxUSBMonSolarisClient)494 {495 if (RT_LIKELY(g_pDip))496 {497 mutex_exit(&g_VBoxUSBMonSolarisMtx);498 usb_unregister_dev_driver(g_pDip);499 Log((DEVICE_NAME ":Successfully deregistered driver election callback\n"));500 }501 else502 {503 mutex_exit(&g_VBoxUSBMonSolarisMtx);504 LogRel((DEVICE_NAME ":Extreme error! Missing device info during close.\n"));505 }506 }507 else508 mutex_exit(&g_VBoxUSBMonSolarisMtx);509 476 510 477 /* … … 526 493 static int VBoxUSBMonSolarisRead(dev_t Dev, struct uio *pUio, cred_t *pCred) 527 494 { 528 LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisRead\n"));495 LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisRead\n")); 529 496 return 0; 530 497 } … … 533 500 static int VBoxUSBMonSolarisWrite(dev_t Dev, struct uio *pUio, cred_t *pCred) 534 501 { 535 LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisWrite\n"));502 LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisWrite\n")); 536 503 return 0; 537 504 } … … 548 515 static int VBoxUSBMonSolarisIOCtl(dev_t Dev, int Cmd, intptr_t pArg, int Mode, cred_t *pCred, int *pVal) 549 516 { 550 LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisIOCtlDev=%d Cmd=%d pArg=%p Mode=%d\n", Dev, Cmd, pArg));517 LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: Dev=%d Cmd=%d pArg=%p Mode=%d\n", Dev, Cmd, pArg)); 551 518 552 519 /* … … 556 523 if (!pState) 557 524 { 558 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: no state data for%d\n", getminor(Dev)));525 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: No state data for minor instance %d\n", getminor(Dev))); 559 526 return EINVAL; 560 527 } … … 567 534 if (IOCPARM_LEN(Cmd) != sizeof(ReqWrap)) 568 535 { 569 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: bad request %#x size=%d expected=%d\n", Cmd, IOCPARM_LEN(Cmd), sizeof(ReqWrap))); 536 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: bad request %#x size=%d expected=%d\n", Cmd, IOCPARM_LEN(Cmd), 537 sizeof(ReqWrap))); 570 538 return ENOTTY; 571 539 } … … 574 542 if (RT_UNLIKELY(rc)) 575 543 { 576 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: ddi_copyin failed to read header pArg=%p Cmd=%d. rc=%d .\n", pArg, Cmd, rc));544 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: ddi_copyin failed to read header pArg=%p Cmd=%d. rc=%d\n", pArg, Cmd, rc)); 577 545 return EINVAL; 578 546 } … … 580 548 if (ReqWrap.u32Magic != VBOXUSBMON_MAGIC) 581 549 { 582 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: bad magic %#x; pArg=%p Cmd=%d.\n", ReqWrap.u32Magic, pArg, Cmd));550 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: Bad magic %#x; pArg=%p Cmd=%d\n", ReqWrap.u32Magic, pArg, Cmd)); 583 551 return EINVAL; 584 552 } … … 586 554 || ReqWrap.cbData > _1M*16)) 587 555 { 588 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: bad size %#x; pArg=%p Cmd=%d.\n", ReqWrap.cbData, pArg, Cmd));556 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: Bad size %#x; pArg=%p Cmd=%d\n", ReqWrap.cbData, pArg, Cmd)); 589 557 return EINVAL; 590 558 } … … 596 564 if (RT_UNLIKELY(!pvBuf)) 597 565 { 598 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: RTMemTmpAlloc failed to alloc %d bytes.\n", ReqWrap.cbData));566 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: RTMemTmpAlloc failed to alloc %d bytes\n", ReqWrap.cbData)); 599 567 return ENOMEM; 600 568 } … … 604 572 { 605 573 RTMemTmpFree(pvBuf); 606 LogRel((DEVICE_NAME ":VBoxUSBMonSolarisIOCtl: ddi_copyin failed; pvBuf=%p pArg=%p Cmd=%d. rc=%d\n", pvBuf, pArg, Cmd, rc)); 574 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: ddi_copyin failed; pvBuf=%p pArg=%p Cmd=%d. rc=%d\n", pvBuf, pArg, Cmd, 575 rc)); 607 576 return EFAULT; 608 577 } … … 611 580 { 612 581 RTMemTmpFree(pvBuf); 613 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: pvBuf invalid pointer %p\n", pvBuf));582 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: pvBuf Invalid pointer %p\n", pvBuf)); 614 583 return EINVAL; 615 584 } 616 Log((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: pid=%d.\n", (int)RTProcSelf()));585 Log((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: pid=%d\n", (int)RTProcSelf())); 617 586 618 587 /* … … 626 595 if (RT_UNLIKELY(cbDataReturned > ReqWrap.cbData)) 627 596 { 628 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: too much output data %d expected %d\n", cbDataReturned, ReqWrap.cbData));597 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: Too much output data %d expected %d\n", cbDataReturned, ReqWrap.cbData)); 629 598 cbDataReturned = ReqWrap.cbData; 630 599 } … … 646 615 if (RT_UNLIKELY(rc)) 647 616 { 648 LogRel((DEVICE_NAME ":VBoxUSBMonSolarisIOCtl: ddi_copyout failed; pvBuf=%p pArg=%p Cmd=%d. rc=%d\n", pvBuf, pArg, Cmd, rc)); 617 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: ddi_copyout failed; pvBuf=%p pArg=%p Cmd=%d. rc=%d\n", pvBuf, 618 pArg, Cmd, rc)); 649 619 rc = EFAULT; 650 620 } … … 653 623 else 654 624 { 655 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: ddi_copyout(1) failed pArg=%p Cmd=%d\n", pArg, Cmd));625 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: ddi_copyout(1) failed pArg=%p Cmd=%d\n", pArg, Cmd)); 656 626 rc = EFAULT; 657 627 } … … 679 649 static int vboxUSBMonSolarisProcessIOCtl(int iFunction, void *pvState, void *pvData, size_t cbData, size_t *pcbReturnedData) 680 650 { 681 LogFunc((DEVICE_NAME ": solarisUSBProcessIOCtliFunction=%d pvBuf=%p cbBuf=%zu\n", iFunction, pvData, cbData));651 LogFunc((DEVICE_NAME ": vboxUSBMonSolarisProcessIOCtl: iFunction=%d pvBuf=%p cbBuf=%zu\n", iFunction, pvData, cbData)); 682 652 683 653 AssertPtrReturn(pvState, VERR_INVALID_POINTER); … … 709 679 PUSBFILTER pFilter = (PUSBFILTER)&pReq->Filter; 710 680 711 Log(("vboxUSBMonSolarisProcessIOCtl: idVendor=%#x idProduct=%#x bcdDevice=%#x bDeviceClass=%#x bDeviceSubClass=%#x bDeviceProtocol=%#x bBus=%#x bPort=%#x\n", 681 Log(("vboxUSBMonSolarisProcessIOCtl: idVendor=%#x idProduct=%#x bcdDevice=%#x bDeviceClass=%#x " 682 "bDeviceSubClass=%#x bDeviceProtocol=%#x bBus=%#x bPort=%#x\n", 712 683 USBFilterGetNum(pFilter, USBFILTERIDX_VENDOR_ID), 713 684 USBFilterGetNum(pFilter, USBFILTERIDX_PRODUCT_ID), … … 727 698 rc = VBoxUSBFilterAdd(pFilter, pState->Process, &pReq->uId); 728 699 *pcbReturnedData = cbData; 729 Log((DEVICE_NAME ": vboxUSBMonSolarisProcessIOCtl: ADD_FILTER (Process:%d) returned %d\n", pState->Process, rc));700 Log((DEVICE_NAME ": vboxUSBMonSolarisProcessIOCtl: ADD_FILTER (Process:%d) returned %d\n", pState->Process, rc)); 730 701 break; 731 702 } … … 738 709 rc = VBoxUSBFilterRemove(pState->Process, (uintptr_t)pReq->uId); 739 710 *pcbReturnedData = 0; 740 Log((DEVICE_NAME ": vboxUSBMonSolarisProcessIOCtl: REMOVE_FILTER (Process:%d) returned %d\n", pState->Process, rc));711 Log((DEVICE_NAME ": vboxUSBMonSolarisProcessIOCtl: REMOVE_FILTER (Process:%d) returned %d\n", pState->Process, rc)); 741 712 break; 742 713 } … … 749 720 rc = vboxUSBMonSolarisResetDevice(pReq->szDevicePath, pReq->fReattach); 750 721 *pcbReturnedData = 0; 751 Log((DEVICE_NAME ": vboxUSBMonSolarisProcessIOCtl: RESET_DEVICE (Process:%d) returned %d\n", pState->Process, rc));722 Log((DEVICE_NAME ": vboxUSBMonSolarisProcessIOCtl: RESET_DEVICE (Process:%d) returned %d\n", pState->Process, rc)); 752 723 break; 753 724 } … … 760 731 rc = vboxUSBMonSolarisClientInfo(pState, pReq); 761 732 *pcbReturnedData = cbData; 762 Log((DEVICE_NAME ": vboxUSBMonSolarisProcessIOCtl: CLIENT_INFO (Process:%d) returned %d\n", pState->Process, rc));733 Log((DEVICE_NAME ": vboxUSBMonSolarisProcessIOCtl: CLIENT_INFO (Process:%d) returned %d\n", pState->Process, rc)); 763 734 break; 764 735 } … … 773 744 *pcbReturnedData = sizeof(VBOXUSBREQ_GET_VERSION); 774 745 rc = VINF_SUCCESS; 775 Log((DEVICE_NAME ": vboxUSBMonSolarisProcessIOCtl: GET_VERSION returned %d\n", rc));746 Log((DEVICE_NAME ": vboxUSBMonSolarisProcessIOCtl: GET_VERSION returned %d\n", rc)); 776 747 break; 777 748 } … … 779 750 default: 780 751 { 781 LogRel((DEVICE_NAME ":vboxUSBMonSolarisProcessIOCtl: Unknown request (Process:%d) %#x\n", pState->Process, iFunction)); 752 LogRel((DEVICE_NAME ": vboxUSBMonSolarisProcessIOCtl: Unknown request (Process:%d) %#x\n", pState->Process, 753 iFunction)); 782 754 *pcbReturnedData = 0; 783 755 rc = VERR_NOT_SUPPORTED; … … 793 765 int rc = VERR_GENERAL_FAILURE; 794 766 795 LogFunc((DEVICE_NAME ": vboxUSBMonSolarisResetDevicepszDevicePath=%s fReattach=%d\n", pszDevicePath, fReattach));767 LogFunc((DEVICE_NAME ": vboxUSBMonSolarisResetDevice: pszDevicePath=%s fReattach=%d\n", pszDevicePath, fReattach)); 796 768 797 769 /* … … 812 784 if (!pTmpDeviceInfo) 813 785 { 814 LogRel((DEVICE_NAME ":vboxUSBMonSolarisResetDevice failed to get parent device info for %s\n", pszDevicePath));786 LogRel((DEVICE_NAME ":vboxUSBMonSolarisResetDevice: Failed to get parent device info for %s\n", pszDevicePath)); 815 787 return VERR_GENERAL_FAILURE; 816 788 } … … 826 798 */ 827 799 rc = usb_reset_device(pDeviceInfo, fReattach ? USB_RESET_LVL_REATTACH : USB_RESET_LVL_DEFAULT); 828 Log((DEVICE_NAME ":usb_reset_device for %s level=%s returned %d\n", pszDevicePath, fReattach ? "ReAttach" : "Default", rc)); 800 Log((DEVICE_NAME ": vboxUSBMonSolarisResetDevice: usb_reset_device for %s level=%s rc=%d\n", pszDevicePath, 801 fReattach ? "ReAttach" : "Default", rc)); 802 829 803 switch (rc) 830 804 { … … 842 816 { 843 817 rc = VERR_INVALID_HANDLE; 844 LogRel((DEVICE_NAME ": vboxUSBMonSolarisResetDeviceCannot obtain device info for %s\n", pszDevicePath));818 LogRel((DEVICE_NAME ": vboxUSBMonSolarisResetDevice: Cannot obtain device info for %s\n", pszDevicePath)); 845 819 } 846 820 … … 859 833 static int vboxUSBMonSolarisClientInfo(vboxusbmon_state_t *pState, PVBOXUSB_CLIENT_INFO pClientInfo) 860 834 { 861 LogFunc((DEVICE_NAME ": vboxUSBMonSolarisClientInfopState=%p pClientInfo=%p\n", pState, pClientInfo));835 LogFunc((DEVICE_NAME ": vboxUSBMonSolarisClientInfo: pState=%p pClientInfo=%p\n", pState, pClientInfo)); 862 836 863 837 AssertPtrReturn(pState, VERR_INVALID_POINTER); … … 882 856 rc = pCur->Info.pfnSetConsumerCredentials(pState->Process, pCur->Info.Instance, NULL /* pvReserved */); 883 857 if (RT_FAILURE(rc)) 884 LogRel((DEVICE_NAME ": vboxUSBMonSolarisClientInfo pfnSetConsumerCredentials failed.rc=%d\n", rc));858 LogRel((DEVICE_NAME ": vboxUSBMonSolarisClientInfo: pfnSetConsumerCredentials failed! rc=%d\n", rc)); 885 859 } 886 860 else … … 889 863 mutex_exit(&g_VBoxUSBMonSolarisMtx); 890 864 891 Log((DEVICE_NAME ": vboxUSBMonSolarisClientInfo found. %src=%d\n", pClientInfo->szDeviceIdent, rc));865 Log((DEVICE_NAME ": vboxUSBMonSolarisClientInfo: Found %s, rc=%d\n", pClientInfo->szDeviceIdent, rc)); 892 866 return rc; 893 867 } … … 898 872 mutex_exit(&g_VBoxUSBMonSolarisMtx); 899 873 900 LogRel((DEVICE_NAME ": vboxUSBMonSolarisClientInfoFailed to find client %s\n", pClientInfo->szDeviceIdent));874 LogRel((DEVICE_NAME ": vboxUSBMonSolarisClientInfo: Failed to find client %s\n", pClientInfo->szDeviceIdent)); 901 875 return VERR_NOT_FOUND; 902 876 } … … 910 884 int VBoxUSBMonSolarisRegisterClient(dev_info_t *pClientDip, PVBOXUSB_CLIENT_INFO pClientInfo) 911 885 { 912 LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisRegisterClientpClientDip=%p pClientInfo=%p\n", pClientDip, pClientInfo));886 LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisRegisterClient: pClientDip=%p pClientInfo=%p\n", pClientDip, pClientInfo)); 913 887 AssertPtrReturn(pClientInfo, VERR_INVALID_PARAMETER); 914 888 … … 929 903 mutex_exit(&g_VBoxUSBMonSolarisMtx); 930 904 931 Log((DEVICE_NAME ":VBoxUSBMonSolarisRegisterClient registered. %d %s %s\n", 932 pClient->Info.Instance, pClient->Info.szClientPath, pClient->Info.szDeviceIdent)); 933 905 Log((DEVICE_NAME ": Client registered (ClientPath=%s Ident=%s)\n", pClient->Info.szClientPath, 906 pClient->Info.szDeviceIdent)); 934 907 return VINF_SUCCESS; 935 908 } … … 947 920 int VBoxUSBMonSolarisUnregisterClient(dev_info_t *pClientDip) 948 921 { 949 LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisUnregisterClientpClientDip=%p\n", pClientDip));922 LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisUnregisterClient: pClientDip=%p\n", pClientDip)); 950 923 AssertReturn(pClientDip, VERR_INVALID_PARAMETER); 951 924 … … 967 940 mutex_exit(&g_VBoxUSBMonSolarisMtx); 968 941 969 Log((DEVICE_NAME ": VBoxUSBMonSolarisUnregisterClient unregistered. %d %s %s\n",970 pCur->Info.Instance, pCur->Info.szClientPath,pCur->Info.szDeviceIdent));942 Log((DEVICE_NAME ": Client unregistered (ClientPath=%s Ident=%s)\n", pCur->Info.szClientPath, 943 pCur->Info.szDeviceIdent)); 971 944 RTMemFree(pCur); 972 pCur = NULL;973 945 return VINF_SUCCESS; 974 946 } … … 979 951 mutex_exit(&g_VBoxUSBMonSolarisMtx); 980 952 981 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisUnregisterClientFailed to find registered client %p\n", pClientDip));953 LogRel((DEVICE_NAME ": VBoxUSBMonSolarisUnregisterClient: Failed to find registered client %p\n", pClientDip)); 982 954 return VERR_NOT_FOUND; 983 955 } … … 1001 973 char **ppszDrv, void *pvReserved) 1002 974 { 1003 LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisElectDriverpDevDesc=%p pDevStrings=%p pszDevicePath=%s Bus=%d Port=%d\n", pDevDesc,975 LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisElectDriver: pDevDesc=%p pDevStrings=%p pszDevicePath=%s Bus=%d Port=%d\n", pDevDesc, 1004 976 pDevStrings, pszDevicePath, Bus, Port)); 1005 977 … … 1027 999 USBFilterSetMustBePresent(&Filter, USBFILTERIDX_BUS, false /* fMustBePresent */); 1028 1000 1029 Log((DEVICE_NAME ":VBoxUSBMonSolarisElectDriver: idVendor=%#x idProduct=%#x bcdDevice=%#x bDeviceClass=%#x bDeviceSubClass=%#x bDeviceProtocol=%#x bBus=%#x bPort=%#x\n", 1001 Log((DEVICE_NAME ": VBoxUSBMonSolarisElectDriver: idVendor=%#x idProduct=%#x bcdDevice=%#x bDeviceClass=%#x " 1002 "bDeviceSubClass=%#x bDeviceProtocol=%#x bBus=%#x bPort=%#x\n", 1030 1003 USBFilterGetNum(&Filter, USBFILTERIDX_VENDOR_ID), 1031 1004 USBFilterGetNum(&Filter, USBFILTERIDX_PRODUCT_ID), … … 1036 1009 USBFilterGetNum(&Filter, USBFILTERIDX_BUS), 1037 1010 USBFilterGetNum(&Filter, USBFILTERIDX_PORT))); 1038 Log((DEVICE_NAME ": VBoxUSBMonSolarisElectDriver: Manufacturer=%s Product=%s Serial=%s\n",1011 Log((DEVICE_NAME ": VBoxUSBMonSolarisElectDriver: Manufacturer=%s Product=%s Serial=%s\n", 1039 1012 USBFilterGetString(&Filter, USBFILTERIDX_MANUFACTURER_STR) ? USBFilterGetString(&Filter, USBFILTERIDX_MANUFACTURER_STR) : "<null>", 1040 1013 USBFilterGetString(&Filter, USBFILTERIDX_PRODUCT_STR) ? USBFilterGetString(&Filter, USBFILTERIDX_PRODUCT_STR) : "<null>", … … 1049 1022 if (Owner == NIL_RTPROCESS) 1050 1023 { 1051 Log((DEVICE_NAME ":No matching filters, device %#x:%#x uninteresting.\n", pDevDesc->idVendor, pDevDesc->idProduct)); 1024 Log((DEVICE_NAME ": VBoxUSBMonSolarisElectDriver: No matching filters, device %#x:%#x uninteresting\n", 1025 pDevDesc->idVendor, pDevDesc->idProduct)); 1052 1026 return USB_FAILURE; 1053 1027 } 1054 1028 1055 1029 *ppszDrv = ddi_strdup(VBOXUSB_DRIVER_NAME, KM_SLEEP); 1056 LogRel((DEVICE_NAME ": Capturing %s %#x:%#x:%s\n", pDevStrings->usb_product ? pDevStrings->usb_product : "<Unnamed USB device>", 1057 pDevDesc->idVendor, pDevDesc->idProduct, pszDevicePath)); 1030 LogRel((DEVICE_NAME ": Capturing %s %s %#x:%#x:%s Bus=%d Port=%d\n", 1031 pDevStrings->usb_mfg ? pDevStrings->usb_mfg : "<Unknown Manufacturer>", 1032 pDevStrings->usb_product ? pDevStrings->usb_product : "<Unnamed USB device>", 1033 pDevDesc->idVendor, pDevDesc->idProduct, pszDevicePath, Bus, Port)); 1058 1034 return USB_SUCCESS; 1059 1035 } -
trunk/src/VBox/HostDrivers/VBoxUSB/solaris/include/usbai_private.h
r33540 r59091 24 24 */ 25 25 26 #ifndef _SYS_USB_USBA_USBAI_PRIVATE_H 27 #define _SYS_USB_USBA_USBAI_PRIVATE_H 28 26 #ifndef _SYS_USB_USBA_USBAI_PRIVATE_H 27 #define _SYS_USB_USBA_USBAI_PRIVATE_H 29 28 30 29 /* … … 34 33 * 35 34 * Status key: 36 * 37 * 35 * C = Remove from Sun client drivers before removing from this file 36 * D = May be needed by legacy (DDK) drivers. 38 37 */ 39 38 40 #ifdef 39 #ifdef __cplusplus 41 40 extern "C" { 42 41 #endif … … 51 50 52 51 /* 53 * **************************************************************************54 * Error and status definitions, and reporting functions55 * **************************************************************************56 */57 58 59 /*60 * convenience functions to get string corresponding to value61 * usb_cb_flags_name requires a workbuffer of sufficient length62 * for the concatenation of all strings as usb_cb_flags_t is a bit63 * mask64 *65 * Status: C and D66 */67 const char *usb_str_cr(usb_cr_t cr);68 char *usb_str_cb_flags(usb_cb_flags_t cb_flags,69 char *buffer, size_t length);70 const char *usb_str_pipe_state(usb_pipe_state_t state);71 const char *usb_str_dev_state(int state);72 const char *usb_str_rval(int rval);73 74 /* function convert a USB return value to an errno */75 int usb_rval2errno(int rval);76 77 /*78 * **************************************************************************79 * Transfer-related definitions and functions80 * **************************************************************************81 */82 83 /* Status C and D for whole section. */84 85 /* Serialize callbacks per interface or device. */86 #define USB_FLAGS_SERIALIZED_CB 0x800087 88 /* default timeout for control requests (in seconds) */89 #define USB_PIPE_TIMEOUT 390 91 /*92 * usb_pipe_sync_ctrl_xfer():93 * for simple synchronous control transactions this wrapper function94 * will perform the allocation, xfer, and deallocation.95 * USB_ATTRS_AUTOCLEARING will be enabled96 *97 * ARGUMENTS:98 * dip - pointer to clients devinfo.99 * pipe_handle - control pipe pipehandle (obtained via usb_pipe_open().100 * bmRequestType - characteristics of request.101 * bRequest - specific request.102 * wValue - varies according to request.103 * wIndex - index or offset.104 * wLength - number of bytes to xfer.105 * data - pointer to pointer to data106 * IN: HCD will allocate data107 * OUT: clients driver allocates data.108 * attrs - required request attributes.109 * completion_reason - completion status.110 * cb_flags - request completions flags.111 * flags - none.112 *113 * RETURN VALUES:114 * USB_SUCCESS - request successfully executed.115 * USB_FAILURE - request failed.116 *117 * NOTES:118 * - in the case of failure, the client should check completion_reason and119 * and cb_flags and determine further recovery action120 * - the client should check data and if non-zero, free the data on121 * completion122 */123 int usb_pipe_sync_ctrl_xfer(124 dev_info_t *dip,125 usb_pipe_handle_t pipe_handle,126 uchar_t bmRequestType,127 uchar_t bRequest,128 uint16_t wValue,129 uint16_t wIndex,130 uint16_t wLength,131 mblk_t **data,132 usb_req_attrs_t attrs,133 usb_cr_t *completion_reason,134 usb_cb_flags_t *cb_flags,135 usb_flags_t flags);136 137 /*138 * **************************************************************************139 * Event registration / pre-suspend and post-resume handling140 * **************************************************************************141 */142 143 /* Status: C and D for whole section. */144 145 /*146 * Event registration info for both hotplug and pre-suspend/post-resume147 * callbacks. Eventually pre-suspend and post-resume callbacks will not be148 * needed, so this is for this OS release only and will go away in a149 * subsequent release.150 */151 typedef struct usb_event {152 /* device disconnected/unplugged */153 int (*disconnect_event_handler)(dev_info_t *dip);154 155 /* device reconnected */156 int (*reconnect_event_handler)(dev_info_t *dip);157 158 /* notification that system is about to checkpoint */159 int (*pre_suspend_event_handler)(dev_info_t *dip);160 161 /* notification that system resumed after a checkpoint */162 int (*post_resume_event_handler)(dev_info_t *dip);163 } usb_event_t;164 165 /*166 * Event callbacks167 * the callbacks should always return USB_SUCCESS.168 */169 int usb_register_event_cbs(170 dev_info_t *dip,171 usb_event_t *usb_evt_data,172 usb_flags_t flags);173 174 void usb_unregister_event_cbs(175 dev_info_t *dip,176 usb_event_t *usb_evt_data);177 178 /*179 * USB CPR support180 * A client driver must call this function in pre-suspend event handler181 * to inform the USBA framework that it can't suspend because182 * driver instance or device could not be quiesced.183 */184 void usb_fail_checkpoint(185 dev_info_t *dip,186 usb_flags_t flags);187 188 189 /*190 * **************************************************************************191 * Logging functions remaining Contracted Consolidation Private192 * **************************************************************************193 */194 195 /* Status: C and D for whole section. */196 197 /*198 52 * Usb logging, debug and console message handling. 199 53 */ 200 54 typedef struct usb_log_handle *usb_log_handle_t; 201 55 202 #define USB_LOG_L0 0/* warnings, console & syslog buffer */203 #define USB_LOG_L1 1/* errors, syslog buffer */204 #define USB_LOG_L2 2/* recoverable errors, debug only */205 #define USB_LOG_L3 3/* interesting data, debug only */206 #define USB_LOG_L4 4/* tracing, debug only */56 #define USB_LOG_L0 0 /* warnings, console & syslog buffer */ 57 #define USB_LOG_L1 1 /* errors, syslog buffer */ 58 #define USB_LOG_L2 2 /* recoverable errors, debug only */ 59 #define USB_LOG_L3 3 /* interesting data, debug only */ 60 #define USB_LOG_L4 4 /* tracing, debug only */ 207 61 208 #ifdef DEBUG 209 #define USB_DPRINTF_L4 usb_dprintf4 210 #define USB_DPRINTF_L3 usb_dprintf3 62 #define USB_CHK_BASIC 0 /* Empty mask. Basics always done. */ 63 #define USB_CHK_SERIAL 0x00000001 /* Compare device serial numbers. */ 64 #define USB_CHK_CFG 0x00000002 /* Compare raw config clouds. */ 65 #define USB_CHK_VIDPID 0x00000004 /* Compare product and vendor ID. */ 66 #define USB_CHK_ALL 0xFFFFFFFF /* Perform maximum checking. */ 211 67 212 /*PRINTFLIKE3*/ 213 void usb_dprintf4( 214 uint_t mask, 215 usb_log_handle_t handle, 216 char *fmt, ...); 217 /*PRINTFLIKE3*/ 218 void usb_dprintf3( 219 uint_t mask, 220 usb_log_handle_t handle, 221 char *fmt, ...); 222 #else 223 #define USB_DPRINTF_L4 0 && 224 #define USB_DPRINTF_L3 0 && 225 #endif 226 227 #define USB_DPRINTF_L2 usb_dprintf2 228 #define USB_DPRINTF_L1 usb_dprintf1 229 #define USB_DPRINTF_L0 usb_dprintf0 230 231 /*PRINTFLIKE3*/ 232 void usb_dprintf2( 233 uint_t mask, 234 usb_log_handle_t handle, 235 char *fmt, ...); 236 /*PRINTFLIKE3*/ 237 void usb_dprintf1( 238 uint_t mask, 239 usb_log_handle_t handle, 240 char *fmt, ...); 241 /*PRINTFLIKE3*/ 242 void usb_dprintf0( 243 uint_t mask, 244 usb_log_handle_t handle, 245 char *fmt, ...); 246 247 usb_log_handle_t usb_alloc_log_hdl( 248 dev_info_t *dip, 249 char *name, 250 uint_t *errlevel, 251 uint_t *mask, 252 uint_t *instance_filter, 253 usb_flags_t flags); 254 255 /* free the log handle */ 256 void usb_free_log_hdl( 257 usb_log_handle_t handle); 258 259 /* log message */ 260 /*PRINTFLIKE4*/ 261 int usb_log( 262 usb_log_handle_t handle, 263 uint_t level, 264 uint_t mask, 265 char *fmt, ...); 266 267 /* 268 * usb_check_same_device: 269 * Check if the device connected to the port is the same as 270 * the previous device that was in the port. The previous device is 271 * represented by the dip on record for the port. Print a message 272 * if the device is different. If device_string arg is not NULL, it is 273 * included in the message. Can block. 274 * 275 * Arguments: 276 * dip - pointer to devinfo of the client 277 * log_handle - handle to which messages are logged 278 * log_level - one of USB_LOG_* 279 * log_mask - logging mask 280 * check_mask - one mask containing things to check: 281 * USB_CHK_BASIC: empty mask; 282 * these checks are always done. 283 * USB_CHK_SERIAL: check match on device 284 * serial number. 285 * USB_CHK_CFG: compare config clouds 286 * byte by byte 287 * USB_CHK_VIDPID: compare product 288 * and vendor ID 289 * USB_CHK_ALL: perform all checks 290 * 291 * NOTE: descr length and content always checked 292 * device_string - Device string to appear in error message 293 * 294 * return values: 295 * USB_SUCCESS: same device 296 * USB_INVALID_VERSION not same device 297 * USB_FAILURE: Failure processing request 298 * USB_INVALID_ARG: dip is invalid 299 */ 300 301 /* Checking bits for checks made by usb_check_same_device */ 302 #define USB_CHK_BASIC 0 /* Empty mask. Basics always done. */ 303 #define USB_CHK_SERIAL 0x00000001 /* Compare device serial numbers. */ 304 #define USB_CHK_CFG 0x00000002 /* Compare raw config clouds. */ 305 #define USB_CHK_VIDPID 0x00000004 /* Compare product and vendor ID. */ 306 #define USB_CHK_ALL 0xFFFFFFFF /* Perform maximum checking. */ 307 308 int usb_check_same_device( 309 dev_info_t *dip, 310 usb_log_handle_t log_handle, 311 int log_level, 312 int log_mask, 313 uint_t check_mask, 314 char *device_string); 315 316 /* 317 * ************************************************************************** 318 * Power management functions remaining Contracted Consolidation Private 319 * ************************************************************************** 320 */ 321 322 /* 323 * usb wrapper around pm_raise_power & pm_lower_power to allow for 324 * non blocking behavior 325 * 326 * Arguments: 327 * dip - pointer to devinfo node of client. 328 * comp - component. 329 * level - power level. 330 * flags - USB_FLAGS_SLEEP: 331 * wait for completion. 332 * cb - function called on completion, may be NULL. 333 * arg - callback argument. 334 * rval - USB_SUCCESS or USB_FAILURE. 335 * 336 * Return Values: 337 * USB_SUCCESS - if no USB_FLAGS_SLEEP has been specified, the request 338 * has been queued for async execution. If 339 * USB_FLAGS_SLEEP has been specified, the raising or 340 * lowering of power 341 * succeeded. 342 * USB_FAILURE - request could not be queued or raising or lowering 343 * of power failed. 344 */ 345 346 /* Status: C and D */ 347 int usb_req_raise_power( 348 dev_info_t *dip, 349 int comp, 350 int level, 351 void (*cb)(void *arg, int rval), 352 void *arg, 353 usb_flags_t flags); 354 355 /* Status: D */ 356 int usb_req_lower_power( 357 dev_info_t *dip, 358 int comp, 359 int level, 360 void (*cb)(void *arg, int rval), 361 void *arg, 362 usb_flags_t flags); 363 364 /* 365 * USB wrapper functions to set usb device power level. 366 * Note : Power levels indicated here are USB power levels 367 * and not OS power levels. 368 * 369 * Note that these were never implemented, and are noops. However, they are 370 * included here as the skeleton driver in DDK 0.8 and 0.9 mentioned them. 371 * 372 * Status: C and D. 373 */ 374 int usb_set_device_pwrlvl0( 375 dev_info_t *dip); 376 int usb_set_device_pwrlvl1( 377 dev_info_t *dip); 378 int usb_set_device_pwrlvl2( 379 dev_info_t *dip); 380 int usb_set_device_pwrlvl3( 381 dev_info_t *dip); 382 68 int usb_check_same_device(dev_info_t *dip, 69 usb_log_handle_t log_handle, 70 int log_level, 71 int log_mask, 72 uint_t check_mask, 73 char *device_string); 383 74 384 75 /* … … 392 83 /* 393 84 * opaque serialization handle. 394 * 85 * Used by all usb_serialization routines. 395 86 * 396 * 87 * This handle is opaque to the client driver. 397 88 */ 398 typedef struct usb_serialization*usb_serialization_t;89 typedef struct usb_serialization *usb_serialization_t; 399 90 400 91 /* 401 92 * usb_init_serialization 402 * 93 * setup for serialization 403 94 * 404 95 * ARGUMENTS: 405 * s_dip - devinfo pointer 406 * flag - USB_INIT_SER_CHECK_SAME_THREAD 407 * when set, usb_release_access() will 408 * verify that the same thread releases 409 * access. If not, a console warning will 410 * be issued but access will be released 411 * anyways. 96 * s_dip - devinfo pointer 97 * flag - USB_INIT_SER_CHECK_SAME_THREAD 98 * when set, usb_release_access() will verify that the same 99 * thread releases access. If not, a console warning will 100 * be issued but access will be released anyways. 412 101 * 413 102 * RETURNS: 414 * 103 * usb_serialization handle 415 104 * 416 105 */ 417 usb_serialization_t usb_init_serialization( 418 dev_info_t *s_dip, 419 uint_t flag); 106 usb_serialization_t usb_init_serialization(dev_info_t *s_dip, 107 uint_t flag); 420 108 421 #define USB_INIT_SER_CHECK_SAME_THREAD1109 #define USB_INIT_SER_CHECK_SAME_THREAD 1 422 110 423 111 /* fini for serialization */ 424 void usb_fini_serialization( 425 usb_serialization_t usb_serp); 112 void usb_fini_serialization(usb_serialization_t usb_serp); 426 113 427 114 /* 428 * Various ways of calling usb_serialize_access. 115 * Various ways of calling usb_serialize_access. These correspond to 429 116 * their cv_*wait* function counterparts for usb_serialize_access. 430 117 */ 431 #define USB_WAIT0432 #define USB_WAIT_SIG1433 #define USB_TIMEDWAIT2434 #define USB_TIMEDWAIT_SIG3118 #define USB_WAIT 0 119 #define USB_WAIT_SIG 1 120 #define USB_TIMEDWAIT 2 121 #define USB_TIMEDWAIT_SIG 3 435 122 436 123 /* 437 124 * usb_serialize_access: 438 * acquire serialized access 439 * ARGUMENTS: 440 * usb_serp - usb_serialization handle 441 * how_to_wait - Which cv_*wait* function to wait for condition. 442 * USB_WAIT: use cv_wait 443 * USB_WAIT_SIG: use cv_wait_sig 444 * USB_TIMEDWAIT: use cv_timedwait 445 * USB_TIMEDWAIT_SIG: use cv_timedwait_sig 446 * delta_timeout - Time in ms from current time to timeout. Checked 447 * only if USB_TIMEDWAIT or USB_TIMEDWAIT_SIG 448 * specified in how_to_wait. 449 * RETURNS: 450 * Same as values returned by cv_*wait* functions, 451 * except for when how_to_wait == USB_WAIT, where 0 is always returned. 452 * For calls where a timeout or signal could be expected, use this value 453 * to tell whether a kill(2) signal or timeout occurred. 454 */ 455 int usb_serialize_access( 456 usb_serialization_t usb_serp, 457 uint_t how_to_wait, 458 uint_t delta_timeout); 459 460 /* 461 * usb_try_serialize_access: 462 * try acquiring serialized access 125 * acquire serialized access 463 126 * 464 127 * ARGUMENTS: 465 * usb_serp - usb_serialization handle 466 * flag - unused 467 * 128 * usb_serp - usb_serialization handle 129 * how_to_wait - Which cv_*wait* function to wait for condition. 130 * USB_WAIT: use cv_wait 131 * USB_WAIT_SIG: use cv_wait_sig 132 * USB_TIMEDWAIT: use cv_timedwait 133 * USB_TIMEDWAIT_SIG: use cv_timedwait_sig 134 * delta_timeout - Time in ms from current time to timeout. Checked 135 * only if USB_TIMEDWAIT or USB_TIMEDWAIT_SIG 136 * specified in how_to_wait. 468 137 * RETURNS: 469 * USB_SUCCESS - access has been acquired 470 * USB_FAILURE - access has not been acquired 138 * Same as values returned by cv_*wait* functions, 139 * except for when how_to_wait == USB_WAIT, where 0 is always returned. 140 * For calls where a timeout or signal could be expected, use this value 141 * to tell whether a kill(2) signal or timeout occurred. 471 142 */ 472 int usb_try_serialize_access(usb_serialization_t usb_serp, uint_t flag); 143 int usb_serialize_access(usb_serialization_t usb_serp, 144 uint_t how_to_wait, 145 uint_t delta_timeout); 473 146 474 147 /* 475 148 * usb_release_access: 476 * 149 * release serialized access 477 150 * 478 151 * ARGUMENTS: 479 * usb_serp- usb_serialization handle152 * usb_serp - usb_serialization handle 480 153 */ 481 154 void usb_release_access(usb_serialization_t usb_serp); 482 483 484 /*485 * **************************************************************************486 * Asynchronous functions remaining Contracted Consolidation Private487 * **************************************************************************488 */489 490 /* This whole section: status: C and D. */491 492 /* For async_req functions. */493 #define USB_FLAGS_NOQUEUE 0x200494 495 /*496 * Issue a request to the asynchronous request service497 * All async request functions return USB_SUCCESS or USB_FAILURE498 * Arguments:499 * dip - pointer to devinfo node500 * func - pointer of function to execute asynchronously501 * arg - argument to function502 * flag - USB_FLAGS_SLEEP or USB_FLAGS_NOSLEEP or503 * USB_FLAGS_NOQUEUE504 * Return Values:505 * USB_SUCCESS - function was scheduled506 * USB_FAILURE - function could not be scheduled507 *508 * Flag combinations:509 * SLEEP - block waiting for resources. always succeeds510 * NOSLEEP - do not wait for resources, may fail.511 * NOSLEEP+NOQUEUE - do not wait for resources, do not queue512 * SLEEP+NOQUEUE - block waiting for resources but may still fail513 * if no thread available514 */515 int usb_async_req(516 dev_info_t *dip,517 void (*func)(void *),518 void *arg,519 usb_flags_t flag);520 521 522 /*523 * index for getting to usb_pipehandle_list in usba_device524 */525 uchar_t usb_get_ep_index(uint8_t ep_addr);526 527 /*528 * **************************************************************************529 * USB device driver registration and callback functions remaining530 * Contracted Project Private (for VirtualBox USB Device Capture)531 * **************************************************************************532 */533 534 #if 0 /* Uncomment this section if usbai.h doesn't have this these bits (required for snv < 123) */535 536 /*537 * getting the device strings of manufacturer, product and serial number538 */539 typedef struct usb_dev_str {540 char *usb_mfg; /* manufacturer string */541 char *usb_product; /* product string */542 char *usb_serialno; /* serial number string */543 } usb_dev_str_t;544 545 /*546 * It is the callback function type for capture driver.547 * Arguments:548 * dev_descr - pointer to device descriptor549 * dev_str - pointer to device strings550 * path - pointer to device physical path551 * bus - USB bus address552 * port - USB port number553 * drv - capture driver name.554 * It is returned by the callback func.555 * Return Values:556 * USB_SUCCESS - VirtualBox will capture the device557 * USB_FAILURE - VirtualBox will not capture the device558 */559 typedef int (*usb_dev_driver_callback_t)(560 usb_dev_descr_t *dev_descr,561 usb_dev_str_t *dev_str,562 char *path,563 int bus,564 int port,565 char **drv,566 void *reserved);567 568 /*569 * Register the callback function in the usba.570 * Argument:571 * dip - client driver's devinfo pointer572 * cb - callback function573 *574 * Return Values:575 * USB_SUCCESS - the registration was successful576 * USB_FAILURE - the registration failed577 */578 int usb_register_dev_driver(579 dev_info_t *dip,580 usb_dev_driver_callback_t cb);581 582 /*583 * Unregister the callback function in the usba.584 */585 void usb_unregister_dev_driver(dev_info_t *dip);586 #endif587 588 589 #ifdef ALLOCB_TEST590 #define allocb(s, p) usba_test_allocb(s, p)591 mblk_t *usba_test_allocb(size_t, uint_t);592 #endif /* ALLOCB_TEST */593 594 /* create an USB style M_CTL message */595 mblk_t *usba_mk_mctl(struct iocblk, void *, size_t);596 155 597 156 #ifdef __cplusplus … … 599 158 #endif 600 159 601 #endif /* _SYS_USB_USBA_USBAI_PRIVATE_H */ 160 #endif /* _SYS_USB_USBA_USBAI_PRIVATE_H */ 161 -
trunk/src/VBox/Main/src-server/solaris/USBProxyServiceSolaris.cpp
r57358 r59091 262 262 pCur->bPort = 0; 263 263 264 char pathBuf[PATH_MAX];265 RTStrPrintf(pathBuf, sizeof(pathBuf), "%s", pszDevicePath);266 RTPathStripFilename(pathBuf);267 268 264 char szBuf[PATH_MAX + 48]; 269 RTStrPrintf(szBuf, sizeof(szBuf), "%#x:%#x:%d:%s", pCur->idVendor, pCur->idProduct, pCur->bcdDevice, p athBuf);265 RTStrPrintf(szBuf, sizeof(szBuf), "%#x:%#x:%d:%s", pCur->idVendor, pCur->idProduct, pCur->bcdDevice, pszDevicePath); 270 266 pCur->pszAddress = RTStrDup(szBuf); 271 267
Note:
See TracChangeset
for help on using the changeset viewer.