X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/1fe5f5eb5378a47bf0f3451762743c162e40faad..d1b1c8d9119229dbeed06cd252917e54a1cb77f6:/lunaix-os/arch/i386/exceptions/intr_routines.c diff --git a/lunaix-os/arch/i386/exceptions/intr_routines.c b/lunaix-os/arch/i386/exceptions/intr_routines.c index 6571f9a..ddd06a8 100644 --- a/lunaix-os/arch/i386/exceptions/intr_routines.c +++ b/lunaix-os/arch/i386/exceptions/intr_routines.c @@ -1,97 +1,79 @@ -#include +#include -#include -#include +#include #include #include #include #include -#include +#include +#include -#include +#include -#include +#include "sys/apic.h" #include LOG_MODULE("INTR") extern void -intr_routine_page_fault(const isr_param* param); +intr_routine_page_fault(const struct hart_state* state); extern u32_t debug_resv; void -__print_panic_msg(const char* msg, const isr_param* param) +__print_panic_msg(const char* msg, const struct hart_state* state) { - volatile struct exec_param* execp = param->execp; - - kprint_panic(" INT %u: (%x) [%p: %p] %s", - execp->vector, - execp->err_code, - execp->cs, - execp->eip, - msg); + ERROR("panic: %s", msg); + failsafe_diagnostic(); } void -intr_routine_divide_zero(const isr_param* param) +intr_routine_divide_zero(const struct hart_state* state) { - console_flush(); - __print_panic_msg("Divide by zero!", param); - spin(); + __print_panic_msg("div zero", state); } void -intr_routine_general_protection(const isr_param* param) +intr_routine_general_protection(const struct hart_state* state) { - kprintf(KERROR "Pid: %d\n", __current->pid); - kprintf(KERROR "Addr: %p\n", (&debug_resv)[0]); - kprintf(KERROR "Expected: %p\n", (&debug_resv)[1]); - console_flush(); - __print_panic_msg("General Protection", param); - spin(); + __print_panic_msg("general protection", state); } void -intr_routine_sys_panic(const isr_param* param) +intr_routine_sys_panic(const struct hart_state* state) { - console_flush(); - __print_panic_msg((char*)(param->registers.edi), param); - spin(); + __print_panic_msg((char*)(state->registers.edi), state); } void -intr_routine_fallback(const isr_param* param) +intr_routine_fallback(const struct hart_state* state) { - __print_panic_msg("Unknown Interrupt", param); - console_flush(); - spin(); + __print_panic_msg("unknown interrupt", state); } /** * @brief ISR for Spurious interrupt * - * @param isr_param passed by CPU + * @param struct hart_state passed by CPU */ void -intr_routine_apic_spi(const isr_param* param) +intr_routine_apic_spi(const struct hart_state* state) { // FUTURE: do nothing for now } void -intr_routine_apic_error(const isr_param* param) +intr_routine_apic_error(const struct hart_state* state) { u32_t error_reg = apic_read_reg(APIC_ESR); char buf[32]; ksprintf(buf, "APIC error, ESR=0x%x", error_reg); - console_flush(); - __print_panic_msg(buf, param); - spin(); + + failsafe_diagnostic(); } void -intr_routine_sched(const isr_param* param) +intr_routine_sched(const struct hart_state* state) { schedule(); }