k-chow/k/events/pic/pit.c
Julien CLEMENT f6cdc3005d feat(pit): add pit initialization and handler
Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
2021-07-26 14:15:21 +02:00

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);
}