compat_stub.c revision 1.6 1 /* $NetBSD: compat_stub.c,v 1.6 2019/01/29 09:28:50 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 #include <sys/cdefs.h>
33
34 #ifdef _KERNEL_OPT
35 #include "opt_ntp.h"
36 #include "opt_sctp.h"
37 #endif
38
39 #include <sys/systm.h>
40 #include <sys/compat_stub.h>
41
42 #ifdef NTP
43 #include <sys/timespec.h>
44 #include <sys/timex.h>
45 #endif
46
47 #ifdef SCTP
48 #include <netinet/sctp_asconf.h>
49 #endif
50
51 /*
52 * Routine vectors for compat_50___sys_ntp_gettime
53 *
54 * MP-hooks not needed since the NTP code is not modular
55 */
56
57 #ifdef NTP
58 void (*vec_ntp_gettime)(struct ntptimeval *) = ntp_gettime;
59 int (*vec_ntp_timestatus)(void) = ntp_timestatus;
60 void (*vec_ntp_adjtime1)(struct timex *) = ntp_adjtime1;
61 #else
62 void (*vec_ntp_gettime)(struct ntptimeval *) = NULL;
63 int (*vec_ntp_timestatus)(void) = NULL;
64 void (*vec_ntp_adjtime1)(struct timex *) = NULL;
65 #endif
66
67 /*
68 * Routine vectors for sctp (called from within rtsock)
69 *
70 * MP-hooks not needed since the SCTP code is not modular
71 */
72
73 #ifdef SCTP
74 void (*vec_sctp_add_ip_address)(struct ifaddr *) = sctp_add_ip_address;
75 void (*vec_sctp_delete_ip_address)(struct ifaddr *) = sctp_delete_ip_address;
76 #else
77 void (*vec_sctp_add_ip_address)(struct ifaddr *) = NULL;
78 void (*vec_sctp_delete_ip_address)(struct ifaddr *) = NULL;
79 #endif
80
81
82 /*
83 * usb device_info compatability
84 */
85 struct usb_subr_fill_30_hook_t usb_subr_fill_30_hook;
86 struct usb_subr_copy_30_hook_t usb_subr_copy_30_hook;
87
88 /*
89 * ccd device compatability ioctl
90 */
91
92 struct ccd_ioctl_60_hook_t ccd_ioctl_60_hook;
93
94 /*
95 * clockctl device compatability ioctl
96 */
97
98 struct clockctl_ioctl_50_hook_t clockctl_ioctl_50_hook;
99
100 /*
101 * if_sppp device compatability ioctl subroutine
102 */
103
104 struct sppp_params_50_hook_t sppp_params_50_hook;
105
106 /*
107 * cryptodev compatability ioctl
108 */
109
110 struct ocryptof_50_hook_t ocryptof_50_hook;
111
112 /*
113 * raidframe compatability
114 */
115 struct raidframe_ioctl_50_hook_t raidframe_ioctl_50_hook;
116 struct raidframe_ioctl_80_hook_t raidframe_ioctl_80_hook;
117
118 /*
119 * puffs compatability
120 */
121
122 struct puffs_out_50_hook_t puffs_out_50_hook;
123 struct puffs_in_50_hook_t puffs_in_50_hook;
124
125 /* XXX
126 int (*puffs50_compat_outgoing)(struct puffs_req *, struct puffs_req **,
127 ssize_t *) = (void *)enosys;
128 void (*puffs50_compat_incoming)(struct puffs_req *, struct puffs_req *) =
129 (void *)voidop;
130 XXX */
131
132 /*
133 * wsevents compatability
134 */
135 struct wscons_copyout_events_50_hook_t wscons_copyout_events_50_hook;
136
137 /*
138 * sysmon_power compatability
139 */
140 struct compat_sysmon_power_40_hook_t compat_sysmon_power_40_hook;
141
142 /*
143 * compat_bio compatability
144 */
145 struct compat_bio_30_hook_t compat_bio_30_hook;
146
147 /*
148 * vnd ioctl compatability
149 */
150 struct compat_vndioctl_30_hook_t compat_vndioctl_30_hook;
151 struct compat_vndioctl_50_hook_t compat_vndioctl_50_hook;
152
153 /*
154 * ieee80211 ioctl compatability
155 */
156 struct ieee80211_ioctl_20_hook_t ieee80211_ioctl_20_hook;
157
158 /*
159 * if_43 compatability
160 */
161 struct if_cvtcmd_43_hook_t if_cvtcmd_43_hook;
162 struct if_ifioctl_43_hook_t if_ifioctl_43_hook;
163
164 /*
165 * if43_cvtcmd_20 compatability
166 */
167 struct if43_cvtcmd_20_hook_t if43_cvtcmd_20_hook;
168
169 /*
170 * tty 43 ioctl compatibility
171 */
172 struct tty_ttioctl_43_hook_t tty_ttioctl_43_hook;
173
174 /*
175 * uipc_syscalls_40 compatability
176 */
177 struct uipc_syscalls_40_hook_t uipc_syscalls_40_hook;
178
179 /*
180 * uipc_syscalls_50 compatability
181 */
182 struct uipc_syscalls_50_hook_t uipc_syscalls_50_hook;
183
184 /*
185 * rtsock 14 compatability
186 */
187 struct rtsock_oifmsg_14_hook_t rtsock_oifmsg_14_hook;
188 struct rtsock_iflist_14_hook_t rtsock_iflist_14_hook;
189
190 /*
191 * rtsock 50 compatability
192 */
193 struct rtsock_iflist_50_hook_t rtsock_iflist_50_hook;
194 struct rtsock_oifmsg_50_hook_t rtsock_oifmsg_50_hook;
195 struct rtsock_rt_missmsg_50_hook_t rtsock_rt_missmsg_50_hook;
196 struct rtsock_rt_ifmsg_50_hook_t rtsock_rt_ifmsg_50_hook;
197 struct rtsock_rt_ifannouncemsg_50_hook_t rtsock_rt_ifannouncemsg_50_hook;
198 struct rtsock_rt_newaddrmsg_50_hook_t rtsock_rt_newaddrmsg_50_hook;
199 struct rtsock_rt_ieee80211msg_50_hook_t rtsock_rt_ieee80211msg_50_hook;
200
201 /*
202 * rtsock 70 compatability
203 */
204 struct rtsock_newaddr_70_hook_t rtsock_newaddr_70_hook;
205 struct rtsock_iflist_70_hook_t rtsock_iflist_70_hook;
206
207 /*
208 * modctl handler for old style OSTAT
209 */
210 struct compat_modstat_80_hook_t compat_modstat_80_hook;
211
212 /*
213 * mask for kern_sig_43's killpg (updated by compat_09)
214 */
215 int kern_sig_43_pgid_mask = ~0;
216
217 /*
218 * hook for kern_proc_32
219 */
220 struct kern_proc32_copyin_hook_t kern_proc32_copyin_hook;
221 struct kern_proc32_base_hook_t kern_proc32_base_hook;
222
223 /*
224 * Hook for sparc fpu code to check if a process is running
225 * under sunos emulation
226 */
227 struct get_emul_sunos_hook_t get_emul_sunos_hook;
228
229 /*
230 * Hook for rnd_ioctl_50 callbacks
231 */
232 struct rnd_ioctl_50_hook_t rnd_ioctl_50_hook;
233 struct rnd_ioctl32_50_hook_t rnd_ioctl32_50_hook;
234
235 /*
236 * Hooks for compat_60 ttioctl and ptmioctl
237 */
238 struct tty_ttioctl_60_hook_t tty_ttioctl_60_hook;
239 struct tty_ptmioctl_60_hook_t tty_ptmioctl_60_hook;
240
241 /*
242 * Hook for compat_10 openat
243 */
244 struct vfs_openat_10_hook_t vfs_openat_10_hook;
245
246 /*
247 * Hook for compat_70_unp_addsockcred
248 */
249 struct uipc_unp_70_hook_t uipc_unp_70_hook;
250
251 /*
252 * Hook for sysvipc50_sysctl
253 */
254 struct sysvipc_sysctl_50_hook_t sysvipc_sysctl_50_hook;
255
256 /*
257 * Hook for 32-bit machine name
258 *
259 * This probably would be better placed in compat/netbsd32/netbsd32_mod.c
260 * but the consumer code in linux32_exec_elf32.c is sometimes included in
261 * the main kernel, and not in a compat_netbsd32 module. (In particular,
262 * this is true for i386 and sgimips.)
263 */
264 struct netbsd32_machine32_hook_t netbsd32_machine32_hook;
265