Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/powerpc/powerpc Move child_return back to syscall.c



details:   https://anonhg.NetBSD.org/src/rev/9bcbf54b6ed9
branches:  trunk
changeset: 538809:9bcbf54b6ed9
user:      matt <matt%NetBSD.org@localhost>
date:      Wed Oct 30 18:34:15 2002 +0000

description:
Move child_return back to syscall.c
Fix syscall to use emulations SYS_syscall/SYS___syscall definitions.
Use the emulation NSYSENT to limit code.
Don't define *syscall_fancy if it will never be used.

diffstat:

 sys/arch/powerpc/powerpc/linux_syscall.c |   22 +---
 sys/arch/powerpc/powerpc/mach_syscall.c  |   13 +--
 sys/arch/powerpc/powerpc/syscall.c       |  136 ++++++++++++++++++++----------
 sys/arch/powerpc/powerpc/trap.c          |   30 +------
 4 files changed, 103 insertions(+), 98 deletions(-)

diffs (truncated from 347 to 300 lines):

diff -r c2ae4309f90b -r 9bcbf54b6ed9 sys/arch/powerpc/powerpc/linux_syscall.c
--- a/sys/arch/powerpc/powerpc/linux_syscall.c  Wed Oct 30 18:31:39 2002 +0000
+++ b/sys/arch/powerpc/powerpc/linux_syscall.c  Wed Oct 30 18:34:15 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_syscall.c,v 1.2 2002/10/30 07:39:40 manu Exp $ */
+/*     $NetBSD: linux_syscall.c,v 1.3 2002/10/30 18:34:15 matt Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -36,22 +36,12 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "opt_compat_linux.h"
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: linux_syscall.c,v 1.2 2002/10/30 07:39:40 manu Exp $");
-
-#include <sys/param.h>
-#include <sys/signal.h>
-#include <sys/types.h>
-#include <sys/proc.h>
-
-#include <machine/frame.h>
+__KERNEL_RCSID(0, "$NetBSD: linux_syscall.c,v 1.3 2002/10/30 18:34:15 matt Exp $");
 
-void syscall_fancy __P((struct trapframe *frame));
-void linux_syscall_intern __P((struct proc *p));
+#define EMULNAME(x)    __CONCAT(linux_,x)
+#define EMULNAMEU(x)   __CONCAT(LINUX_,x)
 
-void
-linux_syscall_intern(struct proc *p)
-{
-       p->p_md.md_syscall = syscall_fancy;
-}
+#include "syscall.c"
diff -r c2ae4309f90b -r 9bcbf54b6ed9 sys/arch/powerpc/powerpc/mach_syscall.c
--- a/sys/arch/powerpc/powerpc/mach_syscall.c   Wed Oct 30 18:31:39 2002 +0000
+++ b/sys/arch/powerpc/powerpc/mach_syscall.c   Wed Oct 30 18:34:15 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mach_syscall.c,v 1.1 2002/10/30 06:41:45 manu Exp $ */
+/*     $NetBSD: mach_syscall.c,v 1.2 2002/10/30 18:34:15 matt Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -36,18 +36,13 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "opt_compat_mach.h"
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: mach_syscall.c,v 1.1 2002/10/30 06:41:45 manu Exp $");
-
-#include <sys/param.h>
-#include <sys/signal.h>
-#include <sys/types.h>
-#include <sys/proc.h>
-
-void mach_syscall_intern __P((struct proc *));
+__KERNEL_RCSID(0, "$NetBSD: mach_syscall.c,v 1.2 2002/10/30 18:34:15 matt Exp $");
 
 #define EMULNAME(x)    __CONCAT(mach_,x)
+#define EMULNAMEU(x)   (x)     /* COMPAT_MACH uses the native syscalls */
 #define MACH_SYSCALL
 
 #include "syscall.c"
diff -r c2ae4309f90b -r 9bcbf54b6ed9 sys/arch/powerpc/powerpc/syscall.c
--- a/sys/arch/powerpc/powerpc/syscall.c        Wed Oct 30 18:31:39 2002 +0000
+++ b/sys/arch/powerpc/powerpc/syscall.c        Wed Oct 30 18:34:15 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: syscall.c,v 1.7 2002/10/30 07:39:40 manu Exp $ */
+/*     $NetBSD: syscall.c,v 1.8 2002/10/30 18:34:15 matt Exp $ */
 
 /*
  * Copyright (C) 2002 Matt Thomas
@@ -35,14 +35,11 @@
 #include "opt_altivec.h"
 #include "opt_ktrace.h"
 #include "opt_systrace.h"
-#include "opt_compat_linux.h"
-#include "opt_compat_mach.h"
 #include "opt_multiprocessor.h"
 
 #include <sys/param.h>
 #include <sys/proc.h>
 #include <sys/reboot.h>
-#include <sys/syscall.h>
 #include <sys/systm.h>
 #include <sys/user.h>
 #ifdef KTRACE
@@ -69,6 +66,7 @@
 #endif
 
 #ifdef COMPAT_MACH
+#include <sys/syscall.h>
 #include <compat/mach/mach_syscall.h>
 extern struct sysent mach_sysent[];
 #endif
@@ -78,11 +76,40 @@
 #define        MOREARGS(sp)    ((caddr_t)((uintptr_t)(sp) + 8)) /* more args go here */
 
 #ifndef EMULNAME
+#include <sys/syscall.h>
+
 #define EMULNAME(x)    (x)
+#define EMULNAMEU(x)   (x)
+
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.8 2002/10/30 18:34:15 matt Exp $");
+
+void
+child_return(void *arg)
+{
+       struct proc * const p = arg;
+       struct trapframe * const tf = trapframe(p);
+
+       KERNEL_PROC_UNLOCK(p);
+
+       tf->fixreg[FIRSTARG] = 0;
+       tf->fixreg[FIRSTARG + 1] = 1;
+       tf->cr &= ~0x10000000;
+       tf->srr1 &= ~(PSL_FP|PSL_VEC);  /* Disable FP & AltiVec, as we can't
+                                          be them. */
+       p->p_addr->u_pcb.pcb_fpcpu = NULL;
+#ifdef KTRACE
+       if (KTRPOINT(p, KTR_SYSRET)) {
+               KERNEL_PROC_LOCK(p);
+               ktrsysret(p, SYS_fork, 0, 0);
+               KERNEL_PROC_UNLOCK(p);
+       }
+#endif
+       /* Profiling?                                                   XXX */
+       curcpu()->ci_schedstate.spc_curpriority = p->p_priority;
+}
 #endif
 
-void EMULNAME(syscall_plain)(struct trapframe *frame);
-void EMULNAME(syscall_fancy)(struct trapframe *frame);
+static void EMULNAME(syscall_plain)(struct trapframe *);
 
 void
 EMULNAME(syscall_plain)(struct trapframe *frame)
@@ -95,10 +122,13 @@
        register_t args[10];
        int error;
        int n;
+       int nsysent;
 
        curcpu()->ci_ev_scalls.ev_count++;
 
        code = frame->fixreg[0];
+       params = frame->fixreg + FIRSTARG;
+       n = NARGREG;
 
 #ifdef MACH_SYSCALL
        if (code < 0) {
@@ -107,31 +137,35 @@
 #endif /* DEBUG_MACH */
                code = -code;
                callp = mach_sysent;
+               nsysent = MACH_SYS_NSYSENT;
        } else
 #endif /* MACH_SYSCALL */
+       {
                callp = p->p_emul->e_sysent;
-       params = frame->fixreg + FIRSTARG;
-       n = NARGREG;
+               nsysent = p->p_emul->e_nsysent;
 
-       switch (code) {
-       case SYS_syscall:
-               /*
-                * code is first argument,
-                * followed by actual args.
-                */
-               code = *params++;
-               n -= 1;
-               break;
-       case SYS___syscall:
-               params++;
-               code = *params++;
-               n -= 2;
-               break;
-       default:
-               break;
+               switch (code) {
+               case EMULNAMEU(SYS_syscall):
+                       /*
+                        * code is first argument,
+                        * followed by actual args.
+                        */
+                       code = *params++;
+                       n -= 1;
+                       break;
+#if !defined(COMPAT_LINUX)
+               case EMULNAMEU(SYS___syscall):
+                       params++;
+                       code = *params++;
+                       n -= 2;
+                       break;
+#endif
+               default:
+                       break;
+               }
        }
 
-       code &= (SYS_NSYSENT - 1);
+       code &= (nsysent - 1);
        callp += code;
        argsize = callp->sy_argsize;
 
@@ -186,6 +220,9 @@
        userret(p, frame);
 }
 
+#if defined(KTRACE) || defined(SYSTRACE)
+static void EMULNAME(syscall_fancy)(struct trapframe *);
+
 void
 EMULNAME(syscall_fancy)(struct trapframe *frame)
 {
@@ -197,11 +234,15 @@
        register_t args[10];
        int error;
        int n;
+       int nsysent;
 
        KERNEL_PROC_LOCK(p);
        curcpu()->ci_ev_scalls.ev_count++;
 
        code = frame->fixreg[0];
+       params = frame->fixreg + FIRSTARG;
+       n = NARGREG;
+
 #ifdef MACH_SYSCALL
        if (code < 0) {
 #ifdef DEBUG_MACH
@@ -209,31 +250,35 @@
 #endif /* DEBUG_MACH */
                code = -code;
                callp = mach_sysent;
+               nsysent = MACH_SYS_NSYSENT;
        } else 
 #endif /* MACH_SYSCALL */
+       {
                callp = p->p_emul->e_sysent;
-       params = frame->fixreg + FIRSTARG;
-       n = NARGREG;
+               nsysent = p->p_emul->e_nsysent;
 
-       switch (code) {
-       case SYS_syscall:
-               /*
-                * code is first argument,
-                * followed by actual args.
-                */
-               code = *params++;
-               n -= 1;
-               break;
-       case SYS___syscall:
-               params++;
-               code = *params++;
-               n -= 2;
-               break;
-       default:
-               break;
+               switch (code) {
+               case EMULNAMEU(SYS_syscall):
+                       /*
+                        * code is first argument,
+                        * followed by actual args.
+                        */
+                       code = *params++;
+                       n -= 1;
+                       break;
+#if !defined(COMPAT_LINUX)
+               case EMULNAMEU(SYS___syscall):
+                       params++;
+                       code = *params++;
+                       n -= 2;
+                       break;
+#endif
+               default:
+                       break;
+               }
        }
 
-       code &= (SYS_NSYSENT - 1);
+       code &= (nsysent - 1);
        callp += code;
        argsize = callp->sy_argsize;
 
@@ -281,6 +326,9 @@
        trace_exit(p, code, params, rval, error);
        userret(p, frame);
 }
+#endif /* KTRACE || SYSTRACE */
+
+void EMULNAME(syscall_intern)(struct proc *);



Home | Main Index | Thread Index | Old Index