131 lines
3.7 KiB
C
131 lines
3.7 KiB
C
#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);
|
|
kprintf("selector %d\n", (int)frame->selector);
|
|
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) {
|
|
generic_exception_handler(frame, 18);
|
|
}
|
|
|
|
|
|
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);
|
|
}
|