source: rtems/c/src/lib/libbsp/sparc/leon/startup/spurious.c @ b21b0ab

4.104.114.84.95
Last change on this file since b21b0ab was b21b0ab, checked in by Joel Sherrill <joel.sherrill@…>, on Nov 13, 2000 at 10:40:29 PM

2000-11-13 Jiri Gaisler <jgais@…>

  • .cvsignore, ChangeLog?, Makefile.am, README, bsp_specs, configure.in, times, clock/.cvsignore, clock/Makefile.am, clock/ckinit.c, console/.cvsignore, console/Makefile.am, console/console.c, console/consolereserveresources.c, console/debugputs.c, gnatsupp/.cvsignore, gnatsupp/Makefile.am, gnatsupp/gnatsupp.c, include/.cvsignore, include/Makefile.am, include/bsp.h, include/coverhd.h, include/leon.h, start/.cvsignore, start/Makefile.am, startup/.cvsignore, startup/Makefile.am, startup/boardinit.S, startup/linkcmds, startup/setvec.c, startup/spurious.c, timer/.cvsignore, timer/Makefile.am, timer/timer.c, tools/.cvsignore, tools/Makefile.am, tools/configure.in, tools/runtest.in, wrapup/.cvsignore, wrapup/Makefile.am: New file.
  • Property mode set to 100644
File size: 4.2 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
20#include <string.h>
21
22static const char digits[16] = "0123456789abcdef";
23
24/* Simple integer-to-string conversion */
25
26void itos(unsigned32 u, char *s)
27{
28  int i;
29
30  for (i=0; i<8; i++) {
31    s[i] =  digits[(u >> (28 - (i*4))) & 0x0f];
32  }
33}
34
35/*
36 *  bsp_spurious_handler
37 *
38 *  Print a message on the debug console and then die
39 */
40
41rtems_isr bsp_spurious_handler(
42   rtems_vector_number trap,
43   CPU_Interrupt_frame *isf
44)
45{
46  char line[ 80 ];
47  rtems_unsigned32 real_trap;
48
49  real_trap = SPARC_REAL_TRAP_NUMBER(trap);
50
51  strcpy(line, "Unexpected trap (0x  ) at address 0x        ");
52  line[ 19 ] = digits[ real_trap >> 4 ];
53  line[ 20 ] = digits[ real_trap & 0xf ];
54  itos(isf->tpc, &line[36]);
55  DEBUG_puts( line );
56
57  switch (real_trap) {
58
59    /*
60     *  First the ones defined by the basic architecture
61     */
62
63    case 0x00: 
64      DEBUG_puts( "reset" );
65      break;
66    case 0x01: 
67      DEBUG_puts( "instruction access exception" );
68      break;
69    case 0x02: 
70      DEBUG_puts( "illegal instruction" );
71      break;
72    case 0x03: 
73      DEBUG_puts( "privileged instruction" );
74      break;
75    case 0x04: 
76      DEBUG_puts( "fp disabled" );
77      break;
78    case 0x07: 
79      DEBUG_puts( "memory address not aligned" );
80      break;
81    case 0x08: 
82      DEBUG_puts( "fp exception" );
83      break;
84    case 0x09: 
85      strcpy(line, "data access exception at 0x        " );
86      itos(LEON_REG.Failed_Address, &line[27]);
87      DEBUG_puts( line );
88      break;
89    case 0x0A: 
90      DEBUG_puts( "tag overflow" );
91      break;
92
93    /*
94     *  Then the ones defined by the LEON in particular
95     */
96
97    case LEON_TRAP_TYPE( LEON_INTERRUPT_CORRECTABLE_MEMORY_ERROR ):
98      DEBUG_puts( "LEON_INTERRUPT_CORRECTABLE_MEMORY_ERROR" );
99      break;
100    case LEON_TRAP_TYPE( LEON_INTERRUPT_UART_2_RX_TX ):
101      DEBUG_puts( "LEON_INTERRUPT_UART_2_RX_TX" );
102      break;
103    case LEON_TRAP_TYPE( LEON_INTERRUPT_UART_1_RX_TX ):
104      DEBUG_puts( "LEON_INTERRUPT_UART_1_RX_TX" );
105      break;
106    case LEON_TRAP_TYPE( LEON_INTERRUPT_EXTERNAL_0 ):
107      DEBUG_puts( "LEON_INTERRUPT_EXTERNAL_0" );
108      break;
109    case LEON_TRAP_TYPE( LEON_INTERRUPT_EXTERNAL_1 ):
110      DEBUG_puts( "LEON_INTERRUPT_EXTERNAL_1" );
111      break;
112    case LEON_TRAP_TYPE( LEON_INTERRUPT_EXTERNAL_2 ):
113      DEBUG_puts( "LEON_INTERRUPT_EXTERNAL_2" );
114      break;
115    case LEON_TRAP_TYPE( LEON_INTERRUPT_EXTERNAL_3 ):
116      DEBUG_puts( "LEON_INTERRUPT_EXTERNAL_3" );
117      break;
118    case LEON_TRAP_TYPE( LEON_INTERRUPT_TIMER1 ):
119      DEBUG_puts( "LEON_INTERRUPT_TIMER1" );
120      break;
121    case LEON_TRAP_TYPE( LEON_INTERRUPT_TIMER2 ):
122      DEBUG_puts( "LEON_INTERRUPT_TIMER2" );
123      break;
124
125    default:
126      break;
127  }
128
129  /*
130   *  What else can we do but stop ...
131   */
132
133  asm volatile( "mov 1, %g1; ta 0x0" );
134}
135
136/*
137 *  bsp_spurious_initialize
138 *
139 *  Install the spurious handler for most traps. Note that set_vector()
140 *  will unmask the corresponding asynchronous interrupt, so the initial
141 *  interrupt mask is restored after the handlers are installed.
142 */
143
144void bsp_spurious_initialize()
145{
146  rtems_unsigned32 trap;
147  unsigned32 level;
148  unsigned32 mask;
149
150  level = sparc_disable_interrupts();
151  mask = LEON_REG.Interrupt_Mask;
152
153  for ( trap=0 ; trap<256 ; trap++ ) {
154
155    /*
156     *  Skip window overflow, underflow, and flush as well as software
157     *  trap 0 which we will use as a shutdown. Also avoid trap 0x70 - 0x7f
158     *  which cannot happen and where some of the space is used to pass
159     *  paramaters to the program.
160     */
161
162    if (( trap == 5 || trap == 6 ) ||
163        (( trap >= 0x11 ) && ( trap <= 0x1f )) || 
164        (( trap >= 0x70 ) && ( trap <= 0x83 )))
165      continue;
166
167    set_vector( bsp_spurious_handler, SPARC_SYNCHRONOUS_TRAP( trap ), 1 );
168  }
169
170  LEON_REG.Interrupt_Mask = mask;
171  sparc_enable_interrupts(level);
172
173}
Note: See TracBrowser for help on using the repository browser.