diff --git a/kernel/kernel.h b/kernel/kernel.h index 5ccce6a..03e7d18 100644 --- a/kernel/kernel.h +++ b/kernel/kernel.h @@ -1,4 +1,5 @@ #include "interupt.h" +#include "pic.h" #include "memory.h" #include "paging.h" #include "../drivers/vga.h" diff --git a/kernel/pic.c b/kernel/pic.c index 1912725..c8e94a1 100644 --- a/kernel/pic.c +++ b/kernel/pic.c @@ -1,25 +1,38 @@ #include "pic.h" #include "io.h" -void PIC_sendEOI(uint8 irq) { +void pic_send_eoi(uint8 irq) { if( irq >= 8 ) outb(PIC2_CMD, PIC_EOI); outb(PIC1_CMD, PIC_EOI); } -void PIC_remap(uint offset_1, uint offset_2) { +void pic_remap(uint offset_1, uint offset_2) { uint8 a1, a2; a1 = inb(PIC1_DATA); a2 = inb(PIC2_DATA); // Start the init sequance - outb_w( PIC1_CMD, ICW_INIT_MASK ); + outb_w(PIC1_CMD, ICW_INIT_MASK); - outb_w(PIC2_CMD, ICW_INIT_MASK ); + outb_w(PIC2_CMD, ICW_INIT_MASK); outb_w(PIC1_DATA, offset_1); // ICW2 master offset outb_w(PIC2_DATA, offset_2); // ICW2 slave offset - outb_w(PIC1_DATA, 0x4); + outb_w(PIC1_DATA, 0x4); outb_w(PIC2_DATA, 0x2); + + outb_w(PIC1_DATA, ICW4_8086); + outb_w(PIC2_DATA, ICW4_8086); + + // restore old masks + outb(PIC1_DATA, a1); + outb(PIC2_DATA, a2); +} + +// disable the PIC +void pic_disable() { + outb(PIC1_DATA, 0xff); + outb(PIC2_DATA, 0xff); } diff --git a/kernel/pic.h b/kernel/pic.h index 5bd66e9..43420db 100644 --- a/kernel/pic.h +++ b/kernel/pic.h @@ -28,5 +28,10 @@ // Ints #define PIC_EOI 0x20 // End-of-interupt -void PIC_sendEOI(uint8); -void PIC_remap(uint, uint); +// PIC +void pic_send_eoi(uint8); +void pic_remap(uint, uint); +void pic_disable(); + +// IRQs +void irq_set(uint8);