summaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/linux/arc/setcontext.S
diff options
context:
space:
mode:
authorVineet Gupta <vgupta@synopsys.com>2018-10-23 14:56:39 -0700
committerVineet Gupta <vgupta@synopsys.com>2020-07-09 09:29:03 -0700
commit4be42eb5067f869a9f1fb3349be811f9e0991348 (patch)
tree3aeeb7941167a789d737616ab32bf60b183c0c59 /sysdeps/unix/sysv/linux/arc/setcontext.S
parent3b6a0070434433e79c9e14ff460c29001fb4d010 (diff)
downloadglibc-4be42eb5067f869a9f1fb3349be811f9e0991348.tar.gz
ARC: Linux ABI
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'sysdeps/unix/sysv/linux/arc/setcontext.S')
-rw-r--r--sysdeps/unix/sysv/linux/arc/setcontext.S93
1 files changed, 93 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/linux/arc/setcontext.S b/sysdeps/unix/sysv/linux/arc/setcontext.S
new file mode 100644
index 0000000000..56a362f837
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/arc/setcontext.S
@@ -0,0 +1,93 @@
+/* Set current context for ARC.
+ Copyright (C) 2020 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include "ucontext-macros.h"
+
+/* int setcontext (const ucontext_t *ucp)
+ - Restores the machine context in @ucp and resumes execution
+ (doesn't return to caller). */
+
+ENTRY (__setcontext)
+
+ mov r9, r0 /* Stash @ucp across syscall. */
+
+ /* rt_sigprocmask (SIG_SETMASK, &ucp->uc_sigmask, NULL, _NSIG8). */
+ mov r3, _NSIG8
+ mov r2, 0
+ add r1, r0, UCONTEXT_SIGMASK
+ mov r0, SIG_SETMASK
+ mov r8, __NR_rt_sigprocmask
+ ARC_TRAP_INSN
+ brhi r0, -1024, L (call_syscall_err)
+
+ /* Restore scratch/arg regs for makecontext case. */
+ add r9, r9, UCONTEXT_MCONTEXT
+ LDR (r0, r9, 22)
+ LDR (r1, r9, 21)
+ LDR (r2, r9, 20)
+ LDR (r3, r9, 19)
+ LDR (r4, r9, 18)
+ LDR (r5, r9, 17)
+ LDR (r6, r9, 16)
+ LDR (r7, r9, 15)
+
+ /* Restore callee saved registers. */
+ LDR (r13, r9, 37)
+ LDR (r14, r9, 36)
+ LDR (r15, r9, 35)
+ LDR (r16, r9, 34)
+ LDR (r17, r9, 33)
+ LDR (r18, r9, 32)
+ LDR (r19, r9, 31)
+ LDR (r20, r9, 30)
+ LDR (r21, r9, 29)
+ LDR (r22, r9, 28)
+ LDR (r23, r9, 27)
+ LDR (r24, r9, 26)
+
+ LDR (blink, r9, 7)
+ LDR (fp, r9, 8)
+ LDR (gp, r9, 9)
+ LDR (sp, r9, 23)
+
+ j [blink]
+
+PSEUDO_END (__setcontext)
+weak_alias (__setcontext, setcontext)
+
+
+/* Helper for activating makecontext created context
+ - r14 has @func, r15 has uc_link. */
+
+ENTRY (__startcontext)
+
+ .cfi_label .Ldummy
+ cfi_undefined (blink)
+
+ /* Call user @func, loaded in r14 by setcontext. */
+ jl [r14]
+
+ /* If uc_link (r15) call setcontext with that. */
+ mov r0, r15
+ breq r0, 0, 1f
+
+ bl __setcontext
+1:
+ /* Exit with status 0. */
+ b HIDDEN_JUMPTARGET(exit)
+END (__startcontext)