summaryrefslogtreecommitdiff
path: root/src/base/addr_range.hh
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/base/addr_range.hh
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/base/addr_range.hh')
-rw-r--r--src/base/addr_range.hh51
1 files changed, 50 insertions, 1 deletions
diff --git a/src/base/addr_range.hh b/src/base/addr_range.hh
index 1137efa28..ac1cbd05a 100644
--- a/src/base/addr_range.hh
+++ b/src/base/addr_range.hh
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2014 ARM Limited
+ * Copyright (c) 2012, 2014, 2017 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
@@ -347,6 +347,55 @@ class AddrRange
}
/**
+ * Remove the interleaving bits from an input address.
+ *
+ * This function returns a new address that doesn't have the bits
+ * that are use to determine which of the interleaved ranges it
+ * belongs to.
+ *
+ * e.g., if the input address is:
+ * -------------------------------
+ * | prefix | intlvBits | suffix |
+ * -------------------------------
+ * this function will return:
+ * -------------------------------
+ * | 0 | prefix | suffix |
+ * -------------------------------
+ *
+ * @param the input address
+ * @return the address without the interleaved bits
+ */
+ inline Addr removeIntlvBits(const Addr &a) const
+ {
+ const auto intlv_low_bit = intlvHighBit - intlvBits + 1;
+ return insertBits(a >> intlvBits, intlv_low_bit - 1, 0, a);
+ }
+
+ /**
+ * Determine the offset of an address within the range.
+ *
+ * This function returns the offset of the given address from the
+ * starting address discarding any bits that are used for
+ * interleaving. This way we can convert the input address to a
+ * new unique address in a continuous range that starts from 0.
+ *
+ * @param the input address
+ * @return the flat offset in the address range
+ */
+ Addr getOffset(const Addr& a) const
+ {
+ bool in_range = a >= _start && a <= _end;
+ if (!in_range) {
+ return MaxAddr;
+ }
+ if (interleaved()) {
+ return removeIntlvBits(a) - removeIntlvBits(_start);
+ } else {
+ return a - _start;
+ }
+ }
+
+ /**
* Less-than operator used to turn an STL map into a binary search
* tree of non-overlapping address ranges.
*