summaryrefslogtreecommitdiffstats
path: root/lib/libpthread/arch/sparc
diff options
context:
space:
mode:
authord <d@openbsd.org>2000-09-25 01:16:40 +0000
committerd <d@openbsd.org>2000-09-25 01:16:40 +0000
commit837600b667895a023a1305b68581eadc5378ee7a (patch)
tree55af2ef35537f9050fb2621969477c476889ce0e /lib/libpthread/arch/sparc
parentswitch powerpc to libgcc -fPIC. (diff)
downloadwireguard-openbsd-837600b667895a023a1305b68581eadc5378ee7a.tar.xz
wireguard-openbsd-837600b667895a023a1305b68581eadc5378ee7a.zip
preparation for switch-based threads
Diffstat (limited to 'lib/libpthread/arch/sparc')
-rw-r--r--lib/libpthread/arch/sparc/uthread_machdep.c44
-rw-r--r--lib/libpthread/arch/sparc/uthread_machdep_asm.S39
2 files changed, 83 insertions, 0 deletions
diff --git a/lib/libpthread/arch/sparc/uthread_machdep.c b/lib/libpthread/arch/sparc/uthread_machdep.c
new file mode 100644
index 00000000000..789a1d3efd1
--- /dev/null
+++ b/lib/libpthread/arch/sparc/uthread_machdep.c
@@ -0,0 +1,44 @@
+/* $OpenBSD: uthread_machdep.c,v 1.1 2000/09/25 01:16:40 d Exp $ */
+
+/*
+ * Machine-dependent thread state functions for OpenBSD/sparc.
+ */
+
+#include <machine/frame.h>
+#include <machine/param.h>
+#include <pthread.h>
+#include "pthread_private.h"
+
+/*
+ * Given a stack and an entry function, initialise a state
+ * structure that can be later switched to.
+ */
+void
+_thread_machdep_init(statep, base, len, entry)
+ struct _machdep_state* statep;
+ void *base;
+ int len;
+ void (*entry)(void);
+{
+ struct frame *f;
+
+ /* Locate the initial frame, aligned at the top of the stack */
+ f = (struct frame *)(((int)base + len - sizeof *f) & ~ALIGNBYTES);
+
+ f->fr_fp = (struct frame *)-1; /* purposefully misaligned */
+ f->fr_pc = -1; /* for gdb */
+ statep->fp = (int)f;
+ statep->pc = -8 + (int)entry;
+}
+
+void
+_thread_machdep_save_float_state(statep)
+ struct _machdep_state* statep;
+{
+}
+
+void
+_thread_machdep_restore_float_state(statep)
+ struct _machdep_state* statep;
+{
+}
diff --git a/lib/libpthread/arch/sparc/uthread_machdep_asm.S b/lib/libpthread/arch/sparc/uthread_machdep_asm.S
new file mode 100644
index 00000000000..27be8c45311
--- /dev/null
+++ b/lib/libpthread/arch/sparc/uthread_machdep_asm.S
@@ -0,0 +1,39 @@
+/* $OpenBSD: uthread_machdep_asm.S,v 1.1 2000/09/25 01:16:40 d 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 __sparc_v9__
+#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
+