summaryrefslogtreecommitdiff
path: root/sys/arch/i386/isa/clock.c
diff options
context:
space:
mode:
authorThorsten Lockert <tholo@cvs.openbsd.org>1996-02-25 23:03:17 +0000
committerThorsten Lockert <tholo@cvs.openbsd.org>1996-02-25 23:03:17 +0000
commit915abd18d665696c222321f6c34870ebed9a5457 (patch)
tree8879e4bd855cc89da55753b81fb094b329021735 /sys/arch/i386/isa/clock.c
parentd9458b4cd30074b84a2c9949cbbf2aaecd954409 (diff)
Allow use of Pentium cycle counter for high-precision time keeping;
from FreeBSD
Diffstat (limited to 'sys/arch/i386/isa/clock.c')
-rw-r--r--sys/arch/i386/isa/clock.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/sys/arch/i386/isa/clock.c b/sys/arch/i386/isa/clock.c
index 5cacb8cc9fc..2833d2f2f10 100644
--- a/sys/arch/i386/isa/clock.c
+++ b/sys/arch/i386/isa/clock.c
@@ -107,6 +107,10 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
void spinwait __P((int));
+#ifdef I586_CPU
+int pentium_mhz;
+#endif
+
#define SECMIN ((unsigned)60) /* seconds per minute */
#define SECHOUR ((unsigned)(60*SECMIN)) /* seconds per hour */
#define SECDAY ((unsigned)(24*SECHOUR)) /* seconds per day */
@@ -303,6 +307,19 @@ findcpuspeed()
delaycount = (FIRST_GUESS * TIMER_DIV(1000)) / (0xffff-remainder);
}
+#ifdef I586_CPU
+void
+calibrate_cyclecounter()
+{
+ unsigned long long count, last_count;
+
+ __asm __volatile(".byte 0xf, 0x31" : "=A" (last_count));
+ delay(1000000);
+ __asm __volatile(".byte 0xf, 0x31" : "=A" (count));
+ pentium_mhz = ((count - last_count) + 500000) / 1000000;
+}
+#endif
+
void
cpu_initclocks()
{