From ace65b453151845bc361f21f3e5b651c35f9f126 Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Wed, 22 May 2024 13:00:41 -0400 Subject: massive refactor for mp and organization --- arch/x86_64/int_handler.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 arch/x86_64/int_handler.c (limited to 'arch/x86_64/int_handler.c') diff --git a/arch/x86_64/int_handler.c b/arch/x86_64/int_handler.c new file mode 100644 index 0000000..3674d1c --- /dev/null +++ b/arch/x86_64/int_handler.c @@ -0,0 +1,52 @@ +#include "arch/x86_64/idt.h" +#include "arch/processor.h" +#include "print.h" +#include "jove.h" +#include "assert.h" +#include + +static int_handler_t s_handlers[48]; + +int_state_t* +irq_handle(int_state_t *state) +{ + if(__isr_num < 48) { + if(s_handlers[__isr_num] != NULL) { + return s_handlers[__isr_num](state); + } + } + + klogf("Interrupt %i\nerror code %#016X\n", __isr_num, __isr_err); + int_state_print(state); + kpanic("Unhandled exception\n"); + return state; +} + +void +int_handler_set(uint8_t i, int_handler_t handler) +{ + assert(i < 48); + s_handlers[i] = handler; +} + +int_handler_t +int_handler_get(uint8_t i) +{ + assert(i < 48); + return s_handlers[i]; +} + +void +int_state_print(int_state_t *state) +{ + if(!state) return; + klogf("IP: %016p\n", state->ip); + klogf("AX: %016p BX: %016p\n", state->ax, state->bx); + klogf("CX: %016p DX: %016p\n", state->cx, state->dx); + klogf("SI: %016p DI: %016p\n", state->si, state->di); + klogf("SP: %016p BP: %016p\n", state->sp, state->bp); + klogf("R8: %016p R9: %016p\n", state->r8, state->r9); + klogf("R10: %016p R11: %016p\n", state->r10, state->r11); + klogf("R12: %016p R13: %016p\n", state->r12, state->r13); + klogf("R14: %016p R15: %016p\n", state->r14, state->r15); +} -- cgit v1.2.1