1 | /* |
---|
2 | * Authorship |
---|
3 | * ---------- |
---|
4 | * This software was created by |
---|
5 | * Till Straumann <strauman@slac.stanford.edu>, 5/2002, |
---|
6 | * Stanford Linear Accelerator Center, Stanford University. |
---|
7 | * |
---|
8 | * Acknowledgement of sponsorship |
---|
9 | * ------------------------------ |
---|
10 | * This software was produced by |
---|
11 | * the Stanford Linear Accelerator Center, Stanford University, |
---|
12 | * under Contract DE-AC03-76SFO0515 with the Department of Energy. |
---|
13 | * |
---|
14 | * Government disclaimer of liability |
---|
15 | * ---------------------------------- |
---|
16 | * Neither the United States nor the United States Department of Energy, |
---|
17 | * nor any of their employees, makes any warranty, express or implied, or |
---|
18 | * assumes any legal liability or responsibility for the accuracy, |
---|
19 | * completeness, or usefulness of any data, apparatus, product, or process |
---|
20 | * disclosed, or represents that its use would not infringe privately owned |
---|
21 | * rights. |
---|
22 | * |
---|
23 | * Stanford disclaimer of liability |
---|
24 | * -------------------------------- |
---|
25 | * Stanford University makes no representations or warranties, express or |
---|
26 | * implied, nor assumes any liability for the use of this software. |
---|
27 | * |
---|
28 | * Stanford disclaimer of copyright |
---|
29 | * -------------------------------- |
---|
30 | * Stanford University, owner of the copyright, hereby disclaims its |
---|
31 | * copyright and all other rights in this software. Hence, anyone may |
---|
32 | * freely use it for any purpose without restriction. |
---|
33 | * |
---|
34 | * Maintenance of notices |
---|
35 | * ---------------------- |
---|
36 | * In the interest of clarity regarding the origin and status of this |
---|
37 | * SLAC software, this and all the preceding Stanford University notices |
---|
38 | * are to remain affixed to any copy or derivative of this software made |
---|
39 | * or distributed by the recipient and are to be affixed to any copy of |
---|
40 | * software made or distributed by the recipient that contains a copy or |
---|
41 | * derivative of this software. |
---|
42 | * |
---|
43 | * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03 |
---|
44 | */ |
---|
45 | /* Copyright : |
---|
46 | * (C) S. Kate Feng <feng1@bnl.gov> 4/2004 modified it for MVME5500 |
---|
47 | */ |
---|
48 | |
---|
49 | #include <bsp.h> |
---|
50 | #include <bsp/vectors.h> |
---|
51 | #include <bsp/bootcard.h> |
---|
52 | #include <libcpu/spr.h> |
---|
53 | #include <bsp/pci.h> |
---|
54 | #include <rtems/bspIo.h> |
---|
55 | #include <rtems/score/percpu.h> |
---|
56 | #include <threads.h> |
---|
57 | #include <inttypes.h> |
---|
58 | |
---|
59 | #include <bsp/bspException.h> |
---|
60 | |
---|
61 | #define SRR1_TEA_EXC (1<<(31-13)) |
---|
62 | #define SRR1_MCP_EXC (1<<(31-12)) |
---|
63 | |
---|
64 | static thread_local volatile BSP_ExceptionExtension BSP_exceptionExtension = 0; |
---|
65 | |
---|
66 | BSP_ExceptionExtension |
---|
67 | BSP_exceptionHandlerInstall(BSP_ExceptionExtension e) |
---|
68 | { |
---|
69 | volatile BSP_ExceptionExtension test; |
---|
70 | test = BSP_exceptionExtension; |
---|
71 | BSP_exceptionExtension = e; |
---|
72 | return test; |
---|
73 | } |
---|
74 | |
---|
75 | void |
---|
76 | BSP_exceptionHandler(BSP_Exception_frame* excPtr) |
---|
77 | { |
---|
78 | BSP_ExceptionExtension ext=0; |
---|
79 | rtems_id id=0; |
---|
80 | int recoverable = 0; |
---|
81 | char *fmt="Uhuuuh, Exception %d in unknown task???\n"; |
---|
82 | int quiet=0; |
---|
83 | |
---|
84 | if (!quiet) printk("In BSP_exceptionHandler()\n"); |
---|
85 | /* If we are in interrupt context, we are in trouble - skip the user |
---|
86 | * hook and panic |
---|
87 | */ |
---|
88 | if (rtems_interrupt_is_in_progress()) { |
---|
89 | fmt="Aieeh, Exception %d in interrupt handler\n"; |
---|
90 | } else if ( !_Thread_Executing) { |
---|
91 | fmt="Aieeh, Exception %d in initialization code\n"; |
---|
92 | } else { |
---|
93 | /* retrieve the notepad which possibly holds an extention pointer */ |
---|
94 | if (RTEMS_SUCCESSFUL==rtems_task_ident(RTEMS_SELF,RTEMS_LOCAL,&id)) { |
---|
95 | ext = BSP_exceptionExtension; |
---|
96 | if (ext) |
---|
97 | quiet=ext->quiet; |
---|
98 | if (!quiet) { |
---|
99 | printk("Task (Id 0x%08" PRIx32 ") got ",id); |
---|
100 | } |
---|
101 | fmt="exception %d\n"; |
---|
102 | } |
---|
103 | } |
---|
104 | |
---|
105 | if (ext && ext->lowlevelHook && ext->lowlevelHook(excPtr,ext,0)) { |
---|
106 | /* they did all the work and want us to do nothing! */ |
---|
107 | printk("they did all the work and want us to do nothing!\n"); |
---|
108 | return; |
---|
109 | } |
---|
110 | |
---|
111 | if (!quiet) { |
---|
112 | /* message about exception */ |
---|
113 | printk(fmt, excPtr->_EXC_number); |
---|
114 | /* register dump */ |
---|
115 | printk("\t Next PC or Address of fault = %" PRIxPTR ", ", excPtr->EXC_SRR0); |
---|
116 | printk("Mvme5500 Saved MSR = %" PRIxPTR "\n", excPtr->EXC_SRR1); |
---|
117 | printk("\t R0 = %08" PRIxPTR, excPtr->GPR0); |
---|
118 | printk(" R1 = %08" PRIxPTR, excPtr->GPR1); |
---|
119 | printk(" R2 = %08" PRIxPTR, excPtr->GPR2); |
---|
120 | printk(" R3 = %08" PRIxPTR "\n", excPtr->GPR3); |
---|
121 | printk("\t R4 = %08" PRIxPTR, excPtr->GPR4); |
---|
122 | printk(" R5 = %08" PRIxPTR, excPtr->GPR5); |
---|
123 | printk(" R6 = %08" PRIxPTR, excPtr->GPR6); |
---|
124 | printk(" R7 = %08" PRIxPTR "\n", excPtr->GPR7); |
---|
125 | printk("\t R8 = %08" PRIxPTR, excPtr->GPR8); |
---|
126 | printk(" R9 = %08" PRIxPTR, excPtr->GPR9); |
---|
127 | printk(" R10 = %08" PRIxPTR, excPtr->GPR10); |
---|
128 | printk(" R11 = %08" PRIxPTR "\n", excPtr->GPR11); |
---|
129 | printk("\t R12 = %08" PRIxPTR, excPtr->GPR12); |
---|
130 | printk(" R13 = %08" PRIxPTR, excPtr->GPR13); |
---|
131 | printk(" R14 = %08" PRIxPTR, excPtr->GPR14); |
---|
132 | printk(" R15 = %08" PRIxPTR "\n", excPtr->GPR15); |
---|
133 | printk("\t R16 = %08" PRIxPTR, excPtr->GPR16); |
---|
134 | printk(" R17 = %08" PRIxPTR, excPtr->GPR17); |
---|
135 | printk(" R18 = %08" PRIxPTR, excPtr->GPR18); |
---|
136 | printk(" R19 = %08" PRIxPTR "\n", excPtr->GPR19); |
---|
137 | printk("\t R20 = %08" PRIxPTR, excPtr->GPR20); |
---|
138 | printk(" R21 = %08" PRIxPTR, excPtr->GPR21); |
---|
139 | printk(" R22 = %08" PRIxPTR, excPtr->GPR22); |
---|
140 | printk(" R23 = %08" PRIxPTR "\n", excPtr->GPR23); |
---|
141 | printk("\t R24 = %08" PRIxPTR, excPtr->GPR24); |
---|
142 | printk(" R25 = %08" PRIxPTR, excPtr->GPR25); |
---|
143 | printk(" R26 = %08" PRIxPTR, excPtr->GPR26); |
---|
144 | printk(" R27 = %08" PRIxPTR "\n", excPtr->GPR27); |
---|
145 | printk("\t R28 = %08" PRIxPTR, excPtr->GPR28); |
---|
146 | printk(" R29 = %08" PRIxPTR, excPtr->GPR29); |
---|
147 | printk(" R30 = %08" PRIxPTR, excPtr->GPR30); |
---|
148 | printk(" R31 = %08" PRIxPTR "\n", excPtr->GPR31); |
---|
149 | printk("\t CR = %08" PRIx32 "\n", excPtr->EXC_CR); |
---|
150 | printk("\t CTR = %08" PRIxPTR "\n", excPtr->EXC_CTR); |
---|
151 | printk("\t XER = %08" PRIx32 "\n", excPtr->EXC_XER); |
---|
152 | printk("\t LR = %08" PRIxPTR "\n", excPtr->EXC_LR); |
---|
153 | |
---|
154 | BSP_printStackTrace(excPtr); |
---|
155 | } |
---|
156 | |
---|
157 | if (ASM_MACH_VECTOR == excPtr->_EXC_number) { |
---|
158 | /* ollah , we got a machine check - this could either |
---|
159 | * be a TEA, MCP or internal; let's see and provide more info |
---|
160 | */ |
---|
161 | if (!quiet) |
---|
162 | printk("Machine check; reason:"); |
---|
163 | if ( ! (excPtr->EXC_SRR1 & (SRR1_TEA_EXC | SRR1_MCP_EXC)) ) { |
---|
164 | if (!quiet) |
---|
165 | printk("SRR1\n"); |
---|
166 | } else { |
---|
167 | if (excPtr->EXC_SRR1 & (SRR1_TEA_EXC)) { |
---|
168 | if (!quiet) |
---|
169 | printk(" TEA"); |
---|
170 | } |
---|
171 | if (excPtr->EXC_SRR1 & (SRR1_MCP_EXC)) { |
---|
172 | unsigned long gerr; |
---|
173 | |
---|
174 | if (!quiet) printk(" MCP\n"); |
---|
175 | |
---|
176 | /* it's MCP; gather info from the host bridge */ |
---|
177 | gerr=_BSP_clear_hostbridge_errors(0,0); |
---|
178 | if (gerr&0x80000000) printk("GT64260 Parity error\n"); |
---|
179 | if (gerr&0x40000000) printk("GT64260 SysErr\n"); |
---|
180 | if ((!quiet) && (!gerr)) printk("GT64260 host bridge seems OK\n"); |
---|
181 | } |
---|
182 | } |
---|
183 | } else if (ASM_DEC_VECTOR == excPtr->_EXC_number) { |
---|
184 | recoverable = 1; |
---|
185 | } else if (ASM_SYS_VECTOR == excPtr->_EXC_number) { |
---|
186 | #ifdef TEST_RAW_EXCEPTION_CODE |
---|
187 | recoverable = 1; |
---|
188 | #else |
---|
189 | recoverable = 0; |
---|
190 | #endif |
---|
191 | } |
---|
192 | |
---|
193 | /* call them for a second time giving a chance to intercept |
---|
194 | * the task_suspend |
---|
195 | */ |
---|
196 | if (ext && ext->lowlevelHook && ext->lowlevelHook(excPtr, ext, 1)) |
---|
197 | return; |
---|
198 | |
---|
199 | if (!recoverable) { |
---|
200 | if (id) { |
---|
201 | /* if there's a highlevel hook, install it */ |
---|
202 | if (ext && ext->highlevelHook) { |
---|
203 | excPtr->EXC_SRR0 = (uint32_t)ext->highlevelHook; |
---|
204 | excPtr->GPR3 = (uint32_t)ext; |
---|
205 | return; |
---|
206 | } |
---|
207 | if (excPtr->EXC_SRR1 & MSR_FP) { |
---|
208 | /* thread dispatching is _not_ disabled at this point; hence |
---|
209 | * we must make sure we have the FPU enabled... |
---|
210 | */ |
---|
211 | _write_MSR( _read_MSR() | MSR_FP ); |
---|
212 | __asm__ __volatile__("isync"); |
---|
213 | } |
---|
214 | printk("unrecoverable exception!!! task %08" PRIx32 " suspended\n",id); |
---|
215 | rtems_task_suspend(id); |
---|
216 | } else { |
---|
217 | printk("PANIC, rebooting...\n"); |
---|
218 | bsp_reset(); |
---|
219 | } |
---|
220 | } |
---|
221 | } |
---|