xref: /netbsd-src/sys/sys/compat_stub.h (revision 4be362dba2fc692dca601f96af55d588031d61c5)
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 
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_info30;
86 struct usb_device_info100;
87 struct usb_event;
88 struct usb_event30;
89 struct usb_event100;
90 struct uio;
91 MODULE_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)));
95 MODULE_HOOK(usb_subr_copy_30_hook, int,
96     (struct usb_event *, struct usb_event30 *, struct uio *));
97 
98 MODULE_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)));
102 MODULE_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 
108 MODULE_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 
115 MODULE_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 
122 struct sppp;
123 MODULE_HOOK(sppp_params_50_hook, int, (struct sppp *, u_long, void *));
124 
125 /*
126  * cryptodev compatibility ioctl
127  */
128 
129 struct fcrypt;
130 struct session_op;
131 struct csession;
132 struct crypt_op;
133 struct crypt_n_op;
134 struct kmutex_t;
135 MODULE_HOOK(ocryptof_50_hook, int, (struct file *, u_long, void *));
136 
137 /*
138  * raidframe compatibility
139  */
140 struct raid_softc;
141 MODULE_HOOK(raidframe_ioctl_50_hook, int,
142     (struct raid_softc *, u_long, void *));
143 MODULE_HOOK(raidframe_ioctl_80_hook, int,
144     (struct raid_softc *, u_long, void *));
145 MODULE_HOOK(raidframe_netbsd32_ioctl_hook, int,
146     (struct raid_softc *, u_long, void *));
147 
148 /*
149  * puffs compatibility
150  */
151 
152 struct puffs_req;
153 MODULE_HOOK(puffs_out_50_hook, int,
154     (struct puffs_req *, struct puffs_req **, ssize_t *));	/* outgoing */
155 MODULE_HOOK(puffs_in_50_hook, void,
156     (struct puffs_req *, struct puffs_req *));			/* incoming */
157 
158 /*
159  * wsevents compatibility
160  */
161 
162 struct wscons_event;
163 struct uio;
164 MODULE_HOOK(wscons_copyout_events_50_hook, int,
165     (const struct wscons_event *, int, struct uio *));
166 
167 /*
168  * sysmon_power compatibility
169  */
170 
171 struct power_event;
172 struct sysmon_pswitch;
173 MODULE_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 
180 MODULE_HOOK(compat_bio_30_hook, int,
181     (void *, u_long, void *, int(*)(void *, u_long, void *)));
182 
183 /*
184  * vnd_30 ioctl compatibility
185  */
186 struct vattr;
187 MODULE_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  */
193 struct vattr;
194 MODULE_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  */
200 struct ieee80211com;
201 
202 MODULE_HOOK(ieee80211_ioctl_20_hook, int,
203     (struct ieee80211com *, u_long, void *));
204 
205 /*
206  * if_43 compatibility
207  */
208 struct socket;
209 
210 MODULE_HOOK(if_cvtcmd_43_hook, int, (u_long *, u_long));
211 MODULE_HOOK(if_ifioctl_43_hook, int,
212     (struct socket *, u_long, u_long, void *, struct lwp *));
213 
214 /*
215  * if43_cvtcmd_20 compatibility
216  */
217 MODULE_HOOK(if43_cvtcmd_20_hook, int, (u_long));
218 
219 /*
220  * tty 43 ioctl compatibility
221  */
222 struct tty;
223 
224 MODULE_HOOK(tty_ttioctl_43_hook, int,
225     (struct tty *, u_long, void *, int, struct lwp *));
226 
227 /*
228  * uipc_syscalls_40 compatibility
229  */
230 
231 MODULE_HOOK(uipc_syscalls_40_hook, int, (u_long, void *));
232 
233 /*
234  * uipc_socket_50 compatibility
235  */
236 struct sockopt;
237 struct mbuf;
238 
239 MODULE_HOOK(uipc_socket_50_setopt1_hook, int,
240     (int, struct socket *, const struct sockopt *));
241 MODULE_HOOK(uipc_socket_50_getopt1_hook, int,
242     (int, struct socket *, struct sockopt *));
243 MODULE_HOOK(uipc_socket_50_sbts_hook, int, (int, struct mbuf ***));
244 
245 /*
246  * uipc_syscalls_50 compatibility
247  */
248 
249 MODULE_HOOK(uipc_syscalls_50_hook, int, (struct lwp *, u_long, void *));
250 
251 /*
252  * rtsock 14 compatibility
253  */
254 struct ifnet;
255 struct rt_walkarg;
256 struct rt_addrinfo;
257 MODULE_HOOK(rtsock_oifmsg_14_hook, void, (struct ifnet *));
258 MODULE_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 
265 struct rtentry;
266 struct ifaddr;
267 MODULE_HOOK(rtsock_oifmsg_50_hook, void, (struct ifnet *));
268 MODULE_HOOK(rtsock_iflist_50_hook, int,
269     (struct ifnet *, struct rt_walkarg *, struct rt_addrinfo *, size_t));
270 MODULE_HOOK(rtsock_rt_missmsg_50_hook, void,
271     (int, const struct rt_addrinfo *, int, int));
272 MODULE_HOOK(rtsock_rt_ifmsg_50_hook, void, (struct ifnet *));
273 MODULE_HOOK(rtsock_rt_addrmsg_rt_50_hook, void,
274     (int, struct ifaddr *, int, struct rtentry *));
275 MODULE_HOOK(rtsock_rt_addrmsg_src_50_hook, void,
276     (int, struct ifaddr *, const struct sockaddr *));
277 MODULE_HOOK(rtsock_rt_addrmsg_50_hook, void, (int, struct ifaddr *));
278 MODULE_HOOK(rtsock_rt_ifannouncemsg_50_hook, void, (struct ifnet *, int));
279 MODULE_HOOK(rtsock_rt_ieee80211msg_50_hook, void,
280     (struct ifnet *, int, void *, size_t));
281 
282 /*
283  * Hooks for rtsock_70
284  */
285 struct ifaddr;
286 MODULE_HOOK(rtsock_newaddr_70_hook, void, (int, struct ifaddr *));
287 MODULE_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  */
293 struct iovec;
294 MODULE_HOOK(compat_modstat_80_hook, int, (int, struct iovec *, void *));
295 
296 /*
297  * mask for kern_sig_43's killpg
298  */
299 extern int kern_sig_43_pgid_mask;
300 
301 /*
302  * Hooks for kern_proc.c for netbsd32 compat
303  */
304 struct ps_strings;
305 MODULE_HOOK(kern_proc32_copyin_hook, int,
306     (struct proc *, struct ps_strings *));
307 MODULE_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  */
313 struct emul;
314 MODULE_HOOK(get_emul_sunos_hook, int, (const struct emul **));
315 
316 /*
317  * Hooks for rnd_ioctl_50
318  */
319 MODULE_HOOK(rnd_ioctl_50_hook, int, (struct file *, u_long, void *));
320 MODULE_HOOK(rnd_ioctl32_50_hook, int, (struct file *, u_long, void *));
321 
322 /*
323  * Hooks for compat_60 ttioctl and ptmioctl
324  */
325 MODULE_HOOK(tty_ttioctl_60_hook, int,
326     (struct tty *, u_long, void *, int, struct lwp *));
327 MODULE_HOOK(tty_ptmioctl_60_hook, int,
328     (dev_t, u_long, void *, int, struct lwp *));
329 
330 /*
331  * Hook for compat_10 openat
332  */
333 struct pathbuf;
334 MODULE_HOOK(vfs_openat_10_hook, int, (struct pathbuf **));
335 
336 /*
337  * Hook for compat_70_unp_addsockcred
338  */
339 MODULE_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>
346 MODULE_HOOK(sysvipc_sysctl_50_hook, int, (SYSCTLFN_PROTO));
347 
348 /*
349  * ifmedia_80 compatibility
350  */
351 
352 struct ifmedia;
353 struct ifreq;
354 MODULE_HOOK(ifmedia_80_pre_hook, int, (struct ifreq *, u_long *, bool *));
355 MODULE_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  */
365 struct reg;
366 MODULE_HOOK(netbsd32_machine32_hook, const char *, (void));
367 MODULE_HOOK(netbsd32_reg_validate_hook, int,
368     (struct lwp *, const struct reg *));
369 
370 /*
371  * Hook for compat_16 sendsig_sigcontext
372  */
373 struct ksiginfo;
374 MODULE_HOOK(sendsig_sigcontext_16_hook, void,
375     (const struct ksiginfo *, const sigset_t *));
376 
377 /*
378  * Hooks for coredumps
379  */
380 
381 struct uvm_coredump_state;
382 MODULE_HOOK(coredump_hook, int, (struct lwp *, const char *));
383 MODULE_HOOK(coredump_offset_hook, off_t, (struct coredump_iostate *));
384 MODULE_HOOK(coredump_write_hook, int,
385     (struct coredump_iostate *, enum uio_seg, const void *, size_t));
386 MODULE_HOOK(coredump_netbsd_hook, int,
387     (struct lwp *, struct coredump_iostate *));
388 MODULE_HOOK(coredump_netbsd32_hook, int,
389     (struct lwp *, struct coredump_iostate *));
390 MODULE_HOOK(coredump_elf32_hook, int,
391     (struct lwp *, struct coredump_iostate *));
392 MODULE_HOOK(coredump_elf64_hook, int,
393     (struct lwp *, struct coredump_iostate *));
394 MODULE_HOOK(uvm_coredump_walkmap_hook, int,
395     (struct proc *, int (*)(struct uvm_coredump_state *), void *));
396 MODULE_HOOK(uvm_coredump_count_segs_hook, int, (struct proc *));
397 
398 /*
399  * Hook for amd64 handler for oosyscall for COMPAT_NETBSD32 && COMPAT_10)
400  */
401 struct proc;
402 struct trapframe;
403 MODULE_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  */
408 MODULE_HOOK(net_inet6_nd_90_hook, int, (int));
409 
410 #endif	/* _SYS_COMPAT_STUB_H */
411