1 | /* Install given context. |
2 | Copyright (C) 2005-2022 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, see |
17 | <https://www.gnu.org/licenses/>. */ |
18 | |
19 | #include <sysdep.h> |
20 | |
21 | #include "ucontext_i.h" |
22 | |
23 | /* int __setcontext (const ucontext_t *uc); */ |
24 | |
25 | .text |
26 | .align 5 |
27 | ENTRY(__setcontext) |
28 | |
29 | mov r4, r8 |
30 | |
31 | /* sigprocmask (SIG_SETMASK, &uc->uc_sigmask, NULL). */ |
32 | mov r4, r5 |
33 | add #oSIGMASK, r5 |
34 | mov #SIG_SETMASK, r4 |
35 | mov #0, r6 |
36 | mov #+SYS_ify(sigprocmask), r3 |
37 | trapa #0x13 |
38 | mov r0, r1 |
39 | mov #-12, r2 |
40 | shad r2, r1 |
41 | not r1, r1 // r1=0 means r0 = -1 to -4095 |
42 | tst r1, r1 // i.e. error in linux |
43 | bf .Lsetcontext_restore |
44 | .Lsyscall_error: |
45 | SYSCALL_ERROR_HANDLER |
46 | .Lpseudo_end: |
47 | rts |
48 | nop |
49 | |
50 | .Lsetcontext_restore: |
51 | mov r8, r0 |
52 | add #(oPC), r0 |
53 | mov.l @r0+, r2 |
54 | lds.l @r0+, pr |
55 | |
56 | /* Restore T frag. */ |
57 | mov.l @r0+, r1 |
58 | shlr r1 |
59 | /* Skip GBR which is used for thread pointer. */ |
60 | add #4, r0 |
61 | |
62 | lds.l @r0+, mach |
63 | lds.l @r0+, macl |
64 | |
65 | mov r8, r0 |
66 | add #(oR9), r0 |
67 | mov.l @r0+, r9 |
68 | mov.l @r0+, r10 |
69 | mov.l @r0+, r11 |
70 | mov.l @r0+, r12 |
71 | mov.l @r0+, r13 |
72 | mov.l @r0+, r14 |
73 | mov.l @r0+, r15 |
74 | |
75 | mov r8, r0 |
76 | mov.l @(oR0,r0), r1 |
77 | mov.l r1, @-r15 |
78 | cfi_adjust_cfa_offset(4) |
79 | cfi_rel_offset (r1, 0) |
80 | mov.l r2, @-r15 |
81 | cfi_adjust_cfa_offset(4) |
82 | cfi_rel_offset (r2, 0) |
83 | |
84 | mov.l @(oR1,r0), r1 |
85 | mov.l @(oR2,r0), r2 |
86 | mov.l @(oR3,r0), r3 |
87 | mov.l @(oR4,r0), r4 |
88 | mov.l @(oR5,r0), r5 |
89 | mov.l @(oR6,r0), r6 |
90 | mov.l @(oR7,r0), r7 |
91 | mov.l @(oR8,r0), r8 |
92 | mov.l @r15+, r0 |
93 | cfi_adjust_cfa_offset(-4) |
94 | jmp @r0 |
95 | mov.l @r15+, r0 |
96 | |
97 | PSEUDO_END(__setcontext) |
98 | |
99 | weak_alias (__setcontext, setcontext) |
100 | |