changeset 835a99bdab10 in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=835a99bdab10
description:
        RTC: Make calls to writeData update the RTCs internal representation of 
time.

diffstat:

1 file changed, 18 insertions(+), 2 deletions(-)
src/dev/mc146818.cc |   20 ++++++++++++++++++--

diffs (38 lines):

diff -r ade9a088bb14 -r 835a99bdab10 src/dev/mc146818.cc
--- a/src/dev/mc146818.cc       Thu Aug 20 00:42:43 2009 -0700
+++ b/src/dev/mc146818.cc       Thu Aug 20 23:09:03 2009 -0700
@@ -52,6 +52,15 @@
     return result;
 }
 
+static uint8_t
+unbcdize(uint8_t val)
+{
+    uint8_t result;
+    result = val & 0xf;
+    result += (val >> 4) * 10;
+    return result;
+}
+
 void
 MC146818::setTime(const struct tm time)
 {
@@ -101,9 +110,16 @@
 void
 MC146818::writeData(const uint8_t addr, const uint8_t data)
 {
-    if (addr < RTC_STAT_REGA)
+    if (addr < RTC_STAT_REGA) {
         clock_data[addr] = data;
-    else {
+        curTime.tm_sec = unbcdize(sec);
+        curTime.tm_min = unbcdize(min);
+        curTime.tm_hour = unbcdize(hour);
+        curTime.tm_mday = unbcdize(mday);
+        curTime.tm_mon = unbcdize(mon) - 1;
+        curTime.tm_year = ((unbcdize(year) + 50) % 100) + 1950;
+        curTime.tm_wday = unbcdize(wday) - 1;
+    } else {
         switch (addr) {
           case RTC_STAT_REGA:
             // The "update in progress" bit is read only.
_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to