source: rtems/c/src/lib/libbsp/sparc/erc32/startup/spurious.c @ 600d88d

5
Last change on this file since 600d88d was 600d88d, checked in by Sebastian Huber <sebastian.huber@…>, on 07/19/17 at 07:07:17

INTERNAL_ERROR_ILLEGAL_USE_OF_FLOATING_POINT_UNIT

Add new fatal error INTERNAL_ERROR_ILLEGAL_USE_OF_FLOATING_POINT_UNIT.

Update #3077.

  • Property mode set to 100644
File size: 5.2 KB
Line 
1/*
2 *  ERC32 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 ERC32 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#include <inttypes.h>
19
20void _CPU_Exception_frame_print( const CPU_Exception_frame *frame )
21{
22  uint32_t                   trap;
23  uint32_t                   real_trap;
24  const CPU_Interrupt_frame *isf;
25
26  trap = frame->trap;
27  real_trap = SPARC_REAL_TRAP_NUMBER(trap);
28  isf = frame->isf;
29
30  printk(
31    "Unexpected trap (%2" PRId32 ") at address 0x%08" PRIx32 "\n",
32    real_trap,
33    isf->tpc
34  );
35
36  switch (real_trap) {
37
38    /*
39     *  First the ones defined by the basic architecture
40     */
41
42    case 0x00:
43      printk( "reset\n" );
44      break;
45    case 0x01:
46      printk( "instruction access exception\n" );
47      break;
48    case 0x02:
49      printk( "illegal instruction\n" );
50      break;
51    case 0x03:
52      printk( "privileged instruction\n" );
53      break;
54    case 0x04:
55      printk( "fp disabled\n" );
56      break;
57    case 0x07:
58      printk( "memory address not aligned\n" );
59      break;
60    case 0x08:
61      printk( "fp exception\n" );
62      break;
63    case 0x09:
64      printk("data access exception at 0x%08" PRIx32 "\n",
65        ERC32_MEC.First_Failing_Address );
66      break;
67    case 0x0A:
68      printk( "tag overflow\n" );
69      break;
70
71    /*
72     *  Then the ones defined by the ERC32 in particular
73     */
74
75    case ERC32_TRAP_TYPE( ERC32_INTERRUPT_MASKED_ERRORS ):
76      printk( "ERC32_INTERRUPT_MASKED_ERRORS\n" );
77      break;
78    case ERC32_TRAP_TYPE( ERC32_INTERRUPT_EXTERNAL_1 ):
79      printk( "ERC32_INTERRUPT_EXTERNAL_1\n" );
80      break;
81    case ERC32_TRAP_TYPE( ERC32_INTERRUPT_EXTERNAL_2 ):
82      printk( "ERC32_INTERRUPT_EXTERNAL_2\n" );
83      break;
84    case ERC32_TRAP_TYPE( ERC32_INTERRUPT_UART_A_RX_TX ):
85      printk( "ERC32_INTERRUPT_UART_A_RX_TX\n" );
86      break;
87    case ERC32_TRAP_TYPE( ERC32_INTERRUPT_UART_B_RX_TX ):
88      printk( "ERC32_INTERRUPT_UART_A_RX_TX\n" );
89      break;
90    case ERC32_TRAP_TYPE( ERC32_INTERRUPT_CORRECTABLE_MEMORY_ERROR ):
91      printk( "ERC32_INTERRUPT_CORRECTABLE_MEMORY_ERROR\n" );
92      break;
93    case ERC32_TRAP_TYPE( ERC32_INTERRUPT_UART_ERROR ):
94      printk( "ERC32_INTERRUPT_UART_ERROR\n" );
95      break;
96    case ERC32_TRAP_TYPE( ERC32_INTERRUPT_DMA_ACCESS_ERROR ):
97      printk( "ERC32_INTERRUPT_DMA_ACCESS_ERROR\n" );
98      break;
99    case ERC32_TRAP_TYPE( ERC32_INTERRUPT_DMA_TIMEOUT ):
100      printk( "ERC32_INTERRUPT_DMA_TIMEOUT\n" );
101      break;
102    case ERC32_TRAP_TYPE( ERC32_INTERRUPT_EXTERNAL_3 ):
103      printk( "ERC32_INTERRUPT_EXTERNAL_3\n" );
104      break;
105    case ERC32_TRAP_TYPE( ERC32_INTERRUPT_EXTERNAL_4 ):
106      printk( "ERC32_INTERRUPT_EXTERNAL_4\n" );
107      break;
108    case ERC32_TRAP_TYPE( ERC32_INTERRUPT_GENERAL_PURPOSE_TIMER ):
109      printk( "ERC32_INTERRUPT_GENERAL_PURPOSE_TIMER\n" );
110      break;
111    case ERC32_TRAP_TYPE( ERC32_INTERRUPT_REAL_TIME_CLOCK ):
112      printk( "ERC32_INTERRUPT_REAL_TIME_CLOCK\n" );
113      break;
114    case ERC32_TRAP_TYPE( ERC32_INTERRUPT_EXTERNAL_5 ):
115      printk( "ERC32_INTERRUPT_EXTERNAL_5\n" );
116      break;
117    case ERC32_TRAP_TYPE( ERC32_INTERRUPT_WATCHDOG_TIMEOUT ):
118      printk( "ERC32_INTERRUPT_WATCHDOG_TIMEOUT\n" );
119      break;
120
121    default:
122      break;
123  }
124}
125
126static rtems_isr bsp_spurious_handler(
127   rtems_vector_number trap,
128   CPU_Interrupt_frame *isf
129)
130{
131  CPU_Exception_frame frame = {
132    .trap = trap,
133    .isf = isf
134  };
135
136  if ( SPARC_REAL_TRAP_NUMBER( trap ) == 4 ) {
137    _Internal_error( INTERNAL_ERROR_ILLEGAL_USE_OF_FLOATING_POINT_UNIT );
138  }
139
140  rtems_fatal(
141    RTEMS_FATAL_SOURCE_EXCEPTION,
142    (rtems_fatal_code) &frame
143  );
144}
145
146/*
147 *  bsp_spurious_initialize
148 *
149 *  Install the spurious handler for most traps. Note that set_vector()
150 *  will unmask the corresponding asynchronous interrupt, so the initial
151 *  interrupt mask is restored after the handlers are installed.
152 */
153
154void bsp_spurious_initialize()
155{
156  uint32_t   trap;
157  uint32_t   level = 15;
158  uint32_t   mask;
159
160  level = sparc_disable_interrupts();
161  mask = ERC32_MEC.Interrupt_Mask;
162
163  for ( trap=0 ; trap<256 ; trap++ ) {
164
165    /*
166     *  Skip window overflow, underflow, and flush as well as software
167     *  trap 0,9,10 which we will use as a shutdown, IRQ disable, IRQ enable.
168     *  Also avoid trap 0x70 - 0x7f which cannot happen and where some of the
169     *  space is used to pass parameters to the program.
170     */
171
172    if (( trap == 5 || trap == 6 ) ||
173        (( trap >= 0x11 ) && ( trap <= 0x1f )) ||
174        (( trap >= 0x70 ) && ( trap <= 0x83 )) ||
175        ( trap == 0x80 + SPARC_SWTRAP_IRQDIS ) ||
176#if SPARC_HAS_FPU == 1
177        ( trap == 0x80 + SPARC_SWTRAP_IRQDIS_FP ) ||
178#endif
179        ( trap == 0x80 + SPARC_SWTRAP_IRQEN ))
180      continue;
181
182    set_vector( (rtems_isr_entry) bsp_spurious_handler,
183         SPARC_SYNCHRONOUS_TRAP( trap ), 1 );
184  }
185
186  ERC32_MEC.Interrupt_Mask = mask;
187  sparc_enable_interrupts(level);
188
189}
Note: See TracBrowser for help on using the repository browser.