summaryrefslogtreecommitdiffstats
path: root/sys/dev/dec/mcclock.c
diff options
context:
space:
mode:
authordfr <dfr@FreeBSD.org>1999-05-18 21:24:16 +0000
committerdfr <dfr@FreeBSD.org>1999-05-18 21:24:16 +0000
commita72b1925b493f31c8edc968eafa58149bf734be6 (patch)
treeb86c9b1f17ab651fb49b1076138c2d13528f5ddc /sys/dev/dec/mcclock.c
parentd446c6adb0181af0297e6e6c8fe8e92a770b0895 (diff)
downloadFreeBSD-src-a72b1925b493f31c8edc968eafa58149bf734be6.zip
FreeBSD-src-a72b1925b493f31c8edc968eafa58149bf734be6.tar.gz
Calibrate the processor cycle counter instead of believing what the
firmware says.
Diffstat (limited to 'sys/dev/dec/mcclock.c')
-rw-r--r--sys/dev/dec/mcclock.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/sys/dev/dec/mcclock.c b/sys/dev/dec/mcclock.c
index 3aada8b..fc06f82 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;
+}
OpenPOWER on IntegriCloud