Module Name: src
Committed By: tsutsui
Date: Tue Jul 7 15:15:09 UTC 2009
Modified Files:
src/sys/arch/atari/dev: clock.c
Log Message:
Add a workaround for annoying
"WARNING: negative runtime; monotonic clock has gone backwards"
message. Partially taken from hp300.
To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/atari/dev/clock.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/atari/dev/clock.c
diff -u src/sys/arch/atari/dev/clock.c:1.46 src/sys/arch/atari/dev/clock.c:1.47
--- src/sys/arch/atari/dev/clock.c:1.46 Wed Mar 18 10:22:24 2009
+++ src/sys/arch/atari/dev/clock.c Tue Jul 7 15:15:08 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: clock.c,v 1.46 2009/03/18 10:22:24 cegger Exp $ */
+/* $NetBSD: clock.c,v 1.47 2009/07/07 15:15:08 tsutsui Exp $ */
/*
* Copyright (c) 1982, 1990 The Regents of the University of California.
@@ -77,7 +77,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.46 2009/03/18 10:22:24 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.47 2009/07/07 15:15:08 tsutsui Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -314,21 +314,29 @@
static u_int
clk_getcounter(struct timecounter *tc)
{
- u_int delta;
- u_char ipra, tadr;
- int s, cur_hardclock;
+ uint32_t delta, count, cur_hardclock;
+ uint8_t ipra, tadr;
+ int s;
+ static uint32_t lastcount;
s = splhigh();
+ cur_hardclock = hardclock_ticks;
ipra = MFP->mf_ipra;
tadr = MFP->mf_tadr;
delta = divisor - tadr;
if (ipra & IA_TIMA)
delta += divisor;
- cur_hardclock = hardclock_ticks;
splx(s);
- return (divisor - tadr) + divisor * cur_hardclock;
+ count = (divisor * cur_hardclock) + delta;
+ if ((int32_t)(count - lastcount) < 0) {
+ /* XXX wrapped; maybe hardclock() is blocked more than 2/HZ */
+ count = lastcount + 1;
+ }
+ lastcount = count;
+
+ return count;
}
#define TIMB_FREQ 614400