Repository navigation
Expand file tree
/
Copy pathrnd.h
More file actions
150 lines (131 loc) · 4.81 KB
/
Copy pathrnd.h
File metadata and controls
150 lines (131 loc) · 4.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/* $NetBSD: rnd.h,v 1.2 2011/12/20 16:38:06 drochner Exp $ */
/*-
* Copyright (c) 1997,2011 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Michael Graff <explorer@flame.org>. This code uses ideas and
* algorithms from the Linux driver written by Ted Ts'o.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _COMPAT_SYS_RND_H_
#define _COMPAT_SYS_RND_H_
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
#include "opt_compat_netbsd32.h"
#endif
#include <sys/types.h>
#include <sys/ioctl.h>
#ifdef COMPAT_NETBSD32
#include <compat/netbsd32/netbsd32.h>
#endif /* COMPAT_NETBSD32 */
#include <sys/rnd.h>
/*
* NetBSD-5 used "void *state" in the rndsource_t struct. rndsource_t
* was used in rnstat_t and rnstat_name_t, which were used by
* the NetBSD-5 RNDGETSRCNUM and RNDGETSRCNAME ioctls.
*
*/
/* Sanitized random source view for userspace. */
typedef struct {
char name[16]; /* device name */
uint32_t unused_time; /* was: last time recorded */
uint32_t unused_delta; /* was: last delta value */
uint32_t unused_delta2; /* was: last delta2 value */
uint32_t total; /* entropy from this source */
uint32_t type; /* type */
uint32_t flags; /* flags */
void *unused_state; /* was: internal state */
} rndsource50_t;
#ifdef COMPAT_NETBSD32
typedef struct {
char name[16]; /* device name */
uint32_t unused_time; /* was: last time recorded */
uint32_t unused_delta; /* was: last delta value */
uint32_t unused_delta2; /* was: last delta2 value */
uint32_t total; /* entropy from this source */
uint32_t type; /* type */
uint32_t flags; /* flags */
netbsd32_voidp unused_state; /* was: internal state */
} rndsource50_32_t;
#endif /* COMPAT_NETBSD32 */
/*
* NetBSD-5 defined RND_MAXSTATCOUNT as 10. We define RND_MAXSTATCOUNT50
* here, and check that the native RND_MAXSTATCOUNT is not smaller.
*/
#define RND_MAXSTATCOUNT50 10 /* 10 sources at once max */
#if (RND_MAXSTATCOUNT50 > RND_MAXSTATCOUNT)
#error "RND_MAXSTATCOUNT50 is too large"
#endif
/*
* return "count" random entries, starting at "start"
*/
typedef struct {
uint32_t start;
uint32_t count;
rndsource50_t source[RND_MAXSTATCOUNT50];
} rndstat50_t;
#ifdef COMPAT_NETBSD32
typedef struct {
uint32_t start;
uint32_t count;
rndsource50_32_t source[RND_MAXSTATCOUNT50];
} rndstat50_32_t;
#endif /* COMPAT_NETBSD32 */
/*
* return information on a specific source by name
*/
typedef struct {
char name[16];
rndsource50_t source;
} rndstat_name50_t;
#ifdef COMPAT_NETBSD32
typedef struct {
char name[16];
rndsource50_32_t source;
} rndstat_name50_32_t;
#endif /* COMPAT_NETBSD32 */
/*
* NetBSD-5 defined RND_POOLWORDS as 128. In NetBSD-6, the value
* exposed to userland via the rnddata_t type was renamed to
* RND_SAVEWORDS. As long as RND_SAVEWORDS remains equal to 128, then
* rnddata_t (used by ioctl RNDADDATA), and rndpoolstat_t (used by ioctl
* RNDGETPOOLSTAT) remain ABI compatible without any extra effort, even
* though the declarations in the source code have changed.
*/
#if (RND_SAVEWORDS != 128)
#error "RND_SAVEWORDS must be 128 for NetBSD-5 compatibility"
#endif
/*
* Compatibility with NetBSD-5 ioctls.
*/
#ifdef _KERNEL
int compat_50_rnd_ioctl(struct file *, u_long, void *);
#endif
#define RNDGETSRCNUM50 _IOWR('R', 102, rndstat50_t)
#define RNDGETSRCNAME50 _IOWR('R', 103, rndstat_name50_t)
#ifdef COMPAT_NETBSD32
#define RNDGETSRCNUM50_32 _IOWR('R', 102, rndstat50_32_t)
#define RNDGETSRCNAME50_32 _IOWR('R', 103, rndstat_name50_32_t)
#endif /* COMPAT_NETBSD32 */
#endif /* !_COMPAT_SYS_RND_H_ */