void __xntimer_init(struct xntimer *timer, struct xnclock *clock, void (*handler)(struct xntimer *timer), struct xnsched *sched, int flags) { spl_t s __maybe_unused; int cpu; #ifdef CONFIG_XENO_OPT_EXTCLOCK timer->clock = clock; #endif xntimerh_init(&timer->aplink); xntimerh_date(&timer->aplink) = XN_INFINITE; xntimer_set_priority(timer, XNTIMER_STDPRIO); timer->status = (XNTIMER_DEQUEUED|(flags & XNTIMER_INIT_MASK)); timer->handler = handler; timer->interval_ns = 0; /* * Timers are affine to a scheduler slot, which is in turn * bound to a real-time CPU. If no scheduler affinity was * given, assign the timer to the scheduler slot of the * current CPU if real-time, otherwise default to the * scheduler slot of the first real-time CPU. */ if (sched) timer->sched = sched; else { cpu = ipipe_processor_id(); if (!xnsched_supported_cpu(cpu)) cpu = first_cpu(xnsched_realtime_cpus); timer->sched = xnsched_struct(cpu); } #ifdef CONFIG_XENO_OPT_STATS #ifdef CONFIG_XENO_OPT_EXTCLOCK timer->tracker = clock; #endif ksformat(timer->name, XNOBJECT_NAME_LEN, "%d/%s", current->pid, current->comm); xntimer_reset_stats(timer); xnlock_get_irqsave(&nklock, s); list_add_tail(&timer->next_stat, &clock->timerq); clock->nrtimers++; xnvfile_touch(&clock->timer_vfile); xnlock_put_irqrestore(&nklock, s); #endif /* CONFIG_XENO_OPT_STATS */ }
void __xntimer_init(xntimer_t *timer, xntbase_t *base, void (*handler) (xntimer_t *timer)) { /* CAUTION: Setup from xntimer_init() must not depend on the periodic/aperiodic timing mode. */ xntimerh_init(&timer->aplink); xntimerh_date(&timer->aplink) = XN_INFINITE; #ifdef CONFIG_XENO_OPT_TIMING_PERIODIC timer->base = base; xntlholder_init(&timer->plink); xntlholder_date(&timer->plink) = XN_INFINITE; #endif /* CONFIG_XENO_OPT_TIMING_PERIODIC */ xntimer_set_priority(timer, XNTIMER_STDPRIO); timer->status = XNTIMER_DEQUEUED; timer->handler = handler; timer->interval = 0; timer->sched = xnpod_current_sched(); #ifdef CONFIG_XENO_OPT_STATS { spl_t s; if (!xnpod_current_thread() || xnpod_shadow_p()) snprintf(timer->name, XNOBJECT_NAME_LEN, "%d/%s", current->pid, current->comm); else xnobject_copy_name(timer->name, xnpod_current_thread()->name); inith(&timer->tblink); xnstat_counter_set(&timer->scheduled, 0); xnstat_counter_set(&timer->fired, 0); xnlock_get_irqsave(&nklock, s); appendq(&base->timerq, &timer->tblink); base->timerq_rev++; xnlock_put_irqrestore(&nklock, s); } #endif /* CONFIG_XENO_OPT_TIMING_PERIODIC */ xnarch_init_display_context(timer); }