diff options
Diffstat (limited to 'kernel/irq.c')
-rw-r--r-- | kernel/irq.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/kernel/irq.c b/kernel/irq.c new file mode 100644 index 0000000..6034735 --- /dev/null +++ b/kernel/irq.c @@ -0,0 +1,42 @@ +#include "irq.h" +#include "portio.h" + +void irq_init() { + // ICW1 + outb(0x20, 0x11); + outb(0xa0, 0x11); + + // ICW2 - Offset. + outb(0x21, 0x20); + outb(0xa1, 0x28); + + // ICW3 + outb(0x21, 0x04); + outb(0xa1, 0x02); + + // ICW4 + outb(0x21, 0x01); + outb(0xa1, 0x01); + + // OCW1 - Mask. + outb(0x21, 0xfe); + outb(0xa1, 0xff); + + // Initialize timer. + // TODO: Move this elsewhere. + outb(0x43, 0x36); + outb(0x40, 0x00); + outb(0x40, 0x00); +} + +void irq_reset() { + // OCW2 + outb(0x20, 0x20); +} + +void irq_reset_slave() { + // OCW2 + outb(0xa0, 0x20); + + irq_reset(); +} |