Orion
Barry Importing existing Orion kernel d41a53c (3 years, 3 months ago)
/*
* This file deals with the Programmable Interrupt Controller. It is usually
* disable and replaced by the APIC.
*/
#include "../io.h"
/* Initialise the PIC to a specified frequency */
static void
init_pit(void)
{
uint32_t divisor = 1193182 / 1000;
outb(0x43, 0x36);
outb(0x40, divisor & 0xFF);
outb(0x40, (divisor >> 8) & 0xFF);
}
/* Initialise the PIC */
void
init_pic(void)
{
/*
* By default interrupts and exceptions both start at IRQ#0. To avoid
* collision we can map interrupts to start at IRQ#32. Since lower
* numbered IRQ lines are higher priority, exceptions have priority.
*/
outb(0x20, 0x11); io_wait();
outb(0xA0, 0x11); io_wait();
outb(0x21, 0x20); io_wait();
outb(0xA1, 0x28); io_wait();
outb(0x21, 0x04); io_wait();
outb(0xA1, 0x02); io_wait();
outb(0x21, 0x01); io_wait();
outb(0xA1, 0x01); io_wait();
outb(0x21, 0x00); io_wait();
outb(0xA1, 0x00); io_wait();
init_pit();
}