source: rtems/c/src/lib/libbsp/powerpc/shared/vectors/vectors_init.c @ 4f3e4f33

4.104.114.84.95
Last change on this file since 4f3e4f33 was 4f3e4f33, checked in by Joel Sherrill <joel.sherrill@…>, on Feb 20, 2003 at 9:32:07 PM

2003-02-20 Till Straumann <strauman@…>

PR 349/bsps

  • console/console.c, console/uart.c, console/uart.h: implement IOCTLs for the serial (UART) console to install/retrieve a BREAK-IRQ callback. The callback routine (if installed) is invoked from the UART ISR when a BREAK interrupt is detected. This can be used e.g. to enforce a "hotkey" reboot a la vxWorks Ctrl-X (although we use the serial line break condition) NOTE: The callback runs in ISR context.
  • 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.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 <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
25exception_handler_t globalExceptHdl;
26
27/* T. Straumann: provide a stack trace
28 * <strauman@slac.stanford.edu>, 6/26/2001
29 */
30typedef struct LRFrameRec_ {
31        struct LRFrameRec_ *frameLink;
32        unsigned long *lr;
33} LRFrameRec, *LRFrame;
34
35#define STACK_CLAMP 50  /* in case we have a corrupted bottom */
36
37SPR_RO(LR)
38
39void
40BSP_printStackTrace(BSP_Exception_frame* excPtr)
41{
42LRFrame f;
43int             i;
44LRFrame sp;
45void    *lr;
46
47        printk("Stack Trace: \n  ");
48        if (excPtr) {
49                printk("IP: 0x%08x, ",excPtr->EXC_SRR0);
50                sp=(LRFrame)excPtr->GPR1;
51                lr=(void*)excPtr->EXC_LR;
52        } else {
53                /* there's no macro for this */
54                __asm__ __volatile__("mr %0, 1":"=r"(sp));
55                lr=(LRFrame)_read_LR();
56        }
57        printk("LR: 0x%08x\n",lr);
58        for (f=(LRFrame)sp, i=0; f->frameLink && i<STACK_CLAMP; f=f->frameLink) {
59                printk("--^ 0x%08x", (long)(f->frameLink->lr));
60                if (!(++i%5))
61                        printk("\n");
62        }
63        if (i>=STACK_CLAMP) {
64                printk("Too many stack frames (stack possibly corrupted), giving up...\n");
65        } else {
66                if (i%5)
67                        printk("\n");
68        }
69}
70
71void C_exception_handler(BSP_Exception_frame* excPtr)
72{
73  int recoverable = 0;
74 
75  printk("exception handler called for exception %d\n", excPtr->_EXC_number);
76  printk("\t Next PC or Address of fault = %x\n", excPtr->EXC_SRR0);
77  printk("\t Saved MSR = %x\n", excPtr->EXC_SRR1);
78  printk("\t R0 = %x\n", excPtr->GPR0);
79  printk("\t R1 = %x\n", excPtr->GPR1);
80  printk("\t R2 = %x\n", excPtr->GPR2);
81  printk("\t R3 = %x\n", excPtr->GPR3);
82  printk("\t R4 = %x\n", excPtr->GPR4);
83  printk("\t R5 = %x\n", excPtr->GPR5);
84  printk("\t R6 = %x\n", excPtr->GPR6);
85  printk("\t R7 = %x\n", excPtr->GPR7);
86  printk("\t R8 = %x\n", excPtr->GPR8);
87  printk("\t R9 = %x\n", excPtr->GPR9);
88  printk("\t R10 = %x\n", excPtr->GPR10);
89  printk("\t R11 = %x\n", excPtr->GPR11);
90  printk("\t R12 = %x\n", excPtr->GPR12);
91  printk("\t R13 = %x\n", excPtr->GPR13);
92  printk("\t R14 = %x\n", excPtr->GPR14);
93  printk("\t R15 = %x\n", excPtr->GPR15);
94  printk("\t R16 = %x\n", excPtr->GPR16);
95  printk("\t R17 = %x\n", excPtr->GPR17);
96  printk("\t R18 = %x\n", excPtr->GPR18);
97  printk("\t R19 = %x\n", excPtr->GPR19);
98  printk("\t R20 = %x\n", excPtr->GPR20);
99  printk("\t R21 = %x\n", excPtr->GPR21);
100  printk("\t R22 = %x\n", excPtr->GPR22);
101  printk("\t R23 = %x\n", excPtr->GPR23);
102  printk("\t R24 = %x\n", excPtr->GPR24);
103  printk("\t R25 = %x\n", excPtr->GPR25);
104  printk("\t R26 = %x\n", excPtr->GPR26);
105  printk("\t R27 = %x\n", excPtr->GPR27);
106  printk("\t R28 = %x\n", excPtr->GPR28);
107  printk("\t R29 = %x\n", excPtr->GPR29);
108  printk("\t R30 = %x\n", excPtr->GPR30);
109  printk("\t R31 = %x\n", excPtr->GPR31);
110  printk("\t CR = %x\n", excPtr->EXC_CR);
111  printk("\t CTR = %x\n", excPtr->EXC_CTR);
112  printk("\t XER = %x\n", excPtr->EXC_XER);
113  printk("\t LR = %x\n", excPtr->EXC_LR);
114  printk("\t DAR = %x\n", excPtr->EXC_DAR);
115
116  BSP_printStackTrace(excPtr);
117
118  if (excPtr->_EXC_number == ASM_DEC_VECTOR)
119       recoverable = 1;
120  if (excPtr->_EXC_number == ASM_SYS_VECTOR)
121#ifdef TEST_RAW_EXCEPTION_CODE     
122    recoverable = 1;
123#else
124    recoverable = 0;
125#endif
126    if (!recoverable) {
127      printk("unrecoverable exception!!! Push reset button\n");
128      while(1);
129    }
130}
131
132void nop_except_enable(const rtems_raw_except_connect_data* ptr)
133{
134}
135int except_always_enabled(const rtems_raw_except_connect_data* ptr)
136{
137  return 1;
138}
139
140int mpc60x_vector_is_valid(rtems_vector vector);
141
142void initialize_exceptions()
143{
144  int i;
145
146  /*
147   * Initialize pointer used by low level execption handling
148   */
149  globalExceptHdl                               = C_exception_handler;
150  /*
151   * Put  default_exception_vector_code_prolog at relevant exception
152   * code entry addresses
153   */
154  exception_config.exceptSize                   = LAST_VALID_EXC + 1;
155  exception_config.rawExceptHdlTbl              = &exception_table[0];
156  exception_config.defaultRawEntry.exceptIndex  = 0;
157  exception_config.defaultRawEntry.hdl.vector   = 0;
158  exception_config.defaultRawEntry.hdl.raw_hdl  = default_exception_vector_code_prolog;
159  /*
160   * Note that next line the '&' before default_exception_vector_code_prolog_size
161   * is not a bug as it is defined a .set directly in asm...
162   */
163  exception_config.defaultRawEntry.hdl.raw_hdl_size = (unsigned) &default_exception_vector_code_prolog_size;
164  for (i=0; i <= exception_config.exceptSize; i++) {
165    if (!mpc60x_vector_is_valid (i)) {
166      continue;
167    }
168    exception_table[i].exceptIndex      = i;
169    exception_table[i].hdl              = exception_config.defaultRawEntry.hdl;
170    exception_table[i].hdl.vector       = i;
171    exception_table[i].on               = nop_except_enable;
172    exception_table[i].off              = nop_except_enable;
173    exception_table[i].isOn             = except_always_enabled;
174  }
175  if (!mpc60x_init_exceptions(&exception_config)) {
176    BSP_panic("Exception handling initialization failed\n");
177  }
178  else {
179    printk("Exception handling initialization done\n");
180  }
181}
Note: See TracBrowser for help on using the repository browser.