From 101aa8090a9bdf2a702bb8e17431080879a40ba1 Mon Sep 17 00:00:00 2001 From: Steve Raasch Date: Thu, 30 Oct 2003 11:47:21 -0500 Subject: [PATCH 1/3] Add support for serialization base/pollevent.hh: Add queued() member function to indicate if this event has been queued --HG-- extra : convert_revision : bebb04dc8e10c1043e55e0036806bd1ca4fec167 --- base/pollevent.hh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/base/pollevent.hh b/base/pollevent.hh index 7ae37398c..393c53996 100644 --- a/base/pollevent.hh +++ b/base/pollevent.hh @@ -50,6 +50,8 @@ class PollEvent void disable(); void enable(); virtual void process(int revent) = 0; + + bool queued() { return queue != 0; } }; class PollQueue From 9dac0d3c568d8767a2022afaaf958455df012e42 Mon Sep 17 00:00:00 2001 From: Steve Raasch Date: Thu, 30 Oct 2003 15:15:27 -0500 Subject: [PATCH 2/3] Add support for serialization --HG-- extra : convert_revision : ff6c93ee2f4e6aeb5a824958c52f62d6c2a1cdfd --- base/pollevent.cc | 19 +++++++++++++++++++ base/pollevent.hh | 5 +++++ 2 files changed, 24 insertions(+) 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 §ion) +{ + UNSERIALIZE_SCALAR(pfd.fd); + UNSERIALIZE_SCALAR(pfd.events); + UNSERIALIZE_SCALAR(enabled); +} + ///////////////////////////////////////////////////// // PollQueue::PollQueue() diff --git a/base/pollevent.hh b/base/pollevent.hh index 393c53996..7ea5b83f4 100644 --- a/base/pollevent.hh +++ b/base/pollevent.hh @@ -33,6 +33,8 @@ #include #include "sim/universe.hh" +class Checkpoint; + class PollEvent { private: @@ -52,6 +54,9 @@ class PollEvent 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 §ion); }; class PollQueue From 48ce8b70e62a203b3aff4bacc35a2657c64fb762 Mon Sep 17 00:00:00 2001 From: Steve Raasch Date: Thu, 30 Oct 2003 15:16:00 -0500 Subject: [PATCH 3/3] Add serialization (which Nate now says we probably don't need) --HG-- extra : convert_revision : e075fafdf6e72a424110a120e24ca71cb44cfb03 --- dev/ethertap.cc | 47 +++++++++++++++++++++++++++++++++++++++++++++++ dev/ethertap.hh | 3 +++ 2 files changed, 50 insertions(+) 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 §ion) +{ + 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 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 §ion); }; #endif // __ETHERTAP_HH__