1*c3850d5fSchristos /* $NetBSD: compat_43_mod.c,v 1.3 2019/01/28 15:46:49 christos Exp $ */
2d91f98a8Spgoyette
3d91f98a8Spgoyette /*-
4d91f98a8Spgoyette * Copyright (c) 2018 The NetBSD Foundation, Inc.
5d91f98a8Spgoyette * All rights reserved.
6d91f98a8Spgoyette *
7d91f98a8Spgoyette * This code is derived from software developed for The NetBSD Foundation
8d91f98a8Spgoyette * by Paul Goyette
9d91f98a8Spgoyette *
10d91f98a8Spgoyette * Redistribution and use in source and binary forms, with or without
11d91f98a8Spgoyette * modification, are permitted provided that the following conditions
12d91f98a8Spgoyette * are met:
13d91f98a8Spgoyette * 1. Redistributions of source code must retain the above copyright
14d91f98a8Spgoyette * notice, this list of conditions and the following disclaimer.
15d91f98a8Spgoyette * 2. Redistributions in binary form must reproduce the above copyright
16d91f98a8Spgoyette * notice, this list of conditions and the following disclaimer in the
17d91f98a8Spgoyette * documentation and/or other materials provided with the distribution.
18d91f98a8Spgoyette *
19d91f98a8Spgoyette * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20d91f98a8Spgoyette * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21d91f98a8Spgoyette * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22d91f98a8Spgoyette * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23d91f98a8Spgoyette * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24d91f98a8Spgoyette * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25d91f98a8Spgoyette * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26d91f98a8Spgoyette * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27d91f98a8Spgoyette * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28d91f98a8Spgoyette * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29d91f98a8Spgoyette * POSSIBILITY OF SUCH DAMAGE.
30d91f98a8Spgoyette */
31d91f98a8Spgoyette
32d91f98a8Spgoyette #include <sys/cdefs.h>
33*c3850d5fSchristos __KERNEL_RCSID(0, "$NetBSD: compat_43_mod.c,v 1.3 2019/01/28 15:46:49 christos Exp $");
34d91f98a8Spgoyette
35d91f98a8Spgoyette #if defined(_KERNEL_OPT)
36d91f98a8Spgoyette #include "opt_compat_netbsd.h"
37d91f98a8Spgoyette #endif
38d91f98a8Spgoyette
39d91f98a8Spgoyette #include <sys/systm.h>
40d91f98a8Spgoyette #include <sys/module.h>
41d91f98a8Spgoyette #include <sys/sysctl.h>
42d91f98a8Spgoyette #include <sys/syscall.h>
43d91f98a8Spgoyette #include <sys/syscallvar.h>
44d91f98a8Spgoyette #include <sys/syscallargs.h>
45d91f98a8Spgoyette
46d91f98a8Spgoyette #include <compat/common/compat_util.h>
47d91f98a8Spgoyette #include <compat/common/compat_mod.h>
48d91f98a8Spgoyette
49d91f98a8Spgoyette int
compat_43_init(void)50d91f98a8Spgoyette compat_43_init(void)
51d91f98a8Spgoyette {
52d91f98a8Spgoyette int error;
53d91f98a8Spgoyette
54d91f98a8Spgoyette error = kern_exit_43_init();
55d91f98a8Spgoyette if (error != 0)
56d91f98a8Spgoyette return error;
57d91f98a8Spgoyette
58d91f98a8Spgoyette error = kern_info_43_init();
59d91f98a8Spgoyette if (error != 0)
60d91f98a8Spgoyette goto out8;
61d91f98a8Spgoyette
62d91f98a8Spgoyette error = kern_resource_43_init();
63d91f98a8Spgoyette if (error != 0)
64d91f98a8Spgoyette goto out7;
65d91f98a8Spgoyette
66d91f98a8Spgoyette error = kern_sig_43_init();
67d91f98a8Spgoyette if (error != 0)
68d91f98a8Spgoyette goto out6;
69d91f98a8Spgoyette
70*c3850d5fSchristos error = kern_tty_43_init();
71d91f98a8Spgoyette if (error != 0)
72d91f98a8Spgoyette goto out5;
73d91f98a8Spgoyette
74d91f98a8Spgoyette error = uipc_syscalls_43_init();
75d91f98a8Spgoyette if (error != 0)
76d91f98a8Spgoyette goto out4;
77d91f98a8Spgoyette
78d91f98a8Spgoyette error = vfs_syscalls_43_init();
79d91f98a8Spgoyette if (error != 0)
80d91f98a8Spgoyette goto out3;
81d91f98a8Spgoyette
82d91f98a8Spgoyette error = vm_43_init();
83d91f98a8Spgoyette if (error != 0)
84d91f98a8Spgoyette goto out2;
85d91f98a8Spgoyette
86d91f98a8Spgoyette error = if_43_init();
87d91f98a8Spgoyette if (error != 0)
88d91f98a8Spgoyette goto out1;
89d91f98a8Spgoyette
90d91f98a8Spgoyette return 0;
91d91f98a8Spgoyette
92d91f98a8Spgoyette out1:
93d91f98a8Spgoyette vm_43_fini();
94d91f98a8Spgoyette out2:
95d91f98a8Spgoyette vfs_syscalls_43_fini();
96d91f98a8Spgoyette out3:
97d91f98a8Spgoyette uipc_syscalls_43_fini();
98d91f98a8Spgoyette out4:
99*c3850d5fSchristos kern_tty_43_fini();
100d91f98a8Spgoyette out5:
101d91f98a8Spgoyette kern_sig_43_fini();
102d91f98a8Spgoyette out6:
103d91f98a8Spgoyette kern_resource_43_fini();
104d91f98a8Spgoyette out7:
105d91f98a8Spgoyette kern_info_43_fini();
106d91f98a8Spgoyette out8:
107d91f98a8Spgoyette kern_exit_43_fini();
108d91f98a8Spgoyette
109d91f98a8Spgoyette return error;
110d91f98a8Spgoyette }
111d91f98a8Spgoyette
112d91f98a8Spgoyette int
compat_43_fini(void)113d91f98a8Spgoyette compat_43_fini(void)
114d91f98a8Spgoyette {
115d91f98a8Spgoyette int error;
116d91f98a8Spgoyette
117d91f98a8Spgoyette error = if_43_fini();
118d91f98a8Spgoyette if (error != 0)
119d91f98a8Spgoyette return error;
120d91f98a8Spgoyette
121d91f98a8Spgoyette error = vm_43_fini();
122d91f98a8Spgoyette if (error != 0)
123d91f98a8Spgoyette goto out8;
124d91f98a8Spgoyette
125d91f98a8Spgoyette error = vfs_syscalls_43_fini();
126d91f98a8Spgoyette if (error != 0)
127d91f98a8Spgoyette goto out7;
128d91f98a8Spgoyette
129d91f98a8Spgoyette error = uipc_syscalls_43_fini();
130d91f98a8Spgoyette if (error != 0)
131d91f98a8Spgoyette goto out6;
132d91f98a8Spgoyette
133*c3850d5fSchristos error = kern_tty_43_fini();
134d91f98a8Spgoyette if (error != 0)
135d91f98a8Spgoyette goto out5;
136d91f98a8Spgoyette
137d91f98a8Spgoyette error = kern_sig_43_fini();
138d91f98a8Spgoyette if (error != 0)
139d91f98a8Spgoyette goto out4;
140d91f98a8Spgoyette
141d91f98a8Spgoyette error = kern_resource_43_fini();
142d91f98a8Spgoyette if (error != 0)
143d91f98a8Spgoyette goto out3;
144d91f98a8Spgoyette
145d91f98a8Spgoyette error = kern_info_43_fini();
146d91f98a8Spgoyette if (error != 0)
147d91f98a8Spgoyette goto out2;
148d91f98a8Spgoyette
149d91f98a8Spgoyette error = kern_exit_43_fini();
150d91f98a8Spgoyette if (error != 0)
151d91f98a8Spgoyette goto out1;
152d91f98a8Spgoyette
153d91f98a8Spgoyette return 0;
154d91f98a8Spgoyette
155d91f98a8Spgoyette out1:
156d91f98a8Spgoyette kern_info_43_init();
157d91f98a8Spgoyette out2:
158d91f98a8Spgoyette kern_resource_43_init();
159d91f98a8Spgoyette out3:
160d91f98a8Spgoyette kern_sig_43_init();
161d91f98a8Spgoyette out4:
162*c3850d5fSchristos kern_tty_43_init();
163d91f98a8Spgoyette out5:
164d91f98a8Spgoyette uipc_syscalls_43_init();
165d91f98a8Spgoyette out6:
166d91f98a8Spgoyette vfs_syscalls_43_init();
167d91f98a8Spgoyette out7:
168d91f98a8Spgoyette vm_43_init();
169d91f98a8Spgoyette out8:
170d91f98a8Spgoyette if_43_init();
171d91f98a8Spgoyette
172d91f98a8Spgoyette return error;
173d91f98a8Spgoyette }
174d91f98a8Spgoyette
175d91f98a8Spgoyette /*
176d91f98a8Spgoyette * XXX We "require" the compat_60 module to ensure proper ordering of
177d91f98a8Spgoyette * XXX vectoring the ttcompatvec replacement routine!
178d91f98a8Spgoyette */
179d91f98a8Spgoyette MODULE(MODULE_CLASS_EXEC, compat_43,
180d91f98a8Spgoyette "compat_sysctl_09_43,compat_util,compat_60");
181d91f98a8Spgoyette
182d91f98a8Spgoyette static int
compat_43_modcmd(modcmd_t cmd,void * arg)183d91f98a8Spgoyette compat_43_modcmd(modcmd_t cmd, void *arg)
184d91f98a8Spgoyette {
185d91f98a8Spgoyette
186d91f98a8Spgoyette switch (cmd) {
187d91f98a8Spgoyette case MODULE_CMD_INIT:
188d91f98a8Spgoyette return compat_43_init();
189d91f98a8Spgoyette case MODULE_CMD_FINI:
190d91f98a8Spgoyette return compat_43_fini();
191d91f98a8Spgoyette default:
192d91f98a8Spgoyette return ENOTTY;
193d91f98a8Spgoyette }
194d91f98a8Spgoyette }
195