source: rtems/c/src/lib/libcpu/powerpc/new_exception_processing/cpu_asm.S @ 2c033b0b

4.104.114.84.95
Last change on this file since 2c033b0b was 590aba4f, checked in by Joel Sherrill <joel.sherrill@…>, on 10/12/01 at 21:03:53

2001-10-12 Joel Sherrill <joel@…>

  • mpc6xx/clock/c_clock.c, mpc6xx/clock/c_clock.h, mpc8xx/clock/clock.c, mpc8xx/timer/timer.c, new_exception_processing/cpu.c, new_exception_processing/cpu.h, new_exception_processing/cpu_asm.S, old_exception_processing/cpu.c, old_exception_processing/cpu.h, old_exception_processing/cpu_asm.S, old_exception_processing/rtems.S: Fixed typo.
  • Property mode set to 100644
File size: 8.8 KB
Line 
1
2/*  cpu_asm.s   1.1 - 95/12/04
3 *
4 *  This file contains the assembly code for the PowerPC implementation
5 *  of RTEMS.
6 *
7 *  Author:     Andrew Bray <andy@i-cubed.co.uk>
8 *
9 *  COPYRIGHT (c) 1995 by i-cubed ltd.
10 *
11 *  To anyone who acknowledges that this file is provided "AS IS"
12 *  without any express or implied warranty:
13 *      permission to use, copy, modify, and distribute this file
14 *      for any purpose is hereby granted without fee, provided that
15 *      the above copyright notice and this notice appears in all
16 *      copies, and that the name of i-cubed limited not be used in
17 *      advertising or publicity pertaining to distribution of the
18 *      software without specific, written prior permission.
19 *      i-cubed limited makes no representations about the suitability
20 *      of this software for any purpose.
21 *
22 *  Derived from c/src/exec/cpu/no_cpu/cpu_asm.c:
23 *
24 *  COPYRIGHT (c) 1989-1997.
25 *  On-Line Applications Research Corporation (OAR).
26 *
27 *  The license and distribution terms for this file may in
28 *  the file LICENSE in this distribution or at
29 *  http://www.OARcorp.com/rtems/license.html.
30 *
31 *  $Id$
32 */
33
34#include <asm.h>
35
36/*
37 * Offsets for various Contexts
38 */
39        .set    GP_1, 0
40        .set    GP_2, (GP_1 + 4)
41        .set    GP_13, (GP_2 + 4)
42        .set    GP_14, (GP_13 + 4)
43
44        .set    GP_15, (GP_14 + 4)
45        .set    GP_16, (GP_15 + 4)
46        .set    GP_17, (GP_16 + 4)
47        .set    GP_18, (GP_17 + 4)
48
49        .set    GP_19, (GP_18 + 4)
50        .set    GP_20, (GP_19 + 4)
51        .set    GP_21, (GP_20 + 4)
52        .set    GP_22, (GP_21 + 4)
53
54        .set    GP_23, (GP_22 + 4)
55        .set    GP_24, (GP_23 + 4)
56        .set    GP_25, (GP_24 + 4)
57        .set    GP_26, (GP_25 + 4)
58
59        .set    GP_27, (GP_26 + 4)
60        .set    GP_28, (GP_27 + 4)
61        .set    GP_29, (GP_28 + 4)
62        .set    GP_30, (GP_29 + 4)
63
64        .set    GP_31, (GP_30 + 4)
65        .set    GP_CR, (GP_31 + 4)
66        .set    GP_PC, (GP_CR + 4)
67        .set    GP_MSR, (GP_PC + 4)
68
69        .set    FP_0, 0
70        .set    FP_1, (FP_0 + 4)
71        .set    FP_2, (FP_1 + 4)
72        .set    FP_3, (FP_2 + 4)
73        .set    FP_4, (FP_3 + 4)
74        .set    FP_5, (FP_4 + 4)
75        .set    FP_6, (FP_5 + 4)
76        .set    FP_7, (FP_6 + 4)
77        .set    FP_8, (FP_7 + 4)
78        .set    FP_9, (FP_8 + 4)
79        .set    FP_10, (FP_9 + 4)
80        .set    FP_11, (FP_10 + 4)
81        .set    FP_12, (FP_11 + 4)
82        .set    FP_13, (FP_12 + 4)
83        .set    FP_14, (FP_13 + 4)
84        .set    FP_15, (FP_14 + 4)
85        .set    FP_16, (FP_15 + 4)
86        .set    FP_17, (FP_16 + 4)
87        .set    FP_18, (FP_17 + 4)
88        .set    FP_19, (FP_18 + 4)
89        .set    FP_20, (FP_19 + 4)
90        .set    FP_21, (FP_20 + 4)
91        .set    FP_22, (FP_21 + 4)
92        .set    FP_23, (FP_22 + 4)
93        .set    FP_24, (FP_23 + 4)
94        .set    FP_25, (FP_24 + 4)
95        .set    FP_26, (FP_25 + 4)
96        .set    FP_27, (FP_26 + 4)
97        .set    FP_28, (FP_27 + 4)
98        .set    FP_29, (FP_28 + 4)
99        .set    FP_30, (FP_29 + 4)
100        .set    FP_31, (FP_30 + 4)
101        .set    FP_FPSCR, (FP_31 + 4)
102       
103        .set    IP_LINK, 0
104        .set    IP_0, (IP_LINK + 8)
105        .set    IP_2, (IP_0 + 4)
106
107        .set    IP_3, (IP_2 + 4)
108        .set    IP_4, (IP_3 + 4)
109        .set    IP_5, (IP_4 + 4)
110        .set    IP_6, (IP_5 + 4)
111       
112        .set    IP_7, (IP_6 + 4)
113        .set    IP_8, (IP_7 + 4)
114        .set    IP_9, (IP_8 + 4)
115        .set    IP_10, (IP_9 + 4)
116       
117        .set    IP_11, (IP_10 + 4)
118        .set    IP_12, (IP_11 + 4)
119        .set    IP_13, (IP_12 + 4)
120        .set    IP_28, (IP_13 + 4)
121
122        .set    IP_29, (IP_28 + 4)
123        .set    IP_30, (IP_29 + 4)
124        .set    IP_31, (IP_30 + 4)
125        .set    IP_CR, (IP_31 + 4)
126       
127        .set    IP_CTR, (IP_CR + 4)
128        .set    IP_XER, (IP_CTR + 4)
129        .set    IP_LR, (IP_XER + 4)
130        .set    IP_PC, (IP_LR + 4)
131       
132        .set    IP_MSR, (IP_PC + 4)
133        .set    IP_END, (IP_MSR + 16)
134       
135        BEGIN_CODE
136/*
137 *  _CPU_Context_save_fp_context
138 *
139 *  This routine is responsible for saving the FP context
140 *  at *fp_context_ptr.  If the point to load the FP context
141 *  from is changed then the pointer is modified by this routine.
142 *
143 *  Sometimes a macro implementation of this is in cpu.h which dereferences
144 *  the ** and a similarly named routine in this file is passed something
145 *  like a (Context_Control_fp *).  The general rule on making this decision
146 *  is to avoid writing assembly language.
147 */
148
149        ALIGN (PPC_CACHE_ALIGNMENT, PPC_CACHE_ALIGN_POWER)
150        PUBLIC_PROC (_CPU_Context_save_fp)
151PROC (_CPU_Context_save_fp):
152#if (PPC_HAS_FPU == 1)
153        lwz     r3, 0(r3)
154        stfs    f0, FP_0(r3)
155        stfs    f1, FP_1(r3)
156        stfs    f2, FP_2(r3)
157        stfs    f3, FP_3(r3)
158        stfs    f4, FP_4(r3)
159        stfs    f5, FP_5(r3)
160        stfs    f6, FP_6(r3)
161        stfs    f7, FP_7(r3)
162        stfs    f8, FP_8(r3)
163        stfs    f9, FP_9(r3)
164        stfs    f10, FP_10(r3)
165        stfs    f11, FP_11(r3)
166        stfs    f12, FP_12(r3)
167        stfs    f13, FP_13(r3)
168        stfs    f14, FP_14(r3)
169        stfs    f15, FP_15(r3)
170        stfs    f16, FP_16(r3)
171        stfs    f17, FP_17(r3)
172        stfs    f18, FP_18(r3)
173        stfs    f19, FP_19(r3)
174        stfs    f20, FP_20(r3)
175        stfs    f21, FP_21(r3)
176        stfs    f22, FP_22(r3)
177        stfs    f23, FP_23(r3)
178        stfs    f24, FP_24(r3)
179        stfs    f25, FP_25(r3)
180        stfs    f26, FP_26(r3)
181        stfs    f27, FP_27(r3)
182        stfs    f28, FP_28(r3)
183        stfs    f29, FP_29(r3)
184        stfs    f30, FP_30(r3)
185        stfs    f31, FP_31(r3)
186        mffs    f2
187        stfs    f2, FP_FPSCR(r3)
188#endif
189        blr
190
191/*
192 *  _CPU_Context_restore_fp_context
193 *
194 *  This routine is responsible for restoring the FP context
195 *  at *fp_context_ptr.  If the point to load the FP context
196 *  from is changed then the pointer is modified by this routine.
197 *
198 *  Sometimes a macro implementation of this is in cpu.h which dereferences
199 *  the ** and a similarly named routine in this file is passed something
200 *  like a (Context_Control_fp *).  The general rule on making this decision
201 *  is to avoid writing assembly language.
202 */
203
204        ALIGN (PPC_CACHE_ALIGNMENT, PPC_CACHE_ALIGN_POWER)
205        PUBLIC_PROC (_CPU_Context_restore_fp)
206PROC (_CPU_Context_restore_fp):
207#if (PPC_HAS_FPU == 1)
208        lwz     r3, 0(r3)
209        lfs     f2, FP_FPSCR(r3)
210        mtfsf   255, f2
211        lfs     f0, FP_0(r3)
212        lfs     f1, FP_1(r3)
213        lfs     f2, FP_2(r3)
214        lfs     f3, FP_3(r3)
215        lfs     f4, FP_4(r3)
216        lfs     f5, FP_5(r3)
217        lfs     f6, FP_6(r3)
218        lfs     f7, FP_7(r3)
219        lfs     f8, FP_8(r3)
220        lfs     f9, FP_9(r3)
221        lfs     f10, FP_10(r3)
222        lfs     f11, FP_11(r3)
223        lfs     f12, FP_12(r3)
224        lfs     f13, FP_13(r3)
225        lfs     f14, FP_14(r3)
226        lfs     f15, FP_15(r3)
227        lfs     f16, FP_16(r3)
228        lfs     f17, FP_17(r3)
229        lfs     f18, FP_18(r3)
230        lfs     f19, FP_19(r3)
231        lfs     f20, FP_20(r3)
232        lfs     f21, FP_21(r3)
233        lfs     f22, FP_22(r3)
234        lfs     f23, FP_23(r3)
235        lfs     f24, FP_24(r3)
236        lfs     f25, FP_25(r3)
237        lfs     f26, FP_26(r3)
238        lfs     f27, FP_27(r3)
239        lfs     f28, FP_28(r3)
240        lfs     f29, FP_29(r3)
241        lfs     f30, FP_30(r3)
242        lfs     f31, FP_31(r3)
243#endif
244        blr
245
246
247/*  _CPU_Context_switch
248 *
249 *  This routine performs a normal non-FP context switch.
250 */
251        ALIGN (PPC_CACHE_ALIGNMENT, PPC_CACHE_ALIGN_POWER)
252        PUBLIC_PROC (_CPU_Context_switch)
253PROC (_CPU_Context_switch):
254        sync
255        isync
256        /* This assumes that all the registers are in the given order */
257        li      r5, 32
258        addi    r3,r3,-4
259#if ( PPC_USE_DATA_CACHE )
260        dcbz    r5, r3
261#endif
262        stw     r1, GP_1+4(r3)
263        stw     r2, GP_2+4(r3)
264#if (PPC_USE_MULTIPLE == 1)
265        addi    r3, r3, GP_18+4
266#if ( PPC_USE_DATA_CACHE )
267        dcbz    r5, r3
268#endif
269        stmw    r13, GP_13-GP_18(r3)
270#else
271        stw     r13, GP_13+4(r3)
272        stw     r14, GP_14+4(r3)
273        stw     r15, GP_15+4(r3)
274        stw     r16, GP_16+4(r3)
275        stw     r17, GP_17+4(r3)
276        stwu    r18, GP_18+4(r3)
277#if ( PPC_USE_DATA_CACHE )
278        dcbz    r5, r3
279#endif
280        stw     r19, GP_19-GP_18(r3)
281        stw     r20, GP_20-GP_18(r3)
282        stw     r21, GP_21-GP_18(r3)
283        stw     r22, GP_22-GP_18(r3)
284        stw     r23, GP_23-GP_18(r3)
285        stw     r24, GP_24-GP_18(r3)
286        stw     r25, GP_25-GP_18(r3)
287        stw     r26, GP_26-GP_18(r3)
288        stw     r27, GP_27-GP_18(r3)
289        stw     r28, GP_28-GP_18(r3)
290        stw     r29, GP_29-GP_18(r3)
291        stw     r30, GP_30-GP_18(r3)
292        stw     r31, GP_31-GP_18(r3)
293#endif
294#if ( PPC_USE_DATA_CACHE )
295        dcbt    r0, r4
296#endif
297        mfcr    r6
298        stw     r6, GP_CR-GP_18(r3)
299        mflr    r7
300        stw     r7, GP_PC-GP_18(r3)
301        mfmsr   r8
302        stw     r8, GP_MSR-GP_18(r3)
303
304#if ( PPC_USE_DATA_CACHE )
305        dcbt    r5, r4
306#endif
307        lwz     r1, GP_1(r4)
308        lwz     r2, GP_2(r4)
309#if (PPC_USE_MULTIPLE == 1)
310        addi    r4, r4, GP_19
311#if ( PPC_USE_DATA_CACHE )
312        dcbt    r5, r4
313#endif
314        lmw     r13, GP_13-GP_19(r4)
315#else
316        lwz     r13, GP_13(r4)
317        lwz     r14, GP_14(r4)
318        lwz     r15, GP_15(r4)
319        lwz     r16, GP_16(r4)
320        lwz     r17, GP_17(r4)
321        lwz     r18, GP_18(r4)
322        lwzu    r19, GP_19(r4)
323#if ( PPC_USE_DATA_CACHE )
324        dcbt    r5, r4
325#endif
326        lwz     r20, GP_20-GP_19(r4)
327        lwz     r21, GP_21-GP_19(r4)
328        lwz     r22, GP_22-GP_19(r4)
329        lwz     r23, GP_23-GP_19(r4)
330        lwz     r24, GP_24-GP_19(r4)
331        lwz     r25, GP_25-GP_19(r4)
332        lwz     r26, GP_26-GP_19(r4)
333        lwz     r27, GP_27-GP_19(r4)
334        lwz     r28, GP_28-GP_19(r4)
335        lwz     r29, GP_29-GP_19(r4)
336        lwz     r30, GP_30-GP_19(r4)
337        lwz     r31, GP_31-GP_19(r4)
338#endif
339        lwz     r6, GP_CR-GP_19(r4)
340        lwz     r7, GP_PC-GP_19(r4)
341        lwz     r8, GP_MSR-GP_19(r4)
342        mtcrf   255, r6
343        mtlr    r7
344        mtmsr   r8
345
346        blr
347
348/*
349 *  _CPU_Context_restore
350 *
351 *  This routine is generallu used only to restart self in an
352 *  efficient manner.  It may simply be a label in _CPU_Context_switch.
353 *
354 *  NOTE: May be unnecessary to reload some registers.
355 */
356/*
357 * ACB: Don't worry about cache optimisation here - this is not THAT critical.
358 */
359        ALIGN (PPC_CACHE_ALIGNMENT, PPC_CACHE_ALIGN_POWER)
360        PUBLIC_PROC (_CPU_Context_restore)
361PROC (_CPU_Context_restore):
362        lwz     r5, GP_CR(r3)
363        lwz     r6, GP_PC(r3)
364        lwz     r7, GP_MSR(r3)
365        mtcrf   255, r5
366        mtlr    r6
367        mtmsr   r7
368        lwz     r1, GP_1(r3)
369        lwz     r2, GP_2(r3)
370#if (PPC_USE_MULTIPLE == 1)
371        lmw     r13, GP_13(r3)
372#else
373        lwz     r13, GP_13(r3)
374        lwz     r14, GP_14(r3)
375        lwz     r15, GP_15(r3)
376        lwz     r16, GP_16(r3)
377        lwz     r17, GP_17(r3)
378        lwz     r18, GP_18(r3)
379        lwz     r19, GP_19(r3)
380        lwz     r20, GP_20(r3)
381        lwz     r21, GP_21(r3)
382        lwz     r22, GP_22(r3)
383        lwz     r23, GP_23(r3)
384        lwz     r24, GP_24(r3)
385        lwz     r25, GP_25(r3)
386        lwz     r26, GP_26(r3)
387        lwz     r27, GP_27(r3)
388        lwz     r28, GP_28(r3)
389        lwz     r29, GP_29(r3)
390        lwz     r30, GP_30(r3)
391        lwz     r31, GP_31(r3)
392#endif
393
394        blr
395
Note: See TracBrowser for help on using the repository browser.