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/idt.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/idt.c')
-rw-r--r-- | src/kernel/arch/i386/interrupts/idt.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/kernel/arch/i386/interrupts/idt.c b/src/kernel/arch/i386/interrupts/idt.c index bbaf610..4c46514 100644 --- a/src/kernel/arch/i386/interrupts/idt.c +++ b/src/kernel/arch/i386/interrupts/idt.c @@ -27,14 +27,14 @@ struct lidt_arg { static struct idt_entry IDT[256]; static struct lidt_arg lidt_arg; -static inline void idt_add(uint8_t num, bool user, void (*isr)); +static inline void idt_add(uint8_t num, bool user); static void idt_prepare(); static void idt_load(); static void idt_test(); -static inline void idt_add(uint8_t num, bool user, void (*isr)) { - uintptr_t offset = (uintptr_t) isr; +static inline void idt_add(uint8_t num, bool user) { + uintptr_t offset = (uintptr_t) &_isr_stubs + 8 * num; IDT[num] = (struct idt_entry) { .offset_low = offset, @@ -52,10 +52,10 @@ static void idt_prepare() { for (int i = 0; i < 256; i++) IDT[i].present = 0; - idt_add(0x08, false, isr_double_fault); - idt_add(0x0d, false, isr_general_protection_fault); - idt_add(0x0e, false, isr_page_fault); - idt_add(0x34, false, isr_test_interrupt); + idt_add(0x08, false); + idt_add(0x0d, false); + idt_add(0x0e, false); + idt_add(0x34, false); } static void idt_load() { |