X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Ftime.c;h=b0ea5e4555cb7633e7599f0a16554808088cae25;hb=HEAD;hp=1180cad979fabc0d7133382ed0a51751e13a5ab1;hpb=df1d534cfe822903fc38e1cc13c4b18941c91908;p=tpg%2Facess2.git diff --git a/Kernel/time.c b/Kernel/time.c deleted file mode 100644 index 1180cad9..00000000 --- a/Kernel/time.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Acess 2 - * - By John Hodge (thePowersGang) - * - * Timer Code - */ -#include - -// === CONSTANTS === -#define NUM_TIMERS 8 - -// === TYPEDEFS === -typedef struct sTimer { - int FiresAfter; - void (*Callback)(void*); - void *Argument; -} tTimer; - -// === PROTOTYPES === -void Timer_CallTimers(void); - -// === GLOBALS === -volatile Uint64 giTicks = 0; -volatile Sint64 giTimestamp = 0; -volatile Uint64 giPartMiliseconds = 0; -tTimer gTimers[NUM_TIMERS]; // TODO: Replace by a ring-list timer - -// === CODE === -/** - * \fn void Timer_CallTimers() - */ -void Timer_CallTimers() -{ - int i; - void (*callback)(void *); - void *arg; - - for(i = 0; i < NUM_TIMERS; i ++) - { - if(gTimers[i].Callback == NULL) continue; - if(giTimestamp < gTimers[i].FiresAfter) continue; - callback = gTimers[i].Callback; arg = gTimers[i].Argument; - gTimers[i].Callback = NULL; - callback(arg); - } -} - -/** - * \fn int Time_CreateTimer(int Delta, tTimerCallback *Callback, void *Argument) - */ -int Time_CreateTimer(int Delta, tTimerCallback *Callback, void *Argument) -{ - int ret; - - if(Callback == NULL) return -1; - - for(ret = 0; - ret < NUM_TIMERS; - ret++) - { - if(gTimers[ret].Callback != NULL) continue; - gTimers[ret].Callback = Callback; - gTimers[ret].FiresAfter = giTimestamp + Delta; - gTimers[ret].Argument = Argument; - //Log("Callback = %p", Callback); - //Log("Timer %i fires at %lli", ret, gTimers[ret].FiresAfter); - return ret; - } - return -1; -} - -/** - * \fn void Time_RemoveTimer(int ID) - */ -void Time_RemoveTimer(int ID) -{ - if(ID < 0 || ID >= NUM_TIMERS) return; - gTimers[ID].Callback = NULL; -} - -/** - * \fn void Time_Delay(int Delay) - * \brief Delay for a small ammount of time - */ -void Time_Delay(int Delay) -{ - Sint64 dest = giTimestamp + Delay; - //Log("Time_Delay: dest = %lli", dest); - while(dest > giTimestamp) Threads_Yield(); - //Log("Time_Delay: giTimestamp = %lli", giTimestamp); -} - -// === EXPORTS === -EXPORT(Time_CreateTimer); -EXPORT(Time_RemoveTimer); -EXPORT(Time_Delay);