diff options
author | obrien <obrien@FreeBSD.org> | 2013-08-09 15:31:50 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2013-08-09 15:31:50 +0000 |
commit | f65ab5c10cefbefba1cca281b8e41b7956ec6d5e (patch) | |
tree | 4744a8ad00a83dbe699947a887d8742001dae753 /sys/dev/random/nehemiah.c | |
parent | e9f37cac7422f86c8a65b4c123705f5dccd43fa1 (diff) | |
download | FreeBSD-src-f65ab5c10cefbefba1cca281b8e41b7956ec6d5e.zip FreeBSD-src-f65ab5c10cefbefba1cca281b8e41b7956ec6d5e.tar.gz |
* Add random_adaptors.[ch] which is basically a store of random_adaptor's.
random_adaptor is basically an adapter that plugs in to random(4).
random_adaptor can only be plugged in to random(4) very early in bootup.
Unplugging random_adaptor from random(4) is not supported, and is probably a
bad idea anyway, due to potential loss of entropy pools.
We currently have 3 random_adaptors:
+ yarrow
+ rdrand (ivy.c)
+ nehemeiah
* Remove platform dependent logic from probe.c, and move it into
corresponding registration routines of each random_adaptor provider.
probe.c doesn't do anything other than picking a specific random_adaptor
from a list of registered ones.
* If the kernel doesn't have any random_adaptor adapters present then the
creation of /dev/random is postponed until next random_adaptor is kldload'ed.
* Fix randomdev_soft.c to refer to its own random_adaptor, instead of a
system wide one.
Submitted by: arthurmesh@gmail.com, obrien
Obtained from: Juniper Networks
Reviewed by: so (des)
Diffstat (limited to 'sys/dev/random/nehemiah.c')
-rw-r--r-- | sys/dev/random/nehemiah.c | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/sys/dev/random/nehemiah.c b/sys/dev/random/nehemiah.c index f3afa89..1b4416e 100644 --- a/sys/dev/random/nehemiah.c +++ b/sys/dev/random/nehemiah.c @@ -1,4 +1,5 @@ /*- + * Copyright (c) 2013 David E. O'Brien <obrien@NUXI.org> * Copyright (c) 2004 Mark R V Murray * All rights reserved. * @@ -28,19 +29,20 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "opt_cpu.h" - -#ifdef PADLOCK_RNG - #include <sys/param.h> #include <sys/time.h> #include <sys/lock.h> #include <sys/mutex.h> +#include <sys/module.h> #include <sys/selinfo.h> #include <sys/systm.h> +#include <sys/kernel.h> #include <machine/pcb.h> +#include <machine/md_var.h> +#include <machine/specialreg.h> +#include <dev/random/random_adaptors.h> #include <dev/random/randomdev.h> #define RANDOM_BLOCK_SIZE 256 @@ -50,7 +52,7 @@ static void random_nehemiah_init(void); static void random_nehemiah_deinit(void); static int random_nehemiah_read(void *, int); -struct random_systat random_nehemiah = { +struct random_adaptor random_nehemiah = { .ident = "Hardware, VIA Nehemiah", .init = random_nehemiah_init, .deinit = random_nehemiah_deinit, @@ -208,4 +210,29 @@ random_nehemiah_read(void *buf, int c) return (c); } +static int +nehemiah_modevent(module_t mod, int type, void *unused) +{ + + switch (type) { + case MOD_LOAD: + if (via_feature_rng & VIA_HAS_RNG) { + random_adaptor_register("nehemiah", &random_nehemiah); + EVENTHANDLER_INVOKE(random_adaptor_attach, + &random_nehemiah); + return (0); + } else { +#ifndef KLD_MODULE + if (bootverbose) #endif + printf( + "%s: VIA RNG feature is not present on this CPU\n", + random_nehemiah.ident); + return (0); + } + } + + return (EINVAL); +} + +RANDOM_ADAPTOR_MODULE(nehemiah, nehemiah_modevent, 1); |