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.
This commit is contained in:
jdolecek 2001-04-23 09:35:12 +00:00
parent 85b2082906
commit 7c9c35e3e7

View File

@ -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 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#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 @@ cmoscheck()
+ 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 @@ int rtc_update_century = 0;
* 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 @@ clock_expandyear(clockyear)
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 @@ clock_expandyear(clockyear)
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 @@ resettodr()
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);
}