diff options
author | Visa Hankala <visa@cvs.openbsd.org> | 2020-05-16 03:35:53 +0000 |
---|---|---|
committer | Visa Hankala <visa@cvs.openbsd.org> | 2020-05-16 03:35:53 +0000 |
commit | 469c20fe93375a4f59e1e7c619efdf667a499351 (patch) | |
tree | 0a6405478f6dc73ad01dbd818ec0ddcd9510950f /sys/arch | |
parent | 5667cc2cd87e4c1062958c154d07a02fd64316e4 (diff) |
Use todr_gettime() in cp0_calibrate() on mips64.
This allows changing RTC drivers from <mips64/dev/clockvar.h>
to <dev/clock_subr.h> API.
OK kettenis@
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/mips64/mips64/mips64_machdep.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/sys/arch/mips64/mips64/mips64_machdep.c b/sys/arch/mips64/mips64/mips64_machdep.c index e3ac7728a3b..ec38cc1b88a 100644 --- a/sys/arch/mips64/mips64/mips64_machdep.c +++ b/sys/arch/mips64/mips64/mips64_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mips64_machdep.c,v 1.28 2020/05/11 13:25:32 kettenis Exp $ */ +/* $OpenBSD: mips64_machdep.c,v 1.29 2020/05/16 03:35:52 visa Exp $ */ /* * Copyright (c) 2009, 2010, 2012 Miodrag Vallat. @@ -343,28 +343,30 @@ cp0_get_timecount(struct timecounter *tc) void cp0_calibrate(struct cpu_info *ci) { - struct tod_desc *cd = &sys_tod; - struct tod_time ct; + struct timeval rtctime; u_int first_cp0, second_cp0, cycles_per_sec; int first_sec; - if (cd->tod_get == NULL) + if (todr_handle == NULL) return; - (*cd->tod_get)(cd->tod_cookie, 0, &ct); - first_sec = ct.sec; + if (todr_gettime(todr_handle, &rtctime) != 0) + return; + first_sec = rtctime.tv_sec; /* Let the clock tick one second. */ do { first_cp0 = cp0_get_count(); - (*cd->tod_get)(cd->tod_cookie, 0, &ct); - } while (ct.sec == first_sec); - first_sec = ct.sec; + if (todr_gettime(todr_handle, &rtctime) != 0) + return; + } while (rtctime.tv_sec == first_sec); + first_sec = rtctime.tv_sec; /* Let the clock tick one more second. */ do { second_cp0 = cp0_get_count(); - (*cd->tod_get)(cd->tod_cookie, 0, &ct); - } while (ct.sec == first_sec); + if (todr_gettime(todr_handle, &rtctime) != 0) + return; + } while (rtctime.tv_sec == first_sec); cycles_per_sec = second_cp0 - first_cp0; ci->ci_hw.clock = cycles_per_sec * CP0_CYCLE_DIVIDER; |