separating: there will be libk and libc
This commit is contained in:
38
drivers/timer.c
Normal file
38
drivers/timer.c
Normal file
@@ -0,0 +1,38 @@
|
||||
// Programmable Interval Timer channel 0 driver
|
||||
// Author: xamidev
|
||||
// Licensed under the Unlicense. See the repo below.
|
||||
// https://github.com/xamidev/blankos
|
||||
|
||||
#include "../kernel/system.h"
|
||||
#include "../libk/stdio.h"
|
||||
|
||||
volatile unsigned long global_ticks = 0;
|
||||
|
||||
void timer_handler()
|
||||
{
|
||||
global_ticks++;
|
||||
if (global_ticks % 20 == 0)
|
||||
{
|
||||
draw_cursor(white);
|
||||
} else if (global_ticks % 20 == 10) {
|
||||
erase_cursor();
|
||||
}
|
||||
}
|
||||
|
||||
void timer_install()
|
||||
{
|
||||
irq_install_handler(0, timer_handler);
|
||||
printf("[timer] initialized, starting g_ticks...\n");
|
||||
}
|
||||
|
||||
void delay(int ticks)
|
||||
{
|
||||
unsigned long eticks;
|
||||
eticks = global_ticks + ticks;
|
||||
while (global_ticks < eticks);
|
||||
}
|
||||
|
||||
int uptime()
|
||||
{
|
||||
return global_ticks;
|
||||
}
|
||||
Reference in New Issue
Block a user