From 7f1458bec4ae3ea3fb5f0948f0323355e1f20512 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 7 Mar 2019 01:32:54 -0800 Subject: mem: Move bind() and unbind() into the Port class. These are now pure virtual methods which more specialized port subclasses will need to implement. The SlavePort class implements them by ignoring them and then providing parallel functions for the MasterPort to call. The MasterPort's methods do basically what they did before, except now bind() uses dynamic cast to check if its peer is of the appropriate type and also to convert it into that type before connecting to it. Change-Id: I0948799bc954acaebf371e6b6612cee1d3023bc4 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/17038 Reviewed-by: Daniel Carvalho Reviewed-by: Andreas Sandberg Maintainer: Andreas Sandberg --- src/dev/net/etherint.cc | 19 +++++++++++++++++++ src/dev/net/etherint.hh | 3 +++ 2 files changed, 22 insertions(+) (limited to 'src/dev') diff --git a/src/dev/net/etherint.cc b/src/dev/net/etherint.cc index 0c5e6b817..b55e625f7 100644 --- a/src/dev/net/etherint.cc +++ b/src/dev/net/etherint.cc @@ -33,6 +33,25 @@ #include "base/logging.hh" #include "sim/sim_object.hh" +void +EtherInt::bind(Port &peer) +{ + EtherInt *p = dynamic_cast(&peer); + if (!p) { + fatal("Attempt to bind port %s to non-ethernet port %s.", + name(), peer.name()); + } + setPeer(p); + _connected = true; +} + +void +EtherInt::unbind() +{ + peer = nullptr; + _connected = false; +} + void EtherInt::setPeer(EtherInt *p) { diff --git a/src/dev/net/etherint.hh b/src/dev/net/etherint.hh index 77032208c..0486631b2 100644 --- a/src/dev/net/etherint.hh +++ b/src/dev/net/etherint.hh @@ -60,6 +60,9 @@ class EtherInt : public Port /** Return port name (for DPRINTF). */ const std::string &name() const { return portName; } + void bind(Port &peer) override; + void unbind() override; + void setPeer(EtherInt *p); EtherInt* getPeer() { return peer; } -- cgit v1.2.3