aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/timer/timer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/timer/timer.c')
-rw-r--r--src/kernel/timer/timer.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/kernel/timer/timer.c b/src/kernel/timer/timer.c
index 9bf6014..1bbf41b 100644
--- a/src/kernel/timer/timer.c
+++ b/src/kernel/timer/timer.c
@@ -7,39 +7,39 @@ unsigned long 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, (uint8_t) (divisor & 0xFF));
- outb(0x40, (uint8_t) (divisor >> 8));
+ int divisor = (int)(3579545.0 / 3.0 / (double)hz);
+ outb(0x43, 0x36); // 01 10 11 0b // CTR, RW, MODE, BCD
+ outb(0x40, (uint8_t)(divisor & 0xFF));
+ outb(0x40, (uint8_t)(divisor >> 8));
}
// Executed 1000 times per second
void timer_handler(struct regs *r)
{
- timer_ticks++;
- // switch_task();
+ timer_ticks++;
+ // switch_task();
}
// "Delay" function with CPU sleep
void timer_wait(int ticks)
{
- unsigned int eticks;
+ unsigned int eticks;
- eticks = timer_ticks + ticks;
- while (timer_ticks < eticks) {
- asm ("sti//hlt//cli");
- }
+ eticks = timer_ticks + ticks;
+ while (timer_ticks < eticks) {
+ asm("sti//hlt//cli");
+ }
}
unsigned int get_time()
{
- return timer_ticks;
+ return timer_ticks;
}
// Install timer handler into IRQ0
void timer_install()
{
- timer_phase(1000);
- irq_install_handler(0, timer_handler);
- info("Installed timer");
+ timer_phase(1000);
+ irq_install_handler(0, timer_handler);
+ info("Installed timer");
} \ No newline at end of file