1 | /* irq_stub.s 1.0 - 95/08/08 |
---|
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.demon.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 | mfsrr0 r9 |
---|
49 | mfsrr1 r10 |
---|
50 | /* Establish addressing */ |
---|
51 | mfsprg3 r11 |
---|
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 | cmpwi r30, 0 |
---|
76 | lwz r29, Disable_level(r11) |
---|
77 | subf r31,r1,r31 |
---|
78 | bne LABEL (nested) |
---|
79 | stwux r1,r1,r31 |
---|
80 | LABEL (nested): |
---|
81 | /* |
---|
82 | * _ISR_Nest_level++; |
---|
83 | */ |
---|
84 | lwz r31, 0(r29) |
---|
85 | addi r30,r30,1 |
---|
86 | stw r30,0(r28) |
---|
87 | /* From here on out, interrupts can be re-enabled. RTEMS |
---|
88 | * convention says not. |
---|
89 | */ |
---|
90 | lwz r4,0(r4) |
---|
91 | /* |
---|
92 | * _Thread_Dispatch_disable_level++; |
---|
93 | */ |
---|
94 | addi r31,r31,1 |
---|
95 | stw r31, 0(r29) |
---|
96 | /* |
---|
97 | * (*_ISR_Vector_table[ vector ])( vector ); |
---|
98 | */ |
---|
99 | #if (PPC_ABI == PPC_ABI_POWEROPEN) |
---|
100 | lwz r6,0(r4) |
---|
101 | lwz r2,4(r4) |
---|
102 | mtlr r6 |
---|
103 | lwz r11,8(r4) |
---|
104 | #endif |
---|
105 | #if (PPC_ABI == PPC_ABI_GCC27) |
---|
106 | lwz r2, Default_r2(r11) |
---|
107 | mtlr r4 |
---|
108 | lwz r2, 0(r2) |
---|
109 | #endif |
---|
110 | #if (PPC_ABI == PPC_ABI_SVR4 || PPC_ABI == PPC_ABI_EABI) |
---|
111 | mtlr r4 |
---|
112 | lwz r2, Default_r2(r11) |
---|
113 | lwz r13, Default_r13(r11) |
---|
114 | lwz r2, 0(r2) |
---|
115 | lwz r13, 0(r13) |
---|
116 | #endif |
---|
117 | mr r4,r1 |
---|
118 | blrl |
---|
119 | /* NOP marker for debuggers */ |
---|
120 | or r6,r6,r6 |
---|
121 | |
---|
122 | /* We must re-disable the interrupts */ |
---|
123 | mfsprg3 r11 |
---|
124 | mfsprg2 r0 |
---|
125 | mtmsr r0 |
---|
126 | |
---|
127 | /* |
---|
128 | * if (--Thread_Dispatch_disable,--_ISR_Nest_level) |
---|
129 | * goto easy_exit; |
---|
130 | */ |
---|
131 | addi r30, r30, -1 |
---|
132 | cmpwi r30, 0 |
---|
133 | addi r31, r31, -1 |
---|
134 | stw r30, 0(r28) |
---|
135 | stw r31, 0(r29) |
---|
136 | bne LABEL (easy_exit) |
---|
137 | |
---|
138 | lwz r30, Switch_necessary(r11) |
---|
139 | |
---|
140 | /* |
---|
141 | * #if ( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE ) |
---|
142 | * restore stack |
---|
143 | * #endif |
---|
144 | */ |
---|
145 | lwz r1,0(r1) |
---|
146 | lwz r30, 0(r30) |
---|
147 | lwz r31, Signal(r11) |
---|
148 | |
---|
149 | /* |
---|
150 | * if ( _Context_Switch_necessary ) |
---|
151 | * goto switch |
---|
152 | */ |
---|
153 | cmpwi r30, 0 |
---|
154 | lwz r28, 0(r31) |
---|
155 | bne LABEL (switch) |
---|
156 | /* |
---|
157 | * if ( !_ISR_Signals_to_thread_executing ) |
---|
158 | * goto easy_exit |
---|
159 | * _ISR_Signals_to_thread_executing = 0; |
---|
160 | */ |
---|
161 | cmpwi r28, 0 |
---|
162 | li r6,0 |
---|
163 | beq LABEL (easy_exit) |
---|
164 | stw r6, 0(r31) |
---|
165 | |
---|
166 | /* |
---|
167 | * switch: |
---|
168 | * call _Thread_Dispatch() or prepare to return to _ISR_Dispatch |
---|
169 | */ |
---|
170 | LABEL (switch): |
---|
171 | #if (PPC_ABI == PPC_ABI_POWEROPEN) |
---|
172 | lwz r2, Dispatch_r2(r11) |
---|
173 | #else |
---|
174 | /* R2 and R13 still hold their values from the last call */ |
---|
175 | #endif |
---|
176 | bl PROC (_Thread_Dispatch) |
---|
177 | /* NOP marker for debuggers */ |
---|
178 | or r6,r6,r6 |
---|
179 | /* |
---|
180 | * prepare to get out of interrupt |
---|
181 | */ |
---|
182 | /* Re-disable IRQs */ |
---|
183 | mfsprg2 r0 |
---|
184 | mtmsr r0 |
---|
185 | /* |
---|
186 | * easy_exit: |
---|
187 | * prepare to get out of interrupt |
---|
188 | * return from interrupt |
---|
189 | */ |
---|
190 | LABEL (easy_exit): |
---|
191 | lwz r5, IP_CR(r1) |
---|
192 | lwz r6, IP_CTR(r1) |
---|
193 | lwz r7, IP_XER(r1) |
---|
194 | lwz r8, IP_LR(r1) |
---|
195 | lwz r9, IP_PC(r1) |
---|
196 | lwz r10, IP_MSR(r1) |
---|
197 | mtcrf 255,r5 |
---|
198 | mtctr r6 |
---|
199 | mtxer r7 |
---|
200 | mtlr r8 |
---|
201 | mtsrr0 r9 |
---|
202 | mtsrr1 r10 |
---|
203 | lwz r0, IP_0(r1) |
---|
204 | lwz r2, IP_2(r1) |
---|
205 | lwz r3, IP_3(r1) |
---|
206 | lwz r4, IP_4(r1) |
---|
207 | lwz r5, IP_5(r1) |
---|
208 | lwz r6, IP_6(r1) |
---|
209 | lwz r7, IP_7(r1) |
---|
210 | lwz r8, IP_8(r1) |
---|
211 | lwz r9, IP_9(r1) |
---|
212 | lwz r10, IP_10(r1) |
---|
213 | lwz r11, IP_11(r1) |
---|
214 | lwz r12, IP_12(r1) |
---|
215 | lwz r13, IP_13(r1) |
---|
216 | lmw r28, IP_28(r1) |
---|
217 | lwz r1, 0(r1) |
---|