Subject: Re: NetBSD-1.3.2 Y2K problem
To: None <perry@piermont.com>
From: NG Yew Ban <ybng@cpm.com.my>
List: tech-kern
Date: 10/22/1998 18:25:27
Dear Mr. Perry,
Thanks for your useful infomation, anyway may I know when is the
release of NetBSD-1.3.3 ?
-----Original Message-----
From: Perry E. Metzger <perry@piermont.com>
To: NG Yew Ban <ybng@cpm.com.my>
Cc: Y.H.LOK <yhl@cpm.com.my>; asu@cpm.com.my <asu@cpm.com.my>
Date: Wednesday, October 21, 1998 10:35 PM
Subject: Re: NetBSD-1.3.2 Y2K problem
>
>We cannot use the BIOS for any of our work. This is because the BIOS
>is non-reentrant and operates only in real mode, not in protected
>mode. No NetBSD code (or code for any other Unix system) can do BIOS
>calls.
>
>(There are actually some subtle exceptions to this rule, but we can't
>invoke any of them for inittodr/resettotdr. It is far easier for us to
>simply read the RTC directly.)
>
>The code that is in isa/clock.c should permit NetBSD to be Y2K
>compliant regardless of whether the RTC or the BIOS are Y2K
>compliant. This mostly worked even before -- we have now removed the
>remaining bugs.
>
>Perry
>
>"NG Yew Ban" writes:
>> This is a multi-part message in MIME format.
>>
>> ------=_NextPart_000_0009_01BDFD20.0E73E8E0
>> Content-Type: text/plain;
>> charset="iso-8859-1"
>> Content-Transfer-Encoding: 7bit
>>
>> Dear Mr. Perry,
>>
>> I have a program which read the time from BIOS CHKTIME.C and I
can
>> roll the time correctly from Y1999 to Y2000 although my RTC is not Y2K
>> compatible, my BIOS is Award Modular BIOS 4.51PG, may I know will NetBSD
>> implement reading the time from BIOS since in the market still have a lot
of
>> non-Y2K compliance RTCs?
>>
>> What is the advantage for reading the time from RTC instead of
BIOS
>> in NetBSD?
>>
>> -----Original Message-----
>> From: Perry E. Metzger <perry@piermont.com>
>> To: NG Yew Ban <ybng@cpm.com.my>
>> Cc: perry@piermont.com <perry@piermont.com>; tech-userlevel@netbsd.org
>> <tech-userlevel@netbsd.org>; tech-kern@netbsd.org <tech-kern@netbsd.org>;
>> Y.H.LOK <yhl@cpm.com.my>; asu@cpm.com.my <asu@cpm.com.my>
>> Date: Thursday, October 08, 1998 2:02 PM
>> Subject: Re: NetBSD-1.3.2 Y2K problem
>>
>>
>> >
>> >"NG Yew Ban" writes:
>> >> I tested my PC again with other Y2K scan tools AMI2000.EXE
(from
>> >> American MegaTrends) and Yes2K, I found that the result is different
with
>> >> NTSL YMARK2000, my PC failed at RTC Y2000 roll over test.
>> >>
>> >> I wrote a program RTC.C to access the CMOS RAM directly
bypassing
>> >> BIOS, it is confirm that my PC fail when roll over from Y1999 to Y2000
>> (it
>> >> has rolled over to 1900). But my BIOS is Y2K compliance.
>> >>
>> >> Here I attach my program RTC.C for your reference.
>> >>
>> >> Is any help for running NetBSD in non-Y2K compliance RTC BUT
Y2K
>> >> compliance BIOS PC ?
>> >
>> >I'm writing code (which may go into NetBSD 1.3.3) to handle the
>> >century byte. Previously NetBSD was largely ignoring this byte, and
>> >simply assuming that a year < 70 indicated a date past 2000.
>> >Many machines fail to set the century byte properly and it is unsafe
>> >for us to depend on it being set, but there is no reason I can't make
>> >the resettodr routine handle setting the century byte properly.
>> >
>> >Perry
>> >
>>
>> ------=_NextPart_000_0009_01BDFD20.0E73E8E0
>> Content-Type: application/octet-stream;
>> name="Chktime.c"
>> Content-Transfer-Encoding: quoted-printable
>> Content-Disposition: attachment;
>> filename="Chktime.c"
>>
>> #include <stdio.h>
>> #include <conio.h>
>> #include <dos.h>
>> #include <time.h>
>>
>> /* 8254 programmable interval timer definitions */
>> /* port addresses */
>> #define PIT_TMR0 0x40 /* timer 0 count */
>> #define PIT_TMR1 0x41
>> #define PIT_TMR2 0x42
>> #define PIT_CR 0x43 /* 8254 control register */
>>
>> /* some of the possible control register values */
>> #define PITSC0 0x00
>> #define PITSC1 0x40
>> #define PITSC2 0x80
>> #define PITRWLSBMSB 0x30
>> #define PITMODE2 0x04
>>
>> long getmrsecs()
>> {
>> struct dostime_t t;
>>
>> _dos_gettime(&t);
>> return((t.hour * 60L * 60) + (t.minute * 60) + t.second);
>> }
>>
>> #define bcdbytetoint(x) ((((x >> 4) & 0x0f) * 10) + (x & 0x0f))
>>
>> int getrtktime(union REGS *regs)
>> {
>> regs->h.ah =3D 2;
>> int86(0x1a, regs, regs);
>> return(regs->x.cflag);
>> }
>>
>> int getrtkdate(union REGS *regs)
>> {
>> regs->h.ah =3D 3;
>> int86(0x1a, regs, regs);
>> return(regs->x.cflag);
>> }
>>
>> long getrtksecs(union REGS *regs)
>> {
>> if (getrtktime(regs)) return(-1);
>> return((bcdbytetoint(regs->h.ch) * 60L * 60) + =
>> (bcdbytetoint(regs->h.cl) * 60) +
>> bcdbytetoint(regs->h.dh));
>> }
>>
>> void syncrtktmrtime()
>> {
>> union REGS regs;
>> struct tm t;
>> time_t curtime;
>>
>> getrtkdate(®s);
>> t.tm_year =3D bcdbytetoint(regs.h.ch);
>> t.tm_mon =3D bcdbytetoint(regs.h.cl) - 1;
>> t.tm_mday =3D bcdbytetoint(regs.h.dh);
>> getrtktime(®s);
>> t.tm_hour =3D bcdbytetoint(regs.h.ch);
>> t.tm_min =3D bcdbytetoint(regs.h.cl);
>> t.tm_sec =3D bcdbytetoint(regs.h.dh);
>> curtime =3D mktime(&t);
>> stime(&curtime);
>> }
>>
>>
>> void main(void)
>> {
>> long tmrsecs, rtksecs;
>> long ds, prevds, adjsecs;
>> union REGS regs;
>> unsigned short oldtmrval, timerval =3D 0;
>>
>> clrscr();
>> gotoxy(1,15);
>> cprintf("Please don't switch off this PC !!! Thanks, yhl");
>> tmrsecs =3D adjsecs =3D getmrsecs();
>> while ((rtksecs =3D getrtksecs(®s)) < 0)
>> ;
>> ds =3D rtksecs - tmrsecs;
>> if (ds < -120 || ds > 120)
>> ds =3D 86400L - rtksecs + tmrsecs;
>> prevds =3D ds;
>> while (!kbhit())
>> {
>> tmrsecs =3D getmrsecs();
>> if ((rtksecs =3D getrtksecs(®s)) < 0) continue;
>> // check time difference every 60 seconds
>> if ((tmrsecs > adjsecs && (tmrsecs - adjsecs) >=3D 60) ||
>> (adjsecs > tmrsecs && (86400L - adjsecs + tmrsecs) >=3D
> 60))
>> {
>> adjsecs =3D tmrsecs;
>> ds =3D rtksecs - tmrsecs;
>> if (ds < -120 || ds > 120)
>> ds =3D 86400L - rtksecs + tmrsecs;
>> gotoxy(1, 9);
>> cprintf("Current time difference =3D %ld, Previous time
> difference =
>> =3D %ld",
>> ds, prevds);
>> prevds =3D prevds - ds;
>> oldtmrval =3D timerval;
>> if (prevds > 0)
>> timerval -=3D 8;
>> else if (prevds < 0)
>> timerval +=3D 8;
>> else if (ds > 0)
>> timerval--;
>> else if (ds < 0)
>> timerval++;
>> if (timerval !=3D oldtmrval)
>> {
>> _disable();
>> outp(PIT_CR, PITSC2 | PITRWLSBMSB | PITMODE2);
>> outp(PIT_TMR0, timerval);
>> outp(PIT_TMR0, (timerval >> 8));
>> _enable();
>> }
>> gotoxy(1, 11);
>> cprintf("Time Constant =3D %u", timerval);
>> prevds =3D ds;
>> }
>> gotoxy(1, 3);
>> cprintf("Timer secs: %5lu", tmrsecs);
>> gotoxy(1, 5);
>> cprintf("Real time Clock secs: %5lu", rtksecs);
>> gotoxy(1,7);
>> cprintf("CMOS real time clock time is: %02x:%02x:%02x",
>> regs.h.ch, regs.h.cl, regs.h.dh);
>> }
>> getch();
>> gotoxy(1,24);
>> }
>>
>> #ifdef NOTUSED
>> _dos_gettime(&t);
>> gotoxy(1,3);
>> cprintf("_dos_gettime() is: %02d:%02d:%02d.%02d", t.hour, t.min
>ute,
>> t.second, t.hsecond);
>> regs.h.ah =3D 2;
>> int86(0x1a, ®s, ®s);
>> gotoxy(1,5);
>> cprintf("CMOS real time clock time is: %02x:%02x:%02x",
>> regs.h.ch, regs.h.cl, regs.h.dh);
>> #endif
>>
>> ------=_NextPart_000_0009_01BDFD20.0E73E8E0--
>>
>