source: trunk/libs/newlib/src/libgloss/sparc_leon/regwin.S @ 444

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

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

File size: 3.7 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/leon.h>
27#include <asm-leon/leonstack.h>
28#include <asm-leon/asmmacro.h>
29       
30  .seg    "text"
31
32       
33/* Number of register windows */
34        .global _nwindows_min1, _nwindows
35       
36        ! Window overflow trap handler on save.
37        ! Touches %g1
38        /* ------- */
39        .weak   _window_overflow
40        .set    _window_overflow,__window_overflow
41        .weak   _window_overflow_svt
42        .set    _window_overflow_svt,__window_overflow_svt
43        /* ------- */
44        !.global _window_overflow,_window_overflow_svt
45        .global __window_overflow_rettseq,__window_overflow_rettseq_ret,__window_overflow_slow1
46
47__window_overflow_svt:         
48__window_overflow:
49#ifndef _FLAT
50__window_overflow_rettseq:             
51        mov  %wim, %l3                  ! Calculate next WIM
52        mov  %g1, %l7           
53        srl  %l3, 1, %g1       
54__window_overflow_rettseq_ret:         
55        sethi %hi(_nwindows_min1), %l4  ! NWINDOWS-1
56        ld [%l4+%lo(_nwindows_min1)], %l4
57       
58        sll  %l3, %l4 , %l4
59        or   %l4, %g1, %g1
60
61        save                              ! Get into window to be saved.
62        mov  %g1, %wim
63        nop; nop; nop
64        std   %l0, [%sp + 0];
65        std   %l2, [%sp + 8];
66        std   %l4, [%sp + 16];
67        std   %l6, [%sp + 24];
68        std   %i0, [%sp + 32];
69        std   %i2, [%sp + 40];
70        std   %i4, [%sp + 48];
71        std   %i6, [%sp + 56];
72        restore                         ! Go back to trap window.
73        mov  %l7, %g1
74       
75        jmp  %l1                        ! Re-execute save.
76        rett %l2
77        nop
78       
79__window_overflow_slow1:                ! space for possible stackcheck patch
80        nop
81        nop
82#else   
83        ta      0                       ! halt
84__window_overflow_rettseq:             
85__window_overflow_rettseq_ret:         
86__window_overflow_slow1:               
87        nop
88        nop
89        nop
90#endif
91       
92  /* Window underflow trap handler on restore.  */
93
94        ! Touches %g1
95        /* ------- */
96        .weak   _window_underflow
97        .set    _window_underflow,__window_underflow
98        .weak   _window_underflow_svt
99        .set    _window_underflow_svt,__window_underflow_svt
100        /* ------- */
101        !.global  _window_underflow,_window_underflow_svt
102
103__window_underflow_svt:
104__window_underflow:
105#ifndef _FLAT
106        mov  %wim, %l3                  ! Calculate next WIM
107        sll  %l3, 1, %l4
108
109        sethi %hi(_nwindows_min1), %l5  ! NWINDOWS-1
110        ld [%l5+%lo(_nwindows_min1)], %l5
111       
112        srl  %l3, %l5, %l5
113        or   %l5, %l4, %l5
114        mov  %l5, %wim
115        nop; nop; nop
116        restore                         ! Two restores to get into the
117        restore                         ! window to restore
118        ldd   [%sp + 0], %l0;           ! Restore window from the stack
119        ldd   [%sp + 8], %l2;
120        ldd   [%sp + 16], %l4;
121        ldd   [%sp + 24], %l6;
122        ldd   [%sp + 32], %i0;
123        ldd   [%sp + 40], %i2;
124        ldd   [%sp + 48], %i4;
125        ldd   [%sp + 56], %i6;
126        save                            ! Get back to the trap window.
127        save
128        jmp  %l1                        ! Re-execute restore.
129        rett  %l2
130#else   
131        ta      0                       ! halt
132#endif
133
134       
Note: See TracBrowser for help on using the repository browser.