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.


Merge branch 'lwip_dev' of ssh://palacios@newskysaw.cs.northwestern.edu/home/palacios...
Lei Xia [Mon, 29 Sep 2008 16:18:21 +0000 (11:18 -0500)]
1  2 
palacios/include/geekos/synch.h
palacios/include/geekos/timer.h
palacios/src/geekos/timer.c

@@@ -18,9 -18,9 +18,9 @@@
  enum { MUTEX_UNLOCKED, MUTEX_LOCKED };
  
  struct Mutex {
-     int state;
-     struct Kernel_Thread* owner;
-     struct Thread_Queue waitQueue;
+   int state;
+   struct Kernel_Thread* owner;
+   struct Thread_Queue waitQueue;
  };
  
  #define MUTEX_INITIALIZER { MUTEX_UNLOCKED, 0, THREAD_QUEUE_INITIALIZER }
@@@ -32,13 -32,12 +32,14 @@@ struct Condition 
  void Mutex_Init(struct Mutex* mutex);
  void Mutex_Lock(struct Mutex* mutex);
  void Mutex_Unlock(struct Mutex* mutex);
 +void Mutex_Destroy(struct Mutex *mutex);   //added by Lei, do some cleaning work?
  
  void Cond_Init(struct Condition* cond);
  void Cond_Wait(struct Condition* cond, struct Mutex* mutex);
+ int Cond_Wait_Timeout(struct Condition * cond, struct Mutex * mutex, uint_t ms);
  void Cond_Signal(struct Condition* cond);
  void Cond_Broadcast(struct Condition* cond);
 +void Cond_Destroy(struct Condition *cond); //added by Lei
  
  #define IS_HELD(mutex) \
      ((mutex)->state == MUTEX_LOCKED && (mutex)->owner == g_currentThread)
@@@ -16,7 -16,7 +16,7 @@@
  
  extern volatile ulong_t g_numTicks;
  
- typedef void (*timerCallback)(int);
+ typedef void (*timerCallback)(int, void*);
  
  void Init_Timer(void);
  
@@@ -24,21 -24,24 +24,23 @@@ 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);
  int Get_Remaining_Timer_Ticks(int id);
  int Cancel_Timer(int id);
  
 -
  void Micro_Delay(int us);
  
  #endif  /* GEEKOS_TIMER_H */
@@@ -192,7 -192,7 +192,7 @@@ static void Timer_Interrupt_Handler(str
      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 +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;
  
        ret = nextEventID++;
        pendingTimerEvents[timeEventCount].id = ret;
        pendingTimerEvents[timeEventCount].callBack = cb;
+       pendingTimerEvents[timeEventCount].cb_arg = arg;
        pendingTimerEvents[timeEventCount].ticks = ticks;
        pendingTimerEvents[timeEventCount].origTicks = ticks;
        timeEventCount++;
@@@ -438,6 -439,3 +439,6 @@@ void Micro_Delay(int us
  
      Spin(numSpins);
  }
 +
 +
 +