summaryrefslogtreecommitdiffstats
path: root/sys/alpha
diff options
context:
space:
mode:
authorgallatin <gallatin@FreeBSD.org>2001-11-03 17:22:50 +0000
committergallatin <gallatin@FreeBSD.org>2001-11-03 17:22:50 +0000
commitf8c48b0904480174f3f3a271ee41dbfd60d8a0f0 (patch)
treed422a2f20c58389b7be663a54d6fda9e466a4b49 /sys/alpha
parentea642e6058721b958befdc46845b768143fd1d6d (diff)
downloadFreeBSD-src-f8c48b0904480174f3f3a271ee41dbfd60d8a0f0.zip
FreeBSD-src-f8c48b0904480174f3f3a271ee41dbfd60d8a0f0.tar.gz
Introduce a boot environment variable (clock_compat_osf1) which can
be set to 1 to make FreeBSD and Tru64 coexist peacefully on a dual boot system and not clobber each other's year in the TOY clock. (Tru64 uses an offset 52 years higher than one would expect) Obtained from: NetBSD MFC After: 1 week
Diffstat (limited to 'sys/alpha')
-rw-r--r--sys/alpha/alpha/clock.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/sys/alpha/alpha/clock.c b/sys/alpha/alpha/clock.c
index 6cba099..3bc0ce0 100644
--- a/sys/alpha/alpha/clock.c
+++ b/sys/alpha/alpha/clock.c
@@ -71,6 +71,17 @@
#define SECYR ((unsigned)(365*SECDAY)) /* seconds per common year */
/*
+ * According to OSF/1's /usr/sys/include/arch/alpha/clock.h,
+ * the console adjusts the RTC years 13..19 to 93..99 and
+ * 20..40 to 00..20. (historical reasons?)
+ * DEC Unix uses an offset to the year to stay outside
+ * the dangerous area for the next couple of years.
+ */
+#define UNIX_YEAR_OFFSET 52 /* 41=>1993, 12=>2064 */
+
+static int clock_year_offset = 0;
+
+/*
* 32-bit time_t's can't reach leap years before 1904 or after 2036, so we
* can use a simple formula for leap years.
*/
@@ -472,7 +483,7 @@ inittodr(base)
register int days, yr;
struct clocktime ct;
time_t deltat;
- int badbase;
+ int badbase, clock_compat_osf1;
int s;
struct timespec ts;
@@ -484,9 +495,22 @@ inittodr(base)
} else
badbase = 0;
+ if (getenv_int("clock_compat_osf1", &clock_compat_osf1)) {
+ if (clock_compat_osf1)
+ clock_year_offset = UNIX_YEAR_OFFSET;
+ }
+
CLOCK_GET(clockdev, base, &ct);
clockinitted = 1;
+#ifdef DEBUG
+ printf("readclock: %d/%d/%d/%d/%d/%d\n", ct.year, ct.mon, ct.day,
+ ct.hour, ct.min, ct.sec);
+#endif
+ ct.year += clock_year_offset;
+ if (ct.year < 70)
+ ct.year += 100;
+
/* simple sanity checks */
if (ct.year < 70 || ct.mon < 1 || ct.mon > 12 || ct.day < 1 ||
ct.day > 31 || ct.hour > 23 || ct.min > 59 || ct.sec > 59) {
@@ -595,6 +619,7 @@ resettodr()
ct.min = t / SECMIN;
ct.sec = t % SECMIN;
+ ct.year = (ct.year - clock_year_offset) % 100;
CLOCK_SET(clockdev, &ct);
}
OpenPOWER on IntegriCloud