diff options
author | dzwdz | 2021-07-21 18:02:53 +0200 |
---|---|---|
committer | dzwdz | 2021-07-21 18:02:53 +0200 |
commit | 04b4c029420b010a906d0af3fb7b52108471c4bd (patch) | |
tree | 48154dfd8de19f140c242fc1c21b89f780730adb /src/kernel/arch/i386/interrupts/isr.c | |
parent | 1b9c86d59753e2ecaf9529386483aebbe25ba265 (diff) |
create ISR stubs, which call a single main isr handler
quick explaination of how this even works:
The `call` in each stub pushes its own address onto the stack before
calling stage2. We can substract the address of the 0th ISR to get the
offset, which we then divide by the size of each stub to get the index.
Diffstat (limited to 'src/kernel/arch/i386/interrupts/isr.c')
-rw-r--r-- | src/kernel/arch/i386/interrupts/isr.c | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/src/kernel/arch/i386/interrupts/isr.c b/src/kernel/arch/i386/interrupts/isr.c index 9da06fb..800bdba 100644 --- a/src/kernel/arch/i386/interrupts/isr.c +++ b/src/kernel/arch/i386/interrupts/isr.c @@ -4,29 +4,22 @@ #include <stdbool.h> #include <stdint.h> -#define UNUSED __attribute__((unused)) +#define log_n_panic(x) {log_const(x); panic();} bool isr_test_interrupt_called = false; -__attribute__((interrupt)) -void isr_double_fault(UNUSED struct interrupt_frame *frame) { - log_const("#DF"); - panic(); -} - -__attribute__((interrupt)) -void isr_general_protection_fault(UNUSED struct interrupt_frame *frame) { - log_const("#GP"); - panic(); -} +void isr_stage3(int interrupt) { + switch (interrupt) { + case 0x08: log_n_panic("#DF"); // double fault + case 0x0D: log_n_panic("#GP"); // general protection fault + case 0x0E: log_n_panic("#PF"); // page fault -__attribute__((interrupt)) -void isr_page_fault(UNUSED struct interrupt_frame *frame) { - log_const("#PF"); - panic(); -} + case 0x34: + isr_test_interrupt_called = true; + return; -__attribute__((interrupt)) -void isr_test_interrupt(UNUSED struct interrupt_frame *frame) { - isr_test_interrupt_called = true; + default: + log_const("unknown interrupt"); + panic(); + } } |