Initial commit of random source driver.
authormickey <mickey@openbsd.org>
Fri, 29 Mar 1996 12:05:34 +0000 (12:05 +0000)
committermickey <mickey@openbsd.org>
Fri, 29 Mar 1996 12:05:34 +0000 (12:05 +0000)
sys/arch/i386/i386/conf.c
sys/arch/i386/isa/pccons.c
sys/arch/i386/isa/pcvt/pcvt_drv.c
sys/arch/i386/isa/pcvt/pcvt_kbd.c
sys/conf/files
sys/kern/vfs_bio.c
sys/net/netisr.h
sys/sys/conf.h

index f94045c..179a571 100644 (file)
@@ -197,6 +197,8 @@ cdev_decl(svr4_net);
 cdev_decl(ccd);
 #include "joy.h"
 cdev_decl(joy);
+#include "rnd.h"
+cdev_decl(rnd);
 
 cdev_decl(ipl);
 #ifdef IPFILTER
@@ -257,7 +259,8 @@ struct cdevsw       cdevsw[] =
 #else
        cdev_notdef(),                  /* 43 */
 #endif
-       cdev_gen_ipf(NIPF,ipl),         /* 44 */
+       cdev_gen_ipf(NIPF,ipl),         /* 44 ip filtering */
+       cdev_rnd_init(NRND,rnd),        /* 45 random data source */
 };
 int    nchrdev = sizeof(cdevsw) / sizeof(cdevsw[0]);
 
index cc952ed..aefc27a 100644 (file)
@@ -1,3 +1,4 @@
+/*     $OpenBSD: pccons.c,v 1.6 1996/03/29 12:05:39 mickey Exp $       */
 /*     $NetBSD: pccons.c,v 1.91 1995/12/24 02:30:25 mycroft Exp $      */
 
 /*-
 #include <i386/isa/isa_machdep.h>
 #include <i386/isa/kbdreg.h>
 
+#include "rnd.h"
+#if    NRND
+#include <dev/rndvar.h>
+#endif
+
 #define        XFREE86_BUG_COMPAT
 
 #ifndef BEEP_FREQ
@@ -1421,6 +1427,10 @@ top:
                goto loop;
        }
 
+#if    NRND
+       add_keyboard_randomness(dt);
+#endif
+
        if (pc_xmode > 0) {
 #if defined(DDB) && defined(XSERVER_DDB)
                /* F12 enters the debugger while in X mode */
index 0f71a01..9644eb9 100644 (file)
 #define EXTERN                 /* allocate mem */
 
 #include "pcvt_hdr.h"          /* global include */
+#include "rnd.h"
+#if    NRND
+#include <dev/rndvar.h>
+#endif
 
 #ifdef NOTDEF
 unsigned       __debug = 0; /*0xffe */;
@@ -874,6 +878,9 @@ pcrint(void)
 
                dt = inb(CONTROLLER_DATA);              /* get it 8042 data */
 
+#if    NRND
+               add_keyboard_randomness(dt);
+#endif
                if (pcvt_kbd_count >= PCVT_KBD_FIFO_SZ) /* fifo overflow ? */
                {
                        log (LOG_WARNING, "pcvt: keyboard buffer overflow\n");
index d13008c..61773c8 100644 (file)
 #if NVT > 0
 
 #include "pcvt_hdr.h"          /* global include */
+#include "rnd.h"
+#if    NRND
+#include <dev/rndvar.h>
+#endif
 
 static void fkey1(void), fkey2(void),  fkey3(void),  fkey4(void);
 static void fkey5(void), fkey6(void),  fkey7(void),  fkey8(void);
@@ -999,6 +1003,9 @@ loop:
                PCVT_KBD_DELAY();               /* 7 us delay */
                dt = inb(CONTROLLER_DATA);      /* yes, get data */
 
+#if    NRND
+               add_keyboard_randomness(dt)
+#endif
 #endif /* !PCVT_KBD_FIFO */
 
                /*
index 2732125..4d790ad 100644 (file)
@@ -38,6 +38,7 @@ pseudo-device sl: ifnet
 pseudo-device ppp: ifnet
 pseudo-device tun: ifnet
 pseudo-device bpfilter: ifnet
+pseudo-device rnd
 
 # XXX machine-independent SCSI files should live somewhere here, maybe
 
@@ -69,6 +70,7 @@ file dev/ic/ncr5380sbc.c              ncr5380sbc
 file dev/ic/pdq.c                      pdq
 file dev/ic/pdq_ifsubr.c               pdq
 file dev/mulaw.c                       mulaw
+file dev/rnd.c                         rnd                     needs-flag
 file dev/vnd.c                         vnd                     needs-flag
 file isofs/cd9660/cd9660_bmap.c                cd9660
 file isofs/cd9660/cd9660_lookup.c      cd9660
index 0667f8e..1db9d35 100644 (file)
 #include <sys/conf.h>
 #include <sys/cpu.h>
 
+#include "rnd.h"
+#if    NRND > 0
+#include <dev/rndvar.h>
+#endif
+
 /* Macros to clear/set/test flags. */
 #define        SET(t, f)       (t) |= (f)
 #define        CLR(t, f)       (t) &= ~(f)
@@ -790,6 +795,10 @@ biodone(bp)
                panic("biodone already");
        SET(bp->b_flags, B_DONE);               /* note that it's done */
 
+#if    NRND > 0
+       add_blkdev_randomness(bp->b_dev);
+#endif
+
        if (!ISSET(bp->b_flags, B_READ))        /* wake up reader */
                vwakeup(bp);
 
index ed6a632..32db862 100644 (file)
 #define        NETISR_ARP      18              /* same as AF_LINK */
 #define NETISR_PPP     26              /* for PPP processing */
 
-#define        schednetisr(anisr)      { netisr |= 1<<(anisr); setsoftnet(); }
-
 #ifndef _LOCORE
 #ifdef _KERNEL
 int    netisr;                         /* scheduling bits for network */
+
+#include "rnd.h"
+#if NRND > 0
+#include <dev/rndvar.h>
+#define        schednetisr(anisr)      \
+       { netisr |= 1<<(anisr); add_net_randomness(anisr); setsoftnet(); }
+#else /* no rnd */
+#define        schednetisr(anisr)      { netisr |= 1<<(anisr); setsoftnet(); }
+#endif
 #endif
 #endif
index e4cb5e7..f4efd83 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: conf.h,v 1.3 1996/03/03 12:11:27 niklas Exp $ */
+/*     $OpenBSD: conf.h,v 1.4 1996/03/29 12:05:56 mickey Exp $ */
 /*     $NetBSD: conf.h,v 1.30 1996/02/13 21:08:50 christos Exp $       */
 
 /*-
@@ -305,6 +305,12 @@ extern struct cdevsw cdevsw[];
        (dev_type_stop((*))) enodev, 0, (dev_type_select((*))) enodev, \
        (dev_type_mmap((*))) enodev }
 
+/* open, close, read, write, ioctl, select */
+#define        cdev_rnd_init(c,n) { \
+       dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
+       dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
+       0, dev_init(c,n,select), (dev_type_mmap((*))) enodev }
+
 /* symbolic sleep message strings */
 extern char devopn[], devio[], devwait[], devin[], devout[];
 extern char devioc[], devcls[];