Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Gather rnd-private declarations into <dev/rnd_private.h>.
details: https://anonhg.NetBSD.org/src/rev/40d7220921d2
branches: trunk
changeset: 337362:40d7220921d2
user: riastradh <riastradh%NetBSD.org@localhost>
date: Mon Apr 13 15:13:50 2015 +0000
description:
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.
diffstat:
sys/dev/rnd_private.h | 46 +++++++++++++++++++++++++++++++++++++++++++++-
sys/dev/rndpseudo.c | 27 +++------------------------
sys/kern/kern_rndq.c | 11 +++--------
sys/kern/kern_rndsink.c | 9 +++------
sys/sys/rnd.h | 4 +---
5 files changed, 55 insertions(+), 42 deletions(-)
diffs (228 lines):
diff -r 846e5a4e7379 -r 40d7220921d2 sys/dev/rnd_private.h
--- a/sys/dev/rnd_private.h Mon Apr 13 14:56:22 2015 +0000
+++ b/sys/dev/rnd_private.h Mon Apr 13 15:13:50 2015 +0000
@@ -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 -r 846e5a4e7379 -r 40d7220921d2 sys/dev/rndpseudo.c
--- a/sys/dev/rndpseudo.c Mon Apr 13 14:56:22 2015 +0000
+++ b/sys/dev/rndpseudo.c Mon Apr 13 15:13:50 2015 +0000
@@ -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 @@
#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 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 @@
.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,
diff -r 846e5a4e7379 -r 40d7220921d2 sys/kern/kern_rndq.c
--- a/sys/kern/kern_rndq.c Mon Apr 13 14:56:22 2015 +0000
+++ b/sys/kern/kern_rndq.c Mon Apr 13 15:13:50 2015 +0000
@@ -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 @@
#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 uint8_t rnd_testbits[sizeof(rnd_rt.rt_b)];
#endif
-LIST_HEAD(, krndsource) rnd_sources;
+struct rndsource_head rnd_sources;
rndsave_t *boot_rsp;
diff -r 846e5a4e7379 -r 40d7220921d2 sys/kern/kern_rndsink.c
--- a/sys/kern/kern_rndsink.c Mon Apr 13 14:56:22 2015 +0000
+++ b/sys/kern/kern_rndsink.c Mon Apr 13 15:13:50 2015 +0000
@@ -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 @@
#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 @@
* 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:
diff -r 846e5a4e7379 -r 40d7220921d2 sys/sys/rnd.h
--- a/sys/sys/rnd.h Mon Apr 13 14:56:22 2015 +0000
+++ b/sys/sys/rnd.h Mon Apr 13 15:13:50 2015 +0000
@@ -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 @@
uint32_t, uint32_t);
void rnd_detach_source(krndsource_t *);
-void rnd_getmore(size_t);
-
void rnd_seed(void *, size_t);
static inline void
Home |
Main Index |
Thread Index |
Old Index