compat_stub.h revision 1.23
1/*	$NetBSD: compat_stub.h,v 1.23 2020/03/08 00:53:13 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_info_old;
86struct usb_event;
87struct usb_event_old;
88struct uio;
89MODULE_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)));
93MODULE_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
100MODULE_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
107MODULE_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
114struct sppp;
115MODULE_HOOK(sppp_params_50_hook, int, (struct sppp *, u_long, void *));
116
117/*
118 * cryptodev compatibility ioctl
119 */
120
121struct fcrypt;
122struct session_op;
123struct csession;
124struct crypt_op;
125struct crypt_n_op;
126struct kmutex_t;
127MODULE_HOOK(ocryptof_50_hook, int, (struct file *, u_long, void *));
128
129/*
130 * raidframe compatibility
131 */
132struct raid_softc;
133MODULE_HOOK(raidframe_ioctl_50_hook, int,
134    (struct raid_softc *, u_long, void *));
135MODULE_HOOK(raidframe_ioctl_80_hook, int,
136    (struct raid_softc *, u_long, void *));
137MODULE_HOOK(raidframe_netbsd32_ioctl_hook, int,
138    (struct raid_softc *, u_long, void *));
139
140/*
141 * puffs compatibility
142 */
143
144struct puffs_req;
145MODULE_HOOK(puffs_out_50_hook, int,
146    (struct puffs_req *, struct puffs_req **, ssize_t *));	/* outgoing */
147MODULE_HOOK(puffs_in_50_hook, void,
148    (struct puffs_req *, struct puffs_req *));			/* incoming */
149
150/*
151 * wsevents compatibility
152 */
153
154struct wscons_event;
155struct uio;
156MODULE_HOOK(wscons_copyout_events_50_hook, int,
157    (const struct wscons_event *, int, struct uio *));
158
159/*
160 * sysmon_power compatibility
161 */
162
163struct power_event;
164struct sysmon_pswitch;
165MODULE_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
172MODULE_HOOK(compat_bio_30_hook, int,
173    (void *, u_long, void *, int(*)(void *, u_long, void *)));
174
175/*
176 * vnd_30 ioctl compatibility
177 */
178struct vattr;
179MODULE_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 */
185struct vattr;
186MODULE_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 */
192struct ieee80211com;
193
194MODULE_HOOK(ieee80211_ioctl_20_hook, int,
195    (struct ieee80211com *, u_long, void *));
196
197/*
198 * if_43 compatibility
199 */
200struct socket;
201
202MODULE_HOOK(if_cvtcmd_43_hook, int, (u_long *, u_long));
203MODULE_HOOK(if_ifioctl_43_hook, int,
204    (struct socket *, u_long, u_long, void *, struct lwp *));
205
206/*
207 * if43_cvtcmd_20 compatibility
208 */
209MODULE_HOOK(if43_cvtcmd_20_hook, int, (u_long));
210
211/*
212 * tty 43 ioctl compatibility
213 */
214struct tty;
215
216MODULE_HOOK(tty_ttioctl_43_hook, int,
217    (struct tty *, u_long, void *, int, struct lwp *));
218
219/*
220 * uipc_syscalls_40 compatibility
221 */
222
223MODULE_HOOK(uipc_syscalls_40_hook, int, (u_long, void *));
224
225/*
226 * uipc_socket_50 compatibility
227 */
228struct sockopt;
229struct mbuf;
230
231MODULE_HOOK(uipc_socket_50_setopt1_hook, int,
232    (int, struct socket *, const struct sockopt *));
233MODULE_HOOK(uipc_socket_50_getopt1_hook, int,
234    (int, struct socket *, struct sockopt *));
235MODULE_HOOK(uipc_socket_50_sbts_hook, int, (int, struct mbuf ***));
236
237/*
238 * uipc_syscalls_50 compatibility
239 */
240
241MODULE_HOOK(uipc_syscalls_50_hook, int, (struct lwp *, u_long, void *));
242
243/*
244 * rtsock 14 compatibility
245 */
246struct ifnet;
247struct rt_walkarg;
248struct rt_addrinfo;
249MODULE_HOOK(rtsock_oifmsg_14_hook, void, (struct ifnet *));
250MODULE_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
257struct rtentry;
258struct ifaddr;
259MODULE_HOOK(rtsock_oifmsg_50_hook, void, (struct ifnet *));
260MODULE_HOOK(rtsock_iflist_50_hook, int,
261    (struct ifnet *, struct rt_walkarg *, struct rt_addrinfo *, size_t));
262MODULE_HOOK(rtsock_rt_missmsg_50_hook, void,
263    (int, const struct rt_addrinfo *, int, int));
264MODULE_HOOK(rtsock_rt_ifmsg_50_hook, void, (struct ifnet *));
265MODULE_HOOK(rtsock_rt_addrmsg_rt_50_hook, void,
266    (int, struct ifaddr *, int, struct rtentry *));
267MODULE_HOOK(rtsock_rt_addrmsg_src_50_hook, void,
268    (int, struct ifaddr *, const struct sockaddr *));
269MODULE_HOOK(rtsock_rt_addrmsg_50_hook, void, (int, struct ifaddr *));
270MODULE_HOOK(rtsock_rt_ifannouncemsg_50_hook, void, (struct ifnet *, int));
271MODULE_HOOK(rtsock_rt_ieee80211msg_50_hook, void,
272    (struct ifnet *, int, void *, size_t));
273
274/*
275 * Hooks for rtsock_70
276 */
277struct ifaddr;
278MODULE_HOOK(rtsock_newaddr_70_hook, void, (int, struct ifaddr *));
279MODULE_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 */
285struct iovec;
286MODULE_HOOK(compat_modstat_80_hook, int, (int, struct iovec *, void *));
287
288/*
289 * mask for kern_sig_43's killpg
290 */
291extern int kern_sig_43_pgid_mask;
292
293/*
294 * Hooks for kern_proc.c for netbsd32 compat
295 */
296struct ps_strings;
297MODULE_HOOK(kern_proc32_copyin_hook, int,
298    (struct proc *, struct ps_strings *));
299MODULE_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 */
305struct emul;
306MODULE_HOOK(get_emul_sunos_hook, int, (const struct emul **));
307
308/*
309 * Hooks for rnd_ioctl_50
310 */
311MODULE_HOOK(rnd_ioctl_50_hook, int, (struct file *, u_long, void *));
312MODULE_HOOK(rnd_ioctl32_50_hook, int, (struct file *, u_long, void *));
313
314/*
315 * Hooks for compat_60 ttioctl and ptmioctl
316 */
317MODULE_HOOK(tty_ttioctl_60_hook, int,
318    (struct tty *, u_long, void *, int, struct lwp *));
319MODULE_HOOK(tty_ptmioctl_60_hook, int,
320    (dev_t, u_long, void *, int, struct lwp *));
321
322/*
323 * Hook for compat_10 openat
324 */
325struct pathbuf;
326MODULE_HOOK(vfs_openat_10_hook, int, (struct pathbuf **));
327
328/*
329 * Hook for compat_70_unp_addsockcred
330 */
331MODULE_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>
338MODULE_HOOK(sysvipc_sysctl_50_hook, int, (SYSCTLFN_PROTO));
339
340/*
341 * ifmedia_80 compatibility
342 */
343
344struct ifmedia;
345struct ifreq;
346MODULE_HOOK(ifmedia_80_pre_hook, int, (struct ifreq *, u_long *, bool *));
347MODULE_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 */
357struct reg;
358MODULE_HOOK(netbsd32_machine32_hook, const char *, (void));
359MODULE_HOOK(netbsd32_reg_validate_hook, int,
360    (struct lwp *, const struct reg *));
361
362/*
363 * Hook for compat_16 sendsig_sigcontext
364 */
365struct ksiginfo;
366MODULE_HOOK(sendsig_sigcontext_16_hook, void,
367    (const struct ksiginfo *, const sigset_t *));
368
369/*
370 * Hooks for coredumps
371 */
372
373struct uvm_coredump_state;
374MODULE_HOOK(coredump_hook, int, (struct lwp *, const char *));
375MODULE_HOOK(coredump_offset_hook, off_t, (struct coredump_iostate *));
376MODULE_HOOK(coredump_write_hook, int,
377    (struct coredump_iostate *, enum uio_seg, const void *, size_t));
378MODULE_HOOK(coredump_netbsd_hook, int,
379    (struct lwp *, struct coredump_iostate *));
380MODULE_HOOK(uvm_coredump_walkmap_hook, int,
381    (struct proc *, int (*)(struct uvm_coredump_state *), void *));
382MODULE_HOOK(uvm_coredump_count_segs_hook, int, (struct proc *));
383
384/*
385 * Hook for amd64 handler for oosyscall for COMPAT_NETBSD32 && COMPAT_10)
386 */
387struct proc;
388struct trapframe;
389MODULE_HOOK(amd64_oosyscall_hook, int, (struct proc *, struct trapframe *));
390
391#endif	/* _SYS_COMPAT_STUB_H */
392