aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/timer
diff options
context:
space:
mode:
authorMarvin Borner2019-11-24 23:34:32 +0100
committerMarvin Borner2019-11-24 23:34:32 +0100
commitbb57b124d1bb385d41747f50be7dd4f3625539c1 (patch)
treefe461afad63df40571784565e8d435cba8c8e59c /src/kernel/timer
parentf9c50b9ff23e9a3e8db5826fef7a6e7ebb8af21d (diff)
Major coding style reformatting -> Kernighan & Ritchie
This project now (hopefully) uses the same style recommended by Kernighan and Ritchie and used in the Linux Kernel
Diffstat (limited to 'src/kernel/timer')
-rw-r--r--src/kernel/timer/timer.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/kernel/timer/timer.c b/src/kernel/timer/timer.c
index 0e10c07..defb95d 100644
--- a/src/kernel/timer/timer.c
+++ b/src/kernel/timer/timer.c
@@ -4,35 +4,39 @@
unsigned long timer_ticks = 0;
-void timer_phase(int hz) {
+void timer_phase(int hz)
+{
int divisor = (int) (3579545.0 / 3.0 / (double) hz);
- send_b(0x43, 0x36); // 01 10 11 0b // CTR, RW, MODE, BCD
- send_b(0x40, divisor & 0xFF);
- send_b(0x40, divisor >> 8);
+ outb(0x43, 0x36); // 01 10 11 0b // CTR, RW, MODE, BCD
+ outb(0x40, divisor & 0xFF);
+ outb(0x40, divisor >> 8);
}
// Executed 1000 times per second
-void timer_handler(struct regs *r) {
+void timer_handler(struct regs *r)
+{
timer_ticks++;
}
// "Delay" function with CPU sleep
-void timer_wait(int ticks) {
+void timer_wait(int ticks)
+{
unsigned int eticks;
eticks = timer_ticks + ticks;
while (timer_ticks < eticks) {
- asm volatile ("sti//hlt//cli");
+ asm ("sti//hlt//cli");
}
}
-unsigned int get_time() {
+unsigned int get_time()
+{
return timer_ticks;
}
// Install timer handler into IRQ0
-void timer_install() {
+void timer_install()
+{
timer_phase(1000);
irq_install_handler(0, timer_handler);
- vga_log("Installed timer", 1);
} \ No newline at end of file