diff options
author | Gabe Black <gabeblack@google.com> | 2019-08-16 23:21:56 -0700 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2019-08-27 22:18:28 +0000 |
commit | 4d503eeffee054de0aab10962c345ca4bcb54140 (patch) | |
tree | f85cff96b40616488a885019c902627b484f2695 /src/cpu | |
parent | f4f31b261cdda95fe6e5a5a71ce232ee479686ae (diff) | |
download | gem5-4d503eeffee054de0aab10962c345ca4bcb54140.tar.xz |
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 <noreply+kokoro@google.com>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Diffstat (limited to 'src/cpu')
-rw-r--r-- | src/cpu/base.cc | 61 | ||||
-rw-r--r-- | src/cpu/trace/trace_cpu.cc | 13 |
2 files changed, 12 insertions, 62 deletions
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<BaseMasterPort *>(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<BaseMasterPort *>(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<BaseMasterPort *>(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<BaseMasterPort *>(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<BaseMasterPort &>(oldCPU->getInstPort()).getSlavePort(); - oldCPU->getInstPort().unbind(); - getInstPort().bind(inst_peer_port); - - assert(!getDataPort().isConnected()); - assert(oldCPU->getDataPort().isConnected()); - auto &data_peer_port = - dynamic_cast<BaseMasterPort &>(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 |