Merge "gem5: restore works now"
This commit is contained in:
@ -15,6 +15,9 @@ void Gem5Controller::startup()
|
||||
m_System = GetSystemObject();
|
||||
m_Mem = new Gem5MemoryManager(m_System);
|
||||
|
||||
restore_request = false;
|
||||
restore_path = "";
|
||||
|
||||
int numCtxs = GetNumberOfContexts(m_System);
|
||||
for (int i = 0; i < numCtxs; i++) {
|
||||
ConcreteCPU* cpu = new ConcreteCPU(GetCPUId(m_System, i), m_System);
|
||||
@ -53,13 +56,53 @@ bool Gem5Controller::save(const std::string &path)
|
||||
}
|
||||
}
|
||||
|
||||
void Gem5Controller::restore(const std::string &path)
|
||||
void Gem5Controller::restore(const std::string& path)
|
||||
{
|
||||
// FIXME: not working currently
|
||||
Root* root = Root::root();
|
||||
Checkpoint cp(path);
|
||||
clearListeners();
|
||||
restore_request = true;
|
||||
restore_path = path;
|
||||
m_CurrFlow = m_Flows.getCurrent();
|
||||
m_Flows.resume();
|
||||
}
|
||||
|
||||
void Gem5Controller::onRestore()
|
||||
{
|
||||
/* Get the instance of the root-object from gem5
|
||||
* The root object seems to be the root of a tree
|
||||
* that contains all the simulation objects, e.g.
|
||||
* cpu, memory etc.
|
||||
* gem5/src/sim/root.cc,root.hh
|
||||
* */
|
||||
Root* root = Root::root();
|
||||
/* Checkpoint is a class of gem5 that is used to
|
||||
* manage the built-in save and restore function
|
||||
* of gem5.
|
||||
* gem5/src/sim/serialize.cc,serialize.hh
|
||||
* */
|
||||
Checkpoint cp(restore_path);
|
||||
/* Set some global variables from checkpoint.
|
||||
* gem5/src/sim/serialize.cc,serialize.hh
|
||||
* */
|
||||
Serializable::unserializeGlobals(&cp);
|
||||
/* loadStateAll(Checkpoint *cp) is a self-implemented
|
||||
* function that calls loadState() for all simulation
|
||||
* objects. (without the root object).
|
||||
* gem5/src/sim/serialize.cc,serialize.hh
|
||||
* gem5/src/sim/sim_object.cc,sim_object.hh
|
||||
* */
|
||||
Serializable::loadStateAll(&cp);
|
||||
/* Call loadState() on the root-object.
|
||||
* gem5/src/sim/root.cc,root.hh
|
||||
* */
|
||||
root->loadState(&cp);
|
||||
|
||||
restore_request = false;
|
||||
m_Flows.toggle(m_CurrFlow);
|
||||
}
|
||||
|
||||
bool Gem5Controller::isRestoreRequest()
|
||||
{
|
||||
return restore_request;
|
||||
}
|
||||
|
||||
// TODO: Implement reboot
|
||||
|
||||
@ -22,16 +22,21 @@ namespace fail {
|
||||
class Gem5Controller : public SimulatorController {
|
||||
private:
|
||||
System* m_System; //!< the gem5 system object
|
||||
ExperimentFlow* m_CurrFlow; //!< Stores the current flow for save/restore-operations
|
||||
#if defined(CONFIG_EVENT_BREAKPOINTS) ||\
|
||||
defined(CONFIG_EVENT_BREAKPOINTS_RANGE)
|
||||
std::string m_Mnemonic; //!< mnemonic of the instr. (only with BPs)
|
||||
#endif
|
||||
bool restore_request;
|
||||
std::string restore_path;
|
||||
public:
|
||||
void startup();
|
||||
~Gem5Controller();
|
||||
|
||||
bool save(const std::string &path);
|
||||
void restore(const std::string &path);
|
||||
void onRestore();
|
||||
bool isRestoreRequest();
|
||||
void reboot();
|
||||
#if defined(CONFIG_EVENT_BREAKPOINTS) ||\
|
||||
defined(CONFIG_EVENT_BREAKPOINTS_RANGE)
|
||||
|
||||
Reference in New Issue
Block a user