1
0
Fork 0
mirror of https://github.com/tailix/kernel.git synced 2024-10-30 12:03:52 -04:00
kernel/arch/x86/timer.c

29 lines
552 B
C
Raw Normal View History

2017-11-03 00:19:48 -04:00
#include "timer.h"
#include "logger.h"
#include "asm.h"
void timer_initialize(unsigned int frequency)
{
2017-11-05 23:21:18 -05:00
logger_info_from("timer", "Initialize timer.");
2017-11-03 00:19:48 -04:00
2017-11-03 00:31:23 -04:00
const unsigned int divisor = 1193180 / frequency;
const unsigned char l = divisor & 0xFF;
const unsigned char h = (divisor >> 8) & 0xFF;
2017-11-03 00:19:48 -04:00
outportb(0x43, 0x36);
2017-11-03 00:31:23 -04:00
outportb(0x40, l);
outportb(0x40, h);
2017-11-03 00:19:48 -04:00
}
2017-11-03 01:10:07 -04:00
void timer_register_handler(timer_handler_t handler)
{
hwint_register_handler(0, handler);
}
void timer_unregister_handler()
{
hwint_unregister_handler(0);
}