source: rtems/c/src/lib/libbsp/powerpc/mvme5500/vectors/exceptionhandler.c @ 48fed9a

4.115
Last change on this file since 48fed9a was 48fed9a, checked in by Sebastian Huber <sebastian.huber@…>, on 06/25/15 at 12:11:53

score: Simplify <rtems/system.h>

Drop the <rtems/score/percpu.h> include since this file exposes a lot of
implementation details.

  • Property mode set to 100644
File size: 8.1 KB
Line 
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
57#include <bsp/bspException.h>
58
59#define SRR1_TEA_EXC    (1<<(31-13))
60#define SRR1_MCP_EXC    (1<<(31-12))
61
62static volatile BSP_ExceptionExtension  BSP_exceptionExtension = 0;
63
64/*
65 * We know task variables are deprecated and don't want a warning. The
66 * use of task variables needs to be fixed in this file.
67 */
68#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
69
70BSP_ExceptionExtension
71BSP_exceptionHandlerInstall(BSP_ExceptionExtension e)
72{
73volatile BSP_ExceptionExtension test;
74        if ( RTEMS_SUCCESSFUL != rtems_task_variable_get(RTEMS_SELF, (void*)&BSP_exceptionExtension, (void**)&test) ) {
75                /* not yet added */
76                rtems_task_variable_add(RTEMS_SELF, (void*)&BSP_exceptionExtension, 0);
77        }
78        test = BSP_exceptionExtension;
79        BSP_exceptionExtension = e;
80        return test;
81}
82
83void
84BSP_exceptionHandler(BSP_Exception_frame* excPtr)
85{
86uint32_t        note;
87BSP_ExceptionExtension  ext=0;
88rtems_id                id=0;
89int                     recoverable = 0;
90char                    *fmt="Uhuuuh, Exception %d in unknown task???\n";
91int                     quiet=0;
92
93 if (!quiet) printk("In BSP_exceptionHandler()\n");
94   /* If we are in interrupt context, we are in trouble - skip the user
95    * hook and panic
96    */
97    if (rtems_interrupt_is_in_progress()) {
98      fmt="Aieeh, Exception %d in interrupt handler\n";
99    } else if ( !_Thread_Executing) {
100      fmt="Aieeh, Exception %d in initialization code\n";
101    } else {
102    /* retrieve the notepad which possibly holds an extention pointer */
103    if (RTEMS_SUCCESSFUL==rtems_task_ident(RTEMS_SELF,RTEMS_LOCAL,&id) &&
104#if 0
105/* Must not use a notepad due to unknown initial value (notepad memory is allocated from the
106 * workspace)!
107 */
108                RTEMS_SUCCESSFUL==rtems_task_get_note(id, BSP_EXCEPTION_NOTEPAD, &note)
109#else
110                RTEMS_SUCCESSFUL==rtems_task_variable_get(id, (void*)&BSP_exceptionExtension, (void**)&note)
111#endif
112         ) {
113           ext = (BSP_ExceptionExtension)note;
114           if (ext)
115               quiet=ext->quiet;
116           if (!quiet) {
117              printk("Task (Id 0x%08x) got ",id);
118           }
119           fmt="exception %d\n";
120        }
121    }
122
123    if (ext && ext->lowlevelHook && ext->lowlevelHook(excPtr,ext,0)) {
124                /* they did all the work and want us to do nothing! */
125      printk("they did all the work and want us to do nothing!\n");
126                return;
127    }
128
129    if (!quiet) {
130       /* message about exception */
131       printk(fmt, excPtr->_EXC_number);
132       /* register dump */
133       printk("\t Next PC or Address of fault = %x, ", excPtr->EXC_SRR0);
134       printk("Mvme5500 Saved MSR = %x\n", excPtr->EXC_SRR1);
135       printk("\t R0  = %08x", excPtr->GPR0);
136       printk(" R1  = %08x", excPtr->GPR1);
137       printk(" R2  = %08x", excPtr->GPR2);
138       printk(" R3  = %08x\n", excPtr->GPR3);
139       printk("\t R4  = %08x", excPtr->GPR4);
140       printk(" R5  = %08x", excPtr->GPR5);
141       printk(" R6  = %08x", excPtr->GPR6);
142       printk(" R7  = %08x\n", excPtr->GPR7);
143       printk("\t R8  = %08x", excPtr->GPR8);
144       printk(" R9  = %08x", excPtr->GPR9);
145       printk(" R10 = %08x", excPtr->GPR10);
146       printk(" R11 = %08x\n", excPtr->GPR11);
147       printk("\t R12 = %08x", excPtr->GPR12);
148       printk(" R13 = %08x", excPtr->GPR13);
149       printk(" R14 = %08x", excPtr->GPR14);
150       printk(" R15 = %08x\n", excPtr->GPR15);
151       printk("\t R16 = %08x", excPtr->GPR16);
152       printk(" R17 = %08x", excPtr->GPR17);
153       printk(" R18 = %08x", excPtr->GPR18);
154       printk(" R19 = %08x\n", excPtr->GPR19);
155       printk("\t R20 = %08x", excPtr->GPR20);
156       printk(" R21 = %08x", excPtr->GPR21);
157       printk(" R22 = %08x", excPtr->GPR22);
158       printk(" R23 = %08x\n", excPtr->GPR23);
159       printk("\t R24 = %08x", excPtr->GPR24);
160       printk(" R25 = %08x", excPtr->GPR25);
161       printk(" R26 = %08x", excPtr->GPR26);
162       printk(" R27 = %08x\n", excPtr->GPR27);
163       printk("\t R28 = %08x", excPtr->GPR28);
164       printk(" R29 = %08x", excPtr->GPR29);
165       printk(" R30 = %08x", excPtr->GPR30);
166       printk(" R31 = %08x\n", excPtr->GPR31);
167       printk("\t CR  = %08x\n", excPtr->EXC_CR);
168       printk("\t CTR = %08x\n", excPtr->EXC_CTR);
169       printk("\t XER = %08x\n", excPtr->EXC_XER);
170       printk("\t LR  = %08x\n", excPtr->EXC_LR);
171
172       BSP_printStackTrace(excPtr);
173    }
174
175    if (ASM_MACH_VECTOR == excPtr->_EXC_number) {
176       /* ollah , we got a machine check - this could either
177        * be a TEA, MCP or internal; let's see and provide more info
178        */
179       if (!quiet)
180           printk("Machine check; reason:");
181       if ( ! (excPtr->EXC_SRR1 & (SRR1_TEA_EXC | SRR1_MCP_EXC)) ) {
182           if (!quiet)
183               printk("SRR1\n");
184       } else {
185           if (excPtr->EXC_SRR1 & (SRR1_TEA_EXC)) {
186              if (!quiet)
187                 printk(" TEA");
188           }
189           if (excPtr->EXC_SRR1 & (SRR1_MCP_EXC)) {
190              unsigned long gerr;
191
192              if (!quiet) printk(" MCP\n");
193
194              /* it's MCP; gather info from the host bridge */
195              gerr=_BSP_clear_hostbridge_errors(0,0);
196              if (gerr&0x80000000) printk("GT64260 Parity error\n");
197              if (gerr&0x40000000) printk("GT64260 SysErr\n");
198              if ((!quiet) && (!gerr)) printk("GT64260 host bridge seems OK\n");
199            }
200       }
201    } else if (ASM_DEC_VECTOR == excPtr->_EXC_number) {
202                recoverable = 1;
203    } else if (ASM_SYS_VECTOR == excPtr->_EXC_number) {
204#ifdef TEST_RAW_EXCEPTION_CODE
205                recoverable = 1;
206#else
207                recoverable = 0;
208#endif
209    }
210
211    /* call them for a second time giving a chance to intercept
212     * the task_suspend
213     */
214    if (ext && ext->lowlevelHook && ext->lowlevelHook(excPtr, ext, 1))
215                return;
216
217    if (!recoverable) {
218                if (id) {
219                        /* if there's a highlevel hook, install it */
220                        if (ext && ext->highlevelHook) {
221                                excPtr->EXC_SRR0 = (uint32_t)ext->highlevelHook;
222                                excPtr->GPR3     = (uint32_t)ext;
223                                return;
224                        }
225                        if (excPtr->EXC_SRR1 & MSR_FP) {
226                                /* thread dispatching is _not_ disabled at this point; hence
227                                 * we must make sure we have the FPU enabled...
228                                 */
229                                _write_MSR( _read_MSR() | MSR_FP );
230                                __asm__ __volatile__("isync");
231                        }
232                        printk("unrecoverable exception!!! task %08x suspended\n",id);
233                        rtems_task_suspend(id);
234                } else {
235                        printk("PANIC, rebooting...\n");
236                        bsp_reset();
237                }
238    }
239}
Note: See TracBrowser for help on using the repository browser.