1/* Save and set current context for ARC. 2 Copyright (C) 2020-2021 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 "ucontext-macros.h" 20 21/* int swapcontext (ucontext_t *oucp, const ucontext_t *ucp). */ 22 23ENTRY (__swapcontext) 24 25 /* Save context into @oucp pointed to by r0. */ 26 27 add r2, r0, UCONTEXT_MCONTEXT 28 STR (r13, r2, 37) 29 STR (r14, r2, 36) 30 STR (r15, r2, 35) 31 STR (r16, r2, 34) 32 STR (r17, r2, 33) 33 STR (r18, r2, 32) 34 STR (r19, r2, 31) 35 STR (r20, r2, 30) 36 STR (r21, r2, 29) 37 STR (r22, r2, 28) 38 STR (r23, r2, 27) 39 STR (r24, r2, 26) 40 41 STR (blink, r2, 7) 42 STR (fp, r2, 8) 43 STR (gp, r2, 9) 44 STR (sp, r2, 23) 45 46 /* Save 0 in r0 placeholder to return 0 when @oucp activated. */ 47 mov r9, 0 48 STR (r9, r2, 22) 49 50 /* Load context from @ucp. */ 51 52 mov r9, r1 /* Safekeep @ucp across syscall. */ 53 54 /* rt_sigprocmask (SIG_SETMASK, &ucp->uc_sigmask, &oucp->uc_sigmask, _NSIG8) */ 55 mov r3, _NSIG8 56 add r2, r0, UCONTEXT_SIGMASK 57 add r1, r1, UCONTEXT_SIGMASK 58 mov r0, SIG_SETMASK 59 mov r8, __NR_rt_sigprocmask 60 ARC_TRAP_INSN 61 brhi r0, -1024, L (call_syscall_err) 62 63 add r9, r9, UCONTEXT_MCONTEXT 64 LDR (r0, r9, 22) 65 LDR (r1, r9, 21) 66 LDR (r2, r9, 20) 67 LDR (r3, r9, 19) 68 LDR (r4, r9, 18) 69 LDR (r5, r9, 17) 70 LDR (r6, r9, 16) 71 LDR (r7, r9, 15) 72 73 LDR (r13, r9, 37) 74 LDR (r14, r9, 36) 75 LDR (r15, r9, 35) 76 LDR (r16, r9, 34) 77 LDR (r17, r9, 33) 78 LDR (r18, r9, 32) 79 LDR (r19, r9, 31) 80 LDR (r20, r9, 30) 81 LDR (r21, r9, 29) 82 LDR (r22, r9, 28) 83 LDR (r23, r9, 27) 84 LDR (r24, r9, 26) 85 86 LDR (blink, r9, 7) 87 LDR (fp, r9, 8) 88 LDR (gp, r9, 9) 89 LDR (sp, r9, 23) 90 91 j [blink] 92 93PSEUDO_END (__swapcontext) 94weak_alias (__swapcontext, swapcontext) 95