diff options
author | gallatin <gallatin@FreeBSD.org> | 2001-11-03 17:22:50 +0000 |
---|---|---|
committer | gallatin <gallatin@FreeBSD.org> | 2001-11-03 17:22:50 +0000 |
commit | f8c48b0904480174f3f3a271ee41dbfd60d8a0f0 (patch) | |
tree | d422a2f20c58389b7be663a54d6fda9e466a4b49 | |
parent | ea642e6058721b958befdc46845b768143fd1d6d (diff) | |
download | FreeBSD-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
-rw-r--r-- | sys/alpha/alpha/clock.c | 27 | ||||
-rw-r--r-- | sys/dev/dec/mcclock.c | 14 |
2 files changed, 28 insertions, 13 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); } diff --git a/sys/dev/dec/mcclock.c b/sys/dev/dec/mcclock.c index 9cb3af2..a8a94be 100644 --- a/sys/dev/dec/mcclock.c +++ b/sys/dev/dec/mcclock.c @@ -84,13 +84,6 @@ mcclock_get(device_t dev, time_t base, struct clocktime *ct) ct->day = regs[MC_DOM]; ct->mon = regs[MC_MONTH]; ct->year = regs[MC_YEAR]; - /* - * This chip is not y2k compliant- If it's less than - * 70, we're clearly past the year 2000. - */ - if (ct->year < 70) { - ct->year += 100; - } } /* @@ -112,11 +105,8 @@ mcclock_set(device_t dev, struct clocktime *ct) regs[MC_DOW] = ct->dow; regs[MC_DOM] = ct->day; regs[MC_MONTH] = ct->mon; - /* - * This chip is not y2k compliant- write it with - * no more than two digits. - */ - regs[MC_YEAR] = ct->year % 100; + regs[MC_YEAR] = ct->year; + s = splclock(); MC146818_PUTTOD(dev, ®s); splx(s); |