diff options
Diffstat (limited to 'src/dev/io_device.hh')
-rw-r--r-- | src/dev/io_device.hh | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/src/dev/io_device.hh b/src/dev/io_device.hh index c9e25d224..804133893 100644 --- a/src/dev/io_device.hh +++ b/src/dev/io_device.hh @@ -59,19 +59,37 @@ class System; * must respond to. The device must also provide getAddrRanges() function * with which it returns the address ranges it is interested in. */ +template <class Device> class PioPort : public SimpleTimingPort { protected: /** The device that this port serves. */ - PioDevice *device; + Device *device; - virtual Tick recvAtomic(PacketPtr pkt); + Tick + recvAtomic(PacketPtr pkt) override + { + // Technically the packet only reaches us after the header delay, + // and typically we also need to deserialise any payload. + Tick receive_delay = pkt->headerDelay + pkt->payloadDelay; + pkt->headerDelay = pkt->payloadDelay = 0; + + const Tick delay = + pkt->isRead() ? device->read(pkt) : device->write(pkt); + assert(pkt->isResponse() || pkt->isError()); + return delay + receive_delay; + } - virtual AddrRangeList getAddrRanges() const; + AddrRangeList + getAddrRanges() const override + { + return device->getAddrRanges(); + } public: - - PioPort(PioDevice *dev); + PioPort(Device *dev) : + SimpleTimingPort(dev->name() + ".pio", dev), device(dev) + {} }; /** @@ -88,7 +106,7 @@ class PioDevice : public ClockedObject /** The pioPort that handles the requests for us and provides us requests * that it sees. */ - PioPort pioPort; + PioPort<PioDevice> pioPort; /** * Every PIO device is obliged to provide an implementation that @@ -128,7 +146,7 @@ class PioDevice : public ClockedObject Port &getPort(const std::string &if_name, PortID idx=InvalidPortID) override; - friend class PioPort; + friend class PioPort<PioDevice>; }; @@ -159,8 +177,7 @@ class BasicPioDevice : public PioDevice * * @return a list of non-overlapping address ranges */ - virtual AddrRangeList getAddrRanges() const; - + AddrRangeList getAddrRanges() const override; }; #endif // __DEV_IO_DEVICE_HH__ |