aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/timer
diff options
context:
space:
mode:
authorMarvin Borner2020-06-17 18:31:46 +0200
committerMarvin Borner2020-06-17 18:31:46 +0200
commiteed77bd2970a00d1394ed027ceca5b646e4671ce (patch)
treec44643d98aed2b6818f2b33417c0dea9c5853094 /src/kernel/timer
parent49dfa1f4021026bf7c4d77817959c8aa24067016 (diff)
Started rewrite
Diffstat (limited to 'src/kernel/timer')
-rw-r--r--src/kernel/timer/timer.c44
-rw-r--r--src/kernel/timer/timer.h26
2 files changed, 0 insertions, 70 deletions
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 <interrupts/interrupts.h>
-#include <io/io.h>
-#include <stdint.h>
-#include <system.h>
-
-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
diff --git a/src/kernel/timer/timer.h b/src/kernel/timer/timer.h
deleted file mode 100644
index 7b0401e..0000000
--- a/src/kernel/timer/timer.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef MELVIX_TIMER_H
-#define MELVIX_TIMER_H
-
-#include <interrupts/interrupts.h>
-#include <stdint.h>
-
-void timer_handler(struct regs *r);
-
-/**
- * Install the timer and set the timer phase to 100
- */
-void timer_install();
-
-/**
- * Stop processing for specific duration
- * @param ticks The duration of sleeping in ticks
- */
-void timer_wait(int ticks);
-
-/**
- * Get the current timer ticks
- * @return The current timer ticks (1000 ticks = 1 second)
- */
-u32 get_time();
-
-#endif \ No newline at end of file