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

4.115
Last change on this file since 94297838 was 94297838, checked in by Ralf Corsepius <ralf.corsepius@…>, on 02/11/11 at 10:06:52

2011-02-11 Ralf Corsépius <ralf.corsepius@…>

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