xref: /netbsd-src/sys/compat/common/compat_100_mod.c (revision 679926ade63ac409d4a6489ed7b4b76d25a7ef63)
1*679926adSchristos /*	$NetBSD: compat_100_mod.c,v 1.3 2024/05/20 01:30:34 christos Exp $ */
2189762b3Spgoyette 
3189762b3Spgoyette /*-
4189762b3Spgoyette  * Copyright (c) 2019 The NetBSD Foundation, Inc.
5189762b3Spgoyette  * All rights reserved.
6189762b3Spgoyette  *
7189762b3Spgoyette  * This code is derived from software developed for The NetBSD Foundation
8189762b3Spgoyette  * by Paul Goyette
9189762b3Spgoyette  *
10189762b3Spgoyette  * Redistribution and use in source and binary forms, with or without
11189762b3Spgoyette  * modification, are permitted provided that the following conditions
12189762b3Spgoyette  * are met:
13189762b3Spgoyette  * 1. Redistributions of source code must retain the above copyright
14189762b3Spgoyette  *    notice, this list of conditions and the following disclaimer.
15189762b3Spgoyette  * 2. Redistributions in binary form must reproduce the above copyright
16189762b3Spgoyette  *    notice, this list of conditions and the following disclaimer in the
17189762b3Spgoyette  *    documentation and/or other materials provided with the distribution.
18189762b3Spgoyette  *
19189762b3Spgoyette  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20189762b3Spgoyette  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21189762b3Spgoyette  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22189762b3Spgoyette  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23189762b3Spgoyette  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24189762b3Spgoyette  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25189762b3Spgoyette  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26189762b3Spgoyette  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27189762b3Spgoyette  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28189762b3Spgoyette  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29189762b3Spgoyette  * POSSIBILITY OF SUCH DAMAGE.
30189762b3Spgoyette  */
31189762b3Spgoyette 
32189762b3Spgoyette /*
33189762b3Spgoyette  * Linkage for the compat module: spaghetti.
34189762b3Spgoyette  */
35189762b3Spgoyette 
36189762b3Spgoyette #if defined(_KERNEL_OPT)
37189762b3Spgoyette #include "opt_compat_netbsd.h"
38189762b3Spgoyette #endif
39189762b3Spgoyette 
40189762b3Spgoyette #include <sys/cdefs.h>
41*679926adSchristos __KERNEL_RCSID(0, "$NetBSD: compat_100_mod.c,v 1.3 2024/05/20 01:30:34 christos Exp $");
42189762b3Spgoyette 
43189762b3Spgoyette #include <sys/systm.h>
44189762b3Spgoyette #include <sys/module.h>
45189762b3Spgoyette 
46189762b3Spgoyette #include <compat/common/compat_util.h>
47189762b3Spgoyette #include <compat/common/compat_mod.h>
48189762b3Spgoyette 
49189762b3Spgoyette int
compat_100_init(void)50189762b3Spgoyette compat_100_init(void)
51189762b3Spgoyette {
52*679926adSchristos 	int error;
53189762b3Spgoyette 
54*679926adSchristos 	error = kern_event_100_init();
55*679926adSchristos 	if (error)
56*679926adSchristos 		return error;
57*679926adSchristos 	return sys_descrip_100_init();
58189762b3Spgoyette }
59189762b3Spgoyette 
60189762b3Spgoyette int
compat_100_fini(void)61189762b3Spgoyette compat_100_fini(void)
62189762b3Spgoyette {
63*679926adSchristos 	int error;
64189762b3Spgoyette 
65*679926adSchristos 	error = kern_event_100_fini();
66*679926adSchristos 	if (error)
67*679926adSchristos 		return error;
68*679926adSchristos 	return sys_descrip_100_fini();
69189762b3Spgoyette }
70189762b3Spgoyette 
71189762b3Spgoyette MODULE(MODULE_CLASS_EXEC, compat_100, NULL);
72189762b3Spgoyette 
73189762b3Spgoyette static int
compat_100_modcmd(modcmd_t cmd,void * arg)74189762b3Spgoyette compat_100_modcmd(modcmd_t cmd, void *arg)
75189762b3Spgoyette {
76189762b3Spgoyette 
77189762b3Spgoyette 	switch (cmd) {
78189762b3Spgoyette 	case MODULE_CMD_INIT:
79189762b3Spgoyette 		return compat_100_init();
80189762b3Spgoyette 
81189762b3Spgoyette 	case MODULE_CMD_FINI:
82189762b3Spgoyette 		return compat_100_fini();
83189762b3Spgoyette 
84189762b3Spgoyette 	default:
85189762b3Spgoyette 		return ENOTTY;
86189762b3Spgoyette 	}
87189762b3Spgoyette }
88