From: Jack Lange Date: Fri, 26 Sep 2008 21:48:27 +0000 (-0500) Subject: added second and millisecond timer support X-Git-Tag: 1.0~3^2~24 X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=d1eb5efb0a6b8b3a1dfd5d1eb944bbe2a20cf95a;p=palacios-OLD.git added second and millisecond timer support --- diff --git a/palacios/include/geekos/timer.h b/palacios/include/geekos/timer.h index 768a31b..7fb783d 100644 --- a/palacios/include/geekos/timer.h +++ b/palacios/include/geekos/timer.h @@ -30,8 +30,13 @@ typedef struct { int origTicks; } timerEvent; +int Start_Timer_Secs(int seconds, timerCallback cb); +int Start_Timer_MSecs(int msecs, timerCallback cb); int Start_Timer(int ticks, timerCallback); -int Get_Remaing_Timer_Ticks(int id); + +double Get_Remaining_Timer_Secs(int id); +int Get_Remaining_Timer_MSecs(int id); +int Get_Remaining_Timer_Ticks(int id); int Cancel_Timer(int id); diff --git a/palacios/src/geekos/timer.c b/palacios/src/geekos/timer.c index d3d4a6a..7f4ab49 100644 --- a/palacios/src/geekos/timer.c +++ b/palacios/src/geekos/timer.c @@ -338,6 +338,19 @@ void Init_Timer(void) } +int Start_Timer_Secs(int seconds, timerCallback cb) { + return Start_Timer(seconds * HZ, cb); +} + + +int Start_Timer_MSecs(int msecs, timerCallback cb) { + msecs += 10 - (msecs % 10); + + return Start_Timer(msecs * (HZ / 1000), cb); +} + + + int Start_Timer(int ticks, timerCallback cb) { int ret; @@ -358,7 +371,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 +386,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;