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

Last change on this file since 7acdb10 was 7acdb10, checked in by Cillian O'Donnell <cpodonnell8@…>, on Apr 7, 2017 at 2:11:20 PM

libcpu/../mpc5xx/.../vectors_init.c: Using inttype macros fixes 39 format warnings

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