nehemiah.c (253845) | nehemiah.c (254147) |
---|---|
1/*- | 1/*- |
2 * Copyright (c) 2013 David E. O'Brien <obrien@NUXI.org> |
|
2 * Copyright (c) 2004 Mark R V Murray 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer --- 11 unchanged lines hidden (view full) --- 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * 26 */ 27 28#include <sys/cdefs.h> | 3 * Copyright (c) 2004 Mark R V Murray 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer --- 11 unchanged lines hidden (view full) --- 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * 27 */ 28 29#include <sys/cdefs.h> |
29__FBSDID("$FreeBSD: head/sys/dev/random/nehemiah.c 253845 2013-07-31 17:21:18Z obrien $"); | 30__FBSDID("$FreeBSD: head/sys/dev/random/nehemiah.c 254147 2013-08-09 15:31:50Z obrien $"); |
30 | 31 |
31#include "opt_cpu.h" 32 33#ifdef PADLOCK_RNG 34 | |
35#include <sys/param.h> 36#include <sys/time.h> 37#include <sys/lock.h> 38#include <sys/mutex.h> | 32#include <sys/param.h> 33#include <sys/time.h> 34#include <sys/lock.h> 35#include <sys/mutex.h> |
36#include <sys/module.h> |
|
39#include <sys/selinfo.h> 40#include <sys/systm.h> | 37#include <sys/selinfo.h> 38#include <sys/systm.h> |
39#include <sys/kernel.h> |
|
41 42#include <machine/pcb.h> | 40 41#include <machine/pcb.h> |
42#include <machine/md_var.h> 43#include <machine/specialreg.h> |
|
43 | 44 |
45#include <dev/random/random_adaptors.h> |
|
44#include <dev/random/randomdev.h> 45 46#define RANDOM_BLOCK_SIZE 256 47#define CIPHER_BLOCK_SIZE 16 48 49static void random_nehemiah_init(void); 50static void random_nehemiah_deinit(void); 51static int random_nehemiah_read(void *, int); 52 | 46#include <dev/random/randomdev.h> 47 48#define RANDOM_BLOCK_SIZE 256 49#define CIPHER_BLOCK_SIZE 16 50 51static void random_nehemiah_init(void); 52static void random_nehemiah_deinit(void); 53static int random_nehemiah_read(void *, int); 54 |
53struct random_systat random_nehemiah = { | 55struct random_adaptor random_nehemiah = { |
54 .ident = "Hardware, VIA Nehemiah", 55 .init = random_nehemiah_init, 56 .deinit = random_nehemiah_deinit, 57 .read = random_nehemiah_read, 58 .write = (random_write_func_t *)random_null_func, 59 .reseed = (random_reseed_func_t *)random_null_func, 60 .seeded = 1, 61}; --- 141 unchanged lines hidden (view full) --- 203 c = MIN(RANDOM_BLOCK_SIZE, c); 204 memcpy(buf, out, (size_t)c); 205 206 fpu_kern_leave(curthread, fpu_ctx_save); 207 mtx_unlock(&random_nehemiah_mtx); 208 return (c); 209} 210 | 56 .ident = "Hardware, VIA Nehemiah", 57 .init = random_nehemiah_init, 58 .deinit = random_nehemiah_deinit, 59 .read = random_nehemiah_read, 60 .write = (random_write_func_t *)random_null_func, 61 .reseed = (random_reseed_func_t *)random_null_func, 62 .seeded = 1, 63}; --- 141 unchanged lines hidden (view full) --- 205 c = MIN(RANDOM_BLOCK_SIZE, c); 206 memcpy(buf, out, (size_t)c); 207 208 fpu_kern_leave(curthread, fpu_ctx_save); 209 mtx_unlock(&random_nehemiah_mtx); 210 return (c); 211} 212 |
213static int 214nehemiah_modevent(module_t mod, int type, void *unused) 215{ 216 217 switch (type) { 218 case MOD_LOAD: 219 if (via_feature_rng & VIA_HAS_RNG) { 220 random_adaptor_register("nehemiah", &random_nehemiah); 221 EVENTHANDLER_INVOKE(random_adaptor_attach, 222 &random_nehemiah); 223 return (0); 224 } else { 225#ifndef KLD_MODULE 226 if (bootverbose) |
|
211#endif | 227#endif |
228 printf( 229 "%s: VIA RNG feature is not present on this CPU\n", 230 random_nehemiah.ident); 231 return (0); 232 } 233 } 234 235 return (EINVAL); 236} 237 238RANDOM_ADAPTOR_MODULE(nehemiah, nehemiah_modevent, 1); |
|