summaryrefslogtreecommitdiff
path: root/sys/arch/macppc
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2020-05-16 14:44:46 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2020-05-16 14:44:46 +0000
commitca55818eef7945b63fe2fd6683902b7a6281ef17 (patch)
tree5f2efc756d600a861c2778d775b147c695379476 /sys/arch/macppc
parente4b72d678a30243ed627b79b55f8dc6b8913bfd4 (diff)
Make inittodr() and resettodr() MI.
ok deraadt@, mpi@, visa@ ok cheloha@ as well (would have preferred in new file for this code)
Diffstat (limited to 'sys/arch/macppc')
-rw-r--r--sys/arch/macppc/macppc/machdep.c94
1 files changed, 1 insertions, 93 deletions
diff --git a/sys/arch/macppc/macppc/machdep.c b/sys/arch/macppc/macppc/machdep.c
index a074b55300f..8949d1db24d 100644
--- a/sys/arch/macppc/macppc/machdep.c
+++ b/sys/arch/macppc/macppc/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.188 2020/05/11 13:25:32 kettenis Exp $ */
+/* $OpenBSD: machdep.c,v 1.189 2020/05/16 14:44:45 kettenis Exp $ */
/* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */
/*
@@ -910,95 +910,3 @@ cpu_switchto(struct proc *oldproc, struct proc *newproc)
cpu_switchto_asm(oldproc, newproc);
}
-
-#include <sys/timetc.h>
-#include <dev/clock_subr.h>
-
-todr_chip_handle_t todr_handle;
-
-#define MINYEAR ((OpenBSD / 100) - 1) /* minimum plausible year */
-
-/*
- * inittodr:
- *
- * Initialize time from the time-of-day register.
- */
-void
-inittodr(time_t base)
-{
- time_t deltat;
- struct timeval rtctime;
- struct timespec ts;
- int badbase;
-
- if (base < (MINYEAR - 1970) * SECYR) {
- printf("WARNING: preposterous time in file system\n");
- /* read the system clock anyway */
- base = (MINYEAR - 1970) * SECYR;
- badbase = 1;
- } else
- badbase = 0;
-
- rtctime.tv_sec = base;
- rtctime.tv_usec = 0;
-
- if (todr_handle == NULL ||
- todr_gettime(todr_handle, &rtctime) != 0 ||
- rtctime.tv_sec < (MINYEAR - 1970) * SECYR) {
- /*
- * Believe the time in the file system for lack of
- * anything better, resetting the TODR.
- */
- rtctime.tv_sec = base;
- rtctime.tv_usec = 0;
- if (todr_handle != NULL && !badbase)
- printf("WARNING: bad clock chip time\n");
- ts.tv_sec = rtctime.tv_sec;
- ts.tv_nsec = rtctime.tv_usec * 1000;
- tc_setclock(&ts);
- goto bad;
- } else {
- ts.tv_sec = rtctime.tv_sec;
- ts.tv_nsec = rtctime.tv_usec * 1000;
- tc_setclock(&ts);
- }
-
- if (!badbase) {
- /*
- * See if we gained/lost two or more days; if
- * so, assume something is amiss.
- */
- deltat = rtctime.tv_sec - base;
- if (deltat < 0)
- deltat = -deltat;
- if (deltat < 2 * SECDAY)
- return; /* all is well */
-#ifndef SMALL_KERNEL
- printf("WARNING: clock %s %lld days\n",
- rtctime.tv_sec < base ? "lost" : "gained",
- (long long)(deltat / SECDAY));
-#endif
- }
- bad:
- printf("WARNING: CHECK AND RESET THE DATE!\n");
-}
-
-/*
- * resettodr:
- *
- * Reset the time-of-day register with the current time.
- */
-void
-resettodr(void)
-{
- struct timeval rtctime;
-
- if (time_second == 1)
- return;
-
- microtime(&rtctime);
-
- if (todr_handle != NULL &&
- todr_settime(todr_handle, &rtctime) != 0)
- printf("WARNING: can't update clock chip time\n");
-}