diff options
Diffstat (limited to 'src/mem')
-rw-r--r-- | src/mem/bus.cc | 15 | ||||
-rw-r--r-- | src/mem/bus.hh | 10 | ||||
-rw-r--r-- | src/mem/cache/base.cc | 12 | ||||
-rw-r--r-- | src/mem/cache/base.hh | 4 | ||||
-rw-r--r-- | src/mem/coherent_bus.cc | 4 | ||||
-rw-r--r-- | src/mem/coherent_bus.hh | 2 | ||||
-rw-r--r-- | src/mem/noncoherent_bus.cc | 4 | ||||
-rw-r--r-- | src/mem/noncoherent_bus.hh | 2 | ||||
-rw-r--r-- | src/mem/packet_queue.cc | 12 | ||||
-rw-r--r-- | src/mem/packet_queue.hh | 15 | ||||
-rw-r--r-- | src/mem/qport.hh | 16 | ||||
-rw-r--r-- | src/mem/ruby/system/MemoryControl.hh | 2 | ||||
-rw-r--r-- | src/mem/ruby/system/RubyMemoryControl.cc | 2 | ||||
-rw-r--r-- | src/mem/ruby/system/RubyMemoryControl.hh | 2 | ||||
-rw-r--r-- | src/mem/ruby/system/RubyPort.cc | 36 | ||||
-rw-r--r-- | src/mem/ruby/system/RubyPort.hh | 6 | ||||
-rw-r--r-- | src/mem/ruby/system/Sequencer.cc | 5 | ||||
-rw-r--r-- | src/mem/simple_dram.cc | 24 | ||||
-rw-r--r-- | src/mem/simple_dram.hh | 6 | ||||
-rw-r--r-- | src/mem/simple_mem.cc | 8 | ||||
-rw-r--r-- | src/mem/simple_mem.hh | 2 |
21 files changed, 86 insertions, 103 deletions
diff --git a/src/mem/bus.cc b/src/mem/bus.cc index a0db6e52a..ddbdcb136 100644 --- a/src/mem/bus.cc +++ b/src/mem/bus.cc @@ -161,7 +161,8 @@ BaseBus::calcPacketTiming(PacketPtr pkt) template <typename PortClass> BaseBus::Layer<PortClass>::Layer(BaseBus& _bus, const std::string& _name, Tick _clock) : - bus(_bus), _name(_name), state(IDLE), clock(_clock), drainEvent(NULL), + Drainable(), + bus(_bus), _name(_name), state(IDLE), clock(_clock), drainManager(NULL), releaseEvent(this) { } @@ -266,12 +267,12 @@ BaseBus::Layer<PortClass>::releaseLayer() // busy, and in the latter case the bus may be released before // we see a retry from the destination retryWaiting(); - } else if (drainEvent) { - DPRINTF(Drain, "Bus done draining, processing drain event\n"); + } else if (drainManager) { + DPRINTF(Drain, "Bus done draining, signaling drain manager\n"); //If we weren't able to drain before, do it now. - drainEvent->process(); + drainManager->signalDrainDone(); // Clear the drain event once we're done with it. - drainEvent = NULL; + drainManager = NULL; } } @@ -522,14 +523,14 @@ BaseBus::deviceBlockSize() const template <typename PortClass> unsigned int -BaseBus::Layer<PortClass>::drain(Event * de) +BaseBus::Layer<PortClass>::drain(DrainManager *dm) { //We should check that we're not "doing" anything, and that noone is //waiting. We might be idle but have someone waiting if the device we //contacted for a retry didn't actually retry. if (!retryList.empty() || state != IDLE) { DPRINTF(Drain, "Bus not drained\n"); - drainEvent = de; + drainManager = dm; return 1; } return 0; diff --git a/src/mem/bus.hh b/src/mem/bus.hh index f3cbc9d24..19ffa020c 100644 --- a/src/mem/bus.hh +++ b/src/mem/bus.hh @@ -94,7 +94,7 @@ class BaseBus : public MemObject * whereas a response layer holds master ports. */ template <typename PortClass> - class Layer + class Layer : public Drainable { public: @@ -118,7 +118,7 @@ class BaseBus : public MemObject * * @return 1 if busy or waiting to retry, or 0 if idle */ - unsigned int drain(Event *de); + unsigned int drain(DrainManager *dm); /** * Get the bus layer's name @@ -206,8 +206,8 @@ class BaseBus : public MemObject /** the clock speed for the bus layer */ Tick clock; - /** event for signalling when drained */ - Event * drainEvent; + /** manager to signal when drained */ + DrainManager *drainManager; /** * An array of ports that retry should be called @@ -366,7 +366,7 @@ class BaseBus : public MemObject BaseSlavePort& getSlavePort(const std::string& if_name, PortID idx = InvalidPortID); - virtual unsigned int drain(Event *de) = 0; + virtual unsigned int drain(DrainManager *dm) = 0; }; diff --git a/src/mem/cache/base.cc b/src/mem/cache/base.cc index a88749627..ad1c751bc 100644 --- a/src/mem/cache/base.cc +++ b/src/mem/cache/base.cc @@ -77,7 +77,7 @@ BaseCache::BaseCache(const Params *p) blocked(0), noTargetMSHR(NULL), missCount(p->max_miss_count), - drainEvent(NULL), + drainManager(NULL), addrRanges(p->addr_ranges.begin(), p->addr_ranges.end()), system(p->system) { @@ -749,19 +749,19 @@ BaseCache::regStats() } unsigned int -BaseCache::drain(Event *de) +BaseCache::drain(DrainManager *dm) { - int count = memSidePort->drain(de) + cpuSidePort->drain(de); + int count = memSidePort->drain(dm) + cpuSidePort->drain(dm); // Set status if (count != 0) { - drainEvent = de; + drainManager = dm; - changeState(SimObject::Draining); + setDrainState(Drainable::Draining); DPRINTF(Drain, "Cache not drained\n"); return count; } - changeState(SimObject::Drained); + setDrainState(Drainable::Drained); return 0; } diff --git a/src/mem/cache/base.hh b/src/mem/cache/base.hh index 42ade9b0b..ab13be771 100644 --- a/src/mem/cache/base.hh +++ b/src/mem/cache/base.hh @@ -269,7 +269,7 @@ class BaseCache : public MemObject Counter missCount; /** The drain event. */ - Event *drainEvent; + DrainManager *drainManager; /** * The address range to which the cache responds on the CPU side. @@ -542,7 +542,7 @@ class BaseCache : public MemObject // interesting again. } - virtual unsigned int drain(Event *de); + virtual unsigned int drain(DrainManager *dm); virtual bool inCache(Addr addr) = 0; diff --git a/src/mem/coherent_bus.cc b/src/mem/coherent_bus.cc index 98d86f3f0..b1ac6dbcf 100644 --- a/src/mem/coherent_bus.cc +++ b/src/mem/coherent_bus.cc @@ -508,10 +508,10 @@ CoherentBus::forwardFunctional(PacketPtr pkt, PortID exclude_slave_port_id) } unsigned int -CoherentBus::drain(Event *de) +CoherentBus::drain(DrainManager *dm) { // sum up the individual layers - return reqLayer.drain(de) + respLayer.drain(de) + snoopRespLayer.drain(de); + return reqLayer.drain(dm) + respLayer.drain(dm) + snoopRespLayer.drain(dm); } CoherentBus * diff --git a/src/mem/coherent_bus.hh b/src/mem/coherent_bus.hh index 89a759546..61406608b 100644 --- a/src/mem/coherent_bus.hh +++ b/src/mem/coherent_bus.hh @@ -299,7 +299,7 @@ class CoherentBus : public BaseBus CoherentBus(const CoherentBusParams *p); - unsigned int drain(Event *de); + unsigned int drain(DrainManager *dm); }; #endif //__MEM_COHERENT_BUS_HH__ diff --git a/src/mem/noncoherent_bus.cc b/src/mem/noncoherent_bus.cc index 237e8726b..f14f6e3d6 100644 --- a/src/mem/noncoherent_bus.cc +++ b/src/mem/noncoherent_bus.cc @@ -212,10 +212,10 @@ NoncoherentBus::recvFunctional(PacketPtr pkt, PortID slave_port_id) } unsigned int -NoncoherentBus::drain(Event *de) +NoncoherentBus::drain(DrainManager *dm) { // sum up the individual layers - return reqLayer.drain(de) + respLayer.drain(de); + return reqLayer.drain(dm) + respLayer.drain(dm); } NoncoherentBus* diff --git a/src/mem/noncoherent_bus.hh b/src/mem/noncoherent_bus.hh index 16cf7deda..a42c26b2e 100644 --- a/src/mem/noncoherent_bus.hh +++ b/src/mem/noncoherent_bus.hh @@ -207,7 +207,7 @@ class NoncoherentBus : public BaseBus NoncoherentBus(const NoncoherentBusParams *p); - unsigned int drain(Event *de); + unsigned int drain(DrainManager *dm); }; diff --git a/src/mem/packet_queue.cc b/src/mem/packet_queue.cc index 4a4543f61..eb94cc397 100644 --- a/src/mem/packet_queue.cc +++ b/src/mem/packet_queue.cc @@ -48,7 +48,7 @@ using namespace std; PacketQueue::PacketQueue(EventManager& _em, const std::string& _label) - : em(_em), sendEvent(this), drainEvent(NULL), label(_label), + : em(_em), sendEvent(this), drainManager(NULL), label(_label), waitingOnRetry(false) { } @@ -173,11 +173,11 @@ PacketQueue::scheduleSend(Tick time) em.schedule(&sendEvent, std::max(nextReady, curTick() + 1)); } else { // no more to send, so if we're draining, we may be done - if (drainEvent && transmitList.empty() && !sendEvent.scheduled()) { + if (drainManager && transmitList.empty() && !sendEvent.scheduled()) { DPRINTF(Drain, "PacketQueue done draining," "processing drain event\n"); - drainEvent->process(); - drainEvent = NULL; + drainManager->signalDrainDone(); + drainManager = NULL; } } } @@ -204,12 +204,12 @@ PacketQueue::processSendEvent() } unsigned int -PacketQueue::drain(Event *de) +PacketQueue::drain(DrainManager *dm) { if (transmitList.empty() && !sendEvent.scheduled()) return 0; DPRINTF(Drain, "PacketQueue not drained\n"); - drainEvent = de; + drainManager = dm; return 1; } diff --git a/src/mem/packet_queue.hh b/src/mem/packet_queue.hh index 0171eb9a3..2321ec4f2 100644 --- a/src/mem/packet_queue.hh +++ b/src/mem/packet_queue.hh @@ -57,12 +57,13 @@ #include "mem/port.hh" #include "sim/eventq.hh" +#include "sim/drain.hh" /** * A packet queue is a class that holds deferred packets and later * sends them using the associated slave port or master port. */ -class PacketQueue +class PacketQueue : public Drainable { private: /** A deferred packet, buffered to transmit later. */ @@ -95,9 +96,9 @@ class PacketQueue **/ EventWrapper<PacketQueue, &PacketQueue::processSendEvent> sendEvent; - /** If we need to drain, keep the drain event around until we're done + /** If we need to drain, keep the drain manager around until we're done * here.*/ - Event *drainEvent; + DrainManager *drainManager; protected: @@ -207,13 +208,7 @@ class PacketQueue */ void retry(); - /** - * Hook for draining the packet queue. - * - * @param de An event which is used to signal back to the caller - * @return A number indicating how many times process will be called - */ - unsigned int drain(Event *de); + unsigned int drain(DrainManager *dm); }; class MasterPacketQueue : public PacketQueue diff --git a/src/mem/qport.hh b/src/mem/qport.hh index b771f6984..dd5caa084 100644 --- a/src/mem/qport.hh +++ b/src/mem/qport.hh @@ -97,13 +97,7 @@ class QueuedSlavePort : public SlavePort * functional request. */ bool checkFunctional(PacketPtr pkt) { return queue.checkFunctional(pkt); } - /** - * Hook for draining the queued port. - * - * @param de an event which is used to signal back to the caller - * @returns a number indicating how many times process will be called - */ - unsigned int drain(Event *de) { return queue.drain(de); } + unsigned int drain(DrainManager *dm) { return queue.drain(dm); } }; class QueuedMasterPort : public MasterPort @@ -156,13 +150,7 @@ class QueuedMasterPort : public MasterPort * functional request. */ bool checkFunctional(PacketPtr pkt) { return queue.checkFunctional(pkt); } - /** - * Hook for draining the queued port. - * - * @param de an event which is used to signal back to the caller - * @returns a number indicating how many times process will be called - */ - unsigned int drain(Event *de) { return queue.drain(de); } + unsigned int drain(DrainManager *dm) { return queue.drain(dm); } }; #endif // __MEM_QPORT_HH__ diff --git a/src/mem/ruby/system/MemoryControl.hh b/src/mem/ruby/system/MemoryControl.hh index 8d15b8dec..5c6adb0ab 100644 --- a/src/mem/ruby/system/MemoryControl.hh +++ b/src/mem/ruby/system/MemoryControl.hh @@ -56,8 +56,6 @@ class MemoryControl : public ClockedObject, public Consumer ~MemoryControl(); - unsigned int drain(Event *de) = 0; - virtual void wakeup() = 0; virtual void setConsumer(Consumer* consumer_ptr) = 0; diff --git a/src/mem/ruby/system/RubyMemoryControl.cc b/src/mem/ruby/system/RubyMemoryControl.cc index c0e91c28b..620113719 100644 --- a/src/mem/ruby/system/RubyMemoryControl.cc +++ b/src/mem/ruby/system/RubyMemoryControl.cc @@ -684,7 +684,7 @@ RubyMemoryControl::executeCycle() } unsigned int -RubyMemoryControl::drain(Event *de) +RubyMemoryControl::drain(DrainManager *dm) { DPRINTF(RubyMemory, "MemoryController drain\n"); if(m_event.scheduled()) { diff --git a/src/mem/ruby/system/RubyMemoryControl.hh b/src/mem/ruby/system/RubyMemoryControl.hh index 1f3a8acf5..53e8fabef 100644 --- a/src/mem/ruby/system/RubyMemoryControl.hh +++ b/src/mem/ruby/system/RubyMemoryControl.hh @@ -62,7 +62,7 @@ class RubyMemoryControl : public MemoryControl ~RubyMemoryControl(); - unsigned int drain(Event *de); + unsigned int drain(DrainManager *dm); void wakeup(); diff --git a/src/mem/ruby/system/RubyPort.cc b/src/mem/ruby/system/RubyPort.cc index 1259f0f15..dd9e9676e 100644 --- a/src/mem/ruby/system/RubyPort.cc +++ b/src/mem/ruby/system/RubyPort.cc @@ -53,7 +53,7 @@ RubyPort::RubyPort(const Params *p) m_mandatory_q_ptr(NULL), pio_port(csprintf("%s-pio-port", name()), this), m_usingRubyTester(p->using_ruby_tester), m_request_cnt(0), - drainEvent(NULL), ruby_system(p->ruby_system), system(p->system), + drainManager(NULL), ruby_system(p->ruby_system), system(p->system), waitingOnSequencer(false), access_phys_mem(p->access_phys_mem) { assert(m_version != -1); @@ -343,36 +343,36 @@ void RubyPort::testDrainComplete() { //If we weren't able to drain before, we might be able to now. - if (drainEvent != NULL) { + if (drainManager != NULL) { unsigned int drainCount = outstandingCount(); DPRINTF(Drain, "Drain count: %u\n", drainCount); if (drainCount == 0) { - DPRINTF(Drain, "RubyPort done draining, processing drain event\n"); - drainEvent->process(); - // Clear the drain event once we're done with it. - drainEvent = NULL; + DPRINTF(Drain, "RubyPort done draining, signaling drain done\n"); + drainManager->signalDrainDone(); + // Clear the drain manager once we're done with it. + drainManager = NULL; } } } unsigned int -RubyPort::getChildDrainCount(Event *de) +RubyPort::getChildDrainCount(DrainManager *dm) { int count = 0; if (pio_port.isConnected()) { - count += pio_port.drain(de); + count += pio_port.drain(dm); DPRINTF(Config, "count after pio check %d\n", count); } for (CpuPortIter p = slave_ports.begin(); p != slave_ports.end(); ++p) { - count += (*p)->drain(de); + count += (*p)->drain(dm); DPRINTF(Config, "count after slave port check %d\n", count); } for (std::vector<PioPort*>::iterator p = master_ports.begin(); p != master_ports.end(); ++p) { - count += (*p)->drain(de); + count += (*p)->drain(dm); DPRINTF(Config, "count after master port check %d\n", count); } @@ -382,7 +382,7 @@ RubyPort::getChildDrainCount(Event *de) } unsigned int -RubyPort::drain(Event *de) +RubyPort::drain(DrainManager *dm) { if (isDeadlockEventScheduled()) { descheduleDeadlockEvent(); @@ -390,28 +390,28 @@ RubyPort::drain(Event *de) // // If the RubyPort is not empty, then it needs to clear all outstanding - // requests before it should call drainEvent->process() + // requests before it should call drainManager->signalDrainDone() // DPRINTF(Config, "outstanding count %d\n", outstandingCount()); bool need_drain = outstandingCount() > 0; // // Also, get the number of child ports that will also need to clear - // their buffered requests before they call drainEvent->process() + // their buffered requests before they call drainManager->signalDrainDone() // - unsigned int child_drain_count = getChildDrainCount(de); + unsigned int child_drain_count = getChildDrainCount(dm); // Set status if (need_drain) { - drainEvent = de; + drainManager = dm; DPRINTF(Drain, "RubyPort not drained\n"); - changeState(SimObject::Draining); + setDrainState(Drainable::Draining); return child_drain_count + 1; } - drainEvent = NULL; - changeState(SimObject::Drained); + drainManager = NULL; + setDrainState(Drainable::Drained); return child_drain_count; } diff --git a/src/mem/ruby/system/RubyPort.hh b/src/mem/ruby/system/RubyPort.hh index ab09bd90a..98bcede44 100644 --- a/src/mem/ruby/system/RubyPort.hh +++ b/src/mem/ruby/system/RubyPort.hh @@ -142,7 +142,7 @@ class RubyPort : public MemObject // void setController(AbstractController* _cntrl) { m_controller = _cntrl; } int getId() { return m_version; } - unsigned int drain(Event *de); + unsigned int drain(DrainManager *dm); protected: const std::string m_name; @@ -166,7 +166,7 @@ class RubyPort : public MemObject } } - unsigned int getChildDrainCount(Event *de); + unsigned int getChildDrainCount(DrainManager *dm); uint16_t m_port_id; uint64_t m_request_cnt; @@ -176,7 +176,7 @@ class RubyPort : public MemObject std::vector<M5Port*> slave_ports; std::vector<PioPort*> master_ports; - Event *drainEvent; + DrainManager *drainManager; RubySystem* ruby_system; System* system; diff --git a/src/mem/ruby/system/Sequencer.cc b/src/mem/ruby/system/Sequencer.cc index 9b6ef35cd..a45dfc98d 100644 --- a/src/mem/ruby/system/Sequencer.cc +++ b/src/mem/ruby/system/Sequencer.cc @@ -85,7 +85,7 @@ Sequencer::~Sequencer() void Sequencer::wakeup() { - assert(getState() != SimObject::Draining); + assert(getDrainState() != Drainable::Draining); // Check for deadlock of any of the requests Time current_time = g_system_ptr->getTime(); @@ -209,7 +209,8 @@ Sequencer::insertRequest(PacketPtr pkt, RubyRequestType request_type) (m_writeRequestTable.size() + m_readRequestTable.size())); // See if we should schedule a deadlock check - if (!deadlockCheckEvent.scheduled() && getState() != SimObject::Draining) { + if (!deadlockCheckEvent.scheduled() && + getDrainState() != Drainable::Draining) { schedule(deadlockCheckEvent, g_system_ptr->clockPeriod() * m_deadlock_threshold + curTick()); } diff --git a/src/mem/simple_dram.cc b/src/mem/simple_dram.cc index 0f6e9511c..42c97977a 100644 --- a/src/mem/simple_dram.cc +++ b/src/mem/simple_dram.cc @@ -51,7 +51,7 @@ SimpleDRAM::SimpleDRAM(const SimpleDRAMParams* p) : retryRdReq(false), retryWrReq(false), rowHitFlag(false), stopReads(false), writeEvent(this), respondEvent(this), - refreshEvent(this), nextReqEvent(this), drainEvent(NULL), + refreshEvent(this), nextReqEvent(this), drainManager(NULL), bytesPerCacheLine(0), linesPerRowBuffer(p->lines_per_rowbuffer), ranksPerChannel(p->ranks_per_channel), @@ -346,9 +346,9 @@ SimpleDRAM::processWriteEvent() // if there is nothing left in any queue, signal a drain if (dramWriteQueue.empty() && dramReadQueue.empty() && - dramRespQueue.empty () && drainEvent) { - drainEvent->process(); - drainEvent = NULL; + dramRespQueue.empty () && drainManager) { + drainManager->signalDrainDone(); + drainManager = NULL; } // Once you're done emptying the write queue, check if there's @@ -595,9 +595,9 @@ SimpleDRAM::processRespondEvent() } else { // if there is nothing left in any queue, signal a drain if (dramWriteQueue.empty() && dramReadQueue.empty() && - drainEvent) { - drainEvent->process(); - drainEvent = NULL; + drainManager) { + drainManager->signalDrainDone(); + drainManager = NULL; } } } @@ -1197,22 +1197,22 @@ SimpleDRAM::getSlavePort(const string &if_name, PortID idx) } unsigned int -SimpleDRAM::drain(Event *de) +SimpleDRAM::drain(DrainManager *dm) { - unsigned int count = port.drain(de); + unsigned int count = port.drain(dm); // if there is anything in any of our internal queues, keep track // of that as well if (!(dramWriteQueue.empty() && dramReadQueue.empty() && dramRespQueue.empty())) { ++count; - drainEvent = de; + drainManager = dm; } if (count) - changeState(Draining); + setDrainState(Drainable::Draining); else - changeState(Drained); + setDrainState(Drainable::Drained); return count; } diff --git a/src/mem/simple_dram.hh b/src/mem/simple_dram.hh index 74058afaa..373408c2a 100644 --- a/src/mem/simple_dram.hh +++ b/src/mem/simple_dram.hh @@ -341,10 +341,10 @@ class SimpleDRAM : public AbstractMemory */ std::list<DRAMPacket*> dramRespQueue; - /** If we need to drain, keep the drain event around until we're done + /** If we need to drain, keep the drain manager around until we're done * here. */ - Event *drainEvent; + DrainManager *drainManager; /** * Multi-dimensional vector of banks, first dimension is ranks, @@ -459,7 +459,7 @@ class SimpleDRAM : public AbstractMemory SimpleDRAM(const SimpleDRAMParams* p); - unsigned int drain(Event* de); + unsigned int drain(DrainManager* dm); virtual BaseSlavePort& getSlavePort(const std::string& if_name, PortID idx = InvalidPortID); diff --git a/src/mem/simple_mem.cc b/src/mem/simple_mem.cc index c54e8e5ea..e78b57928 100644 --- a/src/mem/simple_mem.cc +++ b/src/mem/simple_mem.cc @@ -176,14 +176,14 @@ SimpleMemory::getSlavePort(const std::string &if_name, PortID idx) } unsigned int -SimpleMemory::drain(Event *de) +SimpleMemory::drain(DrainManager *dm) { - int count = port.drain(de); + int count = port.drain(dm); if (count) - changeState(Draining); + setDrainState(Drainable::Draining); else - changeState(Drained); + setDrainState(Drainable::Drained); return count; } diff --git a/src/mem/simple_mem.hh b/src/mem/simple_mem.hh index 7fd64db47..f1bad7d9f 100644 --- a/src/mem/simple_mem.hh +++ b/src/mem/simple_mem.hh @@ -123,7 +123,7 @@ class SimpleMemory : public AbstractMemory SimpleMemory(const SimpleMemoryParams *p); virtual ~SimpleMemory() { } - unsigned int drain(Event* de); + unsigned int drain(DrainManager *dm); virtual BaseSlavePort& getSlavePort(const std::string& if_name, PortID idx = InvalidPortID); |