summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/rnd.c24
-rw-r--r--sys/dev/rndpool.c8
2 files changed, 17 insertions, 15 deletions
diff --git a/sys/dev/rnd.c b/sys/dev/rnd.c
index d8f0b814a72..47e3f656304 100644
--- a/sys/dev/rnd.c
+++ b/sys/dev/rnd.c
@@ -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 @@ rnd_estimate_entropy(rndsource_t *rs, u_int32_t t)
}
/*
- * 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 --git a/sys/dev/rndpool.c b/sys/dev/rndpool.c
index 6a2fdf23c95..5a1e9feea4e 100644
--- a/sys/dev/rndpool.c
+++ b/sys/dev/rndpool.c
@@ -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 @@ rndpool_init(rndpool_t *rp)
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 @@ rndpool_extract_data(rndpool_t *rp, void *p, u_int32_t len, u_int32_t mode)
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)) {
/*