Date: Sat, 18 Nov 2000 13:59:58 +0200 From: Mark Murray <mark@grondar.za> To: arch@freebsd.org Subject: "Monotonic" counter/register call - commit candidate. Message-ID: <200011181200.eAIC00J12131@gratis.grondar.za>
next in thread | raw e-mail | index | archive | help
Hi Many thanks to those of you gave me all the constructive suggestions! Here is the commit candidate, taking into account as many of the reasonable ones as I could. WARNING! This is untested on Alpha and IA64. I considered renaming the function to marks(9), as I kinda liked that name, but on reflection, it seems way too arrogant, so Mike Smith's "get_jiffiecounter" won. I'm keeping the function public, as others have expressed an interest in using it. If this is accepted, I'll write a man 9 page for it. I have also included some fixes for ".byte xx,yy" code to use real Pentium opcodes (now that GAS is updated (a while back)). M Index: alpha/include//cpufunc.h =================================================================== RCS file: /home/ncvs/src/sys/alpha/include/cpufunc.h,v retrieving revision 1.9 diff -u -d -r1.9 cpufunc.h --- alpha/include//cpufunc.h 2000/09/07 01:32:40 1.9 +++ alpha/include//cpufunc.h 2000/11/18 11:43:00 @@ -72,6 +72,15 @@ alpha_pal_swpipl(ipl); } +/* + * Standardised jiffy counter interface + */ +static __inline u_int64_t +get_jiffiecount(void) +{ + return alpha_rpcc(); +} + #endif /* _KERNEL */ #endif /* !_MACHINE_CPUFUNC_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 11:18:09 @@ -397,10 +397,24 @@ { u_int64_t rv; - __asm __volatile(".byte 0x0f, 0x31" : "=A" (rv)); + __asm __volatile("rdtsc" : "=A" (rv)); return (rv); } +/* + * Standardised jiffy counter interface + */ +static __inline u_int64_t +get_jiffiecount(void) +{ +#if defined(I386_CPU) || defined(I486_CPU) + if (!tsc_present) + return nanotime(); + else +#endif + return rdtsc(); +} + static __inline void wbinvd(void) { @@ -416,7 +430,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//cpufunc.h =================================================================== RCS file: /home/ncvs/src/sys/ia64/include/cpufunc.h,v retrieving revision 1.1 diff -u -d -r1.1 cpufunc.h --- ia64/include//cpufunc.h 2000/09/29 13:46:05 1.1 +++ ia64/include//cpufunc.h 2000/11/18 11:46:01 @@ -32,6 +32,7 @@ #ifdef _KERNEL #include <sys/types.h> +#include <machine/ia64_cpu.h> #ifdef __GNUC__ @@ -190,6 +191,15 @@ restore_intr(u_int psr) { __asm __volatile ("mov psr.l=%0;; srlz.d" :: "r" (psr)); +} + +/* + * Standardised jiffy counter interface + */ +static __inline u_int64_t +get_jiffiecount(void) +{ + return ia64_get_itc(); } #endif /* _KERNEL */ 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?200011181200.eAIC00J12131>