vbox的更動 50228 路徑 trunk/src/VBox/Devices/USB/linux
- 時間撮記:
- 2014-1-24 下午09:16:37 (11 年 以前)
- 檔案:
-
- 修改 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Devices/USB/linux/USBProxyDevice-linux.cpp
r49814 r50228 160 160 /** The device node/sysfs path of the device. 161 161 * Used to figure out the configuration after a reset. */ 162 char szPath[1];162 char *pszPath; 163 163 } USBPROXYDEVLNX, *PUSBPROXYDEVLNX; 164 164 … … 194 194 { 195 195 int rc; 196 PUSBPROXYDEVLNX pDevLnx = (PUSBPROXYDEVLNX)pProxyDev->Backend.pv;196 PUSBPROXYDEVLNX pDevLnx = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVLNX); 197 197 do 198 198 { … … 225 225 static void usbProxLinuxUrbUnplugged(PUSBPROXYDEV pProxyDev) 226 226 { 227 PUSBPROXYDEVLNX pDevLnx = (PUSBPROXYDEVLNX)pProxyDev->Backend.pv;227 PUSBPROXYDEVLNX pDevLnx = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVLNX); 228 228 229 229 /* … … 307 307 static PUSBPROXYURBLNX usbProxyLinuxUrbAlloc(PUSBPROXYDEV pProxyDev, PUSBPROXYURBLNX pSplitHead) 308 308 { 309 PUSBPROXYDEVLNX pDevLnx = (PUSBPROXYDEVLNX)pProxyDev->Backend.pv;309 PUSBPROXYDEVLNX pDevLnx = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVLNX); 310 310 PUSBPROXYURBLNX pUrbLnx; 311 311 … … 360 360 static void usbProxyLinuxUrbFree(PUSBPROXYDEV pProxyDev, PUSBPROXYURBLNX pUrbLnx) 361 361 { 362 PUSBPROXYDEVLNX pDevLnx = (PUSBPROXYDEVLNX)pProxyDev->Backend.pv;362 PUSBPROXYDEVLNX pDevLnx = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVLNX); 363 363 364 364 RTCritSectEnter(&pDevLnx->CritSect); … … 398 398 static void usbProxyLinuxUrbFreeSplitList(PUSBPROXYDEV pProxyDev, PUSBPROXYURBLNX pUrbLnx) 399 399 { 400 PUSBPROXYDEVLNX pDevLnx = (PUSBPROXYDEVLNX)pProxyDev->Backend.pv;400 PUSBPROXYDEVLNX pDevLnx = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVLNX); 401 401 402 402 RTCritSectEnter(&pDevLnx->CritSect); … … 585 585 static int usbProxyLinuxFindActiveConfig(PUSBPROXYDEV pProxyDev, const char *pszPath, int *piFirstCfg) 586 586 { 587 PUSBPROXYDEVLNX pDevLnx = (PUSBPROXYDEVLNX)pProxyDev->Backend.pv;587 PUSBPROXYDEVLNX pDevLnx = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVLNX); 588 588 if (pDevLnx->fUsingSysfs) 589 589 return usbProxyLinuxFindActiveConfigSysfs(pProxyDev, pszPath, piFirstCfg); … … 600 600 RTDECL(int) USBProxyDeviceLinuxGetFD(PUSBPROXYDEV pProxyDev) 601 601 { 602 PUSBPROXYDEVLNX pDevLnx = (PUSBPROXYDEVLNX)pProxyDev->Backend.pv;602 PUSBPROXYDEVLNX pDevLnx = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVLNX); 603 603 AssertReturn(pDevLnx->hFile != NIL_RTFILE, -1); 604 604 return RTFileToNative(pDevLnx->hFile); … … 618 618 * @param pvBackend Backend specific pointer, unused for the linux backend. 619 619 */ 620 static intusbProxyLinuxOpen(PUSBPROXYDEV pProxyDev, const char *pszAddress, void *pvBackend)620 static DECLCALLBACK(int) usbProxyLinuxOpen(PUSBPROXYDEV pProxyDev, const char *pszAddress, void *pvBackend) 621 621 { 622 622 LogFlow(("usbProxyLinuxOpen: pProxyDev=%p pszAddress=%s\n", pProxyDev, pszAddress)); … … 637 637 { 638 638 LogRel(("usbProxyLinuxOpen: Invalid device address: '%s'\n", pszAddress)); 639 pProxyDev->Backend.pv = NULL;640 639 return VERR_INVALID_PARAMETER; 641 640 } … … 662 661 if (RT_SUCCESS(rc)) 663 662 { 664 /* 665 * Allocate and initialize the linux backend data. 666 */ 667 PUSBPROXYDEVLNX pDevLnx = (PUSBPROXYDEVLNX)RTMemAllocZVar(sizeof(*pDevLnx) + cchPath); 668 if (pDevLnx) 663 /* 664 * Initialize the linux backend data. 665 */ 666 PUSBPROXYDEVLNX pDevLnx = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVLNX); 667 pDevLnx->pszPath = RTStrDupN(pszPath, cchPath); 668 if (pDevLnx->pszPath) 669 { 670 rc = RTPipeCreate(&pDevLnx->hPipeWakeupR, &pDevLnx->hPipeWakeupW, 0); 671 if (RT_SUCCESS(rc)) 669 672 { 670 671 rc = RTPipeCreate(&pDevLnx->hPipeWakeupR, &pDevLnx->hPipeWakeupW, 0); 673 pDevLnx->fUsingSysfs = fUsingSysfs; 674 pDevLnx->hFile = hFile; 675 rc = RTCritSectInit(&pDevLnx->CritSect); 672 676 if (RT_SUCCESS(rc)) 673 677 { 674 pDevLnx->fUsingSysfs = fUsingSysfs; 675 memcpy(&pDevLnx->szPath[0], pszPath, cchPath); 676 pDevLnx->szPath[cchPath] = '\0'; 677 pDevLnx->hFile = hFile; 678 rc = RTCritSectInit(&pDevLnx->CritSect); 679 if (RT_SUCCESS(rc)) 680 { 681 pProxyDev->Backend.pv = pDevLnx; 682 683 LogFlow(("usbProxyLinuxOpen(%p, %s): returns successfully File=%RTfile iActiveCfg=%d\n", 684 pProxyDev, pszAddress, pDevLnx->hFile, pProxyDev->iActiveCfg)); 685 686 return VINF_SUCCESS; 687 } 688 RTPipeClose(pDevLnx->hPipeWakeupR); 689 RTPipeClose(pDevLnx->hPipeWakeupW); 678 LogFlow(("usbProxyLinuxOpen(%p, %s): returns successfully File=%RTfile iActiveCfg=%d\n", 679 pProxyDev, pszAddress, pDevLnx->hFile, pProxyDev->iActiveCfg)); 680 681 return VINF_SUCCESS; 690 682 } 691 692 RT MemFree(pDevLnx);683 RTPipeClose(pDevLnx->hPipeWakeupR); 684 RTPipeClose(pDevLnx->hPipeWakeupW); 693 685 } 694 else 695 rc = VERR_NO_MEMORY; 686 } 687 else 688 rc = VERR_NO_MEMORY; 696 689 697 690 RTFileClose(hFile); … … 702 695 Log(("usbProxyLinuxOpen(%p, %s) failed, rc=%s!\n", pProxyDev, pszAddress, 703 696 RTErrGetShort(rc))); 704 pProxyDev->Backend.pv = NULL;705 697 706 698 NOREF(pvBackend); … … 716 708 * @param pProxyDev The proxy device. 717 709 */ 718 static intusbProxyLinuxInit(PUSBPROXYDEV pProxyDev)719 { 720 PUSBPROXYDEVLNX pDevLnx = (PUSBPROXYDEVLNX)pProxyDev->Backend.pv;710 static DECLCALLBACK(int) usbProxyLinuxInit(PUSBPROXYDEV pProxyDev) 711 { 712 PUSBPROXYDEVLNX pDevLnx = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVLNX); 721 713 722 714 /* … … 737 729 pProxyDev->cIgnoreSetConfigs = 1; 738 730 int iFirstCfg; 739 pProxyDev->iActiveCfg = usbProxyLinuxFindActiveConfig(pProxyDev, pDevLnx-> szPath, &iFirstCfg);731 pProxyDev->iActiveCfg = usbProxyLinuxFindActiveConfig(pProxyDev, pDevLnx->pszPath, &iFirstCfg); 740 732 if (pProxyDev->iActiveCfg == -1) 741 733 { 742 734 usbProxyLinuxDoIoCtl(pProxyDev, USBDEVFS_SETCONFIGURATION, &iFirstCfg, false, UINT32_MAX); 743 pProxyDev->iActiveCfg = usbProxyLinuxFindActiveConfig(pProxyDev, pDevLnx-> szPath, NULL);735 pProxyDev->iActiveCfg = usbProxyLinuxFindActiveConfig(pProxyDev, pDevLnx->pszPath, NULL); 744 736 Log(("usbProxyLinuxInit: No active config! Tried to set %d: iActiveCfg=%d\n", iFirstCfg, pProxyDev->iActiveCfg)); 745 737 } … … 753 745 * Closes the proxy device. 754 746 */ 755 static voidusbProxyLinuxClose(PUSBPROXYDEV pProxyDev)747 static DECLCALLBACK(void) usbProxyLinuxClose(PUSBPROXYDEV pProxyDev) 756 748 { 757 749 LogFlow(("usbProxyLinuxClose: pProxyDev=%s\n", usbProxyGetName(pProxyDev))); 758 PUSBPROXYDEVLNX pDevLnx = (PUSBPROXYDEVLNX)pProxyDev->Backend.pv; 759 Assert(pDevLnx); 760 if (!pDevLnx) 761 return; 750 PUSBPROXYDEVLNX pDevLnx = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVLNX); 751 AssertPtrReturnVoid(pDevLnx); 762 752 763 753 /* … … 831 821 RTPipeClose(pDevLnx->hPipeWakeupW); 832 822 833 RT MemFree(pDevLnx);834 pProxyDev->Backend.pv = NULL; 823 RTStrFree(pDevLnx->pszPath); 824 835 825 LogFlow(("usbProxyLinuxClose: returns\n")); 836 826 } … … 1029 1019 * @param pDev The device to reset. 1030 1020 */ 1031 static intusbProxyLinuxReset(PUSBPROXYDEV pProxyDev, bool fResetOnLinux)1021 static DECLCALLBACK(int) usbProxyLinuxReset(PUSBPROXYDEV pProxyDev, bool fResetOnLinux) 1032 1022 { 1033 1023 #ifdef NO_PORT_RESET 1034 PUSBPROXYDEVLNX pDevLnx = (PUSBPROXYDEVLNX)pProxyDev->Backend.pv;1024 PUSBPROXYDEVLNX pDevLnx = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVLNX); 1035 1025 1036 1026 /* … … 1058 1048 1059 1049 /* find the active config - damn annoying. */ 1060 pProxyDev->iActiveCfg = usbProxyLinuxFindActiveConfig(pProxyDev, pDevLnx-> szPath, NULL);1050 pProxyDev->iActiveCfg = usbProxyLinuxFindActiveConfig(pProxyDev, pDevLnx->pszPath, NULL); 1061 1051 LogFlow(("usbProxyLinuxReset: returns successfully iActiveCfg=%d\n", pProxyDev->iActiveCfg)); 1062 1052 } … … 1128 1118 * @param iCfg The configuration to set. 1129 1119 */ 1130 static intusbProxyLinuxSetConfig(PUSBPROXYDEV pProxyDev, int iCfg)1120 static DECLCALLBACK(int) usbProxyLinuxSetConfig(PUSBPROXYDEV pProxyDev, int iCfg) 1131 1121 { 1132 1122 LogFlow(("usbProxyLinuxSetConfig: pProxyDev=%s cfg=%#x\n", … … 1146 1136 * @returns success indicator. 1147 1137 */ 1148 static intusbProxyLinuxClaimInterface(PUSBPROXYDEV pProxyDev, int iIf)1138 static DECLCALLBACK(int) usbProxyLinuxClaimInterface(PUSBPROXYDEV pProxyDev, int iIf) 1149 1139 { 1150 1140 LogFlow(("usbProxyLinuxClaimInterface: pProxyDev=%s ifnum=%#x\n", usbProxyGetName(pProxyDev), iIf)); … … 1291 1281 static bool usbProxyLinuxSubmitURB(PUSBPROXYDEV pProxyDev, PUSBPROXYURBLNX pCur, PVUSBURB pUrb, bool *pfUnplugged) 1292 1282 { 1293 PUSBPROXYDEVLNX pDevLnx = (PUSBPROXYDEVLNX)pProxyDev->Backend.pv;1283 PUSBPROXYDEVLNX pDevLnx = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVLNX); 1294 1284 unsigned cTries = 0; 1295 1285 … … 1463 1453 * @copydoc USBPROXYBACK::pfnUrbQueue 1464 1454 */ 1465 static intusbProxyLinuxUrbQueue(PVUSBURB pUrb)1455 static DECLCALLBACK(int) usbProxyLinuxUrbQueue(PVUSBURB pUrb) 1466 1456 { 1467 1457 unsigned cTries; … … 1471 1461 PUSBPROXYDEV pProxyDev = usbProxyFromVusbDev(pUrb->pDev); 1472 1462 #endif 1473 PUSBPROXYDEVLNX pDevLnx = (PUSBPROXYDEVLNX)pProxyDev->Backend.pv;1463 PUSBPROXYDEVLNX pDevLnx = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVLNX); 1474 1464 LogFlow(("usbProxyLinuxUrbQueue: pProxyDev=%s pUrb=%p EndPt=%d cbData=%d\n", 1475 1465 usbProxyGetName(pProxyDev), pUrb, pUrb->EndPt, pUrb->cbData)); … … 1723 1713 * @param cMillies Number of milliseconds to wait. Use 0 to not wait at all. 1724 1714 */ 1725 static PVUSBURBusbProxyLinuxUrbReap(PUSBPROXYDEV pProxyDev, RTMSINTERVAL cMillies)1715 static DECLCALLBACK(PVUSBURB) usbProxyLinuxUrbReap(PUSBPROXYDEV pProxyDev, RTMSINTERVAL cMillies) 1726 1716 { 1727 1717 PUSBPROXYURBLNX pUrbLnx = NULL; 1728 PUSBPROXYDEVLNX pDevLnx = (PUSBPROXYDEVLNX)pProxyDev->Backend.pv;1718 PUSBPROXYDEVLNX pDevLnx = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVLNX); 1729 1719 1730 1720 /* … … 1961 1951 * The URB requires reaping, so we don't change its state. 1962 1952 */ 1963 static voidusbProxyLinuxUrbCancel(PVUSBURB pUrb)1953 static DECLCALLBACK(void) usbProxyLinuxUrbCancel(PVUSBURB pUrb) 1964 1954 { 1965 1955 #ifndef RDESKTOP … … 2001 1991 static DECLCALLBACK(int) usbProxyLinuxWakeup(PUSBPROXYDEV pProxyDev) 2002 1992 { 2003 PUSBPROXYDEVLNX pDevLnx = (PUSBPROXYDEVLNX)pProxyDev->Backend.pv;1993 PUSBPROXYDEVLNX pDevLnx = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVLNX); 2004 1994 size_t cbIgnored; 2005 1995 … … 2014 2004 const USBPROXYBACK g_USBProxyDeviceHost = 2015 2005 { 2006 /* pszName */ 2016 2007 "host", 2008 /* cbBackend */ 2009 sizeof(USBPROXYDEVLNX), 2017 2010 usbProxyLinuxOpen, 2018 2011 usbProxyLinuxInit,
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器