3 #include <asm-generic/isrm.h>
4 #include <lunaix/process.h>
5 #include <lunaix/sched.h>
6 #include <lunaix/spike.h>
7 #include <lunaix/syslog.h>
8 #include <lunaix/trace.h>
9 #include <lunaix/failsafe.h>
11 #include <klibc/strfmt.h>
13 #include "asm/soc/apic.h"
19 intr_routine_page_fault(const struct hart_state* state);
21 extern u32_t debug_resv;
24 __print_panic_msg(const char* msg, const struct hart_state* state)
26 ERROR("panic: %s", msg);
27 failsafe_diagnostic();
31 intr_routine_divide_zero(const struct hart_state* state)
33 __print_panic_msg("div zero", state);
37 intr_routine_general_protection(const struct hart_state* state)
39 __print_panic_msg("general protection", state);
43 intr_routine_invl_opcode(const struct hart_state* state)
45 __print_panic_msg("invalid opcode", state);
49 intr_routine_sys_panic(const struct hart_state* state)
51 #ifdef CONFIG_ARCH_X86_64
52 __print_panic_msg((char*)(state->registers.rdi), state);
54 __print_panic_msg((char*)(state->registers.edi), state);
59 intr_routine_fallback(const struct hart_state* state)
61 __print_panic_msg("unknown interrupt", state);
65 * @brief ISR for Spurious interrupt
67 * @param struct hart_state passed by CPU
70 intr_routine_apic_spi(const struct hart_state* state)
72 // FUTURE: do nothing for now
76 intr_routine_apic_error(const struct hart_state* state)
78 u32_t error_reg = apic_read_reg(APIC_ESR);
80 ksprintf(buf, "APIC error, ESR=0x%x", error_reg);
82 failsafe_diagnostic();
86 intr_routine_sched(const struct hart_state* state)
94 isrm_bindiv(FAULT_DIVISION_ERROR, intr_routine_divide_zero);
95 isrm_bindiv(FAULT_GENERAL_PROTECTION, intr_routine_general_protection);
96 isrm_bindiv(FAULT_PAGE_FAULT, intr_routine_page_fault);
97 isrm_bindiv(FAULT_STACK_SEG_FAULT, intr_routine_page_fault);
98 isrm_bindiv(FAULT_INVALID_OPCODE, intr_routine_invl_opcode);
100 isrm_bindiv(LUNAIX_SYS_PANIC, intr_routine_sys_panic);
101 isrm_bindiv(LUNAIX_SCHED, intr_routine_sched);
103 isrm_bindiv(APIC_SPIV_IV, intr_routine_apic_spi);
104 isrm_bindiv(APIC_ERROR_IV, intr_routine_apic_error);