From eed77bd2970a00d1394ed027ceca5b646e4671ce Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Wed, 17 Jun 2020 18:31:46 +0200 Subject: Started rewrite --- src/kernel/timer/timer.c | 44 -------------------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 src/kernel/timer/timer.c (limited to 'src/kernel/timer/timer.c') diff --git a/src/kernel/timer/timer.c b/src/kernel/timer/timer.c deleted file mode 100644 index 6f8ae85..0000000 --- a/src/kernel/timer/timer.c +++ /dev/null @@ -1,44 +0,0 @@ -#include -#include -#include -#include - -u64 timer_ticks = 0; - -void timer_phase(int hz) -{ - int divisor = (int)(3579545.0 / 3.0 / (double)hz); - outb(0x43, 0x36); // 01 10 11 0b // CTR, RW, MODE, BCD - outb(0x40, (u8)(divisor & 0xFF)); - outb(0x40, (u8)(divisor >> 8)); -} - -// Executed 1000 times per second -void timer_handler(struct regs *r) -{ - timer_ticks++; -} - -// "Delay" function with CPU sleep -void timer_wait(int ticks) -{ - u32 eticks; - - eticks = timer_ticks + ticks; - while (timer_ticks < eticks) { - asm("sti//hlt//cli"); - } -} - -u32 get_time() -{ - return timer_ticks; -} - -// Install timer handler into IRQ0 -void timer_install() -{ - timer_phase(1000); - irq_install_handler(0, timer_handler); - info("Installed timer"); -} \ No newline at end of file -- cgit v1.2.3