Updated to fedora-glibc-20051020T0651
[glibc.git] / sysdeps / unix / sysv / linux / sh / sh4 / setcontext.S
blob9e98910b4b05d4c78a9631e1a6bbc7f2b6be12b0
1 /* Install given context.
2    Copyright (C) 2005 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, write to the Free
17    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18    02111-1307 USA.  */
20 #include <sysdep.h>
22 #include "ucontext_i.h"
24 /*  int __setcontext (const ucontext_t *uc);  */
26         .text
27         .align  5
28         cfi_startproc
29 ENTRY(__setcontext)
31         mov     r4, r8
33         /* sigprocmask (SIG_SETMASK, &uc->uc_sigmask, NULL).  */
34         mov     r4, r5
35         add     #(oSIGMASK/2), r5
36         add     #(oSIGMASK/2), r5
37         mov     #SIG_SETMASK, r4
38         mov     #0, r6
39         mov     #+SYS_ify(sigprocmask), r3
40         trapa   #0x13
41         mov     r0, r1
42         mov     #-12, r2
43         shad    r2, r1
44         not     r1, r1                  // r1=0 means r0 = -1 to -4095
45         tst     r1, r1                  // i.e. error in linux
46         bf      .Lsetcontext_restore
47 .Lsyscall_error:        
48         SYSCALL_ERROR_HANDLER
49 .Lpseudo_end:
50         rts
51          nop
53 .Lsetcontext_restore:
54         mov     r8, r0
55         add     #(oFR0),r0
56         fmov.s  @r0+, fr0
57         fmov.s  @r0+, fr1
58         fmov.s  @r0+, fr2
59         fmov.s  @r0+, fr3
60         fmov.s  @r0+, fr4
61         fmov.s  @r0+, fr5
62         fmov.s  @r0+, fr6
63         fmov.s  @r0+, fr7
64         fmov.s  @r0+, fr8
65         fmov.s  @r0+, fr9
66         fmov.s  @r0+, fr10
67         fmov.s  @r0+, fr11
68         fmov.s  @r0+, fr12
69         fmov.s  @r0+, fr13
70         fmov.s  @r0+, fr14
71         fmov.s  @r0+, fr15
72         frchg
73         fmov.s  @r0+, fr0
74         fmov.s  @r0+, fr1
75         fmov.s  @r0+, fr2
76         fmov.s  @r0+, fr3
77         fmov.s  @r0+, fr4
78         fmov.s  @r0+, fr5
79         fmov.s  @r0+, fr6
80         fmov.s  @r0+, fr7
81         fmov.s  @r0+, fr8
82         fmov.s  @r0+, fr9
83         fmov.s  @r0+, fr10
84         fmov.s  @r0+, fr11
85         fmov.s  @r0+, fr12
86         fmov.s  @r0+, fr13
87         fmov.s  @r0+, fr14
88         fmov.s  @r0+, fr15
89         frchg
90         lds.l   @r0+, fpscr
91         lds.l   @r0+, fpul
93         mov     r8, r0
94         add     #(oPC), r0
95         mov.l   @r0+, r2
96         lds.l   @r0+, pr
98         /* Restore T frag.  */
99         mov.l   @r0+, r1
100         shlr    r1
101         /* Skip GBR which is used for thread pointer.  */
102         add     #4, r0
104         lds.l   @r0+, mach
105         lds.l   @r0+, macl
107         mov     r8, r0
108         add     #(oR9), r0
109         mov.l   @r0+, r9
110         mov.l   @r0+, r10
111         mov.l   @r0+, r11
112         mov.l   @r0+, r12
113         mov.l   @r0+, r13
114         mov.l   @r0+, r14
115         mov.l   @r0+, r15
117         mov     r8, r0
118         mov.l   @(oR0,r0), r1
119         mov.l   r1, @-r15
120         cfi_adjust_cfa_offset(4)
121         cfi_rel_offset (r1, 0)
122         mov.l   r2, @-r15
123         cfi_adjust_cfa_offset(4)
124         cfi_rel_offset (r2, 0)
126         mov.l   @(oR1,r0), r1
127         mov.l   @(oR2,r0), r2
128         mov.l   @(oR3,r0), r3
129         mov.l   @(oR4,r0), r4
130         mov.l   @(oR5,r0), r5
131         mov.l   @(oR6,r0), r6
132         mov.l   @(oR7,r0), r7
133         mov.l   @(oR8,r0), r8
134         mov.l   @r15+, r0
135         jmp     @r0
136          mov.l  @r15+, r0
138         cfi_endproc
139 PSEUDO_END(__setcontext)
141 weak_alias (__setcontext, setcontext)