summaryrefslogtreecommitdiff
path: root/src/dev/mc146818.cc
diff options
context:
space:
mode:
authorGabe Black <gblack@eecs.umich.edu>2009-08-20 23:09:03 -0700
committerGabe Black <gblack@eecs.umich.edu>2009-08-20 23:09:03 -0700
commitf6bb7ec4eb38cc61c32f4c6941e09deda23f979c (patch)
treeaf0ea22d13535beb68022f0ece09f96b135e3668 /src/dev/mc146818.cc
parentda3c3bfa98e7cf81010a476b0b6ceba4c936f417 (diff)
downloadgem5-f6bb7ec4eb38cc61c32f4c6941e09deda23f979c.tar.xz
RTC: Make calls to writeData update the RTCs internal representation of time.
Diffstat (limited to 'src/dev/mc146818.cc')
-rw-r--r--src/dev/mc146818.cc20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/dev/mc146818.cc b/src/dev/mc146818.cc
index 8d289a416..b25b015d2 100644
--- a/src/dev/mc146818.cc
+++ b/src/dev/mc146818.cc
@@ -52,6 +52,15 @@ bcdize(uint8_t val)
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 @@ MC146818::~MC146818()
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.