Module Name:    src
Committed By:   jmcneill
Date:           Wed Jul 13 11:11:53 UTC 2016

Modified Files:
        src/sys/compat/netbsd32: netbsd32_ioctl.c netbsd32_ioctl.h

Log Message:
Add netbsd32 support for drvctl(4)


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/sys/compat/netbsd32/netbsd32_ioctl.c
cvs rdiff -u -r1.53 -r1.54 src/sys/compat/netbsd32/netbsd32_ioctl.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/netbsd32/netbsd32_ioctl.c
diff -u src/sys/compat/netbsd32/netbsd32_ioctl.c:1.83 src/sys/compat/netbsd32/netbsd32_ioctl.c:1.84
--- src/sys/compat/netbsd32/netbsd32_ioctl.c:1.83	Tue Dec  8 20:36:14 2015
+++ src/sys/compat/netbsd32/netbsd32_ioctl.c	Wed Jul 13 11:11:53 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_ioctl.c,v 1.83 2015/12/08 20:36:14 christos Exp $	*/
+/*	$NetBSD: netbsd32_ioctl.c,v 1.84 2016/07/13 11:11:53 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.83 2015/12/08 20:36:14 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.84 2016/07/13 11:11:53 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -56,6 +56,7 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_ioc
 #include <sys/clockctl.h>
 #include <sys/exec_elf.h>
 #include <sys/ksyms.h>
+#include <sys/drvctlio.h>
 
 #ifdef __sparc__
 #include <dev/sun/fbio.h>
@@ -475,6 +476,29 @@ netbsd32_to_npf_ioctl_table(
 	}
 }
 
+static inline void
+netbsd32_to_devlistargs(
+    const struct netbsd32_devlistargs *s32p,
+    struct devlistargs *p,
+    u_long cmd)
+{
+	memcpy(p->l_devname, s32p->l_devname, sizeof(p->l_devname));
+	p->l_children = s32p->l_children;
+	p->l_childname = NETBSD32PTR64(s32p->l_childname);
+}
+
+static inline void
+netbsd32_to_devrescanargs(
+    const struct netbsd32_devrescanargs *s32p,
+    struct devrescanargs *p,
+    u_long cmd)
+{
+	memcpy(p->busname, s32p->busname, sizeof(p->busname));
+	memcpy(p->ifattr, s32p->ifattr, sizeof(p->ifattr));
+	p->numlocators = s32p->numlocators;
+	p->locators = NETBSD32PTR64(s32p->locators);
+}
+
 /*
  * handle ioctl conversions from 64-bit kernel -> netbsd32
  */
@@ -874,6 +898,29 @@ netbsd32_from_npf_ioctl_table(
 	}
 }
 
+static inline void
+netbsd32_from_devlistargs(
+    const struct devlistargs *p,
+    struct netbsd32_devlistargs *s32p,
+    u_long cmd)
+{
+	memcpy(s32p->l_devname, p->l_devname, sizeof(s32p->l_devname));
+	s32p->l_children = p->l_children;
+	NETBSD32PTR32(s32p->l_childname, p->l_childname);
+}
+
+static inline void
+netbsd32_from_devrescanargs(
+    const struct devrescanargs *p,
+    struct netbsd32_devrescanargs *s32p,
+    u_long cmd)
+{
+	memcpy(s32p->busname, p->busname, sizeof(s32p->busname));
+	memcpy(s32p->ifattr, p->ifattr, sizeof(s32p->ifattr));
+	s32p->numlocators = p->numlocators;
+	NETBSD32PTR32(s32p->locators, p->locators);
+}
+
 /*
  * main ioctl syscall.
  *
@@ -1263,6 +1310,15 @@ netbsd32_ioctl(struct lwp *l, const stru
 	case IOC_NPF_RULE32:
 		IOCTL_STRUCT_CONV_TO(IOC_NPF_RULE, plistref);
 
+	case DRVRESCANBUS32:
+		IOCTL_STRUCT_CONV_TO(DRVRESCANBUS, devrescanargs);
+	case DRVLISTDEV32:
+		IOCTL_STRUCT_CONV_TO(DRVLISTDEV, devlistargs);
+	case DRVCTLCOMMAND32:
+		IOCTL_STRUCT_CONV_TO(DRVCTLCOMMAND, plistref);
+	case DRVGETEVENT32:
+		IOCTL_STRUCT_CONV_TO(DRVGETEVENT, plistref);
+
 	default:
 #ifdef NETBSD32_MD_IOCTL
 		error = netbsd32_md_ioctl(fp, com, data32, l);

Index: src/sys/compat/netbsd32/netbsd32_ioctl.h
diff -u src/sys/compat/netbsd32/netbsd32_ioctl.h:1.53 src/sys/compat/netbsd32/netbsd32_ioctl.h:1.54
--- src/sys/compat/netbsd32/netbsd32_ioctl.h:1.53	Tue Dec  8 20:36:14 2015
+++ src/sys/compat/netbsd32/netbsd32_ioctl.h	Wed Jul 13 11:11:53 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_ioctl.h,v 1.53 2015/12/08 20:36:14 christos Exp $	*/
+/*	$NetBSD: netbsd32_ioctl.h,v 1.54 2016/07/13 11:11:53 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -604,3 +604,22 @@ typedef struct netbsd32_npf_ioctl_table 
 #define IOC_NPF_STATS32         _IOW('N', 104, netbsd32_voidp)
 #define IOC_NPF_SAVE32          _IOR('N', 105, struct netbsd32_plistref)
 #define IOC_NPF_RULE32          _IOWR('N', 107, struct netbsd32_plistref)
+
+/* From sys/drvctlio.h */
+struct netbsd32_devlistargs {
+	char			l_devname[16];
+	netbsd32_charpp		l_childname;
+	netbsd32_size_t		l_children;
+};
+
+struct netbsd32_devrescanargs {
+	char			busname[16];
+	char			ifattr[16];
+	unsigned int		numlocators;
+	netbsd32_intp		locators;
+};
+
+#define	DRVRESCANBUS32		_IOW('D', 124, struct netbsd32_devrescanargs)
+#define DRVCTLCOMMAND32		_IOWR('D', 125, struct netbsd32_plistref)
+#define	DRVLISTDEV32		_IOWR('D', 127, struct netbsd32_devlistargs)
+#define DRVGETEVENT32		_IOR('D', 128, struct netbsd32_plistref)

Reply via email to