Example #1
0
bool
MolEnet::resetAndEnable( bool enable )
{
	int i;
	ready = false;

	if( getWorkLoop() )
		getWorkLoop()->disableAllInterrupts();
	OSI_Enet2Cntrl( kEnet2Reset );

	// Initialize the link status.
	setLinkStatus( 0, 0 );

	// Reset ring buffers
	rx_head = tx_tail = 0;
	memset( rx_ring, 0, sizeof(enet2_ring_t) * RX_NUM_EL );
	memset( tx_ring, 0, sizeof(enet2_ring_t) * TX_NUM_EL );

	if( !enable )
		return true;

	for( i=0; i<RX_NUM_EL; i++ )
		updateRXDescriptor( i );

	OSI_Enet2Cntrl( kEnet2Start );
	if( getWorkLoop() )
		getWorkLoop()->enableAllInterrupts();

	ready = true;
	monitorLinkStatus( true );

	return true;
}
Example #2
0
bool GPUSensors::start(IOService *provider)
{
    HWSensorsDebugLog("Starting...");
    
    if (!provider || !super::start(provider))
        return false;
    
    if (!(pciDevice = OSDynamicCast(IOPCIDevice, provider))) {
        HWSensorsFatalLog("no PCI device");
        return false;
    }

    
    if (!(workloop = getWorkLoop())) {
        HWSensorsFatalLog("failed to obtain workloop");
        return false;
    }
    
    if (!(timerEventSource = IOTimerEventSource::timerEventSource( this, OSMemberFunctionCast(IOTimerEventSource::Action, this, &GPUSensors::probeEvent)))) {
        HWSensorsFatalLog("failed to initialize timer event source");
        return false;
    }
    
    if (kIOReturnSuccess != workloop->addEventSource(timerEventSource))
    {
        HWSensorsFatalLog("failed to add timer event source into workloop");
        timerEventSource->release();
        return false;
    }
    
    timerEventSource->setTimeoutMS(500);
    
    return true;
}
Example #3
0
/*---------------------------------------------------------------------------
 *
 *	connect the device (drive) interrupt to our workloop
 *
 *
 ---------------------------------------------------------------------------*/
bool
AppleKiwiATA::createDeviceInterrupt(void)
{
	// create a device interrupt source and attach it to the work loop
	
	DLOG("AppleKiwiATA createDeviceInterrupt started\n");
	
	_devIntSrc = IOInterruptEventSource::interruptEventSource( 	
					(OSObject *)this,
					(IOInterruptEventSource::Action) &AppleKiwiATA::sDeviceInterruptOccurred, 
					getProvider(), 
					0); 
	
	DLOG("AppleKiwiATA createdDeviceInterruptsource = %x\n", _devIntSrc);
	DLOG("_workLoop = %x\n", _workLoop);
	
	if( !_devIntSrc || getWorkLoop()->addEventSource(_devIntSrc) )
	{
		DLOG("AppleKiwiATA failed create dev intrpt source\n");
		return false;
	}
		
	// enable interrupt to PCI bus
	UInt32 intMaskLE = (busChildNumber == 0)? 0x00000200 : 0x00000400;
	*globalControlReg &= ~intMaskLE; 
	OSSynchronizeIO();

	_devIntSrc->enable();
	
	DLOG("AppleKiwiATA createDeviceInterrupt done\n");
	
	return true;

}
Example #4
0
void net_habitue_device_SC101::prepareAndDoAsyncReadWrite(OSData *addr, IOMemoryDescriptor *buffer, UInt32 block, UInt32 nblks, IOStorageCompletion completion)
{
  bool isWrite = (buffer->getDirection() == kIODirectionOut);
  const OSSymbol *ioMaxKey = (isWrite ? gSC101DeviceIOMaxWriteSizeKey : gSC101DeviceIOMaxReadSizeKey);
  UInt64 ioMaxSize = OSDynamicCast(OSNumber, getProperty(ioMaxKey))->unsigned64BitValue();
  UInt64 ioSize = (nblks * SECTOR_SIZE);
  
#if WRITEPROTECT
  if (isWrite)
    panic();
#endif

  if (ioSize > ioMaxSize || ioSize & (ioSize - 1))
  {
    KDEBUG("%s size=%llu, deblocking", (isWrite ? "write" : "read"), ioSize);
    deblock(addr, buffer, block, nblks, completion);
    return;
  }
  
  outstanding_io *io = IONewZero(outstanding_io, 1);
  io->addr = addr;
  io->buffer = buffer;
  io->block = block;
  io->nblks = nblks;
  io->completion = completion;
  io->attempt = 0;
  io->timeout_ms = getNextTimeoutMS(io->attempt, isWrite);
  
  io->addr->retain();
  
  getWorkLoop()->runAction(OSMemberFunctionCast(Action, this, &net_habitue_device_SC101::submitIO), this, io);
}
bool BatteryTracker::start(IOService* provider)
{
    DEBUG_LOG("BatteryTracker::start: entering start\n");
    
    if (!IOService::start(provider))
    {
        IOLog("BatteryTracker: IOService::start failed!\n");
        return false;
    }
    
    IOWorkLoop* workLoop = getWorkLoop();
    if (!workLoop)
    {
        IOLog("BatteryTracker: getWorkLoop failed\n");
        return false;
    }
    m_pCmdGate = IOCommandGate::commandGate(this);
    if (!m_pCmdGate)
    {
        IOLog("BatteryTracker: IOCommandGate::commmandGate failed\n");
        return false;
    }
    workLoop->addEventSource(m_pCmdGate);
    
	DEBUG_LOG("ACPIBatteryManager: Version 1.52 starting BatteryTracker.\n");
    
    m_pBatteryList = OSArray::withCapacity(2);
    m_pLock = IORecursiveLockAlloc();
    
    registerService();
    
    return true;
}
Example #6
0
/******************************************************************************
 * ACPIDebug::start
 ******************************************************************************/
bool ACPIDebug::start(IOService *provider)
{
    DEBUG_LOG("ACPIDebug::start: called\n");
    
    m_pDevice = OSDynamicCast(IOACPIPlatformDevice, provider);
    if (NULL == m_pDevice || !super::start(provider))
        return false;

    // need a work loop to send timer events to
    m_pWorkLoop = getWorkLoop();
    if (NULL == m_pWorkLoop)
        return false;
    m_pWorkLoop->retain();

    // need a timer to kick off every second
    m_pTimer = IOTimerEventSource::timerEventSource(this,
        OSMemberFunctionCast(IOTimerEventSource::Action, this, &ACPIDebug::OnTimerEvent));
    if (NULL == m_pTimer)
        return false;
	if (kIOReturnSuccess != m_pWorkLoop->addEventSource(m_pTimer))
        return false;

    // command gate to route setProperties through workloop
    m_pCmdGate = IOCommandGate::commandGate(this);
    if (m_pCmdGate)
        m_pWorkLoop->addEventSource(m_pCmdGate);
    
	IOLog("ACPIDebug: Version 0.1.0 starting\n");
    
    // call it once
    OnTimerEvent();
    
	this->registerService(0);
    return true;
}
bool IOHIDEventSystemUserClient::start( IOService * provider )
{
    if( !super::start( provider )) {
      return( false);
    }
  
    owner = (IOHIDSystem *) provider;
    if (owner) {
        owner->retain();
    }
  
  
    IOWorkLoop * workLoop = getWorkLoop();
    if (workLoop == NULL)
    {
       return false;
    }
  
    commandGate = IOCommandGate::commandGate(this);
    if (commandGate == NULL)
    {
       return false;
    }
  
    if (workLoop->addEventSource(commandGate) != kIOReturnSuccess) {
       return false;
    }

    return( true );
}
Example #8
0
bool
org_virtualbox_VBoxGuest::setupVmmDevInterrupts(IOService *pProvider)
{
    IOWorkLoop *pWorkLoop = getWorkLoop();

    if (!pWorkLoop)
        return false;

    m_pInterruptSrc = IOFilterInterruptEventSource::filterInterruptEventSource(this,
                                                                               &deferredInterruptHandler,
                                                                               &directInterruptHandler,
                                                                               pProvider);

    if (kIOReturnSuccess != pWorkLoop->addEventSource(m_pInterruptSrc))
    {
        m_pInterruptSrc->disable();
        m_pInterruptSrc->release();
        m_pInterruptSrc = 0;
        return false;
    }

    m_pInterruptSrc->enable();

    return true;
}
bool BrcmPatchRAM::start(IOService *provider)
{
    DebugLog("start\n");

    if (!super::start(provider))
        return false;
    
    // add interrupt source for delayed actions...
    IOWorkLoop* workLoop = getWorkLoop();
    if (!workLoop)
        return false;
    mWorkSource = IOInterruptEventSource::interruptEventSource(this, OSMemberFunctionCast(IOInterruptEventAction, this, &BrcmPatchRAM::processWorkQueue));
    if (!mWorkSource)
        return false;
    workLoop->addEventSource(mWorkSource);
    mWorkPending = 0;

    // add timer for firmware load in the case no re-probe after wake
    mTimer = IOTimerEventSource::timerEventSource(this, OSMemberFunctionCast(IOTimerEventSource::Action, this, &BrcmPatchRAM::onTimerEvent));
    if (!mTimer)
    {
        workLoop->removeEventSource(mWorkSource);
        mWorkSource->release();
        mWorkSource = NULL;
        return false;
    }
    workLoop->addEventSource(mTimer);

    // register for power state notifications
    PMinit();
    registerPowerDriver(this, myTwoStates, 2);
    provider->joinPMtree(this);
    
    return true;
}
Example #10
0
IOReturn net_habitue_device_SC101::doAsyncReadWrite(IOMemoryDescriptor *buffer, UInt32 block, UInt32 nblks, IOStorageCompletion completion)
{
  /* run on workloop */
  getWorkLoop()->runAction(OSMemberFunctionCast(Action, this, &net_habitue_device_SC101::safeDoAsyncReadWrite),
                           this, (void*)buffer, (void*)block, (void*)nblks, (void*)&completion);

  return kIOReturnSuccess;
}
void IOHIDEventSystemUserClient::stop( IOService * provider )
{
    IOWorkLoop * workLoop = getWorkLoop();
    if (workLoop && commandGate)
    {
        workLoop->removeEventSource(commandGate);
    }
}
Example #12
0
void
MolEnet::free()
{
	int i;
	
	if( is_open ) {
		OSI_Enet2Cntrl( kEnet2Reset );
		OSI_Enet2Close();
	}

	if( getWorkLoop() )
		getWorkLoop()->disableAllEventSources();

	if( _irq )
		_irq->release();

	if( transmitQueue )
		transmitQueue->release();

	if( networkInterface )
		networkInterface->release();

	if( rxMBufCursor )
		rxMBufCursor->release();
	if( txMBufCursor )
		txMBufCursor->release();

	if( mediumDict )
		mediumDict->release();

	if( rx_ring )
		IOFreeContiguous( rx_ring, sizeof(enet2_ring_t) * RX_NUM_EL );
	if( tx_ring )
		IOFreeContiguous( tx_ring, sizeof(enet2_ring_t) * TX_NUM_EL );

	if( workLoop ) {
		workLoop->release();
		workLoop = 0;
	}
	for( i=0; i<RX_NUM_EL; i++ )
		if( rxMBuf[i] )
			freePacket( rxMBuf[i] );

	// free packets in progress
	super::free();
}
Example #13
0
void SoftU2FUserClient::stop(IOService *provider) {
  IOLog("%s[%p]::%s(%p)\n", getName(), this, __FUNCTION__, provider);

  IOWorkLoop *workLoop = getWorkLoop();
  if (workLoop && _commandGate)
    workLoop->removeEventSource(_commandGate);

  super::stop(provider);
}
Example #14
0
bool	AREngine::initHardware(IOService* inProvider)
{
	bool theAnswer = false;
	
	if(IOAudioEngine::initHardware(inProvider))
	{
		IOAudioSampleRate theInitialSampleRate = { 0, 0 };
		UInt32 theNumberChannels = 0;
		
		//	create the streams
		if(CreateStreams(&theInitialSampleRate, &theNumberChannels) && (theInitialSampleRate.whole != 0))
		{
			CreateControls(theNumberChannels);
			
			//	figure out how long each block is in microseconds
			mBlockTimeoutMicroseconds = 1000000 * mBlockSize / theInitialSampleRate.whole;
			
			setSampleRate(&theInitialSampleRate);
			
			// Set the number of sample frames in each buffer
			setNumSampleFramesPerBuffer(mBlockSize * mNumberBlocks);
			
			//	set up the timer
			IOWorkLoop* theWorkLoop = getWorkLoop();
			if(theWorkLoop != NULL)
			{
				mTimerEventSource = IOTimerEventSource::timerEventSource(this, TimerFired);
				if(mTimerEventSource != NULL)
				{
					theWorkLoop->addEventSource(mTimerEventSource);
					theAnswer = true;
				}
			}
			
			//	set the safety offset
			//	note that due to cache issues, it probably isn't wise to leave the safety offset at 0,
			//	we set it to 4 here, just to be safe.
			setSampleOffset(4);
			
			//	set up the time stamp generator
			mTimeStampGenerator.SetSampleRate(theInitialSampleRate.whole);
			mTimeStampGenerator.SetFramesPerRingBuffer(mBlockSize * mNumberBlocks);
			
			//	nate that the rate scalar is a 4.28 fixed point number
			//	this means that each incremnt is 1/2^28
			mTimeStampGenerator.SetRateScalar(1UL << 28);
			
			//	set the maximum jitter
//			AbsoluteTime theMaximumJitter = { 0, 0 };
//			nanoseconds_to_absolutetime(5ULL * 1000ULL, &theMaximumJitter);
//			mTimeStampGenerator.SetMaximumJitter(theMaximumJitter.lo);
		}
	}
	
	return theAnswer;
}
Example #15
0
IOOutputQueue * darwin_iwi3945::createOutputQueue( void )
{
	// An IOGatedOutputQueue will serialize all calls to the driver's
    // outputPacket() function with its work loop. This essentially
    // serializes all access to the driver and the hardware through
    // the driver's work loop, which simplifies the driver but also
    // carries a small performance cost (relatively for 10/100 Mb).

    return IOGatedOutputQueue::withTarget( this, getWorkLoop() );
}
Example #16
0
// start is called after initWithTask as a result of the user process calling
// IOServiceOpen.
bool SoftU2FUserClient::start(IOService *provider) {
  IOLog("%s[%p]::%s(%p)\n", getName(), this, __FUNCTION__, provider);

  SoftU2FDevice *device = nullptr;
  IOWorkLoop *workLoop = nullptr;

  if (!OSDynamicCast(SoftU2FDriver, provider))
    goto fail_bad_provider;

  if (!super::start(provider))
    goto fail_super_start;

  device = SoftU2FDevice::newDevice();
  if (!device)
    goto fail_new_device;

  if (!device->attach(this))
    goto fail_device_attach;

  if (!device->start(this))
    goto fail_device_start;

  workLoop = getWorkLoop();
  if (!workLoop)
    goto fail_no_workloop;

  _commandGate = IOCommandGate::commandGate(this);
  if (!_commandGate)
    goto fail_new_cgate;

  if (workLoop->addEventSource(_commandGate) != kIOReturnSuccess)
    goto fail_add_event_source;

  // Our call to device->attach took a retain on the device when it was added to the registry.
  // That will be released when the device is detached from the registry.
  device->release();

  return true;

fail_add_event_source:
fail_new_cgate:
fail_no_workloop:
fail_device_start:
  device->detach(this);

fail_device_attach:
  device->release();

fail_new_device:
  stop(provider);

fail_super_start:
fail_bad_provider:
  return false;
}
Example #17
0
bool eqMac2DriverEngine::initHardware(IOService *provider)
{
    bool result = false;
    IOAudioSampleRate initialSampleRate;
    IOWorkLoop *wl;
    
    //IOLog("eqMac2DriverEngine[%p]::initHardware(%p)\n", this, provider);
    
    duringHardwareInit = TRUE;
    
    if (!super::initHardware(provider)) {
        goto Done;
    }
    
    initialSampleRate.whole = 0;
    initialSampleRate.fraction = 0;

    if (!createAudioStreams(&initialSampleRate)) {
		IOLog("eqMac2DriverEngine::initHardware() failed\n");
        goto Done;
    }
	
    if (initialSampleRate.whole == 0) {
        goto Done;
    }
    
    // calculate our timeout in nanosecs, taking care to keep 64bits
    blockTimeoutNS = blockSize;
    blockTimeoutNS *= 1000000000;
    blockTimeoutNS /= initialSampleRate.whole;

	setSampleRate(&initialSampleRate);
    
    // Set the number of sample frames in each buffer
    setNumSampleFramesPerBuffer(blockSize * numBlocks);
    
    wl = getWorkLoop();
    if (!wl) {
        goto Done;
    }
    
    timerEventSource = IOTimerEventSource::timerEventSource(this, ourTimerFired);
    
    if (!timerEventSource) {
        goto Done;
    }
    
    workLoop->addEventSource(timerEventSource);
        
    result = true;
    
Done:
    duringHardwareInit = FALSE;    
    return result;
}
bool RTL8139::initEventSources( IOService *provider )
{
	ELG( 0, 0, 'InES', "RTL8139::initEventSources - " );
    DEBUG_LOG( "initEventSources() ===>\n" );

	IOWorkLoop	*wl = getWorkLoop();
	if ( 0 == wl )
        return false;

	fTransmitQueue = getOutputQueue();
	if ( 0 == fTransmitQueue )
        return false;
	fTransmitQueue->setCapacity( kTransmitQueueCapacity );

		// Create an interrupt event source to handle hardware interrupts.

	interruptSrc = IOInterruptEventSource::interruptEventSource(
						this,
					   OSMemberFunctionCast(	IOInterruptEventAction,
												this,
												&RTL8139::interruptOccurred ),
					   provider );

	if ( !interruptSrc || (wl->addEventSource( interruptSrc ) != kIOReturnSuccess) )
		return false;

		// This is important. If the interrupt line is shared with other devices,
		// then the interrupt vector will be enabled only if all corresponding
		// interrupt event sources are enabled. To avoid masking interrupts for
		// other devices that are sharing the interrupt line, the event source
		// is enabled immediately. Hardware interrupt sources remain disabled.

    interruptSrc->enable();

		// Register a timer event source used as a watchdog timer:

	timerSrc = IOTimerEventSource::timerEventSource(
					this,
					OSMemberFunctionCast(	IOTimerEventSource::Action,
											this,
											&RTL8139::timeoutOccurred ) );

	if ( !timerSrc || (wl->addEventSource( timerSrc ) != kIOReturnSuccess) )
		return false;

		// Create a dictionary to hold IONetworkMedium objects:

	mediumDict = OSDictionary::withCapacity( 5 );
	if ( 0 == mediumDict )
		return false;

	DEBUG_LOG( "initEventSources() <===\n" );
	return true;
}/* end initEventSources */
Example #19
0
bool PhantomAudioEngine::initHardware(IOService *provider)
{
    bool result = false;
    IOAudioSampleRate initialSampleRate;
    IOWorkLoop *wl;
    
    IOLog("PhantomAudioEngine[%p]::initHardware(%p)\n", this, provider);
    
    duringHardwareInit = TRUE;
    
    if (!super::initHardware(provider)) {
        goto Done;
    }
    
    initialSampleRate.whole = 0;
    initialSampleRate.fraction = 0;

    if (!createAudioStreams(&initialSampleRate)) {
        goto Done;
    }
    
    if (initialSampleRate.whole == 0) {
        goto Done;
    }
    
    blockTimeoutUS = 1000000 * blockSize / initialSampleRate.whole;
    
    setSampleRate(&initialSampleRate);
    
    // Set the number of sample frames in each buffer
    setNumSampleFramesPerBuffer(blockSize * numBlocks);
    
    wl = getWorkLoop();
    if (!wl) {
        goto Done;
    }
    
    timerEventSource = IOTimerEventSource::timerEventSource(this, timerFired);
    
    if (!timerEventSource) {
        goto Done;
    }
    
    workLoop->addEventSource(timerEventSource);
        
    result = true;
    
Done:

    duringHardwareInit = FALSE;
    
    return result;
}
// Releases all the objects used
void Xbox360Peripheral::ReleaseAll(void)
{
    LockRequired locker(mainLock);
    
	SerialDisconnect();
	PadDisconnect();
	if (serialTimer != NULL)
	{
		serialTimer->cancelTimeout();
		getWorkLoop()->removeEventSource(serialTimer);
		serialTimer->release();
		serialTimer = NULL;
	}
	if (serialInPipe != NULL)
	{
		serialInPipe->Abort();
		serialInPipe->release();
		serialInPipe = NULL;
	}
	if (serialInBuffer != NULL)
	{
		serialInBuffer->release();
		serialInBuffer = NULL;
	}
	if (serialIn != NULL)
	{
		serialIn->close(this);
		serialIn = NULL;
	}
    if(outPipe!=NULL) {
        outPipe->Abort();
        outPipe->release();
        outPipe=NULL;
    }
    if(inPipe!=NULL) {
        inPipe->Abort();
        inPipe->release();
        inPipe=NULL;
    }
    if(inBuffer!=NULL) {
        inBuffer->release();
        inBuffer=NULL;
    }
    if(interface!=NULL) {
        interface->close(this);
        interface=NULL;
    }
    if(device!=NULL) {
        device->close(this);
        device=NULL;
    }
}
Example #21
0
/******************************************************************************
 * ACPIDebug::start
 ******************************************************************************/
bool ACPIDebug::start(IOService *provider)
{
    DEBUG_LOG("ACPIDebug::start: called\n");
    
    // announce version
    extern kmod_info_t kmod_info;
    IOLog("ACPIDebug: Version %s starting on OS X Darwin %d.%d.\n", kmod_info.version, version_major, version_minor);

    // place version/build info in ioreg properties RM,Build and RM,Version
    char buf[128];
    snprintf(buf, sizeof(buf), "%s %s", kmod_info.name, kmod_info.version);
    setProperty("RM,Version", buf);
#ifdef DEBUG
    setProperty("RM,Build", "Debug-" LOGNAME);
#else
    setProperty("RM,Build", "Release-" LOGNAME);
#endif

    m_pDevice = OSDynamicCast(IOACPIPlatformDevice, provider);
    if (NULL == m_pDevice || !super::start(provider))
        return false;

    m_pLock = IOLockAlloc();
    if (!m_pLock)
        return false;

    // need a work loop to send timer events to
    m_pWorkLoop = getWorkLoop();
    if (NULL == m_pWorkLoop)
        return false;
    m_pWorkLoop->retain();

    // need a timer to kick off every second
    m_pTimer = IOTimerEventSource::timerEventSource(this,
        OSMemberFunctionCast(IOTimerEventSource::Action, this, &ACPIDebug::OnTimerEvent));
    if (NULL == m_pTimer)
        return false;
	if (kIOReturnSuccess != m_pWorkLoop->addEventSource(m_pTimer))
        return false;

    // command gate to route setProperties through workloop
    m_pCmdGate = IOCommandGate::commandGate(this);
    if (m_pCmdGate)
        m_pWorkLoop->addEventSource(m_pCmdGate);

    // call it once
    OnTimerEvent();
    
	this->registerService(0);
    return true;
}
IOOutputQueue* RTL8139::createOutputQueue()
{
	ELG( 0, 0, 'crOQ', "RTL8139::createOutputQueue" );
    DEBUG_LOG( "createOutputQueue() ===>\n" );
    DEBUG_LOG( "createOutputQueue() <===\n" );

		// An IOGatedOutputQueue will serialize all calls to the driver's
		// outputPacket() function with its work loop. This essentially
		// serializes all access to the driver and the hardware through
		// the driver's work loop, which simplifies the driver but also
		// carries a small performance cost (relatively for 10/100 Mb).

    return IOGatedOutputQueue::withTarget( this, getWorkLoop() );
}/* end createOutputQueue */
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);
}
Example #24
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");
}
Example #25
0
/*-----------------------------------------------------------------------------*
 * Script Initialization
 *
 *-----------------------------------------------------------------------------*/
bool Sym8xxSCSIController::Sym8xxInit()
{
    // IOLog( "Sym8xxSCSIController::Sym8xxInit entered\n" );
    /*
     * Perform PCI related initialization
     */
    if ( Sym8xxInitPCI() == false )
    {
	IOLog( "Sym8xxSCSIController::Sym8xxInitPCI returned FALSE\n" );
        return false;
    }

    /*
     * Allocate/initialize driver resources
     */
    if ( Sym8xxInitVars() == false )
    {
	IOLog( "Sym8xxSCSIController::Sym8xxInitVars returned FALSE\n" );
        return false;
    }

    /*
     * Initialize the script engine registers
     */
    if ( Sym8xxInitChip() == false )
    {
	IOLog( "Sym8xxSCSIController::Sym8xxInitChip returned FALSE\n" );
        return false;
    }

    /* 
     * Apply fixups to script and copy script to script engine's on-board ram
     */
    if ( Sym8xxInitScript() == false )
    {
	IOLog( "Sym8xxSCSIController::Sym8xxInitScript returned FALSE\n" );
        return false;
    }

    getWorkLoop()->enableAllInterrupts();

    /*
     * Start script execution
     */
    Sym8xxWriteRegs( chipBaseAddr, DSP, DSP_SIZE, (UInt32) &chipRamAddrPhys[Ent_select_phase] );

    return true;
}
//---------------------------------------------------------------------------
bool AgereET131x::initEventSources( IOService* provider )
{
	// Get a handle to our superclass' workloop.
	//
	IOWorkLoop* myWorkLoop = (IOWorkLoop *) getWorkLoop();
	if (myWorkLoop == NULL) {
		IOLog(" myWorkLoop is NULL.\n");
		return false;
	}
	
	transmitQueue = getOutputQueue();
	if (transmitQueue == NULL) {
		IOLog("getOutputQueue failed.\n");
		return false;
	}
	transmitQueue->setCapacity(NUM_TCB);
	
	interruptSource = IOFilterInterruptEventSource::filterInterruptEventSource( this, &AgereET131x::interruptHandler, &AgereET131x::interruptFilter, provider);
	
	if (!interruptSource ||
		(myWorkLoop->addEventSource(interruptSource) != kIOReturnSuccess)) {
		IOLog("workloop add eventsource interrupt source.\n");
		return false;
	}
	
	// This is important. If the interrupt line is shared with other devices,
	// then the interrupt vector will be enabled only if all corresponding
	// interrupt event sources are enabled. To avoid masking interrupts for
	// other devices that are sharing the interrupt line, the event source
	// is enabled immediately.
	interruptSource->enable();
	
	// Register a timer event source. This is used as a watchdog timer.
	//
	watchdogSource = IOTimerEventSource::timerEventSource(this, &AgereET131x::timeoutHandler );
	if (!watchdogSource || (myWorkLoop->addEventSource(watchdogSource) != kIOReturnSuccess)) {
		IOLog("watchdogSource create failed.\n");
		return false;
	}
	
	mediumDict = OSDictionary::withCapacity(MEDIUM_INDEX_COUNT + 1);
	if (mediumDict == NULL) {
		return false;
	}
	return true;
}
Example #27
0
bool org_virtualbox_VBoxGuest::disableVmmDevInterrupts(void)
{
    IOWorkLoop *pWorkLoop = (IOWorkLoop *)getWorkLoop();

    if (!pWorkLoop)
        return false;

    if (!m_pInterruptSrc)
        return false;

    m_pInterruptSrc->disable();
    pWorkLoop->removeEventSource(m_pInterruptSrc);
    m_pInterruptSrc->release();
    m_pInterruptSrc = NULL;

    return true;
}
Example #28
0
bool GPUSensors::start(IOService *provider)
{
    HWSensorsDebugLog("Starting...");

    int arg_value = 1;

    if (PE_parse_boot_argn("-gpusensors-disable", &arg_value, sizeof(arg_value))) {
        return false;
    }
    
    if (!provider || !super::start(provider))
        return false;
    
    if (!(pciDevice = OSDynamicCast(IOPCIDevice, provider))) {
        HWSensorsFatalLog("no PCI device");
        return false;
    }

    if (!onStartUp(provider))
        return false;

    if (shouldWaitForAccelerator()) {
        if (!(workloop = getWorkLoop())) {
            HWSensorsFatalLog("failed to obtain workloop");
            return false;
        }
        
        if (!(timerEventSource = IOTimerEventSource::timerEventSource( this, OSMemberFunctionCast(IOTimerEventSource::Action, this, &GPUSensors::probeEvent)))) {
            HWSensorsFatalLog("failed to initialize startup check timer event source");
            return false;
        }
        
        if (kIOReturnSuccess != workloop->addEventSource(timerEventSource))
        {
            HWSensorsFatalLog("failed to add startup check timer event source into workloop");
            timerEventSource->release();
            return false;
        }
        
        timerEventSource->setTimeoutMS(100);
    }
    else return managedStart(provider);
    
    return true;
}
bool BrcmPatchRAM::start(IOService *provider)
{
    DebugLog("start\n");

    if (!super::start(provider))
        return false;

    // place version/build info in ioreg properties RM,Build and RM,Version
    char buf[128];
    snprintf(buf, sizeof(buf), "%s %s", OSKextGetCurrentIdentifier(), OSKextGetCurrentVersionString());
    setProperty("RM,Version", buf);
#ifdef DEBUG
    setProperty("RM,Build", "Debug-" LOGNAME);
#else
    setProperty("RM,Build", "Release-" LOGNAME);
#endif

   // add interrupt source for delayed actions...
    IOWorkLoop* workLoop = getWorkLoop();
    if (!workLoop)
        return false;
    mWorkSource = IOInterruptEventSource::interruptEventSource(this, OSMemberFunctionCast(IOInterruptEventAction, this, &BrcmPatchRAM::processWorkQueue));
    if (!mWorkSource)
        return false;
    workLoop->addEventSource(mWorkSource);
    mWorkPending = 0;

    // add timer for firmware load in the case no re-probe after wake
    mTimer = IOTimerEventSource::timerEventSource(this, OSMemberFunctionCast(IOTimerEventSource::Action, this, &BrcmPatchRAM::onTimerEvent));
    if (!mTimer)
    {
        workLoop->removeEventSource(mWorkSource);
        mWorkSource->release();
        mWorkSource = NULL;
        return false;
    }
    workLoop->addEventSource(mTimer);

    // register for power state notifications
    PMinit();
    registerPowerDriver(this, myTwoStates, 2);
    provider->joinPMtree(this);
    
    return true;
}
// Shut down the driver
void WirelessHIDDevice::handleStop(IOService *provider)
{
    WirelessDevice *device = OSDynamicCast(WirelessDevice, provider);

    if (device != NULL)
        device->RegisterWatcher(NULL, NULL, NULL);

    if (serialTimer != NULL) {
        serialTimer->cancelTimeout();
        IOWorkLoop *workloop = getWorkLoop();
        if (workloop != NULL)
            workloop->removeEventSource(serialTimer);
        serialTimer->release();
        serialTimer = NULL;
    }
    
    super::handleStop(provider);
}