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

4.11
Last change on this file since 815994f was 815994f, checked in by Sebastian Huber <sebastian.huber@…>, on Nov 25, 2012 at 4:48:11 PM

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