Fix to check for RDTSC instruction (above 486), and call another timing
function instead if RDTSC is unavailable. This makes minix run on 486 again :) (presumably lower as well).
This commit is contained in:
parent
d2018bb8ad
commit
2ce80ece5c
1 changed files with 15 additions and 1 deletions
|
@ -243,7 +243,21 @@ PUBLIC void get_randomness()
|
||||||
* the lowest bytes because the highest bytes won't differ that much.
|
* the lowest bytes because the highest bytes won't differ that much.
|
||||||
*/
|
*/
|
||||||
unsigned long tsc_high;
|
unsigned long tsc_high;
|
||||||
|
|
||||||
|
/* On machines with the RDTSC (cycle counter read instruction - pentium
|
||||||
|
* and up), use that for high-resolution raw entropy gathering. Otherwise,
|
||||||
|
* use the realtime clock (tick resolution).
|
||||||
|
*
|
||||||
|
* Unfortunately this test is run-time - we don't want to bother with
|
||||||
|
* compiling different kernels for different machines..
|
||||||
|
*
|
||||||
|
* On machines without RDTSC, we use the get_uptime() - read_clock()
|
||||||
|
* has a higher resolution, but would involve I/O calls.
|
||||||
|
*/
|
||||||
|
if(machine.processor > 486)
|
||||||
read_tsc(&tsc_high, &krandom.r_buf[krandom.r_next]);
|
read_tsc(&tsc_high, &krandom.r_buf[krandom.r_next]);
|
||||||
|
else
|
||||||
|
krandom.r_buf[krandom.r_next] = get_uptime();
|
||||||
if (krandom.r_size < RANDOM_ELEMENTS) krandom.r_size ++;
|
if (krandom.r_size < RANDOM_ELEMENTS) krandom.r_size ++;
|
||||||
krandom.r_next = (krandom.r_next + 1 ) % RANDOM_ELEMENTS;
|
krandom.r_next = (krandom.r_next + 1 ) % RANDOM_ELEMENTS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue