diff options
author | Jason Wright <jason@cvs.openbsd.org> | 2001-06-26 05:16:46 +0000 |
---|---|---|
committer | Jason Wright <jason@cvs.openbsd.org> | 2001-06-26 05:16:46 +0000 |
commit | 2874ae9b91e3a28a163edf399ddcaae8d084ae78 (patch) | |
tree | 8e0ada4e4b1d36574d3e79bcf24067141b12c1b7 /sys/dev/pci | |
parent | 4f5551761ca466ce3c4d4091a19f87651112fe07 (diff) |
add support for hardware rng using default scalar (can generate up to a
3Mbit/s stream, but we're not using that... yet).
Diffstat (limited to 'sys/dev/pci')
-rw-r--r-- | sys/dev/pci/lofn.c | 38 | ||||
-rw-r--r-- | sys/dev/pci/lofnreg.h | 3 |
2 files changed, 34 insertions, 7 deletions
diff --git a/sys/dev/pci/lofn.c b/sys/dev/pci/lofn.c index da38fbd7fb4..05a2b2c9ee7 100644 --- a/sys/dev/pci/lofn.c +++ b/sys/dev/pci/lofn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lofn.c,v 1.2 2001/06/26 03:54:31 jason Exp $ */ +/* $OpenBSD: lofn.c,v 1.3 2001/06/26 05:16:45 jason Exp $ */ /* * Copyright (c) 2001 Jason L. Wright (jason@thought.net) @@ -135,7 +135,13 @@ lofn_attach(parent, self, aux) goto fail_io; } - printf("\n"); + /* Enable RNG */ + WRITE_REG_0(sc, LOFN_REL_IER, + READ_REG_0(sc, LOFN_REL_IER) | LOFN_IER_RDY); + WRITE_REG_0(sc, LOFN_REL_CFG2, + READ_REG_0(sc, LOFN_REL_CFG2) | LOFN_CFG2_RNGENA); + + printf(": %s\n", intrstr); return; @@ -145,8 +151,30 @@ fail_io: } int -lofn_intr(arg) - void *arg; +lofn_intr(vsc) + void *vsc; { - return (0); + struct lofn_softc *sc = vsc; + u_int32_t sr; + int r = 0, i; + + sr = READ_REG_0(sc, LOFN_REL_SR); + + if (sr & LOFN_SR_RNG_UF) { + r = 1; + printf("%s: rng underflow (disabling)\n", sc->sc_dv.dv_xname); + WRITE_REG_0(sc, LOFN_REL_CFG2, + READ_REG_0(sc, LOFN_REL_CFG2) & (~LOFN_CFG2_RNGENA)); + WRITE_REG_0(sc, LOFN_REL_IER, + READ_REG_0(sc, LOFN_REL_IER) & (~LOFN_IER_RDY)); + } else if (sr & LOFN_SR_RNG_RDY) { + r = 1; + + bus_space_read_region_4(sc->sc_st, sc->sc_sh, 0x1080, + sc->sc_rngbuf, LOFN_RNGBUF_SIZE); + for (i = 0; i < LOFN_RNGBUF_SIZE; i++) + add_true_randomness(sc->sc_rngbuf[i]); + } + + return (r); } diff --git a/sys/dev/pci/lofnreg.h b/sys/dev/pci/lofnreg.h index 07d794542bc..f17d6d81b3e 100644 --- a/sys/dev/pci/lofnreg.h +++ b/sys/dev/pci/lofnreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: lofnreg.h,v 1.3 2001/06/26 03:41:01 jason Exp $ */ +/* $OpenBSD: lofnreg.h,v 1.4 2001/06/26 05:16:45 jason Exp $ */ /* * Copyright (c) 2001 Jason L. Wright (jason@thought.net) @@ -68,4 +68,3 @@ #define LOFN_CFG2_PRCENA 0x00000002 /* Processor enable */ #define LOFN_CHIPID_MASK 0x0000ffff /* Chip ID */ - |