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