Source-Changes-HG archive

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

[src/trunk]: src/sys restructure struct emul and execsw, in preparation to ma...



details:   https://anonhg.NetBSD.org/src/rev/33bca35d905c
branches:  trunk
changeset: 499485:33bca35d905c
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Tue Nov 21 00:37:49 2000 +0000

description:
restructure struct emul and execsw, in preparation to make emulations LKMable:
* move all exec-type specific information from struct emul to execsw[] and
  provide single struct emul per emulation
* elf:
  - kern/exec_elf32.c:probe_funcs[] is gone, execsw[] how has one entry
    per emulation and contains pointer to respective probe function
  - interp is allocated via MALLOC() rather than on stack
  - elf_args structure is allocated via MALLOC() rather than malloc()
* ecoff: the per-emulation hooks moved from alpha and mips specific code
  to OSF1 and Ultrix compat code as appropriate, execsw[] has one entry per
  emulation supporting ecoff with appropriate probe function
* the makecmds/probe functions don't set emulation, pointer to emulation is
  part of appropriate execsw[] entry
* constify couple of structures

diffstat:

 sys/arch/alpha/alpha/machdep.c             |   32 +---
 sys/arch/amiga/amiga/trap.c                |   20 +--
 sys/arch/atari/atari/trap.c                |   20 +--
 sys/arch/hp300/hp300/trap.c                |   20 +--
 sys/arch/i386/i386/trap.c                  |   49 +-----
 sys/arch/mac68k/mac68k/trap.c              |   20 +--
 sys/arch/mips/mips/cpu_exec.c              |   21 +--
 sys/arch/mvme68k/mvme68k/trap.c            |   20 +--
 sys/arch/news68k/news68k/trap.c            |   20 +--
 sys/arch/next68k/next68k/trap.c            |   20 +--
 sys/arch/sparc/sparc/trap.c                |    8 +-
 sys/arch/sun3/sun3/trap.c                  |   20 +--
 sys/arch/x68k/x68k/trap.c                  |   20 +--
 sys/compat/aout/aout_exec.c                |   15 +-
 sys/compat/aout/aout_exec.h                |   39 -----
 sys/compat/freebsd/freebsd_exec.c          |   40 +----
 sys/compat/freebsd/freebsd_exec.h          |    9 +-
 sys/compat/hpux/hpux_exec.c                |   12 +-
 sys/compat/ibcs2/ibcs2_exec.c              |   76 +++-------
 sys/compat/ibcs2/ibcs2_exec.h              |   12 +-
 sys/compat/ibcs2/ibcs2_misc.c              |    8 +-
 sys/compat/linux/arch/i386/linux_exec.h    |    8 +-
 sys/compat/linux/common/linux_exec.c       |   24 +++-
 sys/compat/linux/common/linux_exec.h       |   15 +-
 sys/compat/linux/common/linux_exec_aout.c  |   51 ++-----
 sys/compat/linux/common/linux_exec_elf32.c |   29 +---
 sys/compat/m68k4k/m68k4k_exec.c            |   12 +-
 sys/compat/netbsd32/netbsd32_exec.c        |   28 +---
 sys/compat/netbsd32/netbsd32_exec.h        |    6 +-
 sys/compat/osf1/osf1_exec.c                |   25 +--
 sys/compat/osf1/osf1_exec.h                |   41 +++++
 sys/compat/pecoff/pecoff_exec.c            |   20 +-
 sys/compat/pecoff/pecoff_exec.h            |    6 +-
 sys/compat/sunos/sunos_exec.c              |    5 +-
 sys/compat/svr4/svr4_exec.c                |   17 +-
 sys/compat/svr4/svr4_exec.h                |   15 +-
 sys/compat/ultrix/ultrix_exec.h            |   37 +++++
 sys/compat/ultrix/ultrix_misc.c            |   37 ++++-
 sys/kern/exec_conf.c                       |  204 +++++++++++++++++++++++-----
 sys/kern/exec_ecoff.c                      |    4 +-
 sys/kern/exec_elf32.c                      |  133 +++---------------
 sys/kern/exec_script.c                     |    4 +-
 sys/kern/init_main.c                       |   27 +---
 sys/kern/kern_exec.c                       |   58 ++++++--
 sys/kern/kern_xxx.c                        |   10 +-
 sys/sys/exec.h                             |   23 ++-
 sys/sys/exec_ecoff.h                       |    6 +-
 sys/sys/proc.h                             |   14 +-
 48 files changed, 596 insertions(+), 764 deletions(-)

diffs (truncated from 2877 to 300 lines):

diff -r 7ed985e730f9 -r 33bca35d905c sys/arch/alpha/alpha/machdep.c
--- a/sys/arch/alpha/alpha/machdep.c    Tue Nov 21 00:25:43 2000 +0000
+++ b/sys/arch/alpha/alpha/machdep.c    Tue Nov 21 00:37:49 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.223 2000/11/20 20:37:52 thorpej Exp $ */
+/* $NetBSD: machdep.c,v 1.224 2000/11/21 00:37:49 jdolecek Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.223 2000/11/20 20:37:52 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.224 2000/11/21 00:37:49 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1983,10 +1983,7 @@
        }
 }
 
-#if defined(COMPAT_OSF1) || 1          /* XXX */
-void   cpu_exec_ecoff_setregs __P((struct proc *, struct exec_package *,
-           u_long));
-
+#if 1          /* XXX */
 void
 cpu_exec_ecoff_setregs(p, epp, stack)
        struct proc *p;
@@ -2007,31 +2004,18 @@
  *
  */
 int
-cpu_exec_ecoff_hook(p, epp)
+cpu_exec_ecoff_probe(p, epp)
        struct proc *p;
        struct exec_package *epp;
 {
        struct ecoff_exechdr *execp = (struct ecoff_exechdr *)epp->ep_hdr;
-       extern struct emul emul_netbsd;
        int error;
-       extern int osf1_exec_ecoff_hook(struct proc *p,
-                                       struct exec_package *epp);
 
-       switch (execp->f.f_magic) {
-#ifdef COMPAT_OSF1
-       case ECOFF_MAGIC_ALPHA:
-               error = osf1_exec_ecoff_hook(p, epp);
-               break;
-#endif
+       if (execp->f.f_magic == ECOFF_MAGIC_NETBSD_ALPHA)
+               error = 0;
+       else
+               error = ENOEXEC;
 
-       case ECOFF_MAGIC_NETBSD_ALPHA:
-               epp->ep_emul = &emul_netbsd;
-               error = 0;
-               break;
-
-       default:
-               error = ENOEXEC;
-       }
        return (error);
 }
 #endif
diff -r 7ed985e730f9 -r 33bca35d905c sys/arch/amiga/amiga/trap.c
--- a/sys/arch/amiga/amiga/trap.c       Tue Nov 21 00:25:43 2000 +0000
+++ b/sys/arch/amiga/amiga/trap.c       Tue Nov 21 00:37:49 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.78 2000/06/29 08:44:04 mrg Exp $    */
+/*     $NetBSD: trap.c,v 1.79 2000/11/21 00:37:50 jdolecek Exp $       */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -83,12 +83,7 @@
 #endif
 
 #ifdef COMPAT_LINUX
-#ifdef EXEC_AOUT
-extern struct emul emul_linux_aout;
-#endif
-#ifdef EXEC_ELF32
-extern struct emul emul_linux_elf32;
-#endif
+extern struct emul emul_linux;
 #endif
 
 /*
@@ -756,7 +751,7 @@
        struct frame frame;
 {
        register caddr_t params;
-       register struct sysent *callp;
+       register const struct sysent *callp;
        register struct proc *p;
        int error, opc, nsys;
        size_t argsize;
@@ -846,14 +841,7 @@
                callp += code;
        argsize = callp->sy_argsize;
 #ifdef COMPAT_LINUX
-       if (0
-# ifdef EXEC_AOUT
-           || p->p_emul == &emul_linux_aout
-# endif
-# ifdef EXEC_ELF32
-           || p->p_emul == &emul_linux_elf32
-# endif
-            ) {
+       if (p->p_emul == &emul_linux) {
                /*
                 * Linux passes the args in d1-d5
                 */
diff -r 7ed985e730f9 -r 33bca35d905c sys/arch/atari/atari/trap.c
--- a/sys/arch/atari/atari/trap.c       Tue Nov 21 00:25:43 2000 +0000
+++ b/sys/arch/atari/atari/trap.c       Tue Nov 21 00:37:49 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.54 2000/06/29 08:28:23 mrg Exp $    */
+/*     $NetBSD: trap.c,v 1.55 2000/11/21 00:37:50 jdolecek Exp $       */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -94,12 +94,7 @@
 #endif
 
 #ifdef COMPAT_LINUX
-#ifdef EXEC_AOUT
-extern struct emul emul_linux_aout;
-#endif
-#ifdef EXEC_ELF32
-extern struct emul emul_linux_elf32;
-#endif
+extern struct emul emul_linux;
 #endif
 
 void syscall __P((register_t, struct frame));
@@ -992,7 +987,7 @@
        struct frame frame;
 {
        register caddr_t params;
-       register struct sysent *callp;
+       register const struct sysent *callp;
        register struct proc *p;
        int error, opc, nsys;
        size_t argsize;
@@ -1082,14 +1077,7 @@
                callp += code;
        argsize = callp->sy_argsize;
 #ifdef COMPAT_LINUX
-       if (0
-# ifdef EXEC_AOUT
-           || p->p_emul == &emul_linux_aout
-# endif
-# ifdef EXEC_ELF32
-           || p->p_emul == &emul_linux_elf32
-# endif
-            ) {
+       if (p->p_emul == &emul_linux) {
                /*
                 * Linux passes the args in d1-d5
                 */
diff -r 7ed985e730f9 -r 33bca35d905c sys/arch/hp300/hp300/trap.c
--- a/sys/arch/hp300/hp300/trap.c       Tue Nov 21 00:25:43 2000 +0000
+++ b/sys/arch/hp300/hp300/trap.c       Tue Nov 21 00:37:49 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.81 2000/06/29 08:23:03 mrg Exp $    */
+/*     $NetBSD: trap.c,v 1.82 2000/11/21 00:37:50 jdolecek Exp $       */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -91,12 +91,7 @@
 #endif
 
 #ifdef COMPAT_LINUX
-#ifdef EXEC_AOUT
-extern struct emul emul_linux_aout;
-#endif
-#ifdef EXEC_ELF32
-extern struct emul emul_linux_elf32;
-#endif
+extern struct emul emul_linux;
 #endif
 
 int    writeback __P((struct frame *fp, int docachepush));
@@ -987,7 +982,7 @@
        struct frame frame;
 {
        caddr_t params;
-       struct sysent *callp;
+       struct const sysent *callp;
        struct proc *p;
        int error, opc, nsys;
        size_t argsize;
@@ -1077,14 +1072,7 @@
                callp += code;
        argsize = callp->sy_argsize;
 #ifdef COMPAT_LINUX
-       if (0
-# ifdef EXEC_AOUT
-           || p->p_emul == &emul_linux_aout
-# endif
-# ifdef EXEC_ELF32
-           || p->p_emul == &emul_linux_elf32
-# endif
-            ) {
+       if (p->p_emul == &emul_linux) {
                /*
                 * Linux passes the args in d1-d5
                 */
diff -r 7ed985e730f9 -r 33bca35d905c sys/arch/i386/i386/trap.c
--- a/sys/arch/i386/i386/trap.c Tue Nov 21 00:25:43 2000 +0000
+++ b/sys/arch/i386/i386/trap.c Tue Nov 21 00:37:49 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.140 2000/06/29 08:44:54 mrg Exp $   */
+/*     $NetBSD: trap.c,v 1.141 2000/11/21 00:37:50 jdolecek Exp $      */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -128,31 +128,17 @@
 #include <sys/exec_elf.h>
 #include <compat/ibcs2/ibcs2_errno.h>
 #include <compat/ibcs2/ibcs2_exec.h>
-extern struct emul emul_ibcs2_coff, emul_ibcs2_xout, emul_ibcs2_elf;
+extern struct emul emul_ibcs2;
 #endif
 
 #ifdef COMPAT_LINUX
 # include <sys/exec.h>
 # include <compat/linux/linux_syscall.h>
-
-# ifdef EXEC_AOUT
-extern struct emul emul_linux_aout;
-# endif
-# ifdef EXEC_ELF32
-extern struct emul emul_linux_elf32;
-# endif
-# ifdef EXEC_ELF64
-extern struct emul emul_linux_elf64;
-# endif
+extern struct emul emul_linux;
 #endif /* COMPAT_LINUX */
 
 #ifdef COMPAT_FREEBSD
-# ifdef EXEC_AOUT
-extern struct emul emul_freebsd_aout;
-# endif /* EXEC_AOUT */
-# ifdef EXEC_ELF32
-extern struct emul emul_freebsd_elf32;
-# endif /* EXEC_ELF32 */
+extern struct emul emul_freebsd;
 #endif /* COMPAT_FREEBSD */
 
 #ifdef COMPAT_AOUT
@@ -613,7 +599,7 @@
        struct trapframe frame;
 {
        register caddr_t params;
-       register struct sysent *callp;
+       register const struct sysent *callp;
        register struct proc *p;
        int error, opc, nsys;
        size_t argsize;
@@ -639,35 +625,18 @@
        callp = p->p_emul->e_sysent;
 
 #ifdef COMPAT_LINUX
-       linux = 0
-# ifdef EXEC_AOUT
-           || (p->p_emul == &emul_linux_aout)
-# endif /* EXEC_AOUT */
-# ifdef EXEC_ELF32
-           || (p->p_emul == &emul_linux_elf32)
-# endif /* EXEC_ELF32 */
-# ifdef EXEC_ELF64
-           || (p->p_emul == &emul_linux_elf64)
-# endif /* EXEC_ELF64 */
-           ;
+       linux = (p->p_emul == &emul_linux);
 #endif /* COMPAT_LINUX */
 
 #ifdef COMPAT_FREEBSD
-       freebsd = 0
-# ifdef EXEC_AOUT
-           || (p->p_emul == &emul_freebsd_aout)
-# endif /* EXEC_AOUT */
-# ifdef EXEC_ELF32
-           || (p->p_emul == &emul_freebsd_elf32)
-# endif /* EXEC_ELF32 */
-           ;
+       freebsd = (p->p_emul == &emul_freebsd);
 #endif /* COMPAT_FREEBSD */
 
 #ifdef COMPAT_IBCS2
-       if (p->p_emul == &emul_ibcs2_coff || p->p_emul == &emul_ibcs2_elf ||
-           p->p_emul == &emul_ibcs2_xout)
+       if (p->p_emul == &emul_ibcs2) {
                if (IBCS2_HIGH_SYSCALL(code))
                        code = IBCS2_CVT_HIGH_SYSCALL(code);



Home | Main Index | Thread Index | Old Index