source: rtems/c/src/lib/libbsp/sparc/leon2/startup/spurious.c @ 8d830fae

4.11
Last change on this file since 8d830fae was 8d830fae, checked in by Radu <radustoma@…>, on Dec 2, 2013 at 8:07:35 PM

leon2_doxygen_1

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