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

4.115
Last change on this file since c48cf0bd was c48cf0bd, checked in by Sebastian Huber <sebastian.huber@…>, on 09/11/14 at 07:10:16

score: Rename _BSP_Exception_frame_print()

Rename _BSP_Exception_frame_print() to _CPU_Exception_frame_print() to
be in line with other CPU port functions.

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