sgimips converted to timecounters. Systems that can do them get mips_cp0

based logic.  We also use the common mips3_clock functions for those systems,
removing some port-specific code.

Tested by martin@.
This commit is contained in:
gdamore 2006-09-16 08:50:27 +00:00
parent c76c4d01d3
commit 5a87ca8ef8
4 changed files with 12 additions and 89 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: files.sgimips,v 1.40 2005/12/11 12:18:52 christos Exp $
# $NetBSD: files.sgimips,v 1.41 2006/09/16 08:50:27 gdamore Exp $
maxpartitions 16
@ -27,6 +27,8 @@ file arch/sgimips/sgimips/disksubr.c
file arch/sgimips/sgimips/machdep.c
file arch/mips/mips/softintr.c
file arch/mips/mips/mips3_clock.c mips3
file arch/mips/mips/mips3_clockintr.c mips3
file dev/md_root.c memory_disk_hooks

View File

@ -1,10 +1,11 @@
/* $NetBSD: types.h,v 1.10 2006/09/05 01:38:59 rumble Exp $ */
/* $NetBSD: types.h,v 1.11 2006/09/16 08:50:27 gdamore Exp $ */
#include <mips/types.h>
#define __HAVE_DEVICE_REGISTER
#define __HAVE_GENERIC_SOFT_INTERRUPTS
#define __HAVE_GENERIC_TODR
#define __HAVE_TIMECOUNTER
/* MIPS specific options */
#define __HAVE_BOOTINFO_H

View File

@ -1,4 +1,4 @@
/* $NetBSD: clock.c,v 1.17 2006/09/05 01:38:59 rumble Exp $ */
/* $NetBSD: clock.c,v 1.18 2006/09/16 08:50:27 gdamore Exp $ */
/*
* Copyright (c) 1992, 1993
@ -79,7 +79,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.17 2006/09/05 01:38:59 rumble Exp $");
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.18 2006/09/16 08:50:27 gdamore Exp $");
#include <sys/param.h>
#include <sys/device.h>
@ -88,6 +88,7 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.17 2006/09/05 01:38:59 rumble Exp $");
#include <machine/sysconf.h>
#include <mips/locore.h>
#include <mips/mips3_clock.h>
#include <dev/clock_subr.h>
#include <dev/ic/i8253reg.h>
@ -96,12 +97,9 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.17 2006/09/05 01:38:59 rumble Exp $");
u_int32_t next_clk_intr;
u_int32_t missed_clk_intrs;
unsigned long last_clk_intr;
void mips1_clock_intr(u_int32_t, u_int32_t, u_int32_t, u_int32_t);
void mips3_clock_intr(u_int32_t, u_int32_t, u_int32_t, u_int32_t);
unsigned long mips1_clkread(void);
unsigned long mips3_clkread(void);
/*
* Machine-dependent clock routines.
@ -129,20 +127,7 @@ cpu_initclocks()
#if defined(MIPS3)
if (mach_type != MACH_SGI_IP12) {
next_clk_intr = mips3_cp0_count_read()
+ curcpu()->ci_cycles_per_hz;
mips3_cp0_compare_write(next_clk_intr);
/* number of microseconds between interrupts */
tick = 1000000 / hz;
tickfix = 1000000 - (hz * tick);
if (tickfix) {
int ftp;
ftp = min(ffs(tickfix), ffs(hz));
tickfix >>= (ftp - 1);
tickfixinterval = hz >> (ftp - 1);
}
mips3_initclocks();
}
#endif /* MIPS3 */
}
@ -166,51 +151,16 @@ mips1_clock_intr(u_int32_t status, u_int32_t cause, u_int32_t pc,
}
}
unsigned long
mips1_clkread()
{
return 0;
}
#if defined(MIPS3)
void
mips3_clock_intr(u_int32_t status, u_int32_t cause, u_int32_t pc,
u_int32_t ipending)
{
u_int32_t newcnt;
struct clockframe cf;
last_clk_intr = mips3_cp0_count_read();
next_clk_intr += curcpu()->ci_cycles_per_hz;
mips3_cp0_compare_write(next_clk_intr);
newcnt = mips3_cp0_count_read();
/*
* Missed one or more clock interrupts, so let's start
* counting again from the current value.
*/
if ((next_clk_intr - newcnt) & 0x80000000) {
missed_clk_intrs++;
next_clk_intr = newcnt + curcpu()->ci_cycles_per_hz;
mips3_cp0_compare_write(next_clk_intr);
}
cf.pc = pc;
cf.sr = status;
hardclock(&cf);
mips3_clockintr(&cf);
}
unsigned long
mips3_clkread()
{
uint32_t res, count;
count = mips3_cp0_count_read() - last_clk_intr;
MIPS_COUNT_TO_MHZ(curcpu(), count, res);
return (res);
}
#endif /* MIPS3 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.97 2006/09/01 05:43:23 sekiya Exp $ */
/* $NetBSD: machdep.c,v 1.98 2006/09/16 08:50:27 gdamore Exp $ */
/*
* Copyright (c) 2000 Soren S. Jorvang
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.97 2006/09/01 05:43:23 sekiya Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.98 2006/09/16 08:50:27 gdamore Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@ -142,12 +142,10 @@ extern void ip22_sdcache_enable(void);
#if defined(MIPS1)
extern void mips1_clock_intr(u_int32_t, u_int32_t, u_int32_t, u_int32_t);
extern unsigned long mips1_clkread(void);
#endif
#if defined(MIPS3)
extern void mips3_clock_intr(u_int32_t, u_int32_t, u_int32_t, u_int32_t);
extern unsigned long mips3_clkread(void);
#endif
void mach_init(int, char **, int, struct btinfo_common *);
@ -415,7 +413,6 @@ mach_init(int argc, char **argv, int magic, struct btinfo_common *btinfo)
splmasks[IPL_TTY] = 0x1b00;
splmasks[IPL_CLOCK] = 0x7f00;
platform.intr3 = mips1_clock_intr;
platform.clkread = mips1_clkread;
break;
#endif /* MIPS1 */
@ -429,7 +426,6 @@ mach_init(int argc, char **argv, int magic, struct btinfo_common *btinfo)
splmasks[IPL_TTY] = 0x0f00;
splmasks[IPL_CLOCK] = 0xbf00;
platform.intr5 = mips3_clock_intr;
platform.clkread = mips3_clkread;
break;
case MACH_SGI_IP22:
splmasks[IPL_BIO] = 0x0700;
@ -437,7 +433,6 @@ mach_init(int argc, char **argv, int magic, struct btinfo_common *btinfo)
splmasks[IPL_TTY] = 0x0f00;
splmasks[IPL_CLOCK] = 0xbf00;
platform.intr5 = mips3_clock_intr;
platform.clkread = mips3_clkread;
break;
case MACH_SGI_IP30:
splmasks[IPL_BIO] = 0x0700;
@ -445,7 +440,6 @@ mach_init(int argc, char **argv, int magic, struct btinfo_common *btinfo)
splmasks[IPL_TTY] = 0x0700;
splmasks[IPL_CLOCK] = 0x8700;
platform.intr5 = mips3_clock_intr;
platform.clkread = mips3_clkread;
break;
case MACH_SGI_IP32:
splmasks[IPL_BIO] = 0x0700;
@ -453,7 +447,6 @@ mach_init(int argc, char **argv, int magic, struct btinfo_common *btinfo)
splmasks[IPL_TTY] = 0x0700;
splmasks[IPL_CLOCK] = 0x8700;
platform.intr5 = mips3_clock_intr;
platform.clkread = mips3_clkread;
break;
#endif /* MIPS3 */
default:
@ -731,29 +724,6 @@ haltsys:
for (;;);
}
void
microtime(struct timeval *tvp)
{
int s = splclock();
static struct timeval lasttime;
*tvp = time;
tvp->tv_usec += (*platform.clkread)();
/*
* Make sure that the time returned is always greater
* than that returned by the previous call.
*/
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);
}
void delay(unsigned long n)
{
register int __N = curcpu()->ci_divisor_delay * n;