Source-Changes-HG archive

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

[src/trunk]: src New rndsource driver for Araneus Alea II TRNG USB devices.



details:   https://anonhg.NetBSD.org/src/rev/6ba83882a3a4
branches:  trunk
changeset: 353010:6ba83882a3a4
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Apr 17 08:59:37 2017 +0000

description:
New rndsource driver for Araneus Alea II TRNG USB devices.

Disabled by default in x86/GENERIC and usbdevices.config pending
review and testing without rump ugenhc in the way, but enabled in
x86/ALL for compile-testing.

(Hi gson!  Finally found a round tuit in my pocket, next to a certain
rectangular one.)

diffstat:

 distrib/sets/lists/base/shl.mi              |    5 +-
 distrib/sets/lists/comp/mi                  |    4 +-
 distrib/sets/lists/comp/shl.mi              |    3 +-
 distrib/sets/lists/debug/mi                 |    3 +-
 distrib/sets/lists/debug/shl.mi             |    3 +-
 sys/arch/amd64/conf/ALL                     |    7 +-
 sys/arch/amd64/conf/GENERIC                 |    7 +-
 sys/arch/i386/conf/ALL                      |    7 +-
 sys/arch/i386/conf/GENERIC                  |    7 +-
 sys/dev/usb/files.usb                       |    7 +-
 sys/dev/usb/ualea.c                         |  232 ++++++++++++++++++++++++++++
 sys/dev/usb/usbdevices.config               |    5 +-
 sys/dev/usb/usbdevs                         |    6 +-
 sys/rump/dev/Makefile.rumpdevcomp           |    4 +-
 sys/rump/dev/lib/libualea/Makefile          |   16 +
 sys/rump/dev/lib/libualea/UALEA.ioconf      |   11 +
 sys/rump/dev/lib/libualea/ualea_component.c |   44 +++++
 17 files changed, 353 insertions(+), 18 deletions(-)

diffs (truncated from 597 to 300 lines):

diff -r d9af21033495 -r 6ba83882a3a4 distrib/sets/lists/base/shl.mi
--- a/distrib/sets/lists/base/shl.mi    Mon Apr 17 08:34:58 2017 +0000
+++ b/distrib/sets/lists/base/shl.mi    Mon Apr 17 08:59:37 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: shl.mi,v 1.807 2017/04/14 02:43:27 ozaki-r Exp $
+# $NetBSD: shl.mi,v 1.808 2017/04/17 08:59:37 riastradh Exp $
 #
 # Note:        Don't delete entries from here - mark them as "obsolete" instead,
 #      unless otherwise stated below.
@@ -550,6 +550,9 @@
 ./usr/lib/librumpdev_sysmon.so                 base-rump-shlib         rump
 ./usr/lib/librumpdev_sysmon.so.0               base-rump-shlib         rump
 ./usr/lib/librumpdev_sysmon.so.0.0             base-rump-shlib         rump
+./usr/lib/librumpdev_ualea.so                  base-rump-shlib         rump
+./usr/lib/librumpdev_ualea.so.0                        base-rump-shlib         rump
+./usr/lib/librumpdev_ualea.so.0.0              base-rump-shlib         rump
 ./usr/lib/librumpdev_ubt.so                    base-rump-shlib         rump
 ./usr/lib/librumpdev_ubt.so.0                  base-rump-shlib         rump
 ./usr/lib/librumpdev_ubt.so.0.0                        base-rump-shlib         rump
diff -r d9af21033495 -r 6ba83882a3a4 distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi        Mon Apr 17 08:34:58 2017 +0000
+++ b/distrib/sets/lists/comp/mi        Mon Apr 17 08:59:37 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: mi,v 1.2123 2017/04/15 13:52:51 kamil Exp $
+#      $NetBSD: mi,v 1.2124 2017/04/17 08:59:37 riastradh Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 ./etc/mtree/set.comp                           comp-sys-root
@@ -3457,6 +3457,8 @@
 ./usr/lib/librumpdev_sysmon_p.a                        comp-c-proflib          rump,profile
 ./usr/lib/librumpdev_ubt.a                     comp-c-lib              rump
 ./usr/lib/librumpdev_ubt_p.a                   comp-c-proflib          rump,profile
+./usr/lib/librumpdev_ualea.a                   comp-c-lib              rump
+./usr/lib/librumpdev_ualea_p.a                 comp-c-proflib          rump,profile
 ./usr/lib/librumpdev_ucom.a                    comp-c-lib              rump
 ./usr/lib/librumpdev_ucom_p.a                  comp-c-proflib          rump,profile
 ./usr/lib/librumpdev_ugenhc.a                  comp-c-lib              rump
diff -r d9af21033495 -r 6ba83882a3a4 distrib/sets/lists/comp/shl.mi
--- a/distrib/sets/lists/comp/shl.mi    Mon Apr 17 08:34:58 2017 +0000
+++ b/distrib/sets/lists/comp/shl.mi    Mon Apr 17 08:59:37 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: shl.mi,v 1.302 2017/04/14 02:43:27 ozaki-r Exp $
+# $NetBSD: shl.mi,v 1.303 2017/04/17 08:59:37 riastradh Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -169,6 +169,7 @@
 ./usr/lib/librumpdev_scsipi_pic.a              comp-c-piclib           picinstall,rump
 ./usr/lib/librumpdev_scsitest_pic.a            comp-obsolete           obsolete
 ./usr/lib/librumpdev_sysmon_pic.a              comp-c-piclib           picinstall,rump
+./usr/lib/librumpdev_ualea_pic.a               comp-c-piclib           picinstall,rump
 ./usr/lib/librumpdev_ubt_pic.a                 comp-c-piclib           picinstall,rump
 ./usr/lib/librumpdev_ucom_pic.a                        comp-c-piclib           picinstall,rump
 ./usr/lib/librumpdev_ugenhc_pic.a              comp-c-piclib           picinstall,rump
diff -r d9af21033495 -r 6ba83882a3a4 distrib/sets/lists/debug/mi
--- a/distrib/sets/lists/debug/mi       Mon Apr 17 08:34:58 2017 +0000
+++ b/distrib/sets/lists/debug/mi       Mon Apr 17 08:59:37 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.206 2017/04/14 15:20:39 riastradh Exp $
+# $NetBSD: mi,v 1.207 2017/04/17 08:59:37 riastradh Exp $
 ./etc/mtree/set.debug                           comp-sys-root
 ./usr/lib                                      comp-sys-usr            compatdir
 ./usr/lib/i18n/libBIG5_g.a                     comp-c-debuglib         debuglib,compatfile
@@ -160,6 +160,7 @@
 ./usr/lib/librumpdev_scsipi_g.a                        comp-c-debuglib         debuglib,rump
 ./usr/lib/librumpdev_scsitest_g.a              comp-obsolete           obsolete,compatfile
 ./usr/lib/librumpdev_sysmon_g.a                        comp-c-debuglib         debuglib,rump
+./usr/lib/librumpdev_ualea_g.a                 comp-c-debuglib         debuglib,rump
 ./usr/lib/librumpdev_ubt_g.a                   comp-c-debuglib         debuglib,rump
 ./usr/lib/librumpdev_ucom_g.a                  comp-c-debuglib         debuglib,rump
 ./usr/lib/librumpdev_ugenhc_g.a                        comp-c-debuglib         debuglib,rump
diff -r d9af21033495 -r 6ba83882a3a4 distrib/sets/lists/debug/shl.mi
--- a/distrib/sets/lists/debug/shl.mi   Mon Apr 17 08:34:58 2017 +0000
+++ b/distrib/sets/lists/debug/shl.mi   Mon Apr 17 08:59:37 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: shl.mi,v 1.166 2017/04/14 15:21:28 riastradh Exp $
+# $NetBSD: shl.mi,v 1.167 2017/04/17 08:59:37 riastradh Exp $
 ./usr/lib/libbfd_g.a                                           comp-c-debuglib debuglib,compatfile,binutils
 ./usr/libdata/debug/lib                                                base-sys-usr    debug,dynamicroot,compatdir
 ./usr/libdata/debug/lib/libblacklist.so.0.0.debug              comp-sys-debug  debug,dynamicroot
@@ -193,6 +193,7 @@
 ./usr/libdata/debug/usr/lib/librumpdev_scsipi.so.0.0.debug     comp-rump-debug debug,rump
 ./usr/libdata/debug/usr/lib/librumpdev_scsitest.so.0.0.debug   comp-obsolete   debug,compatfile,obsolete
 ./usr/libdata/debug/usr/lib/librumpdev_sysmon.so.0.0.debug     comp-rump-debug debug,rump
+./usr/libdata/debug/usr/lib/librumpdev_ualea.so.0.0.debug      comp-rump-debug debug,rump
 ./usr/libdata/debug/usr/lib/librumpdev_ubt.so.0.0.debug                comp-rump-debug debug,rump
 ./usr/libdata/debug/usr/lib/librumpdev_ucom.so.0.0.debug       comp-rump-debug debug,rump
 ./usr/libdata/debug/usr/lib/librumpdev_ugenhc.so.0.0.debug     comp-rump-debug debug,rump
diff -r d9af21033495 -r 6ba83882a3a4 sys/arch/amd64/conf/ALL
--- a/sys/arch/amd64/conf/ALL   Mon Apr 17 08:34:58 2017 +0000
+++ b/sys/arch/amd64/conf/ALL   Mon Apr 17 08:59:37 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.54 2017/03/08 18:00:49 maxv Exp $
+# $NetBSD: ALL,v 1.55 2017/04/17 08:59:37 riastradh Exp $
 # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
 #
 # ALL machine description file
@@ -17,7 +17,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident         "ALL-$Revision: 1.54 $"
+#ident         "ALL-$Revision: 1.55 $"
 
 maxusers       64              # estimated number of users
 
@@ -1283,6 +1283,9 @@
 ugensa* at uhub? port ?
 ucom*  at ugensa?
 
+# Araneus Alea II TRNG
+ualea* at uhub? port ? configuration ? interface ?
+
 # IrDA and Consumer Ir devices
 
 # Toshiba Oboe
diff -r d9af21033495 -r 6ba83882a3a4 sys/arch/amd64/conf/GENERIC
--- a/sys/arch/amd64/conf/GENERIC       Mon Apr 17 08:34:58 2017 +0000
+++ b/sys/arch/amd64/conf/GENERIC       Mon Apr 17 08:59:37 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.455 2017/03/10 14:54:12 maxv Exp $
+# $NetBSD: GENERIC,v 1.456 2017/04/17 08:59:37 riastradh Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident         "GENERIC-$Revision: 1.455 $"
+#ident         "GENERIC-$Revision: 1.456 $"
 
 maxusers       64              # estimated number of users
 
@@ -1060,6 +1060,9 @@
 ugensa* at uhub? port ?
 ucom*  at ugensa?
 
+# Araneus Alea II TRNG
+#ualea* at uhub? port ? configuration ? interface ?
+
 # IrDA and Consumer Ir devices
 
 # Toshiba Oboe
diff -r d9af21033495 -r 6ba83882a3a4 sys/arch/i386/conf/ALL
--- a/sys/arch/i386/conf/ALL    Mon Apr 17 08:34:58 2017 +0000
+++ b/sys/arch/i386/conf/ALL    Mon Apr 17 08:59:37 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.415 2017/03/08 18:00:49 maxv Exp $
+# $NetBSD: ALL,v 1.416 2017/04/17 08:59:37 riastradh Exp $
 # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
 #
 # ALL machine description file
@@ -17,7 +17,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident         "ALL-$Revision: 1.415 $"
+#ident         "ALL-$Revision: 1.416 $"
 
 maxusers       64              # estimated number of users
 
@@ -1441,6 +1441,9 @@
 ugensa* at uhub? port ?
 ucom*  at ugensa?
 
+# Araneus Alea II TRNG
+ualea* at uhub? port ? configuration ? interface ?
+
 # IrDA and Consumer Ir devices
 
 # Toshiba Oboe
diff -r d9af21033495 -r 6ba83882a3a4 sys/arch/i386/conf/GENERIC
--- a/sys/arch/i386/conf/GENERIC        Mon Apr 17 08:34:58 2017 +0000
+++ b/sys/arch/i386/conf/GENERIC        Mon Apr 17 08:59:37 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.1152 2017/02/26 12:41:50 rin Exp $
+# $NetBSD: GENERIC,v 1.1153 2017/04/17 08:59:37 riastradh Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident         "GENERIC-$Revision: 1.1152 $"
+#ident         "GENERIC-$Revision: 1.1153 $"
 
 maxusers       64              # estimated number of users
 
@@ -1360,6 +1360,9 @@
 ugensa* at uhub? port ?
 ucom*  at ugensa?
 
+# Araneus Alea II TRNG
+#ualea* at uhub? port ? configuration ? interface ?
+
 # IrDA and Consumer Ir devices
 
 # Toshiba Oboe
diff -r d9af21033495 -r 6ba83882a3a4 sys/dev/usb/files.usb
--- a/sys/dev/usb/files.usb     Mon Apr 17 08:34:58 2017 +0000
+++ b/sys/dev/usb/files.usb     Mon Apr 17 08:59:37 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.usb,v 1.142 2016/11/25 12:45:28 skrll Exp $
+#      $NetBSD: files.usb,v 1.143 2017/04/17 08:59:37 riastradh Exp $
 #
 # Config file and device description for machine-independent USB code.
 # Included by ports that need it.  Ports that use it must provide
@@ -544,3 +544,8 @@
 device udsir: irbus, irdasir
 attach udsir at usbifif
 file   dev/usb/udsir.c                 udsir
+
+# Araneus Alea II TRNG
+device ualea
+attach ualea at usbifif
+file   dev/usb/ualea.c                 ualea
diff -r d9af21033495 -r 6ba83882a3a4 sys/dev/usb/ualea.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/usb/ualea.c       Mon Apr 17 08:59:37 2017 +0000
@@ -0,0 +1,232 @@
+/*     $NetBSD: ualea.c,v 1.1 2017/04/17 08:59:37 riastradh Exp $      */
+
+/*-
+ * Copyright (c) 2017 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Taylor R. Campbell.
+ *
+ * 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: ualea.c,v 1.1 2017/04/17 08:59:37 riastradh Exp $");
+
+#include <sys/types.h>
+#include <sys/atomic.h>
+#include <sys/device_if.h>
+#include <sys/kmem.h>
+#include <sys/rndpool.h>
+#include <sys/rndsource.h>
+
+#include <dev/usb/usb.h>
+#include <dev/usb/usbdevs.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+
+struct ualea_softc {
+       device_t                sc_dev;
+       struct usbd_device      *sc_udev;
+       struct usbd_interface   *sc_uif;
+       kmutex_t                sc_lock;
+       krndsource_t            sc_rnd;
+       uint16_t                sc_maxpktsize;
+       struct usbd_pipe        *sc_pipe;
+       struct usbd_xfer        *sc_xfer;
+       bool                    sc_attached:1;
+       bool                    sc_inflight:1;
+       /*
+        * attached true->false only under lock
+        * inflight false->true only under lock
+        * issue xfer only under lock, if attached=true and inflight=false
+        */
+};
+
+static int     ualea_match(device_t, cfdata_t, void *);
+static void    ualea_attach(device_t, device_t, void *);
+static int     ualea_detach(device_t, int);
+static void    ualea_get(size_t, void *);
+static void    ualea_xfer_done(struct usbd_xfer *, void *, usbd_status);
+
+CFATTACH_DECL_NEW(ualea, sizeof(struct ualea_softc),
+    ualea_match, ualea_attach, ualea_detach, NULL);
+
+static const struct usb_devno ualea_devs[] = {
+       { USB_VENDOR_ARANEUS,   USB_PRODUCT_ARANEUS_ALEA_II },
+};
+
+static int



Home | Main Index | Thread Index | Old Index