From owner-freebsd-arch Sun Nov 19 1:32:27 2000 Delivered-To: freebsd-arch@freebsd.org Received: from gratis.grondar.za (grouter.grondar.za [196.7.18.65]) by hub.freebsd.org (Postfix) with ESMTP id D352737B479 for ; Sun, 19 Nov 2000 01:32:15 -0800 (PST) Received: from grondar.za (grapevine.grondar.za [196.7.18.17]) by gratis.grondar.za (8.11.1/8.11.1) with ESMTP id eAJ9WBJ14810 for ; Sun, 19 Nov 2000 11:32:12 +0200 (SAST) (envelope-from mark@grondar.za) Message-Id: <200011190932.eAJ9WBJ14810@gratis.grondar.za> To: arch@freebsd.org Subject: "monotonic" counter commit candidate. Reviews, please. Date: Sun, 19 Nov 2000 11:32:02 +0200 From: Mark Murray Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hi I have incorporated a whole bunch more of ideas and concerns from John Baldein and Bruce Evans. I reckon this is now about ready to go in. Comments/reviews please? (Please - If you have objections, and you want me to take them seriously, do some homework and provide me with an alternative (or at least a suggestion for a fix or improvement). If there is no supplied solution or considered suggestion, I find it very difficult to take your objection seriously.) (Please Please - no more arguing about the @#$%ing name, unless you have a genuine concern there. That dead horse is well buried). M Index: sys/systm.h =================================================================== RCS file: /home/ncvs/src/sys/sys/systm.h,v retrieving revision 1.127 diff -u -d -r1.127 systm.h --- sys/systm.h 2000/11/15 22:39:35 1.127 +++ sys/systm.h 2000/11/18 21:31:38 @@ -44,6 +44,7 @@ #include #include +#include #include extern int securelevel; /* system security level (see init(8)) */ Index: alpha/include/systm.h =================================================================== RCS file: systm.h diff -N systm.h --- /dev/null Sun Nov 19 11:09:56 2000 +++ systm.h Sat Nov 18 23:32:02 2000 @@ -0,0 +1,46 @@ +/*- + * Copyright (c) 1993 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +/* + * Functions to provide access to functions that are present in all + * architectures, but machine dependant. + */ + +#ifndef _MACHINE_SYSTM_H_ +#define _MACHINE_SYSTM_H_ + +/* + * Standardised jiffy counter interface + */ +static __inline u_int64_t +get_cyclecount(void) +{ + return alpha_rpcc(); +} + +#endif /* !_MACHINE_SYSTM_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: i386/include/systm.h =================================================================== RCS file: systm.h diff -N systm.h --- /dev/null Sun Nov 19 11:09:56 2000 +++ systm.h Sun Nov 19 09:47:44 2000 @@ -0,0 +1,60 @@ +/*- + * Copyright (c) 1993 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +/* + * Functions to provide access to functions that are present in all + * architectures, but machine dependant. + */ + +#ifndef _MACHINE_SYSTM_H_ +#define _MACHINE_SYSTM_H_ + +#if defined(I386_CPU) || defined(I486_CPU) +#include +#include +#include +#endif + +/* + * Standardised jiffy counter interface + */ +static __inline u_int64_t +get_cyclecount(void) +{ +#if defined(I386_CPU) || defined(I486_CPU) + struct timespec tv; + + if (!(cpu_feature & CPUID_TSC)) { + nanotime(&tv); + return (u_int64_t)tv.tv_sec*1000000000L + tv.tv_nsec; + } +#endif + return rdtsc(); +} + +#endif /* !_MACHINE_SYSTM_H_ */ Index: ia64/include/systm.h =================================================================== RCS file: systm.h diff -N systm.h --- /dev/null Sun Nov 19 11:09:56 2000 +++ systm.h Sat Nov 18 23:32:22 2000 @@ -0,0 +1,46 @@ +/*- + * Copyright (c) 1993 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +/* + * Functions to provide access to functions that are present in all + * architectures, but machine dependant. + */ + +#ifndef _MACHINE_SYSTM_H_ +#define _MACHINE_SYSTM_H_ + +/* + * Standardised jiffy counter interface + */ +static __inline u_int64_t +get_cyclecount(void) +{ + return ia64_get_itc(); +} + +#endif /* !_MACHINE_SYSTM_H_ */ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message