Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/i386/i386 move



details:   https://anonhg.NetBSD.org/src/rev/e295a74c99a6
branches:  trunk
changeset: 582802:e295a74c99a6
user:      fair <fair%NetBSD.org@localhost>
date:      Wed Jul 06 18:35:39 2005 +0000

description:
move
        microtime_func = cc_microtime;

to a point after the CPU-specific setup routine is called because some of them
"turn off" the TSC because it's broken on those platforms, or not suitable
for use as an interval timer.

One such platform is the Cyrix/NSC Geode processor; when powersave mode is
enabled, the "hlt" instruction stops the TSC too. It continues to be perfectly
reasonable for program profiling as a cycle counter in this mode, but it is
unsuitable for interval time keeping (time doesn't stop just because you're
asleep or napping), and, for now, we don't have a separate flag to make this
distinction - we just test for the presence of TSC to enable cc_microtime().

diffstat:

 sys/arch/i386/i386/cpu.c      |  17 +++++++++++++++--
 sys/arch/i386/i386/identcpu.c |   7 ++-----
 2 files changed, 17 insertions(+), 7 deletions(-)

diffs (66 lines):

diff -r 7fa3f309a181 -r e295a74c99a6 sys/arch/i386/i386/cpu.c
--- a/sys/arch/i386/i386/cpu.c  Wed Jul 06 18:12:31 2005 +0000
+++ b/sys/arch/i386/i386/cpu.c  Wed Jul 06 18:35:39 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.22 2005/06/15 01:52:39 christos Exp $ */
+/* $NetBSD: cpu.c,v 1.23 2005/07/06 18:35:39 fair Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.22 2005/06/15 01:52:39 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.23 2005/07/06 18:35:39 fair Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -409,6 +409,19 @@
        if (ci->ci_cpu_class >= CPUCLASS_486)
                lcr0(rcr0() | CR0_WP);
 #endif
+#if defined(I586_CPU) || defined(I686_CPU)
+#ifndef NO_TSC_TIME
+       /*
+        * On systems with a cycle counter, use that for
+        * interval timing inbetween hz ticks in microtime(9)
+        * N.B. this is not a good idea on processors whose
+        * frequency varies a lot over time (e.g. modern laptops)
+        */
+       if (cpu_feature & TSC) {
+               microtime_func = cc_microtime;
+       }
+#endif
+#endif
 #if defined(I686_CPU)
        /*
         * On a P6 or above, enable global TLB caching if the
diff -r 7fa3f309a181 -r e295a74c99a6 sys/arch/i386/i386/identcpu.c
--- a/sys/arch/i386/i386/identcpu.c     Wed Jul 06 18:12:31 2005 +0000
+++ b/sys/arch/i386/i386/identcpu.c     Wed Jul 06 18:35:39 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: identcpu.c,v 1.19 2005/06/16 00:04:25 seb Exp $        */
+/*     $NetBSD: identcpu.c,v 1.20 2005/07/06 18:35:39 fair Exp $       */
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.19 2005/06/16 00:04:25 seb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.20 2005/07/06 18:35:39 fair Exp $");
 
 #include "opt_cputype.h"
 #include "opt_enhanced_speedstep.h"
@@ -1198,9 +1198,6 @@
                last_tsc = rdtsc();
                delay(100000);
                ci->ci_tsc_freq = (rdtsc() - last_tsc) * 10;
-#ifndef NO_TSC_TIME
-               microtime_func = cc_microtime;
-#endif
        }
        /* XXX end XXX */
 #endif



Home | Main Index | Thread Index | Old Index