Home | History | Annotate | Line # | Download | only in kern
compat_stub.c revision 1.9
      1 /* $NetBSD: compat_stub.c,v 1.9 2019/04/15 02:07:11 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 struct raidframe_netbsd32_ioctl_hook_t raidframe_netbsd32_ioctl_hook;
    118 
    119 /*
    120  * puffs compatability
    121  */
    122 
    123 struct puffs_out_50_hook_t puffs_out_50_hook;
    124 struct puffs_in_50_hook_t puffs_in_50_hook;
    125 
    126 /* XXX
    127 int (*puffs50_compat_outgoing)(struct puffs_req *, struct puffs_req **,
    128     ssize_t *) = (void *)enosys;
    129 void (*puffs50_compat_incoming)(struct puffs_req *, struct puffs_req *) =
    130     (void *)voidop;
    131    XXX */
    132 
    133 /*
    134  * wsevents compatability
    135  */
    136 struct wscons_copyout_events_50_hook_t wscons_copyout_events_50_hook;
    137 
    138 /*
    139  * sysmon_power compatability
    140  */
    141 struct compat_sysmon_power_40_hook_t compat_sysmon_power_40_hook;
    142 
    143 /*
    144  * compat_bio compatability
    145  */
    146 struct compat_bio_30_hook_t compat_bio_30_hook;
    147 
    148 /*
    149  * vnd ioctl compatability
    150  */
    151 struct compat_vndioctl_30_hook_t compat_vndioctl_30_hook;
    152 struct compat_vndioctl_50_hook_t compat_vndioctl_50_hook;
    153 
    154 /*
    155  * ieee80211 ioctl compatability
    156  */
    157 struct ieee80211_ioctl_20_hook_t ieee80211_ioctl_20_hook;
    158 
    159 /*
    160  * if_43 compatability
    161  */
    162 struct if_cvtcmd_43_hook_t if_cvtcmd_43_hook;
    163 struct if_ifioctl_43_hook_t if_ifioctl_43_hook;
    164 
    165 /*
    166  * if43_cvtcmd_20 compatability
    167  */
    168 struct if43_cvtcmd_20_hook_t if43_cvtcmd_20_hook;
    169 
    170 /*
    171  * tty 43 ioctl compatibility
    172  */
    173 struct tty_ttioctl_43_hook_t tty_ttioctl_43_hook;
    174 
    175 /*
    176  * uipc_syscalls_40 compatibility
    177  */
    178 struct uipc_syscalls_40_hook_t uipc_syscalls_40_hook;
    179 
    180 /*
    181  * uipc_socket_50 compatibility
    182  */
    183 struct uipc_socket_50_setopt1_hook_t uipc_socket_50_setopt1_hook;
    184 struct uipc_socket_50_getopt1_hook_t uipc_socket_50_getopt1_hook;
    185 struct uipc_socket_50_sbts_hook_t uipc_socket_50_sbts_hook;
    186 
    187 /*
    188  * uipc_syscalls_50 compatability
    189  */
    190 struct uipc_syscalls_50_hook_t uipc_syscalls_50_hook;
    191 
    192 /*
    193  * rtsock 14 compatability
    194  */
    195 struct rtsock_oifmsg_14_hook_t rtsock_oifmsg_14_hook;
    196 struct rtsock_iflist_14_hook_t rtsock_iflist_14_hook;
    197 
    198 /*
    199  * rtsock 50 compatability
    200  */
    201 struct rtsock_iflist_50_hook_t rtsock_iflist_50_hook;
    202 struct rtsock_oifmsg_50_hook_t rtsock_oifmsg_50_hook;
    203 struct rtsock_rt_missmsg_50_hook_t rtsock_rt_missmsg_50_hook;
    204 struct rtsock_rt_ifmsg_50_hook_t rtsock_rt_ifmsg_50_hook;
    205 struct rtsock_rt_ifannouncemsg_50_hook_t rtsock_rt_ifannouncemsg_50_hook;
    206 struct rtsock_rt_newaddrmsg_50_hook_t rtsock_rt_newaddrmsg_50_hook;
    207 struct rtsock_rt_ieee80211msg_50_hook_t rtsock_rt_ieee80211msg_50_hook;
    208 
    209 /*
    210  * rtsock 70 compatability
    211  */
    212 struct rtsock_newaddr_70_hook_t rtsock_newaddr_70_hook;
    213 struct rtsock_iflist_70_hook_t rtsock_iflist_70_hook;
    214 
    215 /*
    216  * modctl handler for old style OSTAT
    217  */
    218 struct compat_modstat_80_hook_t compat_modstat_80_hook;
    219 
    220 /*
    221  * mask for kern_sig_43's killpg (updated by compat_09)
    222  */
    223 int kern_sig_43_pgid_mask = ~0;
    224 
    225 /*
    226  * hook for kern_proc_32
    227  */
    228 struct kern_proc32_copyin_hook_t kern_proc32_copyin_hook;
    229 struct kern_proc32_base_hook_t kern_proc32_base_hook;
    230 
    231 /*
    232  * Hook for sparc fpu code to check if a process is running
    233  * under sunos emulation
    234  */
    235 struct get_emul_sunos_hook_t get_emul_sunos_hook;
    236 
    237 /*
    238  * Hook for rnd_ioctl_50 callbacks
    239  */
    240 struct rnd_ioctl_50_hook_t rnd_ioctl_50_hook;
    241 struct rnd_ioctl32_50_hook_t rnd_ioctl32_50_hook;
    242 
    243 /*
    244  * Hooks for compat_60 ttioctl and ptmioctl
    245  */
    246 struct tty_ttioctl_60_hook_t tty_ttioctl_60_hook;
    247 struct tty_ptmioctl_60_hook_t tty_ptmioctl_60_hook;
    248 
    249 /*
    250  * Hook for compat_10 openat
    251  */
    252 struct vfs_openat_10_hook_t vfs_openat_10_hook;
    253 
    254 /*
    255  * Hook for compat_70_unp_addsockcred
    256  */
    257 struct uipc_unp_70_hook_t uipc_unp_70_hook;
    258 
    259 /*
    260  * Hook for sysvipc50_sysctl
    261  */
    262 struct sysvipc_sysctl_50_hook_t sysvipc_sysctl_50_hook;
    263 
    264 /*
    265  * Hook for 32-bit machine name
    266  *
    267  * This probably would be better placed in compat/netbsd32/netbsd32_mod.c
    268  * but the consumer code in linux32_exec_elf32.c is sometimes included in
    269  * the main kernel, and not in a compat_netbsd32 module.  (In particular,
    270  * this is true for i386 and sgimips.)
    271  */
    272 struct netbsd32_machine32_hook_t netbsd32_machine32_hook;
    273