Only issue responses if we aren;t already blocked
[gem5.git] / src / dev / sinic.cc
index dddda1f1cbc7c398b4dd933bde7dce289d808868..61fb3aa2467daef1c6db61b38373fd33b15bce1c 100644 (file)
@@ -921,7 +921,7 @@ Device::rxKick()
         break;
 
       case rxBeginCopy:
-        if (dmaPending())
+        if (dmaPending() || getState() != Running)
             goto exit;
 
         rxDmaAddr = params()->platform->pciToDma(
@@ -1109,7 +1109,7 @@ Device::txKick()
         break;
 
       case txBeginCopy:
-        if (dmaPending())
+        if (dmaPending() || getState() != Running)
             goto exit;
 
         txDmaAddr = params()->platform->pciToDma(
@@ -1287,6 +1287,18 @@ Device::recvPacket(EthPacketPtr packet)
     return true;
 }
 
+void
+Device::resume()
+{
+    SimObject::resume();
+
+    // During drain we could have left the state machines in a waiting state and
+    // they wouldn't get out until some other event occured to kick them.
+    // This way they'll get out immediately
+    txKick();
+    rxKick();
+}
+
 //=====================================================================
 //
 //
@@ -1586,24 +1598,24 @@ Device::unserialize(Checkpoint *cp, const std::string &section)
 
 }
 
+/* namespace Sinic */ }
 
-BEGIN_DECLARE_SIM_OBJECT_PARAMS(Interface)
+BEGIN_DECLARE_SIM_OBJECT_PARAMS_WNS(Sinic, SinicInterface)
 
     SimObjectParam<EtherInt *> peer;
-    SimObjectParam<Device *> device;
+    SimObjectParam<Sinic::Device *> device;
+END_DECLARE_SIM_OBJECT_PARAMS_WNS(Sinic, SinicInterface)
 
-END_DECLARE_SIM_OBJECT_PARAMS(Interface)
-
-BEGIN_INIT_SIM_OBJECT_PARAMS(Interface)
+BEGIN_INIT_SIM_OBJECT_PARAMS_WNS(Sinic, SinicInterface)
 
     INIT_PARAM_DFLT(peer, "peer interface", NULL),
     INIT_PARAM(device, "Ethernet device of this interface")
 
-END_INIT_SIM_OBJECT_PARAMS(Interface)
+END_INIT_SIM_OBJECT_PARAMS_WNS(Sinic, SinicInterface)
 
-CREATE_SIM_OBJECT(Interface)
+CREATE_SIM_OBJECT_WNS(Sinic, SinicInterface)
 {
-    Interface *dev_int = new Interface(getInstanceName(), device);
+    Sinic::Interface *dev_int = new Sinic::Interface(getInstanceName(), device);
 
     EtherInt *p = (EtherInt *)peer;
     if (p) {
@@ -1614,10 +1626,10 @@ CREATE_SIM_OBJECT(Interface)
     return dev_int;
 }
 
-REGISTER_SIM_OBJECT("SinicInt", Interface)
+REGISTER_SIM_OBJECT_WNS(Sinic, "SinicInt", SinicInterface)
 
 
-BEGIN_DECLARE_SIM_OBJECT_PARAMS(Device)
+BEGIN_DECLARE_SIM_OBJECT_PARAMS_WNS(Sinic, SinicDevice)
 
 
     SimObjectParam<System *> system;
@@ -1627,6 +1639,7 @@ BEGIN_DECLARE_SIM_OBJECT_PARAMS(Device)
     Param<uint32_t> pci_dev;
     Param<uint32_t> pci_func;
     Param<Tick> pio_latency;
+    Param<Tick> config_latency;
     Param<Tick> intr_delay;
 
     Param<Tick> clock;
@@ -1657,9 +1670,9 @@ BEGIN_DECLARE_SIM_OBJECT_PARAMS(Device)
     Param<bool> delay_copy;
     Param<bool> virtual_addr;
 
-END_DECLARE_SIM_OBJECT_PARAMS(Device)
+END_DECLARE_SIM_OBJECT_PARAMS_WNS(Sinic, SinicDevice)
 
-BEGIN_INIT_SIM_OBJECT_PARAMS(Device)
+BEGIN_INIT_SIM_OBJECT_PARAMS_WNS(Sinic, SinicDevice)
 
 
     INIT_PARAM(system, "System pointer"),
@@ -1669,6 +1682,7 @@ BEGIN_INIT_SIM_OBJECT_PARAMS(Device)
     INIT_PARAM(pci_dev, "PCI device number"),
     INIT_PARAM(pci_func, "PCI function code"),
     INIT_PARAM_DFLT(pio_latency, "Programmed IO latency in bus cycles", 1),
+    INIT_PARAM(config_latency, "Number of cycles for a config read or write"),
     INIT_PARAM(intr_delay, "Interrupt Delay"),
     INIT_PARAM(clock, "State machine cycle time"),
 
@@ -1699,12 +1713,12 @@ BEGIN_INIT_SIM_OBJECT_PARAMS(Device)
     INIT_PARAM(delay_copy, ""),
     INIT_PARAM(virtual_addr, "")
 
-END_INIT_SIM_OBJECT_PARAMS(Device)
+END_INIT_SIM_OBJECT_PARAMS_WNS(Sinic, SinicDevice)
 
 
-CREATE_SIM_OBJECT(Device)
+CREATE_SIM_OBJECT_WNS(Sinic, SinicDevice)
 {
-    Device::Params *params = new Device::Params;
+    Sinic::Sinic::Device::Params *params = new Device::Params;
     params->name = getInstanceName();
     params->platform = platform;
     params->system = system;
@@ -1713,6 +1727,7 @@ CREATE_SIM_OBJECT(Device)
     params->deviceNum = pci_dev;
     params->functionNum = pci_func;
     params->pio_delay = pio_latency;
+    params->config_delay = config_latency;
     params->intr_delay = intr_delay;
     params->clock = clock;
 
@@ -1743,9 +1758,8 @@ CREATE_SIM_OBJECT(Device)
     params->delay_copy = delay_copy;
     params->virtual_addr = virtual_addr;
 
-    return new Device(params);
+    return new Sinic::Device(params);
 }
 
-REGISTER_SIM_OBJECT("Sinic", Device)
+REGISTER_SIM_OBJECT_WNS(Sinic, "Sinic", SinicDevice)
 
-/* namespace Sinic */ }