1 | /** |
---|
2 | * @file |
---|
3 | * @ingroup sparc_leon2 |
---|
4 | * @brief LEON Spurious Trap Handler |
---|
5 | */ |
---|
6 | |
---|
7 | /* |
---|
8 | * LEON Spurious Trap Handler |
---|
9 | * |
---|
10 | * This is just enough of a trap handler to let us know what |
---|
11 | * the likely source of the trap was. |
---|
12 | * |
---|
13 | * Developed as part of the port of RTEMS to the LEON implementation |
---|
14 | * of the SPARC by On-Line Applications Research Corporation (OAR) |
---|
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> |
---|
23 | #include <rtems/bspIo.h> |
---|
24 | #include <inttypes.h> |
---|
25 | |
---|
26 | void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ) |
---|
27 | { |
---|
28 | uint32_t trap; |
---|
29 | uint32_t real_trap; |
---|
30 | const CPU_Interrupt_frame *isf; |
---|
31 | |
---|
32 | trap = frame->trap; |
---|
33 | real_trap = SPARC_REAL_TRAP_NUMBER(trap); |
---|
34 | isf = frame->isf; |
---|
35 | |
---|
36 | printk( |
---|
37 | "Unexpected trap (%2" PRId32 ") at address 0x%08" PRIx32 "\n", |
---|
38 | real_trap, |
---|
39 | isf->tpc |
---|
40 | ); |
---|
41 | |
---|
42 | switch (real_trap) { |
---|
43 | |
---|
44 | /* |
---|
45 | * First the ones defined by the basic architecture |
---|
46 | */ |
---|
47 | |
---|
48 | case 0x00: |
---|
49 | printk( "reset\n" ); |
---|
50 | break; |
---|
51 | case 0x01: |
---|
52 | printk( "instruction access exception\n" ); |
---|
53 | break; |
---|
54 | case 0x02: |
---|
55 | printk( "illegal instruction\n" ); |
---|
56 | break; |
---|
57 | case 0x03: |
---|
58 | printk( "privileged instruction\n" ); |
---|
59 | break; |
---|
60 | case 0x04: |
---|
61 | printk( "fp disabled\n" ); |
---|
62 | break; |
---|
63 | case 0x07: |
---|
64 | printk( "memory address not aligned\n" ); |
---|
65 | break; |
---|
66 | case 0x08: |
---|
67 | printk( "fp exception\n" ); |
---|
68 | break; |
---|
69 | case 0x09: |
---|
70 | printk("data access exception at 0x%08x\n", LEON_REG.Failed_Address ); |
---|
71 | break; |
---|
72 | case 0x0A: |
---|
73 | printk( "tag overflow\n" ); |
---|
74 | break; |
---|
75 | |
---|
76 | /* |
---|
77 | * Then the ones defined by the LEON in particular |
---|
78 | */ |
---|
79 | |
---|
80 | case LEON_TRAP_TYPE( LEON_INTERRUPT_CORRECTABLE_MEMORY_ERROR ): |
---|
81 | printk( "LEON_INTERRUPT_CORRECTABLE_MEMORY_ERROR\n" ); |
---|
82 | break; |
---|
83 | case LEON_TRAP_TYPE( LEON_INTERRUPT_UART_2_RX_TX ): |
---|
84 | printk( "LEON_INTERRUPT_UART_2_RX_TX\n" ); |
---|
85 | break; |
---|
86 | case LEON_TRAP_TYPE( LEON_INTERRUPT_UART_1_RX_TX ): |
---|
87 | printk( "LEON_INTERRUPT_UART_1_RX_TX\n" ); |
---|
88 | break; |
---|
89 | case LEON_TRAP_TYPE( LEON_INTERRUPT_EXTERNAL_0 ): |
---|
90 | printk( "LEON_INTERRUPT_EXTERNAL_0\n" ); |
---|
91 | break; |
---|
92 | case LEON_TRAP_TYPE( LEON_INTERRUPT_EXTERNAL_1 ): |
---|
93 | printk( "LEON_INTERRUPT_EXTERNAL_1\n" ); |
---|
94 | break; |
---|
95 | case LEON_TRAP_TYPE( LEON_INTERRUPT_EXTERNAL_2 ): |
---|
96 | printk( "LEON_INTERRUPT_EXTERNAL_2\n" ); |
---|
97 | break; |
---|
98 | case LEON_TRAP_TYPE( LEON_INTERRUPT_EXTERNAL_3 ): |
---|
99 | printk( "LEON_INTERRUPT_EXTERNAL_3\n" ); |
---|
100 | break; |
---|
101 | case LEON_TRAP_TYPE( LEON_INTERRUPT_TIMER1 ): |
---|
102 | printk( "LEON_INTERRUPT_TIMER1\n" ); |
---|
103 | break; |
---|
104 | case LEON_TRAP_TYPE( LEON_INTERRUPT_TIMER2 ): |
---|
105 | printk( "LEON_INTERRUPT_TIMER2\n" ); |
---|
106 | break; |
---|
107 | |
---|
108 | default: |
---|
109 | break; |
---|
110 | } |
---|
111 | } |
---|
112 | |
---|
113 | static 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 | |
---|
137 | void bsp_spurious_initialize() |
---|
138 | { |
---|
139 | uint32_t trap; |
---|
140 | uint32_t level; |
---|
141 | uint32_t mask; |
---|
142 | |
---|
143 | level = sparc_disable_interrupts(); |
---|
144 | mask = LEON_REG.Interrupt_Mask; |
---|
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 parameters to the program. |
---|
153 | */ |
---|
154 | |
---|
155 | if (( trap == 5 || trap == 6 ) || |
---|
156 | (( trap >= 0x11 ) && ( trap <= 0x1f )) || |
---|
157 | (( trap >= 0x70 ) && ( trap <= 0x83 )) || |
---|
158 | ( trap == 0x80 + SPARC_SWTRAP_IRQDIS ) || |
---|
159 | #if SPARC_HAS_FPU == 1 |
---|
160 | ( trap == 0x80 + SPARC_SWTRAP_IRQDIS_FP ) || |
---|
161 | #endif |
---|
162 | ( trap == 0x80 + SPARC_SWTRAP_IRQEN )) |
---|
163 | continue; |
---|
164 | |
---|
165 | set_vector( |
---|
166 | (rtems_isr_entry) bsp_spurious_handler, |
---|
167 | SPARC_SYNCHRONOUS_TRAP( trap ), |
---|
168 | 1 |
---|
169 | ); |
---|
170 | } |
---|
171 | |
---|
172 | LEON_REG.Interrupt_Mask = mask; |
---|
173 | sparc_enable_interrupts(level); |
---|
174 | |
---|
175 | } |
---|