From 71da1d21578b6f9cf5b43bd4648f313326849533 Mon Sep 17 00:00:00 2001 From: Andreas Hansson Date: Mon, 7 Jan 2013 13:05:38 -0500 Subject: 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. --- src/mem/abstract_mem.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/mem/abstract_mem.cc') diff --git a/src/mem/abstract_mem.cc b/src/mem/abstract_mem.cc index 086985f8d..fb8b7d81b 100644 --- a/src/mem/abstract_mem.cc +++ b/src/mem/abstract_mem.cc @@ -303,8 +303,8 @@ AbstractMemory::checkLockedAddrList(PacketPtr pkt) void AbstractMemory::access(PacketPtr pkt) { - assert(pkt->getAddr() >= range.start && - (pkt->getAddr() + pkt->getSize() - 1) <= range.end); + assert(AddrRange(pkt->getAddr(), + pkt->getAddr() + pkt->getSize() - 1).isSubset(range)); if (pkt->memInhibitAsserted()) { DPRINTF(MemoryAccess, "mem inhibited on 0x%x: not responding\n", @@ -312,7 +312,7 @@ AbstractMemory::access(PacketPtr pkt) return; } - uint8_t *hostAddr = pmemAddr + pkt->getAddr() - range.start; + uint8_t *hostAddr = pmemAddr + pkt->getAddr() - range.start(); if (pkt->cmd == MemCmd::SwapReq) { TheISA::IntReg overwrite_val; @@ -384,10 +384,10 @@ AbstractMemory::access(PacketPtr pkt) void AbstractMemory::functionalAccess(PacketPtr pkt) { - assert(pkt->getAddr() >= range.start && - (pkt->getAddr() + pkt->getSize() - 1) <= range.end); + assert(AddrRange(pkt->getAddr(), + pkt->getAddr() + pkt->getSize() - 1).isSubset(range)); - uint8_t *hostAddr = pmemAddr + pkt->getAddr() - range.start; + uint8_t *hostAddr = pmemAddr + pkt->getAddr() - range.start(); if (pkt->isRead()) { if (pmemAddr) -- cgit v1.2.3