randomdev.c (5711939b6379901610eec3db58d674f10e8efbd1) randomdev.c (ddbfa6b19ee786271f561c030bf1aecf2b42cf22)
1/*-
2 * Copyright (c) 2013 Arthur Mesh <arthurmesh@gmail.com>
3 * Copyright (c) 2000-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:

--- 37 unchanged lines hidden (view full) ---

46#include <sys/proc.h>
47#include <sys/selinfo.h>
48#include <sys/uio.h>
49#include <sys/unistd.h>
50
51#include <machine/bus.h>
52#include <machine/cpu.h>
53
1/*-
2 * Copyright (c) 2013 Arthur Mesh <arthurmesh@gmail.com>
3 * Copyright (c) 2000-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:

--- 37 unchanged lines hidden (view full) ---

46#include <sys/proc.h>
47#include <sys/selinfo.h>
48#include <sys/uio.h>
49#include <sys/unistd.h>
50
51#include <machine/bus.h>
52#include <machine/cpu.h>
53
54#include <dev/random/random_adaptors.h>
54#include <dev/random/randomdev.h>
55
56#define RANDOM_MINOR 0
57
58static d_close_t random_close;
59static d_read_t random_read;
60static d_write_t random_write;
61static d_ioctl_t random_ioctl;

--- 18 unchanged lines hidden (view full) ---

80static struct cdev *random_dev;
81
82/* Used to fake out unused random calls in random_adaptor */
83void
84random_null_func(void)
85{
86}
87
55#include <dev/random/randomdev.h>
56
57#define RANDOM_MINOR 0
58
59static d_close_t random_close;
60static d_read_t random_read;
61static d_write_t random_write;
62static d_ioctl_t random_ioctl;

--- 18 unchanged lines hidden (view full) ---

81static struct cdev *random_dev;
82
83/* Used to fake out unused random calls in random_adaptor */
84void
85random_null_func(void)
86{
87}
88
89struct random_adaptor *
90random_get_active_adaptor(void)
91{
92
93 return (random_adaptor);
94}
95
88/* ARGSUSED */
89static int
90random_close(struct cdev *dev __unused, int flags, int fmt __unused,
91 struct thread *td)
92{
93 if ((flags & FWRITE) && (priv_check(td, PRIV_RANDOM_RESEED) == 0)
94 && (securelevel_gt(td->td_ucred, 0) == 0)) {
95 (*random_adaptor->reseed)();

--- 114 unchanged lines hidden (view full) ---

210/* ARGSUSED */
211static int
212random_modevent(module_t mod __unused, int type, void *data __unused)
213{
214 int error = 0;
215
216 switch (type) {
217 case MOD_LOAD:
96/* ARGSUSED */
97static int
98random_close(struct cdev *dev __unused, int flags, int fmt __unused,
99 struct thread *td)
100{
101 if ((flags & FWRITE) && (priv_check(td, PRIV_RANDOM_RESEED) == 0)
102 && (securelevel_gt(td->td_ucred, 0) == 0)) {
103 (*random_adaptor->reseed)();

--- 114 unchanged lines hidden (view full) ---

218/* ARGSUSED */
219static int
220random_modevent(module_t mod __unused, int type, void *data __unused)
221{
222 int error = 0;
223
224 switch (type) {
225 case MOD_LOAD:
218 random_ident_hardware(&random_adaptor);
226 random_adaptor_choose(&random_adaptor);
219
220 if (random_adaptor == NULL) {
221 printf(
222 "random: No random adaptor attached, postponing initialization\n");
223 attach_tag = EVENTHANDLER_REGISTER(random_adaptor_attach,
224 random_initialize, NULL, EVENTHANDLER_PRI_ANY);
225 } else {
226 random_initialize(NULL, random_adaptor);

--- 30 unchanged lines hidden ---
227
228 if (random_adaptor == NULL) {
229 printf(
230 "random: No random adaptor attached, postponing initialization\n");
231 attach_tag = EVENTHANDLER_REGISTER(random_adaptor_attach,
232 random_initialize, NULL, EVENTHANDLER_PRI_ANY);
233 } else {
234 random_initialize(NULL, random_adaptor);

--- 30 unchanged lines hidden ---