]>
Commit | Line | Data |
---|---|---|
554066b8 MS |
1 | /* Modify saved context. |
2 | ||
688903eb | 3 | Copyright (C) 2009-2018 Free Software Foundation, Inc. |
554066b8 MS |
4 | |
5 | This file is part of the GNU C Library. | |
6 | ||
7 | The GNU C Library is free software; you can redistribute it and/or | |
8 | modify it under the terms of the GNU Lesser General Public License as | |
9 | published by the Free Software Foundation; either version 2.1 of the | |
10 | License, or (at your option) any later version. | |
11 | ||
12 | The GNU C Library is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | Lesser General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU Lesser General Public | |
18 | License along with the GNU C Library; if not, see | |
19 | <http://www.gnu.org/licenses/>. */ | |
20 | ||
21 | #include <sysdep.h> | |
22 | ||
23 | #include "ucontext_i.h" | |
24 | #include "ucontext-internal.h" | |
25 | ||
26 | /* int swapcontext (ucontext_t *oucp, const ucontext_t *ucp) */ | |
27 | ||
28 | .text | |
29 | ENTRY(__swapcontext) | |
389d1f1b | 30 | DELOUSE (0) |
554066b8 MS |
31 | /* Set the value returned when swapcontext() returns in this context. */ |
32 | str xzr, [x0, oX0 + 0 * SZREG] | |
33 | ||
34 | stp x18, x19, [x0, oX0 + 18 * SZREG] | |
35 | stp x20, x21, [x0, oX0 + 20 * SZREG] | |
36 | stp x22, x23, [x0, oX0 + 22 * SZREG] | |
37 | stp x24, x25, [x0, oX0 + 24 * SZREG] | |
38 | stp x26, x27, [x0, oX0 + 26 * SZREG] | |
39 | stp x28, x29, [x0, oX0 + 28 * SZREG] | |
40 | str x30, [x0, oX0 + 30 * SZREG] | |
41 | str x30, [x0, oPC] | |
42 | mov x2, sp | |
43 | str x2, [x0, oSP] | |
44 | ||
45 | /* Figure out where to place the first context extension | |
46 | block. */ | |
47 | add x2, x0, #oEXTENSION | |
48 | ||
49 | /* Write the context extension fpsimd header. */ | |
50 | mov w3, #(FPSIMD_MAGIC & 0xffff) | |
51 | movk w3, #(FPSIMD_MAGIC >> 16), lsl #16 | |
52 | str w3, [x2, #oHEAD + oMAGIC] | |
53 | mov w3, #FPSIMD_CONTEXT_SIZE | |
54 | str w3, [x2, #oHEAD + oSIZE] | |
55 | ||
56 | /* Fill in the FP SIMD context. */ | |
57 | add x3, x2, #oV0 + 8 * SZVREG | |
2b1d7148 SN |
58 | stp q8, q9, [x3], #2 * SZVREG |
59 | stp q10, q11, [x3], #2 * SZVREG | |
60 | stp q12, q13, [x3], #2 * SZVREG | |
61 | stp q14, q15, [x3], #2 * SZVREG | |
554066b8 MS |
62 | |
63 | add x3, x2, #oFPSR | |
64 | ||
65 | mrs x4, fpsr | |
66 | str w4, [x3, #oFPSR - oFPSR] | |
67 | ||
68 | mrs x4, fpcr | |
69 | str w4, [x3, #oFPCR - oFPSR] | |
70 | ||
71 | /* Write the termination context extension header. */ | |
72 | add x2, x2, #FPSIMD_CONTEXT_SIZE | |
73 | ||
74 | str xzr, [x2, #oHEAD + oMAGIC] | |
75 | str xzr, [x2, #oHEAD + oSIZE] | |
76 | ||
77 | /* Preserve ucp. */ | |
78 | mov x21, x1 | |
79 | ||
80 | /* rt_sigprocmask (SIG_SETMASK, &ucp->uc_sigmask, &oucp->uc_sigmask, | |
81 | _NSIG8) */ | |
82 | /* Grab the signal mask */ | |
83 | /* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG8) */ | |
84 | add x2, x0, #UCONTEXT_SIGMASK | |
85 | mov x0, SIG_BLOCK | |
86 | mov x1, 0 | |
87 | mov x3, _NSIG8 | |
88 | mov x8, SYS_ify (rt_sigprocmask) | |
89 | svc 0 | |
90 | cbnz x0, 1f | |
91 | ||
92 | mov x22, x30 | |
93 | mov x0, x21 | |
94 | bl JUMPTARGET (__setcontext) | |
95 | mov x30, x22 | |
96 | RET | |
97 | ||
98 | 1: | |
99 | b C_SYMBOL_NAME(__syscall_error) | |
100 | PSEUDO_END (__swapcontext) | |
101 | weak_alias (__swapcontext, swapcontext) |