if (pkt->cmd == MemCmd::SwapReq) {
if (pkt->isAtomicOp()) {
if (pmemAddr) {
- memcpy(pkt->getPtr<uint8_t>(), hostAddr, pkt->getSize());
+ pkt->setData(hostAddr);
(*(pkt->getAtomicOp()))(hostAddr);
}
} else {
uint64_t condition_val64;
uint32_t condition_val32;
- if (!pmemAddr)
- panic("Swap only works if there is real memory (i.e. null=False)");
+ panic_if(!pmemAddr, "Swap only works if there is real memory " \
+ "(i.e. null=False)");
bool overwrite_mem = true;
// keep a copy of our possible write value, and copy what is at the
// memory address into the packet
- std::memcpy(&overwrite_val[0], pkt->getConstPtr<uint8_t>(),
- pkt->getSize());
- std::memcpy(pkt->getPtr<uint8_t>(), hostAddr, pkt->getSize());
+ pkt->writeData(&overwrite_val[0]);
+ pkt->setData(hostAddr);
if (pkt->req->isCondSwap()) {
if (pkt->getSize() == sizeof(uint64_t)) {
// to do the LL/SC tracking here
trackLoadLocked(pkt);
}
- if (pmemAddr)
- memcpy(pkt->getPtr<uint8_t>(), hostAddr, pkt->getSize());
+ if (pmemAddr) {
+ pkt->setData(hostAddr);
+ }
TRACE_PACKET(pkt->req->isInstFetch() ? "IFetch" : "Read");
numReads[pkt->req->masterId()]++;
bytesRead[pkt->req->masterId()] += pkt->getSize();
} else if (pkt->isWrite()) {
if (writeOK(pkt)) {
if (pmemAddr) {
- memcpy(hostAddr, pkt->getConstPtr<uint8_t>(), pkt->getSize());
+ pkt->writeData(hostAddr);
DPRINTF(MemoryAccess, "%s wrote %i bytes to address %x\n",
__func__, pkt->getSize(), pkt->getAddr());
}
uint8_t *hostAddr = pmemAddr + pkt->getAddr() - range.start();
if (pkt->isRead()) {
- if (pmemAddr)
- memcpy(pkt->getPtr<uint8_t>(), hostAddr, pkt->getSize());
+ if (pmemAddr) {
+ pkt->setData(hostAddr);
+ }
TRACE_PACKET("Read");
pkt->makeResponse();
} else if (pkt->isWrite()) {
- if (pmemAddr)
- memcpy(hostAddr, pkt->getConstPtr<uint8_t>(), pkt->getSize());
+ if (pmemAddr) {
+ pkt->writeData(hostAddr);
+ }
TRACE_PACKET("Write");
pkt->makeResponse();
} else if (pkt->isPrint()) {
if (pkt->isAtomicOp()) {
// extract data from cache and save it into the data field in
// the packet as a return value from this atomic op
-
int offset = tags->extractBlkOffset(pkt->getAddr());
uint8_t *blk_data = blk->data + offset;
- std::memcpy(pkt->getPtr<uint8_t>(), blk_data, pkt->getSize());
+ pkt->setData(blk_data);
// execute AMO operation
(*(pkt->getAtomicOp()))(blk_data);
// write. For reads, we have no data yet, so it doesn't make sense to
// allocate.
pkt_data.reset(new uint8_t[size]);
- memcpy(pkt_data.get(), pkt->getConstPtr<uint8_t*>(), size);
+ pkt->writeData(pkt_data.get());
}
// If a cache miss is served by a cache, a monitor near the memory
// a read. For writes, we have already given the MemChecker the data on
// the request, so it doesn't make sense to allocate on write.
pkt_data.reset(new uint8_t[size]);
- memcpy(pkt_data.get(), pkt->getConstPtr<uint8_t*>(), size);
+ pkt->writeData(pkt_data.get());
}
if (is_read || is_write) {