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