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/physical.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/physical.cc')
-rw-r--r-- | src/mem/physical.cc | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/mem/physical.cc b/src/mem/physical.cc index b6f4c7a95..ef1f7159e 100644 --- a/src/mem/physical.cc +++ b/src/mem/physical.cc @@ -120,8 +120,8 @@ PhysicalMemory::createBackingStore(AddrRange range, const vector<AbstractMemory*>& _memories) { // perform the actual mmap - DPRINTF(BusAddrRanges, "Creating backing store for range %x:%x\n", - range.start, range.end); + DPRINTF(BusAddrRanges, "Creating backing store for range %s\n", + range.to_string()); int map_flags = MAP_ANON | MAP_PRIVATE; uint8_t* pmem = (uint8_t*) mmap(NULL, range.size(), PROT_READ | PROT_WRITE, @@ -129,8 +129,8 @@ PhysicalMemory::createBackingStore(AddrRange range, if (pmem == (uint8_t*) MAP_FAILED) { perror("mmap"); - fatal("Could not mmap %d bytes for range %x:%x!\n", range.size(), - range.start, range.end); + fatal("Could not mmap %d bytes for range %s!\n", range.size(), + range.to_string()); } // remember this backing store so we can checkpoint it and unmap @@ -157,8 +157,8 @@ PhysicalMemory::createBackingStore(AddrRange range, if (init_to_zero != 0) { if (init_to_zero != _memories.size()) - fatal("Some, but not all memories in range %x:%x are set zero\n", - range.start, range.end); + fatal("Some, but not all memories in range %s are set zero\n", + range.to_string()); memset(pmem, 0, range.size()); } @@ -176,7 +176,7 @@ bool PhysicalMemory::isMemAddr(Addr addr) const { // see if the address is within the last matched range - if (addr != rangeCache) { + if (!rangeCache.contains(addr)) { // lookup in the interval tree AddrRangeMap<AbstractMemory*>::const_iterator r = addrMap.find(addr); if (r == addrMap.end()) { |