1 /* Set current context.
2 Copyright (C) 2015-2016 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, see
17 <http://www.gnu.org/licenses/>. */
20 #include "ucontext_i.h"
22 /* int setcontext (const ucontext_t *ucp) */
25 ldw r5, UCONTEXT_FLAGS(r4)
27 bne r5, r6, .Lsigreturn
31 /* Restore signal mask. */
32 /* rt_sigprocmask (SIG_SETMASK, &ucp->uc_sigmask, NULL, _NSIG8) */
34 addi r5, r4, UCONTEXT_SIGMASK
37 movi r2, SYS_ify (rt_sigprocmask)
39 bne r7, zero, SYSCALL_ERROR_LABEL
41 /* Restore argument registers, for the makecontext() case. */
42 ldw r4, (UCONTEXT_MCONTEXT + 4*4)(r10)
43 ldw r5, (UCONTEXT_MCONTEXT + 5*4)(r10)
44 ldw r6, (UCONTEXT_MCONTEXT + 6*4)(r10)
45 ldw r7, (UCONTEXT_MCONTEXT + 7*4)(r10)
47 ldw r16, (UCONTEXT_MCONTEXT + 16*4)(r10)
48 ldw r17, (UCONTEXT_MCONTEXT + 17*4)(r10)
49 ldw r18, (UCONTEXT_MCONTEXT + 18*4)(r10)
50 ldw r19, (UCONTEXT_MCONTEXT + 19*4)(r10)
51 ldw r20, (UCONTEXT_MCONTEXT + 20*4)(r10)
52 ldw r21, (UCONTEXT_MCONTEXT + 21*4)(r10)
53 ldw r22, (UCONTEXT_MCONTEXT + 22*4)(r10)
54 ldw ra, (UCONTEXT_MCONTEXT + 24*4)(r10)
55 ldw fp, (UCONTEXT_MCONTEXT + 25*4)(r10)
56 ldw gp, (UCONTEXT_MCONTEXT + 26*4)(r10)
57 /* Load address to continue execution. */
58 ldw r3, (UCONTEXT_MCONTEXT + 28*4)(r10)
59 ldw sp, (UCONTEXT_MCONTEXT + 29*4)(r10)
65 addi sp, sp, -RT_SIGFRAME_SIZE
66 cfi_adjust_cfa_offset (RT_SIGFRAME_SIZE)
68 addi r2, sp, RT_SIGFRAME_UCONTEXT
69 movi r3, UCONTEXT_SIZE-4
78 movi r2, SYS_ify (rt_sigreturn)
81 addi sp, sp, RT_SIGFRAME_SIZE
82 cfi_adjust_cfa_offset (-RT_SIGFRAME_SIZE)
83 br SYSCALL_ERROR_LABEL
85 PSEUDO_END (__setcontext)
86 weak_alias (__setcontext, setcontext)
90 bne r4, zero, __setcontext
92 /* If uc_link == zero, call exit. */
95 1: movhi r8, %hiadj(_gp_got - 1b)
96 addi r8, r8, %lo(_gp_got - 1b)
98 ldw r8, %call(HIDDEN_JUMPTARGET(exit))(r22)