summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2003-08-15 13:25:54 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2003-08-15 13:25:54 +0000
commite0e362d494aec4f7ffe53688f642a11c396dbb8f (patch)
tree24d3f0967bfa72f4f0d69b85a2edfb629b7038fd /sys/arch
parent5a17539e4890e6f27f85f9eee50ddb0699f9ba38 (diff)
bitneaks anonymous randomisation
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/hppa/gsc/harmony.c27
-rw-r--r--sys/arch/hppa/gsc/harmonyvar.h5
2 files changed, 30 insertions, 2 deletions
diff --git a/sys/arch/hppa/gsc/harmony.c b/sys/arch/hppa/gsc/harmony.c
index e7ab1670d77..0e86b5f6ea7 100644
--- a/sys/arch/hppa/gsc/harmony.c
+++ b/sys/arch/hppa/gsc/harmony.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: harmony.c,v 1.20 2003/08/07 19:47:33 mickey Exp $ */
+/* $OpenBSD: harmony.c,v 1.21 2003/08/15 13:25:53 mickey Exp $ */
/*
* Copyright (c) 2003 Jason L. Wright (jason@thought.net)
@@ -42,6 +42,7 @@
#include <sys/audioio.h>
#include <dev/audio_if.h>
#include <dev/auconv.h>
+#include <dev/rndvar.h>
#include <machine/cpu.h>
#include <machine/intr.h>
@@ -118,6 +119,14 @@ void harmony_tick_pb(void *);
void harmony_tick_cp(void *);
void harmony_try_more(struct harmony_softc *);
+void harmony_acc_tmo(void *);
+#define ADD_CLKALLICA(sc) do { \
+ (sc)->sc_acc <<= 1; \
+ (sc)->sc_acc |= READ_REG((sc), HARMONY_DIAG) & DIAG_CO; \
+ if ((sc)->sc_acc_cnt++ && !((sc)->sc_acc_cnt % 32)) \
+ add_true_randomness((sc)->sc_acc_num ^= (sc)->sc_acc); \
+} while(0)
+
int
harmony_match(parent, match, aux)
struct device *parent;
@@ -256,6 +265,9 @@ harmony_attach(parent, self, aux)
sizeof(sc->sc_audev.config));
audio_attach_mi(&harmony_sa_hw_if, sc, &sc->sc_dv);
+
+ timeout_set(&sc->sc_acc_tmo, harmony_acc_tmo, sc);
+ sc->sc_acc_num = 0xa5a5a5a5;
}
void
@@ -274,6 +286,15 @@ harmony_reset_codec(struct harmony_softc *sc)
WRITE_REG(sc, HARMONY_RESET, 0);
}
+void
+harmony_acc_tmo(void *v)
+{
+ struct harmony_softc *sc = v;
+
+ ADD_CLKALLICA(sc);
+ timeout_add(&sc->sc_acc_tmo, 1);
+}
+
/*
* interrupt handler
*/
@@ -286,6 +307,8 @@ harmony_intr(vsc)
u_int32_t dstatus;
int r = 0;
+ ADD_CLKALLICA(sc);
+
harmony_intr_disable(sc);
dstatus = READ_REG(sc, HARMONY_DSTATUS);
@@ -1086,6 +1109,8 @@ harmony_start_cp(struct harmony_softc *sc)
SYNC_REG(sc, HARMONY_RNXTADD, BUS_SPACE_BARRIER_WRITE);
c->c_lastaddr = nextaddr + togo;
}
+
+ timeout_add(&sc->sc_acc_tmo, 1);
}
int
diff --git a/sys/arch/hppa/gsc/harmonyvar.h b/sys/arch/hppa/gsc/harmonyvar.h
index 0ffee9cf1c9..64f59b8b3d8 100644
--- a/sys/arch/hppa/gsc/harmonyvar.h
+++ b/sys/arch/hppa/gsc/harmonyvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: harmonyvar.h,v 1.7 2003/06/02 19:54:29 jason Exp $ */
+/* $OpenBSD: harmonyvar.h,v 1.8 2003/08/15 13:25:53 mickey Exp $ */
/*
* Copyright (c) 2003 Jason L. Wright (jason@thought.net)
@@ -101,6 +101,9 @@ struct harmony_softc {
int sc_in_port, sc_out_port, sc_hasulinear8;
int sc_micpreamp, sc_ov, sc_outputgain;
int sc_teleshare;
+
+ struct timeout sc_acc_tmo;
+ u_int32_t sc_acc, sc_acc_num, sc_acc_cnt;
};
#define READ_REG(sc, reg) \