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

4.104.115
Last change on this file since 5734337 was 5734337, checked in by Joel Sherrill <joel.sherrill@…>, on 09/22/08 at 21:50:25

2008-09-22 Joel Sherrill <joel.sherrill@…>

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