Rev 2245 | Rev 2263 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2245 | Rev 2262 | ||
---|---|---|---|
Line 135... | Line 135... | ||
135 | { |
135 | { |
136 | asm("sub lr, lr, #4"); |
136 | asm("sub lr, lr, #4"); |
137 | PROCESS_EXCEPTION(EXC_IRQ); |
137 | PROCESS_EXCEPTION(EXC_IRQ); |
138 | } |
138 | } |
139 | 139 | ||
- | 140 | static void prefetch_abort_exception(int exc_no, istate_t* istate) |
|
- | 141 | { |
|
- | 142 | //aux_puts("(PREFETCH|DATA) ABORT exception caught, not processed.\n"); |
|
- | 143 | } |
|
- | 144 | ||
140 | 145 | ||
141 | /** Interrupt Exception handler. |
146 | /** Interrupt Exception handler. |
142 | * Determines the sources of interrupt, and calls their handlers. |
147 | * Determines the sources of interrupt, and calls their handlers. |
143 | */ |
148 | */ |
144 | static void irq_exception(int exc_no, istate_t* istate) |
149 | static void irq_exception(int exc_no, istate_t* istate) |
Line 206... | Line 211... | ||
206 | 211 | ||
207 | install_handler((unsigned)fiq_exception_entry, |
212 | install_handler((unsigned)fiq_exception_entry, |
208 | (unsigned*)EXC_FIQ_VEC); |
213 | (unsigned*)EXC_FIQ_VEC); |
209 | } |
214 | } |
210 | 215 | ||
- | 216 | /** Activates using high exception vectors addresses. */ |
|
- | 217 | static void high_vectors() |
|
- | 218 | { |
|
- | 219 | uint32_t control_reg; |
|
- | 220 | ||
- | 221 | asm volatile( "mrc p15, 0, %0, c1, c1": "=r" (control_reg)); |
|
- | 222 | ||
- | 223 | //switch on the high vectors bit |
|
- | 224 | control_reg |= CP15_R1_HIGH_VECTORS_BIT; |
|
- | 225 | ||
- | 226 | asm volatile( "mcr p15, 0, %0, c1, c1" : : "r" (control_reg)); |
|
- | 227 | } |
|
- | 228 | ||
- | 229 | ||
211 | /** Initializes exception handling. |
230 | /** Initializes exception handling. |
212 | * |
231 | * |
213 | * Installs low-level exception handlers and then registers |
232 | * Installs low-level exception handlers and then registers |
214 | * exceptions and their handlers to kernel exception dispatcher. |
233 | * exceptions and their handlers to kernel exception dispatcher. |
215 | */ |
234 | */ |
216 | void exception_init(void) |
235 | void exception_init(void) |
217 | { |
236 | { |
- | 237 | #ifdef HIGH_EXCEPTION_VECTORS |
|
- | 238 | high_vectors(); |
|
- | 239 | #endif |
|
- | 240 | ||
218 | install_exception_handlers(); |
241 | install_exception_handlers(); |
219 | 242 | ||
220 | exc_register(EXC_IRQ, "interrupt", (iroutine) irq_exception); |
243 | exc_register(EXC_IRQ, "interrupt", (iroutine) irq_exception); |
- | 244 | exc_register(EXC_PREFETCH_ABORT, "prefetch abort", (iroutine) prefetch_abort_exception); |
|
- | 245 | exc_register(EXC_DATA_ABORT, "data abort", (iroutine) prefetch_abort_exception); |
|
221 | /* TODO add next */ |
246 | /* TODO add next */ |
222 | } |
247 | } |
223 | 248 | ||
224 | /* TODO change soon, temporary hack. */ |
249 | /* TODO change soon, temporary hack. */ |
225 | void setup_exception_stacks() |
250 | void setup_exception_stacks() |
226 | { |
251 | { |
227 | /* switch to particular mode and set "sp" there */ |
252 | /* switch to particular mode and set "sp" there */ |
- | 253 | ||
228 | uint32_t cspr = current_status_reg_read(); |
254 | uint32_t cspr = current_status_reg_read(); |
- | 255 | ||
- | 256 | /* IRQ stack */ |
|
229 | current_status_reg_control_write( |
257 | current_status_reg_control_write( |
230 | (cspr & ~STATUS_REG_MODE_MASK) | IRQ_MODE |
258 | (cspr & ~STATUS_REG_MODE_MASK) | IRQ_MODE |
231 | ); |
259 | ); |
232 | asm("ldr sp, =irq_stack"); |
260 | asm("ldr sp, =irq_stack"); |
- | 261 | ||
- | 262 | /* abort stack */ |
|
233 | current_status_reg_control_write( cspr); |
263 | current_status_reg_control_write( |
- | 264 | (cspr & ~STATUS_REG_MODE_MASK) | ABORT_MODE |
|
- | 265 | ); |
|
- | 266 | asm("ldr sp, =abort_stack"); |
|
234 | 267 | ||
235 | /* TODO if you want to test other exceptions than IRQ, |
268 | /* TODO if you want to test other exceptions than IRQ, |
236 | make stack analogous to irq_stack (in start.S), |
269 | make stack analogous to irq_stack (in start.S), |
237 | and then set stack pointer here */ |
270 | and then set stack pointer here */ |
- | 271 | ||
- | 272 | current_status_reg_control_write( cspr); |
|
- | 273 | ||
238 | } |
274 | } |
239 | 275 | ||
240 | /** @} |
276 | /** @} |
241 | */ |
277 | */ |