summaryrefslogtreecommitdiff
path: root/src/mem/ruby/structures/DirectoryMemory.cc
diff options
context:
space:
mode:
authorNikos Nikoleris <nikos.nikoleris@arm.com>2017-03-13 18:19:08 +0000
committerNikos Nikoleris <nikos.nikoleris@arm.com>2017-06-13 15:52:32 +0000
commit12db50c89584938839e035da47d206250cbfd7c2 (patch)
tree831a4151b29cdc14958b8dab2cce97fc3136d7b6 /src/mem/ruby/structures/DirectoryMemory.cc
parentdd3fc1f996679f4cfd29f980d43a0652542e6d9b (diff)
downloadgem5-12db50c89584938839e035da47d206250cbfd7c2.tar.xz
ruby: Add support for address ranges in the directory
Previously the directory covered a flat address range that always started from address 0. This change adds a vector of address ranges with interleaving and hashing that each directory keeps track of and the necessary flexibility to support systems with non continuous memory ranges. Change-Id: I6ea1c629bdf4c5137b7d9c89dbaf6c826adfd977 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/2903 Reviewed-by: Bradford Beckmann <brad.beckmann@amd.com> Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Jason Lowe-Power <jason@lowepower.com>
Diffstat (limited to 'src/mem/ruby/structures/DirectoryMemory.cc')
-rw-r--r--src/mem/ruby/structures/DirectoryMemory.cc75
1 files changed, 31 insertions, 44 deletions
diff --git a/src/mem/ruby/structures/DirectoryMemory.cc b/src/mem/ruby/structures/DirectoryMemory.cc
index ee77931d7..551e3f57f 100644
--- a/src/mem/ruby/structures/DirectoryMemory.cc
+++ b/src/mem/ruby/structures/DirectoryMemory.cc
@@ -1,4 +1,16 @@
/*
+ * Copyright (c) 2017 ARM Limited
+ * All rights reserved.
+ *
+ * The license below extends only to copyright in the software and shall
+ * not be construed as granting a license to any other intellectual
+ * property including but not limited to intellectual property relating
+ * to a hardware implementation of the functionality of the software
+ * licensed hereunder. You may use the software subject to the license
+ * terms below provided that you ensure that this notice is replicated
+ * unmodified and in its entirety in all distributions of the software,
+ * modified or unmodified, in source code or in binary form.
+ *
* Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
* Copyright (c) 2017 Google Inc.
* All rights reserved.
@@ -31,6 +43,7 @@
#include "mem/ruby/structures/DirectoryMemory.hh"
+#include "base/addr_range.hh"
#include "base/intmath.hh"
#include "debug/RubyCache.hh"
#include "debug/RubyStats.hh"
@@ -40,25 +53,15 @@
using namespace std;
-int DirectoryMemory::m_num_directories = 0;
-int DirectoryMemory::m_num_directories_bits = 0;
-int DirectoryMemory::m_numa_high_bit = 0;
-
DirectoryMemory::DirectoryMemory(const Params *p)
- : SimObject(p)
+ : SimObject(p), addrRanges(p->addr_ranges.begin(), p->addr_ranges.end())
{
- m_version = p->version;
- // In X86, there is an IO gap in the 3-4GB range.
- if (p->system->getArch() == Arch::X86ISA && p->size > 0xc0000000){
- // We need to add 1GB to the size for the gap
- m_size_bytes = p->size + 0x40000000;
- }
- else {
- m_size_bytes = p->size;
+ m_size_bytes = 0;
+ for (const auto &r: addrRanges) {
+ m_size_bytes += r.size();
}
m_size_bits = floorLog2(m_size_bytes);
m_num_entries = 0;
- m_numa_high_bit = p->numa_high_bit;
}
void
@@ -68,14 +71,6 @@ DirectoryMemory::init()
m_entries = new AbstractEntry*[m_num_entries];
for (int i = 0; i < m_num_entries; i++)
m_entries[i] = NULL;
-
- m_num_directories++;
- m_num_directories_bits = ceilLog2(m_num_directories);
-
- if (m_numa_high_bit == 0) {
- m_numa_high_bit = RubySystem::getMemorySizeBits() - 1;
- }
- assert(m_numa_high_bit != 0);
}
DirectoryMemory::~DirectoryMemory()
@@ -89,37 +84,29 @@ DirectoryMemory::~DirectoryMemory()
delete [] m_entries;
}
-uint64_t
-DirectoryMemory::mapAddressToDirectoryVersion(Addr address)
-{
- if (m_num_directories_bits == 0)
- return 0;
-
- uint64_t ret = bitSelect(address,
- m_numa_high_bit - m_num_directories_bits + 1,
- m_numa_high_bit);
- return ret;
-}
-
bool
DirectoryMemory::isPresent(Addr address)
{
- bool ret = (mapAddressToDirectoryVersion(address) == m_version);
- return ret;
+ for (const auto& r: addrRanges) {
+ if (r.contains(address)) {
+ return true;
+ }
+ }
+ return false;
}
uint64_t
DirectoryMemory::mapAddressToLocalIdx(Addr address)
{
- uint64_t ret;
- if (m_num_directories_bits > 0) {
- ret = bitRemove(address, m_numa_high_bit - m_num_directories_bits + 1,
- m_numa_high_bit);
- } else {
- ret = address;
+ uint64_t ret = 0;
+ for (const auto& r: addrRanges) {
+ if (r.contains(address)) {
+ ret += r.getOffset(address);
+ break;
+ }
+ ret += r.size();
}
-
- return ret >> (RubySystem::getBlockSizeBits());
+ return ret >> RubySystem::getBlockSizeBits();
}
AbstractEntry*