Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/i386/isa Move the inclusion of 'mca.h' so that it d...



details:   https://anonhg.NetBSD.org/src/rev/324ab4e2c97b
branches:  trunk
changeset: 508956:324ab4e2c97b
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Mon Apr 23 09:35:12 2001 +0000

description:
Move the inclusion of 'mca.h' so that it doesn't depend on pcppi. The clock
interrupts are properly reset on PS/2 now.

Handle the slighly different PS/2 CMOS layout and get/set century
byte as appropriate. The check for valid CMOS CRC checksum is not implemented
yet; I don't currently know algorithm they use.

The info about PS/2 CMOS was taken from the Padgett Peterson's
x86/MSDOS Interrupt List, release 60.

diffstat:

 sys/arch/i386/isa/clock.c |  45 +++++++++++++++++++++++++++++++++++++--------
 1 files changed, 37 insertions(+), 8 deletions(-)

diffs (99 lines):

diff -r e39f399de2af -r 324ab4e2c97b sys/arch/i386/isa/clock.c
--- a/sys/arch/i386/isa/clock.c Mon Apr 23 09:07:49 2001 +0000
+++ b/sys/arch/i386/isa/clock.c Mon Apr 23 09:35:12 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: clock.c,v 1.66 2001/03/12 17:26:37 wiz Exp $   */
+/*     $NetBSD: clock.c,v 1.67 2001/04/23 09:35:12 jdolecek Exp $      */
 
 /*-
  * Copyright (c) 1993, 1994 Charles M. Hannum.
@@ -109,15 +109,15 @@
 #include <i386/isa/timerreg.h>
 #include <dev/clock_subr.h>
 
-#include "pcppi.h"
-#if (NPCPPI > 0)
-#include <dev/isa/pcppivar.h>
-
 #include "mca.h"
 #if NMCA > 0
 #include <machine/mca_machdep.h>       /* for MCA_system */
 #endif
 
+#include "pcppi.h"
+#if (NPCPPI > 0)
+#include <dev/isa/pcppivar.h>
+
 #ifdef CLOCKDEBUG
 int clock_debug = 0;
 #define DPRINTF(arg) if (clock_debug) printf arg
@@ -641,6 +641,31 @@
                          + mc146818_read(NULL, 0x2f));
 }
 
+#if NMCA > 0
+/*
+ * Check whether the CMOS layout is PS/2 like, to be called at splclock().
+ */
+static int cmoscheckps2 __P((void));
+static int
+cmoscheckps2()
+{
+#if 0
+       /* Disabled until I find out the CRC checksum algorithm IBM uses */
+       int i;
+       unsigned short cksum = 0;
+
+       for (i = 0x10; i <= 0x31; i++)
+               cksum += mc146818_read(NULL, i); /* XXX softc */
+
+       return (cksum == (mc146818_read(NULL, 0x32) << 8)
+                         + mc146818_read(NULL, 0x33));
+#else
+       /* Check 'incorrect checksum' bit of IBM PS/2 Diagnostic Status Byte */
+       return ((mc146818_read(NULL, NVRAM_DIAG) & (1<<6)) == 0);
+#endif
+}
+#endif /* NMCA > 0 */
+
 /*
  * patchable to control century byte handling:
  * 1: always update
@@ -654,6 +679,7 @@
  * into full width.
  * Being here, deal with the CMOS century byte.
  */
+static int centb = NVRAM_CENTURY;
 static int clock_expandyear __P((int));
 static int
 clock_expandyear(clockyear)
@@ -670,6 +696,10 @@
        s = splclock();
        if (cmoscheck())
                cmoscentury = mc146818_read(NULL, NVRAM_CENTURY);
+#if NMCA > 0
+       else if (MCA_system && cmoscheckps2())
+               cmoscentury = mc146818_read(NULL, (centb = 0x37));
+#endif
        else
                cmoscentury = 0;
        splx(s);
@@ -693,8 +723,7 @@
                        printf("WARNING: Setting NVRAM century to %d\n",
                               clockcentury);
                        s = splclock();
-                       mc146818_write(NULL, NVRAM_CENTURY,
-                                      bintobcd(clockcentury));
+                       mc146818_write(NULL, centb, bintobcd(clockcentury));
                        splx(s);
                }
        } else if (cmoscentury == 19 && rtc_update_century == 0)
@@ -831,7 +860,7 @@
        rtcput(&rtclk);
        if (rtc_update_century > 0) {
                century = bintobcd(dt.dt_year / 100);
-               mc146818_write(NULL, NVRAM_CENTURY, century); /* XXX softc */
+               mc146818_write(NULL, centb, century); /* XXX softc */
        }
        splx(s);
 }



Home | Main Index | Thread Index | Old Index