Source-Changes-HG archive

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

[src/trunk]: src/sys/dev stir in something at initialisation



details:   https://anonhg.NetBSD.org/src/rev/d9ec52df71bc
branches:  trunk
changeset: 537871:d9ec52df71bc
user:      dan <dan%NetBSD.org@localhost>
date:      Mon Oct 07 02:38:41 2002 +0000

description:
stir in something at initialisation

diffstat:

 sys/dev/rnd.c |  21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)

diffs (53 lines):

diff -r 8141fd44a328 -r d9ec52df71bc sys/dev/rnd.c
--- a/sys/dev/rnd.c     Mon Oct 07 02:33:55 2002 +0000
+++ b/sys/dev/rnd.c     Mon Oct 07 02:38:41 2002 +0000
@@ -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 @@
 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 @@
 
        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



Home | Main Index | Thread Index | Old Index