From 489b832f9b48edfe684164d955acec36e053bb26 Mon Sep 17 00:00:00 2001 From: he Date: Tue, 10 Oct 2000 19:58:42 +0000 Subject: [PATCH] Add randomness sampling from hil, sd and rd devices. --- sys/arch/hp300/dev/hil.c | 21 ++++++++++++++++++++- sys/arch/hp300/dev/hilvar.h | 5 ++++- sys/arch/hp300/dev/rd.c | 21 ++++++++++++++++++--- sys/arch/hp300/dev/rdvar.h | 5 ++++- sys/arch/hp300/dev/sd.c | 21 ++++++++++++++++++--- sys/arch/hp300/dev/sdvar.h | 5 ++++- 6 files changed, 68 insertions(+), 10 deletions(-) diff --git a/sys/arch/hp300/dev/hil.c b/sys/arch/hp300/dev/hil.c index 4fea66804d30..6480eb856b28 100644 --- a/sys/arch/hp300/dev/hil.c +++ b/sys/arch/hp300/dev/hil.c @@ -1,4 +1,4 @@ -/* $NetBSD: hil.c,v 1.40 2000/06/26 04:55:39 simonb Exp $ */ +/* $NetBSD: hil.c,v 1.41 2000/10/10 19:58:42 he Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -43,6 +43,7 @@ */ #include "opt_compat_hpux.h" +#include "rnd.h" #include #include @@ -57,6 +58,10 @@ #include #include +#if NRND > 0 +#include +#endif + #include #include #include @@ -825,6 +830,9 @@ hilint(unit) stat = READHILSTAT(hildevice); c = READHILDATA(hildevice); /* clears interrupt */ hil_process_int(hilp, stat, c); +#if NRND > 0 + rnd_add_uint32(&hilp->rnd_source, (stat<<8)|c); +#endif } #include "ite.h" @@ -1338,6 +1346,17 @@ hilinfo(unit) printf(" 0"); printf("\n"); } +#if NRND > 0 + /* + * attach the device into the random source list + * except from ID module (no point) + */ + if (!id) { + char buf[10]; + sprintf(buf, "hil%d", unit); + rnd_attach_source(&hilp->rnd_source, buf, RND_TYPE_TTY, 0); + } +#endif } #define HILAR1 0x3E diff --git a/sys/arch/hp300/dev/hilvar.h b/sys/arch/hp300/dev/hilvar.h index 0d5895415b19..cd6007207de9 100644 --- a/sys/arch/hp300/dev/hilvar.h +++ b/sys/arch/hp300/dev/hilvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: hilvar.h,v 1.15 1998/06/25 23:57:35 thorpej Exp $ */ +/* $NetBSD: hilvar.h,v 1.16 2000/10/10 19:58:43 he Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -111,6 +111,9 @@ struct hil_softc { u_char hl_kbddev; /* keyboard device on loop */ u_char hl_kbdlang; /* keyboard language */ u_char hl_kbdflags; /* keyboard state */ +#if NRND > 0 + rndsource_element_t rnd_source; +#endif }; /* hl_kbdflags */ diff --git a/sys/arch/hp300/dev/rd.c b/sys/arch/hp300/dev/rd.c index 8f66acd4b334..492be7f445ce 100644 --- a/sys/arch/hp300/dev/rd.c +++ b/sys/arch/hp300/dev/rd.c @@ -1,4 +1,4 @@ -/* $NetBSD: rd.c,v 1.43 2000/05/27 04:52:28 thorpej Exp $ */ +/* $NetBSD: rd.c,v 1.44 2000/10/10 19:58:43 he Exp $ */ /*- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. @@ -82,6 +82,9 @@ * CS80/SS80 disk driver */ +#include "opt_useleds.h" +#include "rnd.h" + #include #include #include @@ -94,13 +97,15 @@ #include #include +#if NRND > 0 +#include +#endif + #include #include #include -#include "opt_useleds.h" - #ifdef USELEDS #include #endif @@ -350,6 +355,13 @@ rdattach(parent, self, aux) if (rddebug & RDB_ERROR) rderrthresh = 0; #endif +#if NRND > 0 + /* + * attach the device into the random source list + */ + rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname, + RND_TYPE_DISK, 0); +#endif } int @@ -934,6 +946,9 @@ rdintr(arg) } if (rdfinish(rs, bp)) rdustart(rs); +#if NRND > 0 + rnd_add_uint32(&rs->rnd_source, bp->b_blkno); +#endif } int diff --git a/sys/arch/hp300/dev/rdvar.h b/sys/arch/hp300/dev/rdvar.h index 81d223003381..be2d0b646bb2 100644 --- a/sys/arch/hp300/dev/rdvar.h +++ b/sys/arch/hp300/dev/rdvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: rdvar.h,v 1.9 2000/03/23 06:37:24 thorpej Exp $ */ +/* $NetBSD: rdvar.h,v 1.10 2000/10/10 19:58:43 he Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -84,6 +84,9 @@ struct rd_softc { int sc_active; int sc_errcnt; struct rdstats sc_stats; +#if NRND > 0 + rndsource_element_t rnd_source; +#endif }; /* sc_flags values */ diff --git a/sys/arch/hp300/dev/sd.c b/sys/arch/hp300/dev/sd.c index 9ee96f1aa262..5656d7ce4e10 100644 --- a/sys/arch/hp300/dev/sd.c +++ b/sys/arch/hp300/dev/sd.c @@ -1,4 +1,4 @@ -/* $NetBSD: sd.c,v 1.43 2000/07/17 06:51:18 scottr Exp $ */ +/* $NetBSD: sd.c,v 1.44 2000/10/10 19:58:43 he Exp $ */ /*- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. @@ -78,6 +78,9 @@ * SCSI CCS (Command Command Set) disk driver. */ +#include "rnd.h" +#include "opt_useleds.h" + #include #include #include @@ -90,12 +93,14 @@ #include #include +#if NRND > 0 +#include +#endif + #include #include #include -#include "opt_useleds.h" - #ifdef USELEDS #include #endif @@ -296,6 +301,13 @@ sdattach(parent, self, aux) disk_attach(&sc->sc_dkdev); sc->sc_flags |= SDF_ALIVE; +#if NRND > 0 + /* + * attach the device into the random source list + */ + rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname, + RND_TYPE_DISK, 0); +#endif } void @@ -1008,6 +1020,9 @@ sdintr(arg, stat) } } sdfinish(sc, bp); +#if NRND > 0 + rnd_add_uint32(&sc->rnd_source, bp->b_blkno); +#endif } int diff --git a/sys/arch/hp300/dev/sdvar.h b/sys/arch/hp300/dev/sdvar.h index 5bf46ed696c4..6895b863399a 100644 --- a/sys/arch/hp300/dev/sdvar.h +++ b/sys/arch/hp300/dev/sdvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: sdvar.h,v 1.8 2000/01/21 23:29:04 thorpej Exp $ */ +/* $NetBSD: sdvar.h,v 1.9 2000/10/10 19:58:43 he Exp $ */ /* * Copyright (c) 1990, 1993 @@ -64,6 +64,9 @@ struct sd_softc { struct sdstats sc_stats; /* debugging stats */ struct scsi_fmt_cdb sc_cmdstore; struct scsi_fmt_sense sc_sensestore; +#if NRND > 0 + rndsource_element_t rnd_source; +#endif }; /* sc_flags values */