summaryrefslogtreecommitdiff
path: root/lib/libpthread/arch/sparc64/uthread_machdep_asm.S
diff options
context:
space:
mode:
authorJason Wright <jason@cvs.openbsd.org>2001-09-10 20:00:15 +0000
committerJason Wright <jason@cvs.openbsd.org>2001-09-10 20:00:15 +0000
commitcf0a3aafd4f3d1aebfa8491b8f0ba507c8baa802 (patch)
tree11bb9eaa68a8c3e3c09598bca2a9222981973214 /lib/libpthread/arch/sparc64/uthread_machdep_asm.S
parent37e8cc1621c3eff734b8d369f2f1a1aa0a2147d6 (diff)
Enough for libc_r on sparc64 to build (this stuff is mostly taken from sparc,
and will need attention before it can be expected to work).
Diffstat (limited to 'lib/libpthread/arch/sparc64/uthread_machdep_asm.S')
-rw-r--r--lib/libpthread/arch/sparc64/uthread_machdep_asm.S39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/libpthread/arch/sparc64/uthread_machdep_asm.S b/lib/libpthread/arch/sparc64/uthread_machdep_asm.S
new file mode 100644
index 00000000000..aef33143968
--- /dev/null
+++ b/lib/libpthread/arch/sparc64/uthread_machdep_asm.S
@@ -0,0 +1,39 @@
+/* $OpenBSD: uthread_machdep_asm.S,v 1.1 2001/09/10 20:00:14 jason Exp $ */
+/* David Leonard <d@csee.uq.edu.au>. Public domain. */
+
+#include <machine/asm.h>
+#include <machine/trap.h>
+
+/*
+ * Switch stacks.
+ * On sparc this also means we switch register windows.
+ */
+
+#ifdef __sparcv9__
+#define flushw .word 0x81580000
+#else
+#define flushw t T_FLUSHWIN
+#endif
+
+#define SA(x) (((x)+15)&(~0x1f))
+#define MINFRAME ((16+1+6)*8)
+
+/* void _thread_switch(int newstate[2], int savestate[2], int flags); */
+ENTRY(_thread_machdep_switch)
+
+ /* new window */
+ save %sp, -SA(MINFRAME), %sp
+
+ /* flush all windows (except current one) into memory frames */
+ flushw
+
+ /* switch the stack pointer and return address */
+ st %fp, [%i1 + 0]
+ st %i7, [%i1 + 4]
+ ld [%i0 + 0], %fp
+ ld [%i0 + 4], %i7
+
+ /* return to saved window at new %fp */
+ ret
+ restore
+