]> git.proxmox.com Git - mirror_qemu.git/commitdiff
mc146818rtc: update registers after a format change
authorAurelien Jarno <aurelien@aurel32.net>
Tue, 25 Jan 2011 10:55:15 +0000 (11:55 +0100)
committerAurelien Jarno <aurelien@aurel32.net>
Sat, 29 Jan 2011 14:19:22 +0000 (15:19 +0100)
For some unknown reason, the MIPS kernel briefly changes the RTC to
binary mode during boot, switch back to BCD mode and read the time. As
the registers are updated only every second, they may still be in the
old format when they are read.

This patch forces a register update immediately after a format change
(BCD/binary or 12/24H). This avoid long fsck during boot due to time
wrap.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
hw/mc146818rtc.c

index ec7c4ecdb6966f497a0ada8bb859300436f18d51..a1b0e31ee547c18922d7483d2fb79d38a2103e13 100644 (file)
@@ -247,7 +247,15 @@ static void cmos_ioport_write(void *opaque, uint32_t addr, uint32_t data)
                     rtc_set_time(s);
                 }
             }
-            s->cmos_data[RTC_REG_B] = data;
+            if (((s->cmos_data[RTC_REG_B] ^ data) & (REG_B_DM | REG_B_24H)) &&
+                !(data & REG_B_SET)) {
+                /* If the time format has changed and not in set mode,
+                   update the registers immediately. */
+                s->cmos_data[RTC_REG_B] = data;
+                rtc_copy_date(s);
+            } else {
+                s->cmos_data[RTC_REG_B] = data;
+            }
             rtc_timer_update(s, qemu_get_clock(rtc_clock));
             break;
         case RTC_REG_C: