mem-ruby: Add deallocate to DirectoryMemory
authorTiago Muck <tiago.muck@arm.com>
Tue, 16 Apr 2019 23:05:49 +0000 (18:05 -0500)
committerTiago Mück <tiago.muck@arm.com>
Wed, 6 May 2020 14:42:33 +0000 (14:42 +0000)
Change-Id: Ib261ec8b302b55e539d8e13064957170412b752c
Signed-off-by: Tiago Mück <tiago.muck@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/21920
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/mem/ruby/protocol/RubySlicc_Types.sm
src/mem/ruby/structures/DirectoryMemory.cc
src/mem/ruby/structures/DirectoryMemory.hh

index 66d84fca30cf95699e45619b1eeaf101d197117c..fc1f7f39890f6a194b04aa815ed3bf656ea23feb 100644 (file)
@@ -197,6 +197,7 @@ structure(AbstractCacheEntry, primitive="yes", external = "yes") {
 structure (DirectoryMemory, external = "yes") {
   AbstractCacheEntry allocate(Addr, AbstractCacheEntry);
   AbstractCacheEntry lookup(Addr);
+  void deallocate(Addr);
   bool isPresent(Addr);
   void invalidateBlock(Addr);
   void recordRequestType(DirectoryRequestType);
index e2ee0fc549bf5cbaa6bdae3452b3b67e3dcfdf67..c6e3ccf5402eb6a7c8a185b6bceec0a8579ef252 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 ARM Limited
+ * Copyright (c) 2017,2019 ARM Limited
  * All rights reserved.
  *
  * The license below extends only to copyright in the software and shall
@@ -127,12 +127,27 @@ DirectoryMemory::allocate(Addr address, AbstractCacheEntry *entry)
 
     idx = mapAddressToLocalIdx(address);
     assert(idx < m_num_entries);
+    assert(m_entries[idx] == NULL);
     entry->changePermission(AccessPermission_Read_Only);
     m_entries[idx] = entry;
 
     return entry;
 }
 
+void
+DirectoryMemory::deallocate(Addr address)
+{
+    assert(isPresent(address));
+    uint64_t idx;
+    DPRINTF(RubyCache, "Removing entry for address: %#x\n", address);
+
+    idx = mapAddressToLocalIdx(address);
+    assert(idx < m_num_entries);
+    assert(m_entries[idx] != NULL);
+    delete m_entries[idx];
+    m_entries[idx] = NULL;
+}
+
 void
 DirectoryMemory::print(ostream& out) const
 {
index f879b294f6e1890036a55c3d53dc5967137cbe86..3dd0e95668b12b00e46092805241e724a8817263 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 ARM Limited
+ * Copyright (c) 2017,2019 ARM Limited
  * All rights reserved.
  *
  * The license below extends only to copyright in the software and shall
@@ -79,6 +79,9 @@ class DirectoryMemory : public SimObject
     AbstractCacheEntry *lookup(Addr address);
     AbstractCacheEntry *allocate(Addr address, AbstractCacheEntry* new_entry);
 
+    // Explicitly free up this address
+    void deallocate(Addr address);
+
     void print(std::ostream& out) const;
     void recordRequestType(DirectoryRequestType requestType);