SERIALIZE_SCALAR(event_time);
}
- if (packet_exists) {
- nameOut(os, csprintf("%s.packet", name()));
- packet->serialize(os);
- }
+ if (packet_exists)
+ packet->serialize("packet", os);
}
void
UNSERIALIZE_SCALAR(packet_exists);
if (packet_exists) {
packet = new PacketData;
- packet->unserialize(cp, csprintf("%s.packet", section));
+ packet->unserialize("packet", cp, section);
}
bool event_scheduled;
Event::serialize(os);
SERIALIZE_OBJPTR(link);
- nameOut(os, csprintf("%s.packet", name()));
- packet->serialize(os);
+ packet->serialize("packet", os);
}
{
Event::unserialize(cp, section);
packet = new PacketData;
- packet->unserialize(cp, csprintf("%s.packet", section));
+ packet->unserialize("packet", cp, section);
}
#include <iostream>
+#include "base/misc.hh"
#include "dev/etherpkt.hh"
#include "sim/serialize.hh"
using namespace std;
void
-PacketData::serialize(ostream &os)
+PacketData::serialize(const string &base, ostream &os)
{
- SERIALIZE_SCALAR(length);
- SERIALIZE_ARRAY(data, length);
+ paramOut(os, base + ".length", length);
+ arrayParamOut(os, base + ".data", data, length);
}
void
-PacketData::unserialize(Checkpoint *cp, const string §ion)
+PacketData::unserialize(const string &base, Checkpoint *cp,
+ const string §ion)
{
- UNSERIALIZE_SCALAR(length);
- data = new uint8_t[length];
- UNSERIALIZE_ARRAY(data, length);
+ paramIn(cp, section, base + ".length", length);
+ arrayParamIn(cp, section, base + ".data", data, length);
}
public:
PacketData() : data(NULL), length(0) { }
+ explicit PacketData(size_t size) : data(new uint8_t[size]), length(0) { }
PacketData(std::auto_ptr<uint8_t> d, int l)
: data(d.release()), length(l) { }
~PacketData() { if (data) delete [] data; }
public:
- void serialize(std::ostream &os);
- void unserialize(Checkpoint *cp, const std::string §ion);
+ void serialize(const std::string &base, std::ostream &os);
+ void unserialize(const std::string &base, Checkpoint *cp,
+ const std::string §ion);
};
typedef RefCountingPtr<PacketData> PacketPtr;
SERIALIZE_SCALAR(txNumPkts);
int i = 0;
pktiter_t end = txFifo.end();
- for (pktiter_t p = txFifo.begin(); p != end; ++p) {
- nameOut(os, csprintf("%s.txFifo%d", name(), i++));
- (*p)->serialize(os);
- }
+ for (pktiter_t p = txFifo.begin(); p != end; ++p)
+ (*p)->serialize(csprintf("txFifo%d", i++), os);
int rxNumPkts = rxFifo.size();
SERIALIZE_SCALAR(rxNumPkts);
i = 0;
end = rxFifo.end();
- for (pktiter_t p = rxFifo.begin(); p != end; ++p) {
- nameOut(os, csprintf("%s.rxFifo%d", name(), i++));
- (*p)->serialize(os);
- }
+ for (pktiter_t p = rxFifo.begin(); p != end; ++p)
+ (*p)->serialize(csprintf("rxFifo%d", i++), os);
/*
* Serialize the various helper variables
bool txPacketExists = txPacket;
SERIALIZE_SCALAR(txPacketExists);
if (txPacketExists) {
- nameOut(os, csprintf("%s.txPacket", name()));
- txPacket->serialize(os);
+ txPacket->serialize("txPacket", os);
uint32_t txPktBufPtr = (uint32_t) (txPacketBufPtr - txPacket->data);
SERIALIZE_SCALAR(txPktBufPtr);
}
bool rxPacketExists = rxPacket;
SERIALIZE_SCALAR(rxPacketExists);
if (rxPacketExists) {
- nameOut(os, csprintf("%s.rxPacket", name()));
- rxPacket->serialize(os);
+ rxPacket->serialize("rxPacket", os);
uint32_t rxPktBufPtr = (uint32_t) (rxPacketBufPtr - rxPacket->data);
SERIALIZE_SCALAR(rxPktBufPtr);
}
int i;
for (i = 0; i < txNumPkts; ++i) {
PacketPtr p = new PacketData;
- p->unserialize(cp, csprintf("%s.rxFifo%d", section, i));
+ p->unserialize(csprintf("rxFifo%d", i), cp, section);
txFifo.push_back(p);
}
UNSERIALIZE_SCALAR(rxNumPkts);
for (i = 0; i < rxNumPkts; ++i) {
PacketPtr p = new PacketData;
- p->unserialize(cp, csprintf("%s.rxFifo%d", section, i));
+ p->unserialize(csprintf("rxFifo%d", i), cp, section);
rxFifo.push_back(p);
}
UNSERIALIZE_SCALAR(txPacketExists);
if (txPacketExists) {
txPacket = new PacketData;
- txPacket->unserialize(cp, csprintf("%s.txPacket", section));
+ txPacket->unserialize("txPacket", cp, section);
uint32_t txPktBufPtr;
UNSERIALIZE_SCALAR(txPktBufPtr);
txPacketBufPtr = (uint8_t *) txPacket->data + txPktBufPtr;
rxPacket = 0;
if (rxPacketExists) {
rxPacket = new PacketData;
- rxPacket->unserialize(cp, csprintf("%s.rxPacket", section));
+ rxPacket->unserialize("rxPacket", cp, section);
uint32_t rxPktBufPtr;
UNSERIALIZE_SCALAR(rxPktBufPtr);
rxPacketBufPtr = (uint8_t *) rxPacket->data + rxPktBufPtr;