1*4be362dbSpgoyette /* $NetBSD: compat_stub.c,v 1.23 2023/12/09 15:21:01 pgoyette Exp $ */ 2d91f98a8Spgoyette 3d91f98a8Spgoyette /*- 4d91f98a8Spgoyette * Copyright (c) 2018 The NetBSD Foundation, Inc. 5d91f98a8Spgoyette * All rights reserved. 6d91f98a8Spgoyette * 7d91f98a8Spgoyette * This code is derived from software contributed to 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> 33d91f98a8Spgoyette 34d91f98a8Spgoyette #ifdef _KERNEL_OPT 35d91f98a8Spgoyette #include "opt_ntp.h" 36d91f98a8Spgoyette #endif 37d91f98a8Spgoyette 38d91f98a8Spgoyette #include <sys/systm.h> 39d91f98a8Spgoyette #include <sys/compat_stub.h> 40d91f98a8Spgoyette 41d91f98a8Spgoyette #ifdef NTP 42d91f98a8Spgoyette #include <sys/timespec.h> 43d91f98a8Spgoyette #include <sys/timex.h> 44d91f98a8Spgoyette #endif 45d91f98a8Spgoyette 46d91f98a8Spgoyette /* 47d91f98a8Spgoyette * Routine vectors for compat_50___sys_ntp_gettime 48d91f98a8Spgoyette * 49d91f98a8Spgoyette * MP-hooks not needed since the NTP code is not modular 50d91f98a8Spgoyette */ 51d91f98a8Spgoyette 52d91f98a8Spgoyette #ifdef NTP 53d91f98a8Spgoyette void (*vec_ntp_gettime)(struct ntptimeval *) = ntp_gettime; 54d91f98a8Spgoyette int (*vec_ntp_timestatus)(void) = ntp_timestatus; 55d91f98a8Spgoyette void (*vec_ntp_adjtime1)(struct timex *) = ntp_adjtime1; 56d91f98a8Spgoyette #else 57d91f98a8Spgoyette void (*vec_ntp_gettime)(struct ntptimeval *) = NULL; 58d91f98a8Spgoyette int (*vec_ntp_timestatus)(void) = NULL; 59d91f98a8Spgoyette void (*vec_ntp_adjtime1)(struct timex *) = NULL; 60d91f98a8Spgoyette #endif 61d91f98a8Spgoyette 62d91f98a8Spgoyette /* 63d91f98a8Spgoyette * Routine vectors for sctp (called from within rtsock) 64d91f98a8Spgoyette * 65d91f98a8Spgoyette * MP-hooks not needed since the SCTP code is not modular 6640a27fe7Spgoyette * 6740a27fe7Spgoyette * For now, just point these at NULL. Network initialization code 6840a27fe7Spgoyette * in if.c will overwrite these with correct values. This is needed 6940a27fe7Spgoyette * to enable building of rumpkern library without creating circular 7040a27fe7Spgoyette * dependency with rumpnet library 71d91f98a8Spgoyette */ 72d91f98a8Spgoyette 73d91f98a8Spgoyette void (*vec_sctp_add_ip_address)(struct ifaddr *) = NULL; 74d91f98a8Spgoyette void (*vec_sctp_delete_ip_address)(struct ifaddr *) = NULL; 75d91f98a8Spgoyette 76d91f98a8Spgoyette 77d91f98a8Spgoyette /* 786584ea56Sandvar * usb device_info compatibility 79d91f98a8Spgoyette */ 80c1283e70Spgoyette struct usb_subr_fill_30_hook_t usb_subr_fill_30_hook; 81c1283e70Spgoyette struct usb_subr_copy_30_hook_t usb_subr_copy_30_hook; 82d91f98a8Spgoyette 83d91f98a8Spgoyette /* 846584ea56Sandvar * ccd device compatibility ioctl 85d91f98a8Spgoyette */ 86d91f98a8Spgoyette 87d91f98a8Spgoyette struct ccd_ioctl_60_hook_t ccd_ioctl_60_hook; 88d91f98a8Spgoyette 89d91f98a8Spgoyette /* 906584ea56Sandvar * clockctl device compatibility ioctl 91d91f98a8Spgoyette */ 92d91f98a8Spgoyette 93d91f98a8Spgoyette struct clockctl_ioctl_50_hook_t clockctl_ioctl_50_hook; 94d91f98a8Spgoyette 95d91f98a8Spgoyette /* 966584ea56Sandvar * if_sppp device compatibility ioctl subroutine 97d91f98a8Spgoyette */ 98d91f98a8Spgoyette 99d91f98a8Spgoyette struct sppp_params_50_hook_t sppp_params_50_hook; 100d91f98a8Spgoyette 101d91f98a8Spgoyette /* 1026584ea56Sandvar * cryptodev compatibility ioctl 103d91f98a8Spgoyette */ 104d91f98a8Spgoyette 105d91f98a8Spgoyette struct ocryptof_50_hook_t ocryptof_50_hook; 106d91f98a8Spgoyette 107d91f98a8Spgoyette /* 1086584ea56Sandvar * raidframe compatibility 109d91f98a8Spgoyette */ 110c1283e70Spgoyette struct raidframe_ioctl_50_hook_t raidframe_ioctl_50_hook; 111c1283e70Spgoyette struct raidframe_ioctl_80_hook_t raidframe_ioctl_80_hook; 112728e0675Schristos struct raidframe_netbsd32_ioctl_hook_t raidframe_netbsd32_ioctl_hook; 113d91f98a8Spgoyette 114d91f98a8Spgoyette /* 1156584ea56Sandvar * puffs compatibility 116d91f98a8Spgoyette */ 117d91f98a8Spgoyette 118c1283e70Spgoyette struct puffs_out_50_hook_t puffs_out_50_hook; 119c1283e70Spgoyette struct puffs_in_50_hook_t puffs_in_50_hook; 120d91f98a8Spgoyette 121d91f98a8Spgoyette /* 1226584ea56Sandvar * wsevents compatibility 123d91f98a8Spgoyette */ 124c1283e70Spgoyette struct wscons_copyout_events_50_hook_t wscons_copyout_events_50_hook; 125d91f98a8Spgoyette 126d91f98a8Spgoyette /* 1276584ea56Sandvar * sysmon_power compatibility 128d91f98a8Spgoyette */ 129d91f98a8Spgoyette struct compat_sysmon_power_40_hook_t compat_sysmon_power_40_hook; 130d91f98a8Spgoyette 131d91f98a8Spgoyette /* 1326584ea56Sandvar * compat_bio compatibility 133d91f98a8Spgoyette */ 134d91f98a8Spgoyette struct compat_bio_30_hook_t compat_bio_30_hook; 135d91f98a8Spgoyette 136d91f98a8Spgoyette /* 1376584ea56Sandvar * vnd ioctl compatibility 138d91f98a8Spgoyette */ 139d91f98a8Spgoyette struct compat_vndioctl_30_hook_t compat_vndioctl_30_hook; 140d91f98a8Spgoyette struct compat_vndioctl_50_hook_t compat_vndioctl_50_hook; 141d91f98a8Spgoyette 142d91f98a8Spgoyette /* 1436584ea56Sandvar * ieee80211 ioctl compatibility 144d91f98a8Spgoyette */ 145c1283e70Spgoyette struct ieee80211_ioctl_20_hook_t ieee80211_ioctl_20_hook; 146d91f98a8Spgoyette 147d91f98a8Spgoyette /* 1486584ea56Sandvar * if_43 compatibility 149d91f98a8Spgoyette */ 150c1283e70Spgoyette struct if_cvtcmd_43_hook_t if_cvtcmd_43_hook; 151c1283e70Spgoyette struct if_ifioctl_43_hook_t if_ifioctl_43_hook; 152d91f98a8Spgoyette 153d91f98a8Spgoyette /* 1546584ea56Sandvar * if43_cvtcmd_20 compatibility 155d91f98a8Spgoyette */ 156d35e6441Spgoyette struct if43_cvtcmd_20_hook_t if43_cvtcmd_20_hook; 157d91f98a8Spgoyette 158d91f98a8Spgoyette /* 159c3850d5fSchristos * tty 43 ioctl compatibility 160c3850d5fSchristos */ 161c1283e70Spgoyette struct tty_ttioctl_43_hook_t tty_ttioctl_43_hook; 162c3850d5fSchristos 163c3850d5fSchristos /* 16468c01b4bSpgoyette * uipc_syscalls_40 compatibility 165d91f98a8Spgoyette */ 166d91f98a8Spgoyette struct uipc_syscalls_40_hook_t uipc_syscalls_40_hook; 167d91f98a8Spgoyette 168d91f98a8Spgoyette /* 16968c01b4bSpgoyette * uipc_socket_50 compatibility 17068c01b4bSpgoyette */ 17168c01b4bSpgoyette struct uipc_socket_50_setopt1_hook_t uipc_socket_50_setopt1_hook; 17268c01b4bSpgoyette struct uipc_socket_50_getopt1_hook_t uipc_socket_50_getopt1_hook; 17368c01b4bSpgoyette struct uipc_socket_50_sbts_hook_t uipc_socket_50_sbts_hook; 17468c01b4bSpgoyette 17568c01b4bSpgoyette /* 1766584ea56Sandvar * uipc_syscalls_50 compatibility 177d91f98a8Spgoyette */ 178d91f98a8Spgoyette struct uipc_syscalls_50_hook_t uipc_syscalls_50_hook; 179d91f98a8Spgoyette 180d91f98a8Spgoyette /* 1816584ea56Sandvar * rtsock 14 compatibility 182d91f98a8Spgoyette */ 183c1283e70Spgoyette struct rtsock_oifmsg_14_hook_t rtsock_oifmsg_14_hook; 184c1283e70Spgoyette struct rtsock_iflist_14_hook_t rtsock_iflist_14_hook; 185d91f98a8Spgoyette 186d91f98a8Spgoyette /* 1876584ea56Sandvar * rtsock 50 compatibility 188d91f98a8Spgoyette */ 189c1283e70Spgoyette struct rtsock_iflist_50_hook_t rtsock_iflist_50_hook; 190c1283e70Spgoyette struct rtsock_oifmsg_50_hook_t rtsock_oifmsg_50_hook; 191c1283e70Spgoyette struct rtsock_rt_missmsg_50_hook_t rtsock_rt_missmsg_50_hook; 192c1283e70Spgoyette struct rtsock_rt_ifmsg_50_hook_t rtsock_rt_ifmsg_50_hook; 193c1283e70Spgoyette struct rtsock_rt_ifannouncemsg_50_hook_t rtsock_rt_ifannouncemsg_50_hook; 1944af7afb8Sroy struct rtsock_rt_addrmsg_rt_50_hook_t rtsock_rt_addrmsg_rt_50_hook; 1952e9156b7Sroy struct rtsock_rt_addrmsg_src_50_hook_t rtsock_rt_addrmsg_src_50_hook; 1964af7afb8Sroy struct rtsock_rt_addrmsg_50_hook_t rtsock_rt_addrmsg_50_hook; 197c1283e70Spgoyette struct rtsock_rt_ieee80211msg_50_hook_t rtsock_rt_ieee80211msg_50_hook; 198d91f98a8Spgoyette 199d91f98a8Spgoyette /* 2006584ea56Sandvar * rtsock 70 compatibility 201d91f98a8Spgoyette */ 202c1283e70Spgoyette struct rtsock_newaddr_70_hook_t rtsock_newaddr_70_hook; 203c1283e70Spgoyette struct rtsock_iflist_70_hook_t rtsock_iflist_70_hook; 204d91f98a8Spgoyette 205d91f98a8Spgoyette /* 206d91f98a8Spgoyette * modctl handler for old style OSTAT 207d91f98a8Spgoyette */ 208d91f98a8Spgoyette struct compat_modstat_80_hook_t compat_modstat_80_hook; 209d91f98a8Spgoyette 210d91f98a8Spgoyette /* 211d91f98a8Spgoyette * mask for kern_sig_43's killpg (updated by compat_09) 212d91f98a8Spgoyette */ 213d91f98a8Spgoyette int kern_sig_43_pgid_mask = ~0; 214d91f98a8Spgoyette 215d91f98a8Spgoyette /* 216d91f98a8Spgoyette * hook for kern_proc_32 217d91f98a8Spgoyette */ 218c1283e70Spgoyette struct kern_proc32_copyin_hook_t kern_proc32_copyin_hook; 219c1283e70Spgoyette struct kern_proc32_base_hook_t kern_proc32_base_hook; 220d91f98a8Spgoyette 221d91f98a8Spgoyette /* 222d91f98a8Spgoyette * Hook for sparc fpu code to check if a process is running 223d91f98a8Spgoyette * under sunos emulation 224d91f98a8Spgoyette */ 225d91f98a8Spgoyette struct get_emul_sunos_hook_t get_emul_sunos_hook; 226d91f98a8Spgoyette 227d91f98a8Spgoyette /* 228d91f98a8Spgoyette * Hook for rnd_ioctl_50 callbacks 229d91f98a8Spgoyette */ 230d91f98a8Spgoyette struct rnd_ioctl_50_hook_t rnd_ioctl_50_hook; 231c1283e70Spgoyette struct rnd_ioctl32_50_hook_t rnd_ioctl32_50_hook; 232d91f98a8Spgoyette 233d91f98a8Spgoyette /* 234d91f98a8Spgoyette * Hooks for compat_60 ttioctl and ptmioctl 235d91f98a8Spgoyette */ 236c1283e70Spgoyette struct tty_ttioctl_60_hook_t tty_ttioctl_60_hook; 237c1283e70Spgoyette struct tty_ptmioctl_60_hook_t tty_ptmioctl_60_hook; 238d91f98a8Spgoyette 239d91f98a8Spgoyette /* 240d91f98a8Spgoyette * Hook for compat_10 openat 241d91f98a8Spgoyette */ 242c1283e70Spgoyette struct vfs_openat_10_hook_t vfs_openat_10_hook; 243d91f98a8Spgoyette 244d91f98a8Spgoyette /* 245d91f98a8Spgoyette * Hook for compat_70_unp_addsockcred 246d91f98a8Spgoyette */ 247c1283e70Spgoyette struct uipc_unp_70_hook_t uipc_unp_70_hook; 248d91f98a8Spgoyette 249d91f98a8Spgoyette /* 250d91f98a8Spgoyette * Hook for sysvipc50_sysctl 251d91f98a8Spgoyette */ 252c1283e70Spgoyette struct sysvipc_sysctl_50_hook_t sysvipc_sysctl_50_hook; 253d91f98a8Spgoyette 254d91f98a8Spgoyette /* 2556584ea56Sandvar * ifmedia_80 compatibility 256bf354a07Smsaitoh */ 257bf354a07Smsaitoh struct ifmedia_80_pre_hook_t ifmedia_80_pre_hook; 258bf354a07Smsaitoh struct ifmedia_80_post_hook_t ifmedia_80_post_hook; 259bf354a07Smsaitoh 260bf354a07Smsaitoh /* 261d91f98a8Spgoyette * Hook for 32-bit machine name 262d91f98a8Spgoyette * 263d91f98a8Spgoyette * This probably would be better placed in compat/netbsd32/netbsd32_mod.c 264d91f98a8Spgoyette * but the consumer code in linux32_exec_elf32.c is sometimes included in 265d91f98a8Spgoyette * the main kernel, and not in a compat_netbsd32 module. (In particular, 266d91f98a8Spgoyette * this is true for i386 and sgimips.) 267d91f98a8Spgoyette */ 268d91f98a8Spgoyette struct netbsd32_machine32_hook_t netbsd32_machine32_hook; 2693ce1b342Schristos struct netbsd32_reg_validate_hook_t netbsd32_reg_validate_hook; 2707b0f5c9eSpgoyette 2717b0f5c9eSpgoyette /* 2727b0f5c9eSpgoyette * Hook for sendsig_sigcontext_16 2737b0f5c9eSpgoyette */ 2747b0f5c9eSpgoyette struct sendsig_sigcontext_16_hook_t sendsig_sigcontext_16_hook; 27573844747Spgoyette 27673844747Spgoyette /* 2771d577fe3Spgoyette * Hooks for coredumps 27873844747Spgoyette */ 27973844747Spgoyette struct coredump_hook_t coredump_hook; 2801d577fe3Spgoyette struct coredump_offset_hook_t coredump_offset_hook; 2811d577fe3Spgoyette struct coredump_write_hook_t coredump_write_hook; 2821d577fe3Spgoyette struct coredump_netbsd_hook_t coredump_netbsd_hook; 283575be43dSpgoyette struct coredump_netbsd32_hook_t coredump_netbsd32_hook; 2843d852e0eSchristos struct coredump_elf32_hook_t coredump_elf32_hook; 2853d852e0eSchristos struct coredump_elf64_hook_t coredump_elf64_hook; 2861d577fe3Spgoyette struct uvm_coredump_walkmap_hook_t uvm_coredump_walkmap_hook; 2871d577fe3Spgoyette struct uvm_coredump_count_segs_hook_t uvm_coredump_count_segs_hook; 2881d577fe3Spgoyette 289*4be362dbSpgoyette /* 290*4be362dbSpgoyette * Hooks for interacting with remnants of netinet6/nd6 removal 291*4be362dbSpgoyette */ 292*4be362dbSpgoyette struct net_inet6_nd_90_hook_t net_inet6_nd_90_hook; 2931d577fe3Spgoyette 294