24 lines
356 B
C
24 lines
356 B
C
#include "pit.h"
|
|
#include "io.h"
|
|
#include "stdio.h"
|
|
|
|
static unsigned long ticks = 0;
|
|
|
|
void pit_handler(void)
|
|
{
|
|
++ticks;
|
|
}
|
|
|
|
unsigned long gettick(void)
|
|
{
|
|
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);
|
|
}
|