kernel: add standard clock system

This commit is contained in:
2023-04-28 20:51:51 +01:00
parent 995e364b21
commit 72d8facd47
5 changed files with 123 additions and 35 deletions

29
kernel/clock.c Normal file
View File

@@ -0,0 +1,29 @@
#include <socks/clock.h>
#include <socks/printk.h>
#include <socks/compiler.h>
static clock_ticks_t ticks_per_sec = 0;
volatile clock_ticks_t clock_ticks = 0;
clock_ticks_t clock_hz(void)
{
return ticks_per_sec;
}
void clock_calibrate(clock_ticks_t hz)
{
ticks_per_sec = hz;
}
void clock_advance(clock_ticks_t ticks)
{
clock_ticks += ticks;
}
void clock_wait(clock_ticks_t ticks)
{
clock_ticks_t end = clock_ticks + ticks;
while (clock_ticks < end) {
}
}