X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Farch%2Fx86%2Ftime.c;h=cdf23705909f5d1d7d1c89dc1eeb759c8a33f6eb;hb=5beb98670f040b2d4e697e4d8690cd46d2d30cf3;hp=9248bd12f5337e21c361679f8bb530223889fbe8;hpb=abecaa9215f064b5b5631852fd809b63f1379c93;p=tpg%2Facess2.git diff --git a/Kernel/arch/x86/time.c b/Kernel/arch/x86/time.c index 9248bd12..cdf23705 100644 --- a/Kernel/arch/x86/time.c +++ b/Kernel/arch/x86/time.c @@ -3,12 +3,14 @@ * Timekeeping * arch/x86/time.c */ -#include +#include // === MACROS === #define NUM_TIMERS 8 #define TIMER_QUANTUM 100 -#define TIMER_FREQ 1024 //Hz +// 2^(15-rate), 15: 1HZ, 5: 1024Hz, 2: 8192Hz +#define TIMER_RATE 12 // (Max: 15, Min: 2) - 15 = 1Hz, 13 = 4Hz, 12 = 8Hz, 11 = 16Hz 10 = 32Hz, 2 +#define TIMER_FREQ (0x8000>>TIMER_RATE) //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)) @@ -41,6 +43,14 @@ int Time_Setup() outb(0x70, inb(0x70)&0x7F); // Disable NMIs __asm__ __volatile__ ("cli"); // Disable normal interrupts + // Set IRQ8 firing rate + outb(0x70, 0x0A); // Set the index to register A + val = inb(0x71); // Get the current value of register A + outb(0x70, 0x0A); // Reset index to A + val &= 0xF0; + val |= TIMER_RATE; + outb(0x71, val); // Update the timer rate + // Enable IRQ8 outb(0x70, 0x0B); // Set the index to register B val = inb(0x71); // Read the current value of register B @@ -78,10 +88,10 @@ void Time_Interrupt() inb(0x71); // Just throw away contents. } +#if 0 /** * \fn void Time_TimerThread() */ -#if 0 void Time_TimerThread() { Sint64 next; @@ -118,9 +128,7 @@ void Timer_CallTimers() i < NUM_TIMERS; i ++) { - //Log("Timer %i", i); if(gTimers[i].Callback == NULL) continue; - Log("%i - %lli < %lli", i, giTimestamp, gTimers[i].FiresAfter); if(giTimestamp < gTimers[i].FiresAfter) continue; callback = gTimers[i].Callback; gTimers[i].Callback = NULL; @@ -145,8 +153,8 @@ int Time_CreateTimer(int Delta, void *Callback, void *Argument) 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); + //Log("Callback = %p", Callback); + //Log("Timer %i fires at %lli", ret, gTimers[ret].FiresAfter); return ret; } return -1; @@ -170,3 +178,9 @@ void Time_Delay(int Delay) Sint64 dest = giTimestamp + Delay; while(dest < giTimestamp) Threads_Yield(); } + +// === EXPORTS === +EXPORT(now); +EXPORT(Time_CreateTimer); +EXPORT(Time_RemoveTimer); +EXPORT(Time_Delay);