From 24bfdc36f19fddbfcb33cc2f33fb216e8da0382d Mon Sep 17 00:00:00 2001 From: "Daniel R. Carvalho" Date: Thu, 25 Oct 2018 17:26:02 +0200 Subject: 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 Reviewed-on: https://gem5-review.googlesource.com/c/14362 Reviewed-by: Nikos Nikoleris Maintainer: Nikos Nikoleris --- src/mem/cache/cache_blk.hh | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'src/mem/cache/cache_blk.hh') 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 @@ -243,11 +243,28 @@ class CacheBlk : public ReplaceableEntry return (status & BlkSecure) != 0; } + /** + * 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(); } /** -- cgit v1.2.3