summaryrefslogtreecommitdiff
path: root/src/mem/bus.cc
diff options
context:
space:
mode:
authorAndreas Hansson <andreas.hansson@arm.com>2012-02-24 11:40:29 -0500
committerAndreas Hansson <andreas.hansson@arm.com>2012-02-24 11:40:29 -0500
commitef4af8cec8b1826abff5b92b9fec32f7c2818372 (patch)
tree3e4f954a11062139313602304594eeff217c6948 /src/mem/bus.cc
parente121708e08465344a2ab4df8f562159dffdf18d6 (diff)
downloadgem5-ef4af8cec8b1826abff5b92b9fec32f7c2818372.tar.xz
MEM: Fatal when no port can be found for an address
This patch adds a check in the findPort method to ensure that an invalid port id is never returned. Previously this could happen if no default port was set, and no address matched the request, in which case -1 was returned causing a SEGFAULT when using the id to index in the port array. To clean things up further a symbolic name is added for the invalid port id.
Diffstat (limited to 'src/mem/bus.cc')
-rw-r--r--src/mem/bus.cc22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/mem/bus.cc b/src/mem/bus.cc
index e1f10860d..e37449b6e 100644
--- a/src/mem/bus.cc
+++ b/src/mem/bus.cc
@@ -56,8 +56,9 @@
Bus::Bus(const BusParams *p)
: MemObject(p), busId(p->bus_id), clock(p->clock),
headerCycles(p->header_cycles), width(p->width), tickNextIdle(0),
- drainEvent(NULL), busIdle(this), inRetry(false), defaultPortId(-1),
- useDefaultRange(p->use_default_range), defaultBlockSize(p->block_size),
+ drainEvent(NULL), busIdle(this), inRetry(false),
+ defaultPortId(INVALID_PORT_ID), useDefaultRange(p->use_default_range),
+ defaultBlockSize(p->block_size),
cachedBlockSize(0), cachedBlockSizeValid(false)
{
//width, clock period, and header cycles must be positive
@@ -76,7 +77,7 @@ Bus::getPort(const std::string &if_name, int idx)
std::string portName;
int id = interfaces.size();
if (if_name == "default") {
- if (defaultPortId == -1) {
+ if (defaultPortId == INVALID_PORT_ID) {
defaultPortId = id;
portName = csprintf("%s-default", name());
} else
@@ -301,7 +302,7 @@ Bus::findPort(Addr addr)
int dest_id;
dest_id = checkPortCache(addr);
- if (dest_id != -1)
+ if (dest_id != INVALID_PORT_ID)
return dest_id;
// Check normal port ranges
@@ -321,13 +322,16 @@ Bus::findPort(Addr addr)
return defaultPortId;
}
}
-
- panic("Unable to find destination for addr %#llx\n", addr);
+ } else if (defaultPortId != INVALID_PORT_ID) {
+ DPRINTF(Bus, "Unable to find destination for addr %#llx, "
+ "will use default port\n", addr);
+ return defaultPortId;
}
- DPRINTF(Bus, "Unable to find destination for addr %#llx, "
- "will use default port\n", addr);
- return defaultPortId;
+ // we should use the range for the default port and it did not
+ // match, or the default port is not set
+ fatal("Unable to find destination for addr %#llx on bus %s\n", addr,
+ name());
}