diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2003-05-27 22:59:34 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2003-05-27 22:59:34 +0000 |
commit | 7ad07aa12e13d7b7755ea924000201c7ba390ad1 (patch) | |
tree | 257ad834322b0f31232eb5e5a8b8d5216472c409 /lib/libpthread | |
parent | a024d638ff76863626d3d8ea492aa9b5e3885684 (diff) |
libpthread support for vax, at last.
Diffstat (limited to 'lib/libpthread')
-rw-r--r-- | lib/libpthread/arch/vax/uthread_machdep.c | 61 | ||||
-rw-r--r-- | lib/libpthread/arch/vax/uthread_machdep_asm.S | 18 |
2 files changed, 66 insertions, 13 deletions
diff --git a/lib/libpthread/arch/vax/uthread_machdep.c b/lib/libpthread/arch/vax/uthread_machdep.c index c441c258994..0315cec578a 100644 --- a/lib/libpthread/arch/vax/uthread_machdep.c +++ b/lib/libpthread/arch/vax/uthread_machdep.c @@ -1,37 +1,72 @@ -/* $OpenBSD: uthread_machdep.c,v 1.1 2003/01/23 02:43:49 marc Exp $ */ -/* PUBLIC DOMAIN <marc@snafu.org> */ +/* $OpenBSD: uthread_machdep.c,v 1.2 2003/05/27 22:59:33 miod Exp $ */ /* - * Machine-dependent thread state functions for OpenBSD/sparc. + * Machine-dependent thread state functions for OpenBSD/vax + * Written by Miodrag Vallat <miod@openbsd.org> - placed in the public domain. */ -#if 0 -#include <sys/types.h> -#include <machine/frame.h> -#include <machine/param.h> #include <pthread.h> #include "pthread_private.h" -#endif + +/* XXX we need <machine/asm.h> but it conflicts with <machine/cdefs.h> */ +#undef _C_LABEL +#undef WEAK_ALIAS +#include <machine/asm.h> + +#define ALIGNBYTES 3 + +struct frame { + /* a CALLS frame */ + long condition; /* sp and fp point here */ + long psw; + long ap; /* r12 */ + long fp; /* r13 */ + long pc; /* r15 */ + long r[10]; /* r2 - r11 */ + long numarg; /* ap points here */ +}; /* - * Given a stack and an entry function, initialise a state + * Given a stack and an entry function, initialize a state * structure that can be later switched to. */ void _thread_machdep_init(struct _machdep_state* statep, void *base, int len, - void (*entry)(void)) + void (*entry)(void)) { - /* XXX implement, please */ + struct frame *f; + + /* Locate the initial frame, aligned at the top of the stack */ + f = (struct frame *)(((long)base + len - sizeof *f) & ~ALIGNBYTES); + + /* Set up initial frame */ + f->condition = 0; + f->psw = (1 << 29) /* CALLS */ | + ((R2|R3|R4|R5|R6|R7|R8|R9|R10|R11) << 16); + f->ap = (long)&f->numarg; + f->fp = (long)f; + + /* + * DANGER WILL ROBINSON! The thread entry point is a CALLS target + * routine, hence it starts with two bytes being the entry + * mask. We rely here upon the following facts: + * - MI code will always pass _thread_start as the entry argument + * - the entry mask for _thread_start is zero (no registers saved) + */ + f->pc = (long)entry + 2; /* skip entry mask */ + f->numarg = 0; /* safety */ + + statep->frame = f->fp; } void _thread_machdep_save_float_state(struct _machdep_state* statep) { - /* XXX implement, please */ + /* nothing to do */ } void _thread_machdep_restore_float_state(struct _machdep_state* statep) { - /* XXX implement, please */ + /* nothing to do */ } diff --git a/lib/libpthread/arch/vax/uthread_machdep_asm.S b/lib/libpthread/arch/vax/uthread_machdep_asm.S new file mode 100644 index 00000000000..b423a08ca93 --- /dev/null +++ b/lib/libpthread/arch/vax/uthread_machdep_asm.S @@ -0,0 +1,18 @@ +/* $OpenBSD: uthread_machdep_asm.S,v 1.1 2003/05/27 22:59:33 miod Exp $ */ + +#include <machine/asm.h> + +/* + * Switch stacks + * Written by Miodrag Vallat <miod@openbsd.org> - placed in the public domain. + */ + +/* void _thread_machdep_switch(new, oldsave); */ +ENTRY(_thread_machdep_switch, R2|R3|R4|R5|R6|R7|R8|R9|R10|R11) + movl 8(ap), r0 /* r0 = oldsave */ + movl fp, 0(r0) /* save fp */ + + movl 4(ap), r0 /* r0 = new */ + movl 0(r0), fp + + ret |