Share alpha/microtime.c with i386 and sparc64 as kern_microtime.c.

(approved by martin)
This commit is contained in:
nakayama 2003-02-05 12:16:41 +00:00
parent 8920acd333
commit a42ba8d2e3
7 changed files with 114 additions and 28 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: clock.c,v 1.31 2001/05/27 13:53:24 sommerfeld Exp $ */
/* $NetBSD: clock.c,v 1.32 2003/02/05 12:16:41 nakayama Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -44,7 +44,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.31 2001/05/27 13:53:24 sommerfeld Exp $");
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.32 2003/02/05 12:16:41 nakayama Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@ -223,8 +223,8 @@ inittodr(base)
#ifdef DEBUG
printf("=>%ld (%d)\n", time.tv_sec, base);
#endif
microset_time = time;
microset(curcpu(), NULL);
cc_microset_time = time;
cc_microset(curcpu());
if (!badbase) {
/*
@ -260,11 +260,11 @@ resettodr()
if (!clockinitted)
return;
microset_time = time;
cc_microset_time = time;
#if defined(MULTIPROCESSOR)
alpha_multicast_ipi(cpus_running, ALPHA_IPI_MICROSET);
#endif
microset(curcpu(), NULL);
cc_microset(curcpu());
clock_secs_to_ymdhms(time.tv_sec, &dt);

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpu.c,v 1.69 2003/01/17 22:11:17 thorpej Exp $ */
/* $NetBSD: cpu.c,v 1.70 2003/02/05 12:16:41 nakayama Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@ -66,7 +66,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.69 2003/01/17 22:11:17 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.70 2003/02/05 12:16:41 nakayama Exp $");
#include "opt_ddb.h"
#include "opt_multiprocessor.h"
@ -598,7 +598,7 @@ cpu_hatch(struct cpu_info *ci)
ALPHA_TBIA();
alpha_pal_imb();
microset(ci, NULL);
cc_microset(ci);
/* Initialize our base "runtime". */
microtime(&ci->ci_schedstate.spc_runtime);

View File

@ -1,4 +1,4 @@
/* $NetBSD: interrupt.c,v 1.65 2003/01/17 22:11:17 thorpej Exp $ */
/* $NetBSD: interrupt.c,v 1.66 2003/02/05 12:16:42 nakayama Exp $ */
/*-
* Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@ -72,7 +72,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: interrupt.c,v 1.65 2003/01/17 22:11:17 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: interrupt.c,v 1.66 2003/02/05 12:16:42 nakayama Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -206,7 +206,7 @@ void
interrupt(unsigned long a0, unsigned long a1, unsigned long a2,
struct trapframe *framep)
{
static int microset_iter; /* call microset() once per sec. */
static int microset_iter; /* call cc_microset() once per sec. */
struct cpu_info *ci = curcpu();
struct cpu_softc *sc = ci->ci_softc;
struct lwp *l;
@ -250,13 +250,13 @@ interrupt(unsigned long a0, unsigned long a1, unsigned long a2,
#endif
microset_iter-- == 0) {
microset_iter = hz-1;
microset_time = time;
microset_iter = hz - 1;
cc_microset_time = time;
#if defined(MULTIPROCESSOR)
alpha_multicast_ipi(cpus_running,
ALPHA_IPI_MICROSET);
#endif
microset(ci, framep);
cc_microset(ci);
}
if (platform.clockintr) {
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: ipifuncs.c,v 1.32 2003/01/17 22:11:17 thorpej Exp $ */
/* $NetBSD: ipifuncs.c,v 1.33 2003/02/05 12:16:42 nakayama Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@ -39,7 +39,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: ipifuncs.c,v 1.32 2003/01/17 22:11:17 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: ipifuncs.c,v 1.33 2003/02/05 12:16:42 nakayama Exp $");
/*
* Interprocessor interrupt handlers.
@ -65,6 +65,7 @@ __KERNEL_RCSID(0, "$NetBSD: ipifuncs.c,v 1.32 2003/01/17 22:11:17 thorpej Exp $"
typedef void (*ipifunc_t)(struct cpu_info *, struct trapframe *);
void alpha_ipi_halt(struct cpu_info *, struct trapframe *);
void alpha_ipi_microset(struct cpu_info *, struct trapframe *);
void alpha_ipi_imb(struct cpu_info *, struct trapframe *);
void alpha_ipi_ast(struct cpu_info *, struct trapframe *);
void alpha_ipi_synch_fpu(struct cpu_info *, struct trapframe *);
@ -77,7 +78,7 @@ void alpha_ipi_pause(struct cpu_info *, struct trapframe *);
*/
ipifunc_t ipifuncs[ALPHA_NIPIS] = {
alpha_ipi_halt,
microset,
alpha_ipi_microset,
pmap_do_tlb_shootdown,
alpha_ipi_imb,
alpha_ipi_ast,
@ -252,6 +253,13 @@ alpha_ipi_halt(struct cpu_info *ci, struct trapframe *framep)
/* NOTREACHED */
}
void
alpha_ipi_microset(struct cpu_info *ci, struct trapframe *framep)
{
cc_microset(ci);
}
void
alpha_ipi_imb(struct cpu_info *ci, struct trapframe *framep)
{

View File

@ -1,4 +1,4 @@
# $NetBSD: files.alpha,v 1.160 2003/01/13 20:55:14 bouyer Exp $
# $NetBSD: files.alpha,v 1.161 2003/02/05 12:16:42 nakayama Exp $
#
# alpha-specific configuration info
@ -476,7 +476,7 @@ file arch/alpha/alpha/ipifuncs.c multiprocessor
file arch/alpha/alpha/machdep.c
file arch/alpha/alpha/mainbus.c
file arch/alpha/alpha/mem.c
file arch/alpha/alpha/microtime.c
file kern/kern_microtime.c
file arch/alpha/alpha/pmap.c
file arch/alpha/alpha/process_machdep.c
file arch/alpha/alpha/procfs_machdep.c procfs

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpu.h,v 1.59 2003/01/17 22:11:16 thorpej Exp $ */
/* $NetBSD: cpu.h,v 1.60 2003/02/05 12:16:43 nakayama Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@ -132,12 +132,12 @@ struct cpu_info {
struct trapframe *ci_db_regs; /* registers for debuggers */
/*
* Variables used by microtime().
* Variables used by cc_microtime().
*/
struct timeval ci_pcc_time;
long ci_pcc_pcc;
long ci_pcc_ms_delta;
long ci_pcc_denom;
struct timeval ci_cc_time;
long ci_cc_cc;
long ci_cc_ms_delta;
long ci_cc_denom;
#if defined(MULTIPROCESSOR)
__volatile u_long ci_flags; /* flags; see below */
@ -281,10 +281,12 @@ struct reg;
struct rpb;
struct trapframe;
extern struct timeval microset_time;
extern struct timeval cc_microset_time;
int badaddr(void *, size_t);
void microset(struct cpu_info *, struct trapframe *);
#define microtime(tv) cc_microtime(tv)
void cc_microtime __P((struct timeval *));
void cc_microset(struct cpu_info *);
#endif /* _KERNEL */
#endif /* _ALPHA_CPU_H_ */

View File

@ -0,0 +1,76 @@
/* $NetBSD: cpu_counter.h,v 1.1 2003/02/05 12:16:43 nakayama Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* 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 _ALPHA_CPU_COUNTER_H_
#define _ALPHA_CPU_COUNTER_H_
/*
* Machine-specific support for CPU counter.
*/
#ifdef _KERNEL
#include <machine/cpu.h>
#include <machine/rpb.h>
/* Process Cycle Counter is always available. */
#define cpu_hascounter() (1)
#define cpu_counter() cpu_counter32()
static __inline uint32_t
cpu_counter32(void)
{
/*
* Only the lower 32 bits of the PCC are an actual cycle
* counter. Thankfully, the rnd(4) code only wants a
* 32-bit value anyway.
*/
return (alpha_rpcc() & 0xffffffffU);
}
static __inline uint64_t
cpu_frequency(struct cpu_info *ci)
{
return (hwrpb->rpb_cc_freq);
}
#endif /* _KERNEL */
#endif /* !_ALPHA_CPU_COUNTER_H_ */