From 0f150e4015fa63b0a030e83d15e1fa79b3048999 Mon Sep 17 00:00:00 2001 From: David Leonard Date: Mon, 25 Sep 2000 05:44:14 +0000 Subject: prepare for thread switching --- lib/libc_r/arch/alpha/uthread_machdep.c | 48 ++++++++++++++++++++++ lib/libc_r/arch/alpha/uthread_machdep_asm.S | 63 +++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 lib/libc_r/arch/alpha/uthread_machdep.c create mode 100644 lib/libc_r/arch/alpha/uthread_machdep_asm.S (limited to 'lib/libc_r/arch') 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, . Public domain. */ + +/* + * Machine-dependent thread state functions for OpenBSD/alpha + */ + +#include +#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, . Public domain. */ + +#include + +#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 -- cgit v1.2.3