1*b50e3080Spgoyette /* $NetBSD: ultrix_mod.c,v 1.6 2019/03/03 22:25:00 pgoyette Exp $ */
292ce8c6aSad
392ce8c6aSad /*-
492ce8c6aSad * Copyright (c) 2008 The NetBSD Foundation, Inc.
592ce8c6aSad * All rights reserved.
692ce8c6aSad *
792ce8c6aSad * This code is derived from software developed for The NetBSD Foundation
892ce8c6aSad * by Andrew Doran.
992ce8c6aSad *
1092ce8c6aSad * Redistribution and use in source and binary forms, with or without
1192ce8c6aSad * modification, are permitted provided that the following conditions
1292ce8c6aSad * are met:
1392ce8c6aSad * 1. Redistributions of source code must retain the above copyright
1492ce8c6aSad * notice, this list of conditions and the following disclaimer.
1592ce8c6aSad * 2. Redistributions in binary form must reproduce the above copyright
1692ce8c6aSad * notice, this list of conditions and the following disclaimer in the
1792ce8c6aSad * documentation and/or other materials provided with the distribution.
1892ce8c6aSad *
1992ce8c6aSad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2092ce8c6aSad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2192ce8c6aSad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2292ce8c6aSad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2392ce8c6aSad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2492ce8c6aSad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2592ce8c6aSad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2692ce8c6aSad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2792ce8c6aSad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2892ce8c6aSad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2992ce8c6aSad * POSSIBILITY OF SUCH DAMAGE.
3092ce8c6aSad */
3192ce8c6aSad
3292ce8c6aSad #ifdef _KERNEL_OPT
3392ce8c6aSad #include "opt_execfmt.h"
3492ce8c6aSad #endif
3592ce8c6aSad
3692ce8c6aSad #include <sys/cdefs.h>
37*b50e3080Spgoyette __KERNEL_RCSID(0, "$NetBSD: ultrix_mod.c,v 1.6 2019/03/03 22:25:00 pgoyette Exp $");
3892ce8c6aSad
3992ce8c6aSad #include <sys/param.h>
4092ce8c6aSad #include <sys/module.h>
4192ce8c6aSad #include <sys/exec.h>
4292ce8c6aSad #include <sys/signalvar.h>
431a85128fSad #include <sys/exec_elf.h>
441a85128fSad #ifdef EXEC_ECOFF
451a85128fSad #include <sys/exec_ecoff.h>
461a85128fSad #endif
4792ce8c6aSad
4892ce8c6aSad #include <compat/ultrix/ultrix_exec.h>
4992ce8c6aSad
501a85128fSad #ifdef EXEC_ECOFF
511a85128fSad #define MD1 ",exec_ecoff"
521a85128fSad #else
531a85128fSad #define MD1 ""
541a85128fSad #endif
551a85128fSad
56*b50e3080Spgoyette MODULE(MODULE_CLASS_EXEC, compat_ultrix, "compat_13" MD1);
5792ce8c6aSad
5892ce8c6aSad static struct execsw ultrix_execsw[] = {
591a85128fSad #ifdef EXEC_ECOFF
6054b7adb1Schristos {
6154b7adb1Schristos .es_hdrsz = ECOFF_HDR_SIZE,
6254b7adb1Schristos .es_makecmds = exec_ecoff_makecmds,
6354b7adb1Schristos .u = {
6454b7adb1Schristos .ecoff_probe_func = ultrix_exec_ecoff_probe,
6554b7adb1Schristos },
6654b7adb1Schristos .es_emul = &emul_ultrix,
6754b7adb1Schristos .es_prio = EXECSW_PRIO_LAST,
6854b7adb1Schristos .es_arglen = 0,
6954b7adb1Schristos .es_copyargs = copyargs,
7054b7adb1Schristos .es_setregs = cpu_exec_ecoff_setregs,
7154b7adb1Schristos .es_coredump = coredump_netbsd,
7254b7adb1Schristos .es_setup_stack = exec_setup_stack,
7354b7adb1Schristos },
741a85128fSad #endif
7592ce8c6aSad };
7692ce8c6aSad
7792ce8c6aSad static int
compat_ultrix_modcmd(modcmd_t cmd,void * arg)7892ce8c6aSad compat_ultrix_modcmd(modcmd_t cmd, void *arg)
7992ce8c6aSad {
8092ce8c6aSad
8192ce8c6aSad switch (cmd) {
8292ce8c6aSad case MODULE_CMD_INIT:
8392ce8c6aSad return exec_add(ultrix_execsw,
8492ce8c6aSad __arraycount(ultrix_execsw));
8592ce8c6aSad
8692ce8c6aSad case MODULE_CMD_FINI:
8792ce8c6aSad return exec_remove(ultrix_execsw,
8892ce8c6aSad __arraycount(ultrix_execsw));
8992ce8c6aSad
9092ce8c6aSad default:
9192ce8c6aSad return ENOTTY;
9292ce8c6aSad }
9392ce8c6aSad }
94