aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/dec
diff options
context:
space:
mode:
authorDoug Rabson <dfr@FreeBSD.org>1999-05-18 21:24:16 +0000
committerDoug Rabson <dfr@FreeBSD.org>1999-05-18 21:24:16 +0000
commitf38cc0691f778f13d007bcb59cab879070f00e1b (patch)
treee59435462f99f840659c260608a36298b6f2269b /sys/dev/dec
parentab25d374b20b0f2d95e582f809da498a19d541a5 (diff)
downloadsrc-f38cc0691f778f13d007bcb59cab879070f00e1b.tar.gz
src-f38cc0691f778f13d007bcb59cab879070f00e1b.zip
Calibrate the processor cycle counter instead of believing what the
firmware says.
Notes
Notes: svn path=/head/; revision=47309
Diffstat (limited to 'sys/dev/dec')
-rw-r--r--sys/dev/dec/mcclock.c28
-rw-r--r--sys/dev/dec/mcclockvar.h1
2 files changed, 28 insertions, 1 deletions
diff --git a/sys/dev/dec/mcclock.c b/sys/dev/dec/mcclock.c
index 3aada8b83a8d..fc06f829e3d9 100644
--- a/sys/dev/dec/mcclock.c
+++ b/sys/dev/dec/mcclock.c
@@ -1,4 +1,4 @@
-/* $Id: mcclock.c,v 1.1 1998/06/10 10:56:23 dfr Exp $ */
+/* $Id: mcclock.c,v 1.2 1998/06/14 13:45:41 dfr Exp $ */
/* $NetBSD: mcclock.c,v 1.11 1998/04/19 07:50:25 jonathan Exp $ */
/*
@@ -111,3 +111,29 @@ mcclock_set(device_t dev, struct clocktime *ct)
MC146818_PUTTOD(dev, &regs);
splx(s);
}
+
+int
+mcclock_getsecs(device_t dev, int *secp)
+{
+ int timeout = 100000000;
+ int sec;
+ int s;
+
+ s = splclock();
+ for (;;) {
+ if (!(MCCLOCK_READ(dev, MC_REGA) & MC_REGA_UIP)) {
+ sec = MCCLOCK_READ(dev, MC_SEC);
+ break;
+ }
+ if (--timeout == 0)
+ goto fail;
+ }
+
+ splx(s);
+ *secp = sec;
+ return 0;
+
+ fail:
+ splx(s);
+ return ETIMEDOUT;
+}
diff --git a/sys/dev/dec/mcclockvar.h b/sys/dev/dec/mcclockvar.h
index 0c9f5df8d816..a38f632feac5 100644
--- a/sys/dev/dec/mcclockvar.h
+++ b/sys/dev/dec/mcclockvar.h
@@ -33,3 +33,4 @@ void mcclock_attach(device_t dev);
void mcclock_init(device_t);
void mcclock_get(device_t, time_t, struct clocktime *);
void mcclock_set(device_t, struct clocktime *);
+int mcclock_getsecs(device_t dev, int *secp);