source: trunk/libs/newlib/src/libgloss/sparc_leon/regwin_slow.S @ 532

Last change on this file since 532 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       
55__window_overflow_rettseq_ret:         
56        sethi %hi(_nwindows_min1), %l4  ! NWINDOWS-1
57        ld [%l4+%lo(_nwindows_min1)], %l4
58       
59        sll  %l3, %l4 , %l4
60        or   %l4, %g1, %g1
61
62        save                              ! Get into window to be saved.
63        mov  %g1, %wim
64        nop; nop; nop
65        std   %l0, [%sp + 0];
66        std   %l2, [%sp + 8];
67        std   %l4, [%sp + 16];
68        std   %l6, [%sp + 24];
69        std   %i0, [%sp + 32];
70        std   %i2, [%sp + 40];
71        std   %i4, [%sp + 48];
72        std   %i6, [%sp + 56];
73        restore                         ! Go back to trap window.
74        mov  %l7, %g1
75       
76        jmp  %l1                        ! Re-execute save.
77        rett %l2
78        nop
79       
80__window_overflow_slow1:                ! space for possible stackcheck patch
81        nop
82        nop
83#else   
84        ta      0                       ! halt
85__window_overflow_rettseq:             
86__window_overflow_rettseq_ret:         
87__window_overflow_slow1:               
88        nop
89        nop
90        nop
91#endif
92       
93  /* Window underflow trap handler on restore.  */
94
95        ! Touches %g1
96        /* ------- */
97        .weak   _window_underflow
98        .set    _window_underflow,__window_underflow
99        .weak   _window_underflow_svt
100        .set    _window_underflow_svt,__window_underflow_svt
101        /* ------- */
102        !.global  _window_underflow,_window_underflow_svt
103
104__window_underflow_svt:
105__window_underflow:
106#ifndef _FLAT
107        mov  %wim, %l3                  ! Calculate next WIM
108        sll  %l3, 1, %l4
109
110        sethi %hi(_nwindows_min1), %l5  ! NWINDOWS-1
111        ld [%l5+%lo(_nwindows_min1)], %l5
112       
113        srl  %l3, %l5, %l5
114        or   %l5, %l4, %l5
115        mov  %l5, %wim
116        nop; nop; nop
117        restore                         ! Two restores to get into the
118        restore                         ! window to restore
119        ldd   [%sp + 0], %l0;           ! Restore window from the stack
120        ldd   [%sp + 8], %l2;
121        ldd   [%sp + 16], %l4;
122        ldd   [%sp + 24], %l6;
123        ldd   [%sp + 32], %i0;
124        ldd   [%sp + 40], %i2;
125        ldd   [%sp + 48], %i4;
126        ldd   [%sp + 56], %i6;
127        save                            ! Get back to the trap window.
128        save
129        jmp  %l1                        ! Re-execute restore.
130        rett  %l2
131#else   
132        ta      0                       ! halt
133#endif
134
135       
Note: See TracBrowser for help on using the repository browser.