* [Qemu-devel] [PATCH 1/2] mc146818rtc: constantify
@ 2011-01-25 11:05 Aurelien Jarno
2011-01-25 11:05 ` [Qemu-devel] [PATCH 2/2] mc146818rtc: update registers after a format change Aurelien Jarno
0 siblings, 1 reply; 2+ messages in thread
From: Aurelien Jarno @ 2011-01-25 11:05 UTC (permalink / raw)
To: qemu-devel; +Cc: Aurelien Jarno
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
hw/mc146818rtc.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c
index 6466aff..ec7c4ec 100644
--- a/hw/mc146818rtc.c
+++ b/hw/mc146818rtc.c
@@ -72,6 +72,7 @@
#define REG_B_UIE 0x10
#define REG_B_SQWE 0x08
#define REG_B_DM 0x04
+#define REG_B_24H 0x02
#define REG_C_UF 0x10
#define REG_C_IRQF 0x80
@@ -285,7 +286,7 @@ static void rtc_set_time(RTCState *s)
tm->tm_sec = rtc_from_bcd(s, s->cmos_data[RTC_SECONDS]);
tm->tm_min = rtc_from_bcd(s, s->cmos_data[RTC_MINUTES]);
tm->tm_hour = rtc_from_bcd(s, s->cmos_data[RTC_HOURS] & 0x7f);
- if (!(s->cmos_data[RTC_REG_B] & 0x02) &&
+ if (!(s->cmos_data[RTC_REG_B] & REG_B_24H) &&
(s->cmos_data[RTC_HOURS] & 0x80)) {
tm->tm_hour += 12;
}
@@ -304,7 +305,7 @@ static void rtc_copy_date(RTCState *s)
s->cmos_data[RTC_SECONDS] = rtc_to_bcd(s, tm->tm_sec);
s->cmos_data[RTC_MINUTES] = rtc_to_bcd(s, tm->tm_min);
- if (s->cmos_data[RTC_REG_B] & 0x02) {
+ if (s->cmos_data[RTC_REG_B] & REG_B_24H) {
/* 24 hour format */
s->cmos_data[RTC_HOURS] = rtc_to_bcd(s, tm->tm_hour);
} else {
--
1.7.2.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [Qemu-devel] [PATCH 2/2] mc146818rtc: update registers after a format change
2011-01-25 11:05 [Qemu-devel] [PATCH 1/2] mc146818rtc: constantify Aurelien Jarno
@ 2011-01-25 11:05 ` Aurelien Jarno
0 siblings, 0 replies; 2+ messages in thread
From: Aurelien Jarno @ 2011-01-25 11:05 UTC (permalink / raw)
To: qemu-devel; +Cc: Aurelien Jarno
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 | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c
index ec7c4ec..a1b0e31 100644
--- a/hw/mc146818rtc.c
+++ b/hw/mc146818rtc.c
@@ -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:
--
1.7.2.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-01-25 11:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-25 11:05 [Qemu-devel] [PATCH 1/2] mc146818rtc: constantify Aurelien Jarno
2011-01-25 11:05 ` [Qemu-devel] [PATCH 2/2] mc146818rtc: update registers after a format change Aurelien Jarno
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.