From: Jack Lange Date: Mon, 29 Sep 2008 15:46:45 +0000 (-0500) Subject: added void * argument to timer callback X-Git-Tag: 1.0~3^2~22 X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=734dfbecdb21f61f344ca092b99a957b58e49e52;p=palacios-OLD.git added void * argument to timer callback --- diff --git a/palacios/include/geekos/timer.h b/palacios/include/geekos/timer.h index 7fb783d..9b08713 100644 --- a/palacios/include/geekos/timer.h +++ b/palacios/include/geekos/timer.h @@ -16,7 +16,7 @@ extern volatile ulong_t g_numTicks; -typedef void (*timerCallback)(int); +typedef void (*timerCallback)(int, void*); void Init_Timer(void); @@ -24,15 +24,17 @@ void Micro_Delay(int us); typedef struct { - int ticks; /* timer code decrements this */ - int id; /* unqiue id for this timer even */ - timerCallback callBack; /* Queue to wakeup on timer expire */ - int origTicks; + int ticks; /* timer code decrements this */ + int id; /* unqiue id for this timer even */ + timerCallback callBack; /* Queue to wakeup on timer expire */ + void * cb_arg; /* Argument to add to callback */ + 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 Start_Timer_Secs(int seconds, timerCallback cb, void * arg); +int Start_Timer_MSecs(int msecs, timerCallback cb, void * arg); +int Start_Timer(int ticks, timerCallback, void * arg); double Get_Remaining_Timer_Secs(int id); int Get_Remaining_Timer_MSecs(int id); diff --git a/palacios/src/geekos/socket.c b/palacios/src/geekos/socket.c index 63b3ce1..661970e 100644 --- a/palacios/src/geekos/socket.c +++ b/palacios/src/geekos/socket.c @@ -28,7 +28,7 @@ void socket_appcall(void); static int Packet_Received(struct NE2K_Packet_Info* info, uchar_t *pkt); -static void periodic_caller(int timer_id); +static void periodic_caller(int timer_id, void * arg); void init_socket_layer() { int i = 0; @@ -52,7 +52,7 @@ void init_socket_layer() { Init_Ne2k(&Packet_Received); iflag = Begin_Int_Atomic(); - Start_Timer(2, periodic_caller); + Start_Timer(2, periodic_caller, NULL); End_Int_Atomic(iflag); } @@ -108,7 +108,7 @@ struct socket * get_socket_from_fd(int fd) { -static void periodic_caller(int timer_id) { +static void periodic_caller(int timer_id, void * arg) { int i; //handle the periodic calls of uIP diff --git a/palacios/src/geekos/timer.c b/palacios/src/geekos/timer.c index 7f4ab49..663a694 100644 --- a/palacios/src/geekos/timer.c +++ b/palacios/src/geekos/timer.c @@ -192,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--; @@ -338,20 +338,20 @@ void Init_Timer(void) } -int Start_Timer_Secs(int seconds, timerCallback cb) { - return Start_Timer(seconds * HZ, 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) { +int Start_Timer_MSecs(int msecs, timerCallback cb, void * arg) { msecs += 10 - (msecs % 10); - return Start_Timer(msecs * (HZ / 1000), cb); + return Start_Timer(msecs * (HZ / 1000), cb, arg); } -int Start_Timer(int ticks, timerCallback cb) +int Start_Timer(int ticks, timerCallback cb, void * arg) { int ret; @@ -363,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++;