5 #include <minix/profile.h>
6 #include <minix/syslib.h>
7 #include <minix/type.h>
8 #include <minix/minlib.h>
9 #include <minix/sysutil.h>
11 /*===========================================================================*
13 *===========================================================================*/
14 void get_randomness(rand
, source
)
15 struct k_randomness
*rand
;
18 /* Use architecture-dependent high-resolution clock for
19 * raw entropy gathering.
22 unsigned long tsc_high
, tsc_low
;
24 source
%= RANDOM_SOURCES
;
25 r_next
= rand
->bin
[source
].r_next
;
26 read_tsc((u32_t
*) &tsc_high
, (u32_t
*) &tsc_low
);
27 rand
->bin
[source
].r_buf
[r_next
] = tsc_low
;
28 if (rand
->bin
[source
].r_size
< RANDOM_ELEMENTS
) {
29 rand
->bin
[source
].r_size
++;
31 rand
->bin
[source
].r_next
= (r_next
+ 1 ) % RANDOM_ELEMENTS
;