aboutsummaryrefslogtreecommitdiff
path: root/kernel/drivers/timer.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/drivers/timer.c')
-rw-r--r--kernel/drivers/timer.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/kernel/drivers/timer.c b/kernel/drivers/timer.c
index 17a8991..766512f 100644
--- a/kernel/drivers/timer.c
+++ b/kernel/drivers/timer.c
@@ -3,8 +3,10 @@
#include <cpu.h>
#include <def.h>
#include <interrupts.h>
+#include <proc.h>
static u32 timer_ticks = 0;
+static u8 call_scheduler = 0;
void timer_phase(int hz)
{
@@ -19,12 +21,15 @@ u32 timer_get(void)
return timer_ticks;
}
-void timer_handler()
+void timer_handler(struct regs *r)
{
if (timer_ticks >= U32_MAX)
timer_ticks = 0;
else
timer_ticks++;
+
+ if (call_scheduler)
+ scheduler(r);
}
// "Delay" function with CPU sleep
@@ -44,3 +49,15 @@ void timer_install(void)
timer_phase(1000);
irq_install_handler(0, timer_handler);
}
+
+void scheduler_enable(void)
+{
+ call_scheduler = 1;
+ irq_install_handler(0, timer_handler);
+}
+
+void scheduler_disable(void)
+{
+ call_scheduler = 0;
+ irq_install_handler(0, timer_handler);
+}