summaryrefslogtreecommitdiff
path: root/src/dev
diff options
context:
space:
mode:
authorGabe Black <gblack@eecs.umich.edu>2008-03-25 02:15:23 -0400
committerGabe Black <gblack@eecs.umich.edu>2008-03-25 02:15:23 -0400
commit93dd1978a7750ba7cce04ae4401f5c6689290038 (patch)
treef353f05686dba5215fea534183131b6b867e2ac1 /src/dev
parente5bdae15f3651d8f0fc63e483e73e8ea742135e3 (diff)
downloadgem5-93dd1978a7750ba7cce04ae4401f5c6689290038.tar.xz
X86: Put an RTC into the CMOS part of the southbridge.
--HG-- extra : convert_revision : a614373236fe75db6e6181fc152a02b541a131f3
Diffstat (limited to 'src/dev')
-rw-r--r--src/dev/x86/south_bridge/cmos.cc47
-rw-r--r--src/dev/x86/south_bridge/cmos.hh25
2 files changed, 29 insertions, 43 deletions
diff --git a/src/dev/x86/south_bridge/cmos.cc b/src/dev/x86/south_bridge/cmos.cc
index 43ada42e8..164b23d84 100644
--- a/src/dev/x86/south_bridge/cmos.cc
+++ b/src/dev/x86/south_bridge/cmos.cc
@@ -71,27 +71,10 @@ uint8_t
X86ISA::Cmos::readRegister(uint8_t reg)
{
assert(reg < numRegs);
- switch(reg)
- {
- case 0x0:
- case 0x1:
- case 0x2:
- case 0x3:
- case 0x4:
- case 0x5:
- case 0x6:
- case 0x7:
- case 0x8:
- case 0x9:
- case 0xA:
- case 0xB:
- case 0xC:
- case 0xD:
- warn("Reading RTC in the CMOS.\n");
- break;
- default:
+ if (reg <= 0xD) {
+ return rtc.readData(reg);
+ } else {
warn("Reading non-volitile CMOS address %x as %x.\n", reg, regs[reg]);
- break;
}
return regs[reg];
}
@@ -100,27 +83,11 @@ void
X86ISA::Cmos::writeRegister(uint8_t reg, uint8_t val)
{
assert(reg < numRegs);
- switch(reg)
- {
- case 0x0:
- case 0x1:
- case 0x2:
- case 0x3:
- case 0x4:
- case 0x5:
- case 0x6:
- case 0x7:
- case 0x8:
- case 0x9:
- case 0xA:
- case 0xB:
- case 0xC:
- case 0xD:
- warn("Writing RTC in the CMOS.\n");
- break;
- default:
+ if (reg <= 0xD) {
+ rtc.writeData(reg, val);
+ return;
+ } else {
warn("Writing non-volitile CMOS address %x with %x.\n", reg, val);
- break;
}
regs[reg] = val;
}
diff --git a/src/dev/x86/south_bridge/cmos.hh b/src/dev/x86/south_bridge/cmos.hh
index cd3fab280..6fd7613bc 100644
--- a/src/dev/x86/south_bridge/cmos.hh
+++ b/src/dev/x86/south_bridge/cmos.hh
@@ -33,6 +33,7 @@
#include "arch/x86/x86_traits.hh"
#include "base/range.hh"
+#include "dev/mc146818.hh"
#include "dev/x86/south_bridge/sub_device.hh"
namespace X86ISA
@@ -43,6 +44,8 @@ class Cmos : public SubDevice
protected:
uint8_t address;
+ struct tm foo_time;
+
static const int numRegs = 128;
uint8_t regs[numRegs];
@@ -50,22 +53,38 @@ class Cmos : public SubDevice
uint8_t readRegister(uint8_t reg);
void writeRegister(uint8_t reg, uint8_t val);
+ class X86RTC : public MC146818
+ {
+ public:
+ X86RTC(const std::string &n, const struct tm time,
+ bool bcd, Tick frequency) : MC146818(n, time, bcd, frequency)
+ {
+ }
+ protected:
+ void handleEvent()
+ {
+ return;
+ }
+ } rtc;
+
public:
- Cmos()
+ Cmos() : rtc("rtc", foo_time, true, 5000000000)
{
memset(regs, 0, numRegs * sizeof(uint8_t));
address = 0;
}
- Cmos(Tick _latency) : SubDevice(_latency)
+ Cmos(Tick _latency) : SubDevice(_latency),
+ rtc("rtc", foo_time, true, 5000000000)
{
memset(regs, 0, numRegs * sizeof(uint8_t));
address = 0;
}
Cmos(Addr start, Addr size, Tick _latency) :
- SubDevice(start, size, _latency)
+ SubDevice(start, size, _latency),
+ rtc("rtc", foo_time, true, 5000000000)
{
memset(regs, 0, numRegs * sizeof(uint8_t));
address = 0;