2021-07-26 09:17:52 +00:00
|
|
|
#include "pit.h"
|
2021-07-26 12:15:21 +00:00
|
|
|
#include "io.h"
|
|
|
|
#include "stdio.h"
|
|
|
|
|
|
|
|
static unsigned long ticks = 0;
|
2021-07-26 09:17:52 +00:00
|
|
|
|
|
|
|
void pit_handler(void)
|
|
|
|
{
|
2021-07-26 12:15:21 +00:00
|
|
|
++ticks;
|
2021-07-26 09:17:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned long gettick(void)
|
|
|
|
{
|
2021-07-26 12:15:21 +00:00
|
|
|
return ticks;
|
|
|
|
}
|
|
|
|
|
|
|
|
void init_pit(void)
|
|
|
|
{
|
|
|
|
outb(PIT_CONTROL_REG, PIT_MODE_2 | PIT_RW_LSB | PIT_RW_MSB);
|
|
|
|
|
|
|
|
outb(PIT_COUNTER_0, PIT_DIVIDER & 0xff);
|
|
|
|
outb(PIT_COUNTER_0, PIT_DIVIDER >> 8);
|
2021-07-26 09:17:52 +00:00
|
|
|
}
|