hos/kernel/sys/pic.cc
josh bc7064e92a got interrupts working, added sys/{pic,timer,cpu} modules, ready to work on multitasking
git-svn-id: svn://anubis/hos/trunk@69 5b3e749e-e535-0410-8002-a9bb6afbdfca
2009-07-29 22:30:52 +00:00

30 lines
927 B
C++

#include "pic.h"
#include "portio.h"
/*
* Re-maps the Programmable Interrupr Controllers
* so IRQ0->pic1 base address, IRG8->pic2 base address
*/
void pic_remap(u8_t base1, u8_t base2)
{
u8_t a1, a2;
a1 = inportb(PIC1_DATA); /* 0x21 */
a2 = inportb(PIC2_DATA); /* 0xA1 */
outportb(PIC1_COMMAND, ICW1_INIT+ICW1_ICW4); /* 0x20, 0x10+0x01 00010001b */
outportb(PIC2_COMMAND, ICW1_INIT+ICW1_ICW4); /* 0xA0, 0x10+0x01 00010001b */
outportb(PIC1_DATA, base1); /* 0x21, pic1 */
outportb(PIC2_DATA, base2); /* 0xA1, pic2 */
outportb(PIC1_DATA, 4); /* 0x21, 0x04 00000100b */
outportb(PIC2_DATA, 2); /* 0xA1, 0x02 00000010b */
outportb(PIC1_DATA, ICW4_8086); /* 0x21, 0x01 00000001b */
outportb(PIC2_DATA, ICW4_8086); /* 0xA1, 0x01 00000001b */
outportb(PIC1_DATA, a1); /* 0x21 */
outportb(PIC2_DATA, a2); /* 0xA1 */
}