ARM: Add support for running multiple systems
[gem5.git] / src / dev / etherbus.cc
index cedb3cd4dbf8ef08f8ab5db547697444cd8b1a13..c9e9c93ba9895395d2ad878eacbfd532abf50c02 100644 (file)
 #include <vector>
 
 #include "base/trace.hh"
+#include "debug/Ethernet.hh"
+#include "debug/EthernetData.hh"
 #include "dev/etherbus.hh"
 #include "dev/etherdump.hh"
 #include "dev/etherint.hh"
 #include "dev/etherpkt.hh"
-#include "sim/builder.hh"
+#include "params/EtherBus.hh"
 #include "sim/core.hh"
 
 using namespace std;
 
-EtherBus::EtherBus(const string &name, double speed, bool loop,
-                   EtherDump *packet_dump)
-    : SimObject(name), ticksPerByte(speed), loopback(loop),
-      event(&mainEventQueue, this), sender(0), dump(packet_dump)
+EtherBus::EtherBus(const Params *p)
+    : EtherObject(p), ticksPerByte(p->speed), loopback(p->loopback),
+      event(this), sender(0), dump(p->dump)
 {
 }
 
@@ -78,15 +79,17 @@ EtherBus::txDone()
     packet = 0;
 }
 
-void
-EtherBus::reg(EtherInt *dev)
-{ devlist.push_back(dev); }
+EtherInt*
+EtherBus::getEthPort(const std::string &if_name, int idx)
+{
+    panic("Etherbus doesn't work\n");
+}
 
 bool
 EtherBus::send(EtherInt *sndr, EthPacketPtr &pkt)
 {
     if (busy()) {
-        DPRINTF(Ethernet, "ethernet packet not sent, bus busy\n", curTick);
+        DPRINTF(Ethernet, "ethernet packet not sent, bus busy\n", curTick());
         return false;
     }
 
@@ -98,30 +101,13 @@ EtherBus::send(EtherInt *sndr, EthPacketPtr &pkt)
     int delay = (int)ceil(((double)pkt->length * ticksPerByte) + 1.0);
     DPRINTF(Ethernet, "scheduling packet: delay=%d, (rate=%f)\n",
             delay, ticksPerByte);
-    event.schedule(curTick + delay);
+    schedule(event, curTick() + delay);
 
     return true;
 }
 
-BEGIN_DECLARE_SIM_OBJECT_PARAMS(EtherBus)
-
-    Param<bool> loopback;
-    Param<double> speed;
-    SimObjectParam<EtherDump *> packet_dump;
-
-END_DECLARE_SIM_OBJECT_PARAMS(EtherBus)
-
-BEGIN_INIT_SIM_OBJECT_PARAMS(EtherBus)
-
-    INIT_PARAM(loopback, "send the packet back to the sending interface"),
-    INIT_PARAM(speed, "bus speed in ticks per byte"),
-    INIT_PARAM(packet_dump, "object to dump network packets to")
-
-END_INIT_SIM_OBJECT_PARAMS(EtherBus)
-
-CREATE_SIM_OBJECT(EtherBus)
+EtherBus *
+EtherBusParams::create()
 {
-    return new EtherBus(getInstanceName(), speed, loopback, packet_dump);
+    return new EtherBus(this);
 }
-
-REGISTER_SIM_OBJECT("EtherBus", EtherBus)