diff options
author | Andreas Hansson <andreas.hansson@arm.com> | 2012-08-28 14:30:27 -0400 |
---|---|---|
committer | Andreas Hansson <andreas.hansson@arm.com> | 2012-08-28 14:30:27 -0400 |
commit | d14e5857c7e1ee053fb4eb448c4776d7c985c5b2 (patch) | |
tree | e57462955190d314ee97fbe7c3a3a53178aa5148 /src/cpu | |
parent | fb5dd28420d6cebdf4f12a095c3aa32cd5611ed9 (diff) | |
download | gem5-d14e5857c7e1ee053fb4eb448c4776d7c985c5b2.tar.xz |
Port: Stricter port bind/unbind semantics
This patch tightens up the semantics around port binding and checks
that the ports that are being bound are currently not connected, and
similarly connected before unbind is called.
The patch consequently also changes the order of the unbind and bind
for the switching of CPUs to ensure that the rules are adhered
to. Previously the ports would be "over-written" without any check.
There are no changes in behaviour due to this patch, and the only
place where the unbind functionality is used is in the CPU.
Diffstat (limited to 'src/cpu')
-rw-r--r-- | src/cpu/base.cc | 55 |
1 files changed, 33 insertions, 22 deletions
diff --git a/src/cpu/base.cc b/src/cpu/base.cc index c1b1e6d36..ff832f562 100644 --- a/src/cpu/base.cc +++ b/src/cpu/base.cc @@ -389,17 +389,21 @@ BaseCPU::takeOverFrom(BaseCPU *oldCPU) MasterPort *new_dtb_port = newTC->getDTBPtr()->getMasterPort(); // Move over any table walker ports if they exist - if (new_itb_port && !new_itb_port->isConnected()) { + if (new_itb_port) { + assert(!new_itb_port->isConnected()); assert(old_itb_port); + assert(old_itb_port->isConnected()); SlavePort &slavePort = old_itb_port->getSlavePort(); + old_itb_port->unbind(); new_itb_port->bind(slavePort); - old_itb_port->unBind(); } - if (new_dtb_port && !new_dtb_port->isConnected()) { + if (new_dtb_port) { + assert(!new_dtb_port->isConnected()); assert(old_dtb_port); + assert(old_dtb_port->isConnected()); SlavePort &slavePort = old_dtb_port->getSlavePort(); + old_dtb_port->unbind(); new_dtb_port->bind(slavePort); - old_dtb_port->unBind(); } // Checker whether or not we have to transfer CheckerCPU @@ -417,17 +421,21 @@ BaseCPU::takeOverFrom(BaseCPU *oldCPU) newChecker->getDTBPtr()->getMasterPort(); // Move over any table walker ports if they exist for checker - if (new_checker_itb_port && !new_checker_itb_port->isConnected()) { + if (new_checker_itb_port) { + assert(!new_checker_itb_port->isConnected()); assert(old_checker_itb_port); - SlavePort &slavePort = old_checker_itb_port->getSlavePort();; + assert(old_checker_itb_port->isConnected()); + SlavePort &slavePort = old_checker_itb_port->getSlavePort(); + old_checker_itb_port->unbind(); new_checker_itb_port->bind(slavePort); - old_checker_itb_port->unBind(); } - if (new_checker_dtb_port && !new_checker_dtb_port->isConnected()) { + if (new_checker_dtb_port) { + assert(!new_checker_dtb_port->isConnected()); assert(old_checker_dtb_port); - SlavePort &slavePort = old_checker_dtb_port->getSlavePort();; + assert(old_checker_dtb_port->isConnected()); + SlavePort &slavePort = old_checker_dtb_port->getSlavePort(); + old_checker_dtb_port->unbind(); new_checker_dtb_port->bind(slavePort); - old_checker_dtb_port->unBind(); } } } @@ -444,18 +452,21 @@ BaseCPU::takeOverFrom(BaseCPU *oldCPU) schedule(profileEvent, curTick()); } - // Connect new CPU to old CPU's memory only if new CPU isn't - // connected to anything. Also connect old CPU's memory to new - // CPU. - if (!getInstPort().isConnected()) { - getInstPort().bind(oldCPU->getInstPort().getSlavePort()); - oldCPU->getInstPort().unBind(); - } - - if (!getDataPort().isConnected()) { - getDataPort().bind(oldCPU->getDataPort().getSlavePort()); - oldCPU->getDataPort().unBind(); - } + // All CPUs have an instruction and a data port, and the new CPU's + // 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()); + SlavePort &inst_peer_port = oldCPU->getInstPort().getSlavePort(); + oldCPU->getInstPort().unbind(); + getInstPort().bind(inst_peer_port); + + assert(!getDataPort().isConnected()); + assert(oldCPU->getDataPort().isConnected()); + SlavePort &data_peer_port = oldCPU->getDataPort().getSlavePort(); + oldCPU->getDataPort().unbind(); + getDataPort().bind(data_peer_port); } |