// Now do the access
if (fault == NoFault &&
!memReq->getFlags().isSet(Request::NO_ACCESS)) {
- PacketPtr pkt = new Packet(memReq,
- memReq->isLLSC() ?
- MemCmd::LoadLockedReq :
- MemCmd::ReadReq);
+ PacketPtr pkt = Packet::createRead(memReq);
pkt->dataStatic(data);
void
CacheUnit::buildDataPacket(CacheRequest *cache_req)
{
- // Check for LL/SC and if so change command
- if (cache_req->memReq->isLLSC() && cache_req->pktCmd == MemCmd::ReadReq) {
- cache_req->pktCmd = MemCmd::LoadLockedReq;
- }
-
- if (cache_req->pktCmd == MemCmd::WriteReq) {
- cache_req->pktCmd =
- cache_req->memReq->isSwap() ? MemCmd::SwapReq :
- (cache_req->memReq->isLLSC() ? MemCmd::StoreCondReq
- : MemCmd::WriteReq);
- }
-
cache_req->dataPkt = new CacheReqPacket(cache_req,
cache_req->pktCmd,
cache_req->instIdx);
+ cache_req->dataPkt->refineCommand(); // handle LL/SC, etc.
+
DPRINTF(InOrderCachePort, "[slot:%i]: Slot marked for %x\n",
cache_req->getSlot(),
cache_req->dataPkt->getAddr());
// if we the cache is not blocked, do cache access
bool completedFirst = false;
- MemCmd command = req->isLLSC() ? MemCmd::LoadLockedReq : MemCmd::ReadReq;
- PacketPtr data_pkt = new Packet(req, command);
+ PacketPtr data_pkt = Packet::createRead(req);
PacketPtr fst_data_pkt = NULL;
PacketPtr snd_data_pkt = NULL;
fst_data_pkt = data_pkt;
} else {
// Create the split packets.
- fst_data_pkt = new Packet(sreqLow, command);
- snd_data_pkt = new Packet(sreqHigh, command);
+ fst_data_pkt = Packet::createRead(sreqLow);
+ snd_data_pkt = Packet::createRead(sreqHigh);
fst_data_pkt->dataStatic(load_inst->memData);
snd_data_pkt->dataStatic(load_inst->memData + sreqLow->getSize());
else
memcpy(inst->memData, storeQueue[storeWBIdx].data, req->getSize());
- MemCmd command =
- req->isSwap() ? MemCmd::SwapReq :
- (req->isLLSC() ? MemCmd::StoreCondReq : MemCmd::WriteReq);
PacketPtr data_pkt;
PacketPtr snd_data_pkt = NULL;
if (!TheISA::HasUnalignedMemAcc || !storeQueue[storeWBIdx].isSplit) {
// Build a single data packet if the store isn't split.
- data_pkt = new Packet(req, command);
+ data_pkt = Packet::createWrite(req);
data_pkt->dataStatic(inst->memData);
data_pkt->senderState = state;
} else {
// Create two packets if the store is split in two.
- data_pkt = new Packet(sreqLow, command);
- snd_data_pkt = new Packet(sreqHigh, command);
+ data_pkt = Packet::createWrite(sreqLow);
+ snd_data_pkt = Packet::createWrite(sreqHigh);
data_pkt->dataStatic(inst->memData);
snd_data_pkt->dataStatic(inst->memData + sreqLow->getSize());
DPRINTF(OzoneLSQ, "Doing timing access for inst PC %#x\n",
inst->readPC());
- PacketPtr data_pkt =
- new Packet(req,
- (req->isLLSC() ?
- MemCmd::LoadLockedReq : Packet::ReadReq));
+ PacketPtr data_pkt = Packet::createRead(req);
data_pkt->dataStatic(inst->memData);
LSQSenderState *state = new LSQSenderState;
memcpy(inst->memData, (uint8_t *)&(*sq_it).data,
req->getSize());
- MemCmd command =
- req->isSwap() ? MemCmd::SwapReq :
- (req->isLLSC() ? MemCmd::WriteReq : MemCmd::StoreCondReq);
- PacketPtr data_pkt = new Packet(req, command);
+ PacketPtr data_pkt = Packet::createWrite(req);
data_pkt->dataStatic(inst->memData);
LSQSenderState *state = new LSQSenderState;
// Now do the access.
if (fault == NoFault && !req->getFlags().isSet(Request::NO_ACCESS)) {
- Packet pkt = Packet(req,
- req->isLLSC() ? MemCmd::LoadLockedReq :
- MemCmd::ReadReq);
+ Packet pkt(req, MemCmd::ReadReq);
+ pkt.refineCommand();
pkt.dataStatic(data);
if (req->isMmappedIpr())
void
TimingSimpleCPU::buildPacket(PacketPtr &pkt, RequestPtr req, bool read)
{
- MemCmd cmd;
- if (read) {
- cmd = MemCmd::ReadReq;
- if (req->isLLSC())
- cmd = MemCmd::LoadLockedReq;
- } else {
- cmd = MemCmd::WriteReq;
- if (req->isLLSC()) {
- cmd = MemCmd::StoreCondReq;
- } else if (req->isSwap()) {
- cmd = MemCmd::SwapReq;
- }
- }
- pkt = new Packet(req, cmd);
+ pkt = read ? Packet::createRead(req) : Packet::createWrite(req);
}
void
/*
- * Copyright (c) 2012-2013 ARM Limited
+ * Copyright (c) 2012-2014 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
flags.set(pkt->flags & (VALID_ADDR|VALID_SIZE));
flags.set(pkt->flags & STATIC_DATA);
+ }
+
+ /**
+ * Change the packet type based on request type.
+ */
+ void
+ refineCommand()
+ {
+ if (cmd == MemCmd::ReadReq) {
+ if (req->isLLSC()) {
+ cmd = MemCmd::LoadLockedReq;
+ }
+ } else if (cmd == MemCmd::WriteReq) {
+ if (req->isLLSC()) {
+ cmd = MemCmd::StoreCondReq;
+ } else if (req->isSwap()) {
+ cmd = MemCmd::SwapReq;
+ }
+ }
+ }
+
+ /**
+ * Constructor-like methods that return Packets based on Request objects.
+ * Will call refineCommand() to fine-tune the Packet type if it's not a
+ * vanilla read or write.
+ */
+ static PacketPtr
+ createRead(Request *req)
+ {
+ PacketPtr pkt = new Packet(req, MemCmd::ReadReq);
+ pkt->refineCommand();
+ return pkt;
+ }
+ static PacketPtr
+ createWrite(Request *req)
+ {
+ PacketPtr pkt = new Packet(req, MemCmd::WriteReq);
+ pkt->refineCommand();
+ return pkt;
}
/**