source: rtems/c/src/lib/libbsp/powerpc/mvme5500/vectors/exceptionhandler.c @ 46a6fa91

4.104.114.84.95
Last change on this file since 46a6fa91 was f4a59e33, checked in by Ralf Corsepius <ralf.corsepius@…>, on 10/21/04 at 08:17:43

2004-10-21 Ralf Corsepius <ralf_corsepius@…>

  • start/preload.S, include/bsp.h, vectors/exceptionhandler.c, startup/bspstart.c: Misc. adaptations to rtems-4.7.
  • Property mode set to 100644
File size: 6.2 KB
Line 
1/* $Id$ */
2
3/* Copyright :
4 * (C) Author: Till Straumann <strauman@slac.stanford.edu>, 2002/5
5 * (C) S. Kate Feng <feng1@bnl.gov> 4/2004 modified it for MVME5500
6 */
7
8#include <bsp.h>
9#include <bsp/vectors.h>
10#include <libcpu/raw_exception.h>
11#include <libcpu/spr.h>
12#include <bsp/pci.h>
13#include <rtems/bspIo.h>
14
15#include <bsp/bspException.h>
16
17#define SRR1_TEA_EXC    (1<<(31-13))
18#define SRR1_MCP_EXC    (1<<(31-12))
19
20void
21BSP_printStackTrace();
22
23
24void
25rtemsReboot(void);
26
27static volatile BSP_ExceptionExtension  BSP_exceptionExtension = 0;
28
29BSP_ExceptionExtension
30BSP_exceptionHandlerInstall(BSP_ExceptionExtension e)
31{
32volatile BSP_ExceptionExtension test;
33        if ( RTEMS_SUCCESSFUL != rtems_task_variable_get(RTEMS_SELF, (void*)&BSP_exceptionExtension, (void**)&test) ) {
34                /* not yet added */
35                rtems_task_variable_add(RTEMS_SELF, (void*)&BSP_exceptionExtension, 0);
36        }
37        test = BSP_exceptionExtension;
38        BSP_exceptionExtension = e;
39        return test;
40}
41
42void
43BSP_exceptionHandler(BSP_Exception_frame* excPtr)
44{
45uint32_t        note;
46BSP_ExceptionExtension  ext=0;
47rtems_id                id=0;
48int                     recoverable = 0;
49char                    *fmt="Uhuuuh, Exception %d in unknown task???\n";
50int                     quiet=0;
51       
52 if (!quiet) printk("In BSP_exceptionHandler()\n");
53   /* If we are in interrupt context, we are in trouble - skip the user
54    * hook and panic
55    */
56    if (rtems_interrupt_is_in_progress()) {
57      fmt="Aieeh, Exception %d in interrupt handler\n";
58    } else if ( !_Thread_Executing) {
59      fmt="Aieeh, Exception %d in initialization code\n";
60    } else {
61    /* retrieve the notepad which possibly holds an extention pointer */
62    if (RTEMS_SUCCESSFUL==rtems_task_ident(RTEMS_SELF,RTEMS_LOCAL,&id) &&
63#if 0
64/* Must not use a notepad due to unknown initial value (notepad memory is allocated from the
65 * workspace)!
66 */
67                RTEMS_SUCCESSFUL==rtems_task_get_note(id, BSP_EXCEPTION_NOTEPAD, &note)
68#else
69                RTEMS_SUCCESSFUL==rtems_task_variable_get(id, (void*)&BSP_exceptionExtension, (void**)&note)
70#endif
71         ) {
72           ext = (BSP_ExceptionExtension)note;
73           if (ext)
74               quiet=ext->quiet;
75           if (!quiet) {
76              printk("Task (Id 0x%08x) got ",id);
77           }
78           fmt="exception %d\n";
79        }
80    }
81       
82    if (ext && ext->lowlevelHook && ext->lowlevelHook(excPtr,ext,0)) {
83                /* they did all the work and want us to do nothing! */
84      printk("they did all the work and want us to do nothing!\n");
85                return;
86    }
87
88    if (!quiet) {
89       /* message about exception */
90       printk(fmt, excPtr->_EXC_number);
91       /* register dump */
92       printk("\t Next PC or Address of fault = %x, ", excPtr->EXC_SRR0);
93       printk("Mvme5500 Saved MSR = %x\n", excPtr->EXC_SRR1);
94       printk("\t R0  = %08x", excPtr->GPR0);
95       printk(" R1  = %08x", excPtr->GPR1);
96       printk(" R2  = %08x", excPtr->GPR2);
97       printk(" R3  = %08x\n", excPtr->GPR3);
98       printk("\t R4  = %08x", excPtr->GPR4);
99       printk(" R5  = %08x", excPtr->GPR5);
100       printk(" R6  = %08x", excPtr->GPR6);
101       printk(" R7  = %08x\n", excPtr->GPR7);
102       printk("\t R8  = %08x", excPtr->GPR8);
103       printk(" R9  = %08x", excPtr->GPR9);
104       printk(" R10 = %08x", excPtr->GPR10);
105       printk(" R11 = %08x\n", excPtr->GPR11);
106       printk("\t R12 = %08x", excPtr->GPR12);
107       printk(" R13 = %08x", excPtr->GPR13);
108       printk(" R14 = %08x", excPtr->GPR14);
109       printk(" R15 = %08x\n", excPtr->GPR15);
110       printk("\t R16 = %08x", excPtr->GPR16);
111       printk(" R17 = %08x", excPtr->GPR17);
112       printk(" R18 = %08x", excPtr->GPR18);
113       printk(" R19 = %08x\n", excPtr->GPR19);
114       printk("\t R20 = %08x", excPtr->GPR20);
115       printk(" R21 = %08x", excPtr->GPR21);
116       printk(" R22 = %08x", excPtr->GPR22);
117       printk(" R23 = %08x\n", excPtr->GPR23);
118       printk("\t R24 = %08x", excPtr->GPR24);
119       printk(" R25 = %08x", excPtr->GPR25);
120       printk(" R26 = %08x", excPtr->GPR26);
121       printk(" R27 = %08x\n", excPtr->GPR27);
122       printk("\t R28 = %08x", excPtr->GPR28);
123       printk(" R29 = %08x", excPtr->GPR29);
124       printk(" R30 = %08x", excPtr->GPR30);
125       printk(" R31 = %08x\n", excPtr->GPR31);
126       printk("\t CR  = %08x\n", excPtr->EXC_CR);
127       printk("\t CTR = %08x\n", excPtr->EXC_CTR);
128       printk("\t XER = %08x\n", excPtr->EXC_XER);
129       printk("\t LR  = %08x\n", excPtr->EXC_LR);
130       printk("\t DAR = %08x\n", excPtr->EXC_DAR);
131       
132       BSP_printStackTrace(excPtr);
133    }
134       
135    if (ASM_MACH_VECTOR == excPtr->_EXC_number) {
136       /* ollah , we got a machine check - this could either
137        * be a TEA, MCP or internal; let's see and provide more info
138        */
139       if (!quiet)
140           printk("Machine check; reason:");
141       if ( ! (excPtr->EXC_SRR1 & (SRR1_TEA_EXC | SRR1_MCP_EXC)) ) {
142           if (!quiet)
143               printk("SRR1\n");
144       } else {
145           if (excPtr->EXC_SRR1 & (SRR1_TEA_EXC)) {
146              if (!quiet)
147                 printk(" TEA");
148           }
149           if (excPtr->EXC_SRR1 & (SRR1_MCP_EXC)) {
150              unsigned long gerr;
151
152              if (!quiet) printk(" MCP\n");
153
154              /* it's MCP; gather info from the host bridge */
155              gerr=_BSP_clear_hostbridge_errors(0,0);
156              if (gerr&0x80000000) printk("GT64260 Parity error\n");
157              if (gerr&0x40000000) printk("GT64260 SysErr\n");
158              if ((!quiet) && (!gerr)) printk("GT64260 host bridge seems OK\n");
159            }
160       }
161    } else if (ASM_DEC_VECTOR == excPtr->_EXC_number) {
162                recoverable = 1;
163    } else if (ASM_SYS_VECTOR == excPtr->_EXC_number) {
164#ifdef TEST_RAW_EXCEPTION_CODE
165                recoverable = 1;
166#else
167                recoverable = 0;
168#endif
169    }
170
171    /* call them for a second time giving a chance to intercept
172     * the task_suspend
173     */
174    if (ext && ext->lowlevelHook && ext->lowlevelHook(excPtr, ext, 1))
175                return;
176
177    if (!recoverable) {
178                if (id) {
179                        /* if there's a highlevel hook, install it */
180                        if (ext && ext->highlevelHook) {
181                                excPtr->EXC_SRR0 = (uint32_t)ext->highlevelHook;
182                                excPtr->GPR3     = (uint32_t)ext;
183                                return;
184                        }
185                        if (excPtr->EXC_SRR1 & MSR_FP) {
186                                /* thread dispatching is _not_ disabled at this point; hence
187                                 * we must make sure we have the FPU enabled...
188                                 */
189                                _write_MSR( _read_MSR() | MSR_FP );
190                                __asm__ __volatile__("isync");
191                        }
192                        printk("unrecoverable exception!!! task %08x suspended\n",id);
193                        rtems_task_suspend(id);
194                } else {
195                        printk("PANIC, rebooting...\n");
196                        rtemsReboot();
197                }
198    }
199}
Note: See TracBrowser for help on using the repository browser.