33 lines
615 B
C
33 lines
615 B
C
/*#include <stdint.h>
|
|
#include <port_io.h>
|
|
#include <drivers/irq.h>
|
|
|
|
#define PIT_CHANNEL0 0x40
|
|
#define PIT_COMMAND 0x43
|
|
#define PIT_FREQUENCY 1193182
|
|
|
|
static uint32_t tick = 0;
|
|
|
|
void pit_callback(struct regs* r)
|
|
{
|
|
(void)r;
|
|
tick++;
|
|
}
|
|
|
|
void pit_init(uint32_t frequency)
|
|
{
|
|
uint32_t divisor = PIT_FREQUENCY / frequency;
|
|
|
|
outb(PIT_COMMAND, 0x36);
|
|
outb(PIT_CHANNEL0, (uint8_t)(divisor & 0xFF));
|
|
outb(PIT_CHANNEL0, (uint8_t)((divisor >> 8) & 0xFF));
|
|
|
|
register_interrupt_handler(32, pit_callback);
|
|
}
|
|
|
|
void sleep(uint32_t milliseconds)
|
|
{
|
|
uint32_t target = tick + milliseconds;
|
|
while (tick < target);
|
|
}*/
|