X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fgeekos%2Ftimer.c;h=e287b6e21b8d12fd86be97e58b1f55c7934712cb;hb=7617d3cee4bd93b90558206b1bb1681c07f0396a;hp=d3d4a6a9c45ec7f1fd28d6abd581a65ab79bed6c;hpb=56f8088296ee4116a4811a2f4f843edd80a7748d;p=palacios.git diff --git a/palacios/src/geekos/timer.c b/palacios/src/geekos/timer.c index d3d4a6a..e287b6e 100644 --- a/palacios/src/geekos/timer.c +++ b/palacios/src/geekos/timer.c @@ -23,7 +23,9 @@ #include /* PAD this currently is in nvram.c */ +/* JRL: This is completely broken extern void deliver_timer_interrupt_to_vmm(uint_t period_us); +*/ /* JRL Add a cpu frequency measurement */ uint_t cpu_khz_freq; @@ -192,7 +194,7 @@ static void Timer_Interrupt_Handler(struct Interrupt_State* state) if (pendingTimerEvents[i].ticks == 0) { if (timerDebug) Print("timer: event %d expired (%d ticks)\n", pendingTimerEvents[i].id, pendingTimerEvents[i].origTicks); - (pendingTimerEvents[i].callBack)(pendingTimerEvents[i].id); + (pendingTimerEvents[i].callBack)(pendingTimerEvents[i].id, pendingTimerEvents[i].cb_arg); pendingTimerEvents[i].ticks = pendingTimerEvents[i].origTicks; } else { pendingTimerEvents[i].ticks--; @@ -217,9 +219,9 @@ static void Timer_Interrupt_Handler(struct Interrupt_State* state) } - + /* JRL: Broken, deliver_timer_interrupt_to_vmm(1000000/HZ); - + */ End_IRQ(state); } @@ -338,7 +340,20 @@ void Init_Timer(void) } -int Start_Timer(int ticks, timerCallback cb) +int Start_Timer_Secs(int seconds, timerCallback cb, void * arg) { + return Start_Timer(seconds * HZ, cb, arg); +} + + +int Start_Timer_MSecs(int msecs, timerCallback cb, void * arg) { + msecs += 10 - (msecs % 10); + + return Start_Timer(msecs * (HZ / 1000), cb, arg); +} + + + +int Start_Timer(int ticks, timerCallback cb, void * arg) { int ret; @@ -350,6 +365,7 @@ int Start_Timer(int ticks, timerCallback cb) ret = nextEventID++; pendingTimerEvents[timeEventCount].id = ret; pendingTimerEvents[timeEventCount].callBack = cb; + pendingTimerEvents[timeEventCount].cb_arg = arg; pendingTimerEvents[timeEventCount].ticks = ticks; pendingTimerEvents[timeEventCount].origTicks = ticks; timeEventCount++; @@ -358,7 +374,8 @@ int Start_Timer(int ticks, timerCallback cb) } } -int Get_Remaing_Timer_Ticks(int id) + +int Get_Remaining_Timer_Ticks(int id) { int i; @@ -372,6 +389,19 @@ int Get_Remaing_Timer_Ticks(int id) return -1; } + + +double Get_Remaining_Timer_Secs(int id) { + return (Get_Remaining_Timer_Ticks(id) / HZ); +} + + +int Get_Remaining_Timer_MSecs(int id) { + return ((Get_Remaining_Timer_Ticks(id) * 1000) / HZ); +} + + + int Cancel_Timer(int id) { int i; @@ -411,3 +441,6 @@ void Micro_Delay(int us) Spin(numSpins); } + + +