2022-02-24 18:11:09 +02:00
|
|
|
#include "cpu/idt.h"
|
|
|
|
#include "std/std.h"
|
|
|
|
#include "std/kstd.h"
|
|
|
|
|
|
|
|
void generic_exception_handler(struct interrupt_descriptor_32 *frame, uint8_t irq) {
|
|
|
|
kprintf("\n\n");
|
|
|
|
kprintf("---- PANIC -------------\n");
|
|
|
|
kprintf("Kernel panic due to exception\n");
|
|
|
|
kprintf("IRQ %d\n", (int)irq);
|
2022-02-24 21:16:28 +02:00
|
|
|
kprintf("selector %d\n", (int)frame->selector);
|
2022-02-24 18:11:09 +02:00
|
|
|
kprintf("------------------------\n");
|
|
|
|
kabort();
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr0(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr1(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr2(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr3(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr4(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr5(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 5);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr6(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 6);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr7(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 7);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr8(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr9(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 9);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr10(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr11(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 11);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr12(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 12);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr13(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 13);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr14(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 14);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr15(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 15);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr16(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 16);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr17(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 17);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr18(struct interrupt_descriptor_32 *frame) {
|
2022-02-24 21:16:28 +02:00
|
|
|
generic_exception_handler(frame, 18);
|
2022-02-24 18:11:09 +02:00
|
|
|
}
|
|
|
|
|
2022-02-24 21:53:44 +02:00
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr19(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 19);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr20(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 20);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr21(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 21);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr22(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 22);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr23(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 23);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr24(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 24);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr25(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 25);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr26(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 26);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr27(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 27);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr28(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 28);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr29(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 29);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr30(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 30);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((interrupt))
|
|
|
|
static void isr31(struct interrupt_descriptor_32 *frame) {
|
|
|
|
generic_exception_handler(frame, 31);
|
|
|
|
}
|
|
|
|
|
2022-02-24 18:11:09 +02:00
|
|
|
|
|
|
|
void exception_handlers_init() {
|
|
|
|
idt_register_handler(0, (size_t)isr0);
|
|
|
|
idt_register_handler(1, (size_t)isr1);
|
|
|
|
idt_register_handler(2, (size_t)isr2);
|
|
|
|
idt_register_handler(3, (size_t)isr3);
|
|
|
|
idt_register_handler(4, (size_t)isr4);
|
|
|
|
idt_register_handler(5, (size_t)isr5);
|
|
|
|
idt_register_handler(6, (size_t)isr6);
|
|
|
|
idt_register_handler(7, (size_t)isr7);
|
|
|
|
idt_register_handler(8, (size_t)isr8);
|
|
|
|
idt_register_handler(9, (size_t)isr9);
|
|
|
|
idt_register_handler(10, (size_t)isr10);
|
|
|
|
idt_register_handler(11, (size_t)isr11);
|
|
|
|
idt_register_handler(12, (size_t)isr12);
|
|
|
|
idt_register_handler(13, (size_t)isr13);
|
|
|
|
idt_register_handler(14, (size_t)isr14);
|
|
|
|
idt_register_handler(15, (size_t)isr15);
|
|
|
|
idt_register_handler(16, (size_t)isr16);
|
|
|
|
idt_register_handler(17, (size_t)isr17);
|
|
|
|
idt_register_handler(18, (size_t)isr18);
|
2022-02-24 21:53:44 +02:00
|
|
|
idt_register_handler(19, (size_t)isr19);
|
|
|
|
idt_register_handler(20, (size_t)isr20);
|
|
|
|
idt_register_handler(21, (size_t)isr21);
|
|
|
|
idt_register_handler(22, (size_t)isr22);
|
|
|
|
idt_register_handler(23, (size_t)isr23);
|
|
|
|
idt_register_handler(24, (size_t)isr24);
|
|
|
|
idt_register_handler(25, (size_t)isr25);
|
|
|
|
idt_register_handler(26, (size_t)isr26);
|
|
|
|
idt_register_handler(27, (size_t)isr27);
|
|
|
|
idt_register_handler(28, (size_t)isr28);
|
|
|
|
idt_register_handler(29, (size_t)isr29);
|
|
|
|
idt_register_handler(30, (size_t)isr30);
|
|
|
|
idt_register_handler(31, (size_t)isr31);
|
2022-02-24 18:11:09 +02:00
|
|
|
}
|