Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


added void * argument to timer callback
[palacios.releases.git] / palacios / src / geekos / timer.c
index f9139bc..663a694 100644 (file)
@@ -2,6 +2,8 @@
  * GeekOS timer interrupt support
  * Copyright (c) 2001,2003 David H. Hovemeyer <daveho@cs.umd.edu>
  * Copyright (c) 2003, Jeffrey K. Hollingsworth <hollings@cs.umd.edu>
+ * (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
+ * (c) 2008, The V3VEE Project <http://www.v3vee.org> 
  * $Revision: 1.11 $
  * 
  * This is free software.  You are permitted to use,
@@ -18,7 +20,7 @@
 #include <geekos/serial.h>
 #include <geekos/debug.h>
 
-#include <geekos/io_crap.h>
+#include <geekos/io_defs.h>
 
 /* PAD this currently is in nvram.c */
 extern void deliver_timer_interrupt_to_vmm(uint_t period_us);
@@ -190,7 +192,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,7 +338,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;
 
@@ -348,6 +363,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++;
@@ -356,7 +372,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 +387,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;