From: Ben Gras Date: Fri, 1 Jul 2005 09:39:47 +0000 (+0000) Subject: Fix to check for RDTSC instruction (above 486), and call another timing X-Git-Tag: v3.1.0~661 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/man.named.html?a=commitdiff_plain;h=2ce80ece5cf63042f1b152cf3ea888879a98aaaf;p=minix.git 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). --- diff --git a/kernel/system.c b/kernel/system.c index 9adadaebe..39fddc4ff 100755 --- a/kernel/system.c +++ b/kernel/system.c @@ -243,7 +243,21 @@ PUBLIC void get_randomness() * the lowest bytes because the highest bytes won't differ that much. */ unsigned long tsc_high; - read_tsc(&tsc_high, &krandom.r_buf[krandom.r_next]); + + /* 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]); + else + krandom.r_buf[krandom.r_next] = get_uptime(); if (krandom.r_size < RANDOM_ELEMENTS) krandom.r_size ++; krandom.r_next = (krandom.r_next + 1 ) % RANDOM_ELEMENTS; }