diff -r 286030fb113a -r c58fb5ed5a39 src/mem/bus.hh --- a/src/mem/bus.hh Mon Feb 13 11:55:51 2012 +0000 +++ b/src/mem/bus.hh Mon Feb 13 11:56:31 2012 +0000 @@ -65,6 +65,10 @@ #include "params/Bus.hh" #include "sim/eventq.hh" + +/** A symbolic name for a port id that denotes no port. */ +const short INVALID_PORT_ID = -1; + class Bus : public MemObject { /** Declaration of the buses port type, one will be instantiated for each @@ -220,7 +224,7 @@ return portCache[2].id; } - return -1; + return INVALID_PORT_ID; } // Clears the earliest entry of the cache and inserts a new port entry diff -r 286030fb113a -r c58fb5ed5a39 src/mem/bus.cc --- a/src/mem/bus.cc Mon Feb 13 11:55:51 2012 +0000 +++ b/src/mem/bus.cc Mon Feb 13 11:56:31 2012 +0000 @@ -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 @@ 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 @@ int dest_id; dest_id = checkPortCache(addr); - if (dest_id != -1) + if (dest_id != INVALID_PORT_ID) return dest_id; // Check normal port ranges @@ -325,9 +326,16 @@ panic("Unable to find destination for addr %#llx\n", addr); } - DPRINTF(Bus, "Unable to find destination for addr %#llx, " - "will use default port\n", addr); - return defaultPortId; + if (defaultPortId != INVALID_PORT_ID) { + DPRINTF(Bus, "Unable to find destination for addr %#llx, " + "will use default port\n", addr); + return defaultPortId; + } else { + panic("Unable to find destination for addr %#llx and no default " + "port set\n", addr); + } + + }