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

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

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