source: rtems/c/src/lib/libbsp/sparc/leon3/startup/spurious.c @ 815994f

4.115
Last change on this file since 815994f was 815994f, checked in by Sebastian Huber <sebastian.huber@…>, on 11/25/12 at 16:48:11

score: Add CPU_Exception_frame

Add CPU port type CPU_Exception_frame and function
_CPU_Exception_frame_print().

The CPU ports of avr, bfin, h8300, lm32, m32c, m32r, m68k, nios2, sh,
sparc64, and v850 use an empty default implementation of
_CPU_Exception_frame_print().

Add rtems_exception_frame and rtems_exception_frame_print().

Add RTEMS_FATAL_SOURCE_EXCEPTION for CPU exceptions. Use rtems_fatal()
with source RTEMS_FATAL_SOURCE_EXCEPTION in CPU ports of i386, powerpc,
and sparc for unexpected exceptions.

Add third parameter to RTEMS_BSP_CLEANUP_OPTIONS() which controls the
BSP_PRINT_EXCEPTION_CONTEXT define used in the default
bsp_fatal_extension().

Add test sptests/spfatal26.

  • Property mode set to 100644
File size: 4.1 KB
Line 
1/*
2 *  LEON Spurious Trap Handler
3 *
4 *  This is just enough of a trap handler to let us know what
5 *  the likely source of the trap was.
6 *
7 *  Developed as part of the port of RTEMS to the LEON implementation
8 *  of the SPARC by On-Line Applications Research Corporation (OAR)
9 *  under contract to the European Space Agency (ESA).
10 *
11 *  COPYRIGHT (c) 1995. European Space Agency.
12 *
13 *  Modified for LEON3 BSP.
14 *  COPYRIGHT (c) 2004.
15 *  Gaisler Research.
16 *
17 *  This terms of the RTEMS license apply to this file.
18 */
19
20#include <bsp.h>
21#include <rtems/bspIo.h>
22
23void _BSP_Exception_frame_print( const CPU_Exception_frame *frame )
24{
25  uint32_t                   trap;
26  uint32_t                   real_trap;
27  const CPU_Interrupt_frame *isf;
28
29  trap = frame->trap;
30  real_trap = SPARC_REAL_TRAP_NUMBER(trap);
31  isf = frame->isf;
32
33  printk( "Unexpected trap (0x%02x) at address 0x%08x\n", real_trap, isf->tpc);
34
35  switch (real_trap) {
36
37    /*
38     *  First the ones defined by the basic architecture
39     */
40
41    case 0x00:
42      printk( "reset\n" );
43      break;
44    case 0x01:
45      printk( "instruction access exception\n" );
46      break;
47    case 0x02:
48      printk( "illegal instruction\n" );
49      break;
50    case 0x03:
51      printk( "privileged instruction\n" );
52      break;
53    case 0x04:
54      printk( "fp disabled\n" );
55      break;
56    case 0x07:
57      printk( "memory address not aligned\n" );
58      break;
59    case 0x08:
60      printk( "fp exception\n" );
61      break;
62    case 0x09:
63      printk( "Unexpected trap (0x%2d) at address XXX\n",
64        real_trap
65        /* XXX FIXME isf->tpc */
66      );
67      break;
68    case 0x0A:
69      printk( "tag overflow\n" );
70      break;
71
72    /*
73     *  Then the ones defined by the LEON in particular
74     */
75      /* FIXME */
76
77      /*
78    case LEON_TRAP_TYPE( LEON_INTERRUPT_CORRECTABLE_MEMORY_ERROR ):
79      printk( "LEON_INTERRUPT_CORRECTABLE_MEMORY_ERROR\n" );
80      break;
81    case LEON_TRAP_TYPE( LEON_INTERRUPT_UART_2_RX_TX ):
82      printk( "LEON_INTERRUPT_UART_2_RX_TX\n" );
83      break;
84    case LEON_TRAP_TYPE( LEON_INTERRUPT_UART_1_RX_TX ):
85      printk( "LEON_INTERRUPT_UART_1_RX_TX\n" );
86      break;
87    case LEON_TRAP_TYPE( LEON_INTERRUPT_EXTERNAL_0 ):
88      printk( "LEON_INTERRUPT_EXTERNAL_0\n" );
89      break;
90    case LEON_TRAP_TYPE( LEON_INTERRUPT_EXTERNAL_1 ):
91      printk( "LEON_INTERRUPT_EXTERNAL_1\n" );
92      break;
93    case LEON_TRAP_TYPE( LEON_INTERRUPT_EXTERNAL_2 ):
94      printk( "LEON_INTERRUPT_EXTERNAL_2\n" );
95      break;
96    case LEON_TRAP_TYPE( LEON_INTERRUPT_EXTERNAL_3 ):
97      printk( "LEON_INTERRUPT_EXTERNAL_3\n" );
98      break;
99    case LEON_TRAP_TYPE( LEON_INTERRUPT_TIMER1 ):
100      printk( "LEON_INTERRUPT_TIMER1\n" );
101      break;
102    case LEON_TRAP_TYPE( LEON_INTERRUPT_TIMER2 ):
103      printk( "LEON_INTERRUPT_TIMER2\n" );
104      break;
105      */
106
107    default:
108      break;
109  }
110}
111
112rtems_isr bsp_spurious_handler(
113   rtems_vector_number trap,
114   CPU_Interrupt_frame *isf
115)
116{
117  CPU_Exception_frame frame = {
118    .trap = trap,
119    .isf = isf
120  };
121
122  rtems_fatal(
123    RTEMS_FATAL_SOURCE_EXCEPTION,
124    (rtems_fatal_code) &frame
125  );
126}
127
128/*
129 *  bsp_spurious_initialize
130 *
131 *  Install the spurious handler for most traps. Note that set_vector()
132 *  will unmask the corresponding asynchronous interrupt, so the initial
133 *  interrupt mask is restored after the handlers are installed.
134 */
135
136void bsp_spurious_initialize()
137{
138  uint32_t trap;
139  uint32_t level;
140  /* uint32_t mask; */
141
142  level = sparc_disable_interrupts();
143  /* mask = LEON3_IrqCtrl_Regs->mask_p0; */
144
145  for ( trap=0 ; trap<256 ; trap++ ) {
146
147    /*
148     *  Skip window overflow, underflow, and flush as well as software
149     *  trap 0 which we will use as a shutdown. Also avoid trap 0x70 - 0x7f
150     *  which cannot happen and where some of the space is used to pass
151     *  paramaters to the program.
152     */
153
154    if (( trap == 5 || trap == 6 ) ||
155        (( trap >= 0x11 ) && ( trap <= 0x1f )) ||
156        (( trap >= 0x70 ) && ( trap <= 0x83 )))
157      continue;
158
159    set_vector(
160        (rtems_isr_entry) bsp_spurious_handler,
161        SPARC_SYNCHRONOUS_TRAP( trap ),
162        1
163    );
164  }
165
166  /* LEON3_IrqCtrl_Regs->mask_p0 = mask; */
167  sparc_enable_interrupts(level);
168
169}
Note: See TracBrowser for help on using the repository browser.