summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authordan <dan@NetBSD.org>2002-10-07 02:38:41 +0000
committerdan <dan@NetBSD.org>2002-10-07 02:38:41 +0000
commit168dbd282b47c2d33e1d36f5df31370337f2cf33 (patch)
tree732454a65ec7aef428d2b3dbaf510c1ddc6e5dba /sys/dev
parent99f05800ca0300302f74a72be0804276c88d381b (diff)
stir in something at initialisation
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/rnd.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/sys/dev/rnd.c b/sys/dev/rnd.c
index cf62f3a6095..407e68356f0 100644
--- a/sys/dev/rnd.c
+++ b/sys/dev/rnd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rnd.c,v 1.28 2002/09/06 13:18:43 gehenna Exp $ */
+/* $NetBSD: rnd.c,v 1.29 2002/10/07 02:38:41 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.28 2002/09/06 13:18:43 gehenna Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rnd.c,v 1.29 2002/10/07 02:38:41 dan Exp $");
#include <sys/param.h>
#include <sys/ioctl.h>
@@ -285,10 +285,17 @@ rndattach(int num)
void
rnd_init(void)
{
+#ifdef __HAVE_CPU_COUNTER
+ u_int32_t c;
+#endif
if (rnd_ready)
return;
+#ifdef __HAVE_CPU_COUNTER
+ c = rnd_counter();
+#endif
+
LIST_INIT(&rnd_sources);
SIMPLEQ_INIT(&rnd_samples);
@@ -297,6 +304,16 @@ rnd_init(void)
rndpool_init(&rnd_pool);
+#ifdef __HAVE_CPU_COUNTER
+ /* Mix *something*, *anything* into the pool to help it get started.
+ * However, it's not safe for rnd_counter to call microtime() yet, so
+ * we can only do this on platforms with a cpu counter.
+ * XXX more things to add would be nice.
+ */
+ rndpool_add_data(&rnd_pool, &c, sizeof(u_int32_t), 0);
+ c = rnd_counter();
+ rndpool_add_data(&rnd_pool, &c, sizeof(u_int32_t), 0);
+#endif
rnd_ready = 1;
#ifdef RND_VERBOSE