Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat redo the cpu ucode compat code.
details: https://anonhg.NetBSD.org/src/rev/16dc1dbaf03d
branches: trunk
changeset: 360590:16dc1dbaf03d
user: christos <christos%NetBSD.org@localhost>
date: Sat Mar 17 19:00:23 2018 +0000
description:
redo the cpu ucode compat code.
diffstat:
sys/compat/common/Makefile.sysio | 4 +-
sys/compat/common/compat_mod.c | 11 ++++-
sys/compat/common/kern_cpu_60.c | 75 ++++++++++++++++++++++++++++++++++++++++
sys/compat/sys/cpuio.h | 7 +++-
4 files changed, 92 insertions(+), 5 deletions(-)
diffs (163 lines):
diff -r c85ee62c77ce -r 16dc1dbaf03d sys/compat/common/Makefile.sysio
--- a/sys/compat/common/Makefile.sysio Sat Mar 17 18:34:09 2018 +0000
+++ b/sys/compat/common/Makefile.sysio Sat Mar 17 19:00:23 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.sysio,v 1.8 2018/03/15 03:13:51 christos Exp $
+# $NetBSD: Makefile.sysio,v 1.9 2018/03/17 19:00:23 christos Exp $
# Sources for syscall and ioctl compatibility across the versions.
@@ -35,7 +35,7 @@
vfs_syscalls_50.c uipc_syscalls_50.c uvm_50.c
# Compatibility code for NetBSD 6.0
-SRCS+= kern_sa_60.c tty_60.c kern_time_60.c
+SRCS+= kern_sa_60.c tty_60.c kern_time_60.c kern_cpu_60.c
# Compatibility code for NetBSD 7.0
SRCS+= rtsock_70.c uipc_usrreq_70.c
diff -r c85ee62c77ce -r 16dc1dbaf03d sys/compat/common/compat_mod.c
--- a/sys/compat/common/compat_mod.c Sat Mar 17 18:34:09 2018 +0000
+++ b/sys/compat/common/compat_mod.c Sat Mar 17 19:00:23 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_mod.c,v 1.25 2018/03/15 03:13:51 christos Exp $ */
+/* $NetBSD: compat_mod.c,v 1.26 2018/03/17 19:00:23 christos Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.25 2018/03/15 03:13:51 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.26 2018/03/17 19:00:23 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -61,6 +61,7 @@
#include <compat/common/compat_mod.h>
#include <compat/common/if_43.h>
#include <compat/sys/uvm.h>
+#include <compat/sys/cpuio.h>
#if defined(COMPAT_09) || defined(COMPAT_43) || defined(COMPAT_50)
static struct sysctllog *compat_clog = NULL;
@@ -258,6 +259,9 @@
#ifdef COMPAT_50
uvm_50_init();
#endif
+#ifdef COMPAT_60
+ kern_cpu_60_init();
+#endif
return 0;
case MODULE_CMD_FINI:
@@ -321,6 +325,9 @@
#ifdef COMPAT_50
uvm_50_fini();
#endif
+#ifdef COMPAT_60
+ kern_cpu_60_fini();
+#endif
return 0;
default:
diff -r c85ee62c77ce -r 16dc1dbaf03d sys/compat/common/kern_cpu_60.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/common/kern_cpu_60.c Sat Mar 17 19:00:23 2018 +0000
@@ -0,0 +1,75 @@
+/* $NetBSD: kern_cpu_60.c,v 1.1 2018/03/17 19:00:23 christos Exp $ */
+
+/*-
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * 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>
+__KERNEL_RCSID(0, "$NetBSD: kern_cpu_60.c,v 1.1 2018/03/17 19:00:23 christos Exp $");
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/errno.h>
+#include <sys/kauth.h>
+#include <sys/cpu.h>
+#include <sys/cpuio.h>
+
+#include <compat/sys/cpuio.h>
+
+static int
+compat6_cpuctl_ioctl(u_long cmd, void *data)
+{
+ switch (cmd) {
+#if defined(CPU_UCODE) && defined(COMPAT_60)
+ case OIOC_CPU_UCODE_GET_VERSION:
+ return compat6_cpu_ucode_get_version(data);
+
+ case OIOC_CPU_UCODE_APPLY:
+ error = kauth_authorize_machdep(l->l_cred,
+ KAUTH_MACHDEP_CPU_UCODE_APPLY, NULL, NULL, NULL, NULL);
+ if (error)
+ return error;
+ return compat6_cpu_ucode_apply(data);
+#endif
+ default:
+ return ENOTTY;
+ }
+}
+
+void
+kern_cpu_60_init(void)
+{
+ compat_cpuctl_ioctl = compat6_cpuctl_ioctl;
+}
+
+void
+kern_cpu_60_fini(void)
+{
+ compat_cpuctl_ioctl = (void *)enosys;
+}
diff -r c85ee62c77ce -r 16dc1dbaf03d sys/compat/sys/cpuio.h
--- a/sys/compat/sys/cpuio.h Sat Mar 17 18:34:09 2018 +0000
+++ b/sys/compat/sys/cpuio.h Sat Mar 17 19:00:23 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpuio.h,v 1.5 2015/09/06 06:00:59 dholland Exp $ */
+/* $NetBSD: cpuio.h,v 1.6 2018/03/17 19:00:23 christos Exp $ */
#include <sys/ioccom.h>
@@ -7,5 +7,10 @@
char fwname[PATH_MAX];
};
+extern int (*compat_cpuctl_ioctl)(u_long, void *);
+
#define OIOC_CPU_UCODE_GET_VERSION _IOR('c', 4, struct compat6_cpu_ucode)
#define OIOC_CPU_UCODE_APPLY _IOW('c', 5, struct compat6_cpu_ucode)
+
+void kern_cpu_60_init(void);
+void kern_cpu_60_fini(void);
Home |
Main Index |
Thread Index |
Old Index