1*8a031a1dSpgoyette /* $NetBSD: sunos_mod.c,v 1.7 2019/12/12 02:15:42 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 #include <sys/cdefs.h>
33*8a031a1dSpgoyette __KERNEL_RCSID(0, "$NetBSD: sunos_mod.c,v 1.7 2019/12/12 02:15:42 pgoyette Exp $");
3492ce8c6aSad
3592ce8c6aSad #include <sys/param.h>
3692ce8c6aSad #include <sys/module.h>
3792ce8c6aSad #include <sys/exec.h>
3892ce8c6aSad #include <sys/exec_aout.h>
3992ce8c6aSad #include <sys/signalvar.h>
40d91f98a8Spgoyette #include <sys/compat_stub.h>
4192ce8c6aSad
4292ce8c6aSad #include <machine/sunos_machdep.h>
4392ce8c6aSad
4492ce8c6aSad #include <compat/sunos/sunos_exec.h>
4592ce8c6aSad
46ffe81881Spgoyette MODULE(MODULE_CLASS_EXEC, compat_sunos, "compat_09,compat_util,exec_aout");
4792ce8c6aSad
4854b7adb1Schristos static struct execsw sunos_execsw = {
4954b7adb1Schristos .es_hdrsz = SUNOS_AOUT_HDR_SIZE,
5054b7adb1Schristos .es_makecmds = exec_sunos_aout_makecmds,
5154b7adb1Schristos .u = {
5254b7adb1Schristos .elf_probe_func = NULL,
5354b7adb1Schristos },
5454b7adb1Schristos .es_emul = &emul_sunos,
5554b7adb1Schristos .es_prio = EXECSW_PRIO_ANY,
5654b7adb1Schristos .es_arglen = 0,
5754b7adb1Schristos .es_copyargs = copyargs,
5854b7adb1Schristos .es_setregs = NULL,
5954b7adb1Schristos .es_coredump = coredump_netbsd,
6054b7adb1Schristos .es_setup_stack = exec_setup_stack,
6192ce8c6aSad };
6292ce8c6aSad
6392ce8c6aSad static int
get_sunos_emul(const struct emul ** e)64d91f98a8Spgoyette get_sunos_emul(const struct emul **e)
65d91f98a8Spgoyette {
66d91f98a8Spgoyette
67d91f98a8Spgoyette *e = &emul_sunos;
68d91f98a8Spgoyette return 0;
69d91f98a8Spgoyette }
70d91f98a8Spgoyette
71d91f98a8Spgoyette static int
compat_sunos_modcmd(modcmd_t cmd,void * arg)7292ce8c6aSad compat_sunos_modcmd(modcmd_t cmd, void *arg)
7392ce8c6aSad {
7492ce8c6aSad
7592ce8c6aSad switch (cmd) {
7692ce8c6aSad case MODULE_CMD_INIT:
77*8a031a1dSpgoyette MODULE_HOOK_SET(get_emul_sunos_hook, get_sunos_emul);
7854b7adb1Schristos return exec_add(&sunos_execsw, 1);
7992ce8c6aSad
8092ce8c6aSad case MODULE_CMD_FINI:
818c2f80f1Spgoyette MODULE_HOOK_UNSET(get_emul_sunos_hook);
8254b7adb1Schristos return exec_remove(&sunos_execsw, 1);
8392ce8c6aSad
8492ce8c6aSad default:
8592ce8c6aSad return ENOTTY;
8692ce8c6aSad }
8792ce8c6aSad }
88