diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/dev/alpha/tsunami_io.cc | 14 | ||||
-rw-r--r-- | src/dev/intel_8254_timer.cc | 34 | ||||
-rw-r--r-- | src/dev/intel_8254_timer.hh | 31 | ||||
-rw-r--r-- | src/dev/x86/pc.cc | 4 | ||||
-rw-r--r-- | src/dev/x86/south_bridge/i8254.cc | 12 | ||||
-rw-r--r-- | src/dev/x86/south_bridge/speaker.cc | 2 |
6 files changed, 62 insertions, 35 deletions
diff --git a/src/dev/alpha/tsunami_io.cc b/src/dev/alpha/tsunami_io.cc index 2aaf323a2..9c88904e3 100644 --- a/src/dev/alpha/tsunami_io.cc +++ b/src/dev/alpha/tsunami_io.cc @@ -114,19 +114,19 @@ TsunamiIO::read(PacketPtr pkt) pkt->set(0x00); break; case TSDEV_TMR0_DATA: - pkt->set(pitimer.counter0.read()); + pkt->set(pitimer.readCounter(0)); break; case TSDEV_TMR1_DATA: - pkt->set(pitimer.counter1.read()); + pkt->set(pitimer.readCounter(1)); break; case TSDEV_TMR2_DATA: - pkt->set(pitimer.counter2.read()); + pkt->set(pitimer.readCounter(2)); break; case TSDEV_RTC_DATA: pkt->set(rtc.readData(rtcAddr)); break; case TSDEV_CTRL_PORTB: - if (pitimer.counter2.outputHigh()) + if (pitimer.outputHigh(2)) pkt->set(PORTB_SPKR_HIGH); else pkt->set(0x00); @@ -189,13 +189,13 @@ TsunamiIO::write(PacketPtr pkt) mode2 = pkt->get<uint8_t>(); break; case TSDEV_TMR0_DATA: - pitimer.counter0.write(pkt->get<uint8_t>()); + pitimer.writeCounter(0, pkt->get<uint8_t>()); break; case TSDEV_TMR1_DATA: - pitimer.counter1.write(pkt->get<uint8_t>()); + pitimer.writeCounter(1, pkt->get<uint8_t>()); break; case TSDEV_TMR2_DATA: - pitimer.counter2.write(pkt->get<uint8_t>()); + pitimer.writeCounter(2, pkt->get<uint8_t>()); break; case TSDEV_TMR_CTRL: pitimer.writeControl(pkt->get<uint8_t>()); diff --git a/src/dev/intel_8254_timer.cc b/src/dev/intel_8254_timer.cc index 27f55fd92..35fbd9c38 100644 --- a/src/dev/intel_8254_timer.cc +++ b/src/dev/intel_8254_timer.cc @@ -35,15 +35,21 @@ using namespace std; -Intel8254Timer::Intel8254Timer(EventManager *em, const string &name) - : EventManager(em), _name(name), - counter0(this, name + ".counter0"), - counter1(this, name + ".counter1"), - counter2(this, name + ".counter2") +Intel8254Timer::Intel8254Timer(EventManager *em, const string &name, + Counter *counter0, Counter *counter1, Counter *counter2) : + EventManager(em), _name(name) { - counter[0] = &counter0; - counter[1] = &counter0; - counter[2] = &counter0; + counter[0] = counter0; + counter[1] = counter1; + counter[2] = counter2; +} + +Intel8254Timer::Intel8254Timer(EventManager *em, const string &name) : + EventManager(em), _name(name) +{ + counter[0] = new Counter(this, name + ".counter0"); + counter[1] = new Counter(this, name + ".counter1"); + counter[2] = new Counter(this, name + ".counter2"); } void @@ -67,9 +73,9 @@ void Intel8254Timer::serialize(const string &base, ostream &os) { // serialize the counters - counter0.serialize(base + ".counter0", os); - counter1.serialize(base + ".counter1", os); - counter2.serialize(base + ".counter2", os); + counter[0]->serialize(base + ".counter0", os); + counter[1]->serialize(base + ".counter1", os); + counter[2]->serialize(base + ".counter2", os); } void @@ -77,9 +83,9 @@ Intel8254Timer::unserialize(const string &base, Checkpoint *cp, const string §ion) { // unserialze the counters - counter0.unserialize(base + ".counter0", cp, section); - counter1.unserialize(base + ".counter1", cp, section); - counter2.unserialize(base + ".counter2", cp, section); + counter[0]->unserialize(base + ".counter0", cp, section); + counter[1]->unserialize(base + ".counter1", cp, section); + counter[2]->unserialize(base + ".counter2", cp, section); } Intel8254Timer::Counter::Counter(Intel8254Timer *p, const string &name) diff --git a/src/dev/intel_8254_timer.hh b/src/dev/intel_8254_timer.hh index 439432aed..9391b0f9e 100644 --- a/src/dev/intel_8254_timer.hh +++ b/src/dev/intel_8254_timer.hh @@ -44,6 +44,7 @@ /** Programmable Interval Timer (Intel 8254) */ class Intel8254Timer : public EventManager { + protected: BitUnion8(CtrlReg) Bitfield<7, 6> sel; Bitfield<5, 4> rw; @@ -173,7 +174,7 @@ class Intel8254Timer : public EventManager const std::string §ion); }; - private: + protected: std::string _name; const std::string &name() const { return _name; } @@ -181,16 +182,36 @@ class Intel8254Timer : public EventManager Counter *counter[3]; public: - /** Public way to access individual counters (avoid array accesses) */ - Counter counter0; - Counter counter1; - Counter counter2; + + Intel8254Timer(EventManager *em, const std::string &name, + Counter *counter0, Counter *counter1, Counter *counter2); Intel8254Timer(EventManager *em, const std::string &name); /** Write control word */ void writeControl(const CtrlReg data); + uint8_t + readCounter(unsigned int num) + { + assert(num < 3); + return counter[num]->read(); + } + + void + writeCounter(unsigned int num, const uint8_t data) + { + assert(num < 3); + counter[num]->write(data); + } + + bool + outputHigh(unsigned int num) + { + assert(num < 3); + return counter[num]->outputHigh(); + } + /** * Serialize this object to the given output stream. * @param base The base name of the counter object. diff --git a/src/dev/x86/pc.cc b/src/dev/x86/pc.cc index d04529ab9..3de28bce5 100644 --- a/src/dev/x86/pc.cc +++ b/src/dev/x86/pc.cc @@ -64,8 +64,8 @@ PC::init() //Timer 0, latch command timer.writeControl(0x00); //Write a 16 bit count of 0 - timer.counter0.write(0); - timer.counter0.write(0); + timer.writeCounter(0, 0); + timer.writeCounter(0, 0); } Tick diff --git a/src/dev/x86/south_bridge/i8254.cc b/src/dev/x86/south_bridge/i8254.cc index 7c3501c37..c9c0d625a 100644 --- a/src/dev/x86/south_bridge/i8254.cc +++ b/src/dev/x86/south_bridge/i8254.cc @@ -38,13 +38,13 @@ X86ISA::I8254::read(PacketPtr pkt) switch(pkt->getAddr() - addrRange.start) { case 0x0: - pkt->set(pit.counter0.read()); + pkt->set(pit.readCounter(0)); break; case 0x1: - pkt->set(pit.counter1.read()); + pkt->set(pit.readCounter(1)); break; case 0x2: - pkt->set(pit.counter2.read()); + pkt->set(pit.readCounter(2)); break; case 0x3: pkt->set(uint8_t(-1)); @@ -62,13 +62,13 @@ X86ISA::I8254::write(PacketPtr pkt) switch(pkt->getAddr() - addrRange.start) { case 0x0: - pit.counter0.write(pkt->get<uint8_t>()); + pit.writeCounter(0, pkt->get<uint8_t>()); break; case 0x1: - pit.counter1.write(pkt->get<uint8_t>()); + pit.writeCounter(1, pkt->get<uint8_t>()); break; case 0x2: - pit.counter2.write(pkt->get<uint8_t>()); + pit.writeCounter(2, pkt->get<uint8_t>()); break; case 0x3: pit.writeControl(pkt->get<uint8_t>()); diff --git a/src/dev/x86/south_bridge/speaker.cc b/src/dev/x86/south_bridge/speaker.cc index 784c9504b..59a86c634 100644 --- a/src/dev/x86/south_bridge/speaker.cc +++ b/src/dev/x86/south_bridge/speaker.cc @@ -39,7 +39,7 @@ X86ISA::Speaker::read(PacketPtr pkt) { assert(pkt->getAddr() == addrRange.start); assert(pkt->getSize() == 1); - controlVal.timer = timer->pit.counter2.outputHigh() ? 1 : 0; + controlVal.timer = timer->pit.outputHigh(2) ? 1 : 0; DPRINTF(PCSpeaker, "Reading from speaker device: gate %s, speaker %s, output %s.\n", controlVal.gate ? "on" : "off", |