summaryrefslogtreecommitdiff
path: root/sys/arch/i386
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2000-07-18 15:17:20 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2000-07-18 15:17:20 +0000
commitc2cdca550c262bdc452a9fe3791dd5a0673a0e8c (patch)
treec7c049894f3352d691deac59d79a8ea96e66c4ac /sys/arch/i386
parent0ada1c70a544069a89d03cd00d54d3fe1d607195 (diff)
do not include random number in dmesg, per deraadt's suggestion.
instead, print rng number generation speed, measured.
Diffstat (limited to 'sys/arch/i386')
-rw-r--r--sys/arch/i386/pci/pchb.c51
1 files changed, 34 insertions, 17 deletions
diff --git a/sys/arch/i386/pci/pchb.c b/sys/arch/i386/pci/pchb.c
index 20159b5a8b9..a9c624d4092 100644
--- a/sys/arch/i386/pci/pchb.c
+++ b/sys/arch/i386/pci/pchb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pchb.c,v 1.16 2000/06/15 20:35:57 ho Exp $ */
+/* $OpenBSD: pchb.c,v 1.17 2000/07/18 15:17:19 mickey Exp $ */
/* $NetBSD: pchb.c,v 1.6 1997/06/06 23:29:16 thorpej Exp $ */
/*
@@ -307,11 +307,29 @@ pchbattach(parent, self, aux)
&& (r = bus_space_read_1(sc->bt, sc->bh,
I82802_RNG_DATA)) != 0
/*&& runfipstest()>=0*/) {
- printf (": RNG(%x)", r);
+ struct timeval tv1, tv2;
+
+ /* benchmark the RNG */
+ microtime(&tv1);
+ for (i = 8 * 1024; i--; ) {
+ while(!(bus_space_read_1(sc->bt,
+ sc->bh, I82802_RNG_RNGST) &
+ I82802_RNG_RNGST_DATAV));
+ (void)bus_space_read_1(sc->bt,
+ sc->bh, I82802_RNG_DATA);
+ }
+ microtime(&tv2);
+
+ timersub(&tv2, &tv1, &tv1);
+ if (tv1.tv_sec)
+ tv1.tv_usec +=
+ 1000000 * tv1.tv_sec;
+ printf(": rng active, %dK/sec",
+ 8 * 1000000 / tv1.tv_usec);
- sc->i = 4;
timeout_set(&sc->sc_tmo, pchb_rnd, sc);
- timeout_add(&sc->sc_tmo, 1);
+ sc->i = 4;
+ pchb_rnd(sc);
}
}
break;
@@ -342,21 +360,20 @@ pchb_rnd(v)
void *v;
{
struct pchb_softc *sc = v;
- int s, ret = -1;
+ int s, ret;
s = splhigh();
- if (bus_space_read_1(sc->bt, sc->bh, I82802_RNG_RNGST) &
- I82802_RNG_RNGST_DATAV)
- ret = bus_space_read_1(sc->bt, sc->bh, I82802_RNG_DATA);
- splx(s);
-
- if (ret >= 0) {
- if (sc->i--)
- sc->ax = (sc->ax << 8) + ret;
- else {
- sc->i = 4;
- add_true_randomness(sc->ax);
- }
+ while (!(bus_space_read_1(sc->bt, sc->bh, I82802_RNG_RNGST) &
+ I82802_RNG_RNGST_DATAV));
+ ret = bus_space_read_1(sc->bt, sc->bh, I82802_RNG_DATA);
+
+ if (sc->i--) {
+ sc->ax = (sc->ax << 8) | ret;
+ splx(s);
+ } else {
+ sc->i = 4;
+ splx(s);
+ add_true_randomness(sc->ax);
}
timeout_add(&sc->sc_tmo, 1);
}