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

4.11
Last change on this file since dff1803 was dff1803, checked in by Daniel Hellstrom <daniel@…>, on Dec 3, 2014 at 10:35:52 AM

SPARC: optimize IRQ enable & disable

  • Coding style cleanups.
  • Use OS reserved trap 0x89 for IRQ Disable
  • Use OS reserved trap 0x8A for IRQ Enable
  • Add to SPARC CPU supplement documentation

This will result in faster Disable/Enable? code since the
system trap handler does not need to decode which function
the user wants. Besides the IRQ disable/enabled can now
be inline which avoids the caller to take into account that
o0-o7+g1-g4 registers are destroyed by trap handler.

It was also possible to reduce the interrupt trap handler by
five instructions due to this.

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