summaryrefslogtreecommitdiffstats
path: root/sys/dev/hifn/hifn7751.c
diff options
context:
space:
mode:
authorsam <sam@FreeBSD.org>2003-03-11 22:47:06 +0000
committersam <sam@FreeBSD.org>2003-03-11 22:47:06 +0000
commit08b96bb1399a2789ebc9d72321d31751cec37e33 (patch)
treec4b232799e4ac8460f49b969f01ac7575565a38e /sys/dev/hifn/hifn7751.c
parent0c3ac305c83bd43547194c4582f11b1918260bba (diff)
downloadFreeBSD-src-08b96bb1399a2789ebc9d72321d31751cec37e33.zip
FreeBSD-src-08b96bb1399a2789ebc9d72321d31751cec37e33.tar.gz
o add crypto driver glue for using the new rndtest driver/module; this is
conditional in each driver on foo_RNDTEST being defined_ o bring HIFN_DEBUG and UBSEC_DEBUG out to be visible options; they control the debugging printfs that are set with hw.foo.debug (e.g. hw.hifn.debug)
Diffstat (limited to 'sys/dev/hifn/hifn7751.c')
-rw-r--r--sys/dev/hifn/hifn7751.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/sys/dev/hifn/hifn7751.c b/sys/dev/hifn/hifn7751.c
index cb58fe0..f7d60a4 100644
--- a/sys/dev/hifn/hifn7751.c
+++ b/sys/dev/hifn/hifn7751.c
@@ -41,11 +41,10 @@
*
*/
-#define HIFN_DEBUG
-
/*
* Driver for the Hifn 7751 encryption processor.
*/
+#include "opt_hifn.h"
#include <sys/param.h>
#include <sys/systm.h>
@@ -72,6 +71,10 @@
#include <pci/pcivar.h>
#include <pci/pcireg.h>
+
+#ifdef HIFN_RNDTEST
+#include <dev/rndtest/rndtest.h>
+#endif
#include <dev/hifn/hifn7751reg.h>
#include <dev/hifn/hifn7751var.h>
@@ -109,6 +112,9 @@ static devclass_t hifn_devclass;
DRIVER_MODULE(hifn, pci, hifn_driver, hifn_devclass, 0, 0);
MODULE_DEPEND(hifn, crypto, 1, 1, 1);
+#ifdef HIFN_RNDTEST
+MODULE_DEPEND(hifn, rndtest, 1, 1, 1);
+#endif
static void hifn_reset_board(struct hifn_softc *, int);
static void hifn_reset_puc(struct hifn_softc *);
@@ -230,6 +236,12 @@ hifn_partname(struct hifn_softc *sc)
return "Unknown-vendor unknown-part";
}
+static void
+default_harvest(struct rndtest_state *rsp, void *buf, u_int count)
+{
+ random_harvest(buf, count, count*NBBY, 0, RANDOM_PURE);
+}
+
/*
* Attach an interface that successfully probed.
*/
@@ -621,6 +633,15 @@ hifn_init_pubrng(struct hifn_softc *sc)
u_int32_t r;
int i;
+#ifdef HIFN_RNDTEST
+ sc->sc_rndtest = rndtest_attach(sc->sc_dev);
+ if (sc->sc_rndtest)
+ sc->sc_harvest = rndtest_harvest;
+ else
+ sc->sc_harvest = default_harvest;
+#else
+ sc->sc_harvest = default_harvest;
+#endif
if ((sc->sc_flags & HIFN_IS_7811) == 0) {
/* Reset 7951 public key/rng engine */
WRITE_REG_1(sc, HIFN_1_PUB_RESET,
@@ -705,7 +726,8 @@ hifn_rng(void *vsc)
if (sc->sc_rngfirst)
sc->sc_rngfirst = 0;
else
- random_harvest(num, RANDOM_BITS(2), RANDOM_PURE);
+ (*sc->sc_harvest)(sc->sc_rndtest,
+ num, sizeof (num));
}
} else {
num[0] = READ_REG_1(sc, HIFN_1_RNG_DATA);
@@ -714,7 +736,8 @@ hifn_rng(void *vsc)
if (sc->sc_rngfirst)
sc->sc_rngfirst = 0;
else
- random_harvest(num, RANDOM_BITS(1), RANDOM_PURE);
+ (*sc->sc_harvest)(sc->sc_rndtest,
+ num, sizeof (num[0]));
}
callout_reset(&sc->sc_rngto, sc->sc_rnghz, hifn_rng, sc);
OpenPOWER on IntegriCloud