[87db514] | 1 | /************************************************************************** |
---|
| 2 | * |
---|
| 3 | * Copyright (c) 2013 Alcatel-Lucent |
---|
| 4 | * |
---|
| 5 | * Alcatel Lucent licenses this file to You under the Apache License, |
---|
| 6 | * Version 2.0 (the "License"); you may not use this file except in |
---|
| 7 | * compliance with the License. A copy of the License is contained the |
---|
| 8 | * file LICENSE at the top level of this repository. |
---|
| 9 | * You may also obtain a copy of the License at: |
---|
| 10 | * |
---|
| 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
---|
| 12 | * |
---|
| 13 | * Unless required by applicable law or agreed to in writing, software |
---|
| 14 | * distributed under the License is distributed on an "AS IS" BASIS, |
---|
| 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
| 16 | * See the License for the specific language governing permissions and |
---|
| 17 | * limitations under the License. |
---|
| 18 | * |
---|
| 19 | ************************************************************************** |
---|
| 20 | * |
---|
| 21 | * FILENAME_HERE |
---|
| 22 | * |
---|
| 23 | * DESCRIPTION_HERE |
---|
| 24 | * |
---|
| 25 | * Original author: Ed Sutter (ed.sutter@alcatel-lucent.com) |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | #include "config.h" |
---|
| 30 | #include "arm.h" |
---|
| 31 | #include "stddefs.h" |
---|
| 32 | #include "genlib.h" |
---|
| 33 | #include "warmstart.h" |
---|
| 34 | |
---|
| 35 | ulong ExceptionAddr; |
---|
[a7b6f00] | 36 | int ExceptionType; |
---|
[87db514] | 37 | |
---|
[6e6815e] | 38 | #define PRIx32 "lx" |
---|
| 39 | #define PRIxPTR "lx" |
---|
| 40 | |
---|
| 41 | /* Taken from RTEMS cpukit/score/cpu/arm/arm-exception-frame-print.c */ |
---|
| 42 | static void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ) |
---|
| 43 | { |
---|
| 44 | printf( |
---|
| 45 | "\n" |
---|
| 46 | "R0 = 0x%08" PRIx32 " R8 = 0x%08" PRIx32 "\n" |
---|
| 47 | "R1 = 0x%08" PRIx32 " R9 = 0x%08" PRIx32 "\n" |
---|
| 48 | "R2 = 0x%08" PRIx32 " R10 = 0x%08" PRIx32 "\n" |
---|
| 49 | "R3 = 0x%08" PRIx32 " R11 = 0x%08" PRIx32 "\n" |
---|
| 50 | "R4 = 0x%08" PRIx32 " R12 = 0x%08" PRIx32 "\n" |
---|
| 51 | "R5 = 0x%08" PRIx32 " SP = 0x%08" PRIx32 "\n" |
---|
| 52 | "R6 = 0x%08" PRIx32 " LR = 0x%08" PRIxPTR "\n" |
---|
| 53 | "R7 = 0x%08" PRIx32 " PC = 0x%08" PRIxPTR "\n" |
---|
| 54 | "VEC = 0x%08" PRIxPTR "\n", |
---|
| 55 | frame->register_r0, |
---|
| 56 | frame->register_r8, |
---|
| 57 | frame->register_r1, |
---|
| 58 | frame->register_r9, |
---|
| 59 | frame->register_r2, |
---|
| 60 | frame->register_r10, |
---|
| 61 | frame->register_r3, |
---|
| 62 | frame->register_r11, |
---|
| 63 | frame->register_r4, |
---|
| 64 | frame->register_r12, |
---|
| 65 | frame->register_r5, |
---|
| 66 | frame->register_sp, |
---|
| 67 | frame->register_r6, |
---|
| 68 | (uint32_t) frame->register_lr, |
---|
| 69 | frame->register_r7, |
---|
| 70 | (uint32_t) frame->register_pc, |
---|
| 71 | (uint32_t) frame->vector |
---|
| 72 | ); |
---|
| 73 | } |
---|
| 74 | |
---|
[87db514] | 75 | /*********************************************************************** |
---|
| 76 | * |
---|
| 77 | * umon_exception() |
---|
| 78 | * Default exception handler used by the low level code in vectors_arm.S. |
---|
| 79 | */ |
---|
| 80 | void |
---|
[6e6815e] | 81 | umon_exception(CPU_Exception_frame *frame) |
---|
[87db514] | 82 | { |
---|
[6e6815e] | 83 | _CPU_Exception_frame_print(frame); |
---|
| 84 | |
---|
| 85 | ExceptionAddr = (uint32_t) frame->register_pc; |
---|
| 86 | ExceptionType = frame->vector; |
---|
| 87 | |
---|
[a7b6f00] | 88 | monrestart(EXCEPTION); |
---|
[87db514] | 89 | } |
---|
| 90 | |
---|
| 91 | /*********************************************************************** |
---|
| 92 | * |
---|
| 93 | * ExceptionType2String(): |
---|
| 94 | * This function simply returns a string that verbosely describes |
---|
| 95 | * the incoming exception type (vector number). |
---|
| 96 | */ |
---|
| 97 | char * |
---|
| 98 | ExceptionType2String(int type) |
---|
| 99 | { |
---|
[a7b6f00] | 100 | char *string; |
---|
[87db514] | 101 | |
---|
[a7b6f00] | 102 | switch(type) { |
---|
| 103 | case EXCTYPE_UNDEF: |
---|
| 104 | string = "Undefined instruction"; |
---|
| 105 | break; |
---|
| 106 | case EXCTYPE_ABORTP: |
---|
| 107 | string = "Abort prefetch"; |
---|
| 108 | break; |
---|
| 109 | case EXCTYPE_ABORTD: |
---|
| 110 | string = "Abort data"; |
---|
| 111 | break; |
---|
| 112 | case EXCTYPE_IRQ: |
---|
| 113 | string = "IRQ"; |
---|
| 114 | break; |
---|
| 115 | case EXCTYPE_FIRQ: |
---|
| 116 | string = "Fast IRQ"; |
---|
| 117 | break; |
---|
| 118 | case EXCTYPE_NOTASSGN: |
---|
| 119 | string = "Not assigned"; |
---|
| 120 | break; |
---|
| 121 | case EXCTYPE_SWI: |
---|
| 122 | string = "Software Interrupt"; |
---|
| 123 | break; |
---|
| 124 | default: |
---|
| 125 | string = "???"; |
---|
| 126 | break; |
---|
| 127 | } |
---|
| 128 | return(string); |
---|
[87db514] | 129 | } |
---|
| 130 | |
---|
| 131 | void |
---|
| 132 | vinit(void) |
---|
| 133 | { |
---|
| 134 | } |
---|