source: rtems/c/src/lib/libbsp/powerpc/shared/vectors/vectors_init.c @ 7657233d

4.104.114.84.95
Last change on this file since 7657233d was 7657233d, checked in by Joel Sherrill <joel.sherrill@…>, on Oct 31, 2002 at 8:12:09 PM

2002-10-31 Joel Sherrill <joel@…>

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