Switch ews4800mips to a MIPS3 cp0 based timecounter. From gdamore

on port-ews4800mips.

XXX: ews4800mips can't use mips/mips/mips3_clock.c for now because
     it isn't configured to use internal clock interrupt for CPU INT 5,
     i.e. mips3_clockintr() is not needed and its own cpu_initclocks(9)
     is required.
This commit is contained in:
tsutsui 2006-09-08 13:48:11 +00:00
parent a0a2046917
commit 4e1adf90bc
5 changed files with 29 additions and 85 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: clock.c,v 1.3 2006/09/04 20:31:30 tsutsui Exp $ */
/* $NetBSD: clock.c,v 1.4 2006/09/08 13:48:11 tsutsui Exp $ */
/*-
* Copyright (c) 2001, 2004, 2005 The NetBSD Foundation, Inc.
@ -34,16 +34,19 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.3 2006/09/04 20:31:30 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.4 2006/09/08 13:48:11 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h> /* time */
#include <sys/timetc.h>
#include <mips/locore.h> /* mips3_cp0_count_read */
#include <machine/sbdvar.h>
static void init_mips3_tc(void);
void
cpu_initclocks(void)
{
@ -51,6 +54,8 @@ cpu_initclocks(void)
KASSERT(platform.initclocks);
(*platform.initclocks)();
init_mips3_tc();
}
void
@ -60,33 +65,26 @@ setstatclockrate(int arg)
/* not yet */
}
/*
* Return the best possible estimate of the time in the timeval to
* which tv points.
*/
void
microtime(struct timeval *tvp)
init_mips3_tc(void)
{
int s = splclock();
static struct timeval lasttime;
#if !defined(MULTIPROCESSOR)
static struct timecounter tc = {
(timecounter_get_t *)mips3_cp0_count_read, /* get_timecount */
0, /* no poll_pps */
~0u, /* counter_mask */
0, /* frequency */
"mips3_cp0_counter", /* name */
100, /* quality */
};
*tvp = time;
if (platform.readclock)
tvp->tv_usec += (*platform.readclock)();
while (tvp->tv_usec >= 1000000) {
tvp->tv_sec++;
tvp->tv_usec -= 1000000;
tc.tc_frequency = curcpu()->ci_cpu_freq;
if (mips_cpu_flags & CPU_MIPS_DOUBLE_COUNT) {
tc.tc_frequency /= 2;
}
if (tvp->tv_sec == lasttime.tv_sec &&
tvp->tv_usec <= lasttime.tv_usec &&
(tvp->tv_usec = lasttime.tv_usec + 1) >= 1000000) {
tvp->tv_sec++;
tvp->tv_usec -= 1000000;
}
lasttime = *tvp;
splx(s);
tc_init(&tc);
#endif
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: tr2_intr.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
/* $NetBSD: tr2_intr.c,v 1.2 2006/09/08 13:48:11 tsutsui Exp $ */
/*-
* Copyright (c) 2004, 2005 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tr2_intr.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: tr2_intr.c,v 1.2 2006/09/08 13:48:11 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -310,32 +310,6 @@ tr2_initclocks(void)
last_clock_intr = mips3_cp0_count_read();
/* number of microseconds between interrupts */
tick = 1000000 / hz;
tickfix = 1000000 - (hz * tick);
#ifdef NTP
fixtick = tickfix;
#endif
if (tickfix) {
int ftp;
ftp = min(ffs(tickfix), ffs(hz));
tickfix >>= ftp - 1;
tickfixinterval = hz >> (ftp - 1);
}
/* Enable clock interrupt */
*PICNIC_INT5_MASK_REG |= PICNIC_INT_CLOCK;
}
u_long
tr2_readclock(void)
{
uint32_t res, count;
/* 32bit wrap-around during subtruction ok here. */
count = mips3_cp0_count_read() - last_clock_intr;
MIPS_COUNT_TO_MHZ(curcpu(), count, res);
return res;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: tr2a_intr.c,v 1.2 2006/06/10 12:42:37 tsutsui Exp $ */
/* $NetBSD: tr2a_intr.c,v 1.3 2006/09/08 13:48:12 tsutsui Exp $ */
/*-
* Copyright (c) 2004, 2005 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tr2a_intr.c,v 1.2 2006/06/10 12:42:37 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: tr2a_intr.c,v 1.3 2006/09/08 13:48:12 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -363,33 +363,7 @@ tr2a_initclocks(void)
last_clock_intr = mips3_cp0_count_read();
/* number of microseconds between interrupts */
tick = 1000000 / hz;
tickfix = 1000000 - (hz * tick);
#ifdef NTP
fixtick = tickfix;
#endif
if (tickfix) {
int ftp;
ftp = min(ffs(tickfix), ffs(hz));
tickfix >>= ftp - 1;
tickfixinterval = hz >> (ftp - 1);
}
/* Enable INT5 */
*INTC_MASK_REG |= INTC_INT5;
tr2a_wbflush();
}
u_long
tr2a_readclock(void)
{
uint32_t res, count;
/* 32bit wrap-around during subtruction ok here. */
count = mips3_cp0_count_read() - last_clock_intr;
MIPS_COUNT_TO_MHZ(curcpu(), count, res);
return res;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: sbdvar.h,v 1.1 2005/12/29 15:20:09 tsutsui Exp $ */
/* $NetBSD: sbdvar.h,v 1.2 2006/09/08 13:48:12 tsutsui Exp $ */
/*-
* Copyright (c) 2004, 2005 The NetBSD Foundation, Inc.
@ -79,7 +79,6 @@ struct sbd {
/* Interval timer helper routines */
void (*initclocks)(void);
u_long (*readclock)(void);
/* Miscellaneous */
void (*consinit)(void);
@ -98,7 +97,6 @@ void * x ## _intr_establish(int, int (*)(void *), void *); \
void x ## _intr_disestablish(void *); \
void x ## _intr(uint32_t, uint32_t, uint32_t, uint32_t); \
void x ## _initclocks(void); \
u_long x ## _readclock(void); \
void x ## _consinit(void); \
int x ## _ipl_bootdev(void); \
void x ## _reboot(void); \
@ -117,7 +115,6 @@ extern const uint32_t x ## _sr_bits[]
_SBD_OPS_SET(m, intr_disestablish); \
_SBD_OPS_SET(m, intr); \
_SBD_OPS_SET(m, initclocks); \
_SBD_OPS_SET(m, readclock); \
_SBD_OPS_SET(m, consinit); \
_SBD_OPS_SET(m, ipl_bootdev); \
_SBD_OPS_SET(m, reboot); \

View File

@ -1,9 +1,10 @@
/* $NetBSD: types.h,v 1.3 2006/09/04 20:31:30 tsutsui Exp $ */
/* $NetBSD: types.h,v 1.4 2006/09/08 13:48:12 tsutsui Exp $ */
#include <mips/types.h>
#define __HAVE_GENERIC_SOFT_INTERRUPTS
#define __HAVE_GENERIC_TODR
#define __HAVE_TIMECOUNTER
/* MIPS specific options */
#define __HAVE_MIPS_MACHDEP_CACHE_CONFIG