11#include "actimer_internal.h"
15int acTimerAdd(
acTimerT timer, acTimerDone done,
void *arg,
unsigned int us)
33 USec2SysClock(us, &t);
34 timer->t_deadline = t.lo | ((acUint64)(t.hi) << 32);
36 timer->t_deadline += t.lo | ((acUint64)(t.hi) << 32);
38 q_prev = Timerc.waitq.q_prev;
39 timer->t_chain.q_next = (
acQueueT)&Timerc;
40 timer->t_chain.q_prev = q_prev;
41 q_prev->q_next = &timer->t_chain;
42 Timerc.waitq.q_prev = &timer->t_chain;
60 if ( timer->t_deadline )
62 _next_ = timer->t_chain.q_next;
63 _prev_ = timer->t_chain.q_prev;
64 _prev_->q_next = _next_;
65 _next_->q_prev = _prev_;
71static unsigned int timer_handler(
void *arg)
84 memcpy(¤t, &v9,
sizeof(v9));
85 if ( argt->tick == 0 )
89 timer = (
acTimerT)argt->waitq.q_next;
93 if ( current >= timer->t_deadline )
95 q_prev = timer->t_chain.q_prev;
96 q_prev->q_next = &q_next->t_chain;
97 q_next->t_chain.q_prev = q_prev;
98 t_done = timer->t_done;
100 timer->t_deadline = 0LL;
101 t_done(timer, t_arg);
108int acTimerModuleStart(
int argc,
char **argv)
121 tick = strtol(argv[1], &next, 10);
122 if ( next == argv[1] )
126 else if ( tick < 1000 )
132 Timerc.waitq.q_prev = (
acQueueT)&Timerc;
133 Timerc.waitq.q_next = (
acQueueT)&Timerc;
134 USec2SysClock(tick, &t);
135 v5 = SetAlarm(&t, timer_handler, &Timerc);
141 CancelAlarm(timer_handler, &Timerc);
142 SetAlarm(&t, timer_handler, &Timerc);
145 memcpy(&(Timerc.tick), &t,
sizeof(t));
149int acTimerModuleStop()
153 CancelAlarm(timer_handler, &Timerc);
159int acTimerModuleRestart(
int argc,
char **argv)
167int acTimerModuleStatus()
169 return Timerc.tick != 0;
int CpuResumeIntr(int state)
int CpuSuspendIntr(int *state)