1 | /* vectors.s 1.0 - 95/08/08 |
---|
2 | * |
---|
3 | * This file contains the assembly code for the PowerPC 403 |
---|
4 | * interrupt veneers for RTEMS. |
---|
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 | /* |
---|
25 | * The issue with this file is getting it loaded at the right place. |
---|
26 | * The first vector MUST be at address 0x????0100. |
---|
27 | * How this is achieved is dependant on the tool chain. |
---|
28 | * |
---|
29 | * However the basic mechanism for ELF assemblers is to create a |
---|
30 | * section called ".vectors", which will be loaded to an address |
---|
31 | * between 0x????0000 and 0x????0100 (inclusive) via a link script. |
---|
32 | * |
---|
33 | * The basic mechanism for XCOFF assemblers is to place it in the |
---|
34 | * normal text section, and arrange for this file to be located |
---|
35 | * at an appropriate position on the linker command line. |
---|
36 | * |
---|
37 | * The variable 'PPC_VECTOR_FILE_BASE' must be defined to be the |
---|
38 | * offset from 0x????0000 to the first location in the file. This |
---|
39 | * will usually be 0x0000 or 0x0100. |
---|
40 | */ |
---|
41 | |
---|
42 | #include "asm.h" |
---|
43 | |
---|
44 | #ifndef PPC_VECTOR_FILE_BASE |
---|
45 | #error "PPC_VECTOR_FILE_BASE is not defined." |
---|
46 | #endif |
---|
47 | |
---|
48 | /* Where this file will be loaded */ |
---|
49 | .set file_base, PPC_VECTOR_FILE_BASE |
---|
50 | |
---|
51 | /* Offset to store reg 0 */ |
---|
52 | |
---|
53 | .set IP_LINK, 0 |
---|
54 | #if (PPC_ABI == PPC_ABI_POWEROPEN || PPC_ABI == PPC_ABI_GCC27) |
---|
55 | .set IP_0, (IP_LINK + 56) |
---|
56 | #else |
---|
57 | .set IP_0, (IP_LINK + 8) |
---|
58 | #endif |
---|
59 | .set IP_2, (IP_0 + 4) |
---|
60 | |
---|
61 | .set IP_3, (IP_2 + 4) |
---|
62 | .set IP_4, (IP_3 + 4) |
---|
63 | .set IP_5, (IP_4 + 4) |
---|
64 | .set IP_6, (IP_5 + 4) |
---|
65 | |
---|
66 | .set IP_7, (IP_6 + 4) |
---|
67 | .set IP_8, (IP_7 + 4) |
---|
68 | .set IP_9, (IP_8 + 4) |
---|
69 | .set IP_10, (IP_9 + 4) |
---|
70 | |
---|
71 | .set IP_11, (IP_10 + 4) |
---|
72 | .set IP_12, (IP_11 + 4) |
---|
73 | .set IP_13, (IP_12 + 4) |
---|
74 | .set IP_28, (IP_13 + 4) |
---|
75 | |
---|
76 | .set IP_29, (IP_28 + 4) |
---|
77 | .set IP_30, (IP_29 + 4) |
---|
78 | .set IP_31, (IP_30 + 4) |
---|
79 | .set IP_CR, (IP_31 + 4) |
---|
80 | |
---|
81 | .set IP_CTR, (IP_CR + 4) |
---|
82 | .set IP_XER, (IP_CTR + 4) |
---|
83 | .set IP_LR, (IP_XER + 4) |
---|
84 | .set IP_PC, (IP_LR + 4) |
---|
85 | |
---|
86 | .set IP_MSR, (IP_PC + 4) |
---|
87 | |
---|
88 | .set IP_END, (IP_MSR + 16) |
---|
89 | |
---|
90 | /* Vector offsets */ |
---|
91 | .set begin_vector,0x0000 |
---|
92 | .set crit_vector,0x0100 |
---|
93 | .set mach_vector,0x0200 |
---|
94 | .set prot_vector,0x0300 |
---|
95 | .set ext_vector,0x0500 |
---|
96 | .set align_vector,0x0600 |
---|
97 | .set prog_vector,0x0700 |
---|
98 | .set sys_vector,0x0C00 |
---|
99 | .set pit_vector,0x1000 |
---|
100 | .set fit_vector,0x1010 |
---|
101 | .set wadt_vector,0x1020 |
---|
102 | .set debug_vector,0x2000 |
---|
103 | |
---|
104 | /* Go to the right section */ |
---|
105 | #if PPC_ASM == PPC_ASM_ELF |
---|
106 | .section .vectors,"awx",@progbits |
---|
107 | #elif PPC_ASM == PPC_ASM_XCOFF |
---|
108 | .csect .text[PR] |
---|
109 | #endif |
---|
110 | |
---|
111 | PUBLIC_VAR (__vectors) |
---|
112 | SYM (__vectors): |
---|
113 | |
---|
114 | /* Critical error handling */ |
---|
115 | .org crit_vector - file_base |
---|
116 | mtsprg1 r0 |
---|
117 | mfsprg2 r0 |
---|
118 | mtmsr r0 |
---|
119 | #if (PPC_ABI == PPC_ABI_POWEROPEN || PPC_ABI == PPC_ABI_GCC27) |
---|
120 | #if (PPC_HAS_FPU) |
---|
121 | stwu r1, -(20*4 + 18*8 + IP_END)(r1) |
---|
122 | #else |
---|
123 | stwu r1, -(20*4 + IP_END)(r1) |
---|
124 | #endif |
---|
125 | #else |
---|
126 | stwu r1, -(IP_END)(r1) |
---|
127 | #endif |
---|
128 | mfsprg1 r0 |
---|
129 | stw r0, IP_0(r1) |
---|
130 | |
---|
131 | li r0, PPC_IRQ_CRIT |
---|
132 | b PROC (_ISR_HandlerC) |
---|
133 | |
---|
134 | /* Machine check exception */ |
---|
135 | .org mach_vector - file_base |
---|
136 | mtsprg1 r0 |
---|
137 | mfsprg2 r0 |
---|
138 | mtmsr r0 |
---|
139 | #if (PPC_ABI == PPC_ABI_POWEROPEN || PPC_ABI == PPC_ABI_GCC27) |
---|
140 | #if (PPC_HAS_FPU) |
---|
141 | stwu r1, -(20*4 + 18*8 + IP_END)(r1) |
---|
142 | #else |
---|
143 | stwu r1, -(20*4 + IP_END)(r1) |
---|
144 | #endif |
---|
145 | #else |
---|
146 | stwu r1, -(IP_END)(r1) |
---|
147 | #endif |
---|
148 | mfsprg1 r0 |
---|
149 | stw r0, IP_0(r1) |
---|
150 | |
---|
151 | li r0, PPC_IRQ_MCHECK |
---|
152 | b PROC (_ISR_HandlerC) |
---|
153 | |
---|
154 | /* Protection exception */ |
---|
155 | .org prot_vector - file_base |
---|
156 | mtsprg0 r0 |
---|
157 | mfsprg2 r0 |
---|
158 | mtmsr r0 |
---|
159 | #if (PPC_ABI == PPC_ABI_POWEROPEN || PPC_ABI == PPC_ABI_GCC27) |
---|
160 | #if (PPC_HAS_FPU) |
---|
161 | stwu r1, -(20*4 + 18*8 + IP_END)(r1) |
---|
162 | #else |
---|
163 | stwu r1, -(20*4 + IP_END)(r1) |
---|
164 | #endif |
---|
165 | #else |
---|
166 | stwu r1, -(IP_END)(r1) |
---|
167 | #endif |
---|
168 | mfsprg0 r0 |
---|
169 | stw r0, IP_0(r1) |
---|
170 | |
---|
171 | li r0, PPC_IRQ_PROTECT |
---|
172 | b PROC (_ISR_Handler) |
---|
173 | |
---|
174 | /* External interrupt */ |
---|
175 | .org ext_vector - file_base |
---|
176 | mtsprg0 r0 |
---|
177 | mfsprg2 r0 |
---|
178 | mtmsr r0 |
---|
179 | #if (PPC_ABI == PPC_ABI_POWEROPEN || PPC_ABI == PPC_ABI_GCC27) |
---|
180 | #if (PPC_HAS_FPU) |
---|
181 | stwu r1, -(20*4 + 18*8 + IP_END)(r1) |
---|
182 | #else |
---|
183 | stwu r1, -(20*4 + IP_END)(r1) |
---|
184 | #endif |
---|
185 | #else |
---|
186 | stwu r1, -(IP_END)(r1) |
---|
187 | #endif |
---|
188 | mfsprg0 r0 |
---|
189 | stw r0, IP_0(r1) |
---|
190 | |
---|
191 | li r0, PPC_IRQ_EXTERNAL |
---|
192 | b PROC (_ISR_Handler) |
---|
193 | |
---|
194 | /* Align exception */ |
---|
195 | .org align_vector - file_base |
---|
196 | .extern align_h |
---|
197 | b align_h |
---|
198 | |
---|
199 | /* Program exception */ |
---|
200 | .org prog_vector - file_base |
---|
201 | mtsprg0 r0 |
---|
202 | mfsprg2 r0 |
---|
203 | mtmsr r0 |
---|
204 | #if (PPC_ABI == PPC_ABI_POWEROPEN || PPC_ABI == PPC_ABI_GCC27) |
---|
205 | #if (PPC_HAS_FPU) |
---|
206 | stwu r1, -(20*4 + 18*8 + IP_END)(r1) |
---|
207 | #else |
---|
208 | stwu r1, -(20*4 + IP_END)(r1) |
---|
209 | #endif |
---|
210 | #else |
---|
211 | stwu r1, -(IP_END)(r1) |
---|
212 | #endif |
---|
213 | mfsprg0 r0 |
---|
214 | stw r0, IP_0(r1) |
---|
215 | |
---|
216 | li r0, PPC_IRQ_PROGRAM |
---|
217 | b PROC (_ISR_Handler) |
---|
218 | |
---|
219 | /* System call */ |
---|
220 | .org sys_vector - file_base |
---|
221 | mtsprg0 r0 |
---|
222 | mfsprg2 r0 |
---|
223 | mtmsr r0 |
---|
224 | #if (PPC_ABI == PPC_ABI_POWEROPEN || PPC_ABI == PPC_ABI_GCC27) |
---|
225 | #if (PPC_HAS_FPU) |
---|
226 | stwu r1, -(20*4 + 18*8 + IP_END)(r1) |
---|
227 | #else |
---|
228 | stwu r1, -(20*4 + IP_END)(r1) |
---|
229 | #endif |
---|
230 | #else |
---|
231 | stwu r1, -(IP_END)(r1) |
---|
232 | #endif |
---|
233 | mfsprg0 r0 |
---|
234 | stw r0, IP_0(r1) |
---|
235 | |
---|
236 | li r0, PPC_IRQ_SCALL |
---|
237 | b PROC (_ISR_Handler) |
---|
238 | |
---|
239 | /* PIT interrupt */ |
---|
240 | .org pit_vector - file_base |
---|
241 | b pit |
---|
242 | |
---|
243 | /* FIT interrupt */ |
---|
244 | .org fit_vector - file_base |
---|
245 | b fit |
---|
246 | |
---|
247 | /* Watchdog interrupt */ |
---|
248 | .org wadt_vector - file_base |
---|
249 | b watch |
---|
250 | |
---|
251 | /* PIT interrupt */ |
---|
252 | pit: |
---|
253 | mtsprg0 r0 |
---|
254 | mfsprg2 r0 |
---|
255 | mtmsr r0 |
---|
256 | #if (PPC_ABI == PPC_ABI_POWEROPEN || PPC_ABI == PPC_ABI_GCC27) |
---|
257 | #if (PPC_HAS_FPU) |
---|
258 | stwu r1, -(20*4 + 18*8 + IP_END)(r1) |
---|
259 | #else |
---|
260 | stwu r1, -(20*4 + IP_END)(r1) |
---|
261 | #endif |
---|
262 | #else |
---|
263 | stwu r1, -(IP_END)(r1) |
---|
264 | #endif |
---|
265 | mfsprg0 r0 |
---|
266 | stw r0, IP_0(r1) |
---|
267 | |
---|
268 | li r0, PPC_IRQ_PIT |
---|
269 | b PROC (_ISR_Handler) |
---|
270 | |
---|
271 | /* FIT interrupt */ |
---|
272 | fit: |
---|
273 | mtsprg0 r0 |
---|
274 | mfsprg2 r0 |
---|
275 | mtmsr r0 |
---|
276 | #if (PPC_ABI == PPC_ABI_POWEROPEN || PPC_ABI == PPC_ABI_GCC27) |
---|
277 | #if (PPC_HAS_FPU) |
---|
278 | stwu r1, -(20*4 + 18*8 + IP_END)(r1) |
---|
279 | #else |
---|
280 | stwu r1, -(20*4 + IP_END)(r1) |
---|
281 | #endif |
---|
282 | #else |
---|
283 | stwu r1, -(IP_END)(r1) |
---|
284 | #endif |
---|
285 | mfsprg0 r0 |
---|
286 | stw r0, IP_0(r1) |
---|
287 | |
---|
288 | li r0, PPC_IRQ_FIT |
---|
289 | b PROC (_ISR_Handler) |
---|
290 | |
---|
291 | /* Watchdog interrupt */ |
---|
292 | watch: |
---|
293 | mtsprg1 r0 |
---|
294 | mfsprg2 r0 |
---|
295 | mtmsr r0 |
---|
296 | #if (PPC_ABI == PPC_ABI_POWEROPEN || PPC_ABI == PPC_ABI_GCC27) |
---|
297 | #if (PPC_HAS_FPU) |
---|
298 | stwu r1, -(20*4 + 18*8 + IP_END)(r1) |
---|
299 | #else |
---|
300 | stwu r1, -(20*4 + IP_END)(r1) |
---|
301 | #endif |
---|
302 | #else |
---|
303 | stwu r1, -(IP_END)(r1) |
---|
304 | #endif |
---|
305 | mfsprg1 r0 |
---|
306 | stw r0, IP_0(r1) |
---|
307 | |
---|
308 | li r0, PPC_IRQ_WATCHDOG |
---|
309 | b PROC (_ISR_HandlerC) |
---|
310 | |
---|
311 | /* Debug exception */ |
---|
312 | debug: |
---|
313 | mtsprg1 r0 |
---|
314 | mfsprg2 r0 |
---|
315 | mtmsr r0 |
---|
316 | #if (PPC_ABI == PPC_ABI_POWEROPEN || PPC_ABI == PPC_ABI_GCC27) |
---|
317 | #if (PPC_HAS_FPU) |
---|
318 | stwu r1, -(20*4 + 18*8 + IP_END)(r1) |
---|
319 | #else |
---|
320 | stwu r1, -(20*4 + IP_END)(r1) |
---|
321 | #endif |
---|
322 | #else |
---|
323 | stwu r1, -(IP_END)(r1) |
---|
324 | #endif |
---|
325 | mfsprg1 r0 |
---|
326 | stw r0, IP_0(r1) |
---|
327 | |
---|
328 | li r0, PPC_IRQ_DEBUG |
---|
329 | b PROC (_ISR_HandlerC) |
---|
330 | |
---|
331 | /* Debug exception */ |
---|
332 | .org debug_vector - file_base |
---|
333 | b debug |
---|