source: rtems/c/src/lib/libcpu/powerpc/new-exceptions/cpu_asm.S @ f7d0f5e

5
Last change on this file since f7d0f5e was 32b4a0c, checked in by Sebastian Huber <sebastian.huber@…>, on 06/09/17 at 05:25:02

Simplify TLS support in context switch

There is no need to save the thread pointer in _CPU_Context_switch()
since it is a thread invariant. It is initialized once in
_CPU_Context_Initialize().

  • Property mode set to 100644
File size: 15.0 KB
Line 
1/*  cpu_asm.s   1.1 - 95/12/04
2 *
3 *  This file contains the assembly code for the PowerPC implementation
4 *  of RTEMS.
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 *  Derived from c/src/exec/cpu/no_cpu/cpu_asm.c:
22 *
23 *  COPYRIGHT (c) 1989-1997.
24 *  On-Line Applications Research Corporation (OAR).
25 *
26 *  Copyright (c) 2011, 2016 embedded brains GmbH
27 *
28 *  The license and distribution terms for this file may in
29 *  the file LICENSE in this distribution or at
30 *  http://www.rtems.org/license/LICENSE.
31 */
32
33#include <rtems/asm.h>
34#include <rtems/powerpc/powerpc.h>
35#include <rtems/score/percpu.h>
36#include <libcpu/powerpc-utility.h>
37#include <bspopts.h>
38
39#ifdef BSP_USE_DATA_CACHE_BLOCK_TOUCH
40  #define DATA_CACHE_TOUCH(rega, regb) \
41        dcbt rega, regb
42#else
43  #define DATA_CACHE_TOUCH(rega, regb)
44#endif
45
46#if BSP_DATA_CACHE_ENABLED && PPC_DEFAULT_CACHE_LINE_SIZE == 32
47  #define DATA_CACHE_ZERO_AND_TOUCH(reg, offset) \
48        li reg, offset; dcbz reg, r3; DATA_CACHE_TOUCH(reg, r4)
49#else
50  #define DATA_CACHE_ZERO_AND_TOUCH(reg, offset)
51#endif
52
53#define PPC_CONTEXT_CACHE_LINE_0 (1 * PPC_DEFAULT_CACHE_LINE_SIZE)
54#define PPC_CONTEXT_CACHE_LINE_1 (2 * PPC_DEFAULT_CACHE_LINE_SIZE)
55#define PPC_CONTEXT_CACHE_LINE_2 (3 * PPC_DEFAULT_CACHE_LINE_SIZE)
56#define PPC_CONTEXT_CACHE_LINE_3 (4 * PPC_DEFAULT_CACHE_LINE_SIZE)
57#define PPC_CONTEXT_CACHE_LINE_4 (5 * PPC_DEFAULT_CACHE_LINE_SIZE)
58#define PPC_CONTEXT_CACHE_LINE_5 (6 * PPC_DEFAULT_CACHE_LINE_SIZE)
59
60        BEGIN_CODE
61
62#if PPC_HAS_FPU == 1
63
64/*
65 * Offsets for Context_Control_fp
66 */
67
68#if (PPC_HAS_DOUBLE==1)
69        .set    FP_SIZE,        8
70#define LDF     lfd
71#define STF     stfd
72#else
73        .set    FP_SIZE,        4
74#define LDF     lfs
75#define STF     stfs
76#endif
77
78        .set    FP_0, 0
79        .set    FP_1, (FP_0 + FP_SIZE)
80        .set    FP_2, (FP_1 + FP_SIZE)
81        .set    FP_3, (FP_2 + FP_SIZE)
82        .set    FP_4, (FP_3 + FP_SIZE)
83        .set    FP_5, (FP_4 + FP_SIZE)
84        .set    FP_6, (FP_5 + FP_SIZE)
85        .set    FP_7, (FP_6 + FP_SIZE)
86        .set    FP_8, (FP_7 + FP_SIZE)
87        .set    FP_9, (FP_8 + FP_SIZE)
88        .set    FP_10, (FP_9 + FP_SIZE)
89        .set    FP_11, (FP_10 + FP_SIZE)
90        .set    FP_12, (FP_11 + FP_SIZE)
91        .set    FP_13, (FP_12 + FP_SIZE)
92        .set    FP_14, (FP_13 + FP_SIZE)
93        .set    FP_15, (FP_14 + FP_SIZE)
94        .set    FP_16, (FP_15 + FP_SIZE)
95        .set    FP_17, (FP_16 + FP_SIZE)
96        .set    FP_18, (FP_17 + FP_SIZE)
97        .set    FP_19, (FP_18 + FP_SIZE)
98        .set    FP_20, (FP_19 + FP_SIZE)
99        .set    FP_21, (FP_20 + FP_SIZE)
100        .set    FP_22, (FP_21 + FP_SIZE)
101        .set    FP_23, (FP_22 + FP_SIZE)
102        .set    FP_24, (FP_23 + FP_SIZE)
103        .set    FP_25, (FP_24 + FP_SIZE)
104        .set    FP_26, (FP_25 + FP_SIZE)
105        .set    FP_27, (FP_26 + FP_SIZE)
106        .set    FP_28, (FP_27 + FP_SIZE)
107        .set    FP_29, (FP_28 + FP_SIZE)
108        .set    FP_30, (FP_29 + FP_SIZE)
109        .set    FP_31, (FP_30 + FP_SIZE)
110        .set    FP_FPSCR, (FP_31 + FP_SIZE)
111
112/*
113 *  _CPU_Context_save_fp_context
114 *
115 *  This routine is responsible for saving the FP context
116 *  at *fp_context_ptr.  If the point to load the FP context
117 *  from is changed then the pointer is modified by this routine.
118 *
119 *  Sometimes a macro implementation of this is in cpu.h which dereferences
120 *  the ** and a similarly named routine in this file is passed something
121 *  like a (Context_Control_fp *).  The general rule on making this decision
122 *  is to avoid writing assembly language.
123 */
124
125        ALIGN (PPC_CACHE_ALIGNMENT, PPC_CACHE_ALIGN_POWER)
126        PUBLIC_PROC (_CPU_Context_save_fp)
127PROC (_CPU_Context_save_fp):
128/* A FP context switch may occur in an ISR or exception handler when the FPU is not
129 * available. Therefore, we must explicitely enable it here!
130 */
131        mfmsr   r4
132        andi.   r5,r4,MSR_FP
133        bne     1f
134        ori     r5,r4,MSR_FP
135        mtmsr   r5
136        isync
1371:
138        lwz     r3, 0(r3)
139        STF     f0, FP_0(r3)
140        STF     f1, FP_1(r3)
141        STF     f2, FP_2(r3)
142        STF     f3, FP_3(r3)
143        STF     f4, FP_4(r3)
144        STF     f5, FP_5(r3)
145        STF     f6, FP_6(r3)
146        STF     f7, FP_7(r3)
147        STF     f8, FP_8(r3)
148        STF     f9, FP_9(r3)
149        STF     f10, FP_10(r3)
150        STF     f11, FP_11(r3)
151        STF     f12, FP_12(r3)
152        STF     f13, FP_13(r3)
153        STF     f14, FP_14(r3)
154        STF     f15, FP_15(r3)
155        STF     f16, FP_16(r3)
156        STF     f17, FP_17(r3)
157        STF     f18, FP_18(r3)
158        STF     f19, FP_19(r3)
159        STF     f20, FP_20(r3)
160        STF     f21, FP_21(r3)
161        STF     f22, FP_22(r3)
162        STF     f23, FP_23(r3)
163        STF     f24, FP_24(r3)
164        STF     f25, FP_25(r3)
165        STF     f26, FP_26(r3)
166        STF     f27, FP_27(r3)
167        STF     f28, FP_28(r3)
168        STF     f29, FP_29(r3)
169        STF     f30, FP_30(r3)
170        STF     f31, FP_31(r3)
171        mffs    f2
172        STF     f2, FP_FPSCR(r3)
173        bne     1f
174        mtmsr   r4
175        isync
1761:
177        blr
178
179/*
180 *  _CPU_Context_restore_fp_context
181 *
182 *  This routine is responsible for restoring the FP context
183 *  at *fp_context_ptr.  If the point to load the FP context
184 *  from is changed then the pointer is modified by this routine.
185 *
186 *  Sometimes a macro implementation of this is in cpu.h which dereferences
187 *  the ** and a similarly named routine in this file is passed something
188 *  like a (Context_Control_fp *).  The general rule on making this decision
189 *  is to avoid writing assembly language.
190 */
191
192        ALIGN (PPC_CACHE_ALIGNMENT, PPC_CACHE_ALIGN_POWER)
193        PUBLIC_PROC (_CPU_Context_restore_fp)
194PROC (_CPU_Context_restore_fp):
195        lwz     r3, 0(r3)
196/* A FP context switch may occur in an ISR or exception handler when the FPU is not
197 * available. Therefore, we must explicitely enable it here!
198 */
199        mfmsr   r4
200        andi.   r5,r4,MSR_FP
201        bne     1f
202        ori     r5,r4,MSR_FP
203        mtmsr   r5
204        isync
2051:
206        LDF     f2, FP_FPSCR(r3)
207        mtfsf   255, f2
208        LDF     f0, FP_0(r3)
209        LDF     f1, FP_1(r3)
210        LDF     f2, FP_2(r3)
211        LDF     f3, FP_3(r3)
212        LDF     f4, FP_4(r3)
213        LDF     f5, FP_5(r3)
214        LDF     f6, FP_6(r3)
215        LDF     f7, FP_7(r3)
216        LDF     f8, FP_8(r3)
217        LDF     f9, FP_9(r3)
218        LDF     f10, FP_10(r3)
219        LDF     f11, FP_11(r3)
220        LDF     f12, FP_12(r3)
221        LDF     f13, FP_13(r3)
222        LDF     f14, FP_14(r3)
223        LDF     f15, FP_15(r3)
224        LDF     f16, FP_16(r3)
225        LDF     f17, FP_17(r3)
226        LDF     f18, FP_18(r3)
227        LDF     f19, FP_19(r3)
228        LDF     f20, FP_20(r3)
229        LDF     f21, FP_21(r3)
230        LDF     f22, FP_22(r3)
231        LDF     f23, FP_23(r3)
232        LDF     f24, FP_24(r3)
233        LDF     f25, FP_25(r3)
234        LDF     f26, FP_26(r3)
235        LDF     f27, FP_27(r3)
236        LDF     f28, FP_28(r3)
237        LDF     f29, FP_29(r3)
238        LDF     f30, FP_30(r3)
239        LDF     f31, FP_31(r3)
240        bne     1f
241        mtmsr   r4
242        isync
2431:
244        blr
245#endif /* PPC_HAS_FPU == 1 */
246
247        ALIGN (PPC_CACHE_ALIGNMENT, PPC_CACHE_ALIGN_POWER)
248        PUBLIC_PROC (_CPU_Context_switch)
249PROC (_CPU_Context_switch):
250
251#ifdef BSP_USE_SYNC_IN_CONTEXT_SWITCH
252        sync
253        isync
254#endif
255
256        /* Align to a cache line */
257        clrrwi  r3, r3, PPC_DEFAULT_CACHE_LINE_POWER
258        clrrwi  r5, r4, PPC_DEFAULT_CACHE_LINE_POWER
259
260        DATA_CACHE_ZERO_AND_TOUCH(r10, PPC_CONTEXT_CACHE_LINE_0)
261
262#if PPC_CONTEXT_CACHE_LINE_2 <= PPC_CONTEXT_VOLATILE_SIZE
263        DATA_CACHE_ZERO_AND_TOUCH(r11, PPC_CONTEXT_CACHE_LINE_1)
264#endif
265
266        /* Save context to r3 */
267
268        GET_SELF_CPU_CONTROL    r12
269        mfmsr   r6
270        mflr    r7
271        mfcr    r8
272        lwz     r11, PER_CPU_ISR_DISPATCH_DISABLE(r12)
273
274        /*
275         * We have to clear the reservation of the executing thread.  See also
276         * Book E section 6.1.6.2 "Atomic Update Primitives".  Recent GCC
277         * versions use atomic operations in the C++ library for example.  On
278         * SMP configurations the reservation is cleared later during the
279         * context switch.
280         */
281#if PPC_CONTEXT_OFFSET_GPR1 != PPC_CONTEXT_CACHE_LINE_0 \
282  || !BSP_DATA_CACHE_ENABLED \
283  || PPC_DEFAULT_CACHE_LINE_SIZE != 32
284        li      r10, PPC_CONTEXT_OFFSET_GPR1
285#endif
286#ifndef RTEMS_SMP
287        stwcx.  r1, r3, r10
288#endif
289
290        stw     r1, PPC_CONTEXT_OFFSET_GPR1(r3)
291        stw     r6, PPC_CONTEXT_OFFSET_MSR(r3)
292        stw     r7, PPC_CONTEXT_OFFSET_LR(r3)
293        stw     r8, PPC_CONTEXT_OFFSET_CR(r3)
294        PPC_GPR_STORE   r14, PPC_CONTEXT_OFFSET_GPR14(r3)
295        PPC_GPR_STORE   r15, PPC_CONTEXT_OFFSET_GPR15(r3)
296
297#if PPC_CONTEXT_OFFSET_GPR20 == PPC_CONTEXT_CACHE_LINE_2
298        DATA_CACHE_ZERO_AND_TOUCH(r10, PPC_CONTEXT_CACHE_LINE_2)
299#endif
300
301        PPC_GPR_STORE   r16, PPC_CONTEXT_OFFSET_GPR16(r3)
302        PPC_GPR_STORE   r17, PPC_CONTEXT_OFFSET_GPR17(r3)
303
304#if PPC_CONTEXT_OFFSET_GPR26 == PPC_CONTEXT_CACHE_LINE_2
305        DATA_CACHE_ZERO_AND_TOUCH(r10, PPC_CONTEXT_CACHE_LINE_2)
306#endif
307
308        PPC_GPR_STORE   r18, PPC_CONTEXT_OFFSET_GPR18(r3)
309        PPC_GPR_STORE   r19, PPC_CONTEXT_OFFSET_GPR19(r3)
310
311#if PPC_CONTEXT_OFFSET_GPR24 == PPC_CONTEXT_CACHE_LINE_3
312        DATA_CACHE_ZERO_AND_TOUCH(r10, PPC_CONTEXT_CACHE_LINE_3)
313#endif
314
315        PPC_GPR_STORE   r20, PPC_CONTEXT_OFFSET_GPR20(r3)
316        PPC_GPR_STORE   r21, PPC_CONTEXT_OFFSET_GPR21(r3)
317        PPC_GPR_STORE   r22, PPC_CONTEXT_OFFSET_GPR22(r3)
318        PPC_GPR_STORE   r23, PPC_CONTEXT_OFFSET_GPR23(r3)
319
320#if PPC_CONTEXT_OFFSET_GPR28 == PPC_CONTEXT_CACHE_LINE_4
321        DATA_CACHE_ZERO_AND_TOUCH(r10, PPC_CONTEXT_CACHE_LINE_4)
322#endif
323
324        PPC_GPR_STORE   r24, PPC_CONTEXT_OFFSET_GPR24(r3)
325        PPC_GPR_STORE   r25, PPC_CONTEXT_OFFSET_GPR25(r3)
326
327#if PPC_CONTEXT_OFFSET_V22 == PPC_CONTEXT_CACHE_LINE_2
328        DATA_CACHE_ZERO_AND_TOUCH(r10, PPC_CONTEXT_CACHE_LINE_2)
329#endif
330
331        PPC_GPR_STORE   r26, PPC_CONTEXT_OFFSET_GPR26(r3)
332        PPC_GPR_STORE   r27, PPC_CONTEXT_OFFSET_GPR27(r3)
333
334        PPC_GPR_STORE   r28, PPC_CONTEXT_OFFSET_GPR28(r3)
335        PPC_GPR_STORE   r29, PPC_CONTEXT_OFFSET_GPR29(r3)
336        PPC_GPR_STORE   r30, PPC_CONTEXT_OFFSET_GPR30(r3)
337        PPC_GPR_STORE   r31, PPC_CONTEXT_OFFSET_GPR31(r3)
338
339        stw     r11, PPC_CONTEXT_OFFSET_ISR_DISPATCH_DISABLE(r3)
340
341#ifdef PPC_MULTILIB_ALTIVEC
342        li      r9, PPC_CONTEXT_OFFSET_V20
343        stvx    v20, r3, r9
344        li      r9, PPC_CONTEXT_OFFSET_V21
345        stvx    v21, r3, r9
346
347#if PPC_CONTEXT_OFFSET_V26 == PPC_CONTEXT_CACHE_LINE_3
348        DATA_CACHE_ZERO_AND_TOUCH(r10, PPC_CONTEXT_CACHE_LINE_3)
349#endif
350
351        li      r9, PPC_CONTEXT_OFFSET_V22
352        stvx    v22, r3, r9
353        li      r9, PPC_CONTEXT_OFFSET_V23
354        stvx    v23, r3, r9
355        li      r9, PPC_CONTEXT_OFFSET_V24
356        stvx    v24, r3, r9
357        li      r9, PPC_CONTEXT_OFFSET_V25
358        stvx    v25, r3, r9
359
360#if PPC_CONTEXT_OFFSET_V30 == PPC_CONTEXT_CACHE_LINE_4
361        DATA_CACHE_ZERO_AND_TOUCH(r10, PPC_CONTEXT_CACHE_LINE_4)
362#endif
363
364        li      r9, PPC_CONTEXT_OFFSET_V26
365        stvx    v26, r3, r9
366        li      r9, PPC_CONTEXT_OFFSET_V27
367        stvx    v27, r3, r9
368        li      r9, PPC_CONTEXT_OFFSET_V28
369        stvx    v28, r3, r9
370        li      r9, PPC_CONTEXT_OFFSET_V29
371        stvx    v29, r3, r9
372
373#if PPC_CONTEXT_OFFSET_F17 == PPC_CONTEXT_CACHE_LINE_5
374        DATA_CACHE_ZERO_AND_TOUCH(r10, PPC_CONTEXT_CACHE_LINE_5)
375#endif
376
377        li      r9, PPC_CONTEXT_OFFSET_V30
378        stvx    v30, r3, r9
379        li      r9, PPC_CONTEXT_OFFSET_V31
380        stvx    v31, r3, r9
381        mfvrsave        r9
382        stw     r9, PPC_CONTEXT_OFFSET_VRSAVE(r3)
383#endif
384
385#ifdef PPC_MULTILIB_FPU
386        stfd    f14, PPC_CONTEXT_OFFSET_F14(r3)
387        stfd    f15, PPC_CONTEXT_OFFSET_F15(r3)
388        stfd    f16, PPC_CONTEXT_OFFSET_F16(r3)
389        stfd    f17, PPC_CONTEXT_OFFSET_F17(r3)
390        stfd    f18, PPC_CONTEXT_OFFSET_F18(r3)
391        stfd    f19, PPC_CONTEXT_OFFSET_F19(r3)
392        stfd    f20, PPC_CONTEXT_OFFSET_F20(r3)
393        stfd    f21, PPC_CONTEXT_OFFSET_F21(r3)
394        stfd    f22, PPC_CONTEXT_OFFSET_F22(r3)
395        stfd    f23, PPC_CONTEXT_OFFSET_F23(r3)
396        stfd    f24, PPC_CONTEXT_OFFSET_F24(r3)
397        stfd    f25, PPC_CONTEXT_OFFSET_F25(r3)
398        stfd    f26, PPC_CONTEXT_OFFSET_F26(r3)
399        stfd    f27, PPC_CONTEXT_OFFSET_F27(r3)
400        stfd    f28, PPC_CONTEXT_OFFSET_F28(r3)
401        stfd    f29, PPC_CONTEXT_OFFSET_F29(r3)
402        stfd    f30, PPC_CONTEXT_OFFSET_F30(r3)
403        stfd    f31, PPC_CONTEXT_OFFSET_F31(r3)
404#endif
405
406#ifdef RTEMS_SMP
407        /*
408         * The executing thread no longer executes on this processor.  Switch
409         * the stack to the temporary interrupt stack of this processor.  Mark
410         * the context of the executing thread as not executing.
411         */
412        msync
413
414        addi    r1, r12, PER_CPU_INTERRUPT_FRAME_AREA + CPU_INTERRUPT_FRAME_SIZE
415        li      r6, 0
416        stw     r6, PPC_CONTEXT_OFFSET_IS_EXECUTING(r3)
417
418.Lcheck_is_executing:
419
420        /* Check the is executing indicator of the heir context */
421        addi    r6, r5, PPC_CONTEXT_OFFSET_IS_EXECUTING
422        lwarx   r7, r0, r6
423        cmpwi   r7, 0
424        bne     .Lget_potential_new_heir
425
426        /* Try to update the is executing indicator of the heir context */
427        li      r7, 1
428        stwcx.  r7, r0, r6
429        bne     .Lget_potential_new_heir
430        isync
431#endif
432
433        /* Restore context from r5 */
434restore_context:
435
436#if defined(__ALTIVEC__) && !defined(PPC_MULTILIB_ALTIVEC)
437        mr      r4, r5
438        .extern _CPU_Context_switch_altivec
439        bl      _CPU_Context_switch_altivec
440#endif
441
442        lwz     r1, PPC_CONTEXT_OFFSET_GPR1(r5)
443        lwz     r6, PPC_CONTEXT_OFFSET_MSR(r5)
444        lwz     r7, PPC_CONTEXT_OFFSET_LR(r5)
445        lwz     r8, PPC_CONTEXT_OFFSET_CR(r5)
446
447        PPC_GPR_LOAD    r14, PPC_CONTEXT_OFFSET_GPR14(r5)
448        PPC_GPR_LOAD    r15, PPC_CONTEXT_OFFSET_GPR15(r5)
449
450        DATA_CACHE_TOUCH(r0, r1)
451
452        PPC_GPR_LOAD    r16, PPC_CONTEXT_OFFSET_GPR16(r5)
453        PPC_GPR_LOAD    r17, PPC_CONTEXT_OFFSET_GPR17(r5)
454        PPC_GPR_LOAD    r18, PPC_CONTEXT_OFFSET_GPR18(r5)
455        PPC_GPR_LOAD    r19, PPC_CONTEXT_OFFSET_GPR19(r5)
456
457        PPC_GPR_LOAD    r20, PPC_CONTEXT_OFFSET_GPR20(r5)
458        PPC_GPR_LOAD    r21, PPC_CONTEXT_OFFSET_GPR21(r5)
459        PPC_GPR_LOAD    r22, PPC_CONTEXT_OFFSET_GPR22(r5)
460        PPC_GPR_LOAD    r23, PPC_CONTEXT_OFFSET_GPR23(r5)
461
462        PPC_GPR_LOAD    r24, PPC_CONTEXT_OFFSET_GPR24(r5)
463        PPC_GPR_LOAD    r25, PPC_CONTEXT_OFFSET_GPR25(r5)
464        PPC_GPR_LOAD    r26, PPC_CONTEXT_OFFSET_GPR26(r5)
465        PPC_GPR_LOAD    r27, PPC_CONTEXT_OFFSET_GPR27(r5)
466
467        PPC_GPR_LOAD    r28, PPC_CONTEXT_OFFSET_GPR28(r5)
468        PPC_GPR_LOAD    r29, PPC_CONTEXT_OFFSET_GPR29(r5)
469        PPC_GPR_LOAD    r30, PPC_CONTEXT_OFFSET_GPR30(r5)
470        PPC_GPR_LOAD    r31, PPC_CONTEXT_OFFSET_GPR31(r5)
471
472        lwz     r2, PPC_CONTEXT_OFFSET_GPR2(r5)
473        lwz     r11, PPC_CONTEXT_OFFSET_ISR_DISPATCH_DISABLE(r5)
474
475#ifdef PPC_MULTILIB_ALTIVEC
476        li      r9, PPC_CONTEXT_OFFSET_V20
477        lvx     v20, r5, r9
478        li      r9, PPC_CONTEXT_OFFSET_V21
479        lvx     v21, r5, r9
480        li      r9, PPC_CONTEXT_OFFSET_V22
481        lvx     v22, r5, r9
482        li      r9, PPC_CONTEXT_OFFSET_V23
483        lvx     v23, r5, r9
484        li      r9, PPC_CONTEXT_OFFSET_V24
485        lvx     v24, r5, r9
486        li      r9, PPC_CONTEXT_OFFSET_V25
487        lvx     v25, r5, r9
488        li      r9, PPC_CONTEXT_OFFSET_V26
489        lvx     v26, r5, r9
490        li      r9, PPC_CONTEXT_OFFSET_V27
491        lvx     v27, r5, r9
492        li      r9, PPC_CONTEXT_OFFSET_V28
493        lvx     v28, r5, r9
494        li      r9, PPC_CONTEXT_OFFSET_V29
495        lvx     v29, r5, r9
496        li      r9, PPC_CONTEXT_OFFSET_V30
497        lvx     v30, r5, r9
498        li      r9, PPC_CONTEXT_OFFSET_V31
499        lvx     v31, r5, r9
500        lwz     r9, PPC_CONTEXT_OFFSET_VRSAVE(r5)
501        mtvrsave        r9
502#endif
503
504#ifdef PPC_MULTILIB_FPU
505        lfd     f14, PPC_CONTEXT_OFFSET_F14(r5)
506        lfd     f15, PPC_CONTEXT_OFFSET_F15(r5)
507        lfd     f16, PPC_CONTEXT_OFFSET_F16(r5)
508        lfd     f17, PPC_CONTEXT_OFFSET_F17(r5)
509        lfd     f18, PPC_CONTEXT_OFFSET_F18(r5)
510        lfd     f19, PPC_CONTEXT_OFFSET_F19(r5)
511        lfd     f20, PPC_CONTEXT_OFFSET_F20(r5)
512        lfd     f21, PPC_CONTEXT_OFFSET_F21(r5)
513        lfd     f22, PPC_CONTEXT_OFFSET_F22(r5)
514        lfd     f23, PPC_CONTEXT_OFFSET_F23(r5)
515        lfd     f24, PPC_CONTEXT_OFFSET_F24(r5)
516        lfd     f25, PPC_CONTEXT_OFFSET_F25(r5)
517        lfd     f26, PPC_CONTEXT_OFFSET_F26(r5)
518        lfd     f27, PPC_CONTEXT_OFFSET_F27(r5)
519        lfd     f28, PPC_CONTEXT_OFFSET_F28(r5)
520        lfd     f29, PPC_CONTEXT_OFFSET_F29(r5)
521        lfd     f30, PPC_CONTEXT_OFFSET_F30(r5)
522        lfd     f31, PPC_CONTEXT_OFFSET_F31(r5)
523#endif
524
525        mtcr    r8
526        mtlr    r7
527        mtmsr   r6
528        stw     r11, PER_CPU_ISR_DISPATCH_DISABLE(r12)
529
530#ifdef BSP_USE_SYNC_IN_CONTEXT_SWITCH
531        isync
532#endif
533
534        blr
535
536        PUBLIC_PROC (_CPU_Context_restore)
537PROC (_CPU_Context_restore):
538        /* Align to a cache line */
539        clrrwi  r5, r3, PPC_DEFAULT_CACHE_LINE_POWER
540
541        GET_SELF_CPU_CONTROL    r12
542
543#if defined(__ALTIVEC__) && !defined(PPC_MULTILIB_ALTIVEC)
544        li      r3, 0
545#endif
546
547        b       restore_context
548
549#ifdef RTEMS_SMP
550.Lget_potential_new_heir:
551
552        /* We may have a new heir */
553
554        /* Read the executing and heir */
555        lwz     r7, PER_CPU_OFFSET_EXECUTING(r12)
556        lwz     r8, PER_CPU_OFFSET_HEIR(r12)
557
558        /*
559         * Update the executing only if necessary to avoid cache line
560         * monopolization.
561         */
562        cmpw    r7, r8
563        beq     .Lcheck_is_executing
564
565        /* Calculate the heir context pointer */
566        sub     r7, r4, r7
567        add     r4, r8, r7
568        clrrwi  r5, r4, PPC_DEFAULT_CACHE_LINE_POWER
569
570        /* Update the executing */
571        stw     r8, PER_CPU_OFFSET_EXECUTING(r12)
572
573        b       .Lcheck_is_executing
574#endif
Note: See TracBrowser for help on using the repository browser.