Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Nov 2000 21:44:40 +0200
From:      Mark Murray <mark@grondar.za>
To:        arch@freebsd.org
Subject:   "monotime" counter - commit candidate #2
Message-ID:  <200011191944.eAJJieJ15985@gratis.grondar.za>

next in thread | raw e-mail | index | archive | help
Hi

It looks like we are converging, and that the bikeshed factor
is gone!

BDE has sent some useful comments, and I have incorporated them.

We are ready for go. Green Light?

M

Index: alpha/include/cpu.h
===================================================================
RCS file: /home/ncvs/src/sys/alpha/include/cpu.h,v
retrieving revision 1.18
diff -u -d -r1.18 cpu.h
--- alpha/include/cpu.h	2000/10/06 02:20:10	1.18
+++ alpha/include/cpu.h	2000/11/19 19:01:36
@@ -173,6 +173,16 @@
 void	trap __P((unsigned long, unsigned long, unsigned long, unsigned long,
 	    struct trapframe *));
 
+/*
+ * Return contents of in-cpu fast counter as a sort of "bogo-time"
+ * for non-critical timing.
+ */
+static __inline u_int64_t
+get_cyclecount(void)
+{
+	return (alpha_rpcc());
+}
+
 #endif /* _KERNEL */
 
 #endif /* _ALPHA_CPU_H_ */
Index: i386/include/cpu.h
===================================================================
RCS file: /home/ncvs/src/sys/i386/include/cpu.h,v
retrieving revision 1.49
diff -u -d -r1.49 cpu.h
--- i386/include/cpu.h	2000/10/27 08:30:56	1.49
+++ i386/include/cpu.h	2000/11/19 19:38:46
@@ -47,6 +47,8 @@
 #include <machine/frame.h>
 #include <machine/segments.h>
 #include <machine/globals.h>
+#include <machine/md_var.h>
+#include <machine/specialreg.h>
 
 /*
  * definitions of cpu-dependent requirements
@@ -133,6 +135,25 @@
 
 void	fork_trampoline __P((void));
 void	fork_return __P((struct proc *, struct trapframe));
+
+/*
+ * Return contents of in-cpu fast counter as a sort of "bogo-time"
+ * for non-critical timing.
+ */
+static __inline u_int64_t
+get_cyclecount(void)
+{
+#if defined(I386_CPU) || defined(I486_CPU)
+	struct timespec tv;
+
+	if ((cpu_feature & CPUID_TSC) == 0) {
+		nanotime(&tv);
+		return (tv.tv_sec * (u_int64_t)1000000000 + tv.tv_nsec);
+	}
+#endif
+	return (rdtsc());
+}
+
 #endif
 
 #endif /* !_MACHINE_CPU_H_ */
Index: i386/include/cpufunc.h
===================================================================
RCS file: /home/ncvs/src/sys/i386/include/cpufunc.h,v
retrieving revision 1.99
diff -u -d -r1.99 cpufunc.h
--- i386/include/cpufunc.h	2000/10/12 17:05:33	1.99
+++ i386/include/cpufunc.h	2000/11/18 21:29:08
@@ -397,7 +397,7 @@
 {
 	u_int64_t rv;
 
-	__asm __volatile(".byte 0x0f, 0x31" : "=A" (rv));
+	__asm __volatile("rdtsc" : "=A" (rv));
 	return (rv);
 }
 
@@ -416,7 +416,7 @@
 static __inline void
 wrmsr(u_int msr, u_int64_t newval)
 {
-	__asm __volatile(".byte 0x0f, 0x30" : : "A" (newval), "c" (msr));
+	__asm __volatile("wrmsr" : : "A" (newval), "c" (msr));
 }
 
 static __inline u_int
Index: ia64/include/cpu.h
===================================================================
RCS file: /home/ncvs/src/sys/ia64/include/cpu.h,v
retrieving revision 1.5
diff -u -d -r1.5 cpu.h
--- ia64/include/cpu.h	2000/10/16 08:54:40	1.5
+++ ia64/include/cpu.h	2000/11/19 19:01:21
@@ -166,6 +166,16 @@
 void	syscall __P((int, u_int64_t *, struct trapframe *));
 void	trap __P((int vector, int imm, struct trapframe *framep));
 
+/*
+ * Return contents of in-cpu fast counter as a sort of "bogo-time"
+ * for non-critical timing.
+ */
+static __inline u_int64_t
+get_cyclecount(void)
+{
+	return (ia64_get_itc());
+}
+
 #endif /* _KERNEL */
 
 #endif /* _MACHINE_CPU_H_ */


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200011191944.eAJJieJ15985>