Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/usermode Create a ucontext for the system call to w...



details:   https://anonhg.NetBSD.org/src/rev/49469aa4dec6
branches:  trunk
changeset: 769394:49469aa4dec6
user:      reinoud <reinoud%NetBSD.org@localhost>
date:      Thu Sep 08 12:01:22 2011 +0000

description:
Create a ucontext for the system call to work in; its cloned from the new
pcb's call `userland' ucontext.

diffstat:

 sys/arch/usermode/dev/cpu.c          |  19 +++++++++++++++----
 sys/arch/usermode/include/pcb.h      |  14 +++++---------
 sys/arch/usermode/usermode/syscall.c |  10 +++++-----
 3 files changed, 25 insertions(+), 18 deletions(-)

diffs (142 lines):

diff -r 8d172ac24761 -r 49469aa4dec6 sys/arch/usermode/dev/cpu.c
--- a/sys/arch/usermode/dev/cpu.c       Thu Sep 08 12:00:26 2011 +0000
+++ b/sys/arch/usermode/dev/cpu.c       Thu Sep 08 12:01:22 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.34 2011/09/06 09:55:04 jmcneill Exp $ */
+/* $NetBSD: cpu.c,v 1.35 2011/09/08 12:01:22 reinoud Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
 #include "opt_cpu.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.34 2011/09/06 09:55:04 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.35 2011/09/08 12:01:22 reinoud Exp $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
@@ -296,6 +296,7 @@
        panic("%s: shouldn't return", __func__);
 }
 
+extern int syscall(lwp_t *l);
 void
 cpu_lwp_fork(struct lwp *l1, struct lwp *l2, void *stack, size_t stacksize,
     void (*func)(void *), void *arg)
@@ -324,12 +325,23 @@
        if (thunk_getcontext(&pcb2->pcb_ucp))
                panic("getcontext failed");
 
+       /* set up the ucontext for the userland */
        pcb2->pcb_ucp.uc_stack.ss_sp = stack;
        pcb2->pcb_ucp.uc_stack.ss_size = stacksize;
        pcb2->pcb_ucp.uc_link = NULL;
        pcb2->pcb_ucp.uc_flags = _UC_STACK | _UC_CPU;
        thunk_makecontext(&pcb2->pcb_ucp, (void (*)(void))cpu_lwp_trampoline,
            2, func, arg);
+
+       /* set up the ucontext for the syscall */
+       pcb2->pcb_ucp.uc_flags = _UC_CPU;
+       /* hack for it sets the stack anyway!! */
+       pcb2->pcb_syscall_ucp.uc_stack.ss_sp =
+               ((uint8_t *) pcb2->pcb_syscall_ucp.uc_stack.ss_sp) - 4;
+       pcb2->pcb_syscall_ucp.uc_stack.ss_size = 0;
+
+       thunk_makecontext_1(&pcb2->pcb_syscall_ucp, (void (*)(void)) syscall,
+           l2);
 }
 
 void
@@ -337,7 +349,6 @@
 {
 }
 
-int syscall(lwp_t *l, struct trapframe *tr);
 void
 cpu_startup(void)
 {
@@ -355,8 +366,8 @@
        uvm_lwp_setuarea(&lwp0, (vaddr_t)&lwp0pcb);
 
        /* init trapframe (going nowhere!), maybe a panic func? */
-       lwp0pcb.pcb_tf.tf_syscall = syscall;
        memcpy(&lwp0pcb.pcb_userland_ucp, &lwp0pcb.pcb_ucp, sizeof(ucontext_t));
+       memcpy(&lwp0pcb.pcb_syscall_ucp,  &lwp0pcb.pcb_ucp, sizeof(ucontext_t));
 //     thunk_makecontext_trapframe2go(&lwp0pcb.pcb_userland_ucp, NULL, NULL);
 }
 
diff -r 8d172ac24761 -r 49469aa4dec6 sys/arch/usermode/include/pcb.h
--- a/sys/arch/usermode/include/pcb.h   Thu Sep 08 12:00:26 2011 +0000
+++ b/sys/arch/usermode/include/pcb.h   Thu Sep 08 12:01:22 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pcb.h,v 1.10 2011/09/04 21:01:39 reinoud Exp $ */
+/* $NetBSD: pcb.h,v 1.11 2011/09/08 12:01:22 reinoud Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -37,22 +37,18 @@
  * XXX move to frame.h?
  */
 
-/* XXX unused XXX */
-typedef struct trapframe {
-       int             (*tf_syscall)(lwp_t *, struct trapframe *);
-       int              tf_reason;             /* XXX unused */
-       uintptr_t        tf_io[8];              /* to transport info */
-} trapframe_t;
-
+//typedef ucontext_t trapframe;
 
 struct pcb {
        ucontext_t       pcb_ucp;               /* lwp switchframe */
        ucontext_t       pcb_userland_ucp;      /* userland switchframe */
+       ucontext_t       pcb_syscall_ucp;       /* to switch to for syscall */
+
        bool             pcb_needfree;
-       struct trapframe pcb_tf;
        void *           pcb_onfault;           /* on fault handler */
 
        int              pcb_errno;             /* save/restore place */
+       int              pcb_oldspl;
 };
 
 #endif /* !_ARCH_USERMODE_INCLUDE_PCB_H */
diff -r 8d172ac24761 -r 49469aa4dec6 sys/arch/usermode/usermode/syscall.c
--- a/sys/arch/usermode/usermode/syscall.c      Thu Sep 08 12:00:26 2011 +0000
+++ b/sys/arch/usermode/usermode/syscall.c      Thu Sep 08 12:01:22 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: syscall.c,v 1.5 2011/08/29 12:37:20 reinoud Exp $ */
+/* $NetBSD: syscall.c,v 1.6 2011/09/08 12:01:22 reinoud Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.5 2011/08/29 12:37:20 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.6 2011/09/08 12:01:22 reinoud Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -41,7 +41,7 @@
 #include <machine/pcb.h>
 #include <machine/thunk.h>
 
-int syscall(lwp_t *l, struct trapframe *tr);
+extern int syscall(lwp_t *l);
 
 void
 child_return(void *arg)
@@ -60,8 +60,8 @@
 
 
 int
-syscall(lwp_t *l, struct trapframe *tr)
+syscall(lwp_t *l)
 {
-printf("syscall called for lwp %p, trapframe %p!\n", l, tr);
+printf("syscall called for lwp %p!\n", l);
        return ENOENT;
 }



Home | Main Index | Thread Index | Old Index