void BrcmPatchRAM::uploadFirmwareThread(void *arg, wait_result_t wait) { DebugLog("sendFirmwareThread enter\n"); BrcmPatchRAM* me = static_cast<BrcmPatchRAM*>(arg); me->resetDevice(); IOSleep(20); me->uploadFirmware(); me->publishPersonality(); me->scheduleWork(kWorkFinished); DebugLog("sendFirmwareThread termination\n"); thread_terminate(current_thread()); DebugLog("!!! sendFirmwareThread post-terminate !!! should not be here\n"); }
void BrcmPatchRAM::readCompletion(void* target, void* parameter, IOReturn status, uint32_t bytesTransferred) #endif { BrcmPatchRAM *me = (BrcmPatchRAM*)target; IOLockLock(me->mCompletionLock); IOReturn result = me->mReadBuffer->complete(); if (result != kIOReturnSuccess) DebugLog("[%04x:%04x]: ReadCompletion failed to complete read buffer (\"%s\" 0x%08x).\n", me->mVendorId, me->mProductId, me->stringFromReturn(result), result); switch (status) { case kIOReturnSuccess: #ifndef TARGET_ELCAPITAN me->hciParseResponse(me->mReadBuffer->getBytesNoCopy(), me->mReadBuffer->getLength() - bufferSizeRemaining, NULL, NULL); #else me->hciParseResponse(me->mReadBuffer->getBytesNoCopy(), bytesTransferred, NULL, NULL); #endif break; case kIOReturnAborted: AlwaysLog("[%04x:%04x]: readCompletion - Return aborted (0x%08x)\n", me->mVendorId, me->mProductId, status); me->mDeviceState = kUpdateAborted; break; case kIOReturnNoDevice: AlwaysLog("[%04x:%04x]: readCompletion - No such device (0x%08x)\n", me->mVendorId, me->mProductId, status); me->mDeviceState = kUpdateAborted; break; case kIOUSBTransactionTimeout: AlwaysLog("[%04x:%04x]: readCompletion - Transaction timeout (0x%08x)\n", me->mVendorId, me->mProductId, status); break; case kIOReturnNotResponding: AlwaysLog("[%04x:%04x]: Not responding - Delaying next read.\n", me->mVendorId, me->mProductId); me->mInterruptPipe.clearStall(); break; default: AlwaysLog("[%04x:%04x]: readCompletion - Unknown error (0x%08x)\n", me->mVendorId, me->mProductId, status); me->mDeviceState = kUpdateAborted; break; } IOLockUnlock(me->mCompletionLock); // wake waiting task in performUpgrade (in IOLockSleep)... IOLockWakeup(me->mCompletionLock, me, true); }
void BrcmPatchRAM::uploadFirmwareThread(void *arg, wait_result_t wait) { DebugLog("sendFirmwareThread enter\n"); // don't start firmware load when lock is held (instance is shutting down) if (IOLockTryLock(mLoadFirmwareLock)) { BrcmPatchRAM* me = static_cast<BrcmPatchRAM*>(arg); me->resetDevice(); IOSleep(20); me->uploadFirmware(); #ifndef TARGET_ELCAPITAN me->publishPersonality(); #endif me->scheduleWork(kWorkFinished); IOLockUnlock(mLoadFirmwareLock); } DebugLog("sendFirmwareThread termination\n"); thread_terminate(current_thread()); DebugLog("!!! sendFirmwareThread post-terminate !!! should not be here\n"); }