diff options
author | Marvin Borner | 2019-09-19 19:56:59 +0200 |
---|---|---|
committer | Marvin Borner | 2019-09-19 20:05:38 +0200 |
commit | 05e1fedcc9cd30d1a34a65e640da45e980b4f859 (patch) | |
tree | 9cfb7620907ac126f26cdfe9363cb73ed74ea179 /src/kernel/interrupts/isr.c | |
parent | ffd82e18b5259fab477ad375a7af8550fac526d8 (diff) |
Moved source to kernel directory
Diffstat (limited to 'src/kernel/interrupts/isr.c')
-rw-r--r-- | src/kernel/interrupts/isr.c | 155 |
1 files changed, 155 insertions, 0 deletions
diff --git a/src/kernel/interrupts/isr.c b/src/kernel/interrupts/isr.c new file mode 100644 index 0000000..8da7919 --- /dev/null +++ b/src/kernel/interrupts/isr.c @@ -0,0 +1,155 @@ +#include "../graphics/graphics.h" +#include "interrupts.h" + +// Defined in isr.asm +extern void isr0(); + +extern void isr1(); + +extern void isr2(); + +extern void isr3(); + +extern void isr4(); + +extern void isr5(); + +extern void isr6(); + +extern void isr7(); + +extern void isr8(); + +extern void isr9(); + +extern void isr10(); + +extern void isr11(); + +extern void isr12(); + +extern void isr13(); + +extern void isr14(); + +extern void isr15(); + +extern void isr16(); + +extern void isr17(); + +extern void isr18(); + +extern void isr19(); + +extern void isr20(); + +extern void isr21(); + +extern void isr22(); + +extern void isr23(); + +extern void isr24(); + +extern void isr25(); + +extern void isr26(); + +extern void isr27(); + +extern void isr28(); + +extern void isr29(); + +extern void isr30(); + +extern void isr31(); + +// Install ISRs in IDT +void isrs_install() { + idt_set_gate(0, (unsigned) isr0, 0x08, 0x8E); + idt_set_gate(1, (unsigned) isr1, 0x08, 0x8E); + idt_set_gate(2, (unsigned) isr2, 0x08, 0x8E); + idt_set_gate(3, (unsigned) isr3, 0x08, 0x8E); + idt_set_gate(4, (unsigned) isr4, 0x08, 0x8E); + idt_set_gate(5, (unsigned) isr5, 0x08, 0x8E); + idt_set_gate(6, (unsigned) isr6, 0x08, 0x8E); + idt_set_gate(7, (unsigned) isr7, 0x08, 0x8E); + + idt_set_gate(8, (unsigned) isr8, 0x08, 0x8E); + idt_set_gate(9, (unsigned) isr9, 0x08, 0x8E); + idt_set_gate(10, (unsigned) isr10, 0x08, 0x8E); + idt_set_gate(11, (unsigned) isr11, 0x08, 0x8E); + idt_set_gate(12, (unsigned) isr12, 0x08, 0x8E); + idt_set_gate(13, (unsigned) isr13, 0x08, 0x8E); + idt_set_gate(14, (unsigned) isr14, 0x08, 0x8E); + idt_set_gate(15, (unsigned) isr15, 0x08, 0x8E); + + idt_set_gate(16, (unsigned) isr16, 0x08, 0x8E); + idt_set_gate(17, (unsigned) isr17, 0x08, 0x8E); + idt_set_gate(18, (unsigned) isr18, 0x08, 0x8E); + idt_set_gate(19, (unsigned) isr19, 0x08, 0x8E); + idt_set_gate(20, (unsigned) isr20, 0x08, 0x8E); + idt_set_gate(21, (unsigned) isr21, 0x08, 0x8E); + idt_set_gate(22, (unsigned) isr22, 0x08, 0x8E); + idt_set_gate(23, (unsigned) isr23, 0x08, 0x8E); + + idt_set_gate(24, (unsigned) isr24, 0x08, 0x8E); + idt_set_gate(25, (unsigned) isr25, 0x08, 0x8E); + idt_set_gate(26, (unsigned) isr26, 0x08, 0x8E); + idt_set_gate(27, (unsigned) isr27, 0x08, 0x8E); + idt_set_gate(28, (unsigned) isr28, 0x08, 0x8E); + idt_set_gate(29, (unsigned) isr29, 0x08, 0x8E); + idt_set_gate(30, (unsigned) isr30, 0x08, 0x8E); + idt_set_gate(31, (unsigned) isr31, 0x08, 0x8E); +} + +// Error exception messages +const char *exception_messages[] = { + "Division By Zero", + "Debug", + "Non Maskable Interrupt", + "Breakpoint", + "Into Detected Overflow", + "Out of Bounds", + "Invalid Opcode", + "No Coprocessor", + + "Double Fault", + "Coprocessor Segment Overrun", + "Bad TSS", + "Segment Not Present", + "Stack Fault", + "General Protection Fault", + "Page Fault", + "Unknown Interrupt", + + "Coprocessor Fault", + "Alignment Check", + "Machine Check", + "Reserved", + "Reserved", + "Reserved", + "Reserved", + "Reserved", + + "Reserved", + "Reserved", + "Reserved", + "Reserved", + "Reserved", + "Reserved", + "Reserved", + "Reserved" +}; + +// Master exception handler - halt via endless loop +void fault_handler(struct regs *r) { + if (r->int_no < 32) { + terminal_write_string("\n"); + terminal_write_string(exception_messages[r->int_no]); + terminal_write_string(" Exception. System Halted!\n"); + for (;;); + } +} |