diff options
Diffstat (limited to 'src/cpu/simple')
-rw-r--r-- | src/cpu/simple/atomic.cc | 19 | ||||
-rw-r--r-- | src/cpu/simple/atomic.hh | 11 | ||||
-rw-r--r-- | src/cpu/simple/timing.cc | 20 | ||||
-rw-r--r-- | src/cpu/simple/timing.hh | 11 |
4 files changed, 19 insertions, 42 deletions
diff --git a/src/cpu/simple/atomic.cc b/src/cpu/simple/atomic.cc index 4c1c45355..3777ddee9 100644 --- a/src/cpu/simple/atomic.cc +++ b/src/cpu/simple/atomic.cc @@ -108,7 +108,6 @@ AtomicSimpleCPU::AtomicSimpleCPU(AtomicSimpleCPUParams *p) : BaseSimpleCPU(p), tickEvent(this), width(p->width), locked(false), simulate_data_stalls(p->simulate_data_stalls), simulate_inst_stalls(p->simulate_inst_stalls), - drain_manager(NULL), icachePort(name() + ".icache_port", this), dcachePort(name() + ".dcache_port", this), fastmem(p->fastmem), dcache_access(false), dcache_latency(0), @@ -125,23 +124,21 @@ AtomicSimpleCPU::~AtomicSimpleCPU() } } -unsigned int -AtomicSimpleCPU::drain(DrainManager *dm) +DrainState +AtomicSimpleCPU::drain() { - assert(!drain_manager); if (switchedOut()) - return 0; + return DrainState::Drained; if (!isDrained()) { DPRINTF(Drain, "Requesting drain: %s\n", pcState()); - drain_manager = dm; - return 1; + return DrainState::Draining; } else { if (tickEvent.scheduled()) deschedule(tickEvent); DPRINTF(Drain, "Not executing microcode, no need to drain.\n"); - return 0; + return DrainState::Drained; } } @@ -149,7 +146,6 @@ void AtomicSimpleCPU::drainResume() { assert(!tickEvent.scheduled()); - assert(!drain_manager); if (switchedOut()) return; @@ -173,7 +169,7 @@ AtomicSimpleCPU::drainResume() bool AtomicSimpleCPU::tryCompleteDrain() { - if (!drain_manager) + if (drainState() != DrainState::Draining) return false; DPRINTF(Drain, "tryCompleteDrain: %s\n", pcState()); @@ -181,8 +177,7 @@ AtomicSimpleCPU::tryCompleteDrain() return false; DPRINTF(Drain, "CPU done draining, processing drain event\n"); - drain_manager->signalDrainDone(); - drain_manager = NULL; + signalDrainDone(); return true; } diff --git a/src/cpu/simple/atomic.hh b/src/cpu/simple/atomic.hh index 5ad5c4305..3f587e671 100644 --- a/src/cpu/simple/atomic.hh +++ b/src/cpu/simple/atomic.hh @@ -74,13 +74,6 @@ class AtomicSimpleCPU : public BaseSimpleCPU const bool simulate_data_stalls; const bool simulate_inst_stalls; - /** - * Drain manager to use when signaling drain completion - * - * This pointer is non-NULL when draining and NULL otherwise. - */ - DrainManager *drain_manager; - // main simulation loop (one cycle) void tick(); @@ -192,8 +185,8 @@ class AtomicSimpleCPU : public BaseSimpleCPU public: - unsigned int drain(DrainManager *drain_manager); - void drainResume(); + DrainState drain() M5_ATTR_OVERRIDE; + void drainResume() M5_ATTR_OVERRIDE; void switchOut(); void takeOverFrom(BaseCPU *oldCPU); diff --git a/src/cpu/simple/timing.cc b/src/cpu/simple/timing.cc index a3c4e27e8..5dc042f1e 100644 --- a/src/cpu/simple/timing.cc +++ b/src/cpu/simple/timing.cc @@ -91,7 +91,7 @@ TimingSimpleCPU::TimingCPUPort::TickEvent::schedule(PacketPtr _pkt, Tick t) TimingSimpleCPU::TimingSimpleCPU(TimingSimpleCPUParams *p) : BaseSimpleCPU(p), fetchTranslation(this), icachePort(this), dcachePort(this), ifetch_pkt(NULL), dcache_pkt(NULL), previousCycle(0), - fetchEvent(this), drainManager(NULL) + fetchEvent(this) { _status = Idle; } @@ -102,19 +102,17 @@ TimingSimpleCPU::~TimingSimpleCPU() { } -unsigned int -TimingSimpleCPU::drain(DrainManager *drain_manager) +DrainState +TimingSimpleCPU::drain() { - assert(!drainManager); if (switchedOut()) - return 0; + return DrainState::Drained; if (_status == Idle || (_status == BaseSimpleCPU::Running && isDrained())) { DPRINTF(Drain, "No need to drain.\n"); - return 0; + return DrainState::Drained; } else { - drainManager = drain_manager; DPRINTF(Drain, "Requesting drain: %s\n", pcState()); // The fetch event can become descheduled if a drain didn't @@ -123,7 +121,7 @@ TimingSimpleCPU::drain(DrainManager *drain_manager) if (_status == BaseSimpleCPU::Running && !fetchEvent.scheduled()) schedule(fetchEvent, clockEdge()); - return 1; + return DrainState::Draining; } } @@ -131,7 +129,6 @@ void TimingSimpleCPU::drainResume() { assert(!fetchEvent.scheduled()); - assert(!drainManager); if (switchedOut()) return; @@ -155,7 +152,7 @@ TimingSimpleCPU::drainResume() bool TimingSimpleCPU::tryCompleteDrain() { - if (!drainManager) + if (drainState() != DrainState::Draining) return false; DPRINTF(Drain, "tryCompleteDrain: %s\n", pcState()); @@ -163,8 +160,7 @@ TimingSimpleCPU::tryCompleteDrain() return false; DPRINTF(Drain, "CPU done draining, processing drain event\n"); - drainManager->signalDrainDone(); - drainManager = NULL; + signalDrainDone(); return true; } diff --git a/src/cpu/simple/timing.hh b/src/cpu/simple/timing.hh index 3ce596fc7..b6a1da4e2 100644 --- a/src/cpu/simple/timing.hh +++ b/src/cpu/simple/timing.hh @@ -270,8 +270,8 @@ class TimingSimpleCPU : public BaseSimpleCPU public: - unsigned int drain(DrainManager *drain_manager); - void drainResume(); + DrainState drain() M5_ATTR_OVERRIDE; + void drainResume() M5_ATTR_OVERRIDE; void switchOut(); void takeOverFrom(BaseCPU *oldCPU); @@ -351,13 +351,6 @@ class TimingSimpleCPU : public BaseSimpleCPU * @returns true if the CPU is drained, false otherwise. */ bool tryCompleteDrain(); - - /** - * Drain manager to use when signaling drain completion - * - * This pointer is non-NULL when draining and NULL otherwise. - */ - DrainManager *drainManager; }; #endif // __CPU_SIMPLE_TIMING_HH__ |