Module Name: src Committed By: pgoyette Date: Tue Mar 20 08:11:26 UTC 2018
Modified Files: src/sys/compat/common [pgoyette-compat]: ccd_60.c kern_time_50.c src/sys/dev [pgoyette-compat]: ccd.c src/sys/kern [pgoyette-compat]: files.kern src/sys/rump/librump/rumpkern [pgoyette-compat]: Makefile.rumpkern Added Files: src/sys/kern [pgoyette-compat]: compat_stub.c src/sys/sys [pgoyette-compat]: compat_stub.h Log Message: Initial implementation of sys/kern/kern_stup.c as discussed on tech-kern For now, we only handle the dev/ccd and NTP needs; more to follow. To generate a diff of this commit: cvs rdiff -u -r1.1.2.5 -r1.1.2.6 src/sys/compat/common/ccd_60.c cvs rdiff -u -r1.31.16.1 -r1.31.16.2 src/sys/compat/common/kern_time_50.c cvs rdiff -u -r1.175.2.1 -r1.175.2.2 src/sys/dev/ccd.c cvs rdiff -u -r0 -r1.1.2.1 src/sys/kern/compat_stub.c cvs rdiff -u -r1.16.2.4 -r1.16.2.5 src/sys/kern/files.kern cvs rdiff -u -r1.170 -r1.170.2.1 \ src/sys/rump/librump/rumpkern/Makefile.rumpkern cvs rdiff -u -r0 -r1.1.2.1 src/sys/sys/compat_stub.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/compat/common/ccd_60.c diff -u src/sys/compat/common/ccd_60.c:1.1.2.5 src/sys/compat/common/ccd_60.c:1.1.2.6 --- src/sys/compat/common/ccd_60.c:1.1.2.5 Mon Mar 19 21:53:04 2018 +++ src/sys/compat/common/ccd_60.c Tue Mar 20 08:11:25 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ccd_60.c,v 1.1.2.5 2018/03/19 21:53:04 pgoyette Exp $ */ +/* $NetBSD: ccd_60.c,v 1.1.2.6 2018/03/20 08:11:25 pgoyette Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -26,7 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ccd_60.c,v 1.1.2.5 2018/03/19 21:53:04 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ccd_60.c,v 1.1.2.6 2018/03/20 08:11:25 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -36,6 +36,7 @@ __KERNEL_RCSID(0, "$NetBSD: ccd_60.c,v 1 #include <sys/systm.h> #include <sys/disk.h> #include <sys/lwp.h> +#include <sys/compat_stub.h> #include <dev/ccdvar.h> #include <compat/sys/ccdvar.h> @@ -45,7 +46,6 @@ __KERNEL_RCSID(0, "$NetBSD: ccd_60.c,v 1 * sizeof (size_t) == sizeof (uint64_t) as CCDIOCSET will * be the same as CCDIOCSET_60 */ -#if 0 static int compat_60_ccdioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l, int (*f)(dev_t, u_long, void *, int, struct lwp *)) @@ -90,18 +90,17 @@ compat_60_ccdioctl(dev_t dev, u_long cmd return ENOSYS; } } -#endif /* 0 */ void ccd_60_init(void) { -// compat_ccd_ioctl_60 = compat_60_ccdioctl; + compat_ccd_ioctl_60 = compat_60_ccdioctl; } void ccd_60_fini(void) { -// compat_ccd_ioctl_60 = (void *)enosys; + compat_ccd_ioctl_60 = (void *)enosys; } Index: src/sys/compat/common/kern_time_50.c diff -u src/sys/compat/common/kern_time_50.c:1.31.16.1 src/sys/compat/common/kern_time_50.c:1.31.16.2 --- src/sys/compat/common/kern_time_50.c:1.31.16.1 Mon Mar 19 21:54:43 2018 +++ src/sys/compat/common/kern_time_50.c Tue Mar 20 08:11:25 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_time_50.c,v 1.31.16.1 2018/03/19 21:54:43 pgoyette Exp $ */ +/* $NetBSD: kern_time_50.c,v 1.31.16.2 2018/03/20 08:11:25 pgoyette Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_time_50.c,v 1.31.16.1 2018/03/19 21:54:43 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_time_50.c,v 1.31.16.2 2018/03/20 08:11:25 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_aio.h" @@ -61,6 +61,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_time_50 #include <sys/syscallvar.h> #include <sys/sysctl.h> #include <sys/resource.h> +#include <sys/compat_stub.h> #include <compat/common/compat_util.h> #include <compat/common/compat_mod.h> @@ -101,12 +102,9 @@ static const struct syscall_package kern (sy_call_t *)compat_50_sys_timer_gettime }, { SYS_compat_50___ntp_gettime30, 0, (sy_call_t *)compat_50_sys___ntp_gettime30 }, + { SYS_compat_50___ntp_gettime30, 0, + (sy_call_t *)compat_50_sys___ntp_gettime30 }, { 0, 0, NULL } - - - - - }; int @@ -556,10 +554,9 @@ int compat_50_sys___ntp_gettime30(struct lwp *l, const struct compat_50_sys___ntp_gettime30_args *uap, register_t *retval) { -/* XXX - * XXX need to detect if kernel has NTP at run-time! - * XXX */ -#ifdef NTP + if (vec_ntp_gettime == NULL) + return ENOSYS; /* No NTP available in kernel */ + /* { syscallarg(struct ntptimeval *) ntvp; } */ @@ -568,7 +565,7 @@ compat_50_sys___ntp_gettime30(struct lwp int error; if (SCARG(uap, ntvp)) { - ntp_gettime(&ntv); + (*vec_ntp_gettime)(&ntv); timespec_to_timespec50(&ntv.time, &ntv50.time); ntv50.maxerror = ntv.maxerror; ntv50.esterror = ntv.esterror; @@ -579,11 +576,8 @@ compat_50_sys___ntp_gettime30(struct lwp if (error) return error; } - *retval = ntp_timestatus(); + *retval = (*vec_ntp_timestatus)(); return 0; -#else - return ENOSYS; -#endif } static void Index: src/sys/dev/ccd.c diff -u src/sys/dev/ccd.c:1.175.2.1 src/sys/dev/ccd.c:1.175.2.2 --- src/sys/dev/ccd.c:1.175.2.1 Sun Mar 18 21:41:31 2018 +++ src/sys/dev/ccd.c Tue Mar 20 08:11:25 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ccd.c,v 1.175.2.1 2018/03/18 21:41:31 pgoyette Exp $ */ +/* $NetBSD: ccd.c,v 1.175.2.2 2018/03/20 08:11:25 pgoyette Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc. @@ -88,7 +88,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.175.2.1 2018/03/18 21:41:31 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.175.2.2 2018/03/20 08:11:25 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -119,6 +119,7 @@ __KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.17 #include <sys/kthread.h> #include <sys/bufq.h> #include <sys/sysctl.h> +#include <sys/compat_stub.h> #include <uvm/uvm_extern.h> @@ -1076,9 +1077,6 @@ ccdwrite(dev_t dev, struct uio *uio, int return (physio(ccdstrategy, NULL, dev, B_WRITE, minphys, uio)); } -int (*compat_ccd_ioctl_60)(dev_t, u_long, void *, int, struct lwp *, - int (*)(dev_t, u_long, void *, int, struct lwp *)) = (void *)enosys; - static int ccdioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) { Index: src/sys/kern/files.kern diff -u src/sys/kern/files.kern:1.16.2.4 src/sys/kern/files.kern:1.16.2.5 --- src/sys/kern/files.kern:1.16.2.4 Wed Mar 7 09:33:26 2018 +++ src/sys/kern/files.kern Tue Mar 20 08:11:25 2018 @@ -1,4 +1,4 @@ -# $NetBSD: files.kern,v 1.16.2.4 2018/03/07 09:33:26 pgoyette Exp $ +# $NetBSD: files.kern,v 1.16.2.5 2018/03/20 08:11:25 pgoyette Exp $ # # kernel sources @@ -11,6 +11,7 @@ file kern/bufq_disksort.c bufq_disksort file kern/bufq_fcfs.c bufq_fcfs file kern/bufq_priocscan.c bufq_priocscan file kern/bufq_readprio.c bufq_readprio | new_bufq_strategy +file kern/compat_stub.c kern file kern/core_elf32.c exec_elf32 file kern/core_elf64.c exec_elf64 file kern/core_netbsd.c exec_aout | exec_coff | exec_ecoff Index: src/sys/rump/librump/rumpkern/Makefile.rumpkern diff -u src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.170 src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.170.2.1 --- src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.170 Tue Jul 25 05:01:25 2017 +++ src/sys/rump/librump/rumpkern/Makefile.rumpkern Tue Mar 20 08:11:25 2018 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.rumpkern,v 1.170 2017/07/25 05:01:25 ozaki-r Exp $ +# $NetBSD: Makefile.rumpkern,v 1.170.2.1 2018/03/20 08:11:25 pgoyette Exp $ # .include "${RUMPTOP}/Makefile.rump" @@ -67,6 +67,7 @@ SRCS+= devsw.c # # sys/kern SRCS+= init_sysctl_base.c \ + compat_stub.c \ kern_auth.c \ kern_cfglock.c \ kern_clock.c \ Added files: Index: src/sys/kern/compat_stub.c diff -u /dev/null src/sys/kern/compat_stub.c:1.1.2.1 --- /dev/null Tue Mar 20 08:11:26 2018 +++ src/sys/kern/compat_stub.c Tue Mar 20 08:11:25 2018 @@ -0,0 +1,55 @@ +/* $NetBSD: compat_stub.c,v 1.1.2.1 2018/03/20 08:11:25 pgoyette Exp $ */ + +/*- + * Copyright (c) 2018 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Paul Goyette + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> + +#ifdef _KERNEL_OPT +#include "opt_ntp.h" +#endif + +#include <sys/systm.h> +#include <sys/compat_stub.h> + +/* + * Routine vectors for compat_50___sys_ntp_gettime + */ + +#ifdef NTP +void (*vec_ntp_gettime)(struct ntptimeval *) = ntp_gettime; +int (*vec_ntp_timestatus)(void) = ntp_timestatus; +#else +void (*vec_ntp_gettime)(struct ntptimeval *) = NULL; +int (*vec_ntp_timestatus)(void) = NULL; +#endif + +int (*compat_ccd_ioctl_60)(dev_t dev, u_long cmd, void *data, int flag, + struct lwp *l, int (*f)(dev_t, u_long, void *, int, struct lwp *)) = + (void *)enosys; Index: src/sys/sys/compat_stub.h diff -u /dev/null src/sys/sys/compat_stub.h:1.1.2.1 --- /dev/null Tue Mar 20 08:11:26 2018 +++ src/sys/sys/compat_stub.h Tue Mar 20 08:11:26 2018 @@ -0,0 +1,52 @@ +/* $NetBSD: compat_stub.h,v 1.1.2.1 2018/03/20 08:11:26 pgoyette Exp $ */ + +/*- + * Copyright (c) 2018 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Paul Goyette + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SYS_COMPAT_STUB_H +#define _SYS_COMPAT_STUB_H + +/* + * Routine vectors for compat_50___sys_ntp_gettime + */ + +#include <sys/timespec.h> +#include <sys/timex.h> + +extern void (*vec_ntp_gettime)(struct ntptimeval *); +extern int (*vec_ntp_timestatus)(void); + +/* + * Routine vector for dev/ccd ioctl() + */ + +extern int (*compat_ccd_ioctl_60)(dev_t, u_long, void *, int, struct lwp *, + int (*f)(dev_t, u_long, void *, int, struct lwp *)); + +#endif /* _SYS_COMPAT_STUB_H */