/*
- * Copyright (c) 2012 ARM Limited
+ * Copyright (c) 2012,2015,2017 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
* @file
* Port object definitions.
*/
-#include "base/trace.hh"
-#include "mem/mem_object.hh"
#include "mem/port.hh"
-Port::Port(const std::string &_name, MemObject& _owner)
- : portName(_name), peer(NULL), owner(_owner)
-{
-}
-
-Port::~Port()
-{
-}
+#include "base/trace.hh"
+#include "sim/sim_object.hh"
/**
* Master port
*/
-MasterPort::MasterPort(const std::string& name, MemObject* owner)
- : Port(name, *owner), _slavePort(NULL)
+MasterPort::MasterPort(const std::string& name, SimObject* _owner, PortID _id)
+ : Port(name, _id), _slavePort(NULL), owner(*_owner)
{
}
{
}
-SlavePort&
-MasterPort::getSlavePort() const
-{
- if(_slavePort == NULL)
- panic("Cannot getSlavePort on master port %s that is not connected\n",
- name());
-
- return *_slavePort;
-}
-
void
-MasterPort::bind(SlavePort& slave_port)
+MasterPort::bind(Port &peer)
{
+ auto *slave_port = dynamic_cast<SlavePort *>(&peer);
+ if (!slave_port) {
+ fatal("Attempt to bind port %s to non-slave port %s.",
+ name(), peer.name());
+ }
// master port keeps track of the slave port
- _slavePort = &slave_port;
- peer = &slave_port;
-
+ _slavePort = slave_port;
+ Port::bind(peer);
// slave port also keeps track of master port
- _slavePort->bind(*this);
+ _slavePort->slaveBind(*this);
}
-bool
-MasterPort::isConnected() const
+void
+MasterPort::unbind()
{
- return _slavePort != NULL;
+ if (_slavePort == NULL)
+ panic("Attempting to unbind master port %s that is not connected\n",
+ name());
+ _slavePort->slaveUnbind();
+ _slavePort = nullptr;
+ Port::unbind();
}
-unsigned
-MasterPort::peerBlockSize() const
+AddrRangeList
+MasterPort::getAddrRanges() const
{
- return _slavePort->deviceBlockSize();
+ return _slavePort->getAddrRanges();
}
- void
+void
MasterPort::printAddr(Addr a)
{
- Request req(a, 1, 0, Request::funcMasterId);
- Packet pkt(&req, MemCmd::PrintReq, Packet::Broadcast);
+ auto req = std::make_shared<Request>(
+ a, 1, 0, Request::funcMasterId);
+
+ Packet pkt(req, MemCmd::PrintReq);
Packet::PrintReqState prs(std::cerr);
pkt.senderState = &prs;
/**
* Slave port
*/
-SlavePort::SlavePort(const std::string& name, MemObject* owner)
- : Port(name, *owner), _masterPort(NULL)
+SlavePort::SlavePort(const std::string& name, SimObject* _owner, PortID id)
+ : Port(name, id), _masterPort(NULL), defaultBackdoorWarned(false),
+ owner(*_owner)
{
}
}
void
-SlavePort::bind(MasterPort& master_port)
-{
- _masterPort = &master_port;
- peer = &master_port;
-}
-
-MasterPort&
-SlavePort::getMasterPort() const
+SlavePort::slaveUnbind()
{
- if (_masterPort == NULL)
- panic("Cannot getMasterPort on slave port %s that is not connected\n",
- name());
-
- return *_masterPort;
+ _masterPort = NULL;
+ Port::unbind();
}
-unsigned
-SlavePort::peerBlockSize() const
+void
+SlavePort::slaveBind(MasterPort& master_port)
{
- return _masterPort->deviceBlockSize();
+ _masterPort = &master_port;
+ Port::bind(master_port);
}
-bool
-SlavePort::isConnected() const
+Tick
+SlavePort::recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor)
{
- return _masterPort != NULL;
+ if (!defaultBackdoorWarned) {
+ warn("Port %s doesn't support requesting a back door.", name());
+ defaultBackdoorWarned = true;
+ }
+ return recvAtomic(pkt);
}