Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/nathanw_sa]: src/lib/libc/arch/alpha/gen Update to/to work with Klaus's ...



details:   https://anonhg.NetBSD.org/src/rev/9dbd52f42809
branches:  nathanw_sa
changeset: 505477:9dbd52f42809
user:      nathanw <nathanw%NetBSD.org@localhost>
date:      Mon Dec 17 22:10:02 2001 +0000

description:
Update to/to work with Klaus's mcontext code.

diffstat:

 lib/libc/arch/alpha/gen/_lwp.c          |  18 ++++---
 lib/libc/arch/alpha/gen/makecontext.c   |  70 +++++++++--------------------
 lib/libc/arch/alpha/gen/resumecontext.c |  56 ++++++++++++++++++++++--
 lib/libc/arch/alpha/gen/swapcontext.S   |  76 ++++++++++++++++++++++++--------
 4 files changed, 141 insertions(+), 79 deletions(-)

diffs (291 lines):

diff -r e7ec1d1771ed -r 9dbd52f42809 lib/libc/arch/alpha/gen/_lwp.c
--- a/lib/libc/arch/alpha/gen/_lwp.c    Mon Dec 17 22:07:49 2001 +0000
+++ b/lib/libc/arch/alpha/gen/_lwp.c    Mon Dec 17 22:10:02 2001 +0000
@@ -1,4 +1,4 @@
-/*     $Id: _lwp.c,v 1.1.2.1 2001/11/17 03:19:29 nathanw Exp $ */
+/*     $Id: _lwp.c,v 1.1.2.2 2001/12/17 22:10:02 nathanw Exp $ */
 
 /* Copyright */
 
@@ -13,18 +13,20 @@
 void _lwp_makecontext(ucontext_t *u, void (*start)(void *),
     void *arg, void *private, caddr_t stack_base, size_t stack_size)
 {
-       unsigned long *gr = u->uc_mcontext.sc_regs;
+       __greg_t *gr;
 
        getcontext(u);
+       gr = u->uc_mcontext.__gregs;
+
        u->uc_link = NULL;
 
        u->uc_stack.ss_sp = stack_base;
        u->uc_stack.ss_size = stack_size;
 
-       u->uc_mcontext.sc_pc = (unsigned long)start;
-       gr[R_T12] = (unsigned long) start;
-       gr[R_RA] = (unsigned long) _lwp_exit;
-       gr[R_A0] = (unsigned long) arg;
-       gr[R_SP] = (unsigned long) (stack_base + stack_size);
-       gr[R_S6] = 0;
+       gr[_REG_PC] = (unsigned long)start;
+       gr[_REG_T12] = (unsigned long) start;
+       gr[_REG_RA] = (unsigned long) _lwp_exit;
+       gr[_REG_A0] = (unsigned long) arg;
+       gr[_REG_SP] = (unsigned long) (stack_base + stack_size);
+       gr[_REG_S6] = 0;
 }
diff -r e7ec1d1771ed -r 9dbd52f42809 lib/libc/arch/alpha/gen/makecontext.c
--- a/lib/libc/arch/alpha/gen/makecontext.c     Mon Dec 17 22:07:49 2001 +0000
+++ b/lib/libc/arch/alpha/gen/makecontext.c     Mon Dec 17 22:10:02 2001 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: makecontext.c,v 1.1.2.1 2001/11/17 03:19:29 nathanw Exp $ */
+/*     $NetBSD: makecontext.c,v 1.1.2.2 2001/12/17 22:10:03 nathanw Exp $      */
 
 /*-
- * Copyright (c) 1999 The NetBSD Foundation, Inc.
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
- * by Nathan J. Williams.
+ * by Klaus Klein.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -38,65 +38,41 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: makecontext.c,v 1.1.2.1 2001/11/17 03:19:29 nathanw Exp $");
+__RCSID("$NetBSD: makecontext.c,v 1.1.2.2 2001/12/17 22:10:03 nathanw Exp $");
 #endif
 
+#include <stddef.h>
 #include <inttypes.h>
-#include <stddef.h>
 #include <ucontext.h>
-#include <machine/reg.h>
 #include "extern.h"
 
-#if __STDC__
 #include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
 
 void
-#if __STDC__
 makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
-#else
-makecontext(ucp, func, argc, va_alist)
-       ucontext_t *ucp;
-       void (*func)();
-       int argc;
-       va_dcl
-#endif
 {
-       unsigned long *gr = ucp->uc_mcontext.sc_regs;
+       __greg_t *gr = ucp->uc_mcontext.__gregs;
+       int i;
        unsigned long *sp;
        va_list ap;
-       int i;
-
-       ucp->uc_mcontext.sc_pc = (unsigned long)func;
-       gr[R_T12] = (unsigned long)func;
-
-       /* LINTED uintptr_t is safe */
-       sp  = (long *)((uintptr_t)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size);
-       /* LINTED uintptr_t is safe */
-       sp  = (long *)((uintptr_t)sp & ~0x7);   /* Align on quad boundary. */
-       if (argc > 6)
-               sp -= (argc - 6);               /* Make room for args. */
-       gr[R_SP] = (unsigned long)sp;
-       gr[R_S6] = (unsigned long)0;    /* Wipe out frame pointer. */
 
-       gr[R_RA] = (unsigned long)_resumecontext;
+       /* Compute and align stack pointer. */
+       sp = (unsigned long *)
+           (((uintptr_t)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size) & ~0x7);
+       /* Allocate necessary stack space for arguments exceeding a0-5. */
+       if (argc > 6)
+               sp -= (argc - 6);
+       gr[_REG_SP] = (__greg_t)sp;
+       /* Arrange for return via the trampoline code. */
+       gr[_REG_RA] = (__greg_t)_resumecontext;
+       gr[_REG_PC] = (__greg_t)func;
 
-       /* Construct argument list. */
-#if __STDC__
        va_start(ap, argc);
-#else
-       va_start(ap);
-#endif
-       for (i = 0; (i < 6) && (i < argc); i++) {
-               /* LINTED uintptr_t is safe */
-               gr[R_A0 + i] = va_arg(ap, uintptr_t);
-       }
-       for ( ; i < argc ; i ++) {
-               /* LINTED uintptr_t is safe */
-               *sp++ = va_arg(ap, uintptr_t);
-       }
+       /* Pass up to six arguments in a0-5. */
+       for (i = 0; i < argc && i < 6; i++)
+               gr[_REG_A0 + i] = va_arg(ap, unsigned long);
+       /* Pass any additional arguments on the stack. */
+       for (argc -= i; argc > 0; argc--)
+               *sp++ = va_arg(ap, unsigned long);
        va_end(ap);
 }
diff -r e7ec1d1771ed -r 9dbd52f42809 lib/libc/arch/alpha/gen/resumecontext.c
--- a/lib/libc/arch/alpha/gen/resumecontext.c   Mon Dec 17 22:07:49 2001 +0000
+++ b/lib/libc/arch/alpha/gen/resumecontext.c   Mon Dec 17 22:10:02 2001 +0000
@@ -1,10 +1,56 @@
-#include <ucontext.h>
+/*     $NetBSD: resumecontext.c,v 1.1.2.2 2001/12/17 22:10:03 nathanw 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.
+ */
 
-void _resumecontext(void)
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: resumecontext.c,v 1.1.2.2 2001/12/17 22:10:03 nathanw Exp $");
+#endif
+
+#include "namespace.h"
+#include <ucontext.h>
+#include "extern.h"
+
+void
+_resumecontext()
 {
-       ucontext_t uc;
+       ucontext_t uct;
 
-       getcontext(&uc);
-       setcontext(uc.uc_link);
+       (void)getcontext(&uct);
+       (void)setcontext(uct.uc_link);
+       /* NOTREACHED */
 }
diff -r e7ec1d1771ed -r 9dbd52f42809 lib/libc/arch/alpha/gen/swapcontext.S
--- a/lib/libc/arch/alpha/gen/swapcontext.S     Mon Dec 17 22:07:49 2001 +0000
+++ b/lib/libc/arch/alpha/gen/swapcontext.S     Mon Dec 17 22:10:02 2001 +0000
@@ -1,23 +1,61 @@
-#include <machine/asm.h>
+/*     $NetBSD: swapcontext.S,v 1.1.2.2 2001/12/17 22:10:03 nathanw Exp $      */
 
-NESTED(swapcontext,2,24,ra,0x00030000,0)
+/*-
+ * 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.h"
+
+NESTED(swapcontext, 2, 24, ra, IM_RA|IM_A0|IM_A1, 0)
        LDGP(pv)
        lda     sp, -24(sp)
-       stq     ra, 0(sp)
-       stq     a0, 8(sp)
-       stq     a1, 16(sp)
-       CALL(getcontext)
-       ldq     a1, 16(sp)
-       ldq     a0, 8(sp)
-       ldq     ra, 0(sp)
-       bne     v0, 2f  
-       stq     ra, 72(a0)              /* Adjust saved pc ... */
-       stq     ra, (88 + 26 * 8)(a0)   /* ... and saved ra */
-       lda     t0, 24(sp)
-       stq     t0, (88 + 30 * 8)(a0)   /* ... and saved sp */
-       mov     a1, a0
-       CALL(setcontext)
-       /* don't check for an error; if we got here, something broke. */
+       stq     ra, (24- 8)(sp)         /* must save ra, oucp, ucp */
+       stq     a0, (24-16)(sp)
+       stq     a1, (24-24)(sp)
+       CALL(_getcontext)               /* getcontext(oucp) */
+       ldq     t0, (24-16)(sp)
+       bne     v0, Lerr
+       ldq     t1, (24- 8)(sp)
+       stq     t1, (56 + 32 * 8)(t0)   /* Adjust saved PC */
+       lda     t1, 24(sp)
+       stq     t1, (56 + 30 * 8)(t0)   /* Adjust saved SP */
+
+       ldq     a0, (24-24)(sp)
+       CALL(setcontext)                /* setcontext(ucp) */
+Lerr:
+       ldq     ra, (24- 8)(sp)
        lda     sp, 24(sp)
-2:     RET
-       END(swapcontext)
\ No newline at end of file
+       RET
+END(swapcontext)



Home | Main Index | Thread Index | Old Index