summaryrefslogtreecommitdiff
path: root/src/mem/cache/cache_blk.hh
diff options
context:
space:
mode:
authorDaniel R. Carvalho <odanrc@yahoo.com.br>2018-10-25 17:26:02 +0200
committerDaniel Carvalho <odanrc@yahoo.com.br>2018-11-26 12:49:18 +0000
commit24bfdc36f19fddbfcb33cc2f33fb216e8da0382d (patch)
tree76cac629050b370f96fb1d58b6963b9dd7529346 /src/mem/cache/cache_blk.hh
parentd7409ddbaffa18f6c7066a521fb24f38130c5a99 (diff)
downloadgem5-24bfdc36f19fddbfcb33cc2f33fb216e8da0382d.tar.xz
mem-cache: Add setters to validate and secure block
In order to allow polymorphism of the block these two functions have been added, and all direct status assignments to these bits have been substituted. We also assert that the block has been invalidated before insertion. Then the block is validated in the insertion. Change-Id: Ie7be42408721ad4c2c9dc880f82a62cb594f8668 Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br> Reviewed-on: https://gem5-review.googlesource.com/c/14362 Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>
Diffstat (limited to 'src/mem/cache/cache_blk.hh')
-rw-r--r--src/mem/cache/cache_blk.hh29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/mem/cache/cache_blk.hh b/src/mem/cache/cache_blk.hh
index 80983a637..d7530d656 100644
--- a/src/mem/cache/cache_blk.hh
+++ b/src/mem/cache/cache_blk.hh
@@ -244,10 +244,27 @@ class CacheBlk : public ReplaceableEntry
}
/**
+ * Set valid bit.
+ */
+ virtual void setValid()
+ {
+ assert(!isValid());
+ status |= BlkValid;
+ }
+
+ /**
+ * Set secure bit.
+ */
+ virtual void setSecure()
+ {
+ status |= BlkSecure;
+ }
+
+ /**
* Set member variables when a block insertion occurs. Resets reference
* count to 1 (the insertion counts as a reference), and touch block if
* it hadn't been touched previously. Sets the insertion tick to the
- * current tick. Does not make block valid.
+ * current tick. Marks the block valid.
*
* @param tag Block address tag.
* @param is_secure Whether the block is in secure space or not.
@@ -425,15 +442,19 @@ class TempCacheBlk final : public CacheBlk
void insert(const Addr addr, const bool is_secure,
const int src_master_ID=0, const uint32_t task_ID=0) override
{
+ // Make sure that the block has been properly invalidated
+ assert(status == 0);
+
// Set block address
_addr = addr;
// Set secure state
if (is_secure) {
- status = BlkSecure;
- } else {
- status = 0;
+ setSecure();
}
+
+ // Validate block
+ setValid();
}
/**