Module Name:    src
Committed By:   riastradh
Date:           Mon Apr 13 15:13:50 UTC 2015

Modified Files:
        src/sys/dev: rnd_private.h rndpseudo.c
        src/sys/kern: kern_rndq.c kern_rndsink.c
        src/sys/sys: rnd.h

Log Message:
Gather rnd-private declarations into <dev/rnd_private.h>.

Let's try to avoid putting externs in .c files where the compiler
can't check them.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/rnd_private.h
cvs rdiff -u -r1.25 -r1.26 src/sys/dev/rndpseudo.c
cvs rdiff -u -r1.44 -r1.45 src/sys/kern/kern_rndq.c
cvs rdiff -u -r1.11 -r1.12 src/sys/kern/kern_rndsink.c
cvs rdiff -u -r1.44 -r1.45 src/sys/sys/rnd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/rnd_private.h
diff -u src/sys/dev/rnd_private.h:1.6 src/sys/dev/rnd_private.h:1.7
--- src/sys/dev/rnd_private.h:1.6	Mon Apr 13 14:41:06 2015
+++ src/sys/dev/rnd_private.h	Mon Apr 13 15:13:50 2015
@@ -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 */

Index: src/sys/dev/rndpseudo.c
diff -u src/sys/dev/rndpseudo.c:1.25 src/sys/dev/rndpseudo.c:1.26
--- src/sys/dev/rndpseudo.c:1.25	Mon Apr 13 14:56:22 2015
+++ src/sys/dev/rndpseudo.c	Mon Apr 13 15:13:50 2015
@@ -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,
 
 #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,

Index: src/sys/kern/kern_rndq.c
diff -u src/sys/kern/kern_rndq.c:1.44 src/sys/kern/kern_rndq.c:1.45
--- src/sys/kern/kern_rndq.c:1.44	Mon Apr 13 14:41:06 2015
+++ src/sys/kern/kern_rndq.c	Mon Apr 13 15:13:50 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_rndq.c,v 1.44 2015/04/13 14:41:06 riastradh Exp $	*/
+/*	$NetBSD: kern_rndq.c,v 1.45 2015/04/13 15:13:50 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1997-2013 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.44 2015/04/13 14:41:06 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.45 2015/04/13 15:13:50 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -69,11 +69,6 @@ int	rnd_debug = 0;
 #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
  */
@@ -189,7 +184,7 @@ static rngtest_t	rnd_rt;
 static uint8_t		rnd_testbits[sizeof(rnd_rt.rt_b)];
 #endif
 
-LIST_HEAD(, krndsource)	rnd_sources;
+struct rndsource_head	rnd_sources;
 
 rndsave_t		*boot_rsp;
 

Index: src/sys/kern/kern_rndsink.c
diff -u src/sys/kern/kern_rndsink.c:1.11 src/sys/kern/kern_rndsink.c:1.12
--- src/sys/kern/kern_rndsink.c:1.11	Mon Apr 13 14:41:06 2015
+++ src/sys/kern/kern_rndsink.c	Mon Apr 13 15:13:50 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_rndsink.c,v 1.11 2015/04/13 14:41:06 riastradh Exp $	*/
+/*	$NetBSD: kern_rndsink.c,v 1.12 2015/04/13 15:13:50 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_rndsink.c,v 1.11 2015/04/13 14:41:06 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rndsink.c,v 1.12 2015/04/13 15:13:50 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -41,7 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_rndsink
 #include <sys/rnd.h>
 #include <sys/rndsink.h>
 
-#include <dev/rnd_private.h>	/* XXX provisional, for rnd_extract_data */
+#include <dev/rnd_private.h>
 
 enum rsink_state {
 	RNDSINK_IDLE,		/* no callback in progress */
@@ -157,12 +157,9 @@ rndsinks_enqueue(struct rndsink *rndsink
 	 * or something -- as soon as we get that much from the entropy
 	 * sources, distribute it.
 	 */
-    {
-	extern kmutex_t rndpool_mtx;
 	mutex_spin_enter(&rndpool_mtx);
 	rnd_getmore(MAX(rndsink->rsink_bytes, 2 * sizeof(uint32_t)));
 	mutex_spin_exit(&rndpool_mtx);
-    }
 
 	switch (rndsink->rsink_state) {
 	case RNDSINK_IDLE:

Index: src/sys/sys/rnd.h
diff -u src/sys/sys/rnd.h:1.44 src/sys/sys/rnd.h:1.45
--- src/sys/sys/rnd.h:1.44	Wed Apr  8 13:45:01 2015
+++ src/sys/sys/rnd.h	Mon Apr 13 15:13:50 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rnd.h,v 1.44 2015/04/08 13:45:01 riastradh Exp $	*/
+/*	$NetBSD: rnd.h,v 1.45 2015/04/13 15:13:50 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -200,8 +200,6 @@ void		rnd_attach_source(krndsource_t *, 
 		    uint32_t, uint32_t);
 void		rnd_detach_source(krndsource_t *);
 
-void		rnd_getmore(size_t);
-
 void		rnd_seed(void *, size_t);
 
 static inline void

Reply via email to