Changes in kernel/arch/mips32/src/exception.c [e16e0d59:22a28a69] in mainline
- File:
-
- 1 edited
-
kernel/arch/mips32/src/exception.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/mips32/src/exception.c
re16e0d59 r22a28a69 27 27 */ 28 28 29 /** @addtogroup mips32 29 /** @addtogroup mips32 30 30 * @{ 31 31 */ … … 38 38 #include <panic.h> 39 39 #include <arch/cp0.h> 40 #include < arch/types.h>40 #include <typedefs.h> 41 41 #include <arch.h> 42 42 #include <debug.h> … … 49 49 #include <symtab.h> 50 50 51 static c har *exctable[] = {51 static const char *exctable[] = { 52 52 "Interrupt", 53 53 "TLB Modified", … … 67 67 "Floating Point", 68 68 NULL, NULL, NULL, NULL, NULL, NULL, NULL, 69 "WatchHi/WatchLo", /* 23 */69 "WatchHi/WatchLo", /* 23 */ 70 70 NULL, NULL, NULL, NULL, NULL, NULL, NULL, 71 71 "Virtual Coherency - data", 72 72 }; 73 73 74 static void print_regdump(istate_t *istate) 75 { 76 char *pcsymbol, *rasymbol; 77 78 pcsymbol = symtab_fmt_name_lookup(istate->epc); 79 rasymbol = symtab_fmt_name_lookup(istate->ra); 80 81 printf("PC: %#x(%s) RA: %#x(%s), SP(%p)\n", istate->epc, pcsymbol, 82 istate->ra, rasymbol, istate->sp); 83 } 84 85 static void unhandled_exception(int n, istate_t *istate) 74 void istate_decode(istate_t *istate) 75 { 76 printf("at=%p\tv0=%p\tv1=%p\n", istate->at, istate->v0, istate->v1); 77 printf("a0=%p\ta1=%p\ta2=%p\n", istate->a0, istate->a1, istate->a2); 78 printf("a3=%p\tt0=%p\tt1=%p\n", istate->a3, istate->t0, istate->t1); 79 printf("t2=%p\tt3=%p\tt4=%p\n", istate->t2, istate->t3, istate->t4); 80 printf("t5=%p\tt6=%p\tt7=%p\n", istate->t5, istate->t6, istate->t7); 81 printf("t8=%p\tt9=%p\tgp=%p\n", istate->t8, istate->t9, istate->gp); 82 printf("sp=%p\tra=%p\t\n", istate->sp, istate->ra); 83 printf("lo=%p\thi=%p\t\n", istate->lo, istate->hi); 84 printf("cp0_status=%p\tcp0_epc=%p\tk1=%p\n", 85 istate->status, istate->epc, istate->k1); 86 } 87 88 static void unhandled_exception(unsigned int n, istate_t *istate) 86 89 { 87 90 fault_if_from_uspace(istate, "Unhandled exception %s.", exctable[n]); 88 89 print_regdump(istate); 90 panic("Unhandled exception %s.", exctable[n]); 91 } 92 93 static void reserved_instr_exception(int n, istate_t *istate) 94 { 95 if (*((uint32_t *)istate->epc) == 0x7c03e83b) { 91 panic_badtrap(istate, n, "Unhandled exception %s.", exctable[n]); 92 } 93 94 static void reserved_instr_exception(unsigned int n, istate_t *istate) 95 { 96 if (*((uint32_t *) istate->epc) == 0x7c03e83b) { 96 97 ASSERT(THREAD); 97 98 istate->epc += 4; 98 99 istate->v1 = istate->k1; 99 } else 100 } else 100 101 unhandled_exception(n, istate); 101 102 } 102 103 103 static void breakpoint_exception( int n, istate_t *istate)104 static void breakpoint_exception(unsigned int n, istate_t *istate) 104 105 { 105 106 #ifdef CONFIG_DEBUG … … 113 114 } 114 115 115 static void tlbmod_exception( int n, istate_t *istate)116 static void tlbmod_exception(unsigned int n, istate_t *istate) 116 117 { 117 118 tlb_modified(istate); 118 119 } 119 120 120 static void tlbinv_exception( int n, istate_t *istate)121 static void tlbinv_exception(unsigned int n, istate_t *istate) 121 122 { 122 123 tlb_invalid(istate); … … 124 125 125 126 #ifdef CONFIG_FPU_LAZY 126 static void cpuns_exception( int n, istate_t *istate)127 static void cpuns_exception(unsigned int n, istate_t *istate) 127 128 { 128 129 if (cp0_cause_coperr(cp0_cause_read()) == fpu_cop_id) 129 130 scheduler_fpu_lazy_request(); 130 131 else { 131 fault_if_from_uspace(istate, "Unhandled Coprocessor Unusable Exception."); 132 panic("Unhandled Coprocessor Unusable Exception."); 132 fault_if_from_uspace(istate, 133 "Unhandled Coprocessor Unusable Exception."); 134 panic_badtrap(istate, n, 135 "Unhandled Coprocessor Unusable Exception."); 133 136 } 134 137 } 135 138 #endif 136 139 137 static void interrupt_exception(int n, istate_t *istate) 138 { 139 uint32_t cause; 140 int i; 141 142 /* decode interrupt number and process the interrupt */ 143 cause = (cp0_cause_read() >> 8) & 0xff; 144 140 static void interrupt_exception(unsigned int n, istate_t *istate) 141 { 142 /* Decode interrupt number and process the interrupt */ 143 uint32_t cause = (cp0_cause_read() >> 8) & 0xff; 144 145 unsigned int i; 145 146 for (i = 0; i < 8; i++) { 146 147 if (cause & (1 << i)) { … … 151 152 */ 152 153 irq->handler(irq); 153 spinlock_unlock(&irq->lock);154 irq_spinlock_unlock(&irq->lock, false); 154 155 } else { 155 156 /* … … 157 158 */ 158 159 #ifdef CONFIG_DEBUG 159 printf("cpu%u: spurious interrupt (inum=% d)\n",160 printf("cpu%u: spurious interrupt (inum=%u)\n", 160 161 CPU->id, i); 161 162 #endif … … 166 167 167 168 /** Handle syscall userspace call */ 168 static void syscall_exception( int n, istate_t *istate)169 { 170 panic("Syscall is handled through shortcut.");169 static void syscall_exception(unsigned int n, istate_t *istate) 170 { 171 fault_if_from_uspace(istate, "Syscall is handled through shortcut."); 171 172 } 172 173 173 174 void exception_init(void) 174 175 { 175 int i;176 176 unsigned int i; 177 177 178 /* Clear exception table */ 178 179 for (i = 0; i < IVT_ITEMS; i++) 179 exc_register(i, "undef", (iroutine) unhandled_exception); 180 181 exc_register(EXC_Bp, "bkpoint", (iroutine) breakpoint_exception); 182 exc_register(EXC_RI, "resinstr", (iroutine) reserved_instr_exception); 183 exc_register(EXC_Mod, "tlb_mod", (iroutine) tlbmod_exception); 184 exc_register(EXC_TLBL, "tlbinvl", (iroutine) tlbinv_exception); 185 exc_register(EXC_TLBS, "tlbinvl", (iroutine) tlbinv_exception); 186 exc_register(EXC_Int, "interrupt", (iroutine) interrupt_exception); 180 exc_register(i, "undef", false, 181 (iroutine_t) unhandled_exception); 182 183 exc_register(EXC_Bp, "bkpoint", true, 184 (iroutine_t) breakpoint_exception); 185 exc_register(EXC_RI, "resinstr", true, 186 (iroutine_t) reserved_instr_exception); 187 exc_register(EXC_Mod, "tlb_mod", true, 188 (iroutine_t) tlbmod_exception); 189 exc_register(EXC_TLBL, "tlbinvl", true, 190 (iroutine_t) tlbinv_exception); 191 exc_register(EXC_TLBS, "tlbinvl", true, 192 (iroutine_t) tlbinv_exception); 193 exc_register(EXC_Int, "interrupt", true, 194 (iroutine_t) interrupt_exception); 195 187 196 #ifdef CONFIG_FPU_LAZY 188 exc_register(EXC_CpU, "cpunus", (iroutine) cpuns_exception); 189 #endif 190 exc_register(EXC_Sys, "syscall", (iroutine) syscall_exception); 197 exc_register(EXC_CpU, "cpunus", true, 198 (iroutine_t) cpuns_exception); 199 #endif 200 201 exc_register(EXC_Sys, "syscall", true, 202 (iroutine_t) syscall_exception); 191 203 } 192 204
Note:
See TracChangeset
for help on using the changeset viewer.
