Module Name:    src
Committed By:   snj
Date:           Sun Oct  4 00:31:52 UTC 2009

Modified Files:
        src/sys/arch/atari/dev [netbsd-5]: clock.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1057):
        sys/arch/atari/dev/clock.c: revision 1.47
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.41.6.1 -r1.41.6.2 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.41.6.1 src/sys/arch/atari/dev/clock.c:1.41.6.2
--- src/sys/arch/atari/dev/clock.c:1.41.6.1	Thu Nov  6 00:15:55 2008
+++ src/sys/arch/atari/dev/clock.c	Sun Oct  4 00:31:52 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: clock.c,v 1.41.6.1 2008/11/06 00:15:55 snj Exp $	*/
+/*	$NetBSD: clock.c,v 1.41.6.2 2009/10/04 00:31:52 snj 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.41.6.1 2008/11/06 00:15:55 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.41.6.2 2009/10/04 00:31:52 snj Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -319,21 +319,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

Reply via email to