From ddd6af414cdd4939f4ff382f0e83e7dfa695781d Mon Sep 17 00:00:00 2001 From: Andreas Sandberg Date: Fri, 2 Nov 2012 11:32:02 -0500 Subject: mem: Add support for writing back and flushing caches This patch adds support for the following optional drain methods in the classical memory system's cache model: memWriteback() - Write back all dirty cache lines to memory using functional accesses. memInvalidate() - Invalidate all cache lines. Dirty cache lines are lost unless a writeback is requested. Since memWriteback() is called when checkpointing systems, this patch adds support for checkpointing systems with caches. The serialization code now checks whether there are any dirty lines in the cache. If there are dirty lines in the cache, the checkpoint is flagged as bad and a warning is printed. --- src/mem/cache/base.hh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/mem/cache/base.hh') diff --git a/src/mem/cache/base.hh b/src/mem/cache/base.hh index ab13be771..e8adacfa1 100644 --- a/src/mem/cache/base.hh +++ b/src/mem/cache/base.hh @@ -223,6 +223,25 @@ class BaseCache : public MemObject } } + /** + * Write back dirty blocks in the cache using functional accesses. + */ + virtual void memWriteback() = 0; + /** + * Invalidates all blocks in the cache. + * + * @warn Dirty cache lines will not be written back to + * memory. Make sure to call functionalWriteback() first if you + * want the to write them to memory. + */ + virtual void memInvalidate() = 0; + /** + * Determine if there are any dirty blocks in the cache. + * + * \return true if at least one block is dirty, false otherwise. + */ + virtual bool isDirty() const = 0; + /** Block size of this cache */ const unsigned blkSize; -- cgit v1.2.3