1 /* $NetBSD: compat_stub.h,v 1.25 2020/11/01 18:51:03 pgoyette Exp $ */ 2 3 /*- 4 * Copyright (c) 2018 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to 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 #ifndef _SYS_COMPAT_STUB_H 33 #define _SYS_COMPAT_STUB_H 34 35 #include <sys/module_hook.h> 36 #include <sys/param.h> 37 #include <sys/socket.h> 38 #include <sys/sigtypes.h> 39 40 /* 41 * NOTE: If you make changes here, please remember to update the 42 * kernel version number in sys/param.h to ensure that kernel 43 * and modules stay in sync. 44 */ 45 46 /* 47 * Routine hooks for compat_50___sys_ntp_gettime 48 * 49 * MP-hooks not needed since the NTP code is not modular 50 */ 51 52 struct ntptimeval; 53 struct timex; 54 55 extern void (*vec_ntp_gettime)(struct ntptimeval *); 56 extern int (*vec_ntp_timestatus)(void); 57 extern void (*vec_ntp_adjtime1)(struct timex *); 58 59 /* 60 MODULE_HOOK(ntp_gettime_hook, int, (struct ntptimeval *)); 61 MODULE_HOOK(ntp_timestatus_hook, int, (void); 62 MODULE_HOOK(ntp_adjtime1_hook, int, (struct timex *)); 63 */ 64 65 /* 66 * Routine hooks for SCTP code - used by rtsock 67 * 68 * MP-hooks not needed since the SCTP code is not modular 69 */ 70 struct ifaddr; 71 extern void (*vec_sctp_add_ip_address)(struct ifaddr *); 72 extern void (*vec_sctp_delete_ip_address)(struct ifaddr *); 73 74 /* 75 MODULE_HOOK(sctp_add_ip_address, int, struct ifaddr *); 76 MODULE_HOOK(sctp_delete_ip_address, int, struct ifaddr *); 77 */ 78 79 80 /* 81 * usb devinfo compatibility 82 */ 83 84 struct usbd_device; 85 struct usb_device_info_old; 86 struct usb_event; 87 struct usb_event_old; 88 struct uio; 89 MODULE_HOOK(usb_subr_fill_30_hook, int, 90 (struct usbd_device *, struct usb_device_info_old *, int, 91 void (*)(struct usbd_device *, char *, size_t, char *, size_t, int, int), 92 int (*)(char *, size_t, int))); 93 MODULE_HOOK(usb_subr_copy_30_hook, int, 94 (struct usb_event *, struct usb_event_old *, struct uio *)); 95 96 /* 97 * Routine vector for dev/ccd ioctl() 98 */ 99 100 MODULE_HOOK(ccd_ioctl_60_hook, int, (dev_t, u_long, void *, int, struct lwp *, 101 int (*f)(dev_t, u_long, void *, int, struct lwp *))) 102 103 /* 104 * Routine vector for dev/clockctl ioctl() 105 */ 106 107 MODULE_HOOK(clockctl_ioctl_50_hook, int, 108 (dev_t, u_long, void *, int, struct lwp *)); 109 110 /* 111 * if_sppp device compatibility ioctl subroutine 112 */ 113 114 struct sppp; 115 MODULE_HOOK(sppp_params_50_hook, int, (struct sppp *, u_long, void *)); 116 117 /* 118 * cryptodev compatibility ioctl 119 */ 120 121 struct fcrypt; 122 struct session_op; 123 struct csession; 124 struct crypt_op; 125 struct crypt_n_op; 126 struct kmutex_t; 127 MODULE_HOOK(ocryptof_50_hook, int, (struct file *, u_long, void *)); 128 129 /* 130 * raidframe compatibility 131 */ 132 struct raid_softc; 133 MODULE_HOOK(raidframe_ioctl_50_hook, int, 134 (struct raid_softc *, u_long, void *)); 135 MODULE_HOOK(raidframe_ioctl_80_hook, int, 136 (struct raid_softc *, u_long, void *)); 137 MODULE_HOOK(raidframe_netbsd32_ioctl_hook, int, 138 (struct raid_softc *, u_long, void *)); 139 140 /* 141 * puffs compatibility 142 */ 143 144 struct puffs_req; 145 MODULE_HOOK(puffs_out_50_hook, int, 146 (struct puffs_req *, struct puffs_req **, ssize_t *)); /* outgoing */ 147 MODULE_HOOK(puffs_in_50_hook, void, 148 (struct puffs_req *, struct puffs_req *)); /* incoming */ 149 150 /* 151 * wsevents compatibility 152 */ 153 154 struct wscons_event; 155 struct uio; 156 MODULE_HOOK(wscons_copyout_events_50_hook, int, 157 (const struct wscons_event *, int, struct uio *)); 158 159 /* 160 * sysmon_power compatibility 161 */ 162 163 struct power_event; 164 struct sysmon_pswitch; 165 MODULE_HOOK(compat_sysmon_power_40_hook, void, 166 (struct power_event *, struct sysmon_pswitch *, int)); 167 168 /* 169 * compat_bio indirect function pointer 170 */ 171 172 MODULE_HOOK(compat_bio_30_hook, int, 173 (void *, u_long, void *, int(*)(void *, u_long, void *))); 174 175 /* 176 * vnd_30 ioctl compatibility 177 */ 178 struct vattr; 179 MODULE_HOOK(compat_vndioctl_30_hook, int, (u_long, struct lwp *, void *, int, 180 struct vattr *, int (*)(struct lwp *, void *, int, struct vattr *))); 181 182 /* 183 * vnd_50 ioctl compatibility 184 */ 185 struct vattr; 186 MODULE_HOOK(compat_vndioctl_50_hook, int, (u_long, struct lwp *, void *, int, 187 struct vattr *, int (*)(struct lwp *, void *, int, struct vattr *))); 188 189 /* 190 * ieee80211 ioctl compatibility 191 */ 192 struct ieee80211com; 193 194 MODULE_HOOK(ieee80211_ioctl_20_hook, int, 195 (struct ieee80211com *, u_long, void *)); 196 197 /* 198 * if_43 compatibility 199 */ 200 struct socket; 201 202 MODULE_HOOK(if_cvtcmd_43_hook, int, (u_long *, u_long)); 203 MODULE_HOOK(if_ifioctl_43_hook, int, 204 (struct socket *, u_long, u_long, void *, struct lwp *)); 205 206 /* 207 * if43_cvtcmd_20 compatibility 208 */ 209 MODULE_HOOK(if43_cvtcmd_20_hook, int, (u_long)); 210 211 /* 212 * tty 43 ioctl compatibility 213 */ 214 struct tty; 215 216 MODULE_HOOK(tty_ttioctl_43_hook, int, 217 (struct tty *, u_long, void *, int, struct lwp *)); 218 219 /* 220 * uipc_syscalls_40 compatibility 221 */ 222 223 MODULE_HOOK(uipc_syscalls_40_hook, int, (u_long, void *)); 224 225 /* 226 * uipc_socket_50 compatibility 227 */ 228 struct sockopt; 229 struct mbuf; 230 231 MODULE_HOOK(uipc_socket_50_setopt1_hook, int, 232 (int, struct socket *, const struct sockopt *)); 233 MODULE_HOOK(uipc_socket_50_getopt1_hook, int, 234 (int, struct socket *, struct sockopt *)); 235 MODULE_HOOK(uipc_socket_50_sbts_hook, int, (int, struct mbuf ***)); 236 237 /* 238 * uipc_syscalls_50 compatibility 239 */ 240 241 MODULE_HOOK(uipc_syscalls_50_hook, int, (struct lwp *, u_long, void *)); 242 243 /* 244 * rtsock 14 compatibility 245 */ 246 struct ifnet; 247 struct rt_walkarg; 248 struct rt_addrinfo; 249 MODULE_HOOK(rtsock_oifmsg_14_hook, void, (struct ifnet *)); 250 MODULE_HOOK(rtsock_iflist_14_hook, int, 251 (struct ifnet *, struct rt_walkarg *, struct rt_addrinfo *, size_t)); 252 253 /* 254 * Hooks for rtsock_50 255 */ 256 257 struct rtentry; 258 struct ifaddr; 259 MODULE_HOOK(rtsock_oifmsg_50_hook, void, (struct ifnet *)); 260 MODULE_HOOK(rtsock_iflist_50_hook, int, 261 (struct ifnet *, struct rt_walkarg *, struct rt_addrinfo *, size_t)); 262 MODULE_HOOK(rtsock_rt_missmsg_50_hook, void, 263 (int, const struct rt_addrinfo *, int, int)); 264 MODULE_HOOK(rtsock_rt_ifmsg_50_hook, void, (struct ifnet *)); 265 MODULE_HOOK(rtsock_rt_addrmsg_rt_50_hook, void, 266 (int, struct ifaddr *, int, struct rtentry *)); 267 MODULE_HOOK(rtsock_rt_addrmsg_src_50_hook, void, 268 (int, struct ifaddr *, const struct sockaddr *)); 269 MODULE_HOOK(rtsock_rt_addrmsg_50_hook, void, (int, struct ifaddr *)); 270 MODULE_HOOK(rtsock_rt_ifannouncemsg_50_hook, void, (struct ifnet *, int)); 271 MODULE_HOOK(rtsock_rt_ieee80211msg_50_hook, void, 272 (struct ifnet *, int, void *, size_t)); 273 274 /* 275 * Hooks for rtsock_70 276 */ 277 struct ifaddr; 278 MODULE_HOOK(rtsock_newaddr_70_hook, void, (int, struct ifaddr *)); 279 MODULE_HOOK(rtsock_iflist_70_hook, int, 280 (struct rt_walkarg *, struct ifaddr *, struct rt_addrinfo *)); 281 282 /* 283 * modctl handler for old style OSTAT 284 */ 285 struct iovec; 286 MODULE_HOOK(compat_modstat_80_hook, int, (int, struct iovec *, void *)); 287 288 /* 289 * mask for kern_sig_43's killpg 290 */ 291 extern int kern_sig_43_pgid_mask; 292 293 /* 294 * Hooks for kern_proc.c for netbsd32 compat 295 */ 296 struct ps_strings; 297 MODULE_HOOK(kern_proc32_copyin_hook, int, 298 (struct proc *, struct ps_strings *)); 299 MODULE_HOOK(kern_proc32_base_hook, vaddr_t, (char **, size_t)); 300 301 /* 302 * Hook to allow sparc fpu code to see if a process is using sunos 303 * emulation, and select proper fup codes 304 */ 305 struct emul; 306 MODULE_HOOK(get_emul_sunos_hook, int, (const struct emul **)); 307 308 /* 309 * Hooks for rnd_ioctl_50 310 */ 311 MODULE_HOOK(rnd_ioctl_50_hook, int, (struct file *, u_long, void *)); 312 MODULE_HOOK(rnd_ioctl32_50_hook, int, (struct file *, u_long, void *)); 313 314 /* 315 * Hooks for compat_60 ttioctl and ptmioctl 316 */ 317 MODULE_HOOK(tty_ttioctl_60_hook, int, 318 (struct tty *, u_long, void *, int, struct lwp *)); 319 MODULE_HOOK(tty_ptmioctl_60_hook, int, 320 (dev_t, u_long, void *, int, struct lwp *)); 321 322 /* 323 * Hook for compat_10 openat 324 */ 325 struct pathbuf; 326 MODULE_HOOK(vfs_openat_10_hook, int, (struct pathbuf **)); 327 328 /* 329 * Hook for compat_70_unp_addsockcred 330 */ 331 MODULE_HOOK(uipc_unp_70_hook, struct mbuf *, 332 (struct lwp *, struct mbuf *)); 333 334 /* 335 * Hook for sysvipc50 sysctl 336 */ 337 #include <sys/sysctl.h> 338 MODULE_HOOK(sysvipc_sysctl_50_hook, int, (SYSCTLFN_PROTO)); 339 340 /* 341 * ifmedia_80 compatibility 342 */ 343 344 struct ifmedia; 345 struct ifreq; 346 MODULE_HOOK(ifmedia_80_pre_hook, int, (struct ifreq *, u_long *, bool *)); 347 MODULE_HOOK(ifmedia_80_post_hook, int, (struct ifreq *, u_long)); 348 349 /* 350 * Hook for 32-bit machine name 351 * 352 * This probably would be better placed in compat/netbsd32/netbsd32_mod.c 353 * but the consumer code in linux32_exec_elf32.c is sometimes included in 354 * the main kernel, and not in a compat_netbsd32 module. (In particular, 355 * this is true for i386 and sgimips.) 356 */ 357 struct reg; 358 MODULE_HOOK(netbsd32_machine32_hook, const char *, (void)); 359 MODULE_HOOK(netbsd32_reg_validate_hook, int, 360 (struct lwp *, const struct reg *)); 361 362 /* 363 * Hook for compat_16 sendsig_sigcontext 364 */ 365 struct ksiginfo; 366 MODULE_HOOK(sendsig_sigcontext_16_hook, void, 367 (const struct ksiginfo *, const sigset_t *)); 368 369 /* 370 * Hooks for coredumps 371 */ 372 373 struct uvm_coredump_state; 374 MODULE_HOOK(coredump_hook, int, (struct lwp *, const char *)); 375 MODULE_HOOK(coredump_offset_hook, off_t, (struct coredump_iostate *)); 376 MODULE_HOOK(coredump_write_hook, int, 377 (struct coredump_iostate *, enum uio_seg, const void *, size_t)); 378 MODULE_HOOK(coredump_netbsd_hook, int, 379 (struct lwp *, struct coredump_iostate *)); 380 MODULE_HOOK(coredump_netbsd32_hook, int, 381 (struct lwp *, struct coredump_iostate *)); 382 MODULE_HOOK(coredump_elf32_hook, int, 383 (struct lwp *, struct coredump_iostate *)); 384 MODULE_HOOK(coredump_elf64_hook, int, 385 (struct lwp *, struct coredump_iostate *)); 386 MODULE_HOOK(uvm_coredump_walkmap_hook, int, 387 (struct proc *, int (*)(struct uvm_coredump_state *), void *)); 388 MODULE_HOOK(uvm_coredump_count_segs_hook, int, (struct proc *)); 389 390 /* 391 * Hook for amd64 handler for oosyscall for COMPAT_NETBSD32 && COMPAT_10) 392 */ 393 struct proc; 394 struct trapframe; 395 MODULE_HOOK(amd64_oosyscall_hook, int, (struct proc *, struct trapframe *)); 396 397 #endif /* _SYS_COMPAT_STUB_H */ 398