Rev 4647 | Rev 4665 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4647 | Rev 4651 | ||
---|---|---|---|
Line 37... | Line 37... | ||
37 | #include <arch/memstr.h> |
37 | #include <arch/memstr.h> |
38 | #include <arch/regutils.h> |
38 | #include <arch/regutils.h> |
39 | #include <interrupt.h> |
39 | #include <interrupt.h> |
40 | #include <arch/mm/page_fault.h> |
40 | #include <arch/mm/page_fault.h> |
41 | #include <arch/barrier.h> |
41 | #include <arch/barrier.h> |
42 | #include <arch/drivers/gxemul.h> |
42 | #include <arch/machine.h> |
43 | #include <print.h> |
43 | #include <print.h> |
44 | #include <syscall/syscall.h> |
44 | #include <syscall/syscall.h> |
45 | 45 | ||
46 | /** Offset used in calculation of exception handler's relative address. |
46 | /** Offset used in calculation of exception handler's relative address. |
47 | * |
47 | * |
Line 98... | Line 98... | ||
98 | "mov r3, r13\n" |
98 | "mov r3, r13\n" |
99 | "stmfd r13!, {r2}\n" |
99 | "stmfd r13!, {r2}\n" |
100 | "mov r2, lr\n" |
100 | "mov r2, lr\n" |
101 | "stmfd r13!, {r4-r12}\n" |
101 | "stmfd r13!, {r4-r12}\n" |
102 | "mov r1, r13\n" |
102 | "mov r1, r13\n" |
103 | 103 | ||
104 | /* the following two lines are for debugging */ |
104 | /* the following two lines are for debugging */ |
105 | "mov sp, #0\n" |
105 | "mov sp, #0\n" |
106 | "mov lr, #0\n" |
106 | "mov lr, #0\n" |
107 | "msr cpsr_c, r0\n" |
107 | "msr cpsr_c, r0\n" |
108 | 108 | ||
Line 150... | Line 150... | ||
150 | "mov lr, r2 \n" |
150 | "mov lr, r2 \n" |
151 | "msr cpsr_c, r0 \n" |
151 | "msr cpsr_c, r0 \n" |
152 | 152 | ||
153 | /* actual return */ |
153 | /* actual return */ |
154 | "2:\n" |
154 | "2:\n" |
155 | "ldmfd r13, {r0-r12, pc}^\n" |
155 | "ldmfd r13!, {r0-r12, pc}^\n" |
156 | ); |
156 | ); |
157 | } |
157 | } |
158 | 158 | ||
159 | 159 | ||
160 | /** Switch CPU to mode in which interrupts are serviced (currently it |
160 | /** Switch CPU to mode in which interrupts are serviced (currently it |
Line 305... | Line 305... | ||
305 | { |
305 | { |
306 | istate->r0 = syscall_handler(istate->r0, istate->r1, istate->r2, |
306 | istate->r0 = syscall_handler(istate->r0, istate->r1, istate->r2, |
307 | istate->r3, istate->r4, istate->r5, istate->r6); |
307 | istate->r3, istate->r4, istate->r5, istate->r6); |
308 | } |
308 | } |
309 | 309 | ||
310 | /** Returns the mask of active interrupts. */ |
- | |
311 | static inline uint32_t gxemul_irqc_get_sources(void) |
- | |
312 | { |
- | |
313 | return *((uint32_t *) gxemul_irqc); |
- | |
314 | } |
- | |
315 | - | ||
316 | /** Interrupt Exception handler. |
- | |
317 | * |
- | |
318 | * Determines the sources of interrupt and calls their handlers. |
- | |
319 | */ |
- | |
320 | static void irq_exception(int exc_no, istate_t *istate) |
- | |
321 | { |
- | |
322 | uint32_t sources = gxemul_irqc_get_sources(); |
- | |
323 | unsigned int i; |
- | |
324 | - | ||
325 | for (i = 0; i < GXEMUL_IRQC_MAX_IRQ; i++) { |
- | |
326 | if (sources & (1 << i)) { |
- | |
327 | irq_t *irq = irq_dispatch_and_lock(i); |
- | |
328 | if (irq) { |
- | |
329 | /* The IRQ handler was found. */ |
- | |
330 | irq->handler(irq); |
- | |
331 | spinlock_unlock(&irq->lock); |
- | |
332 | } else { |
- | |
333 | /* Spurious interrupt.*/ |
- | |
334 | printf("cpu%d: spurious interrupt (inum=%d)\n", |
- | |
335 | CPU->id, i); |
- | |
336 | } |
- | |
337 | } |
- | |
338 | } |
- | |
339 | } |
- | |
340 | - | ||
341 | /** Fills exception vectors with appropriate exception handlers. */ |
310 | /** Fills exception vectors with appropriate exception handlers. */ |
342 | void install_exception_handlers(void) |
311 | void install_exception_handlers(void) |
343 | { |
312 | { |
344 | install_handler((unsigned) reset_exception_entry, |
313 | install_handler((unsigned) reset_exception_entry, |
345 | (unsigned *) EXC_RESET_VEC); |
314 | (unsigned *) EXC_RESET_VEC); |
Line 382... | Line 351... | ||
382 | :: [control_reg] "r" (control_reg) |
351 | :: [control_reg] "r" (control_reg) |
383 | ); |
352 | ); |
384 | } |
353 | } |
385 | #endif |
354 | #endif |
386 | 355 | ||
- | 356 | /** Interrupt Exception handler. |
|
- | 357 | * |
|
- | 358 | * Determines the sources of interrupt and calls their handlers. |
|
- | 359 | */ |
|
- | 360 | static void irq_exception(int exc_no, istate_t *istate) |
|
- | 361 | { |
|
- | 362 | machine_irq_exception(exc_no, istate); |
|
- | 363 | } |
|
- | 364 | ||
387 | /** Initializes exception handling. |
365 | /** Initializes exception handling. |
388 | * |
366 | * |
389 | * Installs low-level exception handlers and then registers |
367 | * Installs low-level exception handlers and then registers |
390 | * exceptions and their handlers to kernel exception dispatcher. |
368 | * exceptions and their handlers to kernel exception dispatcher. |
391 | */ |
369 | */ |