diff options
Diffstat (limited to 'devices/pic_8259.c')
-rw-r--r-- | devices/pic_8259.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/devices/pic_8259.c b/devices/pic_8259.c new file mode 100644 index 0000000..43b090f --- /dev/null +++ b/devices/pic_8259.c @@ -0,0 +1,39 @@ +#include "pic.h" +#include <sys/io.h> + +#define PIC1 0x20 +#define PIC2 0xa0 +#define DATA 1 + +// initialization +#define ICW1_INIT 0x10 +// TODO +#define ICW1_ICW4 0x01 +// 8086/88 mode +#define ICW4_8086 0x01 + +void +pic_init() +{ + outb(ICW1_INIT | ICW1_ICW4, PIC1); + outb(ICW1_INIT | ICW1_ICW4, PIC2); + + outb(0x20, PIC1 + DATA); // offset 0x20 + outb(0x28, PIC2 + DATA); // offset 0x28 + + outb(0x04, PIC1 + DATA); // tell master pic there is a slave pic + outb(0x02, PIC2 + DATA); // tell slave pic its cascade identity + + outb(ICW4_8086, PIC1 + DATA); + outb(ICW4_8086, PIC2 + DATA); + + // PIC masks + outb(0xff, PIC1 + DATA); + outb(0xff, PIC2 + DATA); +} + +void +pic_clear(unsigned char irq) +{ + outb(0x20, PIC1); +} |