From 12db50c89584938839e035da47d206250cbfd7c2 Mon Sep 17 00:00:00 2001 From: Nikos Nikoleris Date: Mon, 13 Mar 2017 18:19:08 +0000 Subject: 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 Reviewed-on: https://gem5-review.googlesource.com/2903 Reviewed-by: Bradford Beckmann Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power --- src/base/addr_range.hh | 51 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) (limited to 'src/base') 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 @@ -346,6 +346,55 @@ class AddrRange return false; } + /** + * 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. -- cgit v1.2.3