source: rtems/c/src/lib/libbsp/sparc/leon3/startup/spurious.c @ e5330c1

4.104.114.84.95
Last change on this file since e5330c1 was 55cb7c9, checked in by Joel Sherrill <joel.sherrill@…>, on 05/09/07 at 17:49:58

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

  • console/debugputs.c, include/bsp.h, leon_smc91111/leon_smc91111.c, startup/bspstart.c, startup/spurious.c: Remove debug print methods that are redundant with prntk and replace their use with printk.
  • 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 *  Modified for LEON3 BSP.
14 *  COPYRIGHT (c) 2004.
15 *  Gaisler Research.
16 *
17 *  This terms of the RTEMS license apply to this file.
18 *
19 *  $Id$
20 */
21
22#include <bsp.h>
23
24#include <string.h>
25
26static const char digits[16] = "0123456789abcdef";
27
28/* Simple integer-to-string conversion */
29
30void itos(uint32_t u, char *s)
31{
32  int i;
33
34  for (i=0; i<8; i++) {
35    s[i] =  digits[(u >> (28 - (i*4))) & 0x0f];
36  }
37}
38
39/*
40 *  bsp_spurious_handler
41 *
42 *  Print a message on the debug console and then die
43 */
44
45rtems_isr bsp_spurious_handler(
46   rtems_vector_number trap,
47   CPU_Interrupt_frame *isf
48)
49{
50  char line[ 80 ];
51  uint32_t real_trap;
52
53  real_trap = SPARC_REAL_TRAP_NUMBER(trap);
54
55  printk( "Unexpected trap (0x%2d) at address 0x%08x\n", real_trap, isf->tpc);
56
57  switch (real_trap) {
58
59    /*
60     *  First the ones defined by the basic architecture
61     */
62
63    case 0x00:
64      printk( "reset\n" );
65      break;
66    case 0x01:
67      printk( "instruction access exception\n" );
68      break;
69    case 0x02:
70      printk( "illegal instruction\n" );
71      break;
72    case 0x03:
73      printk( "privileged instruction\n" );
74      break;
75    case 0x04:
76      printk( "fp disabled\n" );
77      break;
78    case 0x07:
79      printk( "memory address not aligned\n" );
80      break;
81    case 0x08:
82      printk( "fp exception\n" );
83      break;
84    case 0x09:
85      printk( "Unexpected trap (0x%2d) at address 0x%08x\n",
86        real_trap,
87        abcdef01 /* XXX FIXME isf->tpc */
88      );
89      break;
90    case 0x0A:
91      printk( "tag overflow\n" );
92      break;
93
94    /*
95     *  Then the ones defined by the LEON in particular
96     */
97      /* FIXME */
98
99      /*
100    case LEON_TRAP_TYPE( LEON_INTERRUPT_CORRECTABLE_MEMORY_ERROR ):
101      printk( "LEON_INTERRUPT_CORRECTABLE_MEMORY_ERROR\n" );
102      break;
103    case LEON_TRAP_TYPE( LEON_INTERRUPT_UART_2_RX_TX ):
104      printk( "LEON_INTERRUPT_UART_2_RX_TX\n" );
105      break;
106    case LEON_TRAP_TYPE( LEON_INTERRUPT_UART_1_RX_TX ):
107      printk( "LEON_INTERRUPT_UART_1_RX_TX\n" );
108      break;
109    case LEON_TRAP_TYPE( LEON_INTERRUPT_EXTERNAL_0 ):
110      printk( "LEON_INTERRUPT_EXTERNAL_0\n" );
111      break;
112    case LEON_TRAP_TYPE( LEON_INTERRUPT_EXTERNAL_1 ):
113      printk( "LEON_INTERRUPT_EXTERNAL_1\n" );
114      break;
115    case LEON_TRAP_TYPE( LEON_INTERRUPT_EXTERNAL_2 ):
116      printk( "LEON_INTERRUPT_EXTERNAL_2\n" );
117      break;
118    case LEON_TRAP_TYPE( LEON_INTERRUPT_EXTERNAL_3 ):
119      printk( "LEON_INTERRUPT_EXTERNAL_3\n" );
120      break;
121    case LEON_TRAP_TYPE( LEON_INTERRUPT_TIMER1 ):
122      printk( "LEON_INTERRUPT_TIMER1\n" );
123      break;
124    case LEON_TRAP_TYPE( LEON_INTERRUPT_TIMER2 ):
125      printk( "LEON_INTERRUPT_TIMER2\n" );
126      break;
127      */
128
129    default:
130      break;
131  }
132
133  /*
134   *  What else can we do but stop ...
135   */
136
137  asm volatile( "mov 1, %g1; ta 0x0" );
138}
139
140/*
141 *  bsp_spurious_initialize
142 *
143 *  Install the spurious handler for most traps. Note that set_vector()
144 *  will unmask the corresponding asynchronous interrupt, so the initial
145 *  interrupt mask is restored after the handlers are installed.
146 */
147
148void bsp_spurious_initialize()
149{
150  uint32_t trap;
151  uint32_t level;
152  /* uint32_t mask; */
153
154  level = sparc_disable_interrupts();
155  /* mask = LEON3_IrqCtrl_Regs->mask_p0; */
156
157  for ( trap=0 ; trap<256 ; trap++ ) {
158
159    /*
160     *  Skip window overflow, underflow, and flush as well as software
161     *  trap 0 which we will use as a shutdown. Also avoid trap 0x70 - 0x7f
162     *  which cannot happen and where some of the space is used to pass
163     *  paramaters to the program.
164     */
165
166    if (( trap == 5 || trap == 6 ) ||
167        (( trap >= 0x11 ) && ( trap <= 0x1f )) ||
168        (( trap >= 0x70 ) && ( trap <= 0x83 )))
169      continue;
170
171    set_vector(
172        (rtems_isr_entry) bsp_spurious_handler,
173        SPARC_SYNCHRONOUS_TRAP( trap ),
174        1
175    );
176  }
177
178  /* LEON3_IrqCtrl_Regs->mask_p0 = mask; */
179  sparc_enable_interrupts(level);
180
181}
Note: See TracBrowser for help on using the repository browser.