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