Make microtime(9) do interpolation to get better-than-hz resolution, if
the platform supplies a clkread function that does something other than return 0 (which is the default unless overridden by the platorm code). Supply such a function for the IP22; even if it isn't perfect, it goes a long way to making ntp usable. While I'm at it, move the ticks-per-hz variable out of the struct platform since it's really private to the per-platform interrupt/clock code. XXX: No clkread function supplied for IP32, since it has other problems -- like a hardcoded ticks-per-hz, but the same code as on the IP22 could be used.
This commit is contained in:
parent
b75edaf367
commit
1a9f819d84
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: sysconf.h,v 1.2 2001/06/14 01:06:08 rafal Exp $ */
|
||||
/* $NetBSD: sysconf.h,v 1.3 2001/11/11 17:21:40 rafal Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
|
||||
@ -54,11 +54,6 @@
|
||||
*/
|
||||
|
||||
struct platform {
|
||||
/*
|
||||
* Platform specific data
|
||||
* ticks_per_hz - ticks per HZ
|
||||
*/
|
||||
unsigned long ticks_per_hz;
|
||||
/*
|
||||
* Platform Specific Function Hooks
|
||||
* bus_reset - clear memory error condition
|
||||
@ -73,7 +68,7 @@ struct platform {
|
||||
void (*cons_init)(void);
|
||||
void (*iointr)(unsigned, unsigned, unsigned, unsigned);
|
||||
void (*intr_establish)(int , int, int (*)(void *), void *);
|
||||
unsigned (*clkread) __P((void));
|
||||
unsigned long (*clkread) __P((void));
|
||||
};
|
||||
|
||||
extern struct platform platform;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ip22.c,v 1.5 2001/06/14 01:15:35 rafal Exp $ */
|
||||
/* $NetBSD: ip22.c,v 1.6 2001/11/11 17:21:41 rafal Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 Rafal K. Boni
|
||||
@ -47,6 +47,11 @@ static struct evcnt mips_int5_evcnt =
|
||||
static u_int32_t iocwrite; /* IOC write register: read-only */
|
||||
static u_int32_t iocreset; /* IOC reset register: read-only */
|
||||
|
||||
static unsigned long last_clk_intr;
|
||||
|
||||
static unsigned long ticks_per_hz;
|
||||
static unsigned long ticks_per_usec;
|
||||
|
||||
|
||||
void ip22_init(void);
|
||||
void ip22_bus_reset(void);
|
||||
@ -55,6 +60,8 @@ int ip22_local1_intr(void);
|
||||
int ip22_mappable_intr(void *);
|
||||
void ip22_intr(u_int, u_int, u_int, u_int);
|
||||
void ip22_intr_establish(int, int, int (*)(void *), void *);
|
||||
|
||||
unsigned long ip22_clkread(void);
|
||||
unsigned long ip22_cal_timer(u_int32_t, u_int32_t);
|
||||
|
||||
void
|
||||
@ -159,7 +166,10 @@ ip22_init(void)
|
||||
printf("CPU clock speed = %lu.%02luMhz\n", cps / (1000000 / hz),
|
||||
(cps % (1000000 / hz) / 100));
|
||||
|
||||
platform.ticks_per_hz = cps;
|
||||
platform.clkread = ip22_clkread;
|
||||
|
||||
ticks_per_hz = cps;
|
||||
ticks_per_usec = cps * hz / 1000000;
|
||||
|
||||
evcnt_attach_static(&mips_int5_evcnt);
|
||||
}
|
||||
@ -178,15 +188,14 @@ ip22_intr(status, cause, pc, ipending)
|
||||
u_int32_t pc;
|
||||
u_int32_t ipending;
|
||||
{
|
||||
unsigned long cycles;
|
||||
struct clockframe cf;
|
||||
|
||||
/* Tickle Indy/I2 MC watchdog timer */
|
||||
*(volatile u_int32_t *)MIPS_PHYS_TO_KSEG1(0x1fa00014) = 0;
|
||||
|
||||
if (ipending & MIPS_INT_MASK_5) {
|
||||
cycles = mips3_cp0_count_read();
|
||||
mips3_cp0_compare_write(cycles + platform.ticks_per_hz);
|
||||
last_clk_intr = mips3_cp0_count_read();
|
||||
mips3_cp0_compare_write(last_clk_intr + ticks_per_hz);
|
||||
|
||||
cf.pc = pc;
|
||||
cf.sr = status;
|
||||
@ -374,6 +383,15 @@ ip22_intr_establish(level, ipl, handler, arg)
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long
|
||||
ip22_clkread(void)
|
||||
{
|
||||
unsigned long diff = mips3_cp0_count_read();
|
||||
|
||||
diff -= last_clk_intr;
|
||||
return (diff / ticks_per_usec);
|
||||
}
|
||||
|
||||
unsigned long
|
||||
ip22_cal_timer(u_int32_t tctrl, u_int32_t tcount)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ip32.c,v 1.5 2001/06/14 01:09:37 rafal Exp $ */
|
||||
/* $NetBSD: ip32.c,v 1.6 2001/11/11 17:21:41 rafal Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000 Soren S. Jorvang
|
||||
@ -55,12 +55,16 @@ void *crime_intr_establish(int, int, int, int (*)(void *), void *);
|
||||
static struct evcnt mips_int5_evcnt =
|
||||
EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "mips", "int 5 (clock)");
|
||||
|
||||
static unsigned long ticks_per_hz;
|
||||
|
||||
void ip32_init(void)
|
||||
{
|
||||
/* XXXrkb: enable watchdog timer, clear it */
|
||||
*(volatile u_int32_t *)0xb400000c |= 0x200;
|
||||
*(volatile u_int32_t *)0xb4000034 = 0;
|
||||
|
||||
ticks_per_hz = 1000000;
|
||||
|
||||
platform.iointr = ip32_intr;
|
||||
platform.bus_reset = ip32_bus_reset;
|
||||
platform.intr_establish = ip32_intr_establish;
|
||||
@ -118,7 +122,7 @@ panic("pcierr: %x %x", *(volatile u_int32_t *)0xbf080004,
|
||||
|
||||
if (ipending & MIPS_INT_MASK_5) {
|
||||
cycles = mips3_cp0_count_read();
|
||||
mips3_cp0_compare_write(cycles + platform.ticks_per_hz);
|
||||
mips3_cp0_compare_write(cycles + ticks_per_hz);
|
||||
|
||||
cf.pc = pc;
|
||||
cf.sr = status;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: machdep.c,v 1.28 2001/10/18 02:36:33 mhitch Exp $ */
|
||||
/* $NetBSD: machdep.c,v 1.29 2001/11/11 17:21:41 rafal Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000 Soren S. Jorvang
|
||||
@ -151,12 +151,11 @@ static void unimpl_bus_reset(void);
|
||||
static void unimpl_cons_init(void);
|
||||
static void unimpl_iointr(unsigned, unsigned, unsigned, unsigned);
|
||||
static void unimpl_intr_establish(int, int, int (*)(void *), void *);
|
||||
static unsigned nullwork(void);
|
||||
static unsigned long nullwork(void);
|
||||
|
||||
void ddb_trap_hook(int where);
|
||||
|
||||
struct platform platform = {
|
||||
1000000,
|
||||
unimpl_bus_reset,
|
||||
unimpl_cons_init,
|
||||
unimpl_iointr,
|
||||
@ -656,6 +655,7 @@ microtime(tvp)
|
||||
static struct timeval lasttime;
|
||||
|
||||
*tvp = time;
|
||||
tvp->tv_usec += (*platform.clkread)();
|
||||
|
||||
/*
|
||||
* Make sure that the time returned is always greater
|
||||
@ -718,7 +718,7 @@ unimpl_intr_establish(level, ipl, handler, arg)
|
||||
panic("target init didn't set intr_establish");
|
||||
}
|
||||
|
||||
static unsigned
|
||||
static unsigned long
|
||||
nullwork()
|
||||
{
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user