source: trunk/libs/newlib/src/libgloss/sparc_leon/fpu.S @ 454

Last change on this file since 454 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 2.9 KB
Line 
1/*
2 * Copyright (c) 2011 Aeroflex Gaisler
3 *
4 * BSD license:
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24
25
26#include <asm-leon/asmmacro.h>
27#include <asm-leon/leonstack.h>
28#include <asm-leon/winmacros.h>
29#include <asm-leon/leon.h>
30       
31#ifndef _SOFT_FLOAT
32
33        .seg    "text"
34        /* ------- */
35        .weak   _fpdis_enable_svt
36        .set    _fpdis_enable_svt,__fpdis_enable_svt
37        .weak   _fpdis_enable
38        .set    _fpdis_enable,__fpdis_enable
39        /* ------- */
40        !.global _fpdis_enable,_fpdis_enable_svt
41__fpdis_enable_svt:
42__fpdis_enable:
43
44        set SPARC_PSR_EF_MASK,%l3
45        or %l0,%l3,%l0
46        or %l0,0xf00, %l3               ! PIL up to 15, enable fpu
47        wr %l3,0, %psr                  ! restore the condition flags, enable fpu
48        nop
49        nop
50        nop
51       
52        mov     %psr, %l3               ! check if fpu is present
53        set SPARC_PSR_EF_MASK,%l4
54        andcc   %l3, %l4, %l3
55        bne     4f
56         nop
57       
58         ta     0                       ! no fpu present, halt
59       
604:
61        set     fpustate_current,%l4
62       
63        ld [%l4],%l4
64        set     fpustate_owner,%l5
65        ld [%l5],%l5
66        cmp     %l4,%l5
67        beq     mpfnostore
68         nop
69        cmp    %g0,%l5
70         beq    mpfstore
71        nop
72
73        FW_STORE(%l5)
74       
75mpfstore:       
76        set     fpustate_owner,%l6
77        st %l4,[%l6]
78        cmp    %g0,%l4
79         beq    mpfnostore
80        nop
81       
82        FW_LOAD(%l4)
83
84mpfnostore:     
85        wr      %l0,0, %psr             ! restore the condition flags, enable fpu
86        nop
87        nop
88        nop
89       
90        jmpl    %l1,  %g0
91        rett    %l2
92       
93        .seg    "data"
94
95        .global fpustate_default
96        .align  8
97fpustate_default:
98        .long 0; .long 0; .long 0; .long 0; .long 0; .long 0; .long 0; .long 0;
99        .long 0; .long 0; .long 0; .long 0; .long 0; .long 0; .long 0; .long 0;
100        .long 0; .long 0; .long 0; .long 0; .long 0; .long 0; .long 0; .long 0;
101        .long 0; .long 0; .long 0; .long 0; .long 0; .long 0; .long 0; .long 0;
102        .long 0; .long 0; .long 0; .long 0; .long 0; .long 0; .long 0; .long 0;
103        .global fpustate_owner
104fpustate_owner:
105        .word   fpustate_default                                ! pointer to FPU owning context
106       
107        .global fpustate_current       
108fpustate_current:       
109        .word   fpustate_default                                ! pointer to current threads FPU context
110               
111#endif
Note: See TracBrowser for help on using the repository browser.