Add serialization for packets on the ethernet link,
and for link events --HG-- extra : convert_revision : 0054dbc4a42dd38ff8bbf64af303bc509dd5aa8a
This commit is contained in:
parent
4ec55bef11
commit
373d70980e
|
@ -42,6 +42,7 @@
|
||||||
#include "dev/etherpkt.hh"
|
#include "dev/etherpkt.hh"
|
||||||
#include "sim/builder.hh"
|
#include "sim/builder.hh"
|
||||||
#include "sim/universe.hh"
|
#include "sim/universe.hh"
|
||||||
|
#include "sim/system.hh"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -84,6 +85,20 @@ EtherLink::Link::Link(const std::string &name, double rate, EtherDump *d)
|
||||||
dump(d), event(&mainEventQueue, this)
|
dump(d), event(&mainEventQueue, this)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
void
|
||||||
|
EtherLink::serialize(ostream &os)
|
||||||
|
{
|
||||||
|
link1->serialize(os);
|
||||||
|
link2->serialize(os);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
EtherLink::unserialize(Checkpoint *cp, const string §ion)
|
||||||
|
{
|
||||||
|
link1->unserialize(cp, section);
|
||||||
|
link2->unserialize(cp, section);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
EtherLink::Link::txDone()
|
EtherLink::Link::txDone()
|
||||||
{
|
{
|
||||||
|
@ -121,6 +136,42 @@ EtherLink::Link::transmit(PacketPtr &pkt)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
EtherLink::Link::serialize(ostream &os)
|
||||||
|
{
|
||||||
|
bool packetExists = false;
|
||||||
|
if (packet) packetExists = true;
|
||||||
|
SERIALIZE_SCALAR(packetExists);
|
||||||
|
if (packetExists) {
|
||||||
|
nameOut(os, csprintf("%s.linkPacket", name()));
|
||||||
|
packet->serialize(os);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool event_scheduled = event.scheduled();
|
||||||
|
SERIALIZE_SCALAR(event_scheduled);
|
||||||
|
if (event_scheduled) {
|
||||||
|
SERIALIZE_SCALAR(event.when());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
EtherLink::Link::unserialize(Checkpoint *cp, const string §ion)
|
||||||
|
{
|
||||||
|
bool event_scheduled, packetExists;
|
||||||
|
Tick eventTime;
|
||||||
|
UNSERIALIZE_SCALAR(packetExists);
|
||||||
|
if (packetExists) {
|
||||||
|
packet = new EtherPacket;
|
||||||
|
packet->unserialize(cp, csprintf("%s.linkPacket", section));
|
||||||
|
}
|
||||||
|
|
||||||
|
UNSERIALIZE_SCALAR(event_scheduled);
|
||||||
|
if (event_scheduled) {
|
||||||
|
UNSERIALIZE_SCALAR(eventTime);
|
||||||
|
event.schedule(eventTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BEGIN_DECLARE_SIM_OBJECT_PARAMS(EtherLink)
|
BEGIN_DECLARE_SIM_OBJECT_PARAMS(EtherLink)
|
||||||
|
|
||||||
SimObjectParam<EtherInt *> interface1;
|
SimObjectParam<EtherInt *> interface1;
|
||||||
|
|
|
@ -96,6 +96,9 @@ class EtherLink : public SimObject
|
||||||
|
|
||||||
void setTxInt(Interface *i) { assert(!txint); txint = i; }
|
void setTxInt(Interface *i) { assert(!txint); txint = i; }
|
||||||
void setRxInt(Interface *i) { assert(!rxint); rxint = i; }
|
void setRxInt(Interface *i) { assert(!rxint); rxint = i; }
|
||||||
|
|
||||||
|
virtual void serialize(std::ostream &os);
|
||||||
|
virtual void unserialize(Checkpoint *cp, const std::string §ion);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -122,6 +125,10 @@ class EtherLink : public SimObject
|
||||||
EtherLink(const std::string &name, EtherInt *i1, EtherInt *i2,
|
EtherLink(const std::string &name, EtherInt *i1, EtherInt *i2,
|
||||||
Tick speed, EtherDump *dump);
|
Tick speed, EtherDump *dump);
|
||||||
virtual ~EtherLink();
|
virtual ~EtherLink();
|
||||||
|
|
||||||
|
virtual void serialize(std::ostream &os);
|
||||||
|
virtual void unserialize(Checkpoint *cp, const std::string §ion);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __ETHERLINK_HH__
|
#endif // __ETHERLINK_HH__
|
||||||
|
|
Loading…
Reference in a new issue