[BACK]Return to cc_microtime.h CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / sys

File: [cvs.NetBSD.org] / src / sys / sys / Attic / cc_microtime.h (download)

Revision 1.3, Wed Jun 7 22:34:18 2006 UTC (17 years, 10 months ago) by kardel
Branch: MAIN
CVS Tags: yamt-x86pmap-base4, yamt-x86pmap-base3, yamt-x86pmap-base2, yamt-x86pmap-base, yamt-x86pmap, yamt-splraiseipl-base5, yamt-splraiseipl-base4, yamt-splraiseipl-base3, yamt-splraiseipl-base2, yamt-splraiseipl-base, yamt-splraiseipl, yamt-pdpolicy-base9, yamt-pdpolicy-base8, yamt-pdpolicy-base7, yamt-pdpolicy-base6, yamt-kmem-base3, yamt-kmem-base2, yamt-kmem-base, yamt-kmem, yamt-idlelwp-base8, yamt-idlelwp, wrstuden-fixsa-newbase, wrstuden-fixsa-base-1, wrstuden-fixsa-base, wrstuden-fixsa, vmlocking2-base3, vmlocking2-base2, vmlocking2-base1, vmlocking2, vmlocking-nbase, vmlocking-base, vmlocking, thorpej-atomic-base, thorpej-atomic, rpaulo-netinet-merge-pcb-base, reinoud-bufcleanup-nbase, reinoud-bufcleanup-base, reinoud-bufcleanup, post-newlock2-merge, nick-csl-alignment-base5, nick-csl-alignment-base4, nick-csl-alignment-base3, nick-csl-alignment-base2, nick-csl-alignment-base, nick-csl-alignment, newlock2-nbase, newlock2-base, newlock2, netbsd-4-base, netbsd-4-0-RELEASE, netbsd-4-0-RC5, netbsd-4-0-RC4, netbsd-4-0-RC3, netbsd-4-0-RC2, netbsd-4-0-RC1, netbsd-4-0-1-RELEASE, netbsd-4-0, netbsd-4, mjf-ufs-trans-base, mjf-ufs-trans, matt-nb4-arm-base, matt-nb4-arm, matt-mips64-base, matt-mips64, matt-armv6-prevmlocking, matt-armv6-base, jmcneill-pm-base, jmcneill-pm, jmcneill-base, hpcarm-cleanup, gdamore-uart-base, gdamore-uart, cube-autoconf-base, cube-autoconf, chap-midi-nbase, chap-midi-base, bouyer-xeni386-merge1, bouyer-xeni386-base, bouyer-xenamd64-base2, bouyer-xenamd64-base, bouyer-xenamd64, ad-audiomp-base, ad-audiomp, abandoned-netbsd-4-base, abandoned-netbsd-4
Branch point for: mjf-devfs, matt-armv6, bouyer-xeni386
Changes since 1.2: +18 -1 lines

merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
  time.tv_sec -> time_second
- struct timeval mono_time is gone
  mono_time.tv_sec -> time_uptime
- access to time via
	{get,}{micro,nano,bin}time()
	get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
  Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
  NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html

/*	$NetBSD: cc_microtime.h,v 1.3 2006/06/07 22:34:18 kardel Exp $	*/

/*-
 * Copyright (c) 2004 The NetBSD Foundation, Inc.
 * 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *        This product includes software developed by the NetBSD
 *        Foundation, Inc. and its contributors.
 * 4. Neither the name of The NetBSD Foundation nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
 */

#ifndef _SYS_CC_MICROTIME_H_
#define	_SYS_CC_MICROTIME_H_

#ifndef __HAVE_TIMECOUNTER
extern struct timeval cc_microset_time;
void cc_microtime(struct timeval *);
void cc_microset(struct cpu_info *);

/*
 * Variables used by cc_microtime().
 */
struct cc_microtime_state {
	struct timeval cc_time;
	int64_t cc_cc;
	int64_t cc_ms_delta;
	int64_t cc_denom;
};
#else
/* XXX this file is not named right - rather something like tsc.h */
void tsc_calibrate_cpu(struct cpu_info *);
/*
 * Variables used by cc_microtime().
 */
struct cc_microtime_state {
	volatile u_int   cc_gen;   /* generation number for this data set */
	volatile int64_t cc_val;   /* reference TSC value at calibration time */
	volatile int64_t cc_cc;	   /* local TSC value at calibration time */
	volatile int64_t cc_delta; /* reference TSC difference for
				      last calibration period */
	volatile int64_t cc_denom; /* local TSC difference for
				      last calibration period */
};
#endif /* __HAVE_TIMECOUNTER */

#endif /* _SYS_CC_MICROTIME_H_ */