X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fgeekos%2Ftimer.c;h=0e3804f2421e935a22dcd768caf67011411ff8b1;hb=3fb8af7e2069d7517b5d6c4fb7dc04b22ddf8396;hp=f9139bc10ea4e413ffec83c35b6a6f4303d93604;hpb=eb7dda8d4a92a2e8d0c8f867c65317d756ca6c11;p=palacios.releases.git diff --git a/palacios/src/geekos/timer.c b/palacios/src/geekos/timer.c index f9139bc..0e3804f 100644 --- a/palacios/src/geekos/timer.c +++ b/palacios/src/geekos/timer.c @@ -2,6 +2,8 @@ * GeekOS timer interrupt support * Copyright (c) 2001,2003 David H. Hovemeyer * Copyright (c) 2003, Jeffrey K. Hollingsworth + * (c) 2008, Jack Lange + * (c) 2008, The V3VEE Project * $Revision: 1.11 $ * * This is free software. You are permitted to use, @@ -18,7 +20,7 @@ #include #include -#include +#include /* PAD this currently is in nvram.c */ extern void deliver_timer_interrupt_to_vmm(uint_t period_us); @@ -129,11 +131,6 @@ timerEvent pendingTimerEvents[MAX_TIMER_EVENTS]; */ volatile ulong_t g_numTicks; -ulong_t clock_time(void){ - return g_numTicks; -} - - /* * Number of times the spin loop can execute during one timer tick */ @@ -169,6 +166,10 @@ int g_Quantum = DEFAULT_MAX_TICKS; # define Debug(args...) #endif +ulong_t clock_time(void){//in millisec + return g_numTicks * (1000/HZ); +} + /* ---------------------------------------------------------------------- * Private functions * ---------------------------------------------------------------------- */ @@ -190,7 +191,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--; @@ -336,18 +337,34 @@ 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; KASSERT(!Interrupts_Enabled()); + PrintBoth ("there\n"); + if (timeEventCount == MAX_TIMER_EVENTS) { return -1; } else { ret = nextEventID++; pendingTimerEvents[timeEventCount].id = ret; pendingTimerEvents[timeEventCount].callBack = cb; + pendingTimerEvents[timeEventCount].cb_arg = arg; pendingTimerEvents[timeEventCount].ticks = ticks; pendingTimerEvents[timeEventCount].origTicks = ticks; timeEventCount++; @@ -356,7 +373,8 @@ int Start_Timer(int ticks, timerCallback cb) } } -int Get_Remaing_Timer_Ticks(int id) + +int Get_Remaining_Timer_Ticks(int id) { int i; @@ -370,6 +388,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; @@ -409,3 +440,6 @@ void Micro_Delay(int us) Spin(numSpins); } + + +