diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
commit | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch) | |
tree | a8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /include/linux/random.h | |
parent | 406089d01562f1e2bf9f089fd7637009ebaad589 (diff) |
Patched in Tegra support.
Diffstat (limited to 'include/linux/random.h')
-rw-r--r-- | include/linux/random.h | 79 |
1 files changed, 49 insertions, 30 deletions
diff --git a/include/linux/random.h b/include/linux/random.h index d9846088c2c..d13059f3ea3 100644 --- a/include/linux/random.h +++ b/include/linux/random.h | |||
@@ -3,19 +3,58 @@ | |||
3 | * | 3 | * |
4 | * Include file for the random number generator. | 4 | * Include file for the random number generator. |
5 | */ | 5 | */ |
6 | |||
6 | #ifndef _LINUX_RANDOM_H | 7 | #ifndef _LINUX_RANDOM_H |
7 | #define _LINUX_RANDOM_H | 8 | #define _LINUX_RANDOM_H |
8 | 9 | ||
9 | #include <uapi/linux/random.h> | 10 | #include <linux/types.h> |
11 | #include <linux/ioctl.h> | ||
12 | #include <linux/irqnr.h> | ||
13 | |||
14 | /* ioctl()'s for the random number generator */ | ||
15 | |||
16 | /* Get the entropy count. */ | ||
17 | #define RNDGETENTCNT _IOR( 'R', 0x00, int ) | ||
18 | |||
19 | /* Add to (or subtract from) the entropy count. (Superuser only.) */ | ||
20 | #define RNDADDTOENTCNT _IOW( 'R', 0x01, int ) | ||
21 | |||
22 | /* Get the contents of the entropy pool. (Superuser only.) */ | ||
23 | #define RNDGETPOOL _IOR( 'R', 0x02, int [2] ) | ||
24 | |||
25 | /* | ||
26 | * Write bytes into the entropy pool and add to the entropy count. | ||
27 | * (Superuser only.) | ||
28 | */ | ||
29 | #define RNDADDENTROPY _IOW( 'R', 0x03, int [2] ) | ||
30 | |||
31 | /* Clear entropy count to 0. (Superuser only.) */ | ||
32 | #define RNDZAPENTCNT _IO( 'R', 0x04 ) | ||
33 | |||
34 | /* Clear the entropy pool and associated counters. (Superuser only.) */ | ||
35 | #define RNDCLEARPOOL _IO( 'R', 0x06 ) | ||
36 | |||
37 | struct rand_pool_info { | ||
38 | int entropy_count; | ||
39 | int buf_size; | ||
40 | __u32 buf[0]; | ||
41 | }; | ||
42 | |||
43 | struct rnd_state { | ||
44 | __u32 s1, s2, s3; | ||
45 | }; | ||
10 | 46 | ||
47 | /* Exported functions */ | ||
48 | |||
49 | #ifdef __KERNEL__ | ||
50 | |||
51 | extern void rand_initialize_irq(int irq); | ||
11 | 52 | ||
12 | extern void add_device_randomness(const void *, unsigned int); | ||
13 | extern void add_input_randomness(unsigned int type, unsigned int code, | 53 | extern void add_input_randomness(unsigned int type, unsigned int code, |
14 | unsigned int value); | 54 | unsigned int value); |
15 | extern void add_interrupt_randomness(int irq, int irq_flags); | 55 | extern void add_interrupt_randomness(int irq); |
16 | 56 | ||
17 | extern void get_random_bytes(void *buf, int nbytes); | 57 | extern void get_random_bytes(void *buf, int nbytes); |
18 | extern void get_random_bytes_arch(void *buf, int nbytes); | ||
19 | void generate_random_uuid(unsigned char uuid_out[16]); | 58 | void generate_random_uuid(unsigned char uuid_out[16]); |
20 | 59 | ||
21 | #ifndef MODULE | 60 | #ifndef MODULE |
@@ -25,19 +64,10 @@ extern const struct file_operations random_fops, urandom_fops; | |||
25 | unsigned int get_random_int(void); | 64 | unsigned int get_random_int(void); |
26 | unsigned long randomize_range(unsigned long start, unsigned long end, unsigned long len); | 65 | unsigned long randomize_range(unsigned long start, unsigned long end, unsigned long len); |
27 | 66 | ||
28 | u32 prandom_u32(void); | 67 | u32 random32(void); |
29 | void prandom_bytes(void *buf, int nbytes); | 68 | void srandom32(u32 seed); |
30 | void prandom_seed(u32 seed); | ||
31 | |||
32 | /* | ||
33 | * These macros are preserved for backward compatibility and should be | ||
34 | * removed as soon as a transition is finished. | ||
35 | */ | ||
36 | #define random32() prandom_u32() | ||
37 | #define srandom32(seed) prandom_seed(seed) | ||
38 | 69 | ||
39 | u32 prandom_u32_state(struct rnd_state *); | 70 | u32 prandom32(struct rnd_state *); |
40 | void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes); | ||
41 | 71 | ||
42 | /* | 72 | /* |
43 | * Handle minimum values for seeds | 73 | * Handle minimum values for seeds |
@@ -48,11 +78,11 @@ static inline u32 __seed(u32 x, u32 m) | |||
48 | } | 78 | } |
49 | 79 | ||
50 | /** | 80 | /** |
51 | * prandom_seed_state - set seed for prandom_u32_state(). | 81 | * prandom32_seed - set seed for prandom32(). |
52 | * @state: pointer to state structure to receive the seed. | 82 | * @state: pointer to state structure to receive the seed. |
53 | * @seed: arbitrary 64-bit value to use as a seed. | 83 | * @seed: arbitrary 64-bit value to use as a seed. |
54 | */ | 84 | */ |
55 | static inline void prandom_seed_state(struct rnd_state *state, u64 seed) | 85 | static inline void prandom32_seed(struct rnd_state *state, u64 seed) |
56 | { | 86 | { |
57 | u32 i = (seed >> 32) ^ (seed << 10) ^ seed; | 87 | u32 i = (seed >> 32) ^ (seed << 10) ^ seed; |
58 | 88 | ||
@@ -61,17 +91,6 @@ static inline void prandom_seed_state(struct rnd_state *state, u64 seed) | |||
61 | state->s3 = __seed(i, 15); | 91 | state->s3 = __seed(i, 15); |
62 | } | 92 | } |
63 | 93 | ||
64 | #ifdef CONFIG_ARCH_RANDOM | 94 | #endif /* __KERNEL___ */ |
65 | # include <asm/archrandom.h> | ||
66 | #else | ||
67 | static inline int arch_get_random_long(unsigned long *v) | ||
68 | { | ||
69 | return 0; | ||
70 | } | ||
71 | static inline int arch_get_random_int(unsigned int *v) | ||
72 | { | ||
73 | return 0; | ||
74 | } | ||
75 | #endif | ||
76 | 95 | ||
77 | #endif /* _LINUX_RANDOM_H */ | 96 | #endif /* _LINUX_RANDOM_H */ |