Use mips3_cp0_count_read() for precise microtime(9).

XXX microtime(9) function should be moved from machdep.c to timer.c?
This commit is contained in:
tsutsui 2005-10-30 05:27:14 +00:00
parent 2f451ddebd
commit bc7a643d4f
6 changed files with 35 additions and 15 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: c_magnum.c,v 1.10 2005/08/20 17:58:49 tsutsui Exp $ */
/* $NetBSD: c_magnum.c,v 1.11 2005/10/30 05:27:14 tsutsui Exp $ */
/* $OpenBSD: machdep.c,v 1.36 1999/05/22 21:22:19 weingart Exp $ */
/*
@ -80,7 +80,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: c_magnum.c,v 1.10 2005/08/20 17:58:49 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: c_magnum.c,v 1.11 2005/10/30 05:27:14 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -91,10 +91,12 @@ __KERNEL_RCSID(0, "$NetBSD: c_magnum.c,v 1.10 2005/08/20 17:58:49 tsutsui Exp $"
#include <machine/bus.h>
#include <machine/pio.h>
#include <machine/platform.h>
#include <mips/locore.h>
#include <mips/pte.h>
#include <dev/isa/isavar.h>
#include <arc/arc/timervar.h>
#include <arc/arc/wired_map.h>
#include <arc/jazz/pica.h>
#include <arc/jazz/jazziovar.h>
@ -168,6 +170,7 @@ timer_magnum_intr(uint32_t mask, struct clockframe *cf)
int temp;
temp = inw(R4030_SYS_IT_STAT);
last_cp0_count = mips3_cp0_count_read();
hardclock(cf);
timer_jazzio_ev.ev_count++;

View File

@ -1,4 +1,4 @@
/* $NetBSD: c_nec_jazz.c,v 1.9 2005/08/20 17:58:49 tsutsui Exp $ */
/* $NetBSD: c_nec_jazz.c,v 1.10 2005/10/30 05:27:14 tsutsui Exp $ */
/*-
* Copyright (C) 2000 Shuichiro URATA. All rights reserved.
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: c_nec_jazz.c,v 1.9 2005/08/20 17:58:49 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: c_nec_jazz.c,v 1.10 2005/10/30 05:27:14 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -43,6 +43,7 @@ __KERNEL_RCSID(0, "$NetBSD: c_nec_jazz.c,v 1.9 2005/08/20 17:58:49 tsutsui Exp $
#include <dev/isa/isavar.h>
#include <arc/arc/timervar.h>
#include <arc/jazz/rd94.h>
#include <arc/jazz/jazziovar.h>
#include <arc/jazz/timer_jazziovar.h>
@ -67,6 +68,7 @@ timer_nec_jazz_intr(uint32_t mask, struct clockframe *cf)
int temp;
temp = in32(RD94_SYS_INTSTAT3);
last_cp0_count = mips3_cp0_count_read();
hardclock(cf);
timer_jazzio_ev.ev_count++;

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.90 2005/10/30 04:31:22 tsutsui Exp $ */
/* $NetBSD: machdep.c,v 1.91 2005/10/30 05:27:14 tsutsui Exp $ */
/* $OpenBSD: machdep.c,v 1.36 1999/05/22 21:22:19 weingart Exp $ */
/*
@ -78,7 +78,7 @@
/* from: Utah Hdr: machdep.c 1.63 91/04/24 */
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.90 2005/10/30 04:31:22 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.91 2005/10/30 05:27:14 tsutsui Exp $");
#include "fs_mfs.h"
#include "opt_ddb.h"
@ -137,6 +137,7 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.90 2005/10/30 04:31:22 tsutsui Exp $")
#include <dev/isa/isareg.h>
#include <arc/arc/arcbios.h>
#include <arc/arc/timervar.h>
#include <arc/arc/wired_map.h>
#include "ksyms.h"
@ -655,17 +656,23 @@ arc_sysreset(bus_addr_t addr, bus_size_t cmd_offset)
void
microtime(struct timeval *tvp)
{
int s = splclock();
int s;
static struct timeval lasttime;
uint32_t count, res;
s = splclock();
*tvp = time;
#ifdef notdef
tvp->tv_usec += clkread();
/* 32bit wrap-around during subtraction ok here. */
count = mips3_cp0_count_read() - last_cp0_count;
MIPS_COUNT_TO_MHZ(curcpu(), count, res);
tvp->tv_usec += res;
while (tvp->tv_usec >= 1000000) {
tvp->tv_sec++;
tvp->tv_usec -= 1000000;
}
#endif
if (tvp->tv_sec == lasttime.tv_sec &&
tvp->tv_usec <= lasttime.tv_usec &&
(tvp->tv_usec = lasttime.tv_usec + 1) >= 1000000) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: timer.c,v 1.4 2005/10/30 04:34:03 tsutsui Exp $ */
/* $NetBSD: timer.c,v 1.5 2005/10/30 05:27:14 tsutsui Exp $ */
/* NetBSD: clock.c,v 1.31 2001/05/27 13:53:24 sommerfeld Exp */
/*
@ -79,7 +79,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: timer.c,v 1.4 2005/10/30 04:34:03 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: timer.c,v 1.5 2005/10/30 05:27:14 tsutsui Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@ -92,6 +92,7 @@ __KERNEL_RCSID(0, "$NetBSD: timer.c,v 1.4 2005/10/30 04:34:03 tsutsui Exp $");
struct device *timerdev;
const struct timerfns *timerfns;
int timerinitted;
uint32_t last_cp0_count;
void
timerattach(struct device *dev, const struct timerfns *fns)

View File

@ -1,4 +1,4 @@
/* $NetBSD: timervar.h,v 1.2 2005/01/22 07:35:33 tsutsui Exp $ */
/* $NetBSD: timervar.h,v 1.3 2005/10/30 05:27:14 tsutsui Exp $ */
/* NetBSD: clockvar.h,v 1.4 1997/06/22 08:02:18 jonathan Exp */
/*
@ -38,4 +38,6 @@ struct timerfns {
void (*tf_init)(struct device *);
};
extern uint32_t last_cp0_count;
void timerattach(struct device *, const struct timerfns *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: isabus.c,v 1.28 2005/01/22 08:43:02 tsutsui Exp $ */
/* $NetBSD: isabus.c,v 1.29 2005/10/30 05:27:14 tsutsui Exp $ */
/* $OpenBSD: isabus.c,v 1.15 1998/03/16 09:38:46 pefo Exp $ */
/* NetBSD: isa.c,v 1.33 1995/06/28 04:30:51 cgd Exp */
@ -120,7 +120,7 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: isabus.c,v 1.28 2005/01/22 08:43:02 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: isabus.c,v 1.29 2005/10/30 05:27:14 tsutsui Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@ -140,12 +140,16 @@ __KERNEL_RCSID(0, "$NetBSD: isabus.c,v 1.28 2005/01/22 08:43:02 tsutsui Exp $");
#include <machine/autoconf.h>
#include <machine/intr.h>
#include <mips/locore.h>
#include <dev/ic/i8253reg.h>
#include <dev/isa/isareg.h>
#include <dev/isa/isavar.h>
#include <arc/isa/isabrvar.h>
#include <arc/isa/spkrreg.h>
#include <arc/arc/timervar.h>
static int beeping;
static struct callout sysbeep_ch = CALLOUT_INITIALIZER;
@ -430,6 +434,7 @@ isabr_iointr(uint32_t mask, struct clockframe *cf)
}
ih = intrhand[isa_vector];
if (isa_vector == 0) { /* Clock */ /*XXX*/
last_cp0_count = mips3_cp0_count_read();
(*ih->ih_fun)(cf);
ih = ih->ih_next;
}