summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2012-10-18 17:45:10 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2012-10-18 17:45:10 +0000
commitdd969649aa19881cb80e242688c748bb8f4b0010 (patch)
tree4edc7281e4b14ddc861cd2f9af141d97cfc1ed17
parent708127f93397fbcc3a24d7a6295a4af4cdf7c1ce (diff)
Switch luna88k to timecounters; tested by aoyama@
-rw-r--r--sys/arch/luna88k/include/_types.h5
-rw-r--r--sys/arch/luna88k/luna88k/clock.c41
-rw-r--r--sys/arch/luna88k/luna88k/machdep.c28
3 files changed, 37 insertions, 37 deletions
diff --git a/sys/arch/luna88k/include/_types.h b/sys/arch/luna88k/include/_types.h
index 3c060773dc6..d7d45b463f4 100644
--- a/sys/arch/luna88k/include/_types.h
+++ b/sys/arch/luna88k/include/_types.h
@@ -1,4 +1,7 @@
-/* $OpenBSD: _types.h,v 1.3 2007/05/15 01:56:46 deraadt Exp $ */
+/* $OpenBSD: _types.h,v 1.4 2012/10/18 17:45:08 miod Exp $ */
/* public domain */
#include <m88k/_types.h>
+
+/* Feature test macros */
+#define __HAVE_TIMECOUNTER
diff --git a/sys/arch/luna88k/luna88k/clock.c b/sys/arch/luna88k/luna88k/clock.c
index 97eb4ab3a02..a06cdb70d70 100644
--- a/sys/arch/luna88k/luna88k/clock.c
+++ b/sys/arch/luna88k/luna88k/clock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clock.c,v 1.7 2011/09/13 05:01:21 miod Exp $ */
+/* $OpenBSD: clock.c,v 1.8 2012/10/18 17:45:08 miod Exp $ */
/* $NetBSD: clock.c,v 1.2 2000/01/11 10:29:35 nisimura Exp $ */
/*
@@ -50,6 +50,7 @@
#include <sys/device.h>
#include <sys/kernel.h>
#include <sys/evcount.h>
+#include <sys/timetc.h>
#include <machine/cpu.h>
@@ -90,6 +91,16 @@ clockattach(dev, fns, evc)
* Resettodr restores the time of day hardware after a time change.
*/
+u_int clock_get_tc(struct timecounter *);
+
+struct timecounter clock_tc = {
+ .tc_get_timecount = clock_get_tc,
+ .tc_counter_mask = 0xffffffff,
+ .tc_frequency = 0, /* will be filled in */
+ .tc_name = "clock",
+ .tc_quality = 0
+};
+
/*
* Start the real-time and statistics clocks. Leave stathz 0 since there
* are no other timers available.
@@ -104,7 +115,8 @@ cpu_initclocks()
#endif
tick = 1000000 / hz; /* number of microseconds between interrupts */
-
+ clock_tc.tc_frequency = hz;
+ tc_init(&clock_tc);
clockinitted = 1;
}
@@ -130,13 +142,16 @@ inittodr(base)
time_t base;
{
struct clock_ymdhms dt;
+ struct timespec ts;
time_t deltat;
int badbase;
- if (base < 5*SECYR) {
+ ts.tv_sec = ts.tv_nsec = 0;
+
+ if (base < (2012 - 1970) * SECYR) {
printf("WARNING: preposterous time in file system");
/* read the system clock anyway */
- base = 6*SECYR + 186*SECDAY + SECDAY/2;
+ base = (2012 - 1970) * SECYR;
badbase = 1;
} else
badbase = 0;
@@ -151,7 +166,8 @@ inittodr(base)
* Believe the time in the file system for lack of
* anything better, resetting the TODR.
*/
- time.tv_sec = base;
+ ts.tv_sec = base;
+ tc_setclock(&ts);
if (!badbase) {
printf("WARNING: preposterous clock chip time");
resettodr();
@@ -159,20 +175,21 @@ inittodr(base)
goto bad;
}
/* now have days since Jan 1, 1970; the rest is easy... */
- time.tv_sec = clock_ymdhms_to_secs(&dt);
+ ts.tv_sec = clock_ymdhms_to_secs(&dt);
+ tc_setclock(&ts);
if (!badbase) {
/*
* See if we gained/lost two or more days;
* if so, assume something is amiss.
*/
- deltat = time.tv_sec - base;
+ deltat = ts.tv_sec - base;
if (deltat < 0)
deltat = -deltat;
if (deltat < 2 * SECDAY)
return;
printf("WARNING: clock %s %d days",
- time.tv_sec < base ? "lost" : "gained",
+ ts.tv_sec < base ? "lost" : "gained",
(int) (deltat / SECDAY));
}
bad:
@@ -193,7 +210,7 @@ resettodr()
if (!todrvalid)
return;
- clock_secs_to_ymdhms(time.tv_sec, &dt);
+ clock_secs_to_ymdhms(time_second, &dt);
(*clockfns->cf_set)(clockdev, &dt);
}
@@ -213,3 +230,9 @@ clockintr(void *eframe)
hardclock(eframe);
return 1;
}
+
+u_int
+clock_get_tc(struct timecounter *tc)
+{
+ return (u_int)clockevc->ec_count;
+}
diff --git a/sys/arch/luna88k/luna88k/machdep.c b/sys/arch/luna88k/luna88k/machdep.c
index d0d507b1051..758e20b9cb7 100644
--- a/sys/arch/luna88k/luna88k/machdep.c
+++ b/sys/arch/luna88k/luna88k/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.82 2012/10/08 21:47:48 deraadt Exp $ */
+/* $OpenBSD: machdep.c,v 1.83 2012/10/18 17:45:09 miod Exp $ */
/*
* Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr.
* Copyright (c) 1996 Nivas Madhur
@@ -1122,32 +1122,6 @@ romttycnputc(dev, c)
splx(s);
}
-/* taken from NetBSD/luna68k */
-void
-microtime(tvp)
- register struct timeval *tvp;
-{
- int s = splclock();
- static struct timeval lasttime;
-
- *tvp = time;
-#ifdef notdef
- tvp->tv_usec += clkread();
- while (tvp->tv_usec >= 1000000) {
- tvp->tv_sec++;
- tvp->tv_usec -= 1000000;
- }
-#endif
- 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);
-}
-
/* powerdown */
struct pio {