k-tana-zero/k/pic/pit.c

25 lines
391 B
C
Raw Normal View History

2021-07-17 09:56:34 +00:00
#include "io.h"
#include "pit.h"
static uint64_t counter = 0;
void pit_handler(void)
{
counter++;
}
void init_pit(void)
{
// write to control register
outb(PIT_CONTROL_REG, PIT_SET_COUNTER_0 | PIT_MODE_2 | PIT_RW_LSB_MSB);
// write frequency
outb(PIT_COUNTER_0, DIVIDER_LO);
outb(PIT_COUNTER_0, DIVIDER_HI);
}
uint64_t gettick(void)
{
return counter * 10;
}