diff options
author | dfr <dfr@FreeBSD.org> | 1999-05-18 21:24:16 +0000 |
---|---|---|
committer | dfr <dfr@FreeBSD.org> | 1999-05-18 21:24:16 +0000 |
commit | a72b1925b493f31c8edc968eafa58149bf734be6 (patch) | |
tree | b86c9b1f17ab651fb49b1076138c2d13528f5ddc /sys/dev/dec | |
parent | d446c6adb0181af0297e6e6c8fe8e92a770b0895 (diff) | |
download | FreeBSD-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')
-rw-r--r-- | sys/dev/dec/mcclock.c | 28 | ||||
-rw-r--r-- | sys/dev/dec/mcclockvar.h | 1 |
2 files changed, 28 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, ®s); 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 0c9f5df..a38f632 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); |