Implement device that will return BadAddress.
authorKevin Lim <ktlim@umich.edu>
Thu, 2 Nov 2006 20:18:35 +0000 (15:18 -0500)
committerKevin Lim <ktlim@umich.edu>
Thu, 2 Nov 2006 20:18:35 +0000 (15:18 -0500)
--HG--
extra : convert_revision : d833c20f691e01c84a0678f19f7d83f3ee50c0c1

src/dev/isa_fake.cc
src/dev/isa_fake.hh

index 23761cd1080c3ecddeb85dc6c485e6e67dfc00a7..ccc9a1f7cb3bb2442524ddcabaac4b59d650e1d9 100644 (file)
@@ -88,6 +88,38 @@ IsaFake::write(PacketPtr pkt)
     return pioDelay;
 }
 
+BadAddr::BadAddr(Params *p)
+    : BasicPioDevice(p)
+{
+}
+
+void
+BadAddr::init()
+{
+    // Only init this device if it's connected to anything.
+    if (pioPort)
+        PioDevice::init();
+}
+
+Tick
+BadAddr::read(PacketPtr pkt)
+{
+    assert(pkt->result == Packet::Unknown);
+    DPRINTF(Tsunami, "read to bad address va=%#x size=%d\n",
+            pkt->getAddr(), pkt->getSize());
+    pkt->result = Packet::BadAddress;
+    return pioDelay;
+}
+
+Tick
+BadAddr::write(PacketPtr pkt)
+{
+    DPRINTF(Tsunami, "write to bad address va=%#x size=%d \n",
+            pkt->getAddr(), pkt->getSize());
+    pkt->result = Packet::BadAddress;
+    return pioDelay;
+}
+
 BEGIN_DECLARE_SIM_OBJECT_PARAMS(IsaFake)
 
     Param<Addr> pio_addr;
@@ -121,3 +153,34 @@ CREATE_SIM_OBJECT(IsaFake)
 }
 
 REGISTER_SIM_OBJECT("IsaFake", IsaFake)
+
+BEGIN_DECLARE_SIM_OBJECT_PARAMS(BadAddr)
+
+    Param<Addr> pio_addr;
+    Param<Tick> pio_latency;
+    SimObjectParam<Platform *> platform;
+    SimObjectParam<System *> system;
+
+END_DECLARE_SIM_OBJECT_PARAMS(BadAddr)
+
+BEGIN_INIT_SIM_OBJECT_PARAMS(BadAddr)
+
+    INIT_PARAM(pio_addr, "Device Address"),
+    INIT_PARAM(pio_latency, "Programmed IO latency"),
+    INIT_PARAM(platform, "platform"),
+    INIT_PARAM(system, "system object")
+
+END_INIT_SIM_OBJECT_PARAMS(BadAddr)
+
+CREATE_SIM_OBJECT(BadAddr)
+{
+    BadAddr::Params *p = new BadAddr::Params;
+    p->name = getInstanceName();
+    p->pio_addr = pio_addr;
+    p->pio_delay = pio_latency;
+    p->platform = platform;
+    p->system = system;
+    return new BadAddr(p);
+}
+
+REGISTER_SIM_OBJECT("BadAddr", BadAddr)
index 366061c25462f217c7c7b2f27beaaff526f5ad1f..6665f1a788d7e97ab4784091b3754b4c13e2eb4f 100644 (file)
@@ -79,4 +79,21 @@ class IsaFake : public BasicPioDevice
     virtual Tick write(PacketPtr pkt);
 };
 
+/**
+ * BadAddr is a device that fills the packet's result field with "BadAddress".
+ * @todo: Consider consolidating with IsaFake and similar classes.
+ */
+class BadAddr : public BasicPioDevice
+{
+  public:
+    struct Params : public BasicPioDevice::Params
+    {
+    };
+
+    BadAddr(Params *p);
+    virtual void init();
+    virtual Tick read(PacketPtr pkt);
+    virtual Tick write(PacketPtr pkt);
+};
+
 #endif // __TSUNAMI_FAKE_HH__