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);
}
void
SCSIPressurePathManager::free ( void )
{
	
	STATUS_LOG ( ( "SCSIPressurePathManager::free\n" ) );
	
	if ( fPathSet != NULL )
	{
		
		fPathSet->release ( );
		fPathSet = NULL;
		
	}
	
	if ( fInactivePathSet != NULL )
	{
		
		fInactivePathSet->release ( );
		fInactivePathSet = NULL;
		
	}
	
	if ( fLock != NULL )
	{
		
		IOLockFree ( fLock );
		fLock = NULL;
		
	}
	
	super::free ( );
	
}
Beispiel #3
0
/* keep the pet thread around while we run */
int
kperf_pet_init(void)
{
	kern_return_t rc;
	thread_t t;

	if( pet_thread != NULL )
		return 0;

	/* make the sync poing */
	pet_lock = IOLockAlloc();
	if( pet_lock == NULL )
		return ENOMEM;

	/* create the thread */
	BUF_INFO1(PERF_PET_THREAD, 0);
	rc = kernel_thread_start( pet_thread_loop, NULL, &t );
	if( rc != KERN_SUCCESS )
	{
		IOLockFree( pet_lock );
		pet_lock = NULL;
		return ENOMEM;
	}

	/* OK! */
	return 0;
}
Beispiel #4
0
/******************************************************************************
 * ACPIDebug::stop
 ******************************************************************************/
void ACPIDebug::stop(IOService *provider)
{
	DEBUG_LOG("ACPIDebug::stop: called\n");
    
    if (NULL != m_pTimer)
    {
        m_pTimer->cancelTimeout();
        m_pWorkLoop->removeEventSource(m_pTimer);
        m_pTimer->release();
        m_pTimer = NULL;
    }
    if (NULL != m_pCmdGate)
    {
        m_pWorkLoop->removeEventSource(m_pCmdGate);
        m_pCmdGate->release();
        m_pCmdGate = NULL;
    }
    
    if (NULL != m_pWorkLoop)
    {
        m_pWorkLoop->release();
        m_pWorkLoop = NULL;
    }
    if (NULL != m_pLock)
    {
        IOLockFree(m_pLock);
        m_pLock = NULL;
    }
	
    super::stop(provider);
}
void AppleIntelPIIXATARoot::free( void )
{
    if ( _nubs )
    {
        _nubs->release();
        _nubs = 0;
    }

    if ( _openNubs )
    {
        _openNubs->release();
        _openNubs = 0;
    }

    if ( _provider )
    {
        _provider->release();
        _provider = 0;
    }

    if ( _pciConfigLock )
    {
        IOLockFree( _pciConfigLock );
        _pciConfigLock = 0;
    }

    super::free();
}
bool DldIODataQueue::initWithCapacity( __in UInt32 size )
{
    assert( 0x0 != size );
    assert( preemption_enabled() );
    
    if( !super::init() ){
        return false;
    }
    
    this->lock = IOLockAlloc();
    assert( this->lock );
    if( !this->lock )
        return false;
    
    this->dataQueue = (DldIODataQueueMemory*)IOMallocAligned(round_page(size + DLD_DATA_QUEUE_MEMORY_HEADER_SIZE), PAGE_SIZE);
    assert( this->dataQueue );
    if( !this->dataQueue ){
        
        IOLockFree( this->lock );
        return false;
    }
    
    bzero( this->dataQueue, sizeof( *this->dataQueue ) );
    this->dataQueue->queueSize = size;
    
    return true;
}
void AppleNForceATARoot::free( void )
{
    if (fISABridgeNotifier)
    {
        fISABridgeNotifier->remove();
        fISABridgeNotifier = 0;
    }

    if (fChannels)
    {
        fChannels->release();
        fChannels = 0;
    }

    if (fOpenChannels)
    {
        fOpenChannels->release();
        fOpenChannels = 0;
    }

    if (fProvider)
    {
        fProvider->release();
        fProvider = 0;
    }

    if (fPCILock)
    {
        IOLockFree( fPCILock );
        fPCILock = 0;
    }

    super::free();
}
 static void free(IOLock*& lock) {
   IOLockLock(lock);
   IOLock* tmplock = lock;
   lock = NULL;
   IOLockUnlock(tmplock);
   IOLockFree(tmplock);
 }
void IOHIKeyboard::free()
// Description:	Go Away. Be careful when freeing the lock.
{
    IOLock * lock = NULL;

    if ( _deviceLock )
    {
      lock = _deviceLock;
      IOLockLock( lock);
      _deviceLock = NULL;
    }

    if ( _keyMap ) {
        _keyMap->release();
    }

    if( _keyState )
        IOFree( _keyState, _keyStateSize);

    // RY: MENTAL NOTE Do this last
    if ( lock )
    {
      IOLockUnlock( lock);
      IOLockFree( lock);
    }
    
    super::free();
}
Beispiel #10
0
void I2CUserClient::stop(IOService *provider)
{
	DLOG("+I2CUserClient::stop\n");

	IOLockFree(fIsOpenLock);

	super::stop(provider);
}
IOReturn IOSharedInterruptController::initInterruptController(IOInterruptController *parentController, OSData *parentSource)
{
  int      cnt, interruptType;
  IOReturn error;
  
  if (!super::init())
    return kIOReturnNoResources;
  
  // Set provider to this so enable/disable nub stuff works.
  provider = this;
  
  // Allocate the IOInterruptSource so this can act like a nub.
  _interruptSources = (IOInterruptSource *)IOMalloc(sizeof(IOInterruptSource));
  if (_interruptSources == 0) return kIOReturnNoMemory;
  _numInterruptSources = 1;
  
  // Set up the IOInterruptSource to point at this.
  _interruptSources[0].interruptController = parentController;
  _interruptSources[0].vectorData = parentSource;
  
  sourceIsLevel = false;
  error = provider->getInterruptType(0, &interruptType);
  if (error == kIOReturnSuccess) {
    if (interruptType & kIOInterruptTypeLevel)
      sourceIsLevel = true;
  }
  
  // Allocate the memory for the vectors
  numVectors = 32; // For now a constant number.
  vectors = (IOInterruptVector *)IOMalloc(numVectors * sizeof(IOInterruptVector));
  if (vectors == NULL) {
    IOFree(_interruptSources, sizeof(IOInterruptSource));
    return kIOReturnNoMemory;
  }
  bzero(vectors, numVectors * sizeof(IOInterruptVector));
  
  // Allocate the lock for the controller.
  controllerLock = IOSimpleLockAlloc();
  if (controllerLock == 0) return kIOReturnNoResources;
  
  // Allocate locks for the vectors.
  for (cnt = 0; cnt < numVectors; cnt++) {
    vectors[cnt].interruptLock = IOLockAlloc();
    if (vectors[cnt].interruptLock == NULL) {
      for (cnt = 0; cnt < numVectors; cnt++) {
	if (vectors[cnt].interruptLock != NULL)
	  IOLockFree(vectors[cnt].interruptLock);
      }
      return kIOReturnNoResources;
    }
  }
  
  vectorsRegistered = 0;
  vectorsEnabled = 0;
  controllerDisabled = 1;
  
  return kIOReturnSuccess;
}
bool GenericInterruptController::start(IOService *provider)
{
  IOInterruptAction    handler;
  IOSymbol             *interruptControllerName;
    
  // If needed call the parents start.
  if (!super::start(provider))
    return false;
  
  // Map the device's memory and initalize its state.
  
  // For now you must allocate storage for the vectors.
  // This will probably changed to something like: initVectors(numVectors).
  // In the mean time something like this works well.
#if 0
  // Allocate the memory for the vectors.
  vectors = (IOInterruptVector *)IOMalloc(numVectors *
					  sizeof(IOInterruptVector));
  if (vectors == NULL) return false;
  bzero(vectors, numVectors * sizeof(IOInterruptVector));
  
  // Allocate locks for the vectors.
  for (cnt = 0; cnt < numVectors; cnt++) {
    vectors[cnt].interruptLock = IOLockAlloc();
    if (vectors[cnt].interruptLock == NULL) {
      for (cnt = 0; cnt < numVectors; cnt++) {
	if (vectors[cnt].interruptLock != NULL)
	  IOLockFree(vectors[cnt].interruptLock);
      }
    }
  } 
#endif
  
  // If you know that this interrupt controller is the primary
  // interrupt controller, use this to set it nub properties properly.
  // This may be done by the nub's creator.
  getPlatform()->setCPUInterruptProperties(provider);
  
  // register the interrupt handler so it can receive interrupts.
  handler = getInterruptHandlerAddress();
  provider->registerInterrupt(0, this, handler, 0);
  
  // Just like any interrupt source, you must enable it to receive interrupts.
  provider->enableInterrupt(0);
  
  // Set interruptControllerName to the proper symbol.
  //interruptControllerName = xxx;
  
  // Register this interrupt controller so clients can find it.
  getPlatform()->registerInterruptController(interruptControllerName, this);
  
  // All done, so return true.
  return true;
}
IOReturn EMUUSBInputStream::free() {
    ReturnIf(!initialized, kIOReturnNotReady);
    ReturnIf(started, kIOReturnStillOpen);
    initialized=false;
    
    if (NULL != mLock) {
		IOLockFree(mLock);
		mLock = NULL;
	}
    return kIOReturnSuccess;
}
kern_return_t BrcmPatchRAM_Stop(kmod_info_t* ki, void * d)
{
#ifndef NON_RESIDENT
    if (BrcmPatchRAM::mLoadFirmwareLock)
    {
        IOLockFree(BrcmPatchRAM::mLoadFirmwareLock);
        BrcmPatchRAM::mLoadFirmwareLock = NULL;
    }
#endif

    return KERN_SUCCESS;
}
Beispiel #15
0
void GlobalLock::terminate(void) {
  if (!lock_) return;

  IOLockLock(lock_);
  IOLock* tmp = lock_;
  lock_ = NULL;
  IOLockUnlock(tmp);

  // roughly sleep:
  IOSleep(200);

  IOLockFree(tmp);
}
void DldIODataQueue::free()
{
    assert( preemption_enabled() );
    
    if( this->dataQueue )
        IOFreeAligned( this->dataQueue, round_page(dataQueue->queueSize + DATA_QUEUE_MEMORY_HEADER_SIZE) );
        
    if( this->lock )
        IOLockFree( this->lock );
    
    super::free();
    
    return;
}
void IOSharedEventQueue::free()
{
    if(this->_lock)
    {
        IOLockFree(this->_lock);
        this->_lock=NULL;
    }

    if(this->_descriptor)
    {
        this->_descriptor->release();
        this->_descriptor=NULL;
    }
}
SCSIPressurePathManager::PortBandwidthGlobals::~PortBandwidthGlobals ( void )
{
	
	if ( fLock != NULL )
	{
		
		IOLockFree ( fLock );
		fLock = NULL;
		
	}
	
	IOFree ( fListHead, fCapacity );
	fListHead = NULL;
	fCapacity = 0;
	
}
Beispiel #19
0
void HoRNDIS::releaseResources() {
	int i;
	
	for (i = 0; i < N_OUT_BUFS; i++)
		if (outbufs[i].mdp) {
			outbufs[i].mdp->release();
			outbufs[i].mdp = NULL;
		}
	
	if (inbuf.mdp) {
		inbuf.mdp->release();
		inbuf.mdp = NULL;
	}
	
	if (outbuf_lock)
		IOLockFree(outbuf_lock);
}
Beispiel #20
0
void BrcmPatchRAM::stop(IOService* provider)
{
    DebugLog("stop\n");

    OSSafeReleaseNULL(mFirmwareStore);

    PMstop();

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

    OSSafeReleaseNULL(mDevice);

    super::stop(provider);
}
void
IOFWUserAsyncStreamListener::free()
{
	if ( fPacketQueuePrepared )
		fPacketQueueBuffer->complete() ;

	if ( fPacketQueueBuffer )
		fPacketQueueBuffer->release() ;

	delete fLastWrittenHeader ;

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

	IOFWAsyncStreamListener::free() ;
}
void IOHIDEventQueue::free()
{
    if (_lock)
    {
        IOLockLock(_lock);
        IOLock*	 tempLock = _lock;
        _lock = NULL;
        IOLockUnlock(tempLock);
        IOLockFree(tempLock);
    }
    
    if ( _descriptor )
    {
        _descriptor->release();
        _descriptor = 0;
    }

    super::free();
}
void RadeonController::free( void ) {
	ScrnInfoPtr pScrn = xf86Screens[0];
	if (pScrn) {
		IODelete(pScrn, ScrnInfoRec, 1);
		xf86Screens[0] = NULL;
	}
	
#ifdef DEBUG
	DumpMsg.client--;
	if (DumpMsg.client == 0) {
		DumpMsg.mMsgBufferEnabled = false;
		if (DumpMsg.mMsgBuffer) {
			IOFree(DumpMsg.mMsgBuffer, DumpMsg.mMsgBufferSize);
			DumpMsg.mMsgBuffer = NULL;
		}
		if (DumpMsg.mMessageLock) {
			IOLockLock(DumpMsg.mMessageLock);
			IOLockFree(DumpMsg.mMessageLock);
			DumpMsg.mMessageLock = NULL;
		}
		getRegistryRoot()->removeProperty("RadeonDumpReady");
	}
#endif

	int i;
	for (i = 0;i < 2;i++) {
		if (options.EDID_Block[i]) {
			IOFree(options.EDID_Block[i], options.EDID_Length[i]);
			options.EDID_Block[i] = NULL;
		}
	}
	if (memoryMap.BIOSCopy) {
		IOFree(memoryMap.BIOSCopy, memoryMap.BIOSLength);
		memoryMap.BIOSCopy = NULL;
	}

	if (IOMap) IOMap->release();
	if (FBMap) FBMap->release();

	super::free();
}
Beispiel #24
0
void IOI2CDriveBayGPIO::stop(IOService *provider)
{
	UInt32 i;

	DLOG("IOI2CDriveBayGPIO::stop\n");
	
	for (i = 0; i < kNumGPIOs; i++)
	{
		fClient[i].isEnabled = false;
		fClient[i].self = 0;
		fClient[i].handler = 0;
	}

	// Un-Register with the combined PCA9554M
	if (fPCA9554M)
		fPCA9554M->callPlatformFunction("register9554MInterruptClient", false,
				(void *)fReg, (void *)&sProcess9554MInterrupt, (void *)this, (void *)false);

	if (fClientLock)	{ IOLockFree(fClientLock);		fClientLock = 0; }

    super::stop(provider);
}
Beispiel #25
0
void SPFramebuffer::free() {
    IOLockFree(lock);
    super::free();
}
Beispiel #26
0
void AppleGPIO::stop(IOService *provider)
{
	UInt32 flags, i;
	IOPlatformFunction *func;
	AppleGPIOCallbackInfo *thisClient, *nextClient;

	// Execute any functions flagged as "on termination"
	UInt32 count = fPlatformFuncArray->getCount();
	for (i = 0; i < count; i++)
	{
		if (func = OSDynamicCast(IOPlatformFunction, fPlatformFuncArray->getObject(i)))
		{
			flags = func->getCommandFlags();

			if (flags & kIOPFFlagOnTerm) 
				performFunction(func, (void *)1, (void *)0, (void *)0, (void *)0);
		}
	}

	// Unregister for interrupts
	if (fIntGen && amRegistered())
	{
		disableWithParent();
		unregisterWithParent();
		fIntGen = false;
	}
	
	if (fPFLock) { IOLockFree (fPFLock); fPFLock = NULL; }
	
	IOSimpleLockLock(fClientsLock);
	
	if (fClients)
	{
		thisClient = fClients;
		while (thisClient)
		{
			nextClient = thisClient->next;
			IOFree(thisClient, sizeof(AppleGPIOCallbackInfo));
			thisClient = nextClient;
		}

		fClients = 0;
	}
	
	IOSimpleLockUnlock(fClientsLock);

	IOSimpleLockFree(fClientsLock); fClientsLock = 0;
	IOLockFree(fAmRegisteredLock); fAmRegisteredLock = 0;
	IOSimpleLockFree(fAmEnabledLock); fAmEnabledLock = 0;

	fParent = 0;
	fGPIOID = kGPIOIDInvalid;

	if (fSymIntRegister)	{ fSymIntRegister->release(); fSymIntRegister = 0; }
	if (fSymIntUnRegister)	{ fSymIntUnRegister->release(); fSymIntUnRegister = 0; }
	if (fSymIntEnable)		{ fSymIntEnable->release(); fSymIntEnable = 0; }
	if (fSymIntDisable)		{ fSymIntDisable->release(); fSymIntDisable = 0; }

#ifdef OLD_STYLE_COMPAT

	releaseStrings();
	
#endif

	super::stop(provider);
}
// Free the extension
void Xbox360Peripheral::free(void)
{
    IOLockFree(mainLock);
    super::free();
}
void spin_lock_free(spinlock_t *lock)
{
	IOLockFree(*lock);
	lock = NULL;
}
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);
}
Beispiel #30
0
 ~IOMapperLock() { IOLockFree(fWaitLock); }