本文整理汇总了C++中IOWorkLoop::addEventSource方法的典型用法代码示例。如果您正苦于以下问题:C++ IOWorkLoop::addEventSource方法的具体用法?C++ IOWorkLoop::addEventSource怎么用?C++ IOWorkLoop::addEventSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOWorkLoop
的用法示例。
在下文中一共展示了IOWorkLoop::addEventSource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: start
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;
}
示例2: getWorkLoop
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 */
示例3: WLLogInfo
bool MACJackUserClient::
start(IOService* provider)
{
WLLogInfo("MACJackUserClient::start()\n");
if (!super::start(provider)) {
WLLogErr("MACJackUserClient: start: super::start() failed\n");
return false;
}
_provider = OSDynamicCast(MACJackDriver, provider);
if (!_provider)
return false;
_wlCard = _provider->getWLCard();
_userCommandGate = IOCommandGate::commandGate(this);
if (!_userCommandGate) {
WLLogErr("MACJackUserClient::start: Couldn't get CommandGate\n");
return false;
}
IOWorkLoop* wl = _provider->getWorkLoop();
if (wl->addEventSource(_userCommandGate) != kIOReturnSuccess) {
WLLogErr("MACJackUserClient::start: Couldn't add gate to workloop\n");
return false;
}
_packetQueue = _provider->getPacketQueue();
return true;
}
示例4: getWorkLoop
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;
}
示例5: start
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 );
}
示例6: start
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;
}
示例7: getWorkLoop
//---------------------------------------------------------------------------
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;
}
示例8: start
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;
}
示例9: getWorkLoop
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;
}
示例10: IOLog
// 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;
}
示例11: setupVmmDevInterrupts
bool org_virtualbox_VBoxGuest::setupVmmDevInterrupts(IOService *pProvider)
{
IOWorkLoop *pWorkLoop = getWorkLoop();
if (!pWorkLoop)
return false;
m_pInterruptSrc = IOFilterInterruptEventSource::filterInterruptEventSource(this,
&vgdrvDarwinDeferredIrqHandler,
&vgdrvDarwinDirectIrqHandler,
pProvider);
IOReturn rc = pWorkLoop->addEventSource(m_pInterruptSrc);
if (rc == kIOReturnSuccess)
{
m_pInterruptSrc->enable();
return true;
}
m_pInterruptSrc->disable();
m_pInterruptSrc->release();
m_pInterruptSrc = NULL;
return false;
}
示例12: handleStart
// Start up the driver
bool WirelessHIDDevice::handleStart(IOService *provider)
{
WirelessDevice *device;
IOWorkLoop *workloop;
if (!super::handleStart(provider))
goto fail;
device = OSDynamicCast(WirelessDevice, provider);
if (device == NULL)
goto fail;
serialTimerCount = 0;
serialTimer = IOTimerEventSource::timerEventSource(this, ChatPadTimerActionWrapper);
if (serialTimer == NULL)
{
IOLog("start - failed to create timer for chatpad\n");
goto fail;
}
workloop = getWorkLoop();
if ((workloop == NULL) || (workloop->addEventSource(serialTimer) != kIOReturnSuccess))
{
IOLog("start - failed to connect timer for chatpad\n");
goto fail;
}
device->RegisterWatcher(this, _receivedData, NULL);
device->SendPacket(weirdStart, sizeof(weirdStart));
serialTimer->setTimeoutMS(1000);
return true;
fail:
return false;
}
示例13: start
bool AppleSmartBatteryManager::start(IOService *provider)
{
DEBUG_LOG("AppleSmartBatteryManager::start: called\n");
fProvider = OSDynamicCast(IOACPIPlatformDevice, provider);
if (!fProvider || !super::start(provider)) {
return false;
}
IOWorkLoop *wl = getWorkLoop();
if (!wl) {
return false;
}
// Join power management so that we can get a notification early during
// wakeup to re-sample our battery data. We don't actually power manage
// any devices.
PMinit();
registerPowerDriver(this, myTwoStates, 2);
provider->joinPMtree(this);
//rehabman: updated version
IOLog("AppleSmartBatteryManager: Version 1.41 starting\n");
int value = getPlatform()->numBatteriesSupported();
DEBUG_LOG("AppleSmartBatteryManager: Battery Supported Count(s) %d.\n", value);
// TODO: Create battery array to hold battery objects if more than one battery in the system
if (value > 1)
{
if (kIOReturnSuccess == fProvider->evaluateInteger("_STA", &fBatterySTA)) {
if (fBatterySTA & BATTERY_PRESENT) {
goto populateBattery;
} else {
goto skipBattery;
}
}
}
populateBattery:
fBattery = AppleSmartBattery::smartBattery();
if(!fBattery)
return false;
fBattery->attach(this);
fBattery->start(this);
// Command gate for ACPIBatteryManager
fManagerGate = IOCommandGate::commandGate(this);
if (!fManagerGate) {
return false;
}
wl->addEventSource(fManagerGate);
// Command gate for ACPIBattery
fBatteryGate = IOCommandGate::commandGate(fBattery);
if (!fBatteryGate) {
return false;
}
wl->addEventSource(fBatteryGate);
fBattery->registerService(0);
skipBattery:
this->setName("AppleSmartBatteryManager");
this->registerService(0);
return true;
}
示例14: FWKLOG
//.........这里部分代码省略.........
fProviderTarget = OSDynamicCast( IOFireWireSBP2Target, provider );
if( !fProviderTarget )
status = kIOReturnError;
}
if( status == kIOReturnSuccess )
{
fProviderTarget->retain();
if( !IOService::attach(provider) )
status = kIOReturnError;
}
#if FWDIAGNOSTICS
if( gDiagnostics_Symbol == NULL )
gDiagnostics_Symbol = OSSymbol::withCString("SBP2 Diagnostics");
fDiagnostics = IOFireWireSBP2Diagnostics::createDiagnostics();
if( fDiagnostics )
{
setProperty( gDiagnostics_Symbol, fDiagnostics );
}
#endif
//
// get lun number
//
if( status == kIOReturnSuccess )
{
OSObject *prop;
// read lun number from registry
prop = getProperty( gIOUnit_Symbol );
fLUNumber = ((OSNumber*)prop)->unsigned32BitValue();
}
//
// create login set
//
if( status == kIOReturnSuccess )
{
fLoginSet = OSSet::withCapacity(1);
if( fLoginSet == NULL )
status = kIOReturnNoMemory;
}
if( status == kIOReturnSuccess )
{
if( fLoginSet )
fLoginSetIterator = OSCollectionIterator::withCollection( fLoginSet );
}
//
// create management orb set
//
if( status == kIOReturnSuccess )
{
fORBSet = OSSet::withCapacity(1);
if( fORBSet == NULL )
status = kIOReturnNoMemory;
}
if( status == kIOReturnSuccess )
{
if( fORBSet )
fORBSetIterator = OSCollectionIterator::withCollection( fORBSet );
}
//
// set up command gate
//
IOWorkLoop * workLoop = NULL;
if( status == kIOReturnSuccess )
{
workLoop = getWorkLoop();
if( !workLoop )
status = kIOReturnNoResources;
}
if( status == kIOReturnSuccess )
{
fGate = IOCommandGate::commandGate( this );
if( !fGate )
status = kIOReturnNoMemory;
}
if( status == kIOReturnSuccess )
{
workLoop->retain();
workLoop->addEventSource( fGate );
}
return (status == kIOReturnSuccess);
}
示例15: getWorkLoop
// Class start
bool
VoodooPState::start(IOService * provider)
{
if (!IOService::start(provider)) return false;
// Printout banner
InfoLog("%s %s (%s) %s %s [%s]",
KextProductName,
KextVersion,
KextConfig,
KextBuildDate,
KextBuildTime,
KextOSX);
InfoLog("based on VoodooPower 1.2.3.");
// Setup workloop and timer
IOWorkLoop* WorkLoop = getWorkLoop();
if (!WorkLoop) return false;
TimerEventSource =
IOTimerEventSource::timerEventSource(this, OSMemberFunctionCast(IOTimerEventSource::Action,
this,
&VoodooPState::LoopTimerEvent));
if (!TimerEventSource) return false;
if (kIOReturnSuccess != WorkLoop->addEventSource(TimerEventSource)) {
return false;
}
// Get a SimpleLock
SimpleLock = IOSimpleLockAlloc();
if (!SimpleLock) return false;
// Publish the static characteristics
OSDictionary * dictionary = OSDictionary::withCapacity(13);
if (!dictionary) return false;
OSArray * array = OSArray::withCapacity(PStateCount);
if (!array) return false;
setDictionaryNumber(keyCpuCoreTech, CpuCoreTech, dictionary);
setDictionaryNumber(keyFrontSideBus, CpuFSB, dictionary);
for (int i = 0; i < PStateCount; i++) {
OSDictionary * pdictionary = OSDictionary::withCapacity(3);
if (!pdictionary) return false;
setDictionaryNumber(keyCurrentFrequency, PState[i].frequency, pdictionary);
setDictionaryNumber(keyCurrentVoltage, PState[i].voltage, pdictionary);
setDictionaryNumber(keyFid, PState[i].fid, pdictionary);
setDictionaryNumber(keyDid, PState[i].did, pdictionary);
setDictionaryNumber(keyVid, PState[i].vid, pdictionary);
array->setObject(i, pdictionary);
pdictionary->release();
}
setDictionaryArray(keyPStates, array, dictionary);
setDictionaryString(keyProductName, KextProductName, dictionary);
setDictionaryString(keyProductVersion, KextVersion, dictionary);
setDictionaryString(keyBuildConfig, KextConfig, dictionary);
setDictionaryString(keyBuildDate, KextBuildDate, dictionary);
setDictionaryString(keyBuildTime, KextBuildTime, dictionary);
setDictionaryNumber(keyTimerInterval, TimerInterval, dictionary);
setProperty(keyCharacteristics, dictionary);
array->release();
dictionary->release();
// set initial pstate
Request = ColdStart ? (PStateCount-1) : 0; // hot/cold start
gPEClockFrequencyInfo.cpu_frequency_max_hz = VoodooFrequencyProc(this,&PState[0]) * Mega;
gPEClockFrequencyInfo.cpu_frequency_min_hz = VoodooFrequencyProc(this,&PState[PStateCount-1]) * Mega;
LoopTimerEvent();
// Finalize and kick off the loop
this->registerService(0);
Ready = true;
return true;
}