Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Unification of the m68k syscall() function.



details:   https://anonhg.NetBSD.org/src/rev/989a4bf72e5f
branches:  trunk
changeset: 500867:989a4bf72e5f
user:      scw <scw%NetBSD.org@localhost>
date:      Tue Dec 19 21:09:54 2000 +0000

description:
Unification of the m68k syscall() function.

diffstat:

 sys/arch/amiga/amiga/trap.c       |  238 +------------------------
 sys/arch/amiga/include/cpu.h      |    7 +-
 sys/arch/atari/atari/trap.c       |  240 +------------------------
 sys/arch/atari/include/cpu.h      |    7 +-
 sys/arch/hp300/hp300/trap.c       |  233 +-----------------------
 sys/arch/hp300/include/cpu.h      |    5 +-
 sys/arch/luna68k/include/cpu.h    |    4 +-
 sys/arch/luna68k/luna68k/trap.c   |  201 ++-------------------
 sys/arch/m68k/conf/files.m68k     |    3 +-
 sys/arch/m68k/include/cpu.h       |   10 +-
 sys/arch/m68k/m68k/m68k_syscall.c |  347 ++++++++++++++++++++++++++++++++++++++
 sys/arch/mac68k/include/cpu.h     |    5 +-
 sys/arch/mac68k/mac68k/trap.c     |  238 +------------------------
 sys/arch/mvme68k/mvme68k/trap.c   |  247 +-------------------------
 sys/arch/news68k/include/cpu.h    |    5 +-
 sys/arch/news68k/news68k/trap.c   |  234 +-----------------------
 sys/arch/next68k/include/cpu.h    |    5 +-
 sys/arch/next68k/next68k/trap.c   |  233 +-----------------------
 sys/arch/sun3/sun3/trap.c         |  247 +-------------------------
 sys/arch/x68k/include/cpu.h       |    5 +-
 sys/arch/x68k/x68k/trap.c         |  233 +-----------------------
 21 files changed, 539 insertions(+), 2208 deletions(-)

diffs (truncated from 3347 to 300 lines):

diff -r 0a4baef5f604 -r 989a4bf72e5f sys/arch/amiga/amiga/trap.c
--- a/sys/arch/amiga/amiga/trap.c       Tue Dec 19 18:12:48 2000 +0000
+++ b/sys/arch/amiga/amiga/trap.c       Tue Dec 19 21:09:54 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.79 2000/11/21 00:37:50 jdolecek Exp $       */
+/*     $NetBSD: trap.c,v 1.80 2000/12/19 21:09:54 scw Exp $    */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -43,12 +43,8 @@
  */
 
 #include "opt_ddb.h"
-#include "opt_syscall_debug.h"
 #include "opt_execfmt.h"
-#include "opt_ktrace.h"
-#include "opt_compat_netbsd.h"
 #include "opt_compat_sunos.h"
-#include "opt_compat_linux.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -59,9 +55,6 @@
 #include <sys/resourcevar.h>
 #include <sys/syslog.h>
 #include <sys/syscall.h>
-#ifdef KTRACE
-#include <sys/ktrace.h>
-#endif
 
 #include <sys/user.h>
 
@@ -82,10 +75,6 @@
 extern struct emul emul_sunos;
 #endif
 
-#ifdef COMPAT_LINUX
-extern struct emul emul_linux;
-#endif
-
 /*
  * XXX Hack until I can figure out what to do about this code's removal
  * from m68k/include/frame.h
@@ -202,7 +191,6 @@
 #include <m68k/db_machdep.h>
 int kdb_trap __P((int, db_regs_t *));
 #endif
-void syscall __P((register_t, struct frame));
 void _wb_fault __P((void));
 
 
@@ -238,6 +226,22 @@
        curcpu()->ci_schedstate.spc_curpriority = p->p_priority;
 }
 
+/*
+ * Used by the common m68k syscall() and child_return() functions.
+ * XXX: Temporary until all m68k ports share common trap()/userret() code.
+ */
+void machine_userret(struct proc *, struct frame *, u_quad_t);
+
+void
+machine_userret(p, f, t)
+       struct proc *p;
+       struct frame *f;
+       u_quad_t t;
+{
+
+       userret(p, f->f_pc, t);
+}
+
 void
 panictrap(type, code, v, fp)
        int type;
@@ -743,214 +747,6 @@
 }
 
 /*
- * Process a system call.
- */
-void
-syscall(code, frame)
-       register_t code;
-       struct frame frame;
-{
-       register caddr_t params;
-       register const struct sysent *callp;
-       register struct proc *p;
-       int error, opc, nsys;
-       size_t argsize;
-       register_t args[8], rval[2];
-       u_quad_t sticks;
-
-       uvmexp.syscalls++;
-       if (!USERMODE(frame.f_sr))
-               panic("syscall");
-       p = curproc;
-       sticks = p->p_sticks;
-       p->p_md.md_regs = frame.f_regs;
-       opc = frame.f_pc;
-
-       nsys = p->p_emul->e_nsysent;
-       callp = p->p_emul->e_sysent;
-#ifdef COMPAT_SUNOS
-       if (p->p_emul == &emul_sunos) {
-
-               /*
-                * SunOS passes the syscall-number on the stack, whereas
-                * BSD passes it in D0. So, we have to get the real "code"
-                * from the stack, and clean up the stack, as SunOS glue
-                * code assumes the kernel pops the syscall argument the
-                * glue pushed on the stack. Sigh...
-                */
-               code = fuword((caddr_t)frame.f_regs[SP]);
-
-               /*
-                * XXX
-                * Don't do this for sunos_sigreturn, as there's no stored pc
-                * on the stack to skip, the argument follows the syscall
-                * number without a gap.
-                */
-               if (code != SUNOS_SYS_sigreturn) {
-                       frame.f_regs[SP] += sizeof (int);
-                       /*
-                        * remember that we adjusted the SP, 
-                        * might have to undo this if the system call
-                        * returns ERESTART.
-                        */
-                       p->p_md.md_flags |= MDP_STACKADJ;
-               } else
-                       p->p_md.md_flags &= ~MDP_STACKADJ;
-       }
-#endif
-
-       params = (caddr_t)frame.f_regs[SP] + sizeof(int);
-
-       switch (code) {
-       case SYS_syscall:
-               /*
-                * Code is first argument, followed by actual args.
-                */
-               code = fuword(params);
-               params += sizeof(int);
-               /*
-                * XXX sigreturn requires special stack manipulation
-                * that is only done if entered via the sigreturn
-                * trap.  Cannot allow it here so make sure we fail.
-                */
-               switch (code) {
-#ifdef COMPAT_13
-               case SYS_compat_13_sigreturn13:
-#endif
-               case SYS___sigreturn14:
-                       code = nsys;
-                       break;
-               }
-               break;
-       case SYS___syscall:
-               /*
-                * Like syscall, but code is a quad, so as to maintain
-                * quad alignment for the rest of the arguments.
-                */
-               if (callp != sysent)
-                       break;
-               code = fuword(params + _QUAD_LOWWORD * sizeof(int));
-               params += sizeof(quad_t);
-               break;
-       default:
-               break;
-       }
-       if (code < 0 || code >= nsys)
-               callp += p->p_emul->e_nosys;            /* illegal */
-       else
-               callp += code;
-       argsize = callp->sy_argsize;
-#ifdef COMPAT_LINUX
-       if (p->p_emul == &emul_linux) {
-               /*
-                * Linux passes the args in d1-d5
-                */
-               switch (argsize) {
-               case 20:
-                       args[4] = frame.f_regs[D5];
-               case 16:
-                       args[3] = frame.f_regs[D4];
-               case 12:
-                       args[2] = frame.f_regs[D3];
-               case 8:
-                       args[1] = frame.f_regs[D2];
-               case 4:
-                       args[0] = frame.f_regs[D1];
-               case 0:
-                       error = 0;
-                       break;
-               default:
-#ifdef DEBUG
-                       panic("linux syscall %d weird argsize %d",
-                               code, argsize);
-#else
-                       error = EINVAL;
-#endif
-                       break;
-               }
-       } else
-#endif
-       if (argsize)
-               error = copyin(params, (caddr_t)args, argsize);
-       else
-               error = 0;
-#ifdef SYSCALL_DEBUG
-       scdebug_call(p, code, args);
-#endif
-#ifdef KTRACE
-       if (KTRPOINT(p, KTR_SYSCALL))
-               ktrsyscall(p, code, argsize, args);
-#endif
-       if (error)
-               goto bad;
-       rval[0] = 0;
-       rval[1] = frame.f_regs[D1];
-       error = (*callp->sy_call)(p, args, rval);
-       switch (error) {
-       case 0:
-               /*
-                * Reinitialize proc pointer `p' as it may be different
-                * if this is a child returning from fork syscall.
-                */
-               p = curproc;
-               frame.f_regs[D0] = rval[0];
-               frame.f_regs[D1] = rval[1];
-               frame.f_sr &= ~PSL_C;   /* carry bit */
-               break;
-       case ERESTART:
-               /*
-                * We always enter through a `trap' instruction, which is 2
-                * bytes, so adjust the pc by that amount.
-                */
-               frame.f_pc = opc - 2;
-               break;
-       case EJUSTRETURN:
-               /* nothing to do */
-               break;
-       default:
-       bad:
-               frame.f_regs[D0] = error;
-               frame.f_sr |= PSL_C;    /* carry bit */
-               break;  
-       }
-
-#ifdef SYSCALL_DEBUG
-       scdebug_ret(p, code, error, rval);
-#endif
-#ifdef COMPAT_SUNOS
-       /* need new p-value for this */
-       if (error == ERESTART && (p->p_md.md_flags & MDP_STACKADJ))
-               frame.f_regs[SP] -= sizeof (int);
-#endif
-       userret(p, frame.f_pc, sticks);
-#ifdef KTRACE
-       if (KTRPOINT(p, KTR_SYSRET))
-               ktrsysret(p, code, error, rval[0]);
-#endif
-}
-
-/*
- * Process the tail end of a fork() for the child
- */
-void
-child_return(arg)
-       void *arg;
-{
-       struct proc *p = arg;
-       /* See cpu_fork() */
-       struct frame *f = (struct frame *)p->p_md.md_regs;
-
-       f->f_regs[D0] = 0;
-       f->f_sr &= ~PSL_C;      /* carry bit */
-
-       userret(p, f->f_pc, p->p_sticks);
-#ifdef KTRACE
-       if (KTRPOINT(p, KTR_SYSRET))
-               ktrsysret(p, SYS_fork, 0, 0);
-#endif
-}
-
-/*
  * Process a pending write back
  */
 int
diff -r 0a4baef5f604 -r 989a4bf72e5f sys/arch/amiga/include/cpu.h
--- a/sys/arch/amiga/include/cpu.h      Tue Dec 19 18:12:48 2000 +0000
+++ b/sys/arch/amiga/include/cpu.h      Tue Dec 19 21:09:54 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.50 2000/08/25 01:04:06 thorpej Exp $ */
+/*     $NetBSD: cpu.h,v 1.51 2000/12/19 21:09:55 scw Exp $     */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -243,11 +243,6 @@
  */



Home | Main Index | Thread Index | Old Index