1a2,13
> * 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.
> *
33a46
> #include "base/addr_range.hh"
43,46d55
< int DirectoryMemory::m_num_directories = 0;
< int DirectoryMemory::m_num_directories_bits = 0;
< int DirectoryMemory::m_numa_high_bit = 0;
<
48c57
< : SimObject(p)
---
> : SimObject(p), addrRanges(p->addr_ranges.begin(), p->addr_ranges.end())
50,54c59,61
< 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;
---
> m_size_bytes = 0;
> for (const auto &r: addrRanges) {
> m_size_bytes += r.size();
56,58d62
< else {
< m_size_bytes = p->size;
< }
61d64
< m_numa_high_bit = p->numa_high_bit;
71,78d73
<
< 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);
92,103d86
< 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;
< }
<
107,108c90,95
< bool ret = (mapAddressToDirectoryVersion(address) == m_version);
< return ret;
---
> for (const auto& r: addrRanges) {
> if (r.contains(address)) {
> return true;
> }
> }
> return false;
114,119c101,107
< 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();
121,122c109
<
< return ret >> (RubySystem::getBlockSizeBits());
---
> return ret >> RubySystem::getBlockSizeBits();