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)
|
|
|
|
{
|
2021-07-26 12:53:59 +00:00
|
|
|
return counter;
|
2021-07-17 09:56:34 +00:00
|
|
|
}
|