[9364cf66] | 1 | /** |
---|
| 2 | * @file |
---|
| 3 | * |
---|
| 4 | * ARM exception support code. |
---|
| 5 | */ |
---|
| 6 | |
---|
| 7 | /* |
---|
| 8 | * COPYRIGHT (c) 2000 Canon Research Centre France SA. |
---|
| 9 | * Emmanuel Raguet, mailto:raguet@crf.canon.fr |
---|
| 10 | * |
---|
| 11 | * Copyright (c) 2002 Advent Networks, Inc |
---|
| 12 | * Jay Monkman <jmonkman@adventnetworks.com> |
---|
| 13 | * |
---|
| 14 | * Copyright (c) 2007 Ray xu <rayx.cn@gmail.com> |
---|
| 15 | * |
---|
| 16 | * The license and distribution terms for this file may be |
---|
| 17 | * found in the file LICENSE in this distribution or at |
---|
| 18 | * http://www.rtems.com/license/LICENSE. |
---|
| 19 | * |
---|
| 20 | * Moved from file 'cpukit/score/cpu/arm/cpu.c'. |
---|
| 21 | * |
---|
| 22 | * $Id$ |
---|
| 23 | */ |
---|
| 24 | |
---|
[0acc9af3] | 25 | #ifdef HAVE_CONFIG_H |
---|
| 26 | #include "config.h" |
---|
| 27 | #endif |
---|
| 28 | |
---|
[9364cf66] | 29 | #include <rtems/system.h> |
---|
| 30 | #include <rtems.h> |
---|
| 31 | #include <rtems/bspIo.h> |
---|
| 32 | #include <rtems/score/isr.h> |
---|
| 33 | #include <rtems/score/wkspace.h> |
---|
| 34 | #include <rtems/score/thread.h> |
---|
| 35 | #include <rtems/score/cpu.h> |
---|
| 36 | |
---|
| 37 | static void _defaultExcHandler (CPU_Exception_frame *ctx) |
---|
| 38 | { |
---|
| 39 | printk("\n\r"); |
---|
| 40 | printk("----------------------------------------------------------\n\r"); |
---|
| 41 | #if 1 |
---|
| 42 | printk("Exception 0x%x caught at PC 0x%x by thread %d\n", |
---|
| 43 | ctx->register_ip, ctx->register_lr - 4, |
---|
| 44 | _Thread_Executing->Object.id); |
---|
| 45 | #endif |
---|
| 46 | printk("----------------------------------------------------------\n\r"); |
---|
| 47 | printk("Processor execution context at time of the fault was :\n\r"); |
---|
| 48 | printk("----------------------------------------------------------\n\r"); |
---|
| 49 | #if 0 |
---|
| 50 | printk(" r0 = %8x r1 = %8x r2 = %8x r3 = %8x\n\r", |
---|
[5bb38e15] | 51 | ctx->register_r0, ctx->register_r1, |
---|
[9364cf66] | 52 | ctx->register_r2, ctx->register_r3); |
---|
| 53 | printk(" r4 = %8x r5 = %8x r6 = %8x r7 = %8x\n\r", |
---|
[5bb38e15] | 54 | ctx->register_r4, ctx->register_r5, |
---|
[9364cf66] | 55 | ctx->register_r6, ctx->register_r7); |
---|
| 56 | printk(" r8 = %8x r9 = %8x r10 = %8x\n\r", |
---|
| 57 | ctx->register_r8, ctx->register_r9, ctx->register_r10); |
---|
| 58 | printk(" fp = %8x ip = %8x sp = %8x pc = %8x\n\r", |
---|
[5bb38e15] | 59 | ctx->register_fp, ctx->register_ip, |
---|
[9364cf66] | 60 | ctx->register_sp, ctx->register_lr - 4); |
---|
| 61 | printk("----------------------------------------------------------\n\r"); |
---|
[5bb38e15] | 62 | #endif |
---|
[9364cf66] | 63 | if (_ISR_Nest_level > 0) { |
---|
| 64 | /* |
---|
| 65 | * In this case we shall not delete the task interrupted as |
---|
| 66 | * it has nothing to do with the fault. We cannot return either |
---|
| 67 | * because the eip points to the faulty instruction so... |
---|
| 68 | */ |
---|
| 69 | printk("Exception while executing ISR!!!. System locked\n\r"); |
---|
| 70 | while(1); |
---|
| 71 | } |
---|
| 72 | else { |
---|
| 73 | printk("*********** FAULTY THREAD WILL BE DELETED **************\n\r"); |
---|
| 74 | rtems_task_delete(_Thread_Executing->Object.id); |
---|
| 75 | } |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | typedef void (*cpuExcHandlerType) (CPU_Exception_frame*); |
---|
| 79 | |
---|
| 80 | cpuExcHandlerType _currentExcHandler = _defaultExcHandler; |
---|
| 81 | |
---|
[5bb38e15] | 82 | extern void _Exception_Handler_Undef_Swi(void); |
---|
| 83 | extern void _Exception_Handler_Abort(void); |
---|
| 84 | extern void _exc_data_abort(void); |
---|
[9364cf66] | 85 | |
---|
| 86 | |
---|
| 87 | |
---|
| 88 | /* FIXME: put comments here */ |
---|
| 89 | void rtems_exception_init_mngt(void) |
---|
| 90 | { |
---|
| 91 | ISR_Level level; |
---|
[5bb38e15] | 92 | |
---|
[9364cf66] | 93 | _CPU_ISR_Disable(level); |
---|
| 94 | _CPU_ISR_install_vector(ARM_EXCEPTION_UNDEF, |
---|
| 95 | _Exception_Handler_Undef_Swi, |
---|
| 96 | NULL); |
---|
[5bb38e15] | 97 | |
---|
[9364cf66] | 98 | _CPU_ISR_install_vector(ARM_EXCEPTION_SWI, |
---|
| 99 | _Exception_Handler_Undef_Swi, |
---|
| 100 | NULL); |
---|
[5bb38e15] | 101 | |
---|
[9364cf66] | 102 | _CPU_ISR_install_vector(ARM_EXCEPTION_PREF_ABORT, |
---|
| 103 | _Exception_Handler_Abort, |
---|
| 104 | NULL); |
---|
[5bb38e15] | 105 | |
---|
[9364cf66] | 106 | _CPU_ISR_install_vector(ARM_EXCEPTION_DATA_ABORT, |
---|
| 107 | _exc_data_abort, |
---|
| 108 | NULL); |
---|
[5bb38e15] | 109 | |
---|
| 110 | _CPU_ISR_install_vector(ARM_EXCEPTION_FIQ, |
---|
[9364cf66] | 111 | _Exception_Handler_Abort, |
---|
| 112 | NULL); |
---|
[5bb38e15] | 113 | |
---|
| 114 | _CPU_ISR_install_vector(ARM_EXCEPTION_IRQ, |
---|
[9364cf66] | 115 | _Exception_Handler_Abort, |
---|
| 116 | NULL); |
---|
[5bb38e15] | 117 | |
---|
[9364cf66] | 118 | _CPU_ISR_Enable(level); |
---|
| 119 | } |
---|