diff options
author | Andreas Sandberg <andreas.sandberg@arm.com> | 2015-07-07 09:51:04 +0100 |
---|---|---|
committer | Andreas Sandberg <andreas.sandberg@arm.com> | 2015-07-07 09:51:04 +0100 |
commit | e9c3d59aae58f8fcf77ce5cf4b985dc9e2a90de2 (patch) | |
tree | 799c50d9a0b99f1623a16d9c1d49f4cb0d1fcbaf /src/sim | |
parent | 1dc5e63b889647a153f01351f560a3beaa41f293 (diff) | |
download | gem5-e9c3d59aae58f8fcf77ce5cf4b985dc9e2a90de2.tar.xz |
sim: Make the drain state a global typed enum
The drain state enum is currently a part of the Drainable
interface. The same state machine will be used by the DrainManager to
identify the global state of the simulator. Make the drain state a
global typed enum to better cater for this usage scenario.
Diffstat (limited to 'src/sim')
-rw-r--r-- | src/sim/drain.cc | 6 | ||||
-rw-r--r-- | src/sim/drain.hh | 62 | ||||
-rw-r--r-- | src/sim/sim_object.cc | 2 | ||||
-rw-r--r-- | src/sim/system.cc | 4 |
4 files changed, 37 insertions, 37 deletions
diff --git a/src/sim/drain.cc b/src/sim/drain.cc index 3daf762f6..90fb0c18d 100644 --- a/src/sim/drain.cc +++ b/src/sim/drain.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012 ARM Limited + * Copyright (c) 2012, 2015 ARM Limited * All rights reserved * * The license below extends only to copyright in the software and shall @@ -58,7 +58,7 @@ DrainManager::drainCycleDone() Drainable::Drainable() - : _drainState(Running) + : _drainState(DrainState::Running) { } @@ -69,5 +69,5 @@ Drainable::~Drainable() void Drainable::drainResume() { - _drainState = Running; + _drainState = DrainState::Running; } diff --git a/src/sim/drain.hh b/src/sim/drain.hh index 6f0769f34..ae80fb7e9 100644 --- a/src/sim/drain.hh +++ b/src/sim/drain.hh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012 ARM Limited + * Copyright (c) 2012, 2015 ARM Limited * All rights reserved * * The license below extends only to copyright in the software and shall @@ -45,7 +45,33 @@ #include "base/flags.hh" -class Event; +class Drainable; + +#ifndef SWIG // SWIG doesn't support strongly typed enums +/** + * Object drain/handover states + * + * An object starts out in the Running state. When the simulator + * prepares to take a snapshot or prepares a CPU for handover, it + * calls the drain() method to transfer the object into the Draining + * or Drained state. If any object enters the Draining state + * (Drainable::drain() returning >0), simulation continues until it + * all objects have entered the Drained state. + * + * Before resuming simulation, the simulator calls resume() to + * transfer the object to the Running state. + * + * \note Even though the state of an object (visible to the rest of + * the world through Drainable::getState()) could be used to determine + * if all objects have entered the Drained state, the protocol is + * actually a bit more elaborate. See Drainable::drain() for details. + */ +enum class DrainState { + Running, /** Running normally */ + Draining, /** Draining buffers pending serialization/handover */ + Drained /** Buffers drained, ready for serialization/handover */ +}; +#endif /** * This class coordinates draining of a System. @@ -141,30 +167,6 @@ class DrainManager class Drainable { public: - /** - * Object drain/handover states - * - * An object starts out in the Running state. When the simulator - * prepares to take a snapshot or prepares a CPU for handover, it - * calls the drain() method to transfer the object into the - * Draining or Drained state. If any object enters the Draining - * state (drain() returning >0), simulation continues until it all - * objects have entered the Drained state. - * - * Before resuming simulation, the simulator calls resume() to - * transfer the object to the Running state. - * - * \note Even though the state of an object (visible to the rest - * of the world through getState()) could be used to determine if - * all objects have entered the Drained state, the protocol is - * actually a bit more elaborate. See drain() for details. - */ - enum State { - Running, /** Running normally */ - Draining, /** Draining buffers pending serialization/handover */ - Drained /** Buffers drained, ready for serialization/handover */ - }; - Drainable(); virtual ~Drainable(); @@ -225,15 +227,13 @@ class Drainable */ virtual void memInvalidate() {}; - State getDrainState() const { return _drainState; } + DrainState getDrainState() const { return _drainState; } protected: - void setDrainState(State new_state) { _drainState = new_state; } - + void setDrainState(DrainState new_state) { _drainState = new_state; } private: - State _drainState; - + DrainState _drainState; }; DrainManager *createDrainManager(); diff --git a/src/sim/sim_object.cc b/src/sim/sim_object.cc index 2c4ba48f6..9ea51eb93 100644 --- a/src/sim/sim_object.cc +++ b/src/sim/sim_object.cc @@ -183,7 +183,7 @@ debugObjectBreak(const char *objs) unsigned int SimObject::drain(DrainManager *drain_manager) { - setDrainState(Drained); + setDrainState(DrainState::Drained); return 0; } diff --git a/src/sim/system.cc b/src/sim/system.cc index f781377f7..3d4737617 100644 --- a/src/sim/system.cc +++ b/src/sim/system.cc @@ -191,7 +191,7 @@ System::getMasterPort(const std::string &if_name, PortID idx) void System::setMemoryMode(Enums::MemoryMode mode) { - assert(getDrainState() == Drainable::Drained); + assert(getDrainState() == DrainState::Drained); memoryMode = mode; } @@ -358,7 +358,7 @@ System::isMemAddr(Addr addr) const unsigned int System::drain(DrainManager *dm) { - setDrainState(Drainable::Drained); + setDrainState(DrainState::Drained); return 0; } |