source: rtems/c/src/lib/libbsp/sparc/leon2/startup/spurious.c @ 8d830fae

4.115
Last change on this file since 8d830fae was 8d830fae, checked in by Radu <radustoma@…>, on 12/02/13 at 20:07:35

leon2_doxygen_1

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