summaryrefslogtreecommitdiff
path: root/sys/dev/ld.c
diff options
context:
space:
mode:
authortls <tls@NetBSD.org>2012-02-02 19:42:57 +0000
committertls <tls@NetBSD.org>2012-02-02 19:42:57 +0000
commitcc9ee3de3e25ef31d3a97dc35bedc36945e35d2a (patch)
tree06a2889eb6b4b02bc8b8bba6b5cc3f9b1938d18b /sys/dev/ld.c
parentf622122a62827e27b444c2f95632d61f73357ced (diff)
Entropy-pool implementation move and cleanup.
1) Move core entropy-pool code and source/sink/sample management code to sys/kern from sys/dev. 2) Remove use of NRND as test for presence of entropy-pool code throughout source tree. 3) Remove use of RND_ENABLED in device drivers as microoptimization to avoid expensive operations on disabled entropy sources; make the rnd_add calls do this directly so all callers benefit. 4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might have lead to slight entropy overestimation for some sources. 5) Add new source types for environmental sensors, power sensors, VM system events, and skew between clocks, with a sample implementation for each. ok releng to go in before the branch due to the difficulty of later pullup (widespread #ifdef removal and moved files). Tested with release builds on amd64 and evbarm and live testing on amd64.
Diffstat (limited to 'sys/dev/ld.c')
-rw-r--r--sys/dev/ld.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/sys/dev/ld.c b/sys/dev/ld.c
index 7798a3d1726..300f43e5843 100644
--- a/sys/dev/ld.c
+++ b/sys/dev/ld.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ld.c,v 1.68 2010/09/20 06:54:06 kiyohara Exp $ */
+/* $NetBSD: ld.c,v 1.69 2012/02/02 19:43:01 tls Exp $ */
/*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,9 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.68 2010/09/20 06:54:06 kiyohara Exp $");
-
-#include "rnd.h"
+__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.69 2012/02/02 19:43:01 tls Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -56,9 +54,7 @@ __KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.68 2010/09/20 06:54:06 kiyohara Exp $");
#include <sys/vnode.h>
#include <sys/syslog.h>
#include <sys/mutex.h>
-#if NRND > 0
#include <sys/rnd.h>
-#endif
#include <dev/ldvar.h>
@@ -149,11 +145,9 @@ ldattach(struct ld_softc *sc)
ld_set_properties(sc);
-#if NRND > 0
/* Attach the device into the rnd source list. */
rnd_attach_source(&sc->sc_rnd_source, device_xname(sc->sc_dv),
RND_TYPE_DISK, 0);
-#endif
/* Register with PMF */
if (!pmf_device_register1(sc->sc_dv, ld_suspend, NULL, ld_shutdown))
@@ -243,10 +237,8 @@ ldenddetach(struct ld_softc *sc)
disk_detach(&sc->sc_dk);
disk_destroy(&sc->sc_dk);
-#if NRND > 0
/* Unhook the entropy source. */
rnd_detach_source(&sc->sc_rnd_source);
-#endif
/* Deregister with PMF */
pmf_device_deregister(sc->sc_dv);
@@ -725,9 +717,7 @@ lddone(struct ld_softc *sc, struct buf *bp)
disk_unbusy(&sc->sc_dk, bp->b_bcount - bp->b_resid,
(bp->b_flags & B_READ));
-#if NRND > 0
rnd_add_uint32(&sc->sc_rnd_source, bp->b_rawblkno);
-#endif
biodone(bp);
mutex_enter(&sc->sc_mutex);