Lines Matching defs:pDevOsX
124 struct USBPROXYDEVOSX *pDevOsX;
295 * @param pDevOsX The darwin device instance data.
297 static void usbProxyDarwinReaperKick(PUSBPROXYDEVOSX pDevOsX)
299 CFRunLoopRef hRunLoopWake = (CFRunLoopRef)ASMAtomicReadPtr((void * volatile *)&pDevOsX->hRunLoopReaping);
303 CFRunLoopSourceSignal(pDevOsX->hRunLoopSrcWakeRef);
374 * @param pDevOsX The darwin proxy device.
376 static PUSBPROXYURBOSX usbProxyDarwinUrbAlloc(PUSBPROXYDEVOSX pDevOsX)
380 RTCritSectEnter(&pDevOsX->CritSect);
385 pUrbOsX = pDevOsX->pFreeHead;
388 pDevOsX->pFreeHead = pUrbOsX->pNext;
389 RTCritSectLeave(&pDevOsX->CritSect);
393 RTCritSectLeave(&pDevOsX->CritSect);
399 pUrbOsX->pDevOsX = pDevOsX;
505 * @param pDevOsX The darwin proxy device.
508 static void usbProxyDarwinUrbFree(PUSBPROXYDEVOSX pDevOsX, PUSBPROXYURBOSX pUrbOsX)
510 RTCritSectEnter(&pDevOsX->CritSect);
528 pUrbOsX->pNext = pDevOsX->pFreeHead;
529 pDevOsX->pFreeHead = pUrbOsX;
532 pUrbOsX->pDevOsX = NULL;
535 RTCritSectLeave(&pDevOsX->CritSect);
587 PUSBPROXYDEVOSX pDevOsX = pUrbOsX->pDevOsX;
638 RTCritSectEnter(&pDevOsX->CritSect);
644 pUrbOsX->pPrev = pDevOsX->pTaxingTail;
645 if (pDevOsX->pTaxingTail)
646 pDevOsX->pTaxingTail->pNext = pUrbOsX;
648 pDevOsX->pTaxingHead = pUrbOsX;
649 pDevOsX->pTaxingTail = pUrbOsX;
651 RTCritSectLeave(&pDevOsX->CritSect);
660 * @param pDevOsX The darwin proxy device.
662 static void usbProxyDarwinReleaseAllInterfaces(PUSBPROXYDEVOSX pDevOsX)
664 RTCritSectEnter(&pDevOsX->CritSect);
667 usbProxyDarwinReaperKick(pDevOsX);
669 PUSBPROXYIFOSX pIf = pDevOsX->pIfHead;
670 pDevOsX->pIfHead = pDevOsX->pIfTail = NULL;
714 RTCritSectLeave(&pDevOsX->CritSect);
724 * @param pDevOsX The darwin proxy device.
727 static int usbProxyDarwinGetPipeProperties(PUSBPROXYDEVOSX pDevOsX, PUSBPROXYIFOSX pIf)
763 i, pIf->u8Interface, pDevOsX->pProxyDev->pUsbIns->pszName, pIf->u8Protocol, pIf->u8Class));
788 * @param pDevOsX The darwin proxy device.
792 static int usbProxyDarwinSeizeAllInterfaces(PUSBPROXYDEVOSX pDevOsX, bool fMakeTheBestOfIt)
794 PUSBPROXYDEV pProxyDev = pDevOsX->pProxyDev;
796 RTCritSectEnter(&pDevOsX->CritSect);
807 IOReturn irc = (*pDevOsX->ppDevI)->CreateInterfaceIterator(pDevOsX->ppDevI, &Req, &Interfaces);
881 rc = usbProxyDarwinGetPipeProperties(pDevOsX, pIf);
902 if (pDevOsX->pIfTail)
903 pDevOsX->pIfTail = pDevOsX->pIfTail->pNext = pIf;
905 pDevOsX->pIfTail = pDevOsX->pIfHead = pIf;
944 usbProxyDarwinReleaseAllInterfaces(pDevOsX);
958 RTCritSectLeave(&pDevOsX->CritSect);
967 * @param pDevOsX The darwin proxy device.
970 static PUSBPROXYIFOSX usbProxyDarwinGetInterface(PUSBPROXYDEVOSX pDevOsX, uint8_t u8Interface)
972 if (!pDevOsX->pIfHead)
973 usbProxyDarwinSeizeAllInterfaces(pDevOsX, true /* make the best out of it */);
976 for (pIf = pDevOsX->pIfHead; pIf; pIf = pIf->pNext)
989 * @param pDevOsX The darwin proxy device.
994 static PUSBPROXYIFOSX usbProxyDarwinGetInterfaceForEndpoint(PUSBPROXYDEVOSX pDevOsX, uint8_t u8Endpoint,
997 if (!pDevOsX->pIfHead)
998 usbProxyDarwinSeizeAllInterfaces(pDevOsX, true /* make the best out of it */);
1001 for (pIf = pDevOsX->pIfHead; pIf; pIf = pIf->pNext)
1091 PUSBPROXYDEVOSX pDevOsX = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVOSX);
1228 RTListInit((PRTLISTNODE)&pDevOsX->HeadOfRunLoopLst);
1229 vrc = RTCritSectInit(&pDevOsX->CritSect);
1232 pDevOsX->USBDevice = USBDevice;
1233 pDevOsX->ppDevI = ppDevI;
1234 pDevOsX->pProxyDev = pProxyDev;
1235 pDevOsX->pTaxingHead = NULL;
1236 pDevOsX->pTaxingTail = NULL;
1237 pDevOsX->hRunLoopReapingLast = NULL;
1244 vrc = usbProxyDarwinSeizeAllInterfaces(pDevOsX, false /* give up on failure */);
1251 irc = (*ppDevI)->CreateDeviceAsyncEventSource(ppDevI, &pDevOsX->RunLoopSrcRef);
1274 pDevOsX->hRunLoopSrcWakeRef = CFRunLoopSourceCreate(NULL, 0, &CtxRunLoopSource);
1275 if (CFRunLoopSourceIsValid(pDevOsX->hRunLoopSrcWakeRef))
1278 RTListInit(&pDevOsX->HeadOfRunLoopWakeLst);
1282 usbProxyDarwinAddRunLoopRef(&pDevOsX->HeadOfRunLoopLst, pDevOsX->RunLoopSrcRef);
1296 usbProxyDarwinReleaseAllInterfaces(pDevOsX);
1300 RTCritSectDelete(&pDevOsX->CritSect);
1344 PUSBPROXYDEVOSX pDevOsX = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVOSX);
1345 AssertPtrReturnVoid(pDevOsX);
1351 RTCritSectEnter(&pDevOsX->CritSect);
1353 RTCritSectLeave(&pDevOsX->CritSect);
1355 usbProxyDarwinReleaseAllInterfaces(pDevOsX);
1357 if (pDevOsX->RunLoopSrcRef)
1359 int rc = usbProxyDarwinRemoveSourceRefFromAllRunLoops(&pDevOsX->HeadOfRunLoopLst, pDevOsX->RunLoopSrcRef);
1362 RTListInit((PRTLISTNODE)&pDevOsX->HeadOfRunLoopLst);
1364 CFRelease(pDevOsX->RunLoopSrcRef);
1365 pDevOsX->RunLoopSrcRef = NULL;
1368 if (pDevOsX->hRunLoopSrcWakeRef)
1370 int rc = usbProxyDarwinRemoveSourceRefFromAllRunLoops(&pDevOsX->HeadOfRunLoopWakeLst, pDevOsX->hRunLoopSrcWakeRef);
1373 RTListInit((PRTLISTNODE)&pDevOsX->HeadOfRunLoopWakeLst);
1375 CFRelease(pDevOsX->hRunLoopSrcWakeRef);
1376 pDevOsX->hRunLoopSrcWakeRef = NULL;
1379 IOReturn irc = (*pDevOsX->ppDevI)->ResetDevice(pDevOsX->ppDevI);
1382 irc = (*pDevOsX->ppDevI)->USBDeviceReEnumerate(pDevOsX->ppDevI, 0);
1385 irc = (*pDevOsX->ppDevI)->USBDeviceClose(pDevOsX->ppDevI);
1392 (*pDevOsX->ppDevI)->Release(pDevOsX->ppDevI);
1393 pDevOsX->ppDevI = NULL;
1394 kern_return_t krc = IOObjectRelease(pDevOsX->USBDevice); Assert(krc == KERN_SUCCESS); NOREF(krc);
1395 pDevOsX->USBDevice = NULL;
1396 pDevOsX->pProxyDev = NULL;
1401 RTCritSectDelete(&pDevOsX->CritSect);
1404 while ((pUrbOsX = pDevOsX->pFreeHead) != NULL)
1406 pDevOsX->pFreeHead = pUrbOsX->pNext;
1425 PUSBPROXYDEVOSX pDevOsX = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVOSX);
1428 IOReturn irc = (*pDevOsX->ppDevI)->ResetDevice(pDevOsX->ppDevI);
1463 PUSBPROXYDEVOSX pDevOsX = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVOSX);
1467 IOReturn irc = (*pDevOsX->ppDevI)->SetConfiguration(pDevOsX->ppDevI, (uint8_t)iCfg);
1474 usbProxyDarwinReleaseAllInterfaces(pDevOsX);
1475 usbProxyDarwinSeizeAllInterfaces(pDevOsX, true /* make the best out of it */);
1515 PUSBPROXYDEVOSX pDevOsX = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVOSX);
1517 PUSBPROXYIFOSX pIf = usbProxyDarwinGetInterface(pDevOsX, iIf);
1528 usbProxyDarwinGetPipeProperties(pDevOsX, pIf);
1545 irc = (*pDevOsX->ppDevI)->DeviceRequest(pDevOsX->ppDevI, &Req);
1562 PUSBPROXYDEVOSX pDevOsX = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVOSX);
1579 PUSBPROXYIFOSX pIf = usbProxyDarwinGetInterfaceForEndpoint(pDevOsX, EndPt, &u8PipeRef, NULL);
1599 PUSBPROXYDEVOSX pDevOsX = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVOSX);
1613 pIf = usbProxyDarwinGetInterfaceForEndpoint(pDevOsX, EndPt, &u8PipeRef, &pPipe);
1626 PUSBPROXYURBOSX pUrbOsX = usbProxyDarwinUrbAlloc(pDevOsX);
1632 pUrbOsX->pDevOsX = pDevOsX;
1657 irc = (*pDevOsX->ppDevI)->DeviceRequestAsync(pDevOsX->ppDevI, &pUrbOsX->u.ControlMsg,
1791 usbProxyDarwinUrbFree(pDevOsX, pUrbOsX);
1809 PUSBPROXYDEVOSX pDevOsX = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVOSX);
1812 Assert(!pDevOsX->hRunLoopReaping);
1818 if (pDevOsX->hRunLoopReapingLast != hRunLoopRef)
1820 RTCritSectEnter(&pDevOsX->CritSect);
1823 if (!pDevOsX->pIfHead)
1824 usbProxyDarwinSeizeAllInterfaces(pDevOsX, true /* make the best out of it */);
1827 for (pIf = pDevOsX->pIfHead; pIf; pIf = pIf->pNext)
1834 if (!CFRunLoopContainsSource(hRunLoopRef, pDevOsX->RunLoopSrcRef, g_pRunLoopMode))
1835 usbProxyDarwinAddRunLoopRef(&pDevOsX->HeadOfRunLoopLst, pDevOsX->RunLoopSrcRef);
1838 if (!CFRunLoopContainsSource(hRunLoopRef, pDevOsX->hRunLoopSrcWakeRef, g_pRunLoopMode))
1839 usbProxyDarwinAddRunLoopRef(&pDevOsX->HeadOfRunLoopWakeLst, pDevOsX->hRunLoopSrcWakeRef);
1840 RTCritSectLeave(&pDevOsX->CritSect);
1842 pDevOsX->hRunLoopReapingLast = hRunLoopRef;
1845 ASMAtomicXchgPtr((void * volatile *)&pDevOsX->hRunLoopReaping, hRunLoopRef);
1847 if (ASMAtomicXchgBool(&pDevOsX->fReapingThreadWake, false))
1850 ASMAtomicXchgPtr((void * volatile *)&pDevOsX->hRunLoopReaping, NULL);
1857 if ( !pDevOsX->pTaxingHead
1861 ASMAtomicXchgPtr((void * volatile *)&pDevOsX->hRunLoopReaping, NULL);
1862 ASMAtomicXchgBool(&pDevOsX->fReapingThreadWake, false);
1867 while ( pDevOsX->pTaxingHead
1870 RTCritSectEnter(&pDevOsX->CritSect);
1872 PUSBPROXYURBOSX pUrbOsX = pDevOsX->pTaxingHead;
1880 else if (pDevOsX->pTaxingTail == pUrbOsX)
1881 pDevOsX->pTaxingTail = pUrbOsX->pPrev;
1885 else if (pDevOsX->pTaxingHead == pUrbOsX)
1886 pDevOsX->pTaxingHead = pUrbOsX->pNext;
1894 usbProxyDarwinUrbFree(pDevOsX, pUrbOsX);
1897 RTCritSectLeave(&pDevOsX->CritSect);
1922 PUSBPROXYDEVOSX pDevOsX = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVOSX);
1931 irc = (*pDevOsX->ppDevI)->USBDeviceAbortPipeZero(pDevOsX->ppDevI);
1936 PUSBPROXYIFOSX pIf = usbProxyDarwinGetInterfaceForEndpoint(pDevOsX, EndPt, &u8PipeRef, NULL);
1958 PUSBPROXYDEVOSX pDevOsX = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVOSX);
1962 ASMAtomicXchgBool(&pDevOsX->fReapingThreadWake, true);
1963 usbProxyDarwinReaperKick(pDevOsX);