#if TRACING_ON
static std::string
-printMemData(uint8_t *data, unsigned size)
+printMemData(const uint8_t *data, unsigned size)
{
std::stringstream dataStr;
for (unsigned pos = 0; pos < size; pos++) {
DPRINTF(InOrderCachePort,
"[tid:%u]: [sn:%i]: Storing data: %s\n",
tid, inst->seqNum,
- printMemData(cache_req->dataPkt->getPtr<uint8_t>(),
+ printMemData(cache_req->dataPkt->getConstPtr<uint8_t>(),
cache_req->dataPkt->getSize()));
if (mem_req->isCondSwap()) {
DPRINTF(InOrderCachePort,
"[tid:%u]: [sn:%i]: Bytes loaded were: %s\n",
tid, inst->seqNum,
- (split_pkt) ? printMemData(split_pkt->getPtr<uint8_t>(),
+ (split_pkt) ? printMemData(split_pkt->getConstPtr<uint8_t>(),
split_pkt->getSize()) :
- printMemData(cache_pkt->getPtr<uint8_t>(),
+ printMemData(cache_pkt->getConstPtr<uint8_t>(),
cache_pkt->getSize()));
} else if(inst->isStore()) {
assert(cache_pkt->isWrite());
DPRINTF(InOrderCachePort,
"[tid:%u]: [sn:%i]: Bytes stored were: %s\n",
tid, inst->seqNum,
- (split_pkt) ? printMemData(split_pkt->getPtr<uint8_t>(),
+ (split_pkt) ? printMemData(split_pkt->getConstPtr<uint8_t>(),
split_pkt->getSize()) :
- printMemData(cache_pkt->getPtr<uint8_t>(),
+ printMemData(cache_pkt->getConstPtr<uint8_t>(),
cache_pkt->getSize()));
}
// Copy Data to pendingFetch queue...
(*pend_it)->block = new uint8_t[cacheBlkSize];
- memcpy((*pend_it)->block, cache_pkt->getPtr<uint8_t>(), cacheBlkSize);
+ memcpy((*pend_it)->block, cache_pkt->getConstPtr<uint8_t>(), cacheBlkSize);
(*pend_it)->valid = true;
cache_req->setMemAccPending(false);
if (is_load && packet->getSize() > 0) {
DPRINTF(MinorMem, "Memory data[0]: 0x%x\n",
- static_cast<unsigned int>(packet->getPtr<uint8_t>()[0]));
+ static_cast<unsigned int>(packet->getConstPtr<uint8_t>()[0]));
}
/* Complete the memory access instruction */
* by the response fragment */
std::memcpy(
data + (response->req->getVaddr() - request.getVaddr()),
- response->getPtr<uint8_t>(),
+ response->getConstPtr<uint8_t>(),
response->req->getSize());
}
}
return;
}
- memcpy(fetchBuffer[tid], pkt->getPtr<uint8_t>(), fetchBufferSize);
+ memcpy(fetchBuffer[tid], pkt->getConstPtr<uint8_t>(), fetchBufferSize);
fetchBufferValid[tid] = true;
// Wake up the CPU (if it went to sleep and was waiting on
if (req->isSwap()) {
assert(res);
- memcpy(res, pkt.getPtr<uint8_t>(), fullSize);
+ memcpy(res, pkt.getConstPtr<uint8_t>(), fullSize);
}
}
safe_cast<MemTestSenderState *>(pkt->senderState);
uint8_t *data = state->data;
+ // @todo: This should really be a const pointer
uint8_t *pkt_data = pkt->getPtr<uint8_t>();
//Remove the address from the list of outstanding
pkt->dataDynamic(writeData);
DPRINTF(RubyTest, "data 0x%x check 0x%x\n",
- *(pkt->getPtr<uint8_t>()), *writeData);
+ *(pkt->getConstPtr<uint8_t>()), *writeData);
// push the subblock onto the sender state. The sequencer will
// update the subblock on the return
A, system()->getMasterName(pkt->req->masterId()), \
pkt->getSize(), pkt->getAddr(), \
pkt->req->isUncacheable() ? 'U' : 'C'); \
- DDUMP(MemoryAccess, pkt->getPtr<uint8_t>(), pkt->getSize()); \
+ DDUMP(MemoryAccess, pkt->getConstPtr<uint8_t>(), pkt->getSize()); \
} \
} while (0)
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->getPtr<uint8_t>(), pkt->getSize());
+ std::memcpy(&overwrite_val[0], pkt->getConstPtr<uint8_t>(),
+ pkt->getSize());
std::memcpy(pkt->getPtr<uint8_t>(), hostAddr, pkt->getSize());
if (pkt->req->isCondSwap()) {
} else if (pkt->isWrite()) {
if (writeOK(pkt)) {
if (pmemAddr) {
- memcpy(hostAddr, pkt->getPtr<uint8_t>(), pkt->getSize());
+ memcpy(hostAddr, pkt->getConstPtr<uint8_t>(), pkt->getSize());
DPRINTF(MemoryAccess, "%s wrote %x bytes to address %x\n",
__func__, pkt->getSize(), pkt->getAddr());
}
pkt->makeResponse();
} else if (pkt->isWrite()) {
if (pmemAddr)
- memcpy(hostAddr, pkt->getPtr<uint8_t>(), pkt->getSize());
+ memcpy(hostAddr, pkt->getConstPtr<uint8_t>(), pkt->getSize());
TRACE_PACKET("Write");
pkt->makeResponse();
} else if (pkt->isPrint()) {
bool pending_downgrade = false);
bool satisfyMSHR(MSHR *mshr, PacketPtr pkt, BlkType *blk);
- void doTimingSupplyResponse(PacketPtr req_pkt, uint8_t *blk_data,
+ void doTimingSupplyResponse(PacketPtr req_pkt, const uint8_t *blk_data,
bool already_copied, bool pending_inval);
/**
blk->status &= ~BlkWritable;
++fastWrites;
}
- std::memcpy(blk->data, pkt->getPtr<uint8_t>(), blkSize);
+ std::memcpy(blk->data, pkt->getConstPtr<uint8_t>(), blkSize);
DPRINTF(Cache, "%s new state is %s\n", __func__, blk->print());
incHitCount(pkt);
return true;
completion_time = clockEdge(responseLatency) +
pkt->lastWordDelay;
if (pkt->isRead() && !is_error) {
- target->pkt->setData(pkt->getPtr<uint8_t>());
+ target->pkt->setData(pkt->getConstPtr<uint8_t>());
}
}
target->pkt->makeTimingResponse();
// if we got new data, copy it in
if (pkt->isRead()) {
- std::memcpy(blk->data, pkt->getPtr<uint8_t>(), blkSize);
+ std::memcpy(blk->data, pkt->getConstPtr<uint8_t>(), blkSize);
}
blk->whenReady = clockEdge() + responseLatency * clockPeriod() +
template<class TagStore>
void
Cache<TagStore>::
-doTimingSupplyResponse(PacketPtr req_pkt, uint8_t *blk_data,
+doTimingSupplyResponse(PacketPtr req_pkt, const uint8_t *blk_data,
bool already_copied, bool pending_inval)
{
// sanity check
// the packet's invalidate flag is set...
assert(pkt->isInvalidate());
}
- doTimingSupplyResponse(pkt, wb_pkt->getPtr<uint8_t>(),
+ doTimingSupplyResponse(pkt, wb_pkt->getConstPtr<uint8_t>(),
false, false);
if (pkt->isInvalidate()) {
pkt = new Packet(tgt_pkt);
pkt->allocate();
if (pkt->isWrite()) {
- pkt->setData(tgt_pkt->getPtr<uint8_t>());
+ pkt->setData(tgt_pkt->getConstPtr<uint8_t>());
}
}
}
DPRINTF(ExternalPort, "StubSlavePort: recvAtomic a: 0x%x size: %d"
" data: ...\n", packet->getAddr(), size);
- DDUMP(ExternalPort, packet->getPtr<uint8_t>(), size);
+ DDUMP(ExternalPort, packet->getConstPtr<uint8_t>(), size);
}
return 0;
}
} else if (isWrite()) {
if (offset >= 0) {
- memcpy(data + offset, getPtr<uint8_t>(),
+ memcpy(data + offset, getConstPtr<uint8_t>(),
(min(func_end, val_end) - func_start) + 1);
} else {
// val_start > func_start
- memcpy(data, getPtr<uint8_t>() - offset,
+ memcpy(data, getConstPtr<uint8_t>() - offset,
(min(func_end, val_end) - val_start) + 1);
}
} else {
bool needsResponse() const { return testCmdAttrib(NeedsResponse); }
bool isInvalidate() const { return testCmdAttrib(IsInvalidate); }
bool hasData() const { return testCmdAttrib(HasData); }
- bool isReadWrite() const { return isRead() && isWrite(); }
bool isLLSC() const { return testCmdAttrib(IsLlsc); }
bool isSWPrefetch() const { return testCmdAttrib(IsSWPrefetch); }
bool isHWPrefetch() const { return testCmdAttrib(IsHWPrefetch); }
bool needsResponse() const { return cmd.needsResponse(); }
bool isInvalidate() const { return cmd.isInvalidate(); }
bool hasData() const { return cmd.hasData(); }
- bool isReadWrite() const { return cmd.isReadWrite(); }
bool isLLSC() const { return cmd.isLLSC(); }
bool isError() const { return cmd.isError(); }
bool isPrint() const { return cmd.isPrint(); }
return (T*)data;
}
+ template <typename T>
+ const T*
+ getConstPtr() const
+ {
+ assert(flags.isSet(STATIC_DATA|DYNAMIC_DATA));
+ return (const T*)data;
+ }
+
/**
* return the value of what is pointed to in the packet.
*/
template <typename T>
- T get();
+ T get() const;
/**
* set the value in the data pointer to v.
* Copy data into the packet from the provided pointer.
*/
void
- setData(uint8_t *p)
+ setData(const uint8_t *p)
{
if (p != getPtr<uint8_t>())
std::memcpy(getPtr<uint8_t>(), p, getSize());
* which is aligned to the given block size.
*/
void
- setDataFromBlock(uint8_t *blk_data, int blkSize)
+ setDataFromBlock(const uint8_t *blk_data, int blkSize)
{
setData(blk_data + getOffset(blkSize));
}
* is aligned to the given block size.
*/
void
- writeData(uint8_t *p)
+ writeData(uint8_t *p) const
{
- std::memcpy(p, getPtr<uint8_t>(), getSize());
+ std::memcpy(p, getConstPtr<uint8_t>(), getSize());
}
/**
* Copy data from the packet to the memory at the provided pointer.
*/
void
- writeDataToBlock(uint8_t *blk_data, int blkSize)
+ writeDataToBlock(uint8_t *blk_data, int blkSize) const
{
writeData(blk_data + getOffset(blkSize));
}
/** return the value of what is pointed to in the packet. */
template <typename T>
inline T
-Packet::get()
+Packet::get() const
{
assert(flags.isSet(STATIC_DATA|DYNAMIC_DATA));
assert(sizeof(T) <= size);
}
void
-DataBlock::setData(uint8_t *data, int offset, int len)
+DataBlock::setData(const uint8_t *data, int offset, int len)
{
assert(offset + len <= RubySystem::getBlockSizeBytes());
memcpy(&m_data[offset], data, len);
uint8_t getByte(int whichByte) const;
const uint8_t *getData(int offset, int len) const;
void setByte(int whichByte, uint8_t data);
- void setData(uint8_t *data, int offset, int len);
+ void setData(const uint8_t *data, int offset, int len);
void copyPartial(const DataBlock & dblk, int offset, int len);
bool equal(const DataBlock& obj) const;
void print(std::ostream& out) const;
Addr mBase = m_PhysicalAddress.getAddress();
Addr mTail = mBase + m_Size;
- uint8_t * pktData = pkt->getPtr<uint8_t>();
+ const uint8_t * pktData = pkt->getConstPtr<uint8_t>();
Addr cBase = std::max(wBase, mBase);
Addr cTail = std::min(wTail, mTail);
lineAddr.makeLineAddress();
if (pktLineAddr == lineAddr) {
- uint8_t *data = pkt->getPtr<uint8_t>();
+ const uint8_t *data = pkt->getConstPtr<uint8_t>();
unsigned int size_in_bytes = pkt->getSize();
unsigned startByte = pkt->getAddr() - lineAddr.getAddress();
// update the data unless it is a non-data-carrying flush
if (g_system_ptr->m_warmup_enabled) {
- data.setData(pkt->getPtr<uint8_t>(),
+ data.setData(pkt->getConstPtr<uint8_t>(),
request_address.getOffset(), pkt->getSize());
} else if (!pkt->isFlush()) {
if ((type == RubyRequestType_LD) ||
data.getData(request_address.getOffset(), pkt->getSize()),
pkt->getSize());
} else {
- data.setData(pkt->getPtr<uint8_t>(),
+ data.setData(pkt->getConstPtr<uint8_t>(),
request_address.getOffset(), pkt->getSize());
}
}