From e33bfde398f75098ee1f36258614710771e24f8a Mon Sep 17 00:00:00 2001 From: Mike Smith Date: Wed, 28 Jul 1999 20:22:30 +0000 Subject: [PATCH] We're called too early to have any idea whether APM is going to be active or not. The only sane thing we can do here is assume that if APM is supported it might be active at some point, and bail. In reality, even this isn't good enough; regardless of whether we support APM or not, the system may well futz with the CPU's clock speed and throw the TSC off. We need to stop using it for timekeeping except under controlled circumstances. Curse the lack of a dependable high-resolution timer. --- sys/amd64/amd64/tsc.c | 18 +++++++----------- sys/amd64/isa/clock.c | 18 +++++++----------- sys/i386/i386/tsc.c | 18 +++++++----------- sys/i386/isa/clock.c | 18 +++++++----------- sys/isa/atrtc.c | 18 +++++++----------- 5 files changed, 35 insertions(+), 55 deletions(-) diff --git a/sys/amd64/amd64/tsc.c b/sys/amd64/amd64/tsc.c index ec6ca519137..020e9830bb6 100644 --- a/sys/amd64/amd64/tsc.c +++ b/sys/amd64/amd64/tsc.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)clock.c 7.2 (Berkeley) 5/12/91 - * $Id: clock.c,v 1.139 1999/07/18 15:19:29 bde Exp $ + * $Id: clock.c,v 1.140 1999/07/18 18:32:42 bde Exp $ */ /* @@ -70,10 +70,7 @@ #include #include #include -#if NAPM > 0 -#include -#include -#endif +XXX #ifdef APIC_IO #include #endif @@ -772,17 +769,16 @@ startrtclock() #if NAPM > 0 /* - * We can not use the TSC if we found an APM bios. Too many - * of them lie about their ability&intention to fiddle the CPU - * clock for us to rely on this. Precise timekeeping on an - * APM'ed machine is at best a fools pursuit anyway, since + * We can not use the TSC if we support APM. Precise timekeeping + * on an APM'ed machine is at best a fools pursuit, since * any and all of the time spent in various SMM code can't * be reliably accounted for. Reading the RTC is your only * source of reliable time info. The i8254 looses too of course * but we need to have some kind of time... + * We don't know at this point whether APM is going to be used + * or not, nor when it might be activated. Play it safe. */ - if (apm_version != APMINI_CANTFIND) - return; + return; #endif /* NAPM > 0 */ if (tsc_present && tsc_freq != 0 && !tsc_is_broken) { diff --git a/sys/amd64/isa/clock.c b/sys/amd64/isa/clock.c index ec6ca519137..020e9830bb6 100644 --- a/sys/amd64/isa/clock.c +++ b/sys/amd64/isa/clock.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)clock.c 7.2 (Berkeley) 5/12/91 - * $Id: clock.c,v 1.139 1999/07/18 15:19:29 bde Exp $ + * $Id: clock.c,v 1.140 1999/07/18 18:32:42 bde Exp $ */ /* @@ -70,10 +70,7 @@ #include #include #include -#if NAPM > 0 -#include -#include -#endif +XXX #ifdef APIC_IO #include #endif @@ -772,17 +769,16 @@ startrtclock() #if NAPM > 0 /* - * We can not use the TSC if we found an APM bios. Too many - * of them lie about their ability&intention to fiddle the CPU - * clock for us to rely on this. Precise timekeeping on an - * APM'ed machine is at best a fools pursuit anyway, since + * We can not use the TSC if we support APM. Precise timekeeping + * on an APM'ed machine is at best a fools pursuit, since * any and all of the time spent in various SMM code can't * be reliably accounted for. Reading the RTC is your only * source of reliable time info. The i8254 looses too of course * but we need to have some kind of time... + * We don't know at this point whether APM is going to be used + * or not, nor when it might be activated. Play it safe. */ - if (apm_version != APMINI_CANTFIND) - return; + return; #endif /* NAPM > 0 */ if (tsc_present && tsc_freq != 0 && !tsc_is_broken) { diff --git a/sys/i386/i386/tsc.c b/sys/i386/i386/tsc.c index ec6ca519137..020e9830bb6 100644 --- a/sys/i386/i386/tsc.c +++ b/sys/i386/i386/tsc.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)clock.c 7.2 (Berkeley) 5/12/91 - * $Id: clock.c,v 1.139 1999/07/18 15:19:29 bde Exp $ + * $Id: clock.c,v 1.140 1999/07/18 18:32:42 bde Exp $ */ /* @@ -70,10 +70,7 @@ #include #include #include -#if NAPM > 0 -#include -#include -#endif +XXX #ifdef APIC_IO #include #endif @@ -772,17 +769,16 @@ startrtclock() #if NAPM > 0 /* - * We can not use the TSC if we found an APM bios. Too many - * of them lie about their ability&intention to fiddle the CPU - * clock for us to rely on this. Precise timekeeping on an - * APM'ed machine is at best a fools pursuit anyway, since + * We can not use the TSC if we support APM. Precise timekeeping + * on an APM'ed machine is at best a fools pursuit, since * any and all of the time spent in various SMM code can't * be reliably accounted for. Reading the RTC is your only * source of reliable time info. The i8254 looses too of course * but we need to have some kind of time... + * We don't know at this point whether APM is going to be used + * or not, nor when it might be activated. Play it safe. */ - if (apm_version != APMINI_CANTFIND) - return; + return; #endif /* NAPM > 0 */ if (tsc_present && tsc_freq != 0 && !tsc_is_broken) { diff --git a/sys/i386/isa/clock.c b/sys/i386/isa/clock.c index ec6ca519137..020e9830bb6 100644 --- a/sys/i386/isa/clock.c +++ b/sys/i386/isa/clock.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)clock.c 7.2 (Berkeley) 5/12/91 - * $Id: clock.c,v 1.139 1999/07/18 15:19:29 bde Exp $ + * $Id: clock.c,v 1.140 1999/07/18 18:32:42 bde Exp $ */ /* @@ -70,10 +70,7 @@ #include #include #include -#if NAPM > 0 -#include -#include -#endif +XXX #ifdef APIC_IO #include #endif @@ -772,17 +769,16 @@ startrtclock() #if NAPM > 0 /* - * We can not use the TSC if we found an APM bios. Too many - * of them lie about their ability&intention to fiddle the CPU - * clock for us to rely on this. Precise timekeeping on an - * APM'ed machine is at best a fools pursuit anyway, since + * We can not use the TSC if we support APM. Precise timekeeping + * on an APM'ed machine is at best a fools pursuit, since * any and all of the time spent in various SMM code can't * be reliably accounted for. Reading the RTC is your only * source of reliable time info. The i8254 looses too of course * but we need to have some kind of time... + * We don't know at this point whether APM is going to be used + * or not, nor when it might be activated. Play it safe. */ - if (apm_version != APMINI_CANTFIND) - return; + return; #endif /* NAPM > 0 */ if (tsc_present && tsc_freq != 0 && !tsc_is_broken) { diff --git a/sys/isa/atrtc.c b/sys/isa/atrtc.c index ec6ca519137..020e9830bb6 100644 --- a/sys/isa/atrtc.c +++ b/sys/isa/atrtc.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)clock.c 7.2 (Berkeley) 5/12/91 - * $Id: clock.c,v 1.139 1999/07/18 15:19:29 bde Exp $ + * $Id: clock.c,v 1.140 1999/07/18 18:32:42 bde Exp $ */ /* @@ -70,10 +70,7 @@ #include #include #include -#if NAPM > 0 -#include -#include -#endif +XXX #ifdef APIC_IO #include #endif @@ -772,17 +769,16 @@ startrtclock() #if NAPM > 0 /* - * We can not use the TSC if we found an APM bios. Too many - * of them lie about their ability&intention to fiddle the CPU - * clock for us to rely on this. Precise timekeeping on an - * APM'ed machine is at best a fools pursuit anyway, since + * We can not use the TSC if we support APM. Precise timekeeping + * on an APM'ed machine is at best a fools pursuit, since * any and all of the time spent in various SMM code can't * be reliably accounted for. Reading the RTC is your only * source of reliable time info. The i8254 looses too of course * but we need to have some kind of time... + * We don't know at this point whether APM is going to be used + * or not, nor when it might be activated. Play it safe. */ - if (apm_version != APMINI_CANTFIND) - return; + return; #endif /* NAPM > 0 */ if (tsc_present && tsc_freq != 0 && !tsc_is_broken) {