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

4.104.114.84.95
Last change on this file since 6dacdf9d was 6dacdf9d, checked in by Joel Sherrill <joel.sherrill@…>, on 05/11/07 at 21:19:23

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

  • include/bsp.h, startup/bspstart.c, startup/spurious.c: hello and ticker now run using runtest.
  • Property mode set to 100644
File size: 4.0 KB
RevLine 
[41c9282]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
[2f9e237]24#include <rtems/bspIo.h>
[41c9282]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
[55cb7c9]41  printk( "Unexpected trap (0x%2d) at address 0x%08x\n", real_trap, isf->tpc);
[41c9282]42
43  switch (real_trap) {
44
45    /*
46     *  First the ones defined by the basic architecture
47     */
48
49    case 0x00:
[55cb7c9]50      printk( "reset\n" );
[41c9282]51      break;
52    case 0x01:
[55cb7c9]53      printk( "instruction access exception\n" );
[41c9282]54      break;
55    case 0x02:
[55cb7c9]56      printk( "illegal instruction\n" );
[41c9282]57      break;
58    case 0x03:
[55cb7c9]59      printk( "privileged instruction\n" );
[41c9282]60      break;
61    case 0x04:
[55cb7c9]62      printk( "fp disabled\n" );
[41c9282]63      break;
64    case 0x07:
[55cb7c9]65      printk( "memory address not aligned\n" );
[41c9282]66      break;
67    case 0x08:
[55cb7c9]68      printk( "fp exception\n" );
[41c9282]69      break;
70    case 0x09:
[2f9e237]71      printk( "Unexpected trap (0x%2d) at address XXX\n",
72        real_trap
[6dacdf9d]73        /* XXX FIXME isf->tpc */
[55cb7c9]74      );
[41c9282]75      break;
76    case 0x0A:
[55cb7c9]77      printk( "tag overflow\n" );
[41c9282]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 ):
[55cb7c9]87      printk( "LEON_INTERRUPT_CORRECTABLE_MEMORY_ERROR\n" );
[41c9282]88      break;
89    case LEON_TRAP_TYPE( LEON_INTERRUPT_UART_2_RX_TX ):
[55cb7c9]90      printk( "LEON_INTERRUPT_UART_2_RX_TX\n" );
[41c9282]91      break;
92    case LEON_TRAP_TYPE( LEON_INTERRUPT_UART_1_RX_TX ):
[55cb7c9]93      printk( "LEON_INTERRUPT_UART_1_RX_TX\n" );
[41c9282]94      break;
95    case LEON_TRAP_TYPE( LEON_INTERRUPT_EXTERNAL_0 ):
[55cb7c9]96      printk( "LEON_INTERRUPT_EXTERNAL_0\n" );
[41c9282]97      break;
98    case LEON_TRAP_TYPE( LEON_INTERRUPT_EXTERNAL_1 ):
[55cb7c9]99      printk( "LEON_INTERRUPT_EXTERNAL_1\n" );
[41c9282]100      break;
101    case LEON_TRAP_TYPE( LEON_INTERRUPT_EXTERNAL_2 ):
[55cb7c9]102      printk( "LEON_INTERRUPT_EXTERNAL_2\n" );
[41c9282]103      break;
104    case LEON_TRAP_TYPE( LEON_INTERRUPT_EXTERNAL_3 ):
[55cb7c9]105      printk( "LEON_INTERRUPT_EXTERNAL_3\n" );
[41c9282]106      break;
107    case LEON_TRAP_TYPE( LEON_INTERRUPT_TIMER1 ):
[55cb7c9]108      printk( "LEON_INTERRUPT_TIMER1\n" );
[41c9282]109      break;
110    case LEON_TRAP_TYPE( LEON_INTERRUPT_TIMER2 ):
[55cb7c9]111      printk( "LEON_INTERRUPT_TIMER2\n" );
[41c9282]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.