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