diff options
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/rnd_private.h | 46 | ||||
| -rw-r--r-- | sys/dev/rndpseudo.c | 27 |
2 files changed, 48 insertions, 25 deletions
diff --git a/sys/dev/rnd_private.h b/sys/dev/rnd_private.h index 0767ad4831a..cb36c399491 100644 --- a/sys/dev/rnd_private.h +++ b/sys/dev/rnd_private.h @@ -1,4 +1,4 @@ -/* $NetBSD: rnd_private.h,v 1.6 2015/04/13 14:41:06 riastradh Exp $ */ +/* $NetBSD: rnd_private.h,v 1.7 2015/04/13 15:13:50 riastradh Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -32,6 +32,12 @@ #ifndef _DEV_RNDPRIVATE_H #define _DEV_RNDPRIVATE_H + +#include <sys/types.h> +#include <sys/mutex.h> +#include <sys/queue.h> +#include <sys/rnd.h> + /* * Number of bytes returned per hash. This value is used in both * rnd.c and rndpool.c to decide when enough entropy exists to do a @@ -49,4 +55,42 @@ bool rnd_extract(void *, size_t); bool rnd_tryextract(void *, size_t); +void rnd_getmore(size_t); +void rnd_wakeup_readers(void); + +/* + * Flag indicating rnd_init has run. + */ +extern int rnd_ready; + +/* + * Bootloader-supplied entropy. Use only in tests against NULL to + * determine whether the bootloader supplied entropy. + */ +extern rndsave_t *boot_rsp; + +/* + * List of rndsources. + */ +LIST_HEAD(rndsource_head, krndsource); + +/* + * Global entropy pool state. Access to everything here is serialized + * by rndpool_mtx. + */ +extern kmutex_t rndpool_mtx; +extern rndpool_t rnd_pool; +extern struct rndsource_head rnd_sources; + +/* + * Debugging flags. + */ +#ifdef RND_DEBUG +extern int rnd_debug; +#define RND_DEBUG_WRITE 0x0001 +#define RND_DEBUG_READ 0x0002 +#define RND_DEBUG_IOCTL 0x0004 +#define RND_DEBUG_SNOOZE 0x0008 #endif + +#endif /* _DEV_RNDPRIVATE_H */ diff --git a/sys/dev/rndpseudo.c b/sys/dev/rndpseudo.c index ef6910ff7dd..c46f382a6e0 100644 --- a/sys/dev/rndpseudo.c +++ b/sys/dev/rndpseudo.c @@ -1,4 +1,4 @@ -/* $NetBSD: rndpseudo.c,v 1.25 2015/04/13 14:56:22 riastradh Exp $ */ +/* $NetBSD: rndpseudo.c,v 1.26 2015/04/13 15:13:50 riastradh Exp $ */ /*- * Copyright (c) 1997-2013 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rndpseudo.c,v 1.25 2015/04/13 14:56:22 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rndpseudo.c,v 1.26 2015/04/13 15:13:50 riastradh Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -73,16 +73,10 @@ __KERNEL_RCSID(0, "$NetBSD: rndpseudo.c,v 1.25 2015/04/13 14:56:22 riastradh Exp #ifdef RND_DEBUG #define DPRINTF(l,x) if (rnd_debug & (l)) printf x -extern int rnd_debug; #else #define DPRINTF(l,x) #endif -#define RND_DEBUG_WRITE 0x0001 -#define RND_DEBUG_READ 0x0002 -#define RND_DEBUG_IOCTL 0x0004 -#define RND_DEBUG_SNOOZE 0x0008 - /* * list devices attached */ @@ -112,17 +106,7 @@ static pool_cache_t rnd_ctx_cache; */ static percpu_t *percpu_urandom_cprng; -/* - * Our random pool. This is defined here rather than using the general - * purpose one defined in rndpool.c. - * - * Samples are collected and queued into a separate mutex-protected queue - * (rnd_samples, see above), and processed in a timeout routine; therefore, - * the mutex protecting the random pool is at IPL_SOFTCLOCK() as well. - */ -extern rndpool_t rnd_pool; -extern kmutex_t rndpool_mtx; - +/* Used by ioconf.c to attach the rnd pseudo-device. */ void rndattach(int); dev_type_open(rndopen); @@ -162,11 +146,6 @@ const struct fileops rnd_fileops = { .fo_restart = fnullop_restart }; -void rnd_wakeup_readers(void); /* XXX */ -extern int rnd_ready; /* XXX */ -extern rndsave_t *boot_rsp; /* XXX */ -extern LIST_HEAD(, krndsource) rnd_sources; /* XXX */ - static struct evcnt rndpseudo_soft = EVCNT_INITIALIZER(EVCNT_TYPE_MISC, NULL, "rndpseudo", "open soft"); static struct evcnt rndpseudo_hard = EVCNT_INITIALIZER(EVCNT_TYPE_MISC, |
