Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Comment initialisation conditions for rnd better, an...



details:   https://anonhg.NetBSD.org/src/rev/004d0ebf492c
branches:  trunk
changeset: 537913:004d0ebf492c
user:      dan <dan%NetBSD.org@localhost>
date:      Tue Oct 08 12:12:56 2002 +0000

description:
Comment initialisation conditions for rnd better, and don't uselessly
call rnd_init - instead assert that it has already been called
earlier.

change assert() -> KASSERT()

diffstat:

 sys/dev/rnd.c     |  24 +++++++++++++-----------
 sys/dev/rndpool.c |   8 ++++----
 2 files changed, 17 insertions(+), 15 deletions(-)

diffs (93 lines):

diff -r 61fc7268f8f9 -r 004d0ebf492c sys/dev/rnd.c
--- a/sys/dev/rnd.c     Tue Oct 08 11:58:54 2002 +0000
+++ b/sys/dev/rnd.c     Tue Oct 08 12:12:56 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rnd.c,v 1.33 2002/10/08 09:59:27 dan Exp $     */
+/*     $NetBSD: rnd.c,v 1.34 2002/10/08 12:12:56 dan Exp $     */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rnd.c,v 1.33 2002/10/08 09:59:27 dan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rnd.c,v 1.34 2002/10/08 12:12:56 dan Exp $");
 
 #include <sys/param.h>
 #include <sys/ioctl.h>
@@ -280,27 +280,29 @@
 }
 
 /*
- * Attach the random device, and initialize the global random pool
- * for our use.
+ * "Attach" the random device. This is an (almost) empty stub, since
+ * pseudo-devices don't get attached until after config, after the
+ * entropy sources will attach. We just use the timing of this event
+ * as another potential source of initial entropy.
  */
 void
 rndattach(int num)
 {
        u_int32_t c;
 
-       /*
-        * rnd_init() is actually called very early on in the boot
-        * process, pseudo's don't get attached until much later
-        * (after many of the sources have been attached). 
-        * XXX Maybe this is left "in case", maybe it should be an assert?
-        */     
-       rnd_init();
+       /* Trap unwary players who don't call rnd_init() early */
+       KASSERT(rnd_ready);
 
        /* mix in another counter */
        c = rnd_counter();
        rndpool_add_data(&rnd_pool, &c, sizeof(u_int32_t), 0);
 }
 
+/*
+ * initialize the global random pool for our use.
+ * rnd_init() must be called very early on in the boot process, so
+ * the pool is ready for other devices to attach as sources.
+ */
 void
 rnd_init(void)
 {
diff -r 61fc7268f8f9 -r 004d0ebf492c sys/dev/rndpool.c
--- a/sys/dev/rndpool.c Tue Oct 08 11:58:54 2002 +0000
+++ b/sys/dev/rndpool.c Tue Oct 08 12:12:56 2002 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: rndpool.c,v 1.14 2001/11/15 09:48:03 lukem Exp $        */
+/*      $NetBSD: rndpool.c,v 1.15 2002/10/08 12:12:57 dan Exp $        */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rndpool.c,v 1.14 2001/11/15 09:48:03 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rndpool.c,v 1.15 2002/10/08 12:12:57 dan Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -71,7 +71,7 @@
        rp->stats.threshold = RND_ENTROPY_THRESHOLD;
        rp->stats.maxentropy = RND_POOLBITS;
 
-       assert(RND_ENTROPY_THRESHOLD*2 <= 20); /* XXX sha knowledge */
+       KASSERT(RND_ENTROPY_THRESHOLD*2 <= 20); /* XXX sha knowledge */
 }
 
 u_int32_t
@@ -241,7 +241,7 @@
        else
                good = (rp->stats.curentropy >= (8 * RND_ENTROPY_THRESHOLD));
 
-       assert(RND_ENTROPY_THRESHOLD*2 <= 20); /* XXX SHA knowledge */
+       KASSERT(RND_ENTROPY_THRESHOLD*2 <= 20); /* XXX SHA knowledge */
 
        while (good && (remain != 0)) {
                /*



Home | Main Index | Thread Index | Old Index