source: rtems/c/src/lib/libcpu/powerpc/mpc5xx/vectors/vectors_init.c @ f62c7daa

4.11
Last change on this file since f62c7daa was f62c7daa, checked in by Joel Sherrill <joel.sherrill@…>, on Oct 14, 2014 at 7:10:22 PM

mpc5xx libcpu and ss555 BSP: Fix warnings

  • Property mode set to 100644
File size: 4.5 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
8/*
9 *  MPC5xx port sponsored by Defence Research and Development Canada - Suffield
10 *  Copyright (C) 2004, Real-Time Systems Inc. (querbach@realtime.bc.ca)
11 *
12 *  Derived from libbsp/powerpc/mbx8xx/vectors/vectors_init.c:
13 *
14 *  CopyRight (C) 1999 valette@crf.canon.fr
15 *
16 *  The license and distribution terms for this file may be
17 *  found in the file LICENSE in this distribution or at
18 *  http://www.rtems.org/license/LICENSE.
19 */
20#include <rtems/bspIo.h>
21#include <libcpu/vectors.h>
22#include <libcpu/raw_exception.h>
23#include <bsp/irq.h>
24
25extern rtems_exception_handler_t default_exception_handler;
26
27static rtems_raw_except_global_settings exception_config;
28static rtems_raw_except_connect_data    exception_table[NUM_EXCEPTIONS];
29rtems_exception_handler_t* exception_handler_table[NUM_EXCEPTIONS];
30
31void C_default_exception_handler(CPU_Exception_frame* excPtr)
32{
33  int recoverable = 0;
34
35  printk("exception handler called for exception %d\n", excPtr->_EXC_number);
36  printk("\t Next PC or Address of fault = %x\n", excPtr->EXC_SRR0);
37  printk("\t Saved MSR = %x\n", excPtr->EXC_SRR1);
38  printk("\t R0 = %x\n", excPtr->GPR0);
39  printk("\t R1 = %x\n", excPtr->GPR1);
40  printk("\t R2 = %x\n", excPtr->GPR2);
41  printk("\t R3 = %x\n", excPtr->GPR3);
42  printk("\t R4 = %x\n", excPtr->GPR4);
43  printk("\t R5 = %x\n", excPtr->GPR5);
44  printk("\t R6 = %x\n", excPtr->GPR6);
45  printk("\t R7 = %x\n", excPtr->GPR7);
46  printk("\t R8 = %x\n", excPtr->GPR8);
47  printk("\t R9 = %x\n", excPtr->GPR9);
48  printk("\t R10 = %x\n", excPtr->GPR10);
49  printk("\t R11 = %x\n", excPtr->GPR11);
50  printk("\t R12 = %x\n", excPtr->GPR12);
51  printk("\t R13 = %x\n", excPtr->GPR13);
52  printk("\t R14 = %x\n", excPtr->GPR14);
53  printk("\t R15 = %x\n", excPtr->GPR15);
54  printk("\t R16 = %x\n", excPtr->GPR16);
55  printk("\t R17 = %x\n", excPtr->GPR17);
56  printk("\t R18 = %x\n", excPtr->GPR18);
57  printk("\t R19 = %x\n", excPtr->GPR19);
58  printk("\t R20 = %x\n", excPtr->GPR20);
59  printk("\t R21 = %x\n", excPtr->GPR21);
60  printk("\t R22 = %x\n", excPtr->GPR22);
61  printk("\t R23 = %x\n", excPtr->GPR23);
62  printk("\t R24 = %x\n", excPtr->GPR24);
63  printk("\t R25 = %x\n", excPtr->GPR25);
64  printk("\t R26 = %x\n", excPtr->GPR26);
65  printk("\t R27 = %x\n", excPtr->GPR27);
66  printk("\t R28 = %x\n", excPtr->GPR28);
67  printk("\t R29 = %x\n", excPtr->GPR29);
68  printk("\t R30 = %x\n", excPtr->GPR30);
69  printk("\t R31 = %x\n", excPtr->GPR31);
70  printk("\t CR = %x\n", excPtr->EXC_CR);
71  printk("\t CTR = %x\n", excPtr->EXC_CTR);
72  printk("\t XER = %x\n", excPtr->EXC_XER);
73  printk("\t LR = %x\n", excPtr->EXC_LR);
74  if (excPtr->_EXC_number == ASM_DEC_VECTOR)
75       recoverable = 1;
76  if (excPtr->_EXC_number == ASM_SYS_VECTOR)
77#ifdef TEST_RAW_EXCEPTION_CODE
78    recoverable = 1;
79#else
80    recoverable = 0;
81#endif
82    if (!recoverable) {
83      printk("unrecoverable exception!!! Push reset button\n");
84      while(1);
85    }
86}
87
88static void nop_except_enable(const rtems_raw_except_connect_data* ptr)
89{
90}
91
92static int except_always_enabled(const rtems_raw_except_connect_data* ptr)
93{
94  return 1;
95}
96
97void initialize_exceptions(void)
98{
99  int i;
100
101  /*
102   * Initialize all entries of the exception table with a description of the
103   * default exception handler.
104   */
105  exception_config.exceptSize                   = NUM_EXCEPTIONS;
106  exception_config.rawExceptHdlTbl              = &exception_table[0];
107  exception_config.defaultRawEntry.exceptIndex  = 0;
108  exception_config.defaultRawEntry.hdl.vector   = 0;
109  exception_config.defaultRawEntry.hdl.raw_hdl  = default_exception_handler;
110
111  for (i = 0; i < exception_config.exceptSize; i++) {
112    printk("installing exception number %d\n", i);
113    exception_table[i].exceptIndex      = i;
114    exception_table[i].hdl              = exception_config.defaultRawEntry.hdl;
115    exception_table[i].hdl.vector       = i;
116    exception_table[i].on               = nop_except_enable;
117    exception_table[i].off              = nop_except_enable;
118    exception_table[i].isOn             = except_always_enabled;
119  }
120
121  /*
122   * Now pass the initialized exception table to the exceptions module which
123   * will install the handler pointers in the exception handler table.
124   */
125  if (!mpc5xx_init_exceptions(&exception_config)) {
126    /*
127     * At this stage we may not call CPU_Panic because it uses exceptions!!!
128     */
129    printk("Exception handling initialization failed\n");
130    printk("System locked\n"); while(1);
131  }
132  else {
133    printk("Exception handling initialization done\n");
134  }
135}
Note: See TracBrowser for help on using the repository browser.