OBJ += binary.o bin/elf.o
OBJ += vfs/main.o vfs/open.o vfs/acls.o vfs/dir.o vfs/io.o vfs/mount.o vfs/memfile.o vfs/nodecache.o
OBJ += vfs/fs/root.o vfs/fs/devfs.o vfs/fs/fat.o
-OBJ += drv/fifo.o drv/pci.o drv/ata_x86.o drv/vterm.o drv/vga.o drv/kb.o
+OBJ += drv/dma.o drv/fifo.o drv/pci.o drv/ata_x86.o drv/vterm.o drv/vga.o drv/kb.o drv/fdd.o
OBJ := $(addsuffix .$(ARCH), $(OBJ))
BIN = ../Acess2.$(ARCH).bin
#include <common.h>
// === MACROS ===
+#define NUM_TIMERS 8
+#define TIMER_QUANTUM 100
#define TIMER_FREQ 1024 //Hz
#define MS_PER_TICK_WHOLE (1000/(TIMER_FREQ))
#define MS_PER_TICK_FRACT ((Uint64)(1000*TIMER_FREQ-((Uint64)MS_PER_TICK_WHOLE)*0x80000000/TIMER_FREQ))
+// === TYPEDEFS ===
+typedef struct sTimer {
+ int FiresAfter;
+ void (*Callback)(void*);
+ void *Argument;
+} tTimer;
+
// === PROTOTYPES ===
void Time_Interrupt();
+void Timer_CallTimers();
// === GLOBALS ===
Uint64 giTicks = 0;
Sint64 giTimestamp = 0;
Uint64 giPartMiliseconds = 0;
+tTimer gTimers[NUM_TIMERS];
// === CODE ===
/**
giTimestamp ++;
giPartMiliseconds -= 0x80000000;
}
+
+ Timer_CallTimers();
+}
+
+/**
+ * \fn void Time_TimerThread()
+ */
+#if 0
+void Time_TimerThread()
+{
+ Sint64 next;
+ Threads_SetName("TIMER");
+
+ next = giTimestamp + TIMER_QUANTUM;
+ for(;;)
+ {
+ while(giTimestamp < next) Threads_Yield();
+ next = giTimestamp + TIMER_QUANTUM;
+ Timer_CallTimers();
+ }
}
+#endif
/**
* \fn Sint64 now()
{
return giTimestamp;
}
+
+/**
+ * \fn void Timer_CallTimers()
+ */
+void Timer_CallTimers()
+{
+ int i;
+ void (*callback)(void *);
+
+ for(i = 0;
+ i < NUM_TIMERS;
+ i ++)
+ {
+ if(gTimers[i].Callback == NULL) continue;
+ if(giTimestamp < gTimers[i].FiresAfter) continue;
+ callback = gTimers[i].Callback;
+ gTimers[i].Callback = NULL;
+ callback(gTimers[i].Argument);
+ }
+}
+
+/**
+ * \fn int Time_CreateTimer(int Delta, void *Callback, void *Argument)
+ */
+int Time_CreateTimer(int Delta, void *Callback, void *Argument)
+{
+ int ret;
+ 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;
+ 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;
+ while(dest < giTimestamp) Threads_Yield();
+}
// --- Timing ---
extern Sint64 timestamp(int sec, int mins, int hrs, int day, int month, int year);
extern Sint64 now();
+extern int Time_CreateTimer(int Delta, void *Callback, void *Argument);
+extern void Time_RemoveTimer(int ID);
+extern void Time_Delay(int Delay);
// --- Threads ---
extern int Proc_Spawn(char *Path);
extern void Threads_Exit();