diff options
author | peter <peter@FreeBSD.org> | 2005-12-13 19:08:55 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2005-12-13 19:08:55 +0000 |
commit | 9b3d762efb89570a19cd98865e30117ce8a99d93 (patch) | |
tree | ab36666fbbf06a6153ec45cfe56905154beba4f5 /sys | |
parent | 3bd2c6644920df9a5ccf8d96110acf156fbf786c (diff) | |
download | FreeBSD-src-9b3d762efb89570a19cd98865e30117ce8a99d93.zip FreeBSD-src-9b3d762efb89570a19cd98865e30117ce8a99d93.tar.gz |
MFamd64 rev 1.223: Use the TSC to implement DELAY() if not marked broken
and it has been calibrated.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/i386/isa/clock.c | 15 | ||||
-rw-r--r-- | sys/isa/atrtc.c | 15 |
2 files changed, 30 insertions, 0 deletions
diff --git a/sys/i386/isa/clock.c b/sys/i386/isa/clock.c index 38b238f..7a75cfb 100644 --- a/sys/i386/isa/clock.c +++ b/sys/i386/isa/clock.c @@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$"); #include <sys/kernel.h> #include <sys/limits.h> #include <sys/module.h> +#include <sys/sched.h> #include <sys/sysctl.h> #include <sys/cons.h> #include <sys/power.h> @@ -288,7 +289,21 @@ DELAY(int n) int getit_calls = 1; int n1; static int state = 0; +#endif + + if (tsc_freq != 0 && !tsc_is_broken) { + uint64_t start, end, now; + sched_pin(); + start = rdtsc(); + end = start + (tsc_freq * n) / 1000000; + do { + now = rdtsc(); + } while (now < end || (now > start && end < start)); + sched_unpin(); + return; + } +#ifdef DELAYDEBUG if (state == 0) { state = 1; for (n1 = 1; n1 <= 10000000; n1 *= 10) diff --git a/sys/isa/atrtc.c b/sys/isa/atrtc.c index 38b238f..7a75cfb 100644 --- a/sys/isa/atrtc.c +++ b/sys/isa/atrtc.c @@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$"); #include <sys/kernel.h> #include <sys/limits.h> #include <sys/module.h> +#include <sys/sched.h> #include <sys/sysctl.h> #include <sys/cons.h> #include <sys/power.h> @@ -288,7 +289,21 @@ DELAY(int n) int getit_calls = 1; int n1; static int state = 0; +#endif + + if (tsc_freq != 0 && !tsc_is_broken) { + uint64_t start, end, now; + sched_pin(); + start = rdtsc(); + end = start + (tsc_freq * n) / 1000000; + do { + now = rdtsc(); + } while (now < end || (now > start && end < start)); + sched_unpin(); + return; + } +#ifdef DELAYDEBUG if (state == 0) { state = 1; for (n1 = 1; n1 <= 10000000; n1 *= 10) |