summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel R. Carvalho <odanrc@yahoo.com.br>2018-10-15 12:25:25 +0200
committerDaniel Carvalho <odanrc@yahoo.com.br>2018-11-07 19:34:55 +0000
commit75035f5674df3e497d69404a9093b852d2ccf7aa (patch)
tree5d2d82558ca6be524a2bc8c198f72b72c3b2f251 /src
parentcbbdbcbd6850fa7da83f0def9b6f113ec41da0c0 (diff)
downloadgem5-75035f5674df3e497d69404a9093b852d2ccf7aa.tar.xz
mem-ruby: Use Packet writing functions instead of memcpy
Classes were using memcpy instead of the Packet functions created for writing to/from the packet. This allows these writes to be better checked and tracked. Change-Id: Iae3fba1351330916ee1d4103809c71e151b1639e Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br> Reviewed-on: https://gem5-review.googlesource.com/c/13915 Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>
Diffstat (limited to 'src')
-rw-r--r--src/mem/ruby/slicc_interface/AbstractController.cc11
-rw-r--r--src/mem/ruby/system/GPUCoalescer.cc12
-rw-r--r--src/mem/ruby/system/Sequencer.cc13
3 files changed, 13 insertions, 23 deletions
diff --git a/src/mem/ruby/slicc_interface/AbstractController.cc b/src/mem/ruby/slicc_interface/AbstractController.cc
index de7e03dd7..101a4ce7f 100644
--- a/src/mem/ruby/slicc_interface/AbstractController.cc
+++ b/src/mem/ruby/slicc_interface/AbstractController.cc
@@ -268,10 +268,8 @@ AbstractController::queueMemoryWrite(const MachineID &id, Addr addr,
addr, RubySystem::getBlockSizeBytes(), 0, m_masterId);
PacketPtr pkt = Packet::createWrite(req);
- uint8_t *newData = new uint8_t[RubySystem::getBlockSizeBytes()];
- pkt->dataDynamic(newData);
- memcpy(newData, block.getData(0, RubySystem::getBlockSizeBytes()),
- RubySystem::getBlockSizeBytes());
+ pkt->allocate();
+ pkt->setData(block.getData(0, RubySystem::getBlockSizeBytes()));
SenderState *s = new SenderState(id);
pkt->pushSenderState(s);
@@ -295,9 +293,8 @@ AbstractController::queueMemoryWritePartial(const MachineID &id, Addr addr,
RequestPtr req = std::make_shared<Request>(addr, size, 0, m_masterId);
PacketPtr pkt = Packet::createWrite(req);
- uint8_t *newData = new uint8_t[size];
- pkt->dataDynamic(newData);
- memcpy(newData, block.getData(getOffset(addr), size), size);
+ pkt->allocate();
+ pkt->setData(block.getData(getOffset(addr), size));
SenderState *s = new SenderState(id);
pkt->pushSenderState(s);
diff --git a/src/mem/ruby/system/GPUCoalescer.cc b/src/mem/ruby/system/GPUCoalescer.cc
index e17bf63fd..8b8c9566f 100644
--- a/src/mem/ruby/system/GPUCoalescer.cc
+++ b/src/mem/ruby/system/GPUCoalescer.cc
@@ -640,10 +640,8 @@ GPUCoalescer::hitCallback(GPUCoalescerRequest* srequest,
(type == RubyRequestType_RMW_Read) ||
(type == RubyRequestType_Locked_RMW_Read) ||
(type == RubyRequestType_Load_Linked)) {
- memcpy(pkt->getPtr<uint8_t>(),
- data.getData(getOffset(request_address),
- pkt->getSize()),
- pkt->getSize());
+ pkt->setData(
+ data.getData(getOffset(request_address), pkt->getSize()));
} else {
data.setData(pkt->getPtr<uint8_t>(),
getOffset(request_address), pkt->getSize());
@@ -1097,10 +1095,8 @@ GPUCoalescer::atomicCallback(Addr address,
if (pkt->getPtr<uint8_t>() &&
srequest->m_type != RubyRequestType_ATOMIC_NO_RETURN) {
/* atomics are done in memory, and return the data *before* the atomic op... */
- memcpy(pkt->getPtr<uint8_t>(),
- data.getData(getOffset(request_address),
- pkt->getSize()),
- pkt->getSize());
+ pkt->setData(
+ data.getData(getOffset(request_address), pkt->getSize()));
} else {
DPRINTF(MemoryAccess,
"WARNING. Data not transfered from Ruby to M5 for type " \
diff --git a/src/mem/ruby/system/Sequencer.cc b/src/mem/ruby/system/Sequencer.cc
index f30369710..41ec6ea6c 100644
--- a/src/mem/ruby/system/Sequencer.cc
+++ b/src/mem/ruby/system/Sequencer.cc
@@ -476,17 +476,14 @@ Sequencer::hitCallback(SequencerRequest* srequest, DataBlock& data,
(type == RubyRequestType_RMW_Read) ||
(type == RubyRequestType_Locked_RMW_Read) ||
(type == RubyRequestType_Load_Linked)) {
- memcpy(pkt->getPtr<uint8_t>(),
- data.getData(getOffset(request_address), pkt->getSize()),
- pkt->getSize());
+ pkt->setData(
+ data.getData(getOffset(request_address), pkt->getSize()));
DPRINTF(RubySequencer, "read data %s\n", data);
} else if (pkt->req->isSwap()) {
std::vector<uint8_t> overwrite_val(pkt->getSize());
- memcpy(&overwrite_val[0], pkt->getConstPtr<uint8_t>(),
- pkt->getSize());
- memcpy(pkt->getPtr<uint8_t>(),
- data.getData(getOffset(request_address), pkt->getSize()),
- pkt->getSize());
+ pkt->writeData(&overwrite_val[0]);
+ pkt->setData(
+ data.getData(getOffset(request_address), pkt->getSize()));
data.setData(&overwrite_val[0],
getOffset(request_address), pkt->getSize());
DPRINTF(RubySequencer, "swap data %s\n", data);