X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;ds=sidebyside;f=Kernel%2Farch%2Fx86%2Ftime.c;h=9cccec7c7ac43a21e23301775f90bf3f11f76a0a;hb=b6c3b3cf61caafbd91bbf3acc81995e472656a5b;hp=4cfa280daaf1ebd694582656b105a0c1650d6b68;hpb=466eda7c917791866a29c253c6c22197faf41bf7;p=tpg%2Facess2.git diff --git a/Kernel/arch/x86/time.c b/Kernel/arch/x86/time.c index 4cfa280d..9cccec7c 100644 --- a/Kernel/arch/x86/time.c +++ b/Kernel/arch/x86/time.c @@ -8,7 +8,8 @@ // === MACROS === #define NUM_TIMERS 8 #define TIMER_QUANTUM 100 -#define TIMER_FREQ 1024 //Hz +#define TIMER_RATE 13 // (Max: 15, Min: 2) - 15 = 1Hz, 13 = 4Hz, 10 = 1024Hz +#define TIMER_FREQ (32768>>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 +42,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 @@ -69,9 +78,13 @@ void Time_Interrupt() giPartMiliseconds -= 0x80000000; } - Log("giTimestamp = %lli", giTimestamp); + //Log("giTimestamp = %lli", giTimestamp); - Timer_CallTimers(); + //Timer_CallTimers(); + + // Make sure the RTC Fires again + outb(0x70, 0x0C); // Select register C + inb(0x71); // Just throw away contents. } /** @@ -114,7 +127,7 @@ void Timer_CallTimers() i < NUM_TIMERS; i ++) { - Log("%i", 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;