Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/i386 Add a separate svr4_syscall().



details:   https://anonhg.NetBSD.org/src/rev/2caf54c768ed
branches:  trunk
changeset: 500272:2caf54c768ed
user:      mycroft <mycroft%NetBSD.org@localhost>
date:      Sat Dec 09 06:30:54 2000 +0000

description:
Add a separate svr4_syscall().

diffstat:

 sys/arch/i386/conf/files.i386        |    3 +-
 sys/arch/i386/i386/svr4_syscall.c    |  239 +++++++++++++++++++++++++++++++++++
 sys/arch/i386/include/svr4_machdep.h |    6 +-
 3 files changed, 246 insertions(+), 2 deletions(-)

diffs (278 lines):

diff -r 4f2a27909bfd -r 2caf54c768ed sys/arch/i386/conf/files.i386
--- a/sys/arch/i386/conf/files.i386     Sat Dec 09 06:25:03 2000 +0000
+++ b/sys/arch/i386/conf/files.i386     Sat Dec 09 06:30:54 2000 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.i386,v 1.176 2000/12/02 16:03:23 jdolecek Exp $
+#      $NetBSD: files.i386,v 1.177 2000/12/09 06:30:54 mycroft Exp $
 #
 # new style config file for i386 architecture
 #
@@ -307,6 +307,7 @@
 include "compat/svr4/files.svr4"
 file   arch/i386/i386/svr4_machdep.c           compat_svr4
 file   arch/i386/i386/svr4_sigcode.s           compat_svr4
+file   arch/i386/i386/svr4_syscall.c           compat_svr4
 
 # iBCS-2 binary compatibility (COMPAT_IBCS2)
 include "compat/ibcs2/files.ibcs2"
diff -r 4f2a27909bfd -r 2caf54c768ed sys/arch/i386/i386/svr4_syscall.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/i386/i386/svr4_syscall.c Sat Dec 09 06:30:54 2000 +0000
@@ -0,0 +1,239 @@
+/*     $NetBSD: svr4_syscall.c,v 1.1 2000/12/09 06:30:54 mycroft Exp $ */
+
+/*-
+ * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Charles M. Hannum.
+ *
+ * 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.
+ */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the University of Utah, and William Jolitz.
+ *
+ * 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 University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *     @(#)trap.c      7.4 (Berkeley) 5/13/91
+ */
+
+/*
+ * 386 Trap and System call handling
+ */
+
+#if defined(_KERNEL) && !defined(_LKM)
+#include "opt_syscall_debug.h"
+#include "opt_vm86.h"
+#include "opt_ktrace.h"
+#endif
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/proc.h>
+#include <sys/user.h>
+#include <sys/acct.h>
+#include <sys/kernel.h>
+#include <sys/signal.h>
+#ifdef KTRACE
+#include <sys/ktrace.h>
+#endif
+#include <sys/syscall.h>
+
+#include <uvm/uvm_extern.h>
+
+#include <machine/cpu.h>
+#include <machine/cpufunc.h>
+#include <machine/psl.h>
+#include <machine/reg.h>
+#include <machine/trap.h>
+
+#include <compat/svr4/svr4_syscall.h>
+
+static __inline void userret __P((struct proc *, int, u_quad_t));
+void svr4_syscall __P((struct trapframe *));
+
+/*
+ * Define the code needed before returning to user mode, for
+ * trap and syscall.
+ */
+static __inline void
+userret(p, pc, oticks)
+       register struct proc *p;
+       int pc;
+       u_quad_t oticks;
+{
+       int sig;
+
+       /* Take pending signals. */
+       while ((sig = CURSIG(p)) != 0)
+               postsig(sig);
+
+       /*
+        * If profiling, charge recent system time to the trapped pc.
+        */
+       if (p->p_flag & P_PROFIL) { 
+               extern int psratio;
+
+               addupc_task(p, pc, (int)(p->p_sticks - oticks) * psratio);
+       }                   
+
+       curcpu()->ci_schedstate.spc_curpriority = p->p_priority = p->p_usrpri;
+}
+
+/*
+ * syscall(frame):
+ *     System call request from POSIX system call gate interface to kernel.
+ * Like trap(), argument is call by reference.
+ */
+/*ARGSUSED*/
+void
+svr4_syscall(frame)
+       struct trapframe *frame;
+{
+       register caddr_t params;
+       register const struct sysent *callp;
+       register struct proc *p;
+       int error;
+       size_t argsize;
+       register_t code, args[8], rval[2];
+       u_quad_t sticks;
+
+       p = curproc;
+       sticks = p->p_sticks;
+       code = frame->tf_eax;
+
+       callp = p->p_emul->e_sysent;
+
+       params = (caddr_t)frame->tf_esp + sizeof(int);
+
+#ifdef VM86
+       /*
+        * VM86 mode application found our syscall trap gate by accident; let
+        * it get a SIGSYS and have the VM86 handler in the process take care
+        * of it.
+        */
+       if (frame->tf_eflags & PSL_VM)
+               code = -1;
+       else
+#endif /* VM86 */
+
+       switch (code) {
+       case SYS_syscall:
+               /*
+                * Code is first argument, followed by actual args.
+                */
+               code = fuword(params);
+               params += sizeof(int);
+               break;
+       default:
+               break;
+       }
+       callp += (code & (SVR4_SYS_NSYSENT - 1));
+       argsize = callp->sy_argsize;
+       if (argsize) {
+               error = copyin(params, (caddr_t)args, argsize);
+               if (error)
+                       goto bad;
+       }
+#ifdef SYSCALL_DEBUG
+       scdebug_call(p, code, args);
+#endif /* SYSCALL_DEBUG */
+#ifdef KTRACE
+       if (KTRPOINT(p, KTR_SYSCALL))
+               ktrsyscall(p, code, argsize, args);
+#endif /* KTRACE */
+       rval[0] = 0;
+       rval[1] = 0;
+       error = (*callp->sy_call)(p, args, rval);
+       switch (error) {
+       case 0:
+               frame->tf_eax = rval[0];
+               frame->tf_edx = rval[1];
+               frame->tf_eflags &= ~PSL_C;     /* carry bit */
+               break;
+       case ERESTART:
+               /*
+                * The offset to adjust the PC by depends on whether we entered
+                * the kernel through the trap or call gate.  We pushed the
+                * size of the instruction into tf_err on entry.
+                */
+               frame->tf_eip -= frame->tf_err;
+               break;
+       case EJUSTRETURN:
+               /* nothing to do */
+               break;
+       default:
+       bad:
+               if (p->p_emul->e_errno)
+                       error = p->p_emul->e_errno[error];
+               frame->tf_eax = error;
+               frame->tf_eflags |= PSL_C;      /* carry bit */
+               break;
+       }
+
+#ifdef SYSCALL_DEBUG
+       scdebug_ret(p, code, error, rval);
+#endif /* SYSCALL_DEBUG */
+       userret(p, frame->tf_eip, sticks);
+#ifdef KTRACE
+       if (KTRPOINT(p, KTR_SYSRET))
+               ktrsysret(p, code, error, rval[0]);
+#endif /* KTRACE */
+}
diff -r 4f2a27909bfd -r 2caf54c768ed sys/arch/i386/include/svr4_machdep.h
--- a/sys/arch/i386/include/svr4_machdep.h      Sat Dec 09 06:25:03 2000 +0000
+++ b/sys/arch/i386/include/svr4_machdep.h      Sat Dec 09 06:30:54 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: svr4_machdep.h,v 1.9 1999/01/21 23:11:45 christos Exp $         */
+/*     $NetBSD: svr4_machdep.h,v 1.10 2000/12/09 06:30:54 mycroft Exp $         */
 
 /*-
  * Copyright (c) 1994 The NetBSD Foundation, Inc.
@@ -125,4 +125,8 @@
 #define        SVR4_TRAP_GETHRVTIME    4
 #define        SVR4_TRAP_CLOCK_SETTIME 5
 
+/* i386 has separated svr4_syscall() from syscall() */
+#define SVR4_MACHDEP_HAS_SEPARATED_SYSCALL
+void svr4_syscall __P((struct trapframe *));
+
 #endif /* !_I386_SVR4_MACHDEP_H_ */



Home | Main Index | Thread Index | Old Index