diff options
author | Andreas Hansson <andreas.hansson@arm.com> | 2015-01-22 05:00:53 -0500 |
---|---|---|
committer | Andreas Hansson <andreas.hansson@arm.com> | 2015-01-22 05:00:53 -0500 |
commit | f49830ce0ba79c54c65c9c4b25bc3c6184aaf2a9 (patch) | |
tree | 00b2f9f0131ef65a411c9fd81339caecfc946b47 /src/cpu/simple | |
parent | be3a952394e1f337d1c372448ee099203336181a (diff) | |
download | gem5-f49830ce0ba79c54c65c9c4b25bc3c6184aaf2a9.tar.xz |
mem: Clean up Request initialisation
This patch tidies up how we create and set the fields of a Request. In
essence it tries to use the constructor where possible (as opposed to
setPhys and setVirt), thus avoiding spreading the information across a
number of locations. In fact, setPhys is made private as part of this
patch, and a number of places where we callede setVirt instead uses
the appropriate constructor.
Diffstat (limited to 'src/cpu/simple')
-rw-r--r-- | src/cpu/simple/timing.cc | 16 | ||||
-rw-r--r-- | src/cpu/simple/timing.hh | 2 |
2 files changed, 8 insertions, 10 deletions
diff --git a/src/cpu/simple/timing.cc b/src/cpu/simple/timing.cc index c7db5c4f8..8c90d7c4e 100644 --- a/src/cpu/simple/timing.cc +++ b/src/cpu/simple/timing.cc @@ -270,8 +270,7 @@ void TimingSimpleCPU::sendData(RequestPtr req, uint8_t *data, uint64_t *res, bool read) { - PacketPtr pkt; - buildPacket(pkt, req, read); + PacketPtr pkt = buildPacket(req, read); pkt->dataDynamic<uint8_t>(data); if (req->getFlags().isSet(Request::NO_ACCESS)) { assert(!dcache_pkt); @@ -354,10 +353,10 @@ TimingSimpleCPU::translationFault(const Fault &fault) advanceInst(fault); } -void -TimingSimpleCPU::buildPacket(PacketPtr &pkt, RequestPtr req, bool read) +PacketPtr +TimingSimpleCPU::buildPacket(RequestPtr req, bool read) { - pkt = read ? Packet::createRead(req) : Packet::createWrite(req); + return read ? Packet::createRead(req) : Packet::createWrite(req); } void @@ -370,14 +369,13 @@ TimingSimpleCPU::buildSplitPacket(PacketPtr &pkt1, PacketPtr &pkt2, assert(!req1->isMmappedIpr() && !req2->isMmappedIpr()); if (req->getFlags().isSet(Request::NO_ACCESS)) { - buildPacket(pkt1, req, read); + pkt1 = buildPacket(req, read); return; } - buildPacket(pkt1, req1, read); - buildPacket(pkt2, req2, read); + pkt1 = buildPacket(req1, read); + pkt2 = buildPacket(req2, read); - req->setPhys(req1->getPaddr(), req->getSize(), req1->getFlags(), dataMasterId()); PacketPtr pkt = new Packet(req, pkt1->cmd.responseCommand()); pkt->dataDynamic<uint8_t>(data); diff --git a/src/cpu/simple/timing.hh b/src/cpu/simple/timing.hh index 52eb6b1ba..d8460515b 100644 --- a/src/cpu/simple/timing.hh +++ b/src/cpu/simple/timing.hh @@ -137,7 +137,7 @@ class TimingSimpleCPU : public BaseSimpleCPU void translationFault(const Fault &fault); - void buildPacket(PacketPtr &pkt, RequestPtr req, bool read); + PacketPtr buildPacket(RequestPtr req, bool read); void buildSplitPacket(PacketPtr &pkt1, PacketPtr &pkt2, RequestPtr req1, RequestPtr req2, RequestPtr req, uint8_t *data, bool read); |