compat_50_mod.c revision 1.2
1/* $NetBSD: compat_50_mod.c,v 1.2 2019/01/27 02:08:39 pgoyette Exp $ */ 2 3/*- 4 * Copyright (c) 2018 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software developed for The NetBSD Foundation 8 * by Paul Goyette 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32/* 33 * Linkage for the compat module: spaghetti. 34 */ 35 36#include <sys/cdefs.h> 37__KERNEL_RCSID(0, "$NetBSD: compat_50_mod.c,v 1.2 2019/01/27 02:08:39 pgoyette Exp $"); 38 39#if defined(_KERNEL_OPT) 40#include "opt_compat_netbsd.h" 41#endif 42 43#include <sys/systm.h> 44#include <sys/module.h> 45#include <sys/sysctl.h> 46#include <sys/syscall.h> 47#include <sys/syscallvar.h> 48#include <sys/syscallargs.h> 49 50#include <compat/sys/clockctl.h> 51 52#include <compat/common/compat_util.h> 53#include <compat/common/compat_mod.h> 54#include <compat/common/if_spppsubr50.h> 55 56#include <dev/wscons/wsevent_50.h> 57 58#include <fs/puffs/puffs_sys.h> 59 60int 61compat_50_init(void) 62{ 63 int error = 0; 64 65 error = kern_50_init(); 66 if (error != 0) 67 return error; 68 69 error = kern_time_50_init(); 70 if (error != 0) 71 goto err1; 72 73 error = kern_select_50_init(); 74 if (error != 0) 75 goto err2; 76 77 error = vfs_syscalls_50_init(); 78 if (error != 0) 79 goto err3; 80 81 uvm_50_init(); 82 uipc_syscalls_50_init(); 83 clockctl_50_init(); 84 if_spppsubr_50_init(); 85 puffs_50_init(); 86 wsevent_50_init(); 87 vnd_50_init(); 88 rndpseudo_50_init(); 89 rtsock_50_init(); 90 91 return error; 92 93/* If an error occured, undo all previous set-up before returning */ 94 95 err3: 96 kern_select_50_fini(); 97 err2: 98 kern_time_50_fini(); 99 err1: 100 kern_50_fini(); 101 102 return error; 103} 104 105int 106compat_50_fini(void) 107{ 108 int error = 0; 109 110 rtsock_50_fini(); 111 rndpseudo_50_fini(); 112 vnd_50_fini(); 113 wsevent_50_fini(); 114 puffs_50_fini(); 115 if_spppsubr_50_fini(); 116 clockctl_50_fini(); 117 uipc_syscalls_50_fini(); 118 uvm_50_fini(); 119 120 error = vfs_syscalls_50_fini(); 121 if (error != 0) 122 goto err1; 123 124 error = kern_select_50_fini(); 125 if (error != 0) 126 goto err2; 127 128 error = kern_time_50_fini(); 129 if (error != 0) 130 goto err3; 131 132 error = kern_50_fini(); 133 if (error != 0) 134 goto err4; 135 136 return error; 137 138/* If an error occurred while removing something, restore everything! */ 139 err4: 140 kern_time_50_init(); 141 err3: 142 kern_select_50_init(); 143 err2: 144 vfs_syscalls_50_init(); 145 err1: 146 uvm_50_init(); 147 uipc_syscalls_50_init(); 148 clockctl_50_init(); 149 if_spppsubr_50_init(); 150 puffs_50_init(); 151 wsevent_50_init(); 152 vnd_50_init(); 153 rndpseudo_50_init(); 154 rtsock_50_init(); 155 156 return error; 157} 158 159MODULE(MODULE_CLASS_EXEC, compat_50, "compat_60"); 160 161static int 162compat_50_modcmd(modcmd_t cmd, void *arg) 163{ 164 165 switch (cmd) { 166 case MODULE_CMD_INIT: 167 return compat_50_init(); 168 case MODULE_CMD_FINI: 169 return compat_50_fini(); 170 default: 171 return ENOTTY; 172 } 173} 174