Rev 3022 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 3022 | Rev 4055 | ||
|---|---|---|---|
| Line 43... | Line 43... | ||
| 43 | #include <proc/thread.h> |
43 | #include <proc/thread.h> |
| 44 | #include <symtab.h> |
44 | #include <symtab.h> |
| 45 | #include <print.h> |
45 | #include <print.h> |
| 46 | #include <interrupt.h> |
46 | #include <interrupt.h> |
| 47 | #include <func.h> |
47 | #include <func.h> |
| 48 | #include <console/kconsole.h> |
- | |
| 49 | #include <ddi/irq.h> |
48 | #include <ddi/irq.h> |
| 50 | #include <arch/debugger.h> |
49 | #include <arch/debugger.h> |
| 51 | 50 | ||
| 52 | static char * exctable[] = { |
51 | static char * exctable[] = { |
| 53 | "Interrupt", |
52 | "Interrupt", |
| Line 87... | Line 86... | ||
| 87 | printf("PC: %#x(%s) RA: %#x(%s), SP(%p)\n", istate->epc, pcsymbol, istate->ra, rasymbol, istate->sp); |
86 | printf("PC: %#x(%s) RA: %#x(%s), SP(%p)\n", istate->epc, pcsymbol, istate->ra, rasymbol, istate->sp); |
| 88 | } |
87 | } |
| 89 | 88 | ||
| 90 | static void unhandled_exception(int n, istate_t *istate) |
89 | static void unhandled_exception(int n, istate_t *istate) |
| 91 | { |
90 | { |
| 92 | fault_if_from_uspace(istate, "unhandled exception %s", exctable[n]); |
91 | fault_if_from_uspace(istate, "Unhandled exception %s.", exctable[n]); |
| 93 | 92 | ||
| 94 | print_regdump(istate); |
93 | print_regdump(istate); |
| 95 | panic("unhandled exception %s\n", exctable[n]); |
94 | panic("Unhandled exception %s.", exctable[n]); |
| 96 | } |
95 | } |
| 97 | 96 | ||
| 98 | static void reserved_instr_exception(int n, istate_t *istate) |
97 | static void reserved_instr_exception(int n, istate_t *istate) |
| 99 | { |
98 | { |
| 100 | if (*((uint32_t *)istate->epc) == 0x7c03e83b) { |
99 | if (*((uint32_t *)istate->epc) == 0x7c03e83b) { |
| Line 131... | Line 130... | ||
| 131 | static void cpuns_exception(int n, istate_t *istate) |
130 | static void cpuns_exception(int n, istate_t *istate) |
| 132 | { |
131 | { |
| 133 | if (cp0_cause_coperr(cp0_cause_read()) == fpu_cop_id) |
132 | if (cp0_cause_coperr(cp0_cause_read()) == fpu_cop_id) |
| 134 | scheduler_fpu_lazy_request(); |
133 | scheduler_fpu_lazy_request(); |
| 135 | else { |
134 | else { |
| 136 | fault_if_from_uspace(istate, "unhandled Coprocessor Unusable Exception"); |
135 | fault_if_from_uspace(istate, "Unhandled Coprocessor Unusable Exception."); |
| 137 | panic("unhandled Coprocessor Unusable Exception\n"); |
136 | panic("Unhandled Coprocessor Unusable Exception."); |
| 138 | } |
137 | } |
| 139 | } |
138 | } |
| 140 | #endif |
139 | #endif |
| 141 | 140 | ||
| 142 | static void interrupt_exception(int n, istate_t *istate) |
141 | static void interrupt_exception(int n, istate_t *istate) |
| 143 | { |
142 | { |
| 144 | uint32_t cause; |
143 | uint32_t cause; |
| 145 | int i; |
144 | int i; |
| 146 | 145 | ||
| 147 | /* decode interrupt number and process the interrupt */ |
146 | /* decode interrupt number and process the interrupt */ |
| 148 | cause = (cp0_cause_read() >> 8) &0xff; |
147 | cause = (cp0_cause_read() >> 8) & 0xff; |
| 149 | 148 | ||
| 150 | for (i = 0; i < 8; i++) { |
149 | for (i = 0; i < 8; i++) { |
| 151 | if (cause & (1 << i)) { |
150 | if (cause & (1 << i)) { |
| 152 | irq_t *irq = irq_dispatch_and_lock(i); |
151 | irq_t *irq = irq_dispatch_and_lock(i); |
| 153 | if (irq) { |
152 | if (irq) { |
| 154 | /* |
153 | /* |
| 155 | * The IRQ handler was found. |
154 | * The IRQ handler was found. |
| 156 | */ |
155 | */ |
| 157 | irq->handler(irq, irq->arg); |
156 | irq->handler(irq); |
| 158 | spinlock_unlock(&irq->lock); |
157 | spinlock_unlock(&irq->lock); |
| 159 | } else { |
158 | } else { |
| 160 | /* |
159 | /* |
| 161 | * Spurious interrupt. |
160 | * Spurious interrupt. |
| 162 | */ |
161 | */ |
| 163 | #ifdef CONFIG_DEBUG |
162 | #ifdef CONFIG_DEBUG |
| 164 | printf("cpu%d: spurious interrupt (inum=%d)\n", CPU->id, i); |
163 | printf("cpu%u: spurious interrupt (inum=%d)\n", |
| - | 164 | CPU->id, i); |
|
| 165 | #endif |
165 | #endif |
| 166 | } |
166 | } |
| 167 | } |
167 | } |
| 168 | } |
168 | } |
| 169 | } |
169 | } |
| 170 | 170 | ||
| 171 | /** Handle syscall userspace call */ |
171 | /** Handle syscall userspace call */ |
| 172 | static void syscall_exception(int n, istate_t *istate) |
172 | static void syscall_exception(int n, istate_t *istate) |
| 173 | { |
173 | { |
| 174 | panic("Syscall is handled through shortcut"); |
174 | panic("Syscall is handled through shortcut."); |
| 175 | } |
175 | } |
| 176 | 176 | ||
| 177 | void exception_init(void) |
177 | void exception_init(void) |
| 178 | { |
178 | { |
| 179 | int i; |
179 | int i; |