Share i386/tsc_microtime.c with alpha and sparc64 as kern_microtime.c.
(approved by martin)
This commit is contained in:
parent
a42ba8d2e3
commit
64eb1178ab
@ -1,4 +1,4 @@
|
||||
# $NetBSD: files.i386,v 1.226 2003/01/07 18:55:36 fvdl Exp $
|
||||
# $NetBSD: files.i386,v 1.227 2003/02/05 12:18:01 nakayama Exp $
|
||||
#
|
||||
# new style config file for i386 architecture
|
||||
#
|
||||
@ -85,7 +85,7 @@ file arch/i386/i386/machdep.c
|
||||
file arch/i386/i386/math_emulate.c math_emulate
|
||||
file arch/i386/i386/mem.c
|
||||
file arch/i386/i386/microtime.S
|
||||
file arch/i386/i386/tsc_microtime.c i586_cpu | i686_cpu
|
||||
file kern/kern_microtime.c i586_cpu | i686_cpu
|
||||
file arch/i386/i386/mtrr_i686.c mtrr
|
||||
file arch/i386/i386/mtrr_k6.c mtrr
|
||||
file netns/ns_cksum.c ns
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cpu.c,v 1.9 2003/01/17 23:10:30 thorpej Exp $ */
|
||||
/* $NetBSD: cpu.c,v 1.10 2003/02/05 12:18:02 nakayama Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
@ -610,7 +610,7 @@ cpu_hatch(void *v)
|
||||
printf("%s: CPU %ld running\n",ci->ci_dev->dv_xname, ci->ci_cpuid);
|
||||
#if defined(I586_CPU) || defined(I686_CPU)
|
||||
if (ci->ci_feature_flags & CPUID_TSC)
|
||||
tsc_microset(ci);
|
||||
cc_microset(ci);
|
||||
#endif
|
||||
microtime(&ci->ci_schedstate.spc_runtime);
|
||||
splx(s);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ipifuncs.c,v 1.6 2002/11/28 16:37:35 fvdl Exp $ */
|
||||
/* $NetBSD: ipifuncs.c,v 1.7 2003/02/05 12:18:02 nakayama Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
@ -86,7 +86,7 @@ void (*ipifunc[I386_NIPI])(struct cpu_info *) =
|
||||
{
|
||||
i386_ipi_halt,
|
||||
#if defined(I586_CPU) || defined(I686_CPU)
|
||||
tsc_microset,
|
||||
cc_microset,
|
||||
#else
|
||||
0,
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: lapic.c,v 1.7 2003/01/07 18:51:15 fvdl Exp $ */
|
||||
/* $NetBSD: lapic.c,v 1.8 2003/02/05 12:18:03 nakayama Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
@ -231,9 +231,8 @@ void
|
||||
lapic_clockintr(void *arg, struct intrframe frame)
|
||||
{
|
||||
#if defined(I586_CPU) || defined(I686_CPU)
|
||||
static int microset_iter; /* call tsc_microset once/sec */
|
||||
static int microset_iter; /* call cc_microset once/sec */
|
||||
struct cpu_info *ci = curcpu();
|
||||
extern struct timeval tsc_time;
|
||||
|
||||
ci->ci_isources[LIR_TIMER]->is_evcnt.ev_count++;
|
||||
|
||||
@ -246,12 +245,12 @@ lapic_clockintr(void *arg, struct intrframe frame)
|
||||
CPU_IS_PRIMARY(ci) &&
|
||||
#endif
|
||||
(microset_iter--) == 0) {
|
||||
microset_iter = hz-1;
|
||||
tsc_time = time;
|
||||
microset_iter = hz - 1;
|
||||
cc_microset_time = time;
|
||||
#if defined(MULTIPROCESSOR)
|
||||
i386_broadcast_ipi(I386_IPI_MICROSET);
|
||||
#endif
|
||||
tsc_microset(ci);
|
||||
cc_microset(ci);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: machdep.c,v 1.508 2003/01/17 23:10:30 thorpej Exp $ */
|
||||
/* $NetBSD: machdep.c,v 1.509 2003/02/05 12:18:03 nakayama Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996, 1997, 1998, 2000 The NetBSD Foundation, Inc.
|
||||
@ -76,7 +76,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.508 2003/01/17 23:10:30 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.509 2003/02/05 12:18:03 nakayama Exp $");
|
||||
|
||||
#include "opt_cputype.h"
|
||||
#include "opt_ddb.h"
|
||||
@ -1875,7 +1875,7 @@ identifycpu(struct cpu_info *ci)
|
||||
last_tsc = rdtsc();
|
||||
delay(100000);
|
||||
ci->ci_tsc_freq = (rdtsc() - last_tsc) * 10;
|
||||
microtime_func = tsc_microtime;
|
||||
microtime_func = cc_microtime;
|
||||
}
|
||||
/* XXX end XXX */
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cpu.h,v 1.95 2003/01/17 23:10:28 thorpej Exp $ */
|
||||
/* $NetBSD: cpu.h,v 1.96 2003/02/05 12:18:04 nakayama Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
@ -146,12 +146,12 @@ struct cpu_info {
|
||||
struct i386_cache_info ci_cinfo[CAI_COUNT];
|
||||
|
||||
/*
|
||||
* Variables used by tsc_microtime().
|
||||
* Variables used by cc_microtime().
|
||||
*/
|
||||
struct timeval ci_tsc_time;
|
||||
int64_t ci_tsc_tsc;
|
||||
int64_t ci_tsc_ms_delta;
|
||||
int64_t ci_tsc_denom;
|
||||
struct timeval ci_cc_time;
|
||||
int64_t ci_cc_cc;
|
||||
int64_t ci_cc_ms_delta;
|
||||
int64_t ci_cc_denom;
|
||||
|
||||
union descriptor *ci_gdt;
|
||||
|
||||
@ -385,10 +385,11 @@ void i8254_delay __P((int));
|
||||
void i8254_microtime __P((struct timeval *));
|
||||
void i8254_initclocks __P((void));
|
||||
|
||||
/* tsc_microtime.c */
|
||||
/* kern_microtime.c */
|
||||
|
||||
void tsc_microtime __P((struct timeval *));
|
||||
void tsc_microset __P((struct cpu_info *));
|
||||
extern struct timeval cc_microset_time;
|
||||
void cc_microtime __P((struct timeval *));
|
||||
void cc_microset __P((struct cpu_info *));
|
||||
|
||||
/* cpu.c */
|
||||
|
||||
|
95
sys/arch/i386/include/cpu_counter.h
Normal file
95
sys/arch/i386/include/cpu_counter.h
Normal file
@ -0,0 +1,95 @@
|
||||
/* $NetBSD: cpu_counter.h,v 1.1 2003/02/05 12:18:04 nakayama Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Bill Sommerfeld.
|
||||
*
|
||||
* 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 _I386_CPU_COUNTER_H_
|
||||
#define _I386_CPU_COUNTER_H_
|
||||
|
||||
/*
|
||||
* Machine-specific support for CPU counter.
|
||||
*/
|
||||
|
||||
#include <machine/cpu.h>
|
||||
#include <machine/cpufunc.h>
|
||||
#include <machine/specialreg.h>
|
||||
|
||||
#include "opt_cputype.h"
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
static __inline int
|
||||
cpu_hascounter(void)
|
||||
{
|
||||
|
||||
#if defined(I586_CPU) || defined(I686_CPU)
|
||||
/*
|
||||
* Note that:
|
||||
* 1) Intel documentation is very specific that code *must* test
|
||||
* the CPU feature flag, even if you "know" that a particular
|
||||
* rev of the hardware supports it.
|
||||
* 2) We know that the TSC is busted on some Cyrix CPU's..
|
||||
*/
|
||||
return (cpu_feature & CPUID_TSC) != 0;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static __inline uint64_t
|
||||
cpu_counter(void)
|
||||
{
|
||||
|
||||
return (rdtsc());
|
||||
}
|
||||
|
||||
static __inline uint32_t
|
||||
cpu_counter32(void)
|
||||
{
|
||||
|
||||
return (rdtsc() & 0xffffffffUL);
|
||||
}
|
||||
|
||||
static __inline uint64_t
|
||||
cpu_frequency(struct cpu_info *ci)
|
||||
{
|
||||
|
||||
return (ci->ci_tsc_freq);
|
||||
}
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* !_I386_CPU_COUNTER_H_ */
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: clock.c,v 1.77 2002/12/10 23:24:33 perry Exp $ */
|
||||
/* $NetBSD: clock.c,v 1.78 2003/02/05 12:18:04 nakayama Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993, 1994 Charles M. Hannum.
|
||||
@ -90,7 +90,7 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.77 2002/12/10 23:24:33 perry Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.78 2003/02/05 12:18:04 nakayama Exp $");
|
||||
|
||||
/* #define CLOCKDEBUG */
|
||||
/* #define CLOCK_PARANOIA */
|
||||
@ -390,9 +390,8 @@ int
|
||||
clockintr(void *arg, struct intrframe frame)
|
||||
{
|
||||
#if defined(I586_CPU) || defined(I686_CPU)
|
||||
static int microset_iter; /* call tsc_microset once/sec */
|
||||
static int microset_iter; /* call cc_microset once/sec */
|
||||
struct cpu_info *ci = curcpu();
|
||||
extern struct timeval tsc_time;
|
||||
|
||||
/*
|
||||
* If we have a cycle counter, do the microset thing.
|
||||
@ -403,12 +402,12 @@ clockintr(void *arg, struct intrframe frame)
|
||||
CPU_IS_PRIMARY(ci) &&
|
||||
#endif
|
||||
(microset_iter--) == 0) {
|
||||
tsc_time = time;
|
||||
microset_iter = hz-1;
|
||||
cc_microset_time = time;
|
||||
microset_iter = hz - 1;
|
||||
#if defined(MULTIPROCESSOR)
|
||||
i386_broadcast_ipi(I386_IPI_MICROSET);
|
||||
#endif
|
||||
tsc_microset(ci);
|
||||
cc_microset(ci);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -753,7 +752,6 @@ inittodr(base)
|
||||
int s;
|
||||
#if defined(I586_CPU) || defined(I686_CPU)
|
||||
struct cpu_info *ci = curcpu();
|
||||
extern struct timeval tsc_time;
|
||||
#endif
|
||||
/*
|
||||
* We mostly ignore the suggested time (which comes from the
|
||||
@ -819,8 +817,8 @@ inittodr(base)
|
||||
#endif
|
||||
#if defined(I586_CPU) || defined(I686_CPU)
|
||||
if (ci->ci_feature_flags & CPUID_TSC) {
|
||||
tsc_time = time;
|
||||
tsc_microset(ci);
|
||||
cc_microset_time = time;
|
||||
cc_microset(ci);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user