aboutsummaryrefslogtreecommitdiff
path: root/kernel/drivers
diff options
context:
space:
mode:
authorMarvin Borner2020-11-24 16:42:10 +0100
committerMarvin Borner2020-11-24 16:42:10 +0100
commit9257facb17bf74eb0eb1babfc59ff3549eb66242 (patch)
tree78af10bf8de91b4b8ecca878d5a358c79ae907b4 /kernel/drivers
parent0564c8006da7077064222d15a899b858ae2d7e61 (diff)
Fixed timer counting with yield()
Diffstat (limited to 'kernel/drivers')
-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);
+}