summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Raasch <sraasch@umich.edu>2003-10-30 15:16:05 -0500
committerSteve Raasch <sraasch@umich.edu>2003-10-30 15:16:05 -0500
commitfd232ecb6ad4bc60933feb3bd5b838c5e0231506 (patch)
tree9fd50bbb0d8ee1276746311fdc1dae41ab0dd653
parent2e2d2099689b1cf4d269542276dbe5cb047e5181 (diff)
parent48ce8b70e62a203b3aff4bacc35a2657c64fb762 (diff)
downloadgem5-fd232ecb6ad4bc60933feb3bd5b838c5e0231506.tar.xz
Merge zizzer.eecs.umich.edu:/m5/Bitkeeper/m5
into zizzer.eecs.umich.edu:/y/sraasch/serialize --HG-- extra : convert_revision : ebb65c27685394826efc265bcc674577395e0963
-rw-r--r--base/pollevent.cc19
-rw-r--r--base/pollevent.hh7
-rw-r--r--dev/ethertap.cc47
-rw-r--r--dev/ethertap.hh3
4 files changed, 76 insertions, 0 deletions
diff --git a/base/pollevent.cc b/base/pollevent.cc
index 45a32581f..619bda887 100644
--- a/base/pollevent.cc
+++ b/base/pollevent.cc
@@ -38,6 +38,9 @@
#include "base/misc.hh"
#include "base/pollevent.hh"
#include "sim/universe.hh"
+#include "sim/serialize.hh"
+
+using namespace std;
PollQueue pollQueue;
@@ -76,6 +79,22 @@ PollEvent::enable()
queue->copy();
}
+void
+PollEvent::serialize(ostream &os)
+{
+ SERIALIZE_SCALAR(pfd.fd);
+ SERIALIZE_SCALAR(pfd.events);
+ SERIALIZE_SCALAR(enabled);
+}
+
+void
+PollEvent::unserialize(Checkpoint *cp, const std::string &section)
+{
+ UNSERIALIZE_SCALAR(pfd.fd);
+ UNSERIALIZE_SCALAR(pfd.events);
+ UNSERIALIZE_SCALAR(enabled);
+}
+
/////////////////////////////////////////////////////
//
PollQueue::PollQueue()
diff --git a/base/pollevent.hh b/base/pollevent.hh
index 7ae37398c..7ea5b83f4 100644
--- a/base/pollevent.hh
+++ b/base/pollevent.hh
@@ -33,6 +33,8 @@
#include <poll.h>
#include "sim/universe.hh"
+class Checkpoint;
+
class PollEvent
{
private:
@@ -50,6 +52,11 @@ class PollEvent
void disable();
void enable();
virtual void process(int revent) = 0;
+
+ bool queued() { return queue != 0; }
+
+ virtual void serialize(std::ostream &os);
+ virtual void unserialize(Checkpoint *cp, const std::string &section);
};
class PollQueue
diff --git a/dev/ethertap.cc b/dev/ethertap.cc
index b99d46ce5..339e7ac78 100644
--- a/dev/ethertap.cc
+++ b/dev/ethertap.cc
@@ -163,6 +163,7 @@ EtherTap::detach()
{
DPRINTF(Ethernet, "EtherTap detached\n");
delete event;
+ event = 0;
close(socket);
socket = -1;
}
@@ -262,6 +263,52 @@ EtherTap::retransmit()
txEvent.schedule(curTick + 1000);
}
+//=====================================================================
+
+void
+EtherTap::serialize(ostream &os)
+{
+ SERIALIZE_SCALAR(socket);
+ SERIALIZE_SCALAR(buflen);
+ SERIALIZE_ARRAY((uint8_t *)buffer,buflen);
+ SERIALIZE_SCALAR(buffer_offset);
+ SERIALIZE_SCALAR(data_len);
+
+ bool tapevent_present = false;
+ if (event) {
+ tapevent_present = true;
+ SERIALIZE_SCALAR(tapevent_present);
+ event->serialize(os);
+ }
+ else {
+ SERIALIZE_SCALAR(tapevent_present);
+ }
+}
+
+void
+EtherTap::unserialize(Checkpoint *cp, const std::string &section)
+{
+ UNSERIALIZE_SCALAR(socket);
+ UNSERIALIZE_SCALAR(buflen);
+ UNSERIALIZE_ARRAY((uint8_t *)buffer,buflen);
+ UNSERIALIZE_SCALAR(buffer_offset);
+ UNSERIALIZE_SCALAR(data_len);
+
+ bool tapevent_present;
+ UNSERIALIZE_SCALAR(tapevent_present);
+ if (tapevent_present) {
+ event = new TapEvent(this, socket, POLLIN|POLLERR);
+
+ event->unserialize(cp,section);
+
+ if (event->queued()) {
+ pollQueue.schedule(event);
+ }
+ }
+}
+
+//=====================================================================
+
BEGIN_DECLARE_SIM_OBJECT_PARAMS(EtherTap)
SimObjectParam<EtherInt *> peer;
diff --git a/dev/ethertap.hh b/dev/ethertap.hh
index 6e99bd91d..e2b1f640f 100644
--- a/dev/ethertap.hh
+++ b/dev/ethertap.hh
@@ -96,6 +96,9 @@ class EtherTap : public EtherInt
virtual bool recvPacket(PacketPtr packet);
virtual void sendDone();
+
+ virtual void serialize(std::ostream &os);
+ virtual void unserialize(Checkpoint *cp, const std::string &section);
};
#endif // __ETHERTAP_HH__