All AMD64 systems should be Y2K compliant, so we can kill this code from
clock.c on this arch.

The i386 version currently only functions if the first boot after
Jan 1, 2000 is actually in the year 2000.  Obviously now that we are in
2013, it's much more useful to allow the user to map
1900-1969 -> 2000-2069 in the case that their BIOS doesn't allow years
past 1999 to be set directly.

The i386 version of the patch enables this behavior.


--- /usr/src/sys/arch/amd64/isa/clock.c.orig    Tue Mar 19 22:20:59 2013
+++ /usr/src/sys/arch/amd64/isa/clock.c Thu Mar 21 18:57:36 2013
@@ -382,6 +382,8 @@
  * check whether the CMOS layout is "standard"-like (ie, not PS/2-like),
  * to be called at splclock()
  */
+
+/*
 static int cmoscheck(void);
 static int
 cmoscheck(void)
@@ -390,70 +392,25 @@
        unsigned short cksum = 0;
 
        for (i = 0x10; i <= 0x2d; i++)
-               cksum += mc146818_read(NULL, i); /* XXX softc */
+               cksum += mc146818_read(NULL, i); 
 
        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.
  */
-static int centb = NVRAM_CENTURY;
 static int clock_expandyear(int);
 static int
 clock_expandyear(int clockyear)
 {
-       int s, clockcentury, cmoscentury;
+       int clockcentury;
 
        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 = bcdtobin(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, centb, bintobcd(clockcentury));
-                       splx(s);
-               }
-       } else if (cmoscentury == 19 && rtc_update_century == 0)
-               rtc_update_century = 1; /* will update later in resettodr() */
-
        return (clockyear);
 }
 
@@ -560,7 +517,7 @@
 {
        mc_todregs rtclk;
        struct clock_ymdhms dt;
-       int century, diff, s;
+       int diff, s;
 
        /*
         * We might have been called by boot() due to a crash early
@@ -593,10 +550,6 @@
 #endif
        s = splclock();
        rtcput(&rtclk);
-       if (rtc_update_century > 0) {
-               century = bintobcd(dt.dt_year / 100);
-               mc146818_write(NULL, centb, century); /* XXX softc */
-       }
        splx(s);
 }

 
--- clock.c.orig        Thu Mar 21 19:12:36 2013
+++ clock.c     Thu Mar 21 19:13:54 2013
@@ -543,8 +543,7 @@
 
                /* Kludge to roll over century. */
                if ((rtc_update_century > 0) ||
-                   ((cmoscentury == 19) && (clockcentury == 20) &&
-                    (clockyear == 2000))) {
+                   ((cmoscentury == 19) && (clockcentury == 20))) {
                        printf("WARNING: Setting NVRAM century to %d\n",
                               clockcentury);
                        s = splclock();

-- 
Creamy

Reply via email to