Changeset 50228 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Jan 24, 2014 9:16:37 PM (11 years ago)
- Location:
- trunk/src/VBox/Devices/USB
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/USB/USBProxyDevice-stub.cpp
r44529 r50228 33 33 { 34 34 "host", 35 0, /* cbBackend */ 35 36 NULL, /* Open */ 36 37 NULL, /* Init */ -
trunk/src/VBox/Devices/USB/USBProxyDevice.cpp
r49814 r50228 741 741 RTStrFree(pUsbIns->pszName); 742 742 pUsbIns->pszName = NULL; 743 744 if (pThis->pvInstanceDataR3) 745 RTMemFree(pThis->pvInstanceDataR3); 743 746 } 744 747 … … 820 823 pThis->fMaskedIfs = 0; 821 824 pThis->fOpened = false; 822 pThis->fInited = false;823 825 824 826 /* … … 844 846 else 845 847 pThis->pOps = &g_USBProxyDeviceVRDP; 848 849 pThis->pvInstanceDataR3 = RTMemAllocZ(pThis->pOps->cbBackend); 850 if (!pThis->pvInstanceDataR3) 851 return PDMUSB_SET_ERROR(pUsbIns, VERR_NO_MEMORY, N_("USBProxy: can't allocate memory for host backend")); 852 846 853 rc = pThis->pOps->pfnOpen(pThis, szAddress, pvBackend); 847 854 if (RT_FAILURE(rc)) … … 1065 1072 return rc; 1066 1073 } 1067 pThis->fInited = true;1068 1074 1069 1075 /* -
trunk/src/VBox/Devices/USB/USBProxyDevice.h
r49814 r50228 51 51 /** Name of the backend. */ 52 52 const char *pszName; 53 /** Size of the backend specific data. */ 54 size_t cbBackend; 53 55 54 56 /** … … 64 66 * @param pvBackend Pointer to backend specific data. 65 67 */ 66 int (* pfnOpen)(PUSBPROXYDEV pProxyDev, const char *pszAddress, void *pvBackend);68 DECLR3CALLBACKMEMBER(int, pfnOpen, (PUSBPROXYDEV pProxyDev, const char *pszAddress, void *pvBackend)); 67 69 68 70 /** … … 73 75 * @param pProxyDev The USB Proxy Device instance. 74 76 */ 75 int (* pfnInit)(PUSBPROXYDEV pProxyDev); 76 77 /** Closes handle to the host USB device. 77 DECLR3CALLBACKMEMBER(int, pfnInit, (PUSBPROXYDEV pProxyDev)); 78 79 /** 80 * Closes handle to the host USB device. 78 81 * 79 82 * @param pDev The USB Proxy Device instance. 80 83 */ 81 void (* pfnClose)(PUSBPROXYDEV pProxyDev);84 DECLR3CALLBACKMEMBER(void, pfnClose, (PUSBPROXYDEV pProxyDev)); 82 85 83 86 /** … … 91 94 * being logically reconnected. 92 95 */ 93 int (* pfnReset)(PUSBPROXYDEV pProxyDev, bool fResetOnLinux);94 95 /** @todo make it return a VBox status code! */ 96 int (* pfnSetConfig)(PUSBPROXYDEV pProxyDev, int iCfg);97 98 /** @todo make it return a VBox status code! */ 99 int (* pfnClaimInterface)(PUSBPROXYDEV pProxyDev, int iIf);100 101 /** @todo make it return a VBox status code! */ 102 int (* pfnReleaseInterface)(PUSBPROXYDEV pProxyDev, int iIf);103 104 /** @todo make it return a VBox status code! */ 105 int (* pfnSetInterface)(PUSBPROXYDEV pProxyDev, int iIf, int setting);106 107 /** @todo make it return a VBox status code! */ 108 bool (* pfnClearHaltedEndpoint)(PUSBPROXYDEV pDev, unsigned int iEp);96 DECLR3CALLBACKMEMBER(int, pfnReset, (PUSBPROXYDEV pProxyDev, bool fResetOnLinux)); 97 98 /** @todo make it return a VBox status code! */ 99 DECLR3CALLBACKMEMBER(int, pfnSetConfig, (PUSBPROXYDEV pProxyDev, int iCfg)); 100 101 /** @todo make it return a VBox status code! */ 102 DECLR3CALLBACKMEMBER(int, pfnClaimInterface, (PUSBPROXYDEV pProxyDev, int iIf)); 103 104 /** @todo make it return a VBox status code! */ 105 DECLR3CALLBACKMEMBER(int, pfnReleaseInterface, (PUSBPROXYDEV pProxyDev, int iIf)); 106 107 /** @todo make it return a VBox status code! */ 108 DECLR3CALLBACKMEMBER(int, pfnSetInterface, (PUSBPROXYDEV pProxyDev, int iIf, int setting)); 109 110 /** @todo make it return a VBox status code! */ 111 DECLR3CALLBACKMEMBER(bool, pfnClearHaltedEndpoint, (PUSBPROXYDEV pDev, unsigned int iEp)); 109 112 110 113 /** @todo make it return a VBox status code! Add pDev. */ 111 int (* pfnUrbQueue)(PVUSBURB pUrb);114 DECLR3CALLBACKMEMBER(int, pfnUrbQueue, (PVUSBURB pUrb)); 112 115 113 116 /** … … 117 120 * @todo make it return a VBox status code! Add pDev. 118 121 */ 119 void (* pfnUrbCancel)(PVUSBURB pUrb);122 DECLR3CALLBACKMEMBER(void, pfnUrbCancel, (PVUSBURB pUrb)); 120 123 121 124 /** … … 128 131 * wait at all. 129 132 */ 130 PVUSBURB (* pfnUrbReap)(PUSBPROXYDEV pProxyDev, RTMSINTERVAL cMillies);133 DECLR3CALLBACKMEMBER(PVUSBURB, pfnUrbReap, (PUSBPROXYDEV pProxyDev, RTMSINTERVAL cMillies)); 131 134 132 135 /** … … 136 139 * @param pProxyDev The device. 137 140 */ 138 int (* pfnWakeup)(PUSBPROXYDEV pProxyDev);141 DECLR3CALLBACKMEMBER(int, pfnWakeup, (PUSBPROXYDEV pProxyDev)); 139 142 140 143 /** Dummy entry for making sure we've got all members initialized. */ … … 171 174 PUSBPROXYDEV pPrev; 172 175 /** The vrdp device ID */ 173 uint32_t devid;176 uint32_t devid; 174 177 /** Linked list of in-flight URBs */ 175 178 PVUSBURB pUrbs; … … 203 206 * For dealing with failed construction (the destruct method is always called). */ 204 207 bool fOpened; 205 /** Whether we've called pfnInit or not.206 * For dealing with failed construction (the destruct method is always called). */207 bool fInited;208 208 /** Whether the device has been detached. 209 209 * This is hack for making PDMUSBREG::pfnUsbQueue return the right status code. */ 210 210 bool fDetached; 211 /** Backend specific data */ 212 union USBPROXYBACKENDDATA 213 { 214 /** Pointer to some backend data. 215 * The Linux and Darwin backends are making use of this. */ 216 void *pv; 217 RTFILE hFile; 218 int fd; 219 struct vrdp_priv 220 { 221 void *pCallback; 222 void *pDevice; 223 } vrdp; 224 } Backend; 211 /** Backend specific data, the size is stored in pOps::cbBackend. */ 212 void *pvInstanceDataR3; 225 213 } USBPROXYDEV; 214 215 /** @def USBPROXYDEV_2_DATA 216 * Converts a USB proxy Device, pointer to a pointer to the backend specific instance data. 217 */ 218 #define USBPROXYDEV_2_DATA(a_pProxyDev, a_Type) ( (a_Type)(a_pProxyDev)->pvInstanceDataR3 ) 226 219 227 220 static inline char *usbProxyGetName(PUSBPROXYDEV pProxyDev) -
trunk/src/VBox/Devices/USB/darwin/USBProxyDevice-darwin.cpp
r50093 r50228 5 5 6 6 /* 7 * Copyright (C) 2006-201 2Oracle Corporation7 * Copyright (C) 2006-2014 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 1088 1088 * @param pvBackend Backend specific pointer, unused for the Darwin backend. 1089 1089 */ 1090 static intusbProxyDarwinOpen(PUSBPROXYDEV pProxyDev, const char *pszAddress, void *pvBackend)1090 static DECLCALLBACK(int) usbProxyDarwinOpen(PUSBPROXYDEV pProxyDev, const char *pszAddress, void *pvBackend) 1091 1091 { 1092 1092 int vrc; … … 1098 1098 vrc = RTOnce(&g_usbProxyDarwinOnce, usbProxyDarwinInitOnce, NULL); 1099 1099 AssertRCReturn(vrc, vrc); 1100 1101 PUSBPROXYDEVOSX pDevOsX = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVOSX); 1100 1102 1101 1103 /* … … 1232 1234 { 1233 1235 /* 1234 * Createa proxy device instance.1236 * Init a proxy device instance. 1235 1237 */ 1236 vrc = VERR_NO_MEMORY;1237 PUSBPROXYDEVOSX pDevOsX = (PUSBPROXYDEVOSX)RTMemAllocZ(sizeof(*pDevOsX));1238 if ( pDevOsX)1238 RTListInit((PRTLISTNODE)&pDevOsX->HeadOfRunLoopLst); 1239 vrc = RTCritSectInit(&pDevOsX->CritSect); 1240 if (RT_SUCCESS(vrc)) 1239 1241 { 1240 RTListInit((PRTLISTNODE)&pDevOsX->HeadOfRunLoopLst); 1241 vrc = RTCritSectInit(&pDevOsX->CritSect); 1242 pDevOsX->USBDevice = USBDevice; 1243 pDevOsX->ppDevI = ppDevI; 1244 pDevOsX->pProxyDev = pProxyDev; 1245 1246 /* 1247 * Try seize all the interface. 1248 */ 1249 char *pszDummyName = pProxyDev->pUsbIns->pszName; 1250 pProxyDev->pUsbIns->pszName = (char *)pszAddress; 1251 vrc = usbProxyDarwinSeizeAllInterfaces(pDevOsX, false /* give up on failure */); 1252 pProxyDev->pUsbIns->pszName = pszDummyName; 1242 1253 if (RT_SUCCESS(vrc)) 1243 1254 { 1244 pDevOsX->USBDevice = USBDevice;1245 pDevOsX->ppDevI = ppDevI;1246 pDevOsX->pProxyDev = pProxyDev;1247 1248 1255 /* 1249 * Try seize all the interface.1256 * Create the async event source and add it to the run loop. 1250 1257 */ 1251 char *pszDummyName = pProxyDev->pUsbIns->pszName; 1252 pProxyDev->pUsbIns->pszName = (char *)pszAddress; 1253 vrc = usbProxyDarwinSeizeAllInterfaces(pDevOsX, false /* give up on failure */); 1254 pProxyDev->pUsbIns->pszName = pszDummyName; 1255 if (RT_SUCCESS(vrc)) 1258 irc = (*ppDevI)->CreateDeviceAsyncEventSource(ppDevI, &pDevOsX->RunLoopSrcRef); 1259 if (irc == kIOReturnSuccess) 1256 1260 { 1257 1261 /* 1258 * Create the async event source and add it to the run loop. 1262 * Determine the active configuration. 1263 * Can cause hangs, so drop it for now. 1259 1264 */ 1260 irc = (*ppDevI)->CreateDeviceAsyncEventSource(ppDevI, &pDevOsX->RunLoopSrcRef); 1261 if (irc == kIOReturnSuccess) 1265 /** @todo test Palm. */ 1266 //uint8_t u8Cfg; 1267 //irc = (*ppDevI)->GetConfiguration(ppDevI, &u8Cfg); 1268 if (irc != kIOReturnNoDevice) 1262 1269 { 1263 /* 1264 * Determine the active configuration. 1265 * Can cause hangs, so drop it for now. 1266 */ 1267 /** @todo test Palm. */ 1268 //uint8_t u8Cfg; 1269 //irc = (*ppDevI)->GetConfiguration(ppDevI, &u8Cfg); 1270 if (irc != kIOReturnNoDevice) 1270 CFRunLoopSourceContext CtxRunLoopSource; 1271 CtxRunLoopSource.version = 0; 1272 CtxRunLoopSource.info = NULL; 1273 CtxRunLoopSource.retain = NULL; 1274 CtxRunLoopSource.release = NULL; 1275 CtxRunLoopSource.copyDescription = NULL; 1276 CtxRunLoopSource.equal = NULL; 1277 CtxRunLoopSource.hash = NULL; 1278 CtxRunLoopSource.schedule = NULL; 1279 CtxRunLoopSource.cancel = NULL; 1280 CtxRunLoopSource.perform = usbProxyDarwinPerformWakeup; 1281 pDevOsX->hRunLoopSrcWakeRef = CFRunLoopSourceCreate(NULL, 0, &CtxRunLoopSource); 1282 if (CFRunLoopSourceIsValid(pDevOsX->hRunLoopSrcWakeRef)) 1271 1283 { 1272 CFRunLoopSourceContext CtxRunLoopSource; 1273 CtxRunLoopSource.version = 0; 1274 CtxRunLoopSource.info = NULL; 1275 CtxRunLoopSource.retain = NULL; 1276 CtxRunLoopSource.release = NULL; 1277 CtxRunLoopSource.copyDescription = NULL; 1278 CtxRunLoopSource.equal = NULL; 1279 CtxRunLoopSource.hash = NULL; 1280 CtxRunLoopSource.schedule = NULL; 1281 CtxRunLoopSource.cancel = NULL; 1282 CtxRunLoopSource.perform = usbProxyDarwinPerformWakeup; 1283 pDevOsX->hRunLoopSrcWakeRef = CFRunLoopSourceCreate(NULL, 0, &CtxRunLoopSource); 1284 if (CFRunLoopSourceIsValid(pDevOsX->hRunLoopSrcWakeRef)) 1285 { 1286 //pProxyDev->iActiveCfg = irc == kIOReturnSuccess ? u8Cfg : -1; 1287 RTListInit(&pDevOsX->HeadOfRunLoopWakeLst); 1288 pProxyDev->iActiveCfg = -1; 1289 pProxyDev->cIgnoreSetConfigs = 1; 1290 1291 pProxyDev->Backend.pv = pDevOsX; 1292 usbProxyDarwinAddRunLoopRef(&pDevOsX->HeadOfRunLoopLst, pDevOsX->RunLoopSrcRef); 1293 return VINF_SUCCESS; /* return */ 1294 } 1295 else 1296 { 1297 LogRel(("USB: Device '%s' out of memory allocating runloop source\n", pszAddress)); 1298 vrc = VERR_NO_MEMORY; 1299 } 1284 //pProxyDev->iActiveCfg = irc == kIOReturnSuccess ? u8Cfg : -1; 1285 RTListInit(&pDevOsX->HeadOfRunLoopWakeLst); 1286 pProxyDev->iActiveCfg = -1; 1287 pProxyDev->cIgnoreSetConfigs = 1; 1288 1289 pProxyDev->Backend.pv = pDevOsX; 1290 usbProxyDarwinAddRunLoopRef(&pDevOsX->HeadOfRunLoopLst, pDevOsX->RunLoopSrcRef); 1291 return VINF_SUCCESS; /* return */ 1300 1292 } 1301 vrc = VERR_VUSB_DEVICE_NOT_ATTACHED; 1293 else 1294 { 1295 LogRel(("USB: Device '%s' out of memory allocating runloop source\n", pszAddress)); 1296 vrc = VERR_NO_MEMORY; 1297 } 1302 1298 } 1303 else 1304 vrc = RTErrConvertFromDarwin(irc); 1305 1306 usbProxyDarwinReleaseAllInterfaces(pDevOsX); 1299 vrc = VERR_VUSB_DEVICE_NOT_ATTACHED; 1307 1300 } 1308 /* else: already bitched */ 1309 1310 RTCritSectDelete(&pDevOsX->CritSect); 1301 else 1302 vrc = RTErrConvertFromDarwin(irc); 1303 1304 usbProxyDarwinReleaseAllInterfaces(pDevOsX); 1311 1305 } 1312 1313 RTMemFree(pDevOsX); 1306 /* else: already bitched */ 1307 1308 RTCritSectDelete(&pDevOsX->CritSect); 1314 1309 } 1315 1310 … … 1352 1347 * Closes the proxy device. 1353 1348 */ 1354 static voidusbProxyDarwinClose(PUSBPROXYDEV pProxyDev)1349 static DECLCALLBACK(void) usbProxyDarwinClose(PUSBPROXYDEV pProxyDev) 1355 1350 { 1356 1351 LogFlow(("usbProxyDarwinClose: pProxyDev=%s\n", pProxyDev->pUsbIns->pszName)); 1357 PUSBPROXYDEVOSX pDevOsX = (PUSBPROXYDEVOSX)pProxyDev->Backend.pv; 1358 Assert(pDevOsX); 1359 if (!pDevOsX) 1360 return; 1352 PUSBPROXYDEVOSX pDevOsX = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVOSX); 1353 AssertPtrReturnVoid(pDevOsX); 1361 1354 1362 1355 /* … … 1429 1422 } 1430 1423 1431 RTMemFree(pDevOsX);1432 pProxyDev->Backend.pv = NULL;1433 1434 1424 #ifdef VBOX_WITH_NEW_USB_CODE_ON_DARWIN 1435 1425 USBLibTerm(); … … 1445 1435 * @param pDev The device to reset. 1446 1436 */ 1447 static intusbProxyDarwinReset(PUSBPROXYDEV pProxyDev, bool fResetOnLinux)1448 { 1449 PUSBPROXYDEVOSX pDevOsX = (PUSBPROXYDEVOSX)pProxyDev->Backend.pv;1437 static DECLCALLBACK(int) usbProxyDarwinReset(PUSBPROXYDEV pProxyDev, bool fResetOnLinux) 1438 { 1439 PUSBPROXYDEVOSX pDevOsX = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVOSX); 1450 1440 LogFlow(("usbProxyDarwinReset: pProxyDev=%s\n", pProxyDev->pUsbIns->pszName)); 1451 1441 … … 1483 1473 * @param iCfg The configuration to set. 1484 1474 */ 1485 static intusbProxyDarwinSetConfig(PUSBPROXYDEV pProxyDev, int iCfg)1486 { 1487 PUSBPROXYDEVOSX pDevOsX = (PUSBPROXYDEVOSX)pProxyDev->Backend.pv;1475 static DECLCALLBACK(int) usbProxyDarwinSetConfig(PUSBPROXYDEV pProxyDev, int iCfg) 1476 { 1477 PUSBPROXYDEVOSX pDevOsX = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVOSX); 1488 1478 LogFlow(("usbProxyDarwinSetConfig: pProxyDev=%s cfg=%#x\n", 1489 1479 pProxyDev->pUsbIns->pszName, iCfg)); … … 1510 1500 * @returns success indicator (always true). 1511 1501 */ 1512 static intusbProxyDarwinClaimInterface(PUSBPROXYDEV pProxyDev, int iIf)1502 static DECLCALLBACK(int) usbProxyDarwinClaimInterface(PUSBPROXYDEV pProxyDev, int iIf) 1513 1503 { 1514 1504 return true; … … 1524 1514 * @returns success indicator. 1525 1515 */ 1526 static intusbProxyDarwinReleaseInterface(PUSBPROXYDEV pProxyDev, int iIf)1516 static DECLCALLBACK(int) usbProxyDarwinReleaseInterface(PUSBPROXYDEV pProxyDev, int iIf) 1527 1517 { 1528 1518 return true; … … 1535 1525 * @returns success indicator. 1536 1526 */ 1537 static intusbProxyDarwinSetInterface(PUSBPROXYDEV pProxyDev, int iIf, int iAlt)1538 { 1539 PUSBPROXYDEVOSX pDevOsX = (PUSBPROXYDEVOSX)pProxyDev->Backend.pv;1527 static DECLCALLBACK(int) usbProxyDarwinSetInterface(PUSBPROXYDEV pProxyDev, int iIf, int iAlt) 1528 { 1529 PUSBPROXYDEVOSX pDevOsX = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVOSX); 1540 1530 IOReturn irc = kIOReturnSuccess; 1541 1531 PUSBPROXYIFOSX pIf = usbProxyDarwinGetInterface(pDevOsX, iIf); … … 1582 1572 * Clears the halted endpoint 'EndPt'. 1583 1573 */ 1584 static boolusbProxyDarwinClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int EndPt)1585 { 1586 PUSBPROXYDEVOSX pDevOsX = (PUSBPROXYDEVOSX)pProxyDev->Backend.pv;1574 static DECLCALLBACK(bool) usbProxyDarwinClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int EndPt) 1575 { 1576 PUSBPROXYDEVOSX pDevOsX = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVOSX); 1587 1577 LogFlow(("usbProxyDarwinClearHaltedEp: pProxyDev=%s EndPt=%#x\n", pProxyDev->pUsbIns->pszName, EndPt)); 1588 1578 … … 1619 1609 * @copydoc USBPROXYBACK::pfnUrbQueue 1620 1610 */ 1621 static intusbProxyDarwinUrbQueue(PVUSBURB pUrb)1611 static DECLCALLBACK(int) usbProxyDarwinUrbQueue(PVUSBURB pUrb) 1622 1612 { 1623 1613 PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pUrb->pUsbIns, PUSBPROXYDEV); 1624 PUSBPROXYDEVOSX pDevOsX = (PUSBPROXYDEVOSX)pProxyDev->Backend.pv;1614 PUSBPROXYDEVOSX pDevOsX = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVOSX); 1625 1615 LogFlow(("%s: usbProxyDarwinUrbQueue: pProxyDev=%s pUrb=%p EndPt=%d cbData=%d\n", 1626 1616 pUrb->pszDesc, pProxyDev->pUsbIns->pszName, pUrb, pUrb->EndPt, pUrb->cbData)); … … 1833 1823 * @param cMillies Number of milliseconds to wait. Use 0 to not wait at all. 1834 1824 */ 1835 static PVUSBURBusbProxyDarwinUrbReap(PUSBPROXYDEV pProxyDev, RTMSINTERVAL cMillies)1825 static DECLCALLBACK(PVUSBURB) usbProxyDarwinUrbReap(PUSBPROXYDEV pProxyDev, RTMSINTERVAL cMillies) 1836 1826 { 1837 1827 PVUSBURB pUrb = NULL; 1838 PUSBPROXYDEVOSX pDevOsX = (PUSBPROXYDEVOSX)pProxyDev->Backend.pv;1828 PUSBPROXYDEVOSX pDevOsX = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVOSX); 1839 1829 CFRunLoopRef hRunLoopRef = CFRunLoopGetCurrent(); 1840 1830 … … 1907 1897 * requests, we should probably be fine... 1908 1898 */ 1909 static voidusbProxyDarwinUrbCancel(PVUSBURB pUrb)1899 static DECLCALLBACK(void) usbProxyDarwinUrbCancel(PVUSBURB pUrb) 1910 1900 { 1911 1901 PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pUrb->pUsbIns, PUSBPROXYDEV); 1912 PUSBPROXYDEVOSX pDevOsX = (PUSBPROXYDEVOSX)pProxyDev->Backend.pv;1902 PUSBPROXYDEVOSX pDevOsX = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVOSX); 1913 1903 //PUSBPROXYURBOSX pUrbOsX = (PUSBPROXYURBOSX)pUrb->Dev.pvProxyUrb; 1914 1904 LogFlow(("%s: usbProxyDarwinUrbCancel: pProxyDev=%s EndPt=%d\n", … … 1938 1928 1939 1929 1940 static intusbProxyDarwinWakeup(PUSBPROXYDEV pProxyDev)1941 { 1942 PUSBPROXYDEVOSX pDevOsX = (PUSBPROXYDEVOSX)pProxyDev->Backend.pv;1930 static DECLCALLBACK(int) usbProxyDarwinWakeup(PUSBPROXYDEV pProxyDev) 1931 { 1932 PUSBPROXYDEVOSX pDevOsX = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVOSX); 1943 1933 1944 1934 LogFlow(("usbProxyDarwinWakeup: pProxyDev=%p\n", pProxyDev)); … … 1963 1953 extern const USBPROXYBACK g_USBProxyDeviceHost = 1964 1954 { 1955 /* pszName */ 1965 1956 "host", 1957 /* cbBackend */ 1958 sizeof(USBPROXYDEVOSX), 1966 1959 usbProxyDarwinOpen, 1967 1960 NULL, -
trunk/src/VBox/Devices/USB/freebsd/USBProxyDevice-freebsd.cpp
r44528 r50228 7 7 * Includes contributions from Hans Petter Selasky 8 8 * 9 * Copyright (C) 2006-201 2Oracle Corporation9 * Copyright (C) 2006-2014 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 128 128 { 129 129 int rc = VINF_SUCCESS; 130 PUSBPROXYDEVFBSD pDevFBSD = (PUSBPROXYDEVFBSD) pProxyDev->Backend.pv;130 PUSBPROXYDEVFBSD pDevFBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVFBSD); 131 131 132 132 LogFlow(("usbProxyFreeBSDDoIoCtl: iCmd=%#x\n", iCmd)); … … 159 159 { 160 160 struct usb_fs_init UsbFsInit; 161 PUSBPROXYDEVFBSD pDevFBSD = (PUSBPROXYDEVFBSD) pProxyDev->Backend.pv;161 PUSBPROXYDEVFBSD pDevFBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVFBSD); 162 162 int rc; 163 163 … … 190 190 { 191 191 struct usb_fs_uninit UsbFsUninit; 192 PUSBPROXYDEVFBSD pDevFBSD = (PUSBPROXYDEVFBSD) pProxyDev->Backend.pv;192 PUSBPROXYDEVFBSD pDevFBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVFBSD); 193 193 int rc; 194 194 … … 241 241 static int usbProxyFreeBSDEndpointOpen(PUSBPROXYDEV pProxyDev, int Endpoint, bool fIsoc, int index) 242 242 { 243 PUSBPROXYDEVFBSD pDevFBSD = (PUSBPROXYDEVFBSD) pProxyDev->Backend.pv;243 PUSBPROXYDEVFBSD pDevFBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVFBSD); 244 244 PUSBENDPOINTFBSD pEndpointFBSD = NULL; /* shut up gcc */ 245 245 struct usb_fs_endpoint *pXferEndpoint; … … 316 316 static int usbProxyFreeBSDEndpointClose(PUSBPROXYDEV pProxyDev, int Endpoint) 317 317 { 318 PUSBPROXYDEVFBSD pDevFBSD = (PUSBPROXYDEVFBSD) pProxyDev->Backend.pv;318 PUSBPROXYDEVFBSD pDevFBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVFBSD); 319 319 PUSBENDPOINTFBSD pEndpointFBSD = &pDevFBSD->aSwEndpoint[Endpoint]; 320 320 struct usb_fs_close UsbFsClose; … … 360 360 * @param pvBackend Backend specific pointer, unused for the linux backend. 361 361 */ 362 static int usbProxyFreeBSDOpen(PUSBPROXYDEV pProxyDev, const char *pszAddress, 363 void *pvBackend) 364 { 362 static DECLCALLBACK(int) usbProxyFreeBSDOpen(PUSBPROXYDEV pProxyDev, const char *pszAddress, 363 void *pvBackend) 364 { 365 PUSBPROXYDEVFBSD pDevFBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVFBSD); 365 366 int rc; 366 367 367 368 LogFlow(("usbProxyFreeBSDOpen: pProxyDev=%p pszAddress=%s\n", pProxyDev, pszAddress)); 369 370 NOREF(pvBackend); 368 371 369 372 /* … … 375 378 { 376 379 /* 377 * Allocate and initialize the linuxbackend data.380 * Initialize the FreeBSD backend data. 378 381 */ 379 PUSBPROXYDEVFBSD pDevFBSD = (PUSBPROXYDEVFBSD)RTMemAllocZ(sizeof(USBPROXYDEVFBSD)); 380 if (pDevFBSD) 381 { 382 pDevFBSD->hFile = hFile; 383 pProxyDev->Backend.pv = pDevFBSD; 384 385 rc = usbProxyFreeBSDFsInit(pProxyDev); 386 if (RT_SUCCESS(rc)) 387 { 388 LogFlow(("usbProxyFreeBSDOpen(%p, %s): returns successfully hFile=%RTfile iActiveCfg=%d\n", 389 pProxyDev, pszAddress, pDevFBSD->hFile, pProxyDev->iActiveCfg)); 390 391 return VINF_SUCCESS; 392 } 393 394 RTMemFree(pDevFBSD); 395 } 396 else 397 rc = VERR_NO_MEMORY; 382 pDevFBSD->hFile = hFile; 383 rc = usbProxyFreeBSDFsInit(pProxyDev); 384 if (RT_SUCCESS(rc)) 385 { 386 LogFlow(("usbProxyFreeBSDOpen(%p, %s): returns successfully hFile=%RTfile iActiveCfg=%d\n", 387 pProxyDev, pszAddress, pDevFBSD->hFile, pProxyDev->iActiveCfg)); 388 389 return VINF_SUCCESS; 390 } 398 391 399 392 RTFileClose(hFile); … … 405 398 pProxyDev, pszAddress, rc)); 406 399 407 pProxyDev->Backend.pv = NULL;408 409 NOREF(pvBackend);410 400 return rc; 411 401 } … … 419 409 * @param pProxyDev The proxy device. 420 410 */ 421 static intusbProxyFreeBSDInit(PUSBPROXYDEV pProxyDev)422 { 423 PUSBPROXYDEVFBSD pDevFBSD = (PUSBPROXYDEVFBSD) pProxyDev->Backend.pv;411 static DECLCALLBACK(int) usbProxyFreeBSDInit(PUSBPROXYDEV pProxyDev) 412 { 413 PUSBPROXYDEVFBSD pDevFBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVFBSD); 424 414 int rc; 425 415 … … 449 439 * Closes the proxy device. 450 440 */ 451 static voidusbProxyFreeBSDClose(PUSBPROXYDEV pProxyDev)452 { 453 PUSBPROXYDEVFBSD pDevFBSD = (PUSBPROXYDEVFBSD)pProxyDev->Backend.pv;441 static DECLCALLBACK(void) usbProxyFreeBSDClose(PUSBPROXYDEV pProxyDev) 442 { 443 PUSBPROXYDEVFBSD pDevFBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVFBSD); 454 444 455 445 LogFlow(("usbProxyFreeBSDClose: pProxyDev=%s\n", pProxyDev->pUsbIns->pszName)); … … 475 465 * @param pDev The device to reset. 476 466 */ 477 static intusbProxyFreeBSDReset(PUSBPROXYDEV pProxyDev, bool fResetOnFreeBSD)478 { 479 PUSBPROXYDEVFBSD pDevFBSD = (PUSBPROXYDEVFBSD) pProxyDev->Backend.pv;467 static DECLCALLBACK(int) usbProxyFreeBSDReset(PUSBPROXYDEV pProxyDev, bool fResetOnFreeBSD) 468 { 469 PUSBPROXYDEVFBSD pDevFBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVFBSD); 480 470 int iParm; 481 471 int rc = VINF_SUCCESS; … … 532 522 * @param iCfg The configuration to set. 533 523 */ 534 static intusbProxyFreeBSDSetConfig(PUSBPROXYDEV pProxyDev, int iCfg)535 { 536 PUSBPROXYDEVFBSD pDevFBSD = (PUSBPROXYDEVFBSD) pProxyDev->Backend.pv;524 static DECLCALLBACK(int) usbProxyFreeBSDSetConfig(PUSBPROXYDEV pProxyDev, int iCfg) 525 { 526 PUSBPROXYDEVFBSD pDevFBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVFBSD); 537 527 int iCfgIndex; 538 528 int rc; … … 589 579 * @returns success indicator. 590 580 */ 591 static intusbProxyFreeBSDClaimInterface(PUSBPROXYDEV pProxyDev, int iIf)581 static DECLCALLBACK(int) usbProxyFreeBSDClaimInterface(PUSBPROXYDEV pProxyDev, int iIf) 592 582 { 593 583 int rc; … … 614 604 * @returns success indicator. 615 605 */ 616 static intusbProxyFreeBSDReleaseInterface(PUSBPROXYDEV pProxyDev, int iIf)606 static DECLCALLBACK(int) usbProxyFreeBSDReleaseInterface(PUSBPROXYDEV pProxyDev, int iIf) 617 607 { 618 608 int rc; … … 633 623 * @returns success indicator. 634 624 */ 635 static int625 static DECLCALLBACK(int) 636 626 usbProxyFreeBSDSetInterface(PUSBPROXYDEV pProxyDev, int iIf, int iAlt) 637 627 { 638 PUSBPROXYDEVFBSD pDevFBSD = (PUSBPROXYDEVFBSD) pProxyDev->Backend.pv;628 PUSBPROXYDEVFBSD pDevFBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVFBSD); 639 629 struct usb_alt_interface UsbIntAlt; 640 630 int rc; … … 673 663 * Clears the halted endpoint 'ep_num'. 674 664 */ 675 static boolusbProxyFreeBSDClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int ep_num)665 static DECLCALLBACK(bool) usbProxyFreeBSDClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int ep_num) 676 666 { 677 667 struct usb_ctl_request Req; … … 707 697 * @copydoc USBPROXYBACK::pfnUrbQueue 708 698 */ 709 static intusbProxyFreeBSDUrbQueue(PVUSBURB pUrb)699 static DECLCALLBACK(int) usbProxyFreeBSDUrbQueue(PVUSBURB pUrb) 710 700 { 711 701 PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pUrb->pUsbIns, PUSBPROXYDEV); 712 PUSBPROXYDEVFBSD pDevFBSD = (PUSBPROXYDEVFBSD) pProxyDev->Backend.pv;702 PUSBPROXYDEVFBSD pDevFBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVFBSD); 713 703 PUSBENDPOINTFBSD pEndpointFBSD; 714 704 struct usb_fs_endpoint *pXferEndpoint; … … 851 841 * @param cMillies Number of milliseconds to wait. Use 0 to not wait at all. 852 842 */ 853 static PVUSBURBusbProxyFreeBSDUrbReap(PUSBPROXYDEV pProxyDev, RTMSINTERVAL cMillies)843 static DECLCALLBACK(PVUSBURB) usbProxyFreeBSDUrbReap(PUSBPROXYDEV pProxyDev, RTMSINTERVAL cMillies) 854 844 { 855 845 struct usb_fs_endpoint *pXferEndpoint; 856 PUSBPROXYDEVFBSD pDevFBSD = (PUSBPROXYDEVFBSD) pProxyDev->Backend.pv;846 PUSBPROXYDEVFBSD pDevFBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVFBSD); 857 847 PUSBENDPOINTFBSD pEndpointFBSD; 858 848 PVUSBURB pUrb; … … 1007 997 * The URB requires reaping, so we don't change its state. 1008 998 */ 1009 static voidusbProxyFreeBSDUrbCancel(PVUSBURB pUrb)999 static DECLCALLBACK(void) usbProxyFreeBSDUrbCancel(PVUSBURB pUrb) 1010 1000 { 1011 1001 PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pUrb->pUsbIns, PUSBPROXYDEV); … … 1027 1017 extern const USBPROXYBACK g_USBProxyDeviceHost = 1028 1018 { 1019 /* pszName */ 1029 1020 "host", 1021 /* cbBackend */ 1022 sizeof(PUSBPROXYDEVFBSD), 1030 1023 usbProxyFreeBSDOpen, 1031 1024 usbProxyFreeBSDInit, -
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, -
trunk/src/VBox/Devices/USB/solaris/USBProxyDevice-solaris.cpp
r49816 r50228 5 5 6 6 /* 7 * Copyright (C) 2009-201 3Oracle Corporation7 * Copyright (C) 2009-2014 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 92 92 /** The tail of the landed solaris URBs. */ 93 93 PUSBPROXYURBSOL pTaxingTail; 94 /** Pipe handle for wa iking up - writing end. */94 /** Pipe handle for waking up - writing end. */ 95 95 RTPIPE hPipeWakeupW; 96 /** Pipe handle for wa iking up - reading end. */96 /** Pipe handle for waking up - reading end. */ 97 97 RTPIPE hPipeWakeupR; 98 98 } USBPROXYDEVSOL, *PUSBPROXYDEVSOL; … … 288 288 * @param pvBackend Backend specific pointer, unused for the solaris backend. 289 289 */ 290 static int usbProxySolarisOpen(PUSBPROXYDEV pProxyDev, const char *pszAddress, void *pvBackend) 291 { 290 static DECLCALLBACK(int) usbProxySolarisOpen(PUSBPROXYDEV pProxyDev, const char *pszAddress, void *pvBackend) 291 { 292 PUSBPROXYDEVFBSD pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL); 293 292 294 LogFlowFunc((USBPROXY ":usbProxySolarisOpen pProxyDev=%p pszAddress=%s pvBackend=%p\n", pProxyDev, pszAddress, pvBackend)); 293 295 … … 301 303 * Allocate and initialize the solaris backend data. 302 304 */ 303 PUSBPROXYDEVSOL pDevSol = (PUSBPROXYDEVSOL)RTMemAllocZ(sizeof(*pDevSol)); 304 if (RT_LIKELY(pDevSol)) 305 AssertCompile(PATH_MAX >= MAXPATHLEN); 306 char szDeviceIdent[PATH_MAX+48]; 307 rc = RTStrPrintf(szDeviceIdent, sizeof(szDeviceIdent), "%s", pszAddress); 308 if (RT_SUCCESS(rc)) 305 309 { 306 AssertCompile(PATH_MAX >= MAXPATHLEN); 307 char szDeviceIdent[PATH_MAX+48]; 308 rc = RTStrPrintf(szDeviceIdent, sizeof(szDeviceIdent), "%s", pszAddress); 310 rc = RTCritSectInit(&pDevSol->CritSect); 309 311 if (RT_SUCCESS(rc)) 310 312 { 311 rc = RTCritSectInit(&pDevSol->CritSect); 313 /* 314 * Create wakeup pipe. 315 */ 316 rc = RTPipeCreate(&pDevSol->hPipeWakeupR, &pDevSol->hPipeWakeupW, 0); 312 317 if (RT_SUCCESS(rc)) 313 318 { 314 pProxyDev->Backend.pv = pDevSol; 315 316 /* 317 * Create wakeup pipe. 318 */ 319 rc = RTPipeCreate(&pDevSol->hPipeWakeupR, &pDevSol->hPipeWakeupW, 0); 319 int Instance; 320 char *pszDevicePath = NULL; 321 rc = USBLibGetClientInfo(szDeviceIdent, &pszDevicePath, &Instance); 320 322 if (RT_SUCCESS(rc)) 321 323 { 322 int Instance; 323 char *pszDevicePath = NULL; 324 rc = USBLibGetClientInfo(szDeviceIdent, &pszDevicePath, &Instance); 324 pDevSol->pszDevicePath = pszDevicePath; 325 326 /* 327 * Open the client driver. 328 */ 329 RTFILE hFile; 330 rc = RTFileOpen(&hFile, pDevSol->pszDevicePath, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE); 325 331 if (RT_SUCCESS(rc)) 326 332 { 327 pDevSol->pszDevicePath = pszDevicePath; 333 pDevSol->hFile = hFile; 334 pDevSol->pProxyDev = pProxyDev; 328 335 329 336 /* 330 * Open the client driver.337 * Verify client driver version. 331 338 */ 332 RTFILE hFile; 333 rc = RTFileOpen(&hFile, pDevSol->pszDevicePath, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE); 339 VBOXUSBREQ_GET_VERSION GetVersionReq; 340 bzero(&GetVersionReq, sizeof(GetVersionReq)); 341 rc = usbProxySolarisIOCtl(pDevSol, VBOXUSB_IOCTL_GET_VERSION, &GetVersionReq, sizeof(GetVersionReq)); 334 342 if (RT_SUCCESS(rc)) 335 343 { 336 pDevSol->hFile = hFile; 337 pDevSol->pProxyDev = pProxyDev; 338 339 /* 340 * Verify client driver version. 341 */ 342 VBOXUSBREQ_GET_VERSION GetVersionReq; 343 bzero(&GetVersionReq, sizeof(GetVersionReq)); 344 rc = usbProxySolarisIOCtl(pDevSol, VBOXUSB_IOCTL_GET_VERSION, &GetVersionReq, sizeof(GetVersionReq)); 345 if (RT_SUCCESS(rc)) 344 if ( GetVersionReq.u32Major == VBOXUSB_VERSION_MAJOR 345 && GetVersionReq.u32Minor >= VBOXUSB_VERSION_MINOR) 346 346 { 347 if ( GetVersionReq.u32Major == VBOXUSB_VERSION_MAJOR 348 && GetVersionReq.u32Minor >= VBOXUSB_VERSION_MINOR) 349 { 350 /* 351 * Try & get the current cached config from Solaris. 352 */ 353 usbProxySolarisGetActiveConfig(pDevSol); 354 return VINF_SUCCESS; 355 } 356 else 357 { 358 LogRel((USBPROXY ":version mismatch! driver v%d.%d expecting ~v%d.%d\n", GetVersionReq.u32Major, 359 GetVersionReq.u32Minor, VBOXUSB_VERSION_MAJOR, VBOXUSB_VERSION_MINOR)); 360 rc = VERR_VERSION_MISMATCH; 361 } 347 /* 348 * Try & get the current cached config from Solaris. 349 */ 350 usbProxySolarisGetActiveConfig(pDevSol); 351 return VINF_SUCCESS; 362 352 } 363 353 else 364 354 { 365 LogRel((USBPROXY ":failed to query driver version. rc=%Rrc\n", rc)); 355 LogRel((USBPROXY ":version mismatch! driver v%d.%d expecting ~v%d.%d\n", GetVersionReq.u32Major, 356 GetVersionReq.u32Minor, VBOXUSB_VERSION_MAJOR, VBOXUSB_VERSION_MINOR)); 357 rc = VERR_VERSION_MISMATCH; 366 358 } 367 368 RTFileClose(pDevSol->hFile);369 pDevSol->hFile = NIL_RTFILE;370 pDevSol->pProxyDev = NULL;371 359 } 372 360 else 373 LogRel((USBPROXY ":failed to open device. rc=%Rrc pszDevicePath=%s\n", rc, pDevSol->pszDevicePath)); 374 375 RTStrFree(pDevSol->pszDevicePath); 376 pDevSol->pszDevicePath = NULL; 361 LogRel((USBPROXY ":failed to query driver version. rc=%Rrc\n", rc)); 362 363 RTFileClose(pDevSol->hFile); 364 pDevSol->hFile = NIL_RTFILE; 365 pDevSol->pProxyDev = NULL; 377 366 } 378 367 else 379 { 380 LogRel((USBPROXY ":failed to get client info. rc=%Rrc pszDevicePath=%s\n", rc, pDevSol->pszDevicePath)); 381 if (rc == VERR_NOT_FOUND) 382 rc = VERR_OPEN_FAILED; 383 } 384 RTPipeClose(pDevSol->hPipeWakeupR); 385 RTPipeClose(pDevSol->hPipeWakeupW); 368 LogRel((USBPROXY ":failed to open device. rc=%Rrc pszDevicePath=%s\n", rc, pDevSol->pszDevicePath)); 369 370 RTStrFree(pDevSol->pszDevicePath); 371 pDevSol->pszDevicePath = NULL; 386 372 } 387 388 RTCritSectDelete(&pDevSol->CritSect); 373 else 374 { 375 LogRel((USBPROXY ":failed to get client info. rc=%Rrc pszDevicePath=%s\n", rc, pDevSol->pszDevicePath)); 376 if (rc == VERR_NOT_FOUND) 377 rc = VERR_OPEN_FAILED; 378 } 379 RTPipeClose(pDevSol->hPipeWakeupR); 380 RTPipeClose(pDevSol->hPipeWakeupW); 389 381 } 390 else 391 LogRel((USBPROXY ":RTCritSectInit failed. rc=%Rrc pszAddress=%s\n", rc, pszAddress));382 383 RTCritSectDelete(&pDevSol->CritSect); 392 384 } 393 385 else 394 LogRel((USBPROXY ":RTStrAPrintf failed. rc=%Rrc pszAddress=%s\n", rc, pszAddress)); 395 396 RTMemFree(pDevSol); 397 pDevSol = NULL; 386 LogRel((USBPROXY ":RTCritSectInit failed. rc=%Rrc pszAddress=%s\n", rc, pszAddress)); 398 387 } 399 388 else 400 rc = VERR_NO_MEMORY;389 LogRel((USBPROXY ":RTStrAPrintf failed. rc=%Rrc pszAddress=%s\n", rc, pszAddress)); 401 390 } 402 391 else … … 404 393 405 394 USBLibTerm(); 406 pProxyDev->Backend.pv = NULL;407 395 return rc; 408 396 } … … 414 402 * @param pProxyDev The device instance. 415 403 */ 416 static voidusbProxySolarisClose(PUSBPROXYDEV pProxyDev)404 static DECLCALLBACK(void) usbProxySolarisClose(PUSBPROXYDEV pProxyDev) 417 405 { 418 406 LogFlow((USBPROXY ":usbProxySolarisClose: pProxyDev=%p\n", pProxyDev)); 419 407 420 PUSBPROXYDEV SOL pDevSol = (PUSBPROXYDEVSOL)pProxyDev->Backend.pv;408 PUSBPROXYDEVFBSD pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL); 421 409 422 410 /* Close the device (do not re-enumerate). */ … … 452 440 pDevSol->pszDevicePath = NULL; 453 441 454 RTMemFree(pDevSol);455 pProxyDev->Backend.pv = NULL;456 457 442 USBLibTerm(); 458 443 } … … 466 451 * @param fRootHubReset Is this a root hub reset or device specific reset request. 467 452 */ 468 static intusbProxySolarisReset(PUSBPROXYDEV pProxyDev, bool fRootHubReset)453 static DECLCALLBACK(int) usbProxySolarisReset(PUSBPROXYDEV pProxyDev, bool fRootHubReset) 469 454 { 470 455 LogFlowFunc((USBPROXY ":usbProxySolarisReset pProxyDev=%s fRootHubReset=%d\n", pProxyDev->pUsbIns->pszName, fRootHubReset)); 471 456 472 457 /** Pass all resets to the device. The Trekstor USB (1.1) stick requires this to work. */ 473 PUSBPROXYDEV SOL pDevSol = (PUSBPROXYDEVSOL)pProxyDev->Backend.pv;458 PUSBPROXYDEVFBSD pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL); 474 459 475 460 /* Soft reset the device. */ … … 499 484 * @param iCfg The configuration value to set. 500 485 */ 501 static intusbProxySolarisSetConfig(PUSBPROXYDEV pProxyDev, int iCfg)486 static DECLCALLBACK(int) usbProxySolarisSetConfig(PUSBPROXYDEV pProxyDev, int iCfg) 502 487 { 503 488 LogFlowFunc((USBPROXY ":usbProxySolarisSetConfig: pProxyDev=%p iCfg=%#x\n", pProxyDev, iCfg)); 504 489 505 PUSBPROXYDEV SOL pDevSol = (PUSBPROXYDEVSOL)pProxyDev->Backend.pv;490 PUSBPROXYDEVFBSD pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL); 506 491 AssertPtrReturn(pDevSol, VERR_INVALID_POINTER); 507 492 … … 527 512 * @returns success indicator (always true). 528 513 */ 529 static intusbProxySolarisClaimInterface(PUSBPROXYDEV pProxyDev, int iIf)514 static DECLCALLBACK(int) usbProxySolarisClaimInterface(PUSBPROXYDEV pProxyDev, int iIf) 530 515 { 531 516 return true; … … 541 526 * @returns success indicator. 542 527 */ 543 static intusbProxySolarisReleaseInterface(PUSBPROXYDEV pProxyDev, int iIf)528 static DECLCALLBACK(int) usbProxySolarisReleaseInterface(PUSBPROXYDEV pProxyDev, int iIf) 544 529 { 545 530 return true; … … 552 537 * @returns success indicator. 553 538 */ 554 static intusbProxySolarisSetInterface(PUSBPROXYDEV pProxyDev, int iIf, int iAlt)539 static DECLCALLBACK(int) usbProxySolarisSetInterface(PUSBPROXYDEV pProxyDev, int iIf, int iAlt) 555 540 { 556 541 LogFlowFunc((USBPROXY ":usbProxySolarisSetInterface: pProxyDev=%p iIf=%d iAlt=%d\n", pProxyDev, iIf, iAlt)); 557 542 558 PUSBPROXYDEV SOL pDevSol = (PUSBPROXYDEVSOL)pProxyDev->Backend.pv;543 PUSBPROXYDEVFBSD pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL); 559 544 AssertPtrReturn(pDevSol, VERR_INVALID_POINTER); 560 545 … … 576 561 * Clears the halted endpoint 'EndPt'. 577 562 */ 578 static boolusbProxySolarisClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int EndPt)563 static DECLCALLBACK(bool) usbProxySolarisClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int EndPt) 579 564 { 580 565 LogFlowFunc((USBPROXY ":usbProxySolarisClearHaltedEp pProxyDev=%p EndPt=%#x\n", pProxyDev, EndPt)); 581 566 582 PUSBPROXYDEV SOL pDevSol = (PUSBPROXYDEVSOL)pProxyDev->Backend.pv;567 PUSBPROXYDEVFBSD pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL); 583 568 AssertPtrReturn(pDevSol, VERR_INVALID_POINTER); 584 569 … … 599 584 * @copydoc USBPROXYBACK::pfnUrbQueue 600 585 */ 601 static intusbProxySolarisUrbQueue(PVUSBURB pUrb)586 static DECLCALLBACK(int) usbProxySolarisUrbQueue(PVUSBURB pUrb) 602 587 { 603 588 PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pUrb->pUsbIns, PUSBPROXYDEV); 604 PUSBPROXYDEV SOL pDevSol = (PUSBPROXYDEVSOL)pProxyDev->Backend.pv;589 PUSBPROXYDEVFBSD pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL); 605 590 606 591 LogFlowFunc((USBPROXY ": usbProxySolarisUrbQueue: pProxyDev=%s pUrb=%p EndPt=%#x enmDir=%d cbData=%d pvData=%p\n", … … 665 650 * on Solaris. So we just abort pending URBs on the pipe. 666 651 */ 667 static voidusbProxySolarisUrbCancel(PVUSBURB pUrb)652 static DECLCALLBACK(void) usbProxySolarisUrbCancel(PVUSBURB pUrb) 668 653 { 669 654 PUSBPROXYURBSOL pUrbSol = (PUSBPROXYURBSOL)pUrb->Dev.pvPrivate; 670 655 671 656 PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pUrb->pUsbIns, PUSBPROXYDEV); 672 PUSBPROXYDEV SOL pDevSol = (PUSBPROXYDEVSOL)pProxyDev->Backend.pv;657 PUSBPROXYDEVFBSD pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL); 673 658 AssertPtrReturnVoid(pDevSol); 674 659 … … 701 686 * @param cMillies Number of milliseconds to wait. Use 0 to not wait at all. 702 687 */ 703 static PVUSBURBusbProxySolarisUrbReap(PUSBPROXYDEV pProxyDev, RTMSINTERVAL cMillies)688 static DECLCALLBACK(PVUSBURB) usbProxySolarisUrbReap(PUSBPROXYDEV pProxyDev, RTMSINTERVAL cMillies) 704 689 { 705 690 //LogFlowFunc((USBPROXY ":usbProxySolarisUrbReap pProxyDev=%p cMillies=%u\n", pProxyDev, cMillies)); 706 691 707 PUSBPROXYDEV SOL pDevSol = (PUSBPROXYDEVSOL)pProxyDev->Backend.pv;692 PUSBPROXYDEVFBSD pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL); 708 693 709 694 /* … … 805 790 * @param pDevSol The Solaris device instance. 806 791 */ 807 PVUSBURB usbProxySolarisUrbComplete(PUSBPROXYDEVSOL pDevSol)792 static PVUSBURB usbProxySolarisUrbComplete(PUSBPROXYDEVSOL pDevSol) 808 793 { 809 794 LogFlowFunc((USBPROXY ":usbProxySolarisUrbComplete pDevSol=%p\n", pDevSol)); … … 895 880 static DECLCALLBACK(int) usbProxySolarisWakeup(PUSBPROXYDEV pProxyDev) 896 881 { 897 PUSBPROXYDEV SOL pDevSol = (PUSBPROXYDEVSOL)pProxyDev->Backend.pv;882 PUSBPROXYDEVFBSD pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL); 898 883 size_t cbIgnored; 899 884 … … 909 894 extern const USBPROXYBACK g_USBProxyDeviceHost = 910 895 { 896 /* pszName */ 911 897 "host", 898 /* cbBackend */ 899 sizeof(USBPROXYDEVSOL), 912 900 usbProxySolarisOpen, 913 901 NULL, -
trunk/src/VBox/Devices/USB/vrdp/USBProxyDevice-vrdp.cpp
r49814 r50228 5 5 6 6 /* 7 * Copyright (C) 2006-201 0Oracle Corporation7 * Copyright (C) 2006-2014 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 43 43 */ 44 44 45 static intusbProxyVrdpOpen(PUSBPROXYDEV pProxyDev, const char *pszAddress, void *pvBackend)45 static DECLCALLBACK(int) usbProxyVrdpOpen(PUSBPROXYDEV pProxyDev, const char *pszAddress, void *pvBackend) 46 46 { 47 47 LogFlow(("usbProxyVrdpOpen: pProxyDev=%p pszAddress=%s, pvBackend=%p\n", pProxyDev, pszAddress, pvBackend)); 48 48 49 PUSBPROXYDEVVRDP pDevVrdp = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVVRDP); 49 50 int rc = VINF_SUCCESS; 50 51 … … 58 59 if (RT_SUCCESS (rc)) 59 60 { 60 PUSBPROXYDEVVRDP pDevVrdp = (PUSBPROXYDEVVRDP)RTMemAlloc (sizeof(*pDevVrdp)); 61 if (pDevVrdp) 62 { 63 pDevVrdp->pCallback = pCallback; 64 pDevVrdp->pDevice = pDevice; 65 pProxyDev->Backend.pv = pDevVrdp; 66 pProxyDev->iActiveCfg = 1; /** @todo that may not be always true. */ 67 pProxyDev->cIgnoreSetConfigs = 1; 68 return VINF_SUCCESS; 69 } 70 71 pCallback->pfnClose (pDevice); 72 rc = VERR_NO_MEMORY; 61 pDevVrdp->pCallback = pCallback; 62 pDevVrdp->pDevice = pDevice; 63 pProxyDev->iActiveCfg = 1; /** @todo that may not be always true. */ 64 pProxyDev->cIgnoreSetConfigs = 1; 65 return VINF_SUCCESS; 73 66 } 74 67 } … … 82 75 } 83 76 84 static voidusbProxyVrdpClose(PUSBPROXYDEV pProxyDev)77 static DECLCALLBACK(void) usbProxyVrdpClose(PUSBPROXYDEV pProxyDev) 85 78 { 86 79 LogFlow(("usbProxyVrdpClose: pProxyDev = %p\n", pProxyDev)); 87 80 88 PUSBPROXYDEVVRDP pDevVrdp = (PUSBPROXYDEVVRDP)pProxyDev->Backend.pv;81 PUSBPROXYDEVVRDP pDevVrdp = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVVRDP); 89 82 90 83 pDevVrdp->pCallback->pfnClose (pDevVrdp->pDevice); 91 84 } 92 85 93 static intusbProxyVrdpReset(PUSBPROXYDEV pProxyDev, bool fResetOnLinux)86 static DECLCALLBACK(int) usbProxyVrdpReset(PUSBPROXYDEV pProxyDev, bool fResetOnLinux) 94 87 { 95 88 LogFlow(("usbProxyVrdpReset: pProxyDev = %p\n", pProxyDev)); 96 89 97 PUSBPROXYDEVVRDP pDevVrdp = (PUSBPROXYDEVVRDP)pProxyDev->Backend.pv;90 PUSBPROXYDEVVRDP pDevVrdp = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVVRDP); 98 91 99 92 int rc = pDevVrdp->pCallback->pfnReset (pDevVrdp->pDevice); … … 111 104 } 112 105 113 static intusbProxyVrdpSetConfig(PUSBPROXYDEV pProxyDev, int cfg)106 static DECLCALLBACK(int) usbProxyVrdpSetConfig(PUSBPROXYDEV pProxyDev, int cfg) 114 107 { 115 108 LogFlow(("usbProxyVrdpSetConfig: pProxyDev=%s cfg=%#x\n", pProxyDev->pUsbIns->pszName, cfg)); 116 109 117 PUSBPROXYDEVVRDP pDevVrdp = (PUSBPROXYDEVVRDP)pProxyDev->Backend.pv;110 PUSBPROXYDEVVRDP pDevVrdp = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVVRDP); 118 111 119 112 int rc = pDevVrdp->pCallback->pfnSetConfig (pDevVrdp->pDevice, (uint8_t)cfg); … … 128 121 } 129 122 130 static intusbProxyVrdpClaimInterface(PUSBPROXYDEV pProxyDev, int ifnum)123 static DECLCALLBACK(int) usbProxyVrdpClaimInterface(PUSBPROXYDEV pProxyDev, int ifnum) 131 124 { 132 125 LogFlow(("usbProxyVrdpClaimInterface: pProxyDev=%s ifnum=%#x\n", pProxyDev->pUsbIns->pszName, ifnum)); 133 126 134 PUSBPROXYDEVVRDP pDevVrdp = (PUSBPROXYDEVVRDP)pProxyDev->Backend.pv;127 PUSBPROXYDEVVRDP pDevVrdp = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVVRDP); 135 128 136 129 int rc = pDevVrdp->pCallback->pfnClaimInterface (pDevVrdp->pDevice, (uint8_t)ifnum); … … 145 138 } 146 139 147 static intusbProxyVrdpReleaseInterface(PUSBPROXYDEV pProxyDev, int ifnum)140 static DECLCALLBACK(int) usbProxyVrdpReleaseInterface(PUSBPROXYDEV pProxyDev, int ifnum) 148 141 { 149 142 LogFlow(("usbProxyVrdpReleaseInterface: pProxyDev=%s ifnum=%#x\n", pProxyDev->pUsbIns->pszName, ifnum)); 150 143 151 PUSBPROXYDEVVRDP pDevVrdp = (PUSBPROXYDEVVRDP)pProxyDev->Backend.pv;144 PUSBPROXYDEVVRDP pDevVrdp = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVVRDP); 152 145 153 146 int rc = pDevVrdp->pCallback->pfnReleaseInterface (pDevVrdp->pDevice, (uint8_t)ifnum); … … 162 155 } 163 156 164 static intusbProxyVrdpSetInterface(PUSBPROXYDEV pProxyDev, int ifnum, int setting)157 static DECLCALLBACK(int) usbProxyVrdpSetInterface(PUSBPROXYDEV pProxyDev, int ifnum, int setting) 165 158 { 166 159 LogFlow(("usbProxyVrdpSetInterface: pProxyDev=%p ifnum=%#x setting=%#x\n", pProxyDev, ifnum, setting)); 167 160 168 PUSBPROXYDEVVRDP pDevVrdp = (PUSBPROXYDEVVRDP)pProxyDev->Backend.pv;161 PUSBPROXYDEVVRDP pDevVrdp = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVVRDP); 169 162 170 163 int rc = pDevVrdp->pCallback->pfnInterfaceSetting (pDevVrdp->pDevice, (uint8_t)ifnum, (uint8_t)setting); … … 179 172 } 180 173 181 static boolusbProxyVrdpClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int ep)174 static DECLCALLBACK(bool) usbProxyVrdpClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int ep) 182 175 { 183 176 LogFlow(("usbProxyVrdpClearHaltedEp: pProxyDev=%s ep=%u\n", pProxyDev->pUsbIns->pszName, ep)); 184 177 185 PUSBPROXYDEVVRDP pDevVrdp = (PUSBPROXYDEVVRDP)pProxyDev->Backend.pv;178 PUSBPROXYDEVVRDP pDevVrdp = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVVRDP); 186 179 187 180 int rc = pDevVrdp->pCallback->pfnClearHaltedEP (pDevVrdp->pDevice, (uint8_t)ep); … … 196 189 } 197 190 198 static intusbProxyVrdpUrbQueue(PVUSBURB pUrb)191 static DECLCALLBACK(int) usbProxyVrdpUrbQueue(PVUSBURB pUrb) 199 192 { 200 193 LogFlow(("usbProxyVrdpUrbQueue: pUrb=%p\n", pUrb)); … … 208 201 209 202 PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pUrb->pUsbIns, PUSBPROXYDEV); 210 PUSBPROXYDEVVRDP pDevVrdp = (PUSBPROXYDEVVRDP)pProxyDev->Backend.pv;203 PUSBPROXYDEVVRDP pDevVrdp = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVVRDP); 211 204 212 205 int rc = pDevVrdp->pCallback->pfnQueueURB (pDevVrdp->pDevice, pUrb->enmType, pUrb->EndPt, pUrb->enmDir, pUrb->cbData, … … 222 215 } 223 216 224 static PVUSBURBusbProxyVrdpUrbReap(PUSBPROXYDEV pProxyDev, RTMSINTERVAL cMillies)217 static DECLCALLBACK(PVUSBURB) usbProxyVrdpUrbReap(PUSBPROXYDEV pProxyDev, RTMSINTERVAL cMillies) 225 218 { 226 219 LogFlow(("usbProxyVrdpUrbReap: pProxyDev=%s\n", pProxyDev->pUsbIns->pszName)); 227 220 228 PUSBPROXYDEVVRDP pDevVrdp = (PUSBPROXYDEVVRDP)pProxyDev->Backend.pv;221 PUSBPROXYDEVVRDP pDevVrdp = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVVRDP); 229 222 230 223 PVUSBURB pUrb = NULL; … … 252 245 } 253 246 254 static voidusbProxyVrdpUrbCancel(PVUSBURB pUrb)247 static DECLCALLBACK(void) usbProxyVrdpUrbCancel(PVUSBURB pUrb) 255 248 { 256 249 LogFlow(("usbProxyVrdpUrbCancel: pUrb=%p\n", pUrb)); 257 250 258 251 PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pUrb->pUsbIns, PUSBPROXYDEV); 259 PUSBPROXYDEVVRDP pDevVrdp = (PUSBPROXYDEVVRDP)pProxyDev->Backend.pv;252 PUSBPROXYDEVVRDP pDevVrdp = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVVRDP); 260 253 261 254 pDevVrdp->pCallback->pfnCancelURB (pDevVrdp->pDevice, (PREMOTEUSBQURB)pUrb->Dev.pvPrivate); 262 255 } 263 256 264 static intusbProxyVrdpWakeup(PUSBPROXYDEV pProxyDev)257 static DECLCALLBACK(int) usbProxyVrdpWakeup(PUSBPROXYDEV pProxyDev) 265 258 { 266 259 LogFlow(("usbProxyVrdpWakeup: pProxyDev=%s\n", pProxyDev->pUsbIns->pszName)); 267 260 268 PUSBPROXYDEVVRDP pDevVrdp = (PUSBPROXYDEVVRDP)pProxyDev->Backend.pv;261 PUSBPROXYDEVVRDP pDevVrdp = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVVRDP); 269 262 270 263 return pDevVrdp->pCallback->pfnWakeup (pDevVrdp->pDevice); … … 276 269 extern const USBPROXYBACK g_USBProxyDeviceVRDP = 277 270 { 271 /* pszName */ 278 272 "vrdp", 273 /* cbBackend */ 274 sizeof(USBPROXYDEVVRDP), 279 275 usbProxyVrdpOpen, 280 276 NULL, -
trunk/src/VBox/Devices/USB/win/USBProxyDevice-win.cpp
r49814 r50228 9 9 10 10 /* 11 * Copyright (C) 2006-201 1Oracle Corporation11 * Copyright (C) 2006-2014 Oracle Corporation 12 12 * 13 13 * This file is part of VirtualBox Open Source Edition (OSE), as … … 90 90 * @returns VBox status code. 91 91 */ 92 static int usbProxyWinOpen(PUSBPROXYDEV pProxyDev, const char *pszAddress, void *pvBackend) 93 { 94 /* Here you just need to use pProxyDev->priv to store whatever per-device 95 * data is needed 96 */ 97 /* 98 * Allocate private device instance data and use USBPROXYDEV::Backend::pv to point to it. 99 */ 100 PPRIV_USBW32 pPriv = (PPRIV_USBW32)RTMemAllocZ(sizeof(PRIV_USBW32)); 101 if (!pPriv) 102 return VERR_NO_MEMORY; 103 pProxyDev->Backend.pv = pPriv; 92 static DECLCALLBACK(int) usbProxyWinOpen(PUSBPROXYDEV pProxyDev, const char *pszAddress, void *pvBackend) 93 { 94 PPRIV_USBW32 pPriv = USBPROXYDEV_2_DATA(pProxyDev, PPRIV_USBW32); 104 95 105 96 int rc = VINF_SUCCESS; … … 192 183 RTMemFree(pPriv->paQueuedUrbs); 193 184 RTMemFree(pPriv->paHandles); 194 RTMemFree(pPriv);195 pProxyDev->Backend.pv = NULL;196 185 return rc; 197 186 } … … 200 189 * Copy the device and free resources associated with the backend. 201 190 */ 202 static voidusbProxyWinClose(PUSBPROXYDEV pProxyDev)191 static DECLCALLBACK(void) usbProxyWinClose(PUSBPROXYDEV pProxyDev) 203 192 { 204 193 /* Here we just close the device and free up p->priv … … 206 195 * that will have been done already 207 196 */ 208 PPRIV_USBW32 pPriv = (PPRIV_USBW32)pProxyDev->Backend.pv;197 PPRIV_USBW32 pPriv = USBPROXYDEV_2_DATA(pProxyDev, PPRIV_USBW32); 209 198 Assert(pPriv); 210 199 if (!pPriv) … … 233 222 RTMemFree(pPriv->paQueuedUrbs); 234 223 RTMemFree(pPriv->paHandles); 235 RTMemFree(pPriv); 236 pProxyDev->Backend.pv = NULL; 237 } 238 239 240 static int usbProxyWinReset(PUSBPROXYDEV pProxyDev, bool fResetOnLinux) 241 { 242 PPRIV_USBW32 pPriv = (PPRIV_USBW32)pProxyDev->Backend.pv; 224 } 225 226 227 static DECLCALLBACK(int) usbProxyWinReset(PUSBPROXYDEV pProxyDev, bool fResetOnLinux) 228 { 229 PPRIV_USBW32 pPriv = USBPROXYDEV_2_DATA(pProxyDev, PPRIV_USBW32); 243 230 DWORD cbReturned; 244 231 int rc; … … 271 258 } 272 259 273 static intusbProxyWinSetConfig(PUSBPROXYDEV pProxyDev, int cfg)260 static DECLCALLBACK(int) usbProxyWinSetConfig(PUSBPROXYDEV pProxyDev, int cfg) 274 261 { 275 262 /* Send a SET_CONFIGURATION command to the device. We don't do this … … 280 267 * point but it has to be synchronous. 281 268 */ 282 PPRIV_USBW32 pPriv = (PPRIV_USBW32)pProxyDev->Backend.pv;269 PPRIV_USBW32 pPriv = USBPROXYDEV_2_DATA(pProxyDev, PPRIV_USBW32); 283 270 USBSUP_SET_CONFIG in; 284 271 DWORD cbReturned; … … 306 293 } 307 294 308 static intusbProxyWinClaimInterface(PUSBPROXYDEV p, int ifnum)295 static DECLCALLBACK(int) usbProxyWinClaimInterface(PUSBPROXYDEV p, int ifnum) 309 296 { 310 297 /* Called just before we use an interface. Needed on Linux to claim … … 313 300 * Not relevant for Windows. 314 301 */ 315 PPRIV_USBW32 pPriv = (PPRIV_USBW32)p->Backend.pv;302 PPRIV_USBW32 pPriv = USBPROXYDEV_2_DATA(pProxyDev, PPRIV_USBW32); 316 303 317 304 pPriv->bInterfaceNumber = ifnum; … … 321 308 } 322 309 323 static intusbProxyWinReleaseInterface(PUSBPROXYDEV p, int ifnum)310 static DECLCALLBACK(int) usbProxyWinReleaseInterface(PUSBPROXYDEV p, int ifnum) 324 311 { 325 312 /* The opposite of claim_interface. */ 326 PPRIV_USBW32 pPriv = (PPRIV_USBW32)p->Backend.pv;313 PPRIV_USBW32 pPriv = USBPROXYDEV_2_DATA(pProxyDev, PPRIV_USBW32); 327 314 328 315 Assert(pPriv); … … 330 317 } 331 318 332 static intusbProxyWinSetInterface(PUSBPROXYDEV pProxyDev, int ifnum, int setting)319 static DECLCALLBACK(int) usbProxyWinSetInterface(PUSBPROXYDEV pProxyDev, int ifnum, int setting) 333 320 { 334 321 /* Select an alternate setting for an interface, the same applies … … 336 323 * message if you want but it must be synchronous 337 324 */ 338 PPRIV_USBW32 pPriv = (PPRIV_USBW32)pProxyDev->Backend.pv;325 PPRIV_USBW32 pPriv = USBPROXYDEV_2_DATA(pProxyDev, PPRIV_USBW32); 339 326 USBSUP_SELECT_INTERFACE in; 340 327 DWORD cbReturned; … … 365 352 * Clears the halted endpoint 'ep'. 366 353 */ 367 static boolusbProxyWinClearHaltedEndPt(PUSBPROXYDEV pProxyDev, unsigned int ep)368 { 369 PPRIV_USBW32 pPriv = (PPRIV_USBW32)pProxyDev->Backend.pv;354 static DECLCALLBACK(bool) usbProxyWinClearHaltedEndPt(PUSBPROXYDEV pProxyDev, unsigned int ep) 355 { 356 PPRIV_USBW32 pPriv = USBPROXYDEV_2_DATA(pProxyDev, PPRIV_USBW32); 370 357 USBSUP_CLEAR_ENDPOINT in; 371 358 DWORD cbReturned; … … 396 383 static int usbProxyWinAbortEndPt(PUSBPROXYDEV pProxyDev, unsigned int ep) 397 384 { 398 PPRIV_USBW32 pPriv = (PPRIV_USBW32)pProxyDev->Backend.pv;385 PPRIV_USBW32 pPriv = USBPROXYDEV_2_DATA(pProxyDev, PPRIV_USBW32); 399 386 USBSUP_CLEAR_ENDPOINT in; 400 387 DWORD cbReturned; … … 425 412 * @copydoc USBPROXYBACK::pfnUrbQueue 426 413 */ 427 static intusbProxyWinUrbQueue(PVUSBURB pUrb)414 static DECLCALLBACK(int) usbProxyWinUrbQueue(PVUSBURB pUrb) 428 415 { 429 416 PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pUrb->pUsbIns, PUSBPROXYDEV); 430 PPRIV_USBW32 pPriv = (PPRIV_USBW32)pProxyDev->Backend.pv;417 PPRIV_USBW32 pPriv = USBPROXYDEV_2_DATA(pProxyDev, PPRIV_USBW32); 431 418 Assert(pPriv); 432 419 … … 571 558 * wait at all. 572 559 */ 573 static PVUSBURBusbProxyWinUrbReap(PUSBPROXYDEV pProxyDev, RTMSINTERVAL cMillies)574 { 575 PPRIV_USBW32 pPriv = (PPRIV_USBW32)pProxyDev->Backend.pv;560 static DECLCALLBACK(PVUSBURB) usbProxyWinUrbReap(PUSBPROXYDEV pProxyDev, RTMSINTERVAL cMillies) 561 { 562 PPRIV_USBW32 pPriv = USBPROXYDEV_2_DATA(pProxyDev, PPRIV_USBW32); 576 563 AssertReturn(pPriv, NULL); 577 564 … … 732 719 * exactly what the guest wants to do. 733 720 */ 734 static voidusbProxyWinUrbCancel(PVUSBURB pUrb)721 static DECLCALLBACK(void) usbProxyWinUrbCancel(PVUSBURB pUrb) 735 722 { 736 723 PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pUrb->pUsbIns, PUSBPROXYDEV); 737 PPRIV_USBW32 pPriv = (PPRIV_USBW32)pProxyDev->Backend.pv;724 PPRIV_USBW32 pPriv = USBPROXYDEV_2_DATA(pProxyDev, PPRIV_USBW32); 738 725 PQUEUED_URB pQUrbWin = (PQUEUED_URB)pUrb->Dev.pvPrivate; 739 726 int rc; … … 760 747 } 761 748 762 static intusbProxyWinWakeup(PUSBPROXYDEV pProxyDev)763 { 764 PPRIV_USBW32 pPriv = (PPRIV_USBW32)pProxyDev->Backend.pv;749 static DECLCALLBACK(int) usbProxyWinWakeup(PUSBPROXYDEV pProxyDev) 750 { 751 PPRIV_USBW32 pPriv = USBPROXYDEV_2_DATA(pProxyDev, PPRIV_USBW32); 765 752 766 753 SetEvent(pPriv->hEventWakeup); … … 773 760 extern const USBPROXYBACK g_USBProxyDeviceHost = 774 761 { 762 /* pszName */ 775 763 "host", 764 /* cbBackend */ 765 sizeof(PRIV_USBW32), 776 766 usbProxyWinOpen, 777 767 NULL,
Note:
See TracChangeset
for help on using the changeset viewer.