25 lines
391 B
C
25 lines
391 B
C
#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;
|
|
}
|