mem: Remove redundant Packet::allocate calls

This patch cleans up the packet memory allocation confusion. The data
is always allocated at the requesting side, when a packet is created
(or copied), and there is never a need for any device to allocate any
space if it is merely responding to a paket. This behaviour is in line
with how SystemC and TLM works as well, thus increasing
interoperability, and matching established conventions.

The redundant calls to Packet::allocate are removed, and the checks in
the function are tightened up to make sure data is only ever allocated
once. There are still some oddities in the packet copy constructor
where we copy the data pointer if it is static (without ownership),
and allocate new space if the data is dynamic (with ownership). The
latter is being worked on further in a follow-on patch.
This commit is contained in:
Andreas Hansson
2014-12-02 06:07:41 -05:00
parent 0706a25203
commit 5df96cb690
35 changed files with 6 additions and 72 deletions

View File

@@ -172,8 +172,6 @@ IdeController::readConfig(PacketPtr pkt)
return PciDevice::readConfig(pkt);
}
pkt->allocate();
switch (pkt->getSize()) {
case sizeof(uint8_t):
switch (offset) {
@@ -462,7 +460,6 @@ IdeController::Channel::accessBMI(Addr offset,
void
IdeController::dispatchAccess(PacketPtr pkt, bool read)
{
pkt->allocate();
if (pkt->getSize() != 1 && pkt->getSize() != 2 && pkt->getSize() !=4)
panic("Bad IDE read size: %d\n", pkt->getSize());