x86_64: init local apic on boot, or legacy pic/pit as fallback
This commit is contained in:
29
arch/x86_64/pit.c
Normal file
29
arch/x86_64/pit.c
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <socks/printk.h>
|
||||
#include <arch/ports.h>
|
||||
#include <arch/irq.h>
|
||||
|
||||
static int pit_callback(void)
|
||||
{
|
||||
printk("tick");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static irq_hook_t pit_irq_hook = {
|
||||
.irq_callback = pit_callback
|
||||
};
|
||||
|
||||
void pit_init(unsigned int hz)
|
||||
{
|
||||
unsigned int divisor = 1193180 / hz;
|
||||
|
||||
outportb(0x43, 0x36);
|
||||
uint8_t lo = (uint8_t)(divisor & 0xFF);
|
||||
uint8_t hi = (uint8_t)((divisor >> 8) & 0xFF);
|
||||
|
||||
outportb(0x40, lo);
|
||||
outportb(0x40, hi);
|
||||
|
||||
hook_irq(IRQ0, &pit_irq_hook);
|
||||
|
||||
printk("clock: 8253 PIT initialised at %uHz", hz);
|
||||
}
|
||||
Reference in New Issue
Block a user