/*
- * Copyright (c) 2003 The Regents of The University of Michigan
+ * Copyright (c) 2002-2005 The Regents of The University of Michigan
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* Device module for modelling a fixed bandwidth full duplex ethernet link
*/
-#ifndef __ETHERLINK_HH__
-#define __ETHERLINK_HH__
+#ifndef __DEV_ETHERLINK_HH__
+#define __DEV_ETHERLINK_HH__
-#include "sim/host.hh"
-#include "sim/eventq.hh"
#include "dev/etherint.hh"
#include "dev/etherpkt.hh"
+#include "sim/eventq.hh"
+#include "sim/host.hh"
#include "sim/sim_object.hh"
class EtherDump;
-
+class Checkpoint;
/*
* Model for a fixed bandwidth full duplex ethernet link
*/
protected:
class Interface;
+ friend class LinkDelayEvent;
/*
* Model for a single uni-directional link
*/
- class Link : public Serializeable {
+ class Link
+ {
protected:
std::string objName;
+ EtherLink *parent;
+ int number;
+
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 void DoneEvent::process();
+ DoneEvent doneEvent;
+
+ friend class LinkDelayEvent;
+ void txComplete(PacketPtr packet);
public:
- Link(const std::string &name, double rate, EtherDump *dump);
+ Link(const std::string &name, EtherLink *p, int num,
+ double rate, Tick delay, EtherDump *dump);
~Link() {}
- virtual std::string name() const { return objName; }
+ const std::string name() const { return objName; }
bool busy() const { return (bool)packet; }
bool transmit(PacketPtr packet);
void setTxInt(Interface *i) { assert(!txint); txint = i; }
void setRxInt(Interface *i) { assert(!rxint); rxint = i; }
+
+ void serialize(const std::string &base, std::ostream &os);
+ void unserialize(const std::string &base, Checkpoint *cp,
+ const std::string §ion);
};
/*
public:
Interface(const std::string &name, Link *txlink, Link *rxlink);
bool recvPacket(PacketPtr packet) { return txlink->transmit(packet); }
- void sendDone() { }
+ void sendDone() { peer->sendDone(); }
};
- Link *link1;
- Link *link2;
-
- EtherInt *int1;
- EtherInt *int2;
+ Link *link[2];
+ EtherInt *interface[2];
public:
- EtherLink(const std::string &name, EtherInt *i1, EtherInt *i2,
- Tick speed, EtherDump *dump);
+ EtherLink(const std::string &name, EtherInt *peer0, EtherInt *peer1,
+ double rate, Tick delay, EtherDump *dump);
virtual ~EtherLink();
+
+ virtual void serialize(std::ostream &os);
+ virtual void unserialize(Checkpoint *cp, const std::string §ion);
+
};
#endif // __ETHERLINK_HH__