Seting the hardware clock
David Kelly
dkelly at HiWAAY.net
Mon Jul 14 20:16:17 PDT 2003
On Monday 14 July 2003 08:11 pm, W. D. wrote:
> At 19:24 7/14/2003, David Kelly, wrote:
> >Another thing we saw with Soekris and FreeBSD 4.x was that FreeBSD
> > wrote Sunday as 0 but would accept 0 or 7 on read, Soekris clock
> > hardware was happy with 0, but BIOS demanded 7 else it assumed the
> > clock was corrupt and reset its time to Jan 1, 1980. This only
> > mattered if you rebooted on Sunday. Its a 2 byte patch to FreeBSD
> > 4.x, already included in 5.x.
>
> Where would one find this 2 byte patch for 4.7?
Look for messages from phk in the soekris-tech mail list archives at
http://www.soekris.com/ to be sure of finding the right thing. Nosing
around a bit I believe the file is /usr/src/sys/i386/isa/clock.c.
The fixed version (copied from 5.1):
writertc(RTC_WDAY, (tm + 4) % 7 + 1); /* Write back Weekday */
The old version ("+ 1" hacked out of above):
writertc(RTC_WDAY, (tm + 4) % 7 ); /* Write back Weekday */
% cvs log /usr/src/sys/i386/isa/clock.c says:
revision 1.191
date: 2002/12/04 13:46:49; author: phk; state: Exp; lines: +1 -1
Use the correct value when writing the Day Of Week byte in the CMOS.
The correct range is [1...7] with Sunday=1, but we have been writing
[0...6] with Sunday=0.
The Soekris computers flagged the zero, zapped the date, so if you
rebooted your soekris on a sunday, it would come up with a wrong
date.
Bruce has a more extensive rework of this code, but we will stick with
the minimalist fix for now.
Spotted by: Soren Kristensen <soren at soekris.com>
Thanks to: Michael Sierchio <kudzu at tenebras.com>.
Confirmed by: bde
Approved by: re
IIRC the comment above about Sunday is incorrect. Have been using 0, but
7 (not 1) is correct. I believe 1-6 is still Monday thru Saturday in
both versions. But I'm not going to sweat it tonight. Both versions
work on most BIOS's.
--
David Kelly N4HHE, dkelly at hiwaay.net
=====================================================================
The human mind ordinarily operates at only ten percent of its
capacity -- the rest is overhead for the operating system.
More information about the freebsd-questions
mailing list