IOReturn BrcmPatchRAM::setPowerState(unsigned long which, IOService *whom) { DebugLog("setPowerState: which = 0x%lx\n", which); if (which == kMyOffPowerState) { // consider firmware no longer loaded mDevice->removeProperty(kFirmwareLoaded); // in the case the instance is shutting down, don't do anything if (mFirmwareStore) { // unload native bluetooth driver IOReturn result = gIOCatalogue->terminateDriversForModule(brcmBundleIdentifier, false); if (result != kIOReturnSuccess) AlwaysLog("[%04x:%04x]: failure terminating native Broadcom bluetooth (%08x)\n", mVendorId, mProductId, result); else DebugLog("[%04x:%04x]: success terminating native Broadcom bluetooth\n", mVendorId, mProductId); // unpublish native bluetooth personality removePersonality(); } } else if (which == kMyOnPowerState) { clock_get_uptime(&wake_time); // start loading firmware for case probe is never called after wake if (!mDevice->getProperty(kFirmwareLoaded)) mTimer->setTimeoutMS(400); // longest time seen in normal re-probe was ~200ms } return IOPMAckImplied; }
IOReturn BrcmPatchRAM::setPowerState(unsigned long which, IOService *whom) { DebugLog("setPowerState: which = 0x%lx\n", which); if (which == kMyOffPowerState) { // in the case the instance is shutting down, don't do anything if (mFirmwareStore) { // unload native bluetooth driver IOReturn result = gIOCatalogue->terminateDriversForModule(brcmBundleIdentifier, false); if (result != kIOReturnSuccess) AlwaysLog("[%04x:%04x]: failure terminating native Broadcom bluetooth (%08x)", mVendorId, mProductId, result); else DebugLog("[%04x:%04x]: success terminating native Broadcom bluetooth\n", mVendorId, mProductId); // unpublish native bluetooth personality removePersonality(); } } return IOPMAckImplied; }
void BrcmPatchRAM::stop(IOService* provider) { #ifdef DEBUG uint64_t stop_time, nano_secs; clock_get_uptime(&stop_time); absolutetime_to_nanoseconds(stop_time - wake_time, &nano_secs); uint64_t milli_secs = nano_secs / 1000000; AlwaysLog("Time since wake %llu.%llu seconds.\n", milli_secs / 1000, milli_secs % 1000); #endif DebugLog("stop\n"); #if 0 #ifndef TARGET_ELCAPITAN //REVIEW: so kext can be unloaded with kextunload -p // unload native bluetooth driver IOReturn result = gIOCatalogue->terminateDriversForModule(brcmBundleIdentifier, false); if (result != kIOReturnSuccess) AlwaysLog("[%04x:%04x]: failure terminating native Broadcom bluetooth (%08x)\n", mVendorId, mProductId, result); else DebugLog("[%04x:%04x]: success terminating native Broadcom bluetooth\n", mVendorId, mProductId); // unpublish native bluetooth personality removePersonality(); #endif #endif mStopping = true; // allow firmware load already started to finish IOLockLock(mLoadFirmwareLock); OSSafeReleaseNULL(mFirmwareStore); IOWorkLoop* workLoop = getWorkLoop(); if (workLoop) { if (mTimer) { mTimer->cancelTimeout(); workLoop->removeEventSource(mTimer); mTimer->release(); mTimer = NULL; } if (mWorkSource) { workLoop->removeEventSource(mWorkSource); mWorkSource->release(); mWorkSource = NULL; mWorkPending = 0; } } PMstop(); if (mCompletionLock) { IOLockFree(mCompletionLock); mCompletionLock = NULL; } #ifndef NON_RESIDENT if (mWorkLock) { IOLockFree(mWorkLock); mWorkLock = NULL; } IOLockUnlock(mLoadFirmwareLock); #endif // #ifndef NON_RESIDENT mDevice.setDevice(NULL); mStopping = false; super::stop(provider); }