void IOHIKeyboard::scheduleAutoRepeat() // Description: Schedule a procedure to be called when a timeout has expired // so that we can generate a repeated key. // Preconditions: // * _deviceLock should be held on entry { KeyboardReserved *tempReservedStruct = GetKeyboardReservedStructEventForService(this); if ( _calloutPending == true ) { if (tempReservedStruct) { thread_call_cancel(tempReservedStruct->repeat_thread_call); } _calloutPending = false; } if ( AbsoluteTime_to_scalar(&_downRepeatTime) ) { AbsoluteTime deadline; clock_absolutetime_interval_to_deadline(_downRepeatTime, &deadline); if (tempReservedStruct) { thread_call_enter_delayed(tempReservedStruct->repeat_thread_call, deadline); } _calloutPending = true; } }
void mk_timer_port_destroy( ipc_port_t port) { mk_timer_t timer = NULL; ip_lock(port); if (ip_kotype(port) == IKOT_TIMER) { timer = (mk_timer_t)port->ip_kobject; assert(timer != NULL); ipc_kobject_set_atomically(port, IKO_NULL, IKOT_NONE); simple_lock(&timer->lock); assert(timer->port == port); } ip_unlock(port); if (timer != NULL) { if (thread_call_cancel(&timer->call_entry)) timer->active--; timer->is_armed = FALSE; timer->is_dead = TRUE; if (timer->active == 0) { simple_unlock(&timer->lock); zfree(mk_timer_zone, timer); ipc_port_release_send(port); return; } simple_unlock(&timer->lock); } }
__private_extern__ kern_return_t chudxnu_timer_free(chud_timer_t timer) { thread_call_cancel((thread_call_t)timer); thread_call_free((thread_call_t)timer); return KERN_SUCCESS; }
void cyclic_remove(cyclic_id_t cyclic) { wrap_thread_call_t *wrapTC = (wrap_thread_call_t *)cyclic; ASSERT(cyclic != CYCLIC_NONE); while (!thread_call_cancel(wrapTC->TChdl)) { int ret = assert_wait(wrapTC, THREAD_UNINT); ASSERT(ret == THREAD_WAITING); wrapTC->when.cyt_interval = WAKEUP_REAPER; ret = thread_block(THREAD_CONTINUE_NULL); ASSERT(ret == THREAD_AWAKENED); } if (thread_call_free(wrapTC->TChdl)) _FREE(wrapTC, M_TEMP); else { /* Gut this cyclic and move on ... */ wrapTC->hdlr.cyh_func = noop_cyh_func; wrapTC->when.cyt_interval = NEARLY_FOREVER; } }
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 ); }
bool NoSleepExtension::setSleepSuppressionState(NoSleepState state, int mode) { #ifdef DEBUG IOLog("%s[%p]::%s(%d, %d)\n", getName(), this, __FUNCTION__, state, mode); #endif if(mode != kNoSleepModeCurrent) { if(isOnAC) { if(mode == kNoSleepModeBattery) { batterySleepSuppressionState = state; this->messageClients(KCmdFromState(state), (void *)mode); return true; } } else { if(mode == kNoSleepModeAC) { acSleepSuppressionState = state; this->messageClients(KCmdFromState(state), (void *)mode); return true; } } } isSleepStateInitialized = true; IOLog("%s: setting state: %d, for mode: %d (%s-mode)\n", getName(), state, mode, isOnAC?"ac":"battery"); NoSleepState oldState = getCurrentSleepSuppressionState(); if(forceClientMessage || oldState != state) { forceClientMessage = false; this->messageClients(KCmdFromState(state), (void *)kNoSleepModeCurrent); setCurrentSleepSuppressionState(state); } switch (getCurrentSleepSuppressionState()) { case kNoSleepStateEnabled: pRootDomain->receivePowerNotification(kIOPMDisableClamshell); break; case kNoSleepStateDisabled: thread_call_cancel(delayTimer); setUserSleepDisabled(false); pRootDomain->receivePowerNotification(kIOPMEnableClamshell); break; default: return false; } return true; }
void darwin_iwi3945::queue_td(int num , thread_call_func_t func) { //IWI_DEBUG("queue_td0 %d\n",tlink[num]); //IWI_DEBUG("queue_td0 %d\n",tlink[num]); if (tlink[num]) { thread_call_cancel(tlink[num]); /*if (thread_call_cancel(tlink[num])==0) thread_call_free(tlink[num]); tlink[num]=NULL;*/ } //IWI_DEBUG("queue_td1-%d , %d %d\n",num,r,r1); }
void OSMetaClass::considerUnloads() { static thread_call_t unloadCallout; AbsoluteTime when; mutex_lock(loadLock); if (!unloadCallout) unloadCallout = thread_call_allocate(&_OSMetaClassConsiderUnloads, 0); thread_call_cancel(unloadCallout); clock_interval_to_deadline(sConsiderUnloadDelay, 1000 * 1000 * 1000, &when); thread_call_enter_delayed(unloadCallout, when); mutex_unlock(loadLock); }
__private_extern__ void devtimer_cancel(devtimer_ref timer) { if (timer->dt_timeout_func != NULL) { timer->dt_timeout_func = NULL; if (timer->dt_callout != NULL) { _devtimer_printf("devtimer: cancelling timer source\n"); if (thread_call_cancel(timer->dt_callout)) { devtimer_release(timer); } else { _devtimer_printf("devtimer: delayed release\n"); } } } return; }
kern_return_t mk_timer_cancel_trap( struct mk_timer_cancel_trap_args *args) { mach_port_name_t name = args->name; mach_vm_address_t result_time_addr = args->result_time; uint64_t armed_time = 0; mk_timer_t timer; ipc_space_t myspace = current_space(); ipc_port_t port; kern_return_t result; result = ipc_port_translate_receive(myspace, name, &port); if (result != KERN_SUCCESS) return (result); if (ip_kotype(port) == IKOT_TIMER) { timer = (mk_timer_t)port->ip_kobject; assert(timer != NULL); simple_lock(&timer->lock); assert(timer->port == port); ip_unlock(port); if (timer->is_armed) { armed_time = timer->call_entry.deadline; if (thread_call_cancel(&timer->call_entry)) timer->active--; timer->is_armed = FALSE; } simple_unlock(&timer->lock); } else { ip_unlock(port); result = KERN_INVALID_ARGUMENT; } if (result == KERN_SUCCESS) if ( result_time_addr != 0 && copyout((void *)&armed_time, result_time_addr, sizeof (armed_time)) != 0 ) result = KERN_FAILURE; return (result); }
void IOHIKeyboard::stop(IOService * provider) { super::stop(provider); KeyboardReserved *tempReservedStruct = GetKeyboardReservedStructEventForService(this); if (tempReservedStruct) { thread_call_cancel(tempReservedStruct->repeat_thread_call); thread_call_free(tempReservedStruct->repeat_thread_call); tempReservedStruct->repeat_thread_call = NULL; if ( tempReservedStruct->keyboardNub ) tempReservedStruct->keyboardNub->release(); tempReservedStruct->keyboardNub = NULL; RemoveKeyboardReservedStructForService(this); } }
void NoSleepExtension::stop( IOService * provider ) { #ifdef DEBUG IOLog("%s[%p]::%s(%p)\n", getName(), this, __FUNCTION__, provider); #endif stopPM(); saveState(); setSleepSuppressionState(kNoSleepStateDisabled, kNoSleepModeCurrent); clamshellStateInterestNotifier->remove(); if(delayTimer) { thread_call_cancel(delayTimer); thread_call_free(delayTimer); } setUserSleepDisabled(false); IOLog("%s: successfully stopped\n", getName()); super::stop(provider); }
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(¤tTime); if ( CMP_ABSOLUTETIME(¤tTime, &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); }