// IOFireWireIRMAllocation::free
//
//
void IOFireWireIRMAllocation::free( void )
{
	DebugLog( "IOFireWireIRMAllocation::free\n") ;

	// Take the lock
	IORecursiveLockLock(fLock);

	
	// If we need to release the isoch resources, do so now!
	if (isAllocated)
	{
		if (fReleaseIRMResourcesOnFree)
		{
			if (fBandwidthUnits > 0)
				fControl->releaseIRMBandwidthInGeneration(fBandwidthUnits,fAllocationGeneration);
			if (fIsochChannel < 64)
				fControl->releaseIRMChannelInGeneration(fIsochChannel,fAllocationGeneration);
		}
		// Note: we already removed this allocation from the controller's array! Don't need to do it here!
	}
	
	// Free the lock
	if ( fLock )
		IORecursiveLockFree( fLock ) ;

	OSObject::free();
}
bool
IOFireWireUserClientIniter::init(OSDictionary * propTable)
{
	fProvider = NULL ;

	if( sIniterLock == NULL )
	{
		IORecursiveLock * lock = IORecursiveLockAlloc();
		//IOLog( "IOFireWireUserClientIniter<0x%08lx>::init - IORecursiveLockAlloc = 0x%08lx\n", this, lock );

		bool result = false;
		while( sIniterLock == NULL && result == false )
		{
			result = OSCompareAndSwapPtr( NULL, lock, (void * volatile *)&sIniterLock );
		}

		if( result == false )
		{
			//IOLog( "IOFireWireUserClientIniter<0x%08lx>::init - IORecursiveLockFree = 0x%08lx\n", this, lock );
			IORecursiveLockFree( lock );
		}
	}
	
	//IOLog( "IOFireWireUserClientIniter<0x%08lx>::init - sIniterLock = 0x%08lx\n", this, sIniterLock );

	return super::init(propTable) ;
}
Ejemplo n.º 3
0
// Free is called twice:
// First when the atomic retainCount transitions from 1 -> 0
// Secondly when the work loop itself is commiting hari kari
// Hence the each leg of the free must be single threaded.
void IOWorkLoop::free()
{
    if (workThread) {
	IOInterruptState is;

	// If we are here then we must be trying to shut down this work loop
	// in this case disable all of the event source, mark the loop
	// as terminating and wakeup the work thread itself and return
	// Note: we hold the gate across the entire operation mainly for the 
	// benefit of our event sources so we can disable them cleanly.
	closeGate();

	disableAllEventSources();

        is = IOSimpleLockLockDisableInterrupt(workToDoLock);
	SETP(&fFlags, kLoopTerminate);
        thread_wakeup_one((void *) &workToDo);
        IOSimpleLockUnlockEnableInterrupt(workToDoLock, is);

	openGate();
    }
    else /* !workThread */ {
        IOEventSource *event, *next;

        for (event = eventChain; event; event = next) {
            next = event->getNext();
            event->setWorkLoop(0);
            event->setNext(0);
            event->release();
        }
        eventChain = 0;

	// Either we have a partial initialization to clean up
	// or the workThread itself is performing hari-kari.
	// Either way clean up all of our resources and return.
	
	if (controlG) {
	    controlG->release();
	    controlG = 0;
	}

	if (workToDoLock) {
	    IOSimpleLockFree(workToDoLock);
	    workToDoLock = 0;
	}

	if (gateLock) {
	    IORecursiveLockFree(gateLock);
	    gateLock = 0;
	}
	if (reserved) {
	    IODelete(reserved, ExpansionData, 1);
	    reserved = 0;
	}

	super::free();
    }
}
Ejemplo n.º 4
0
AppleRAIDGlobals::~AppleRAIDGlobals()
{
    IOLog1("AppleRAIDGlobals::~AppleRAIDGlobals called.\n");

    assert(raidControllerReferences == 0);
    
    if (raidGlobalLock) {
        IORecursiveLockFree(raidGlobalLock);
        raidGlobalLock = 0;
    }
}
void FakeSMCKeyStore::free()
{
    if (keysLock) {
        IORecursiveLockFree(keysLock);
        keysLock = 0;
    }
    
    OSSafeRelease(keys);
    OSSafeRelease(types);

    super::free();
}
void ACPIBacklightPanel::stop( IOService * provider )
{
    DbgLog("%s::%s()\n", this->getName(),__FUNCTION__);

    IOWorkLoop* workLoop = getWorkLoop();
    if (workLoop)
    {
        if (_workSource)
        {
            workLoop->removeEventSource(_workSource);
            _workSource->release();
            _workSource = NULL;
        }
        if (_smoothTimer)
        {
            workLoop->removeEventSource(_smoothTimer);
            _smoothTimer->release();
            _smoothTimer = NULL;
        }
        if (_cmdGate)
        {
            workLoop->removeEventSource(_cmdGate);
            _cmdGate->release();
            _cmdGate = NULL;
        }
    }
    _extended = false;

    if (_lock)
    {
        IORecursiveLockFree(_lock);
        _lock = NULL;
    }

#if 0
    OSSafeReleaseNULL(_provider);
#endif

    _backlightHandler = NULL;

    super::stop(provider);
}
void BatteryTracker::stop(IOService* provider)
{
    DEBUG_LOG("BatteryTracker::stop: entering stop\n");
    
    OSSafeReleaseNULL(m_pBatteryList);
    if (NULL != m_pLock)
    {
        IORecursiveLockFree(m_pLock);
        m_pLock = NULL;
    }
    if (m_pCmdGate)
    {
        IOWorkLoop* pWorkLoop = getWorkLoop();
        if (pWorkLoop)
            pWorkLoop->removeEventSource(m_pCmdGate);
        m_pCmdGate->release();
        m_pCmdGate = NULL;
    }
    
    IOService::stop(provider);
}
void
IOFWUserLocalIsochPort::free()
{
	// release DCL pool (if we have one)
	if ( fDCLPool )
	{
		fDCLPool->release() ;
		fDCLPool = NULL ;
	}

	// release fProgramBuffer (if we have one)
	delete [] (UInt8*)fProgramBuffer ;
	fProgramBuffer = NULL ;

	if ( fLock )
	{
		IORecursiveLockFree( fLock ) ;
	}
	
	delete[] fDCLTable ;
	fDCLTable = NULL ;
	
	super::free() ;
}