source: rtems/c/src/lib/libbsp/sparc/leon2/startup/spurious.c @ 65332b4

4.104.114.84.95
Last change on this file since 65332b4 was 65332b4, checked in by Joel Sherrill <joel.sherrill@…>, on 05/11/07 at 21:03:55

2007-05-11 Joel Sherrill <joel.sherrill@…>

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