1 | /* irq_stub.s 1.1 - 95/12/04 |
---|
2 | * |
---|
3 | * This file contains the interrupt handler assembly code for the PowerPC |
---|
4 | * implementation of RTEMS. It is #included from cpu_asm.s. |
---|
5 | * |
---|
6 | * Author: Andrew Bray <andy@i-cubed.co.uk> |
---|
7 | * |
---|
8 | * COPYRIGHT (c) 1995 by i-cubed ltd. |
---|
9 | * |
---|
10 | * To anyone who acknowledges that this file is provided "AS IS" |
---|
11 | * without any express or implied warranty: |
---|
12 | * permission to use, copy, modify, and distribute this file |
---|
13 | * for any purpose is hereby granted without fee, provided that |
---|
14 | * the above copyright notice and this notice appears in all |
---|
15 | * copies, and that the name of i-cubed limited not be used in |
---|
16 | * advertising or publicity pertaining to distribution of the |
---|
17 | * software without specific, written prior permission. |
---|
18 | * i-cubed limited makes no representations about the suitability |
---|
19 | * of this software for any purpose. |
---|
20 | * |
---|
21 | * $Id$ |
---|
22 | */ |
---|
23 | |
---|
24 | /* void __ISR_Handler() |
---|
25 | * |
---|
26 | * This routine provides the RTEMS interrupt management. |
---|
27 | * The vector number is in r0. R0 has already been stacked. |
---|
28 | * |
---|
29 | */ |
---|
30 | /* Finish off the interrupt frame */ |
---|
31 | stw r2, IP_2(r1) |
---|
32 | stw r3, IP_3(r1) |
---|
33 | stw r4, IP_4(r1) |
---|
34 | stw r5, IP_5(r1) |
---|
35 | stw r6, IP_6(r1) |
---|
36 | stw r7, IP_7(r1) |
---|
37 | stw r8, IP_8(r1) |
---|
38 | stw r9, IP_9(r1) |
---|
39 | stw r10, IP_10(r1) |
---|
40 | stw r11, IP_11(r1) |
---|
41 | stw r12, IP_12(r1) |
---|
42 | stw r13, IP_13(r1) |
---|
43 | stmw r28, IP_28(r1) |
---|
44 | mfcr r5 |
---|
45 | mfctr r6 |
---|
46 | mfxer r7 |
---|
47 | mflr r8 |
---|
48 | MFPC (r9) |
---|
49 | MFMSR (r10) |
---|
50 | /* Establish addressing */ |
---|
51 | mfspr r11, sprg3 |
---|
52 | dcbt r0, r11 |
---|
53 | stw r5, IP_CR(r1) |
---|
54 | stw r6, IP_CTR(r1) |
---|
55 | stw r7, IP_XER(r1) |
---|
56 | stw r8, IP_LR(r1) |
---|
57 | stw r9, IP_PC(r1) |
---|
58 | stw r10, IP_MSR(r1) |
---|
59 | |
---|
60 | lwz r30, Vector_table(r11) |
---|
61 | slwi r4,r0,2 |
---|
62 | lwz r28, Nest_level(r11) |
---|
63 | add r4, r4, r30 |
---|
64 | |
---|
65 | lwz r30, 0(r28) |
---|
66 | mr r3, r0 |
---|
67 | lwz r31, Stack(r11) |
---|
68 | /* |
---|
69 | * #if ( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE ) |
---|
70 | * if ( _ISR_Nest_level == 0 ) |
---|
71 | * switch to software interrupt stack |
---|
72 | * #endif |
---|
73 | */ |
---|
74 | /* Switch stacks, here we must prevent ALL interrupts */ |
---|
75 | mfmsr r5 |
---|
76 | mfspr r6, sprg2 |
---|
77 | mtmsr r6 |
---|
78 | cmpwi r30, 0 |
---|
79 | lwz r29, Disable_level(r11) |
---|
80 | subf r31,r1,r31 |
---|
81 | bne LABEL (nested) |
---|
82 | stwux r1,r1,r31 |
---|
83 | LABEL (nested): |
---|
84 | /* |
---|
85 | * _ISR_Nest_level++; |
---|
86 | */ |
---|
87 | lwz r31, 0(r29) |
---|
88 | addi r30,r30,1 |
---|
89 | stw r30,0(r28) |
---|
90 | /* From here on out, interrupts can be re-enabled. RTEMS |
---|
91 | * convention says not. |
---|
92 | */ |
---|
93 | lwz r4,0(r4) |
---|
94 | /* |
---|
95 | * _Thread_Dispatch_disable_level++; |
---|
96 | */ |
---|
97 | addi r31,r31,1 |
---|
98 | stw r31, 0(r29) |
---|
99 | mtmsr r5 |
---|
100 | /* |
---|
101 | * (*_ISR_Vector_table[ vector ])( vector ); |
---|
102 | */ |
---|
103 | #if (PPC_ABI == PPC_ABI_POWEROPEN) |
---|
104 | lwz r6,0(r4) |
---|
105 | lwz r2,4(r4) |
---|
106 | mtlr r6 |
---|
107 | lwz r11,8(r4) |
---|
108 | #endif |
---|
109 | #if (PPC_ABI == PPC_ABI_GCC27) |
---|
110 | lwz r2, Default_r2(r11) |
---|
111 | mtlr r4 |
---|
112 | lwz r2, 0(r2) |
---|
113 | #endif |
---|
114 | #if (PPC_ABI == PPC_ABI_SVR4 || PPC_ABI == PPC_ABI_EABI) |
---|
115 | mtlr r4 |
---|
116 | lwz r2, Default_r2(r11) |
---|
117 | lwz r13, Default_r13(r11) |
---|
118 | lwz r2, 0(r2) |
---|
119 | lwz r13, 0(r13) |
---|
120 | #endif |
---|
121 | mr r4,r1 |
---|
122 | blrl |
---|
123 | /* NOP marker for debuggers */ |
---|
124 | or r6,r6,r6 |
---|
125 | |
---|
126 | /* We must re-disable the interrupts */ |
---|
127 | mfspr r11, sprg3 |
---|
128 | mfspr r0, sprg2 |
---|
129 | mtmsr r0 |
---|
130 | lwz r30, 0(r28) |
---|
131 | lwz r31, 0(r29) |
---|
132 | |
---|
133 | /* |
---|
134 | * if (--Thread_Dispatch_disable,--_ISR_Nest_level) |
---|
135 | * goto easy_exit; |
---|
136 | */ |
---|
137 | addi r30, r30, -1 |
---|
138 | cmpwi r30, 0 |
---|
139 | addi r31, r31, -1 |
---|
140 | stw r30, 0(r28) |
---|
141 | stw r31, 0(r29) |
---|
142 | bne LABEL (easy_exit) |
---|
143 | cmpwi r31, 0 |
---|
144 | |
---|
145 | lwz r30, Switch_necessary(r11) |
---|
146 | |
---|
147 | /* |
---|
148 | * #if ( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE ) |
---|
149 | * restore stack |
---|
150 | * #endif |
---|
151 | */ |
---|
152 | lwz r1,0(r1) |
---|
153 | bne LABEL (easy_exit) |
---|
154 | lwz r30, 0(r30) |
---|
155 | lwz r31, Signal(r11) |
---|
156 | |
---|
157 | /* |
---|
158 | * if ( _Context_Switch_necessary ) |
---|
159 | * goto switch |
---|
160 | */ |
---|
161 | cmpwi r30, 0 |
---|
162 | lwz r28, 0(r31) |
---|
163 | li r6,0 |
---|
164 | bne LABEL (switch) |
---|
165 | /* |
---|
166 | * if ( !_ISR_Signals_to_thread_executing ) |
---|
167 | * goto easy_exit |
---|
168 | * _ISR_Signals_to_thread_executing = 0; |
---|
169 | */ |
---|
170 | cmpwi r28, 0 |
---|
171 | beq LABEL (easy_exit) |
---|
172 | |
---|
173 | /* |
---|
174 | * switch: |
---|
175 | * call _Thread_Dispatch() or prepare to return to _ISR_Dispatch |
---|
176 | */ |
---|
177 | LABEL (switch): |
---|
178 | stw r6, 0(r31) |
---|
179 | /* Re-enable interrupts */ |
---|
180 | lwz r0, IP_MSR(r1) |
---|
181 | #if (PPC_ABI == PPC_ABI_POWEROPEN) |
---|
182 | lwz r2, Dispatch_r2(r11) |
---|
183 | #else |
---|
184 | /* R2 and R13 still hold their values from the last call */ |
---|
185 | #endif |
---|
186 | mtmsr r0 |
---|
187 | bl SYM (_Thread_Dispatch) |
---|
188 | /* NOP marker for debuggers */ |
---|
189 | or r6,r6,r6 |
---|
190 | /* |
---|
191 | * prepare to get out of interrupt |
---|
192 | */ |
---|
193 | /* Re-disable IRQs */ |
---|
194 | mfspr r0, sprg2 |
---|
195 | mtmsr r0 |
---|
196 | /* |
---|
197 | * easy_exit: |
---|
198 | * prepare to get out of interrupt |
---|
199 | * return from interrupt |
---|
200 | */ |
---|
201 | LABEL (easy_exit): |
---|
202 | lwz r5, IP_CR(r1) |
---|
203 | lwz r6, IP_CTR(r1) |
---|
204 | lwz r7, IP_XER(r1) |
---|
205 | lwz r8, IP_LR(r1) |
---|
206 | lwz r9, IP_PC(r1) |
---|
207 | lwz r10, IP_MSR(r1) |
---|
208 | mtcrf 255,r5 |
---|
209 | mtctr r6 |
---|
210 | mtxer r7 |
---|
211 | mtlr r8 |
---|
212 | MTPC (r9) |
---|
213 | MTMSR (r10) |
---|
214 | lwz r0, IP_0(r1) |
---|
215 | lwz r2, IP_2(r1) |
---|
216 | lwz r3, IP_3(r1) |
---|
217 | lwz r4, IP_4(r1) |
---|
218 | lwz r5, IP_5(r1) |
---|
219 | lwz r6, IP_6(r1) |
---|
220 | lwz r7, IP_7(r1) |
---|
221 | lwz r8, IP_8(r1) |
---|
222 | lwz r9, IP_9(r1) |
---|
223 | lwz r10, IP_10(r1) |
---|
224 | lwz r11, IP_11(r1) |
---|
225 | lwz r12, IP_12(r1) |
---|
226 | lwz r13, IP_13(r1) |
---|
227 | lmw r28, IP_28(r1) |
---|
228 | lwz r1, 0(r1) |
---|