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 | * This terms of the RTEMS license apply to this file. |
---|
14 | */ |
---|
15 | |
---|
16 | #include <bsp.h> |
---|
17 | #include <rtems/bspIo.h> |
---|
18 | |
---|
19 | /* |
---|
20 | * bsp_spurious_handler |
---|
21 | * |
---|
22 | * Print a message on the debug console and then die |
---|
23 | */ |
---|
24 | |
---|
25 | rtems_isr bsp_spurious_handler( |
---|
26 | rtems_vector_number trap, |
---|
27 | CPU_Interrupt_frame *isf |
---|
28 | ) |
---|
29 | { |
---|
30 | uint32_t real_trap; |
---|
31 | |
---|
32 | real_trap = SPARC_REAL_TRAP_NUMBER(trap); |
---|
33 | |
---|
34 | printk( "Unexpected trap (%2d) 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("data access exception at 0x%08x\n", LEON_REG.Failed_Address ); |
---|
65 | break; |
---|
66 | case 0x0A: |
---|
67 | printk( "tag overflow\n" ); |
---|
68 | break; |
---|
69 | |
---|
70 | /* |
---|
71 | * Then the ones defined by the LEON in particular |
---|
72 | */ |
---|
73 | |
---|
74 | case LEON_TRAP_TYPE( LEON_INTERRUPT_CORRECTABLE_MEMORY_ERROR ): |
---|
75 | printk( "LEON_INTERRUPT_CORRECTABLE_MEMORY_ERROR\n" ); |
---|
76 | break; |
---|
77 | case LEON_TRAP_TYPE( LEON_INTERRUPT_UART_2_RX_TX ): |
---|
78 | printk( "LEON_INTERRUPT_UART_2_RX_TX\n" ); |
---|
79 | break; |
---|
80 | case LEON_TRAP_TYPE( LEON_INTERRUPT_UART_1_RX_TX ): |
---|
81 | printk( "LEON_INTERRUPT_UART_1_RX_TX\n" ); |
---|
82 | break; |
---|
83 | case LEON_TRAP_TYPE( LEON_INTERRUPT_EXTERNAL_0 ): |
---|
84 | printk( "LEON_INTERRUPT_EXTERNAL_0\n" ); |
---|
85 | break; |
---|
86 | case LEON_TRAP_TYPE( LEON_INTERRUPT_EXTERNAL_1 ): |
---|
87 | printk( "LEON_INTERRUPT_EXTERNAL_1\n" ); |
---|
88 | break; |
---|
89 | case LEON_TRAP_TYPE( LEON_INTERRUPT_EXTERNAL_2 ): |
---|
90 | printk( "LEON_INTERRUPT_EXTERNAL_2\n" ); |
---|
91 | break; |
---|
92 | case LEON_TRAP_TYPE( LEON_INTERRUPT_EXTERNAL_3 ): |
---|
93 | printk( "LEON_INTERRUPT_EXTERNAL_3\n" ); |
---|
94 | break; |
---|
95 | case LEON_TRAP_TYPE( LEON_INTERRUPT_TIMER1 ): |
---|
96 | printk( "LEON_INTERRUPT_TIMER1\n" ); |
---|
97 | break; |
---|
98 | case LEON_TRAP_TYPE( LEON_INTERRUPT_TIMER2 ): |
---|
99 | printk( "LEON_INTERRUPT_TIMER2\n" ); |
---|
100 | break; |
---|
101 | |
---|
102 | default: |
---|
103 | break; |
---|
104 | } |
---|
105 | |
---|
106 | /* |
---|
107 | * What else can we do but stop ... |
---|
108 | */ |
---|
109 | |
---|
110 | __asm__ volatile( "mov 1, %g1; ta 0x0" ); |
---|
111 | } |
---|
112 | |
---|
113 | /* |
---|
114 | * bsp_spurious_initialize |
---|
115 | * |
---|
116 | * Install the spurious handler for most traps. Note that set_vector() |
---|
117 | * will unmask the corresponding asynchronous interrupt, so the initial |
---|
118 | * interrupt mask is restored after the handlers are installed. |
---|
119 | */ |
---|
120 | |
---|
121 | void bsp_spurious_initialize() |
---|
122 | { |
---|
123 | uint32_t trap; |
---|
124 | uint32_t level; |
---|
125 | uint32_t mask; |
---|
126 | |
---|
127 | level = sparc_disable_interrupts(); |
---|
128 | mask = LEON_REG.Interrupt_Mask; |
---|
129 | |
---|
130 | for ( trap=0 ; trap<256 ; trap++ ) { |
---|
131 | |
---|
132 | /* |
---|
133 | * Skip window overflow, underflow, and flush as well as software |
---|
134 | * trap 0 which we will use as a shutdown. Also avoid trap 0x70 - 0x7f |
---|
135 | * which cannot happen and where some of the space is used to pass |
---|
136 | * paramaters to the program. |
---|
137 | */ |
---|
138 | |
---|
139 | if (( trap == 5 || trap == 6 ) || |
---|
140 | (( trap >= 0x11 ) && ( trap <= 0x1f )) || |
---|
141 | (( trap >= 0x70 ) && ( trap <= 0x83 ))) |
---|
142 | continue; |
---|
143 | |
---|
144 | set_vector( |
---|
145 | (rtems_isr_entry) bsp_spurious_handler, |
---|
146 | SPARC_SYNCHRONOUS_TRAP( trap ), |
---|
147 | 1 |
---|
148 | ); |
---|
149 | } |
---|
150 | |
---|
151 | LEON_REG.Interrupt_Mask = mask; |
---|
152 | sparc_enable_interrupts(level); |
---|
153 | |
---|
154 | } |
---|