chiark / gitweb /
eglibc (2.11.3-4+deb6u3) squeeze-lts; urgency=medium
[eglibc.git] / sysdeps / unix / sysv / linux / sh / sh4 / setcontext.S
1 /* Install given context.
2    Copyright (C) 2005, 2009 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4
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.
9
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.
14
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.  */
19
20 #include <sysdep.h>
21
22 #include "ucontext_i.h"
23
24 /*  int __setcontext (const ucontext_t *uc);  */
25
26         .text
27         .align  5
28 ENTRY(__setcontext)
29
30         mov     r4, r8
31
32         /* sigprocmask (SIG_SETMASK, &uc->uc_sigmask, NULL).  */
33         mov     r4, r5
34         add     #(oSIGMASK/2), r5
35         add     #(oSIGMASK/2), r5
36         mov     #SIG_SETMASK, r4
37         mov     #0, r6
38         mov     #+SYS_ify(sigprocmask), r3
39         trapa   #0x13
40         mov     r0, r1
41         mov     #-12, r2
42         shad    r2, r1
43         not     r1, r1                  // r1=0 means r0 = -1 to -4095
44         tst     r1, r1                  // i.e. error in linux
45         bf      .Lsetcontext_restore
46 .Lsyscall_error:
47         SYSCALL_ERROR_HANDLER
48 .Lpseudo_end:
49         rts
50          nop
51
52 .Lsetcontext_restore:
53 #ifdef __SH_FPU_ANY__
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
92 #endif /* __SH_FPU_ANY__ */
93
94         mov     r8, r0
95         add     #(oPC), r0
96         mov.l   @r0+, r2
97         lds.l   @r0+, pr
98
99         /* Restore T frag.  */
100         mov.l   @r0+, r1
101         shlr    r1
102         /* Skip GBR which is used for thread pointer.  */
103         add     #4, r0
104
105         lds.l   @r0+, mach
106         lds.l   @r0+, macl
107
108         mov     r8, r0
109         add     #(oR9), r0
110         mov.l   @r0+, r9
111         mov.l   @r0+, r10
112         mov.l   @r0+, r11
113         mov.l   @r0+, r12
114         mov.l   @r0+, r13
115         mov.l   @r0+, r14
116         mov.l   @r0+, r15
117
118         mov     r8, r0
119         mov.l   @(oR0,r0), r1
120         mov.l   r1, @-r15
121         cfi_adjust_cfa_offset(4)
122         cfi_rel_offset (r1, 0)
123         mov.l   r2, @-r15
124         cfi_adjust_cfa_offset(4)
125         cfi_rel_offset (r2, 0)
126
127         mov.l   @(oR1,r0), r1
128         mov.l   @(oR2,r0), r2
129         mov.l   @(oR3,r0), r3
130         mov.l   @(oR4,r0), r4
131         mov.l   @(oR5,r0), r5
132         mov.l   @(oR6,r0), r6
133         mov.l   @(oR7,r0), r7
134         mov.l   @(oR8,r0), r8
135         mov.l   @r15+, r0
136         jmp     @r0
137          mov.l  @r15+, r0
138
139 PSEUDO_END(__setcontext)
140
141 weak_alias (__setcontext, setcontext)