qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 2/4] hw/ds1338.c: Minor fixes
@ 2012-12-02 17:17 Antoine Mathys
  2012-12-04 17:51 ` Peter Maydell
  0 siblings, 1 reply; 2+ messages in thread
From: Antoine Mathys @ 2012-12-02 17:17 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, paul

Minor fixes in the handling of the RTC registers.

Signed-off-by: Antoine Mathys <barsamin@gmail.com>
---
  hw/ds1338.c |   15 ++++++++-------
  1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/hw/ds1338.c b/hw/ds1338.c
index 1274b22..1fb152e 100644
--- a/hw/ds1338.c
+++ b/hw/ds1338.c
@@ -62,9 +62,9 @@ static void capture_current_time(DS1338State *s)
      } else {
          s->nvram[2] = to_bcd(now.tm_hour);
      }
-    s->nvram[3] = to_bcd(now.tm_wday) + 1;
+    s->nvram[3] = to_bcd(now.tm_wday + 1);
      s->nvram[4] = to_bcd(now.tm_mday);
-    s->nvram[5] = to_bcd(now.tm_mon) + 1;
+    s->nvram[5] = to_bcd(now.tm_mon + 1);
      s->nvram[6] = to_bcd(now.tm_year - 100);
  }

@@ -119,7 +119,8 @@ static int ds1338_send(I2CSlave *i2c, uint8_t data)
          s->addr_byte = false;
          return 0;
      }
-    if (s->ptr < 8) {
+    if (s->ptr < 7) {
+        /* Time register. */
          struct tm now;
          qemu_get_timedate(&now, s->offset);
          switch(s->ptr) {
@@ -145,7 +146,7 @@ static int ds1338_send(I2CSlave *i2c, uint8_t data)
              }
              break;
          case 3:
-            now.tm_wday = from_bcd(data & 7) - 1;
+            now.tm_wday = from_bcd(data & 0x07) - 1;
              break;
          case 4:
              now.tm_mday = from_bcd(data & 0x3f);
@@ -156,11 +157,11 @@ static int ds1338_send(I2CSlave *i2c, uint8_t data)
          case 6:
              now.tm_year = from_bcd(data) + 100;
              break;
-        case 7:
-            /* Control register. Currently ignored.  */
-            break;
          }
          s->offset = qemu_timedate_diff(&now);
+    } else if (s->ptr == 7) {
+        /* Control register. Currently ignored.  */
+        s->nvram[s->ptr] = data;
      } else {
          s->nvram[s->ptr] = data;
      }
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-12-04 17:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-02 17:17 [Qemu-devel] [PATCH 2/4] hw/ds1338.c: Minor fixes Antoine Mathys
2012-12-04 17:51 ` Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).