diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-01-20 22:18:02 +0100 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-01-20 22:18:02 +0100 |
commit | 068368d0bedc34f561ab0c9dd614c02b346d1d4e (patch) | |
tree | 5951082c13767904c9995c759263c18fcd17845e /kernel/irq.c | |
parent | bfa24f7e97eebd26561d87bbab643a9825e93392 (diff) |
Added IRQ-support and timer interrupt.
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(); +} |