From 9be70a793ef67b216a0a824f3ed6845e9af111ce Mon Sep 17 00:00:00 2001
From: David Malone <dwmalone@FreeBSD.org>
Date: Fri, 27 Jul 2007 09:34:42 +0000
Subject: [PATCH] It seems that some i386 mothermoards either do not implement
 the day of week field correctly, or they remember bad values that are written
 into the day of week field. For this reason, ignore the day of week field
 when reading the clock on i386 rather than bailing if it is set incorrectly.

Problems were seen on a number of platforms, including VMWare, qemu,
EPIA ME6000, Epox-3PTA and ABIT-SL30T.

This is a slightly different fix to that proposed by Ted in his PR,
but the same basic idea.

PR:		111117
Submitted by:	Ted Faber <faber@lunabase.org>
Approved by:	re (rwatson)
MFC after:	3 weeks
---
 sys/i386/isa/clock.c | 3 ++-
 sys/isa/atrtc.c      | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/sys/i386/isa/clock.c b/sys/i386/isa/clock.c
index a519a9e7d641..4b848c4e20a4 100644
--- a/sys/i386/isa/clock.c
+++ b/sys/i386/isa/clock.c
@@ -703,7 +703,8 @@ inittodr(time_t base)
 #else
 	ct.year += 2000;
 #endif
-	/* Should we set dow = -1 because some clocks don't set it correctly? */
+	/* Set dow = -1 because some clocks don't set it correctly. */
+	ct.dow = -1;
 	if (clock_ct_to_ts(&ct, &ts)) {
 		printf("Invalid time in clock: check and reset the date!\n");
 		return;
diff --git a/sys/isa/atrtc.c b/sys/isa/atrtc.c
index a519a9e7d641..4b848c4e20a4 100644
--- a/sys/isa/atrtc.c
+++ b/sys/isa/atrtc.c
@@ -703,7 +703,8 @@ inittodr(time_t base)
 #else
 	ct.year += 2000;
 #endif
-	/* Should we set dow = -1 because some clocks don't set it correctly? */
+	/* Set dow = -1 because some clocks don't set it correctly. */
+	ct.dow = -1;
 	if (clock_ct_to_ts(&ct, &ts)) {
 		printf("Invalid time in clock: check and reset the date!\n");
 		return;