source: rtems/c/src/lib/libbsp/powerpc/shared/vectors/vectors_init.c @ 6128a4a

4.104.114.84.95
Last change on this file since 6128a4a was 6128a4a, checked in by Ralf Corsepius <ralf.corsepius@…>, on Apr 21, 2004 at 10:43:04 AM

Remove stray white spaces.

  • Property mode set to 100644
File size: 5.4 KB
Line 
1/*
2 * vectors_init.c Exception hanlding initialisation (and generic handler).
3 *
4 *  This include file describe the data structure and the functions implemented
5 *  by rtems to handle exceptions.
6 *
7 *  CopyRight (C) 1999 valette@crf.canon.fr
8 *
9 *  The license and distribution terms for this file may be
10 *  found in found in the file LICENSE in this distribution or at
11 *  http://www.rtems.com/license/LICENSE.
12 *
13 *  $Id$
14 */
15#include <rtems/bspIo.h>
16
17#include <bsp/vectors.h>
18#include <libcpu/raw_exception.h>
19#include <libcpu/spr.h>
20#include <bsp.h>
21
22static rtems_raw_except_global_settings exception_config;
23static rtems_raw_except_connect_data    exception_table[LAST_VALID_EXC + 1];
24
25extern exception_handler_t globalExceptHdl;
26exception_handler_t globalExceptHdl;
27
28/* T. Straumann: provide a stack trace
29 * <strauman@slac.stanford.edu>, 6/26/2001
30 */
31typedef struct LRFrameRec_ {
32        struct LRFrameRec_ *frameLink;
33        unsigned long *lr;
34} LRFrameRec, *LRFrame;
35
36#define STACK_CLAMP 50  /* in case we have a corrupted bottom */
37
38SPR_RO(LR)
39
40void
41BSP_printStackTrace(BSP_Exception_frame* excPtr)
42{
43LRFrame f;
44int             i;
45LRFrame sp;
46void    *lr;
47
48        printk("Stack Trace: \n  ");
49        if (excPtr) {
50                printk("IP: 0x%08x, ",excPtr->EXC_SRR0);
51                sp=(LRFrame)excPtr->GPR1;
52                lr=(void*)excPtr->EXC_LR;
53        } else {
54                /* there's no macro for this */
55                __asm__ __volatile__("mr %0, 1":"=r"(sp));
56                lr=(LRFrame)_read_LR();
57        }
58        printk("LR: 0x%08x\n",lr);
59        for (f=(LRFrame)sp, i=0; f->frameLink && i<STACK_CLAMP; f=f->frameLink) {
60                printk("--^ 0x%08x", (long)(f->frameLink->lr));
61                if (!(++i%5))
62                        printk("\n");
63        }
64        if (i>=STACK_CLAMP) {
65                printk("Too many stack frames (stack possibly corrupted), giving up...\n");
66        } else {
67                if (i%5)
68                        printk("\n");
69        }
70}
71
72void C_exception_handler(BSP_Exception_frame* excPtr)
73{
74  int recoverable = 0;
75
76  printk("exception handler called for exception %d\n", excPtr->_EXC_number);
77  printk("\t Next PC or Address of fault = %x\n", excPtr->EXC_SRR0);
78  printk("\t Saved MSR = %x\n", excPtr->EXC_SRR1);
79  printk("\t R0 = %x\n", excPtr->GPR0);
80  printk("\t R1 = %x\n", excPtr->GPR1);
81  printk("\t R2 = %x\n", excPtr->GPR2);
82  printk("\t R3 = %x\n", excPtr->GPR3);
83  printk("\t R4 = %x\n", excPtr->GPR4);
84  printk("\t R5 = %x\n", excPtr->GPR5);
85  printk("\t R6 = %x\n", excPtr->GPR6);
86  printk("\t R7 = %x\n", excPtr->GPR7);
87  printk("\t R8 = %x\n", excPtr->GPR8);
88  printk("\t R9 = %x\n", excPtr->GPR9);
89  printk("\t R10 = %x\n", excPtr->GPR10);
90  printk("\t R11 = %x\n", excPtr->GPR11);
91  printk("\t R12 = %x\n", excPtr->GPR12);
92  printk("\t R13 = %x\n", excPtr->GPR13);
93  printk("\t R14 = %x\n", excPtr->GPR14);
94  printk("\t R15 = %x\n", excPtr->GPR15);
95  printk("\t R16 = %x\n", excPtr->GPR16);
96  printk("\t R17 = %x\n", excPtr->GPR17);
97  printk("\t R18 = %x\n", excPtr->GPR18);
98  printk("\t R19 = %x\n", excPtr->GPR19);
99  printk("\t R20 = %x\n", excPtr->GPR20);
100  printk("\t R21 = %x\n", excPtr->GPR21);
101  printk("\t R22 = %x\n", excPtr->GPR22);
102  printk("\t R23 = %x\n", excPtr->GPR23);
103  printk("\t R24 = %x\n", excPtr->GPR24);
104  printk("\t R25 = %x\n", excPtr->GPR25);
105  printk("\t R26 = %x\n", excPtr->GPR26);
106  printk("\t R27 = %x\n", excPtr->GPR27);
107  printk("\t R28 = %x\n", excPtr->GPR28);
108  printk("\t R29 = %x\n", excPtr->GPR29);
109  printk("\t R30 = %x\n", excPtr->GPR30);
110  printk("\t R31 = %x\n", excPtr->GPR31);
111  printk("\t CR = %x\n", excPtr->EXC_CR);
112  printk("\t CTR = %x\n", excPtr->EXC_CTR);
113  printk("\t XER = %x\n", excPtr->EXC_XER);
114  printk("\t LR = %x\n", excPtr->EXC_LR);
115  printk("\t DAR = %x\n", excPtr->EXC_DAR);
116
117  BSP_printStackTrace(excPtr);
118
119  if (excPtr->_EXC_number == ASM_DEC_VECTOR)
120       recoverable = 1;
121  if (excPtr->_EXC_number == ASM_SYS_VECTOR)
122#ifdef TEST_RAW_EXCEPTION_CODE
123    recoverable = 1;
124#else
125    recoverable = 0;
126#endif
127    if (!recoverable) {
128      printk("unrecoverable exception!!! Push reset button\n");
129      while(1);
130    }
131}
132
133void nop_except_enable(const rtems_raw_except_connect_data* ptr)
134{
135}
136int except_always_enabled(const rtems_raw_except_connect_data* ptr)
137{
138  return 1;
139}
140
141int mpc60x_vector_is_valid(rtems_vector vector);
142
143void initialize_exceptions()
144{
145  int i;
146
147  /*
148   * Initialize pointer used by low level execption handling
149   */
150  globalExceptHdl                               = C_exception_handler;
151  /*
152   * Put  default_exception_vector_code_prolog at relevant exception
153   * code entry addresses
154   */
155  exception_config.exceptSize                   = LAST_VALID_EXC + 1;
156  exception_config.rawExceptHdlTbl              = &exception_table[0];
157  exception_config.defaultRawEntry.exceptIndex  = 0;
158  exception_config.defaultRawEntry.hdl.vector   = 0;
159  exception_config.defaultRawEntry.hdl.raw_hdl  = default_exception_vector_code_prolog;
160  /*
161   * Note that next line the '&' before default_exception_vector_code_prolog_size
162   * is not a bug as it is defined a .set directly in asm...
163   */
164  exception_config.defaultRawEntry.hdl.raw_hdl_size = (unsigned) default_exception_vector_code_prolog_size;
165  for (i=0; i <= exception_config.exceptSize; i++) {
166    if (!mpc60x_vector_is_valid (i)) {
167      continue;
168    }
169    exception_table[i].exceptIndex      = i;
170    exception_table[i].hdl              = exception_config.defaultRawEntry.hdl;
171    exception_table[i].hdl.vector       = i;
172    exception_table[i].on               = nop_except_enable;
173    exception_table[i].off              = nop_except_enable;
174    exception_table[i].isOn             = except_always_enabled;
175  }
176  if (!mpc60x_init_exceptions(&exception_config)) {
177    BSP_panic("Exception handling initialization failed\n");
178  }
179  else {
180    printk("Exception handling initialization done\n");
181  }
182}
Note: See TracBrowser for help on using the repository browser.