summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Leonard <d@cvs.openbsd.org>2000-09-25 05:44:14 +0000
committerDavid Leonard <d@cvs.openbsd.org>2000-09-25 05:44:14 +0000
commit0f150e4015fa63b0a030e83d15e1fa79b3048999 (patch)
tree28dd4973d3daa3c68b21df70c35555401dc3e41f
parent8a4c587747beff04cc32298563b4f8f7143bf77d (diff)
prepare for thread switching
-rw-r--r--lib/libc_r/arch/alpha/uthread_machdep.c48
-rw-r--r--lib/libc_r/arch/alpha/uthread_machdep_asm.S63
-rw-r--r--lib/libpthread/arch/alpha/uthread_machdep.c48
-rw-r--r--lib/libpthread/arch/alpha/uthread_machdep_asm.S63
4 files changed, 222 insertions, 0 deletions
diff --git a/lib/libc_r/arch/alpha/uthread_machdep.c b/lib/libc_r/arch/alpha/uthread_machdep.c
new file mode 100644
index 00000000000..1fc640c858e
--- /dev/null
+++ b/lib/libc_r/arch/alpha/uthread_machdep.c
@@ -0,0 +1,48 @@
+/* $OpenBSD: uthread_machdep.c,v 1.1 2000/09/25 05:44:13 d Exp $ */
+/* David Leonard, <d@csee.uq.edu.au>. Public domain. */
+
+/*
+ * Machine-dependent thread state functions for OpenBSD/alpha
+ */
+
+#include <pthread.h>
+#include "pthread_private.h"
+
+#define ALIGNBYTES 15
+
+struct frame {
+ long ra;
+ long s[7];
+ long t12;
+ long fs[8];
+};
+
+/*
+ * 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;
+
+ f = (struct frame *)(((long)base + len - sizeof *f) & ~ALIGNBYTES);
+ f->ra = f->t12 = (long)entry;
+ statep->sp = (long)f;
+}
+
+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/libc_r/arch/alpha/uthread_machdep_asm.S b/lib/libc_r/arch/alpha/uthread_machdep_asm.S
new file mode 100644
index 00000000000..c702ea9cd47
--- /dev/null
+++ b/lib/libc_r/arch/alpha/uthread_machdep_asm.S
@@ -0,0 +1,63 @@
+/* $OpenBSD: uthread_machdep_asm.S,v 1.1 2000/09/25 05:44:13 d Exp $ */
+/* David Leonard, <d@csee.uq.edu.au>. Public domain. */
+
+#include <machine/asm.h>
+
+#define INTOFF(n) ((n)*8)
+#define FPOFF(n) (INTOFF(9) + (n)*8)
+#define ALIGN(x) (((x)+15)&~15)
+#define FRAMESIZE ALIGN(FPOFF(8))
+
+ .globl _thread_machdep_switch
+ .ent _thread_machdep_switch, 2
+_thread_machdep_switch:
+ .frame sp, FRAMESIZE, ra
+
+ lda sp, -FRAMESIZE(sp)
+
+ stq ra, INTOFF(0)(sp)
+ stq s0, INTOFF(1)(sp)
+ stq s1, INTOFF(2)(sp)
+ stq s2, INTOFF(3)(sp)
+ stq s3, INTOFF(4)(sp)
+ stq s4, INTOFF(5)(sp)
+ stq s5, INTOFF(6)(sp)
+ stq s6, INTOFF(7)(sp)
+ stq t12, INTOFF(8)(sp)
+
+ stt fs0, FPOFF(0)(sp)
+ stt fs1, FPOFF(1)(sp)
+ stt fs2, FPOFF(2)(sp)
+ stt fs3, FPOFF(3)(sp)
+ stt fs4, FPOFF(4)(sp)
+ stt fs5, FPOFF(5)(sp)
+ stt fs6, FPOFF(6)(sp)
+ stt fs7, FPOFF(7)(sp)
+
+ stq sp, 0(a1)
+ ldq sp, 0(a0)
+
+ ldt fs7, FPOFF(7)(sp)
+ ldt fs6, FPOFF(6)(sp)
+ ldt fs5, FPOFF(5)(sp)
+ ldt fs4, FPOFF(4)(sp)
+ ldt fs3, FPOFF(3)(sp)
+ ldt fs2, FPOFF(2)(sp)
+ ldt fs1, FPOFF(1)(sp)
+ ldt fs0, FPOFF(0)(sp)
+
+ ldq t12, INTOFF(8)(sp)
+ ldq s6, INTOFF(7)(sp)
+ ldq s5, INTOFF(6)(sp)
+ ldq s4, INTOFF(5)(sp)
+ ldq s3, INTOFF(4)(sp)
+ ldq s2, INTOFF(3)(sp)
+ ldq s1, INTOFF(2)(sp)
+ ldq s0, INTOFF(1)(sp)
+ ldq ra, INTOFF(0)(sp)
+
+ lda sp,FRAMESIZE(sp)
+
+ RET
+
+ .end _thread_machdep_switch
diff --git a/lib/libpthread/arch/alpha/uthread_machdep.c b/lib/libpthread/arch/alpha/uthread_machdep.c
new file mode 100644
index 00000000000..1fc640c858e
--- /dev/null
+++ b/lib/libpthread/arch/alpha/uthread_machdep.c
@@ -0,0 +1,48 @@
+/* $OpenBSD: uthread_machdep.c,v 1.1 2000/09/25 05:44:13 d Exp $ */
+/* David Leonard, <d@csee.uq.edu.au>. Public domain. */
+
+/*
+ * Machine-dependent thread state functions for OpenBSD/alpha
+ */
+
+#include <pthread.h>
+#include "pthread_private.h"
+
+#define ALIGNBYTES 15
+
+struct frame {
+ long ra;
+ long s[7];
+ long t12;
+ long fs[8];
+};
+
+/*
+ * 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;
+
+ f = (struct frame *)(((long)base + len - sizeof *f) & ~ALIGNBYTES);
+ f->ra = f->t12 = (long)entry;
+ statep->sp = (long)f;
+}
+
+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/alpha/uthread_machdep_asm.S b/lib/libpthread/arch/alpha/uthread_machdep_asm.S
new file mode 100644
index 00000000000..c702ea9cd47
--- /dev/null
+++ b/lib/libpthread/arch/alpha/uthread_machdep_asm.S
@@ -0,0 +1,63 @@
+/* $OpenBSD: uthread_machdep_asm.S,v 1.1 2000/09/25 05:44:13 d Exp $ */
+/* David Leonard, <d@csee.uq.edu.au>. Public domain. */
+
+#include <machine/asm.h>
+
+#define INTOFF(n) ((n)*8)
+#define FPOFF(n) (INTOFF(9) + (n)*8)
+#define ALIGN(x) (((x)+15)&~15)
+#define FRAMESIZE ALIGN(FPOFF(8))
+
+ .globl _thread_machdep_switch
+ .ent _thread_machdep_switch, 2
+_thread_machdep_switch:
+ .frame sp, FRAMESIZE, ra
+
+ lda sp, -FRAMESIZE(sp)
+
+ stq ra, INTOFF(0)(sp)
+ stq s0, INTOFF(1)(sp)
+ stq s1, INTOFF(2)(sp)
+ stq s2, INTOFF(3)(sp)
+ stq s3, INTOFF(4)(sp)
+ stq s4, INTOFF(5)(sp)
+ stq s5, INTOFF(6)(sp)
+ stq s6, INTOFF(7)(sp)
+ stq t12, INTOFF(8)(sp)
+
+ stt fs0, FPOFF(0)(sp)
+ stt fs1, FPOFF(1)(sp)
+ stt fs2, FPOFF(2)(sp)
+ stt fs3, FPOFF(3)(sp)
+ stt fs4, FPOFF(4)(sp)
+ stt fs5, FPOFF(5)(sp)
+ stt fs6, FPOFF(6)(sp)
+ stt fs7, FPOFF(7)(sp)
+
+ stq sp, 0(a1)
+ ldq sp, 0(a0)
+
+ ldt fs7, FPOFF(7)(sp)
+ ldt fs6, FPOFF(6)(sp)
+ ldt fs5, FPOFF(5)(sp)
+ ldt fs4, FPOFF(4)(sp)
+ ldt fs3, FPOFF(3)(sp)
+ ldt fs2, FPOFF(2)(sp)
+ ldt fs1, FPOFF(1)(sp)
+ ldt fs0, FPOFF(0)(sp)
+
+ ldq t12, INTOFF(8)(sp)
+ ldq s6, INTOFF(7)(sp)
+ ldq s5, INTOFF(6)(sp)
+ ldq s4, INTOFF(5)(sp)
+ ldq s3, INTOFF(4)(sp)
+ ldq s2, INTOFF(3)(sp)
+ ldq s1, INTOFF(2)(sp)
+ ldq s0, INTOFF(1)(sp)
+ ldq ra, INTOFF(0)(sp)
+
+ lda sp,FRAMESIZE(sp)
+
+ RET
+
+ .end _thread_machdep_switch