On 03/03/2020 12:15, wolfgang kern wrote:
> On 01.03.2020 13:10, James Harris wrote:
> ....
>
>> I think this all confirms, if nothing else, that the BIOS weekday cell
>> is completely unreliable and should be ignored on read. An OS which
>> wants to identify the day of the week can, instead, determine it by
>> calculation.
>
> Yes, I actually set DOW in the CMOS after calculation during boot-up.
That makes sense. But do you correct it for any reason? I can't see any
reason why you would read from it later.
Just out of curiosity do you include code to set it correctly if the
machine is booted up in the few milliseconds across midnight...? (I.e.
if the date changes between reading the date and when you would set the
weekday.)
AFAICS there are three potential OS responses to the issues surrounding
the weekday byte:
1. Correct the weekday byte on bootup (as you chose to do).
2. Never read, never write the weekday byte; ignore it completely, which
is what some BIOSes seem to do.
3. On bootup and at midnight set the weekday byte to some /invalid/
value so that there's less chance of some other [ lesser :-) ] OS
booting on the same machine confusing it with something useful.
I am not sure which is best but option 3 is tempting. It depends on the
test written into the tick-over-at-midnight CMOS RTC code. If it is '>='
as in
if weekday >= 7 then
set weekday to 1
then I think I might either go for option 2 (ignore it completely) or
maybe set the byte to 0xff because the RTC will soon set it to a valid
range. But if the RTC code uses '=' in its comparison as in
if weekday = 7 then
set weekday to 1
then I'd be tempted to set it to 8. That way the PC could be switched
off for over 245 days (over eight months) before the weekday would
naturally tick over into a valid range.
Of course, we don't know what test a certain chip will apply as AFAIK we
don't know what has been written in any RTC's internal code. I've seen a
disassembly of a keyboard controller (KBC)
http://www.halicery.com/8042/8042_1503033.TXT
but I've never seen a disassembly of a CMOS/RTC chip.
All rather academic of course, but ho hum.
--
James Harris