bool
IOATABlockStorageDriver::finalize ( IOOptionBits options )
{
	
    if ( fPowerManagementInitialized )
    {
        
        while ( fPowerTransitionInProgress )
        {
            
            IOSleep ( 1 );
            
        }
		
		fCommandGate->commandWakeup ( &fCurrentPowerState, false );
		
        PMstop ( );
        
		if ( fPowerManagementThread != NULL )
		{
			
			// If the power management thread is scheduled, unschedule it.
			thread_call_cancel ( fPowerManagementThread );
			
		}
		
        fPowerManagementInitialized = false;
		
    }
    
    return super::finalize ( options );
	
}
Ejemplo n.º 2
0
void LPCSensors::stop(IOService *provider)
{
    PMstop();

    timerEventSource->cancelTimeout();
    workloop->removeEventSource(timerEventSource);
    
    if (gpuIndex >= 0)
        releaseGPUIndex(gpuIndex);
    
    super::stop(provider);
}
Ejemplo n.º 3
0
void Insomnia::stopPM()
{
    if (_power_source) {
        _power_source->release();
        _power_source = NULL;
    }

    if (_power_state_notifier) {
        _power_state_notifier->remove();
        _power_state_notifier = NULL;
    }

	PMstop();
}
Ejemplo n.º 4
0
void BrcmPatchRAM::stop(IOService* provider)
{
    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);


    DebugLog("stop\n");

    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;
    }
    if (mWorkLock)
    {
        IOLockFree(mWorkLock);
        mWorkLock = NULL;
    }

    OSSafeReleaseNULL(mDevice);

    super::stop(provider);
}
/******************************************************************************
 * CodecCommander::stop & free - stop and free kernel extension
 ******************************************************************************/
void CodecCommander::stop(IOService *provider)
{
    DEBUG_LOG("CodecCommander: Stopping...\n");
    
    // if workloop is active - release it
    mTimer->cancelTimeout();
    mWorkLoop->removeEventSource(mTimer);
    OSSafeReleaseNULL(mTimer);// disable outstanding calls
    OSSafeReleaseNULL(mWorkLoop);

	// Free IntelHDA engine
	mIntelHDA->~IntelHDA();
	
    PMstop();
    super::stop(provider);
}
Ejemplo n.º 6
0
/******************************************************************************
 * CodecCommander::stop & free - stop and free kernel extension
 ******************************************************************************/
void CodecCommander::stop(IOService *provider)
{
    DEBUG_LOG("CodecCommander: cc: commander stopping\n");
    // if workloop is active - release it
    if (fWorkLoop) {
        if(fTimer) {
            OSSafeReleaseNULL(fTimer);// disable outstanding calls
        }
        OSSafeReleaseNULL(fWorkLoop);
    }
    // stop virtual keyboard device
    if (_keyboardDevice)
		_keyboardDevice->release();
        _keyboardDevice = NULL;
    
    PMstop();
    super::stop(provider);
}
Ejemplo n.º 7
0
void AppleMediaBay::free(void)
{
    PMstop();
    
    if (commandGate)
        commandGate->release();
        
    if(intSource)
        intSource->release();
        
    if(workloop)
        workloop->release();

    if (configAddrMap)
        configAddrMap->release();
    
    super::free();
}
Ejemplo n.º 8
0
void BrcmPatchRAM::stop(IOService* provider)
{
    DebugLog("stop\n");

    OSSafeReleaseNULL(mFirmwareStore);

    PMstop();

    if (mCompletionLock)
    {
        IOLockFree(mCompletionLock);
        mCompletionLock = NULL;
    }

    OSSafeReleaseNULL(mDevice);

    super::stop(provider);
}
Ejemplo n.º 9
0
void iTCOWatchdog::free(void)
{    
    DbgPrint(drvid, "free\n");
    
    free_common();
    
    if (GCSMem.map) GCSMem.map->release();
    if (GCSMem.range) GCSMem.range->release();
    
    LPCNub->close(this);
    LPCNub->release();
    
    PMstop();
    
    IOSimpleLockFree(lock);

    super::free();
}
void AppleSmartBatteryManager::stop(IOService *provider)
{
	DEBUG_LOG("AppleSmartBatteryManager::stop: called\n");
	
    fBattery->detach(this);
    
    fBattery->free();
    fBattery->stop(this);
    fBattery->terminate();
    fBattery = NULL;
    
    IOWorkLoop *wl = getWorkLoop();
    if (wl) {
        wl->removeEventSource(fBatteryGate);
    }

    fBatteryGate->free();
    fBatteryGate = NULL;
    
	PMstop();
    
    super::stop(provider);
}
Ejemplo n.º 11
0
void FileNVRAM::stop(IOService *provider)
{
	// OSSafeReleaseNULL(mFilePath);

	if (mTimer)
	{
		mTimer->cancelTimeout();
		getWorkLoop()->removeEventSource(mTimer);
		OSSafeReleaseNULL(mTimer);
	}

	if (mCommandGate)
	{
		getWorkLoop()->removeEventSource(mCommandGate);
	}

	PMstop();
	LOG(NOTICE, "Stop called, attempting to detachFromParent\n");

	IORegistryEntry* root = IORegistryEntry::fromPath("/", gIODTPlane);
	detachFromParent(root, gIODTPlane);

	LOG(NOTICE, "Stop has passed the detach point.. move along now\n");
}
Ejemplo n.º 12
0
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);
}
//won't get called with attached framebuffer.
void info_ennowelbers_proxyframebuffer_driver::stop(IOService *provider)
{
	super::stop(provider);
	PMstop();
	//IOLog("Stopping\n");
}
Ejemplo n.º 14
0
void
IOI2CDevice::freeI2CResources(void)
{
	if (fStateFlags & kStateFlags_TEARDOWN)
		return;
	fStateFlags |= kStateFlags_TEARDOWN;
	DLOG("+IOI2CDevice@%lx::freeI2CResources %x\n",fI2CAddress, fStateFlags);

#ifdef kUSE_IOLOCK
	if(fClientLock)
#else
	if(fClientSem)
#endif
	I2CLOCK;

	fDeviceOffline = TRUE;

#ifdef kUSE_IOLOCK
	if(fClientLock)
#else
	if(fClientSem)
#endif
	I2CUNLOCK;

	DLOG("+IOI2CDevice@%lx::freeI2CResources\n",fI2CAddress);
	if (fStateFlags & kStateFlags_PMInit)	// Don't rely on initialized flag to identify if PMinit was called.
	{
		DLOGPWR("+IOI2CDevice@%lx::freeI2CResources requesting power OFF\n",fI2CAddress);
		changePowerStateTo(kIOI2CPowerState_OFF);

		AbsoluteTime deadline, currentTime;
		clock_interval_to_deadline(20, kSecondScale, &deadline);

		while (fCurrentPowerState != kIOI2CPowerState_OFF)
		{
			IOSleep(10);
			clock_get_uptime(&currentTime);
			if ( CMP_ABSOLUTETIME(&currentTime, &deadline) > 0 )
			{
				ERRLOG("IOI2CDevice@%lx::freeI2CResources timed out waiting to power off\n", fI2CAddress);
				break;
			}
		}

		DLOGPWR("+IOI2CDevice@%lx::freeI2CResources calling PMStop\n",fI2CAddress);
		if (fStateFlags & kStateFlags_PMInit)
		{
			fStateFlags &= ~kStateFlags_PMInit;
			PMstop();
		}
	}
	DLOG("IOI2CDevice@%lx::freeI2CResources 1\n",fI2CAddress);

	if (fPowerStateThreadCall)
	{
		thread_call_cancel(fPowerStateThreadCall);
		thread_call_free(fPowerStateThreadCall);
		fPowerStateThreadCall = 0;
	}

	if (fProvider)
		fProvider->callPlatformFunction("IOI2CPowerStateInterest", FALSE, (void *)this, (void *)false, 0, 0);

	DLOG("IOI2CDevice@%lx::freeI2CResources 2\n",fI2CAddress);
	if (symLockI2CBus)		{ symLockI2CBus->release();		symLockI2CBus = 0; }
	if (symUnlockI2CBus)	{ symUnlockI2CBus->release();	symUnlockI2CBus = 0; }
	if (symWriteI2CBus)		{ symWriteI2CBus->release();	symWriteI2CBus = 0; }
	if (symReadI2CBus)		{ symReadI2CBus->release();		symReadI2CBus = 0; }

	DLOG("IOI2CDevice@%lx::freeI2CResources 3\n",fI2CAddress);

#ifdef kUSE_IOLOCK
	if (fClientLock)		{ IOLockFree(fClientLock);		fClientLock = 0; }
#else
	if (fClientSem)			{ semaphore_destroy(current_task(), fClientSem);	fClientSem = 0; }
#endif

	DLOG("IOI2CDevice@%lx::freeI2CResources 4\n",fI2CAddress);
	if (reserved)
	{
		if (symClientRead)		{ symClientRead->release();		symClientRead = 0; }
		if (symClientWrite)		{ symClientWrite->release();	symClientWrite = 0; }
		if (symPowerInterest)	{ symPowerInterest->release();	symPowerInterest = 0; }
	}

	DLOG("-IOI2CDevice@%lx::freeI2CResources\n",fI2CAddress);
}