From efa6c773b3330cdeeca07c4032902e87541c1d97 Mon Sep 17 00:00:00 2001 From: Tiago Muck Date: Tue, 16 Apr 2019 18:05:49 -0500 Subject: [PATCH] mem-ruby: Add deallocate to DirectoryMemory MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: Ib261ec8b302b55e539d8e13064957170412b752c Signed-off-by: Tiago Mück Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/21920 Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power Tested-by: kokoro --- src/mem/ruby/protocol/RubySlicc_Types.sm | 1 + src/mem/ruby/structures/DirectoryMemory.cc | 17 ++++++++++++++++- src/mem/ruby/structures/DirectoryMemory.hh | 5 ++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/mem/ruby/protocol/RubySlicc_Types.sm b/src/mem/ruby/protocol/RubySlicc_Types.sm index 66d84fca3..fc1f7f398 100644 --- a/src/mem/ruby/protocol/RubySlicc_Types.sm +++ b/src/mem/ruby/protocol/RubySlicc_Types.sm @@ -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); diff --git a/src/mem/ruby/structures/DirectoryMemory.cc b/src/mem/ruby/structures/DirectoryMemory.cc index e2ee0fc54..c6e3ccf54 100644 --- a/src/mem/ruby/structures/DirectoryMemory.cc +++ b/src/mem/ruby/structures/DirectoryMemory.cc @@ -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 { diff --git a/src/mem/ruby/structures/DirectoryMemory.hh b/src/mem/ruby/structures/DirectoryMemory.hh index f879b294f..3dd0e9566 100644 --- a/src/mem/ruby/structures/DirectoryMemory.hh +++ b/src/mem/ruby/structures/DirectoryMemory.hh @@ -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); -- 2.30.2