summaryrefslogtreecommitdiff
path: root/src/mem
diff options
context:
space:
mode:
Diffstat (limited to 'src/mem')
-rw-r--r--src/mem/cache/cache.hh4
-rw-r--r--src/mem/cache/cache_impl.hh4
-rw-r--r--src/mem/multi_level_page_table.hh4
-rw-r--r--src/mem/multi_level_page_table_impl.hh9
-rw-r--r--src/mem/page_table.cc40
-rw-r--r--src/mem/page_table.hh11
-rw-r--r--src/mem/physical.cc29
-rw-r--r--src/mem/physical.hh10
-rw-r--r--src/mem/ruby/system/System.cc8
-rw-r--r--src/mem/ruby/system/System.hh4
10 files changed, 56 insertions, 67 deletions
diff --git a/src/mem/cache/cache.hh b/src/mem/cache/cache.hh
index 4c70d3a40..27d4b9ee1 100644
--- a/src/mem/cache/cache.hh
+++ b/src/mem/cache/cache.hh
@@ -429,8 +429,8 @@ class Cache : public BaseCache
/** serialize the state of the caches
* We currently don't support checkpointing cache state, so this panics.
*/
- virtual void serialize(std::ostream &os);
- void unserialize(Checkpoint *cp, const std::string &section);
+ void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+ void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
};
/**
diff --git a/src/mem/cache/cache_impl.hh b/src/mem/cache/cache_impl.hh
index 94a3ad4ee..03593554a 100644
--- a/src/mem/cache/cache_impl.hh
+++ b/src/mem/cache/cache_impl.hh
@@ -2292,7 +2292,7 @@ Cache::nextMSHRReadyTime() const
}
void
-Cache::serialize(std::ostream &os)
+Cache::serialize(CheckpointOut &cp) const
{
bool dirty(isDirty());
@@ -2312,7 +2312,7 @@ Cache::serialize(std::ostream &os)
}
void
-Cache::unserialize(Checkpoint *cp, const std::string &section)
+Cache::unserialize(CheckpointIn &cp)
{
bool bad_checkpoint;
UNSERIALIZE_SCALAR(bad_checkpoint);
diff --git a/src/mem/multi_level_page_table.hh b/src/mem/multi_level_page_table.hh
index 232121c21..f622bbbed 100644
--- a/src/mem/multi_level_page_table.hh
+++ b/src/mem/multi_level_page_table.hh
@@ -153,7 +153,7 @@ public:
void unmap(Addr vaddr, int64_t size);
bool isUnmapped(Addr vaddr, int64_t size);
bool lookup(Addr vaddr, TheISA::TlbEntry &entry);
- void serialize(std::ostream &os);
- void unserialize(Checkpoint *cp, const std::string &section);
+ void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+ void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
};
#endif // __MEM_MULTI_LEVEL_PAGE_TABLE_HH__
diff --git a/src/mem/multi_level_page_table_impl.hh b/src/mem/multi_level_page_table_impl.hh
index 6714a170e..610240562 100644
--- a/src/mem/multi_level_page_table_impl.hh
+++ b/src/mem/multi_level_page_table_impl.hh
@@ -314,19 +314,18 @@ MultiLevelPageTable<ISAOps>::lookup(Addr vaddr, TlbEntry &entry)
template <class ISAOps>
void
-MultiLevelPageTable<ISAOps>::serialize(std::ostream &os)
+MultiLevelPageTable<ISAOps>::serialize(CheckpointOut &cp) const
{
/** Since, the page table is stored in system memory
* which is serialized separately, we will serialize
* just the base pointer
*/
- paramOut(os, "ptable.pointer", basePtr);
+ paramOut(cp, "ptable.pointer", basePtr);
}
template <class ISAOps>
void
-MultiLevelPageTable<ISAOps>::unserialize(Checkpoint *cp,
- const std::string &section)
+MultiLevelPageTable<ISAOps>::unserialize(CheckpointIn &cp)
{
- paramIn(cp, section, "ptable.pointer", basePtr);
+ paramIn(cp, "ptable.pointer", basePtr);
}
diff --git a/src/mem/page_table.cc b/src/mem/page_table.cc
index d3af09e1e..6875d6f9b 100644
--- a/src/mem/page_table.cc
+++ b/src/mem/page_table.cc
@@ -37,6 +37,7 @@
*/
#include <fstream>
#include <map>
+#include <memory>
#include <string>
#include "base/bitfield.hh"
@@ -196,44 +197,37 @@ PageTableBase::translate(RequestPtr req)
}
void
-FuncPageTable::serialize(std::ostream &os)
+FuncPageTable::serialize(CheckpointOut &cp) const
{
- paramOut(os, "ptable.size", pTable.size());
+ paramOut(cp, "ptable.size", pTable.size());
PTable::size_type count = 0;
+ for (auto &pte : pTable) {
+ ScopedCheckpointSection sec(cp, csprintf("Entry%d", count++));
- PTableItr iter = pTable.begin();
- PTableItr end = pTable.end();
- while (iter != end) {
- os << "\n[" << csprintf("%s.Entry%d", name(), count) << "]\n";
-
- paramOut(os, "vaddr", iter->first);
- iter->second.serialize(os);
-
- ++iter;
- ++count;
+ paramOut(cp, "vaddr", pte.first);
+ pte.second.serialize(cp);
}
assert(count == pTable.size());
}
void
-FuncPageTable::unserialize(Checkpoint *cp, const std::string &section)
+FuncPageTable::unserialize(CheckpointIn &cp)
{
- int i = 0, count;
- paramIn(cp, section, "ptable.size", count);
+ int count;
+ paramIn(cp, "ptable.size", count);
- pTable.clear();
+ for (int i = 0; i < count; ++i) {
+ ScopedCheckpointSection sec(cp, csprintf("Entry%d", i));
- while (i < count) {
- TheISA::TlbEntry *entry;
+ std::unique_ptr<TheISA::TlbEntry> entry;
Addr vaddr;
- paramIn(cp, csprintf("%s.Entry%d", name(), i), "vaddr", vaddr);
- entry = new TheISA::TlbEntry();
- entry->unserialize(cp, csprintf("%s.Entry%d", name(), i));
+ paramIn(cp, "vaddr", vaddr);
+ entry.reset(new TheISA::TlbEntry());
+ entry->unserialize(cp);
+
pTable[vaddr] = *entry;
- delete entry;
- ++i;
}
}
diff --git a/src/mem/page_table.hh b/src/mem/page_table.hh
index 22b5c61eb..ddec104a7 100644
--- a/src/mem/page_table.hh
+++ b/src/mem/page_table.hh
@@ -53,7 +53,7 @@ class ThreadContext;
/**
* Declaration of base class for page table
*/
-class PageTableBase
+class PageTableBase : public Serializable
{
protected:
struct cacheElement {
@@ -192,10 +192,6 @@ class PageTableBase
pTableCache[2].valid = false;
}
}
-
- virtual void serialize(std::ostream &os) = 0;
-
- virtual void unserialize(Checkpoint *cp, const std::string &section) = 0;
};
/**
@@ -239,9 +235,8 @@ class FuncPageTable : public PageTableBase
*/
bool lookup(Addr vaddr, TheISA::TlbEntry &entry);
- void serialize(std::ostream &os);
-
- void unserialize(Checkpoint *cp, const std::string &section);
+ void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+ void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
};
/**
diff --git a/src/mem/physical.cc b/src/mem/physical.cc
index e6d682624..d757b8c5d 100644
--- a/src/mem/physical.cc
+++ b/src/mem/physical.cc
@@ -289,7 +289,7 @@ PhysicalMemory::functionalAccess(PacketPtr pkt)
}
void
-PhysicalMemory::serialize(ostream& os)
+PhysicalMemory::serialize(CheckpointOut &cp) const
{
// serialize all the locked addresses and their context ids
vector<Addr> lal_addr;
@@ -303,8 +303,8 @@ PhysicalMemory::serialize(ostream& os)
}
}
- arrayParamOut(os, "lal_addr", lal_addr);
- arrayParamOut(os, "lal_cid", lal_cid);
+ SERIALIZE_CONTAINER(lal_addr);
+ SERIALIZE_CONTAINER(lal_cid);
// serialize the backing stores
unsigned int nbr_of_stores = backingStore.size();
@@ -313,14 +313,14 @@ PhysicalMemory::serialize(ostream& os)
unsigned int store_id = 0;
// store each backing store memory segment in a file
for (auto& s : backingStore) {
- nameOut(os, csprintf("%s.store%d", name(), store_id));
- serializeStore(os, store_id++, s.first, s.second);
+ ScopedCheckpointSection sec(cp, csprintf("store%d", store_id));
+ serializeStore(cp, store_id++, s.first, s.second);
}
}
void
-PhysicalMemory::serializeStore(ostream& os, unsigned int store_id,
- AddrRange range, uint8_t* pmem)
+PhysicalMemory::serializeStore(CheckpointOut &cp, unsigned int store_id,
+ AddrRange range, uint8_t* pmem) const
{
// we cannot use the address range for the name as the
// memories that are not part of the address map can overlap
@@ -335,7 +335,7 @@ PhysicalMemory::serializeStore(ostream& os, unsigned int store_id,
SERIALIZE_SCALAR(range_size);
// write memory file
- string filepath = Checkpoint::dir() + "/" + filename.c_str();
+ string filepath = CheckpointIn::dir() + "/" + filename.c_str();
gzFile compressed_mem = gzopen(filepath.c_str(), "wb");
if (compressed_mem == NULL)
fatal("Can't open physical memory checkpoint file '%s'\n",
@@ -365,14 +365,14 @@ PhysicalMemory::serializeStore(ostream& os, unsigned int store_id,
}
void
-PhysicalMemory::unserialize(Checkpoint* cp, const string& section)
+PhysicalMemory::unserialize(CheckpointIn &cp)
{
// unserialize the locked addresses and map them to the
// appropriate memory controller
vector<Addr> lal_addr;
vector<int> lal_cid;
- arrayParamIn(cp, section, "lal_addr", lal_addr);
- arrayParamIn(cp, section, "lal_cid", lal_cid);
+ UNSERIALIZE_CONTAINER(lal_addr);
+ UNSERIALIZE_CONTAINER(lal_cid);
for(size_t i = 0; i < lal_addr.size(); ++i) {
const auto& m = addrMap.find(lal_addr[i]);
m->second->addLockedAddr(LockedAddr(lal_addr[i], lal_cid[i]));
@@ -383,13 +383,14 @@ PhysicalMemory::unserialize(Checkpoint* cp, const string& section)
UNSERIALIZE_SCALAR(nbr_of_stores);
for (unsigned int i = 0; i < nbr_of_stores; ++i) {
- unserializeStore(cp, csprintf("%s.store%d", section, i));
+ ScopedCheckpointSection sec(cp, csprintf("store%d", i));
+ unserializeStore(cp);
}
}
void
-PhysicalMemory::unserializeStore(Checkpoint* cp, const string& section)
+PhysicalMemory::unserializeStore(CheckpointIn &cp)
{
const uint32_t chunk_size = 16384;
@@ -398,7 +399,7 @@ PhysicalMemory::unserializeStore(Checkpoint* cp, const string& section)
string filename;
UNSERIALIZE_SCALAR(filename);
- string filepath = cp->cptDir + "/" + filename;
+ string filepath = cp.cptDir + "/" + filename;
// mmap memoryfile
gzFile compressed_mem = gzopen(filepath.c_str(), "rb");
diff --git a/src/mem/physical.hh b/src/mem/physical.hh
index 0f53b1d9d..c577cd3ea 100644
--- a/src/mem/physical.hh
+++ b/src/mem/physical.hh
@@ -197,7 +197,7 @@ class PhysicalMemory : public Serializable
*
* @param os stream to serialize to
*/
- void serialize(std::ostream& os);
+ void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
/**
* Serialize a specific store.
@@ -206,20 +206,20 @@ class PhysicalMemory : public Serializable
* @param range The address range of this backing store
* @param pmem The host pointer to this backing store
*/
- void serializeStore(std::ostream& os, unsigned int store_id,
- AddrRange range, uint8_t* pmem);
+ void serializeStore(CheckpointOut &cp, unsigned int store_id,
+ AddrRange range, uint8_t* pmem) const;
/**
* Unserialize the memories in the system. As with the
* serialization, this action is independent of how the address
* ranges are mapped to logical memories in the guest system.
*/
- void unserialize(Checkpoint* cp, const std::string& section);
+ void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
/**
* Unserialize a specific backing store, identified by a section.
*/
- void unserializeStore(Checkpoint* cp, const std::string& section);
+ void unserializeStore(CheckpointIn &cp);
};
diff --git a/src/mem/ruby/system/System.cc b/src/mem/ruby/system/System.cc
index 75ebc8caf..9d63643cc 100644
--- a/src/mem/ruby/system/System.cc
+++ b/src/mem/ruby/system/System.cc
@@ -109,7 +109,7 @@ RubySystem::writeCompressedTrace(uint8_t *raw_data, string filename,
uint64 uncompressed_trace_size)
{
// Create the checkpoint file for the memory
- string thefile = Checkpoint::dir() + "/" + filename.c_str();
+ string thefile = CheckpointIn::dir() + "/" + filename.c_str();
int fd = creat(thefile.c_str(), 0664);
if (fd < 0) {
@@ -134,7 +134,7 @@ RubySystem::writeCompressedTrace(uint8_t *raw_data, string filename,
}
void
-RubySystem::serialize(std::ostream &os)
+RubySystem::serializeOld(CheckpointOut &cp)
{
m_cooldown_enabled = true;
vector<Sequencer*> sequencer_map;
@@ -234,7 +234,7 @@ RubySystem::readCompressedTrace(string filename, uint8_t *&raw_data,
}
void
-RubySystem::unserialize(Checkpoint *cp, const string &section)
+RubySystem::unserialize(CheckpointIn &cp)
{
uint8_t *uncompressed_trace = NULL;
@@ -249,7 +249,7 @@ RubySystem::unserialize(Checkpoint *cp, const string &section)
UNSERIALIZE_SCALAR(cache_trace_file);
UNSERIALIZE_SCALAR(cache_trace_size);
- cache_trace_file = cp->cptDir + "/" + cache_trace_file;
+ cache_trace_file = cp.cptDir + "/" + cache_trace_file;
readCompressedTrace(cache_trace_file, uncompressed_trace,
cache_trace_size);
diff --git a/src/mem/ruby/system/System.hh b/src/mem/ruby/system/System.hh
index 45e8aa8b4..a59ade398 100644
--- a/src/mem/ruby/system/System.hh
+++ b/src/mem/ruby/system/System.hh
@@ -92,8 +92,8 @@ class RubySystem : public ClockedObject
void collateStats() { m_profiler->collateStats(); }
void resetStats();
- void serialize(std::ostream &os);
- void unserialize(Checkpoint *cp, const std::string &section);
+ void serializeOld(CheckpointOut &cp) M5_ATTR_OVERRIDE;
+ void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
void process();
void startup();
bool functionalRead(Packet *ptr);