source: rtems/cpukit/score/cpu/sparc/cpu_asm.S @ c499856

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 4.2 KB
Line 
1/*  cpu_asm.s
2 *
3 *  This file contains the basic algorithms for all assembly code used
4 *  in an specific CPU port of RTEMS.  These algorithms must be implemented
5 *  in assembly language.
6 *
7 *  COPYRIGHT (c) 1989-2011.
8 *  On-Line Applications Research Corporation (OAR).
9 *
10 *  The license and distribution terms for this file may be
11 *  found in the file LICENSE in this distribution or at
12 *  http://www.rtems.org/license/LICENSE.
13 *
14 *  Ported to ERC32 implementation of the SPARC by On-Line Applications
15 *  Research Corporation (OAR) under contract to the European Space
16 *  Agency (ESA).
17 *
18 *  ERC32 modifications of respective RTEMS file: COPYRIGHT (c) 1995.
19 *  European Space Agency.
20 */
21
22#ifdef HAVE_CONFIG_H
23#include "config.h"
24#endif
25
26#include <rtems/asm.h>
27#include <rtems/system.h>
28
29#if (SPARC_HAS_FPU == 1)
30
31/*
32 *  void _CPU_Context_save_fp(
33 *    void **fp_context_ptr
34 *  )
35 *
36 *  This routine is responsible for saving the FP context
37 *  at *fp_context_ptr.  If the point to load the FP context
38 *  from is changed then the pointer is modified by this routine.
39 *
40 *  NOTE: See the README in this directory for information on the
41 *        management of the "EF" bit in the PSR.
42 */
43
44        .align 4
45        PUBLIC(_CPU_Context_save_fp)
46SYM(_CPU_Context_save_fp):
47        save    %sp, -CPU_MINIMUM_STACK_FRAME_SIZE, %sp
48
49        /*
50         *  The following enables the floating point unit.
51         */
52
53        mov     %psr, %l0
54        sethi   %hi(SPARC_PSR_EF_MASK), %l1
55        or      %l1, %lo(SPARC_PSR_EF_MASK), %l1
56        or      %l0, %l1, %l0
57        mov     %l0, %psr                  ! **** ENABLE FLOAT ACCESS ****
58        nop; nop; nop;                     ! Need three nops before EF is
59        ld      [%i0], %l0                 ! active due to pipeline delay!!!
60        std     %f0, [%l0 + FO_F1_OFFSET]
61        std     %f2, [%l0 + F2_F3_OFFSET]
62        std     %f4, [%l0 + F4_F5_OFFSET]
63        std     %f6, [%l0 + F6_F7_OFFSET]
64        std     %f8, [%l0 + F8_F9_OFFSET]
65        std     %f10, [%l0 + F1O_F11_OFFSET]
66        std     %f12, [%l0 + F12_F13_OFFSET]
67        std     %f14, [%l0 + F14_F15_OFFSET]
68        std     %f16, [%l0 + F16_F17_OFFSET]
69        std     %f18, [%l0 + F18_F19_OFFSET]
70        std     %f20, [%l0 + F2O_F21_OFFSET]
71        std     %f22, [%l0 + F22_F23_OFFSET]
72        std     %f24, [%l0 + F24_F25_OFFSET]
73        std     %f26, [%l0 + F26_F27_OFFSET]
74        std     %f28, [%l0 + F28_F29_OFFSET]
75        std     %f30, [%l0 + F3O_F31_OFFSET]
76        st      %fsr, [%l0 + FSR_OFFSET]
77        ret
78        restore
79
80/*
81 *  void _CPU_Context_restore_fp(
82 *    void **fp_context_ptr
83 *  )
84 *
85 *  This routine is responsible for restoring the FP context
86 *  at *fp_context_ptr.  If the point to load the FP context
87 *  from is changed then the pointer is modified by this routine.
88 *
89 *  NOTE: See the README in this directory for information on the
90 *        management of the "EF" bit in the PSR.
91 */
92
93        .align 4
94        PUBLIC(_CPU_Context_restore_fp)
95SYM(_CPU_Context_restore_fp):
96        save    %sp, -CPU_MINIMUM_STACK_FRAME_SIZE , %sp
97
98        /*
99         *  The following enables the floating point unit.
100         */
101
102        mov     %psr, %l0
103        sethi   %hi(SPARC_PSR_EF_MASK), %l1
104        or      %l1, %lo(SPARC_PSR_EF_MASK), %l1
105        or      %l0, %l1, %l0
106        mov     %l0, %psr                  ! **** ENABLE FLOAT ACCESS ****
107        nop; nop; nop;                     ! Need three nops before EF is
108        ld      [%i0], %l0                 ! active due to pipeline delay!!!
109        ldd     [%l0 + FO_F1_OFFSET], %f0
110        ldd     [%l0 + F2_F3_OFFSET], %f2
111        ldd     [%l0 + F4_F5_OFFSET], %f4
112        ldd     [%l0 + F6_F7_OFFSET], %f6
113        ldd     [%l0 + F8_F9_OFFSET], %f8
114        ldd     [%l0 + F1O_F11_OFFSET], %f10
115        ldd     [%l0 + F12_F13_OFFSET], %f12
116        ldd     [%l0 + F14_F15_OFFSET], %f14
117        ldd     [%l0 + F16_F17_OFFSET], %f16
118        ldd     [%l0 + F18_F19_OFFSET], %f18
119        ldd     [%l0 + F2O_F21_OFFSET], %f20
120        ldd     [%l0 + F22_F23_OFFSET], %f22
121        ldd     [%l0 + F24_F25_OFFSET], %f24
122        ldd     [%l0 + F26_F27_OFFSET], %f26
123        ldd     [%l0 + F28_F29_OFFSET], %f28
124        ldd     [%l0 + F3O_F31_OFFSET], %f30
125        ld      [%l0 + FSR_OFFSET], %fsr
126        ret
127        restore
128
129#endif /* SPARC_HAS_FPU */
130
131/* end of file */
Note: See TracBrowser for help on using the repository browser.