diff options
author | nyan <nyan@FreeBSD.org> | 2005-02-06 13:23:20 +0000 |
---|---|---|
committer | nyan <nyan@FreeBSD.org> | 2005-02-06 13:23:20 +0000 |
commit | e740735d0155955d44529c57bc428fd808db1194 (patch) | |
tree | 7427d1fa9dca9740e1ab2129a99193d9918fca42 | |
parent | d5130a84f64f083f389a66e8993056d417a5ec99 (diff) | |
download | FreeBSD-src-e740735d0155955d44529c57bc428fd808db1194.zip FreeBSD-src-e740735d0155955d44529c57bc428fd808db1194.tar.gz |
MFi386: revision 1.606.
-rw-r--r-- | sys/pc98/i386/machdep.c | 12 | ||||
-rw-r--r-- | sys/pc98/pc98/machdep.c | 12 |
2 files changed, 20 insertions, 4 deletions
diff --git a/sys/pc98/i386/machdep.c b/sys/pc98/i386/machdep.c index e5492ff..e917a49 100644 --- a/sys/pc98/i386/machdep.c +++ b/sys/pc98/i386/machdep.c @@ -1044,6 +1044,7 @@ cpu_boot(int howto) int cpu_est_clockrate(int cpu_id, uint64_t *rate) { + register_t reg; uint64_t tsc1, tsc2; if (pcpu_find(cpu_id) == NULL || rate == NULL) @@ -1065,9 +1066,11 @@ cpu_est_clockrate(int cpu_id, uint64_t *rate) #endif /* Calibrate by measuring a short delay. */ + reg = intr_disable(); tsc1 = rdtsc(); DELAY(1000); tsc2 = rdtsc(); + intr_restore(reg); #ifdef SMP mtx_lock_spin(&sched_lock); @@ -1075,8 +1078,13 @@ cpu_est_clockrate(int cpu_id, uint64_t *rate) mtx_unlock_spin(&sched_lock); #endif - tsc_freq = (tsc2 - tsc1) * 1000; - *rate = tsc_freq; + /* + * Calculate the difference in readings, convert to Mhz, and + * subtract 0.5% of the total. Empirical testing has shown that + * overhead in DELAY() works out to approximately this value. + */ + tsc2 -= tsc1; + *rate = tsc2 * 1000 - tsc2 * 5; return (0); } diff --git a/sys/pc98/pc98/machdep.c b/sys/pc98/pc98/machdep.c index e5492ff..e917a49 100644 --- a/sys/pc98/pc98/machdep.c +++ b/sys/pc98/pc98/machdep.c @@ -1044,6 +1044,7 @@ cpu_boot(int howto) int cpu_est_clockrate(int cpu_id, uint64_t *rate) { + register_t reg; uint64_t tsc1, tsc2; if (pcpu_find(cpu_id) == NULL || rate == NULL) @@ -1065,9 +1066,11 @@ cpu_est_clockrate(int cpu_id, uint64_t *rate) #endif /* Calibrate by measuring a short delay. */ + reg = intr_disable(); tsc1 = rdtsc(); DELAY(1000); tsc2 = rdtsc(); + intr_restore(reg); #ifdef SMP mtx_lock_spin(&sched_lock); @@ -1075,8 +1078,13 @@ cpu_est_clockrate(int cpu_id, uint64_t *rate) mtx_unlock_spin(&sched_lock); #endif - tsc_freq = (tsc2 - tsc1) * 1000; - *rate = tsc_freq; + /* + * Calculate the difference in readings, convert to Mhz, and + * subtract 0.5% of the total. Empirical testing has shown that + * overhead in DELAY() works out to approximately this value. + */ + tsc2 -= tsc1; + *rate = tsc2 * 1000 - tsc2 * 5; return (0); } |