diff options
author | David Leonard <d@cvs.openbsd.org> | 2000-10-03 02:44:16 +0000 |
---|---|---|
committer | David Leonard <d@cvs.openbsd.org> | 2000-10-03 02:44:16 +0000 |
commit | acd2343e1542808bb090664d32a2b21ac774b0b4 (patch) | |
tree | 835172e207655463d365ac692bfe20ccfe9b377b /lib | |
parent | 81c593cc04e6d594cfc6f291ee9462df318a5e2d (diff) |
thread switching code
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc_r/arch/mips/uthread_machdep.c | 56 | ||||
-rw-r--r-- | lib/libc_r/arch/mips/uthread_machdep_asm.S | 52 | ||||
-rw-r--r-- | lib/libpthread/arch/mips/uthread_machdep.c | 56 | ||||
-rw-r--r-- | lib/libpthread/arch/mips/uthread_machdep_asm.S | 52 |
4 files changed, 216 insertions, 0 deletions
diff --git a/lib/libc_r/arch/mips/uthread_machdep.c b/lib/libc_r/arch/mips/uthread_machdep.c new file mode 100644 index 00000000000..fdbc4f279d8 --- /dev/null +++ b/lib/libc_r/arch/mips/uthread_machdep.c @@ -0,0 +1,56 @@ +/* $OpenBSD: uthread_machdep.c,v 1.1 2000/10/03 02:44:15 d Exp $ */ +/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ + +/* + * Machine-dependent thread state functions for OpenBSD/mips + */ + +#include <pthread.h> +#include "pthread_private.h" + +#define ALIGNBYTES 0x3 + +struct frame { + int s[9]; /* s0..s7 */ + int _fill; + double f[3]; /* $f0..$f2 */ + int t9; /* XXX only used when bootstrapping */ + int ra; + + int arg[4], cra, cfp; /* ABI space for debuggers */ +}; + +/* + * 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->cra = f->cfp = 0; /* for debugger */ + f->ra = (int)entry; + f->t9 = (int)entry; + + statep->frame = (int)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/mips/uthread_machdep_asm.S b/lib/libc_r/arch/mips/uthread_machdep_asm.S new file mode 100644 index 00000000000..d7fc757f1ba --- /dev/null +++ b/lib/libc_r/arch/mips/uthread_machdep_asm.S @@ -0,0 +1,52 @@ +/* $OpenBSD: uthread_machdep_asm.S,v 1.1 2000/10/03 02:44:15 d Exp $ */ +/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ + +#include <machine/asm.h> + +#define SOFF(n) ((n)*4) +#define FPOFF(n) (SOFF(9) + 4 + (n)*8) +#define REGOFF(n) (FPOFF(3) + (n)*4) + +#define FRAMESIZE (REGOFF(2) + 4*4+4+4) + +NON_LEAF(_thread_machdep_switch, FRAMESIZE, ra) + add sp, sp, -FRAMESIZE + + sw s0, SOFF(0)(sp) + sw s1, SOFF(1)(sp) + sw s2, SOFF(2)(sp) + sw s3, SOFF(3)(sp) + sw s4, SOFF(4)(sp) + sw s5, SOFF(5)(sp) + sw s6, SOFF(6)(sp) + sw s7, SOFF(7)(sp) + sw s8, SOFF(8)(sp) + s.d $f0, FPOFF(0)(sp) /* XXX why? */ + s.d $f2, FPOFF(1)(sp) + s.d $f4, FPOFF(2)(sp) + sw t9, REGOFF(0)(sp) + sw ra, REGOFF(1)(sp) + + sw sp, 0(a1) + lw sp, 0(a0) + + .set noreorder /* avoid nops */ + lw ra, REGOFF(1)(sp) + lw t9, REGOFF(0)(sp) + l.d $f4, FPOFF(2)(sp) + l.d $f2, FPOFF(1)(sp) + l.d $f0, FPOFF(0)(sp) + lw s8, SOFF(8)(sp) + lw s7, SOFF(7)(sp) + lw s6, SOFF(6)(sp) + lw s5, SOFF(5)(sp) + lw s4, SOFF(4)(sp) + lw s3, SOFF(3)(sp) + lw s2, SOFF(2)(sp) + lw s1, SOFF(1)(sp) + lw s0, SOFF(0)(sp) + .set reorder + + add sp, sp, FRAMESIZE + j ra +END(_thread_machdep_switch) diff --git a/lib/libpthread/arch/mips/uthread_machdep.c b/lib/libpthread/arch/mips/uthread_machdep.c new file mode 100644 index 00000000000..fdbc4f279d8 --- /dev/null +++ b/lib/libpthread/arch/mips/uthread_machdep.c @@ -0,0 +1,56 @@ +/* $OpenBSD: uthread_machdep.c,v 1.1 2000/10/03 02:44:15 d Exp $ */ +/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ + +/* + * Machine-dependent thread state functions for OpenBSD/mips + */ + +#include <pthread.h> +#include "pthread_private.h" + +#define ALIGNBYTES 0x3 + +struct frame { + int s[9]; /* s0..s7 */ + int _fill; + double f[3]; /* $f0..$f2 */ + int t9; /* XXX only used when bootstrapping */ + int ra; + + int arg[4], cra, cfp; /* ABI space for debuggers */ +}; + +/* + * 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->cra = f->cfp = 0; /* for debugger */ + f->ra = (int)entry; + f->t9 = (int)entry; + + statep->frame = (int)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/mips/uthread_machdep_asm.S b/lib/libpthread/arch/mips/uthread_machdep_asm.S new file mode 100644 index 00000000000..d7fc757f1ba --- /dev/null +++ b/lib/libpthread/arch/mips/uthread_machdep_asm.S @@ -0,0 +1,52 @@ +/* $OpenBSD: uthread_machdep_asm.S,v 1.1 2000/10/03 02:44:15 d Exp $ */ +/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ + +#include <machine/asm.h> + +#define SOFF(n) ((n)*4) +#define FPOFF(n) (SOFF(9) + 4 + (n)*8) +#define REGOFF(n) (FPOFF(3) + (n)*4) + +#define FRAMESIZE (REGOFF(2) + 4*4+4+4) + +NON_LEAF(_thread_machdep_switch, FRAMESIZE, ra) + add sp, sp, -FRAMESIZE + + sw s0, SOFF(0)(sp) + sw s1, SOFF(1)(sp) + sw s2, SOFF(2)(sp) + sw s3, SOFF(3)(sp) + sw s4, SOFF(4)(sp) + sw s5, SOFF(5)(sp) + sw s6, SOFF(6)(sp) + sw s7, SOFF(7)(sp) + sw s8, SOFF(8)(sp) + s.d $f0, FPOFF(0)(sp) /* XXX why? */ + s.d $f2, FPOFF(1)(sp) + s.d $f4, FPOFF(2)(sp) + sw t9, REGOFF(0)(sp) + sw ra, REGOFF(1)(sp) + + sw sp, 0(a1) + lw sp, 0(a0) + + .set noreorder /* avoid nops */ + lw ra, REGOFF(1)(sp) + lw t9, REGOFF(0)(sp) + l.d $f4, FPOFF(2)(sp) + l.d $f2, FPOFF(1)(sp) + l.d $f0, FPOFF(0)(sp) + lw s8, SOFF(8)(sp) + lw s7, SOFF(7)(sp) + lw s6, SOFF(6)(sp) + lw s5, SOFF(5)(sp) + lw s4, SOFF(4)(sp) + lw s3, SOFF(3)(sp) + lw s2, SOFF(2)(sp) + lw s1, SOFF(1)(sp) + lw s0, SOFF(0)(sp) + .set reorder + + add sp, sp, FRAMESIZE + j ra +END(_thread_machdep_switch) |