diff options
author | Andreas Hansson <andreas.hansson@arm.com> | 2013-01-07 13:05:38 -0500 |
---|---|---|
committer | Andreas Hansson <andreas.hansson@arm.com> | 2013-01-07 13:05:38 -0500 |
commit | 71da1d21578b6f9cf5b43bd4648f313326849533 (patch) | |
tree | 639972c7c05b28380952bc655b4dd170d888599d /src/mem/addr_mapper.cc | |
parent | cfdaf53104625a04d504972c76545bf869c6a476 (diff) | |
download | gem5-71da1d21578b6f9cf5b43bd4648f313326849533.tar.xz |
base: Encapsulate the underlying fields in AddrRange
This patch makes the start and end address private in a move to
prevent direct manipulation and matching of ranges based on these
fields. This is done so that a transition to ranges with interleaving
support is possible.
As a result of hiding the start and end, a number of member functions
are needed to perform the comparisons and manipulations that
previously took place directly on the members. An accessor function is
provided for the start address, and a function is added to test if an
address is within a range. As a result of the latter the != and ==
operator is also removed in favour of the member function. A member
function that returns a string representation is also created to allow
debug printing.
In general, this patch does not add any functionality, but it does
take us closer to a situation where interleaving (and more cleverness)
can be added under the bonnet without exposing it to the user. More on
that in a later patch.
Diffstat (limited to 'src/mem/addr_mapper.cc')
-rw-r--r-- | src/mem/addr_mapper.cc | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/mem/addr_mapper.cc b/src/mem/addr_mapper.cc index b754cb7e6..660848c82 100644 --- a/src/mem/addr_mapper.cc +++ b/src/mem/addr_mapper.cc @@ -253,9 +253,9 @@ Addr RangeAddrMapper::remapAddr(Addr addr) const { for (int i = 0; i < originalRanges.size(); ++i) { - if (originalRanges[i] == addr) { - Addr offset = addr - originalRanges[i].start; - return offset + remappedRanges[i].start; + if (originalRanges[i].contains(addr)) { + Addr offset = addr - originalRanges[i].start(); + return offset + remappedRanges[i].start(); } } @@ -277,11 +277,12 @@ RangeAddrMapper::getAddrRanges() const " ranges but are not a subset.\n"); if (range.isSubset(originalRanges[j])) { // range is a subset - Addr offset = range.start - originalRanges[j].start; - range.start -= offset; - range.end -= offset; + Addr offset = range.start() - originalRanges[j].start(); + Addr start = range.start() - offset; + ranges.push_back(AddrRange(start, start + range.size() - 1)); + } else { + ranges.push_back(range); } - ranges.push_back(range); } } |