From: Gabe Black Date: Sat, 17 Aug 2019 06:21:56 +0000 (-0700) Subject: cpu, dev, mem: Use the new Port methods. X-Git-Tag: v19.0.0.0~627 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4d503eeffee054de0aab10962c345ca4bcb54140;p=gem5.git cpu, dev, mem: Use the new Port methods. Use getPeer, takeOverFrom, and << to simplify the use of ports in some areas. Change-Id: Idfbda27411b5d6b742f5e4927894302ea6d6a53d Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/20235 Tested-by: kokoro Reviewed-by: Jason Lowe-Power Reviewed-by: Nikos Nikoleris Reviewed-by: Andreas Sandberg Maintainer: Andreas Sandberg --- diff --git a/src/cpu/base.cc b/src/cpu/base.cc index a9f68bb26..5bc3fe7c7 100644 --- a/src/cpu/base.cc +++ b/src/cpu/base.cc @@ -628,24 +628,10 @@ BaseCPU::takeOverFrom(BaseCPU *oldCPU) Port *new_dtb_port = newTC->getDTBPtr()->getTableWalkerPort(); // Move over any table walker ports if they exist - if (new_itb_port) { - assert(!new_itb_port->isConnected()); - assert(old_itb_port); - assert(old_itb_port->isConnected()); - auto &slavePort = - dynamic_cast(old_itb_port)->getSlavePort(); - old_itb_port->unbind(); - new_itb_port->bind(slavePort); - } - if (new_dtb_port) { - assert(!new_dtb_port->isConnected()); - assert(old_dtb_port); - assert(old_dtb_port->isConnected()); - auto &slavePort = - dynamic_cast(old_dtb_port)->getSlavePort(); - old_dtb_port->unbind(); - new_dtb_port->bind(slavePort); - } + if (new_itb_port) + new_itb_port->takeOverFrom(old_itb_port); + if (new_dtb_port) + new_dtb_port->takeOverFrom(old_dtb_port); newTC->getITBPtr()->takeOverFrom(oldTC->getITBPtr()); newTC->getDTBPtr()->takeOverFrom(oldTC->getDTBPtr()); @@ -667,26 +653,10 @@ BaseCPU::takeOverFrom(BaseCPU *oldCPU) newChecker->getDTBPtr()->takeOverFrom(oldChecker->getDTBPtr()); // Move over any table walker ports if they exist for checker - if (new_checker_itb_port) { - assert(!new_checker_itb_port->isConnected()); - assert(old_checker_itb_port); - assert(old_checker_itb_port->isConnected()); - auto &slavePort = - dynamic_cast(old_checker_itb_port)-> - getSlavePort(); - old_checker_itb_port->unbind(); - new_checker_itb_port->bind(slavePort); - } - if (new_checker_dtb_port) { - assert(!new_checker_dtb_port->isConnected()); - assert(old_checker_dtb_port); - assert(old_checker_dtb_port->isConnected()); - auto &slavePort = - dynamic_cast(old_checker_dtb_port)-> - getSlavePort(); - old_checker_dtb_port->unbind(); - new_checker_dtb_port->bind(slavePort); - } + if (new_checker_itb_port) + new_checker_itb_port->takeOverFrom(old_checker_itb_port); + if (new_checker_dtb_port) + new_checker_dtb_port->takeOverFrom(old_checker_dtb_port); } } @@ -708,19 +678,8 @@ BaseCPU::takeOverFrom(BaseCPU *oldCPU) // ports are dangling while the old CPU has its ports connected // already. Unbind the old CPU and then bind the ports of the one // we are switching to. - assert(!getInstPort().isConnected()); - assert(oldCPU->getInstPort().isConnected()); - auto &inst_peer_port = - dynamic_cast(oldCPU->getInstPort()).getSlavePort(); - oldCPU->getInstPort().unbind(); - getInstPort().bind(inst_peer_port); - - assert(!getDataPort().isConnected()); - assert(oldCPU->getDataPort().isConnected()); - auto &data_peer_port = - dynamic_cast(oldCPU->getDataPort()).getSlavePort(); - oldCPU->getDataPort().unbind(); - getDataPort().bind(data_peer_port); + getInstPort().takeOverFrom(&oldCPU->getInstPort()); + getDataPort().takeOverFrom(&oldCPU->getDataPort()); } void diff --git a/src/cpu/trace/trace_cpu.cc b/src/cpu/trace/trace_cpu.cc index 6e499dbac..2d26ed062 100644 --- a/src/cpu/trace/trace_cpu.cc +++ b/src/cpu/trace/trace_cpu.cc @@ -106,17 +106,8 @@ void TraceCPU::takeOverFrom(BaseCPU *oldCPU) { // Unbind the ports of the old CPU and bind the ports of the TraceCPU. - assert(!getInstPort().isConnected()); - assert(oldCPU->getInstPort().isConnected()); - Port &inst_peer_port = oldCPU->getInstPort().getSlavePort(); - oldCPU->getInstPort().unbind(); - getInstPort().bind(inst_peer_port); - - assert(!getDataPort().isConnected()); - assert(oldCPU->getDataPort().isConnected()); - Port &data_peer_port = oldCPU->getDataPort().getSlavePort(); - oldCPU->getDataPort().unbind(); - getDataPort().bind(data_peer_port); + getInstPort().takeOverFrom(&oldCPU->getInstPort()); + getDataPort().takeOverFrom(&oldCPU->getDataPort()); } void diff --git a/src/dev/arm/smmu_v3_slaveifc.cc b/src/dev/arm/smmu_v3_slaveifc.cc index 0a53ed0ba..fec480da2 100644 --- a/src/dev/arm/smmu_v3_slaveifc.cc +++ b/src/dev/arm/smmu_v3_slaveifc.cc @@ -80,8 +80,7 @@ void SMMUv3SlaveInterface::sendRange() { if (slavePort->isConnected()) { - inform("Slave port is connected to %d\n", - slavePort->getMasterPort().name()); + inform("Slave port is connected to %s\n", slavePort->getPeer()); slavePort->sendRangeChange(); } else { @@ -124,8 +123,7 @@ Tick SMMUv3SlaveInterface::recvAtomic(PacketPtr pkt) { DPRINTF(SMMUv3, "[a] req from %s addr=%#x size=%#x\n", - slavePort->getMasterPort().name(), - pkt->getAddr(), pkt->getSize()); + slavePort->getPeer(), pkt->getAddr(), pkt->getSize()); std::string proc_name = csprintf("%s.port", name()); SMMUTranslationProcess proc(proc_name, *smmu, *this); @@ -141,8 +139,7 @@ bool SMMUv3SlaveInterface::recvTimingReq(PacketPtr pkt) { DPRINTF(SMMUv3, "[t] req from %s addr=%#x size=%#x\n", - slavePort->getMasterPort().name(), - pkt->getAddr(), pkt->getSize()); + slavePort->getPeer(), pkt->getAddr(), pkt->getSize()); // @todo: We need to pay for this and not just zero it out pkt->headerDelay = pkt->payloadDelay = 0; diff --git a/src/mem/coherent_xbar.cc b/src/mem/coherent_xbar.cc index 74c93be0f..a339500a8 100644 --- a/src/mem/coherent_xbar.cc +++ b/src/mem/coherent_xbar.cc @@ -125,8 +125,7 @@ CoherentXBar::init() for (const auto& p: slavePorts) { // check if the connected master port is snooping if (p->isSnooping()) { - DPRINTF(AddrRanges, "Adding snooping master %s\n", - p->getMasterPort().name()); + DPRINTF(AddrRanges, "Adding snooping master %s\n", p->getPeer()); snoopPorts.push_back(p); } } diff --git a/src/mem/mport.cc b/src/mem/mport.cc index 5678f87d7..6b5ae774b 100644 --- a/src/mem/mport.cc +++ b/src/mem/mport.cc @@ -49,6 +49,6 @@ MessageSlavePort::recvAtomic(PacketPtr pkt) return recvMessage(pkt); } else { panic("%s received unexpected atomic command %s from %s.\n", - name(), pkt->cmd.toString(), getMasterPort().name()); + name(), pkt->cmd.toString(), getPeer()); } } diff --git a/src/mem/xbar.cc b/src/mem/xbar.cc index de32c0b32..16f0e21dd 100644 --- a/src/mem/xbar.cc +++ b/src/mem/xbar.cc @@ -344,7 +344,7 @@ void BaseXBar::recvRangeChange(PortID master_port_id) { DPRINTF(AddrRanges, "Received range change from slave port %s\n", - masterPorts[master_port_id]->getSlavePort().name()); + masterPorts[master_port_id]->getPeer()); // remember that we got a range from this master port and thus the // connected slave module @@ -405,8 +405,8 @@ BaseXBar::recvRangeChange(PortID master_port_id) "%s:\n\t%s\n\t%s\n", name(), r.to_string(), - masterPorts[master_port_id]->getSlavePort().name(), - masterPorts[conflict_id]->getSlavePort().name()); + masterPorts[master_port_id]->getPeer(), + masterPorts[conflict_id]->getPeer()); } } } @@ -557,11 +557,11 @@ BaseXBar::regStats() // and snoop responses) and what came from the slave and was // forwarded to the master (responses and snoop requests) for (int i = 0; i < slavePorts.size(); i++) { - pktCount.subname(i, slavePorts[i]->getMasterPort().name()); - pktSize.subname(i, slavePorts[i]->getMasterPort().name()); + pktCount.subname(i, slavePorts[i]->getPeer().name()); + pktSize.subname(i, slavePorts[i]->getPeer().name()); for (int j = 0; j < masterPorts.size(); j++) { - pktCount.ysubname(j, masterPorts[j]->getSlavePort().name()); - pktSize.ysubname(j, masterPorts[j]->getSlavePort().name()); + pktCount.ysubname(j, masterPorts[j]->getPeer().name()); + pktSize.ysubname(j, masterPorts[j]->getPeer().name()); } } }