]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/random/randomdev.h
Update compiler-rt to trunk r228651. This enables using Address
[FreeBSD/FreeBSD.git] / sys / dev / random / randomdev.h
1 /*-
2  * Copyright (c) 2000-2013 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
10  *    in this position and unchanged.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
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  * $FreeBSD$
27  */
28
29 #ifndef SYS_DEV_RANDOM_RANDOMDEV_H_INCLUDED
30 #define SYS_DEV_RANDOM_RANDOMDEV_H_INCLUDED
31
32 /* This header contains only those definitions that are global
33  * and non algorithm-specific for the entropy processor
34  */
35
36 typedef void random_init_func_t(void);
37 typedef void random_deinit_func_t(void);
38
39 void randomdev_init_harvester(void (*)(const void *, u_int, u_int, enum random_entropy_source));
40 void randomdev_init_reader(void (*)(uint8_t *, u_int));
41 void randomdev_deinit_harvester(void);
42 void randomdev_deinit_reader(void);
43
44 /* Stub/fake routines for when no entropy processor is loaded */
45 extern void dummy_random_read_phony(uint8_t *, u_int);
46
47 /* kern.random sysctls */
48 #ifdef SYSCTL_DECL      /* from sysctl.h */
49 SYSCTL_DECL(_kern_random);
50
51 /* If this was C++, the macro below would be a template */
52 #define RANDOM_CHECK_UINT(name, min, max)                               \
53 static int                                                              \
54 random_check_uint_##name(SYSCTL_HANDLER_ARGS)                           \
55 {                                                                       \
56         if (oidp->oid_arg1 != NULL) {                                   \
57                  if (*(u_int *)(oidp->oid_arg1) <= (min))               \
58                         *(u_int *)(oidp->oid_arg1) = (min);             \
59                  else if (*(u_int *)(oidp->oid_arg1) > (max))           \
60                         *(u_int *)(oidp->oid_arg1) = (max);             \
61         }                                                               \
62         return (sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2, \
63                 req));                                                  \
64 }
65 #endif /* SYSCTL_DECL */
66
67 #endif