Renamed OpClass enum members: they all end in 'Op' now.
[gem5.git] / dev / etherlink.hh
index ea7bdcbccd796c229033168acd6724b6bb64efe8..3b1dd21bc2e18e6e0e1954fd34ec96a639295b49 100644 (file)
@@ -49,53 +49,49 @@ class EtherLink : public SimObject
   protected:
     class Interface;
 
+    friend class LinkDelayEvent;
      /*
       * Model for a single uni-directional link
       */
-    class Link : public Serializeable {
+    class Link : public Serializable {
       protected:
         std::string objName;
 
         Interface *txint;
         Interface *rxint;
 
-        double ticks_per_byte;
+        double ticksPerByte;
+        Tick linkDelay;
         EtherDump *dump;
 
       protected:
         /*
          * Transfer is complete
          */
-        class DoneEvent : public Event
-        {
-          protected:
-            Link *link;
-
-          public:
-            DoneEvent(EventQueue *q, Link *l)
-                : Event(q), link(l) {}
-            virtual void process() { link->txDone(); }
-            virtual const char *description()
-                { return "ethernet link completion"; }
-        };
-
-        friend class DoneEvent;
-        DoneEvent event;
         PacketPtr packet;
-
         void txDone();
+        typedef EventWrapper<Link, &Link::txDone> DoneEvent;
+        friend class DoneEvent;
+        DoneEvent doneEvent;
+
+        friend class LinkDelayEvent;
+        void txComplete(PacketPtr &packet);
 
       public:
-        Link(const std::string &name, double rate, EtherDump *dump);
+        Link(const std::string &name, double rate, Tick delay,
+             EtherDump *dump);
         ~Link() {}
 
-        virtual std::string name() const { return objName; }
+        virtual const std::string name() const { return objName; }
 
         bool busy() const { return (bool)packet; }
-        bool transmit(PacketPtr packet);
+        bool transmit(PacketPtr &packet);
 
         void setTxInt(Interface *i) { assert(!txint); txint = i; }
         void setRxInt(Interface *i) { assert(!rxint); rxint = i; }
+
+        virtual void serialize(std::ostream &os);
+        virtual void unserialize(Checkpoint *cp, const std::string &section);
     };
 
     /*
@@ -108,7 +104,7 @@ class EtherLink : public SimObject
 
       public:
         Interface(const std::string &name, Link *txlink, Link *rxlink);
-        bool recvPacket(PacketPtr packet) { return txlink->transmit(packet); }
+        bool recvPacket(PacketPtr &packet) { return txlink->transmit(packet); }
         void sendDone() { }
     };
 
@@ -120,8 +116,12 @@ class EtherLink : public SimObject
 
   public:
     EtherLink(const std::string &name, EtherInt *i1, EtherInt *i2,
-              Tick speed, EtherDump *dump);
+              Tick speed, Tick delay, EtherDump *dump);
     virtual ~EtherLink();
+
+    virtual void serialize(std::ostream &os);
+    virtual void unserialize(Checkpoint *cp, const std::string &section);
+
 };
 
 #endif // __ETHERLINK_HH__