Add the VAX versions of these.
This commit is contained in:
parent
8124b6df6c
commit
8c295614ea
|
@ -0,0 +1,86 @@
|
|||
/* $NetBSD: makecontext.c,v 1.1 2003/01/19 19:07:30 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Matt Thomas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: makecontext.c,v 1.1 2003/01/19 19:07:30 matt Exp $");
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <inttypes.h>
|
||||
#include <ucontext.h>
|
||||
#include "extern.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
void
|
||||
makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
|
||||
{
|
||||
__greg_t *gr = ucp->uc_mcontext.__gregs;
|
||||
va_list ap;
|
||||
int *sp;
|
||||
int i;
|
||||
|
||||
/* Compute and align stack pointer. */
|
||||
sp = (int *)
|
||||
(((uintptr_t)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size) & ~0x3);
|
||||
|
||||
/*
|
||||
* Allocate necessary stack space for arguments including arg count
|
||||
* and call frame
|
||||
*/
|
||||
sp -= argc + 1 + 5;
|
||||
|
||||
va_start(ap, argc);
|
||||
sp[5] = argc;
|
||||
for (i = 0; argc > 0; argc--, i++)
|
||||
sp[5 + i] = va_arg(ap, int);
|
||||
va_end(ap);
|
||||
|
||||
sp[0] = 0; /* condition handler is null */
|
||||
sp[1] = 0x20000000; /* make this a CALLS frame */
|
||||
sp[2] = 0; /* saved argument pointer */
|
||||
sp[3] = 0; /* saved frame pointer */
|
||||
sp[4] = (int)_resumecontext; /* return via trampoline code */
|
||||
|
||||
gr[_REG_AP] = (__greg_t)(sp + 5);
|
||||
gr[_REG_SP] = (__greg_t)sp;
|
||||
gr[_REG_FP] = (__greg_t)sp;
|
||||
gr[_REG_PC] = (__greg_t)func+2;
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/* $NetBSD: resumecontext.c,v 1.1 2003/01/19 19:07:30 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Klaus Klein.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: resumecontext.c,v 1.1 2003/01/19 19:07:30 matt Exp $");
|
||||
#endif
|
||||
|
||||
#include "namespace.h"
|
||||
#include <ucontext.h>
|
||||
#include "extern.h"
|
||||
|
||||
void
|
||||
_resumecontext()
|
||||
{
|
||||
ucontext_t uct;
|
||||
|
||||
(void)getcontext(&uct);
|
||||
(void)setcontext(uct.uc_link);
|
||||
/* NOTREACHED */
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/* $NetBSD: swapcontext.S,v 1.1 2003/01/19 19:07:31 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Matt Thomas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "SYS.h"
|
||||
|
||||
ENTRY(swapcontext, 0)
|
||||
chmk $SYS_getcontext /* getcontext(oucp) */
|
||||
jcc 1f
|
||||
jmp CERROR+2 /* badness happened */
|
||||
|
||||
1: movl 4(%ap),%r0
|
||||
movl $5,%r1 /* size of callframe (in LW) */
|
||||
bbc $13,6(%fp),2f /* was this a CALLG? */
|
||||
addl3 (%ap),$(5+1),%r1 /* size of callframe + arglist (LW) */
|
||||
2: movl 8(%fp),(12*4)(%r0) /* restore AP */
|
||||
moval (%sp)[%r1],(13*4)(%r0) /* restore SP */
|
||||
movq 12(%fp),(14*4)(%r0) /* restore FP + PC */
|
||||
|
||||
pushl 8(%ap)
|
||||
calls $1,_C_LABEL(setcontext) /* setcontext(ucp) */
|
||||
ret
|
Loading…
Reference in New Issue