11.7Spgoyette/* $NetBSD: sunos32_mod.c,v 1.7 2019/12/12 02:15:42 pgoyette Exp $ */ 21.1Sad 31.1Sad/*- 41.1Sad * Copyright (c) 2008 The NetBSD Foundation, Inc. 51.1Sad * All rights reserved. 61.1Sad * 71.1Sad * This code is derived from software developed for The NetBSD Foundation 81.1Sad * by Andrew Doran. 91.1Sad * 101.1Sad * Redistribution and use in source and binary forms, with or without 111.1Sad * modification, are permitted provided that the following conditions 121.1Sad * are met: 131.1Sad * 1. Redistributions of source code must retain the above copyright 141.1Sad * notice, this list of conditions and the following disclaimer. 151.1Sad * 2. Redistributions in binary form must reproduce the above copyright 161.1Sad * notice, this list of conditions and the following disclaimer in the 171.1Sad * documentation and/or other materials provided with the distribution. 181.1Sad * 191.1Sad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 201.1Sad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 211.1Sad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 221.1Sad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 231.1Sad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 241.1Sad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 251.1Sad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 261.1Sad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 271.1Sad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 281.1Sad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 291.1Sad * POSSIBILITY OF SUCH DAMAGE. 301.1Sad */ 311.1Sad 321.1Sad#include <sys/cdefs.h> 331.7Spgoyette__KERNEL_RCSID(0, "$NetBSD: sunos32_mod.c,v 1.7 2019/12/12 02:15:42 pgoyette Exp $"); 341.1Sad 351.1Sad#include <sys/param.h> 361.1Sad#include <sys/module.h> 371.1Sad#include <sys/exec.h> 381.1Sad#include <sys/exec_aout.h> 391.1Sad#include <sys/signalvar.h> 401.4Spgoyette#include <sys/compat_stub.h> 411.1Sad 421.1Sad#include <machine/sunos_machdep.h> 431.1Sad 441.1Sad#include <compat/sunos32/sunos32_exec.h> 451.1Sad 461.1Sad#include <compat/netbsd32/netbsd32_exec.h> 471.1Sad 481.4SpgoyetteMODULE(MODULE_CLASS_EXEC, compat_sunos, 491.5Spgoyette "compat_09,compat_util,compat_netbsd32,exec_aout"); 501.1Sad 511.3Schristosstatic struct execsw sunos_execsw = { 521.3Schristos .es_hdrsz = SUNOS32_AOUT_HDR_SIZE, 531.3Schristos .es_makecmds = exec_sunos32_aout_makecmds, 541.3Schristos .u = { 551.3Schristos .elf_probe_func = NULL, 561.3Schristos }, 571.3Schristos .es_emul = &emul_sunos, 581.3Schristos .es_prio = EXECSW_PRIO_ANY, 591.3Schristos .es_arglen = 0, 601.3Schristos .es_copyargs = netbsd32_copyargs, 611.3Schristos .es_setregs = NULL, 621.3Schristos .es_coredump = coredump_netbsd, 631.3Schristos .es_setup_stack = exec_setup_stack, 641.1Sad}; 651.1Sad 661.1Sadstatic int 671.4Spgoyetteget_sunos_emul(const struct emul **e) 681.4Spgoyette{ 691.4Spgoyette 701.4Spgoyette *e = &emul_sunos; 711.4Spgoyette return 0; 721.4Spgoyette} 731.4Spgoyette 741.4Spgoyettestatic int 751.1Sadcompat_sunos_modcmd(modcmd_t cmd, void *arg) 761.1Sad{ 771.4Spgoyette 781.1Sad switch (cmd) { 791.1Sad case MODULE_CMD_INIT: 801.7Spgoyette MODULE_HOOK_SET(get_emul_sunos_hook, get_sunos_emul); 811.3Schristos return exec_add(&sunos_execsw, 1); 821.4Spgoyette 831.1Sad case MODULE_CMD_FINI: 841.6Spgoyette MODULE_HOOK_UNSET(get_emul_sunos_hook); 851.3Schristos return exec_remove(&sunos_execsw, 1); 861.1Sad 871.1Sad default: 881.1Sad return ENOTTY; 891.1Sad } 901.1Sad} 91