Until we start to worry about Y2K1, does it really matter what the
NVRAM_CENTURY byte says?
--- /usr/src/sys/arch/i386/isa/clock.c.orig Mon May 6 02:15:11 2013
+++ /usr/src/sys/arch/i386/isa/clock.c Wed Aug 27 19:02:46 2014
@@ -502,85 +502,6 @@
static int timeset;
/*
- * check whether the CMOS layout is "standard"-like (ie, not PS/2-like),
- * to be called at splclock()
- */
-int cmoscheck(void);
-int
-cmoscheck(void)
-{
- int i;
- unsigned short cksum = 0;
-
- for (i = 0x10; i <= 0x2d; i++)
- cksum += mc146818_read(NULL, i); /* XXX softc */
-
- return (cksum == (mc146818_read(NULL, 0x2e) << 8)
- + mc146818_read(NULL, 0x2f));
-}
-
-/*
- * patchable to control century byte handling:
- * 1: always update
- * -1: never touch
- * 0: try to figure out itself
- */
-int rtc_update_century = 0;
-
-/*
- * Expand a two-digit year as read from the clock chip
- * into full width.
- * Being here, deal with the CMOS century byte.
- */
-int clock_expandyear(int);
-int
-clock_expandyear(int clockyear)
-{
- int s, clockcentury, cmoscentury;
-
- clockcentury = (clockyear < 70) ? 20 : 19;
- clockyear += 100 * clockcentury;
-
- if (rtc_update_century < 0)
- return (clockyear);
-
- s = splclock();
- if (cmoscheck())
- cmoscentury = mc146818_read(NULL, NVRAM_CENTURY);
- else
- cmoscentury = 0;
- splx(s);
- if (!cmoscentury) {
-#ifdef DIAGNOSTIC
- printf("clock: unknown CMOS layout\n");
-#endif
- return (clockyear);
- }
- cmoscentury = hexdectodec(cmoscentury);
-
- if (cmoscentury != clockcentury) {
- /* XXX note: saying "century is 20" might confuse the naive. */
- printf("WARNING: NVRAM century is %d but RTC year is %d\n",
- cmoscentury, clockyear);
-
- /* Kludge to roll over century. */
- if ((rtc_update_century > 0) ||
- ((cmoscentury == 19) && (clockcentury == 20) &&
- (clockyear == 2000))) {
- printf("WARNING: Setting NVRAM century to %d\n",
- clockcentury);
- s = splclock();
- mc146818_write(NULL, NVRAM_CENTURY,
- dectohexdec(clockcentury));
- splx(s);
- }
- } else if (cmoscentury == 19 && rtc_update_century == 0)
- rtc_update_century = 1; /* will update later in resettodr() */
-
- return (clockyear);
-}
-
-/*
* Initialize the time of day register, based on the time base which is, e.g.
* from a filesystem.
*/
@@ -622,7 +543,7 @@
dt.dt_hour = hexdectodec(rtclk[MC_HOUR]);
dt.dt_day = hexdectodec(rtclk[MC_DOM]);
dt.dt_mon = hexdectodec(rtclk[MC_MONTH]);
- dt.dt_year = clock_expandyear(hexdectodec(rtclk[MC_YEAR]));
+ dt.dt_year = 2000 + hexdectodec(rtclk[MC_YEAR]);
/*
@@ -676,7 +597,6 @@
mc_todregs rtclk;
struct clock_ymdhms dt;
int diff;
- int century;
int s;
/*
@@ -705,10 +625,6 @@
rtclk[MC_DOM] = dectohexdec(dt.dt_day);
s = splclock();
rtcput(&rtclk);
- if (rtc_update_century > 0) {
- century = dectohexdec(dt.dt_year / 100);
- mc146818_write(NULL, NVRAM_CENTURY, century); /* XXX softc */
- }
splx(s);
}
--
(Remove the obvious prefix to reply privately.)
Gemaakt met Opera's e-mailprogramma: http://www.opera.com/mail/