summaryrefslogtreecommitdiff
path: root/sys/dev/sysmon
diff options
context:
space:
mode:
authortls <tls@NetBSD.org>2012-02-02 19:42:57 +0000
committertls <tls@NetBSD.org>2012-02-02 19:42:57 +0000
commitcc9ee3de3e25ef31d3a97dc35bedc36945e35d2a (patch)
tree06a2889eb6b4b02bc8b8bba6b5cc3f9b1938d18b /sys/dev/sysmon
parentf622122a62827e27b444c2f95632d61f73357ced (diff)
Entropy-pool implementation move and cleanup.
1) Move core entropy-pool code and source/sink/sample management code to sys/kern from sys/dev. 2) Remove use of NRND as test for presence of entropy-pool code throughout source tree. 3) Remove use of RND_ENABLED in device drivers as microoptimization to avoid expensive operations on disabled entropy sources; make the rnd_add calls do this directly so all callers benefit. 4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might have lead to slight entropy overestimation for some sources. 5) Add new source types for environmental sensors, power sensors, VM system events, and skew between clocks, with a sample implementation for each. ok releng to go in before the branch due to the difficulty of later pullup (widespread #ifdef removal and moved files). Tested with release builds on amd64 and evbarm and live testing on amd64.
Diffstat (limited to 'sys/dev/sysmon')
-rw-r--r--sys/dev/sysmon/sysmon_power.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/sys/dev/sysmon/sysmon_power.c b/sys/dev/sysmon/sysmon_power.c
index 8b531818b00..ff55ad5e698 100644
--- a/sys/dev/sysmon/sysmon_power.c
+++ b/sys/dev/sysmon/sysmon_power.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_power.c,v 1.45 2011/07/22 14:21:40 jakllsch Exp $ */
+/* $NetBSD: sysmon_power.c,v 1.46 2012/02/02 19:43:07 tls Exp $ */
/*-
* Copyright (c) 2007 Juan Romero Pardines.
@@ -69,7 +69,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.45 2011/07/22 14:21:40 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.46 2012/02/02 19:43:07 tls Exp $");
#include "opt_compat_netbsd.h"
#include <sys/param.h>
@@ -83,6 +83,7 @@ __KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.45 2011/07/22 14:21:40 jakllsch E
#include <sys/kmem.h>
#include <sys/proc.h>
#include <sys/device.h>
+#include <sys/rnd.h>
#include <dev/sysmon/sysmonvar.h>
#include <prop/proplib.h>
@@ -166,6 +167,8 @@ static int sysmon_power_event_queue_head;
static int sysmon_power_event_queue_tail;
static int sysmon_power_event_queue_count;
+static krndsource_t sysmon_rndsource;
+
static SIMPLEQ_HEAD(, power_event_dictionary) pev_dict_list =
SIMPLEQ_HEAD_INITIALIZER(pev_dict_list);
@@ -196,6 +199,10 @@ sysmon_power_init(void)
mutex_init(&sysmon_power_event_queue_mtx, MUTEX_DEFAULT, IPL_NONE);
cv_init(&sysmon_power_event_queue_cv, "smpower");
selinit(&sysmon_power_event_queue_selinfo);
+
+ rnd_attach_source(&sysmon_rndsource, "system-power",
+ RND_TYPE_POWER, 0);
+
}
/*
@@ -779,6 +786,8 @@ sysmon_penvsys_event(struct penvsys_state *pes, int event)
KASSERT(pes != NULL);
+ rnd_add_uint32(&sysmon_rndsource, pes->pes_type);
+
if (sysmon_power_daemon != NULL) {
/*
* Create a dictionary for the new event.