From 503a40be7b52d5d0a65edbf016ade8e74d8c82c6 Mon Sep 17 00:00:00 2001 From: Richard Hellwig Date: Fri, 3 May 2013 15:53:43 +0200 Subject: [PATCH] gem5: save/restore moved to Gem5Controller Change-Id: I5bda346f29d74fdfc67f73f0af83ed1e006d8616 --- src/core/sal/gem5/Gem5Connector.cc | 28 ------------------------ src/core/sal/gem5/Gem5Connector.hpp | 23 ------------------- src/core/sal/gem5/Gem5Controller.cc | 34 +++++++++++++++++++++++------ 3 files changed, 27 insertions(+), 58 deletions(-) delete mode 100644 src/core/sal/gem5/Gem5Connector.cc delete mode 100644 src/core/sal/gem5/Gem5Connector.hpp diff --git a/src/core/sal/gem5/Gem5Connector.cc b/src/core/sal/gem5/Gem5Connector.cc deleted file mode 100644 index 81ef19ba..00000000 --- a/src/core/sal/gem5/Gem5Connector.cc +++ /dev/null @@ -1,28 +0,0 @@ -#if 0 -#include "Gem5Connector.hpp" - -#include "base/trace.hh" -#include "debug/FailState.hh" -#include "sim/root.hh" - -Gem5Connector connector; - -void Gem5Connector::save(const std::string &path) -{ - DPRINTF(FailState, "Saving state to %s.\n", path); - - Root* root = Root::root(); - root->Serializable::serializeAll(path); -} - -void Gem5Connector::restore(const std::string &path) -{ - DPRINTF(FailState, "Restoring state from %s.\n", path); - - Root* root = Root::root(); - Checkpoint cp(path); - - root->loadState(&cp); -} - -#endif diff --git a/src/core/sal/gem5/Gem5Connector.hpp b/src/core/sal/gem5/Gem5Connector.hpp deleted file mode 100644 index 25631223..00000000 --- a/src/core/sal/gem5/Gem5Connector.hpp +++ /dev/null @@ -1,23 +0,0 @@ -#if 0 -// TODO: Incorporate this code into Gem5Controller.{hpp,cc} - -#ifndef __GEM5_CONNECTOR_HPP__ - #define __GEM5_CONNECTOR_HPP__ - -#include - -/** - * \class Gem5Connector - * This class will be compiled inside the gem5 context and provides the - * Gem5Controller a way to call gem5 functions. - */ -class Gem5Connector { -public: - void save(const std::string &path); - void restore(const std::string &path); -}; - -extern Gem5Connector connector; - -#endif // __GEM5_CONNECTOR_HPP__ -#endif diff --git a/src/core/sal/gem5/Gem5Controller.cc b/src/core/sal/gem5/Gem5Controller.cc index e5b2a1af..11e58403 100644 --- a/src/core/sal/gem5/Gem5Controller.cc +++ b/src/core/sal/gem5/Gem5Controller.cc @@ -1,9 +1,11 @@ #include "Gem5Controller.hpp" -//#include "Gem5Connector.hpp" - -#include "../Listener.hpp" - #include "Gem5Wrapper.hpp" +#include "../Listener.hpp" +#include "base/trace.hh" +#include "debug/FailState.hh" +#include "sim/root.hh" + +#include namespace fail { @@ -36,14 +38,32 @@ Gem5Controller::~Gem5Controller() bool Gem5Controller::save(const std::string &path) { -// connector.save(path); // FIXME: not working?! + DPRINTF(FailState, "Saving state to %s.\n", path); - return true; + Root* root = Root::root(); + root->Serializable::serializeAll(path); + + // Test if save was successful + std::ifstream save_test; + + save_test.open((path+"/m5.cpt").c_str(), std::ios_base::in); + + if (save_test) { + save_test.close(); + return true; + } else { + save_test.close(); + return false; + } } void Gem5Controller::restore(const std::string &path) { -// connector.restore(path); // FIXME: not working?! + // FIXME: not working currently + Root* root = Root::root(); + Checkpoint cp(path); + + root->loadState(&cp); } // TODO: Implement reboot