ultrix_mod.c revision 1.6
11.6Spgoyette/*	$NetBSD: ultrix_mod.c,v 1.6 2019/03/03 22:25:00 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#ifdef _KERNEL_OPT
331.1Sad#include "opt_execfmt.h"
341.1Sad#endif
351.1Sad
361.1Sad#include <sys/cdefs.h>
371.6Spgoyette__KERNEL_RCSID(0, "$NetBSD: ultrix_mod.c,v 1.6 2019/03/03 22:25:00 pgoyette Exp $");
381.1Sad
391.1Sad#include <sys/param.h>
401.1Sad#include <sys/module.h>
411.1Sad#include <sys/exec.h>
421.3Sad#include <sys/signalvar.h>
431.1Sad#include <sys/exec_elf.h>
441.3Sad#ifdef EXEC_ECOFF
451.2Scegger#include <sys/exec_ecoff.h>
461.3Sad#endif
471.1Sad
481.1Sad#include <compat/ultrix/ultrix_exec.h>
491.1Sad
501.3Sad#ifdef EXEC_ECOFF
511.3Sad#define	MD1	",exec_ecoff"
521.3Sad#else
531.3Sad#define	MD1	""
541.3Sad#endif
551.3Sad
561.6SpgoyetteMODULE(MODULE_CLASS_EXEC, compat_ultrix, "compat_13" MD1);
571.1Sad
581.1Sadstatic struct execsw ultrix_execsw[] = {
591.3Sad#ifdef EXEC_ECOFF
601.5Schristos	{
611.5Schristos		.es_hdrsz = ECOFF_HDR_SIZE,
621.5Schristos		.es_makecmds = exec_ecoff_makecmds,
631.5Schristos		.u = {
641.5Schristos			.ecoff_probe_func = ultrix_exec_ecoff_probe,
651.5Schristos		},
661.5Schristos		.es_emul = &emul_ultrix,
671.5Schristos		.es_prio = EXECSW_PRIO_LAST,
681.5Schristos		.es_arglen = 0,
691.5Schristos		.es_copyargs = copyargs,
701.5Schristos		.es_setregs = cpu_exec_ecoff_setregs,
711.5Schristos		.es_coredump = coredump_netbsd,
721.5Schristos		.es_setup_stack = exec_setup_stack,
731.5Schristos	},
741.3Sad#endif
751.1Sad};
761.1Sad
771.1Sadstatic int
781.1Sadcompat_ultrix_modcmd(modcmd_t cmd, void *arg)
791.1Sad{
801.1Sad
811.1Sad	switch (cmd) {
821.1Sad	case MODULE_CMD_INIT:
831.1Sad		return exec_add(ultrix_execsw,
841.1Sad		    __arraycount(ultrix_execsw));
851.1Sad
861.1Sad	case MODULE_CMD_FINI:
871.1Sad		return exec_remove(ultrix_execsw,
881.1Sad		    __arraycount(ultrix_execsw));
891.1Sad
901.1Sad	default:
911.1Sad		return ENOTTY;
921.1Sad	}
931.1Sad}
94