11.27Spgoyette/*	$NetBSD: compat_stub.h,v 1.27 2023/12/09 15:21:02 pgoyette Exp $	*/
21.2Spgoyette
31.2Spgoyette/*-
41.2Spgoyette * Copyright (c) 2018 The NetBSD Foundation, Inc.
51.2Spgoyette * All rights reserved.
61.2Spgoyette *
71.2Spgoyette * This code is derived from software contributed to The NetBSD Foundation
81.2Spgoyette * by Paul Goyette
91.2Spgoyette *
101.2Spgoyette * Redistribution and use in source and binary forms, with or without
111.2Spgoyette * modification, are permitted provided that the following conditions
121.2Spgoyette * are met:
131.2Spgoyette * 1. Redistributions of source code must retain the above copyright
141.2Spgoyette *    notice, this list of conditions and the following disclaimer.
151.2Spgoyette * 2. Redistributions in binary form must reproduce the above copyright
161.2Spgoyette *    notice, this list of conditions and the following disclaimer in the
171.2Spgoyette *    documentation and/or other materials provided with the distribution.
181.2Spgoyette *
191.2Spgoyette * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
201.2Spgoyette * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
211.2Spgoyette * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
221.2Spgoyette * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
231.2Spgoyette * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
241.2Spgoyette * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
251.2Spgoyette * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
261.2Spgoyette * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
271.2Spgoyette * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
281.2Spgoyette * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
291.2Spgoyette * POSSIBILITY OF SUCH DAMAGE.
301.2Spgoyette */
311.2Spgoyette
321.2Spgoyette#ifndef _SYS_COMPAT_STUB_H
331.2Spgoyette#define _SYS_COMPAT_STUB_H
341.2Spgoyette
351.2Spgoyette#include <sys/module_hook.h>
361.2Spgoyette#include <sys/param.h>
371.15Sroy#include <sys/socket.h>
381.20Spgoyette#include <sys/sigtypes.h>
391.2Spgoyette
401.2Spgoyette/*
411.7Spgoyette * NOTE: If you make changes here, please remember to update the
421.7Spgoyette * kernel version number in sys/param.h to ensure that kernel
431.7Spgoyette * and modules stay in sync.
441.7Spgoyette */
451.7Spgoyette
461.7Spgoyette/*
471.2Spgoyette * Routine hooks for compat_50___sys_ntp_gettime
481.2Spgoyette *
491.2Spgoyette * MP-hooks not needed since the NTP code is not modular
501.2Spgoyette */
511.2Spgoyette
521.2Spgoyettestruct ntptimeval;
531.2Spgoyettestruct timex;
541.2Spgoyette
551.2Spgoyetteextern void (*vec_ntp_gettime)(struct ntptimeval *);
561.2Spgoyetteextern int (*vec_ntp_timestatus)(void);
571.2Spgoyetteextern void (*vec_ntp_adjtime1)(struct timex *);
581.2Spgoyette
591.2Spgoyette/*
601.2SpgoyetteMODULE_HOOK(ntp_gettime_hook, int, (struct ntptimeval *));
611.2SpgoyetteMODULE_HOOK(ntp_timestatus_hook, int, (void);
621.2SpgoyetteMODULE_HOOK(ntp_adjtime1_hook, int, (struct timex *));
631.2Spgoyette*/
641.2Spgoyette
651.2Spgoyette/*
661.2Spgoyette * Routine hooks for SCTP code - used by rtsock
671.2Spgoyette *
681.2Spgoyette * MP-hooks not needed since the SCTP code is not modular
691.2Spgoyette */
701.2Spgoyettestruct ifaddr;
711.2Spgoyetteextern void (*vec_sctp_add_ip_address)(struct ifaddr *);
721.2Spgoyetteextern void (*vec_sctp_delete_ip_address)(struct ifaddr *);
731.2Spgoyette
741.2Spgoyette/*
751.2SpgoyetteMODULE_HOOK(sctp_add_ip_address, int, struct ifaddr *);
761.2SpgoyetteMODULE_HOOK(sctp_delete_ip_address, int, struct ifaddr *);
771.2Spgoyette*/
781.2Spgoyette
791.2Spgoyette
801.2Spgoyette/*
811.5Schristos * usb devinfo compatibility
821.2Spgoyette */
831.2Spgoyette
841.2Spgoyettestruct usbd_device;
851.26Schristosstruct usb_device_info30;
861.26Schristosstruct usb_device_info100;
871.2Spgoyettestruct usb_event;
881.26Schristosstruct usb_event30;
891.26Schristosstruct usb_event100;
901.2Spgoyettestruct uio;
911.8SpgoyetteMODULE_HOOK(usb_subr_fill_30_hook, int,
921.26Schristos    (struct usbd_device *, struct usb_device_info30 *, int,
931.2Spgoyette      void (*)(struct usbd_device *, char *, size_t, char *, size_t, int, int),
941.2Spgoyette      int (*)(char *, size_t, int)));
951.8SpgoyetteMODULE_HOOK(usb_subr_copy_30_hook, int,
961.26Schristos    (struct usb_event *, struct usb_event30 *, struct uio *));
971.2Spgoyette
981.26SchristosMODULE_HOOK(usb_subr_fill_100_hook, int,
991.26Schristos    (struct usbd_device *, struct usb_device_info100 *, int,
1001.26Schristos      void (*)(struct usbd_device *, char *, size_t, char *, size_t, int, int),
1011.26Schristos      int (*)(char *, size_t, int)));
1021.26SchristosMODULE_HOOK(usb_subr_copy_100_hook, int,
1031.26Schristos    (struct usb_event *, struct usb_event100 *, struct uio *));
1041.2Spgoyette/*
1051.2Spgoyette * Routine vector for dev/ccd ioctl()
1061.2Spgoyette */
1071.2Spgoyette
1081.2SpgoyetteMODULE_HOOK(ccd_ioctl_60_hook, int, (dev_t, u_long, void *, int, struct lwp *,
1091.2Spgoyette    int (*f)(dev_t, u_long, void *, int, struct lwp *)))
1101.2Spgoyette
1111.2Spgoyette/*
1121.2Spgoyette * Routine vector for dev/clockctl ioctl()
1131.2Spgoyette */
1141.2Spgoyette
1151.2SpgoyetteMODULE_HOOK(clockctl_ioctl_50_hook, int,
1161.2Spgoyette    (dev_t, u_long, void *, int, struct lwp *));
1171.2Spgoyette
1181.2Spgoyette/*
1191.5Schristos * if_sppp device compatibility ioctl subroutine
1201.2Spgoyette */
1211.2Spgoyette
1221.2Spgoyettestruct sppp;
1231.2SpgoyetteMODULE_HOOK(sppp_params_50_hook, int, (struct sppp *, u_long, void *));
1241.2Spgoyette
1251.2Spgoyette/*
1261.5Schristos * cryptodev compatibility ioctl
1271.2Spgoyette */
1281.2Spgoyette
1291.2Spgoyettestruct fcrypt;
1301.2Spgoyettestruct session_op;
1311.2Spgoyettestruct csession;
1321.2Spgoyettestruct crypt_op;
1331.2Spgoyettestruct crypt_n_op;
1341.2Spgoyettestruct kmutex_t;
1351.2SpgoyetteMODULE_HOOK(ocryptof_50_hook, int, (struct file *, u_long, void *));
1361.2Spgoyette
1371.2Spgoyette/*
1381.5Schristos * raidframe compatibility
1391.2Spgoyette */
1401.11Schristosstruct raid_softc;
1411.8SpgoyetteMODULE_HOOK(raidframe_ioctl_50_hook, int,
1421.11Schristos    (struct raid_softc *, u_long, void *));
1431.8SpgoyetteMODULE_HOOK(raidframe_ioctl_80_hook, int,
1441.11Schristos    (struct raid_softc *, u_long, void *));
1451.11SchristosMODULE_HOOK(raidframe_netbsd32_ioctl_hook, int,
1461.11Schristos    (struct raid_softc *, u_long, void *));
1471.2Spgoyette
1481.2Spgoyette/*
1491.5Schristos * puffs compatibility
1501.2Spgoyette */
1511.2Spgoyette
1521.2Spgoyettestruct puffs_req;
1531.8SpgoyetteMODULE_HOOK(puffs_out_50_hook, int,
1541.2Spgoyette    (struct puffs_req *, struct puffs_req **, ssize_t *));	/* outgoing */
1551.8SpgoyetteMODULE_HOOK(puffs_in_50_hook, void,
1561.2Spgoyette    (struct puffs_req *, struct puffs_req *));			/* incoming */
1571.2Spgoyette
1581.2Spgoyette/*
1591.5Schristos * wsevents compatibility
1601.2Spgoyette */
1611.2Spgoyette
1621.2Spgoyettestruct wscons_event;
1631.2Spgoyettestruct uio;
1641.8SpgoyetteMODULE_HOOK(wscons_copyout_events_50_hook, int,
1651.2Spgoyette    (const struct wscons_event *, int, struct uio *));
1661.2Spgoyette
1671.2Spgoyette/*
1681.5Schristos * sysmon_power compatibility
1691.2Spgoyette */
1701.2Spgoyette
1711.2Spgoyettestruct power_event;
1721.2Spgoyettestruct sysmon_pswitch;
1731.2SpgoyetteMODULE_HOOK(compat_sysmon_power_40_hook, void,
1741.2Spgoyette    (struct power_event *, struct sysmon_pswitch *, int));
1751.2Spgoyette
1761.2Spgoyette/*
1771.2Spgoyette * compat_bio indirect function pointer
1781.2Spgoyette */
1791.2Spgoyette
1801.2SpgoyetteMODULE_HOOK(compat_bio_30_hook, int,
1811.2Spgoyette    (void *, u_long, void *, int(*)(void *, u_long, void *)));
1821.2Spgoyette
1831.2Spgoyette/*
1841.5Schristos * vnd_30 ioctl compatibility
1851.2Spgoyette */
1861.2Spgoyettestruct vattr;
1871.2SpgoyetteMODULE_HOOK(compat_vndioctl_30_hook, int, (u_long, struct lwp *, void *, int,
1881.2Spgoyette    struct vattr *, int (*)(struct lwp *, void *, int, struct vattr *)));
1891.2Spgoyette
1901.2Spgoyette/*
1911.5Schristos * vnd_50 ioctl compatibility
1921.2Spgoyette */
1931.2Spgoyettestruct vattr;
1941.2SpgoyetteMODULE_HOOK(compat_vndioctl_50_hook, int, (u_long, struct lwp *, void *, int,
1951.2Spgoyette    struct vattr *, int (*)(struct lwp *, void *, int, struct vattr *)));
1961.2Spgoyette
1971.2Spgoyette/*
1981.5Schristos * ieee80211 ioctl compatibility
1991.2Spgoyette */
2001.4Schristosstruct ieee80211com;
2011.2Spgoyette
2021.8SpgoyetteMODULE_HOOK(ieee80211_ioctl_20_hook, int,
2031.5Schristos    (struct ieee80211com *, u_long, void *));
2041.2Spgoyette
2051.2Spgoyette/*
2061.5Schristos * if_43 compatibility
2071.2Spgoyette */
2081.2Spgoyettestruct socket;
2091.2Spgoyette
2101.8SpgoyetteMODULE_HOOK(if_cvtcmd_43_hook, int, (u_long *, u_long));
2111.8SpgoyetteMODULE_HOOK(if_ifioctl_43_hook, int,
2121.2Spgoyette    (struct socket *, u_long, u_long, void *, struct lwp *));
2131.2Spgoyette
2141.2Spgoyette/*
2151.6Spgoyette * if43_cvtcmd_20 compatibility
2161.2Spgoyette */
2171.6SpgoyetteMODULE_HOOK(if43_cvtcmd_20_hook, int, (u_long));
2181.2Spgoyette
2191.2Spgoyette/*
2201.3Schristos * tty 43 ioctl compatibility
2211.3Schristos */
2221.3Schristosstruct tty;
2231.3Schristos
2241.8SpgoyetteMODULE_HOOK(tty_ttioctl_43_hook, int,
2251.3Schristos    (struct tty *, u_long, void *, int, struct lwp *));
2261.3Schristos
2271.3Schristos/*
2281.5Schristos * uipc_syscalls_40 compatibility
2291.2Spgoyette */
2301.2Spgoyette
2311.2SpgoyetteMODULE_HOOK(uipc_syscalls_40_hook, int, (u_long, void *));
2321.2Spgoyette
2331.2Spgoyette/*
2341.12Spgoyette * uipc_socket_50 compatibility
2351.12Spgoyette */
2361.12Spgoyettestruct sockopt;
2371.12Spgoyettestruct mbuf;
2381.12Spgoyette
2391.12SpgoyetteMODULE_HOOK(uipc_socket_50_setopt1_hook, int,
2401.13Spgoyette    (int, struct socket *, const struct sockopt *));
2411.12SpgoyetteMODULE_HOOK(uipc_socket_50_getopt1_hook, int,
2421.13Spgoyette    (int, struct socket *, struct sockopt *));
2431.19SpgoyetteMODULE_HOOK(uipc_socket_50_sbts_hook, int, (int, struct mbuf ***));
2441.12Spgoyette
2451.12Spgoyette/*
2461.5Schristos * uipc_syscalls_50 compatibility
2471.2Spgoyette */
2481.2Spgoyette
2491.2SpgoyetteMODULE_HOOK(uipc_syscalls_50_hook, int, (struct lwp *, u_long, void *));
2501.2Spgoyette
2511.2Spgoyette/*
2521.5Schristos * rtsock 14 compatibility
2531.2Spgoyette */
2541.2Spgoyettestruct ifnet;
2551.2Spgoyettestruct rt_walkarg;
2561.2Spgoyettestruct rt_addrinfo;
2571.8SpgoyetteMODULE_HOOK(rtsock_oifmsg_14_hook, void, (struct ifnet *));
2581.8SpgoyetteMODULE_HOOK(rtsock_iflist_14_hook, int,
2591.2Spgoyette    (struct ifnet *, struct rt_walkarg *, struct rt_addrinfo *, size_t));
2601.2Spgoyette
2611.2Spgoyette/*
2621.2Spgoyette * Hooks for rtsock_50
2631.2Spgoyette */
2641.2Spgoyette
2651.2Spgoyettestruct rtentry;
2661.2Spgoyettestruct ifaddr;
2671.8SpgoyetteMODULE_HOOK(rtsock_oifmsg_50_hook, void, (struct ifnet *));
2681.8SpgoyetteMODULE_HOOK(rtsock_iflist_50_hook, int,
2691.2Spgoyette    (struct ifnet *, struct rt_walkarg *, struct rt_addrinfo *, size_t));
2701.8SpgoyetteMODULE_HOOK(rtsock_rt_missmsg_50_hook, void,
2711.2Spgoyette    (int, const struct rt_addrinfo *, int, int));
2721.8SpgoyetteMODULE_HOOK(rtsock_rt_ifmsg_50_hook, void, (struct ifnet *));
2731.14SroyMODULE_HOOK(rtsock_rt_addrmsg_rt_50_hook, void,
2741.2Spgoyette    (int, struct ifaddr *, int, struct rtentry *));
2751.15SroyMODULE_HOOK(rtsock_rt_addrmsg_src_50_hook, void,
2761.15Sroy    (int, struct ifaddr *, const struct sockaddr *));
2771.14SroyMODULE_HOOK(rtsock_rt_addrmsg_50_hook, void, (int, struct ifaddr *));
2781.8SpgoyetteMODULE_HOOK(rtsock_rt_ifannouncemsg_50_hook, void, (struct ifnet *, int));
2791.8SpgoyetteMODULE_HOOK(rtsock_rt_ieee80211msg_50_hook, void,
2801.2Spgoyette    (struct ifnet *, int, void *, size_t));
2811.2Spgoyette
2821.2Spgoyette/*
2831.2Spgoyette * Hooks for rtsock_70
2841.2Spgoyette */
2851.2Spgoyettestruct ifaddr;
2861.8SpgoyetteMODULE_HOOK(rtsock_newaddr_70_hook, void, (int, struct ifaddr *));
2871.8SpgoyetteMODULE_HOOK(rtsock_iflist_70_hook, int,
2881.2Spgoyette    (struct rt_walkarg *, struct ifaddr *, struct rt_addrinfo *));
2891.2Spgoyette
2901.2Spgoyette/*
2911.2Spgoyette * modctl handler for old style OSTAT
2921.2Spgoyette */
2931.2Spgoyettestruct iovec;
2941.2SpgoyetteMODULE_HOOK(compat_modstat_80_hook, int, (int, struct iovec *, void *));
2951.2Spgoyette
2961.2Spgoyette/*
2971.2Spgoyette * mask for kern_sig_43's killpg
2981.2Spgoyette */
2991.2Spgoyetteextern int kern_sig_43_pgid_mask;
3001.2Spgoyette
3011.2Spgoyette/*
3021.2Spgoyette * Hooks for kern_proc.c for netbsd32 compat
3031.2Spgoyette */
3041.2Spgoyettestruct ps_strings;
3051.8SpgoyetteMODULE_HOOK(kern_proc32_copyin_hook, int,
3061.2Spgoyette    (struct proc *, struct ps_strings *));
3071.8SpgoyetteMODULE_HOOK(kern_proc32_base_hook, vaddr_t, (char **, size_t));
3081.2Spgoyette
3091.2Spgoyette/*
3101.2Spgoyette * Hook to allow sparc fpu code to see if a process is using sunos
3111.2Spgoyette * emulation, and select proper fup codes
3121.2Spgoyette */
3131.2Spgoyettestruct emul;
3141.2SpgoyetteMODULE_HOOK(get_emul_sunos_hook, int, (const struct emul **));
3151.2Spgoyette
3161.2Spgoyette/*
3171.2Spgoyette * Hooks for rnd_ioctl_50
3181.2Spgoyette */
3191.2SpgoyetteMODULE_HOOK(rnd_ioctl_50_hook, int, (struct file *, u_long, void *));
3201.8SpgoyetteMODULE_HOOK(rnd_ioctl32_50_hook, int, (struct file *, u_long, void *));
3211.2Spgoyette
3221.2Spgoyette/*
3231.2Spgoyette * Hooks for compat_60 ttioctl and ptmioctl
3241.2Spgoyette */
3251.8SpgoyetteMODULE_HOOK(tty_ttioctl_60_hook, int,
3261.3Schristos    (struct tty *, u_long, void *, int, struct lwp *));
3271.8SpgoyetteMODULE_HOOK(tty_ptmioctl_60_hook, int,
3281.2Spgoyette    (dev_t, u_long, void *, int, struct lwp *));
3291.2Spgoyette
3301.2Spgoyette/*
3311.2Spgoyette * Hook for compat_10 openat
3321.2Spgoyette */
3331.2Spgoyettestruct pathbuf;
3341.8SpgoyetteMODULE_HOOK(vfs_openat_10_hook, int, (struct pathbuf **));
3351.2Spgoyette
3361.2Spgoyette/*
3371.2Spgoyette * Hook for compat_70_unp_addsockcred
3381.2Spgoyette */
3391.8SpgoyetteMODULE_HOOK(uipc_unp_70_hook, struct mbuf *,
3401.2Spgoyette    (struct lwp *, struct mbuf *));
3411.2Spgoyette
3421.2Spgoyette/*
3431.2Spgoyette * Hook for sysvipc50 sysctl
3441.2Spgoyette */
3451.2Spgoyette#include <sys/sysctl.h>
3461.8SpgoyetteMODULE_HOOK(sysvipc_sysctl_50_hook, int, (SYSCTLFN_PROTO));
3471.2Spgoyette
3481.16Smsaitoh/*
3491.16Smsaitoh * ifmedia_80 compatibility
3501.16Smsaitoh */
3511.16Smsaitoh
3521.16Smsaitohstruct ifmedia;
3531.16Smsaitohstruct ifreq;
3541.16SmsaitohMODULE_HOOK(ifmedia_80_pre_hook, int, (struct ifreq *, u_long *, bool *));
3551.16SmsaitohMODULE_HOOK(ifmedia_80_post_hook, int, (struct ifreq *, u_long));
3561.16Smsaitoh
3571.2Spgoyette/*
3581.2Spgoyette * Hook for 32-bit machine name
3591.2Spgoyette *
3601.2Spgoyette * This probably would be better placed in compat/netbsd32/netbsd32_mod.c
3611.2Spgoyette * but the consumer code in linux32_exec_elf32.c is sometimes included in
3621.2Spgoyette * the main kernel, and not in a compat_netbsd32 module.  (In particular,
3631.2Spgoyette * this is true for i386 and sgimips.)
3641.2Spgoyette */
3651.18Smrgstruct reg;
3661.2SpgoyetteMODULE_HOOK(netbsd32_machine32_hook, const char *, (void));
3671.17SchristosMODULE_HOOK(netbsd32_reg_validate_hook, int,
3681.17Schristos    (struct lwp *, const struct reg *));
3691.20Spgoyette
3701.20Spgoyette/*
3711.20Spgoyette * Hook for compat_16 sendsig_sigcontext
3721.20Spgoyette */
3731.20Spgoyettestruct ksiginfo;
3741.20SpgoyetteMODULE_HOOK(sendsig_sigcontext_16_hook, void,
3751.20Spgoyette    (const struct ksiginfo *, const sigset_t *));
3761.20Spgoyette
3771.21Spgoyette/*
3781.22Spgoyette * Hooks for coredumps
3791.21Spgoyette */
3801.22Spgoyette
3811.22Spgoyettestruct uvm_coredump_state;
3821.21SpgoyetteMODULE_HOOK(coredump_hook, int, (struct lwp *, const char *));
3831.22SpgoyetteMODULE_HOOK(coredump_offset_hook, off_t, (struct coredump_iostate *));
3841.22SpgoyetteMODULE_HOOK(coredump_write_hook, int,
3851.22Spgoyette    (struct coredump_iostate *, enum uio_seg, const void *, size_t));
3861.22SpgoyetteMODULE_HOOK(coredump_netbsd_hook, int,
3871.22Spgoyette    (struct lwp *, struct coredump_iostate *));
3881.25SpgoyetteMODULE_HOOK(coredump_netbsd32_hook, int,
3891.25Spgoyette    (struct lwp *, struct coredump_iostate *));
3901.24SchristosMODULE_HOOK(coredump_elf32_hook, int,
3911.24Schristos    (struct lwp *, struct coredump_iostate *));
3921.24SchristosMODULE_HOOK(coredump_elf64_hook, int,
3931.24Schristos    (struct lwp *, struct coredump_iostate *));
3941.22SpgoyetteMODULE_HOOK(uvm_coredump_walkmap_hook, int,
3951.22Spgoyette    (struct proc *, int (*)(struct uvm_coredump_state *), void *));
3961.22SpgoyetteMODULE_HOOK(uvm_coredump_count_segs_hook, int, (struct proc *));
3971.21Spgoyette
3981.23Spgoyette/*
3991.23Spgoyette * Hook for amd64 handler for oosyscall for COMPAT_NETBSD32 && COMPAT_10)
4001.23Spgoyette */
4011.23Spgoyettestruct proc;
4021.23Spgoyettestruct trapframe;
4031.23SpgoyetteMODULE_HOOK(amd64_oosyscall_hook, int, (struct proc *, struct trapframe *));
4041.23Spgoyette
4051.27Spgoyette/*
4061.27Spgoyette * Hook for compat_90 to deal with removal of nd6 from the kernel
4071.27Spgoyette */
4081.27SpgoyetteMODULE_HOOK(net_inet6_nd_90_hook, int, (int));
4091.27Spgoyette
4101.2Spgoyette#endif	/* _SYS_COMPAT_STUB_H */
411