Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/pgoyette-compat]: src/sys Initial implementation of sys/kern/kern_stup.c...



details:   https://anonhg.NetBSD.org/src/rev/1a720fc52300
branches:  pgoyette-compat
changeset: 321073:1a720fc52300
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Tue Mar 20 08:11:25 2018 +0000

description:
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.

diffstat:

 sys/compat/common/ccd_60.c                  |  11 ++---
 sys/compat/common/kern_time_50.c            |  26 +++++--------
 sys/dev/ccd.c                               |   8 +--
 sys/kern/compat_stub.c                      |  55 +++++++++++++++++++++++++++++
 sys/kern/files.kern                         |   3 +-
 sys/rump/librump/rumpkern/Makefile.rumpkern |   3 +-
 sys/sys/compat_stub.h                       |  52 +++++++++++++++++++++++++++
 7 files changed, 129 insertions(+), 29 deletions(-)

diffs (truncated from 317 to 300 lines):

diff -r c20e5b50f377 -r 1a720fc52300 sys/compat/common/ccd_60.c
--- a/sys/compat/common/ccd_60.c        Tue Mar 20 06:23:36 2018 +0000
+++ b/sys/compat/common/ccd_60.c        Tue Mar 20 08:11:25 2018 +0000
@@ -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 @@
 #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 @@
  * 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 @@
                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;
 }
diff -r c20e5b50f377 -r 1a720fc52300 sys/compat/common/kern_time_50.c
--- a/sys/compat/common/kern_time_50.c  Tue Mar 20 06:23:36 2018 +0000
+++ b/sys/compat/common/kern_time_50.c  Tue Mar 20 08:11:25 2018 +0000
@@ -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 @@
 #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 @@
            (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 @@
 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 @@
        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 @@
                if (error)
                        return error;
        }
-       *retval = ntp_timestatus();
+       *retval = (*vec_ntp_timestatus)();
        return 0;
-#else
-       return ENOSYS;
-#endif
 }
 
 static void
diff -r c20e5b50f377 -r 1a720fc52300 sys/dev/ccd.c
--- a/sys/dev/ccd.c     Tue Mar 20 06:23:36 2018 +0000
+++ b/sys/dev/ccd.c     Tue Mar 20 08:11:25 2018 +0000
@@ -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 @@
 #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 @@
        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)
 {
diff -r c20e5b50f377 -r 1a720fc52300 sys/kern/compat_stub.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/kern/compat_stub.c    Tue Mar 20 08:11:25 2018 +0000
@@ -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;
diff -r c20e5b50f377 -r 1a720fc52300 sys/kern/files.kern
--- a/sys/kern/files.kern       Tue Mar 20 06:23:36 2018 +0000
+++ b/sys/kern/files.kern       Tue Mar 20 08:11:25 2018 +0000
@@ -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_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
diff -r c20e5b50f377 -r 1a720fc52300 sys/rump/librump/rumpkern/Makefile.rumpkern
--- a/sys/rump/librump/rumpkern/Makefile.rumpkern       Tue Mar 20 06:23:36 2018 +0000
+++ b/sys/rump/librump/rumpkern/Makefile.rumpkern       Tue Mar 20 08:11:25 2018 +0000
@@ -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 @@
 #
 # sys/kern
 SRCS+= init_sysctl_base.c      \
+       compat_stub.c           \
        kern_auth.c             \
        kern_cfglock.c          \
        kern_clock.c            \
diff -r c20e5b50f377 -r 1a720fc52300 sys/sys/compat_stub.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/sys/compat_stub.h     Tue Mar 20 08:11:25 2018 +0000
@@ -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
+
+/*



Home | Main Index | Thread Index | Old Index