summaryrefslogtreecommitdiff
path: root/src/mem
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2008-06-15 21:34:32 -0700
committerNathan Binkert <nate@binkert.org>2008-06-15 21:34:32 -0700
commite3c267a3dbe628516777dd74662c786ef4eedceb (patch)
tree1896fcf08d73fb919ef361e678fddc044cb976a9 /src/mem
parentb429b1759defba2f8da1f894f6a3500e3f2c78d2 (diff)
downloadgem5-e3c267a3dbe628516777dd74662c786ef4eedceb.tar.xz
port: Clean up default port setup and port switchover code.
Diffstat (limited to 'src/mem')
-rw-r--r--src/mem/bridge.cc2
-rw-r--r--src/mem/port.cc26
-rw-r--r--src/mem/port.hh9
3 files changed, 23 insertions, 14 deletions
diff --git a/src/mem/bridge.cc b/src/mem/bridge.cc
index 3d3966491..c09cacc00 100644
--- a/src/mem/bridge.cc
+++ b/src/mem/bridge.cc
@@ -89,7 +89,7 @@ void
Bridge::init()
{
// Make sure that both sides are connected to.
- if (portA.getPeer() == NULL || portB.getPeer() == NULL)
+ if (!portA.isConnected() || !portB.isConnected())
fatal("Both ports of bus bridge are not connected to a bus.\n");
if (portA.peerBlockSize() != portB.peerBlockSize())
diff --git a/src/mem/port.cc b/src/mem/port.cc
index ce3f6c74b..0e03194c9 100644
--- a/src/mem/port.cc
+++ b/src/mem/port.cc
@@ -39,17 +39,18 @@
#include "mem/mem_object.hh"
#include "mem/port.hh"
-class defaultPeerPortClass: public Port
+class DefaultPeerPort : public Port
{
protected:
void blowUp()
{
- fatal("Unconnected port!");
+ fatal("%s: Unconnected port!", peer->name());
}
public:
- defaultPeerPortClass() : Port("default_port")
- {}
+ DefaultPeerPort()
+ : Port("default_port")
+ { }
bool recvTiming(PacketPtr)
{
@@ -84,16 +85,22 @@ class defaultPeerPortClass: public Port
blowUp();
}
- bool isDefaultPort() { return true; }
+ bool isDefaultPort() const { return true; }
+};
-} defaultPeerPort;
+DefaultPeerPort defaultPeerPort;
-Port::Port() : peer(&defaultPeerPort), owner(NULL)
+Port::Port()
+ : peer(&defaultPeerPort), owner(NULL)
{
}
-Port::Port(const std::string &_name, MemObject *_owner) :
- portName(_name), peer(&defaultPeerPort), owner(_owner)
+Port::Port(const std::string &_name, MemObject *_owner)
+ : portName(_name), peer(&defaultPeerPort), owner(_owner)
+{
+}
+
+Port::~Port()
{
}
@@ -101,6 +108,7 @@ void
Port::setPeer(Port *port)
{
DPRINTF(Config, "setting peer to %s\n", port->name());
+
peer = port;
}
diff --git a/src/mem/port.hh b/src/mem/port.hh
index f66b566ea..15fda2164 100644
--- a/src/mem/port.hh
+++ b/src/mem/port.hh
@@ -73,8 +73,7 @@ class MemObject;
*/
class Port
{
- private:
-
+ protected:
/** Descriptive name (for DPRINTF output) */
mutable std::string portName;
@@ -103,7 +102,7 @@ class Port
/** Return port name (for DPRINTF). */
const std::string &name() const { return portName; }
- virtual ~Port() {};
+ virtual ~Port();
// mey be better to use subclasses & RTTI?
/** Holds the ports status. Currently just that a range recomputation needs
@@ -131,7 +130,9 @@ class Port
* demise. */
void removeConn();
- virtual bool isDefaultPort() { return false; }
+ virtual bool isDefaultPort() const { return false; }
+
+ bool isConnected() { return peer && !peer->isDefaultPort(); }
protected: