summaryrefslogtreecommitdiff
path: root/src/mem/bus.hh
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.hh
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.hh')
-rw-r--r--src/mem/bus.hh5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/mem/bus.hh b/src/mem/bus.hh
index 3117bf4e1..f7f69e08e 100644
--- a/src/mem/bus.hh
+++ b/src/mem/bus.hh
@@ -220,7 +220,7 @@ class Bus : public MemObject
return portCache[2].id;
}
- return -1;
+ return INVALID_PORT_ID;
}
// Clears the earliest entry of the cache and inserts a new port entry
@@ -317,6 +317,9 @@ class Bus : public MemObject
/** Port that handles requests that don't match any of the interfaces.*/
short defaultPortId;
+ /** A symbolic name for a port id that denotes no port. */
+ static const short INVALID_PORT_ID = -1;
+
/** If true, use address range provided by default device. Any
address not handled by another port and not in default device's
range will cause a fatal error. If false, just send all