Make ports that aren't connected to anything fail more gracefully.

--HG--
extra : convert_revision : 3803b28fb2fdfd729f01f1a44df2ae02ef83a2fc
This commit is contained in:
Gabe Black 2007-11-28 14:39:19 -08:00
parent ab598eadbf
commit 8a020d40d3
3 changed files with 64 additions and 8 deletions

View file

@ -78,8 +78,9 @@ Bridge::getPort(const std::string &if_name, int idx)
else
return NULL;
if (port->getPeer() != NULL)
panic("bridge side %s already connected to.", if_name);
if (port->getPeer() != NULL && !port->getPeer()->isDefaultPort())
panic("bridge side %s already connected to %s.",
if_name, port->getPeer()->name());
return port;
}

View file

@ -39,6 +39,64 @@
#include "mem/mem_object.hh"
#include "mem/port.hh"
class defaultPeerPortClass: public Port
{
protected:
void blowUp()
{
fatal("Unconnected port!");
}
public:
defaultPeerPortClass() : Port("default_port")
{}
bool recvTiming(PacketPtr)
{
blowUp();
return false;
}
Tick recvAtomic(PacketPtr)
{
blowUp();
return 0;
}
void recvFunctional(PacketPtr)
{
blowUp();
}
void recvStatusChange(Status)
{
blowUp();
}
int deviceBlockSize()
{
blowUp();
return 0;
}
void getDeviceAddressRanges(AddrRangeList &, bool &)
{
blowUp();
}
bool isDefaultPort() { return true; }
} defaultPeerPort;
Port::Port() : peer(&defaultPeerPort), owner(NULL)
{
}
Port::Port(const std::string &_name, MemObject *_owner) :
portName(_name), peer(&defaultPeerPort), owner(_owner)
{
}
void
Port::setPeer(Port *port)
{

View file

@ -88,9 +88,7 @@ class Port
public:
Port()
: peer(NULL), owner(NULL)
{ }
Port();
/**
* Constructor.
@ -100,9 +98,7 @@ class Port
* @param _owner Pointer to the MemObject that owns this port.
* Will not necessarily be set.
*/
Port(const std::string &_name, MemObject *_owner = NULL)
: portName(_name), peer(NULL), owner(_owner)
{ }
Port(const std::string &_name, MemObject *_owner = NULL);
/** Return port name (for DPRINTF). */
const std::string &name() const { return portName; }
@ -135,6 +131,7 @@ class Port
* demise. */
void removeConn();
virtual bool isDefaultPort() { return false; }
protected: