type = 'SerialDevice'
abstract = True
cxx_header = "dev/serial.hh"
+
+class SerialNullDevice(SerialDevice):
+ type = 'SerialNullDevice'
+ cxx_header = "dev/serial.hh"
#include "base/misc.hh"
#include "params/SerialDevice.hh"
+#include "params/SerialNullDevice.hh"
SerialDevice::SerialDevice(const SerialDeviceParams *p)
: SimObject(p), interfaceCallback(nullptr)
interfaceCallback->process();
}
+
+
+
+SerialNullDevice::SerialNullDevice(const SerialNullDeviceParams *p)
+ : SerialDevice(p)
+{
+}
+
+uint8_t
+SerialNullDevice::readData()
+{
+ panic("SerialNullDevice does not have pending data.\n");
+}
+
+
+
+SerialNullDevice *
+SerialNullDeviceParams::create()
+{
+ return new SerialNullDevice(this);
+}
#include "sim/sim_object.hh"
struct SerialDeviceParams;
+struct SerialNullDeviceParams;
/**
* Base class for serial devices such as terminals.
Callback *interfaceCallback;
};
+/**
+ * Dummy serial device that discards all data sent to it.
+ */
+class SerialNullDevice : public SerialDevice
+{
+ public:
+ SerialNullDevice(const SerialNullDeviceParams *p);
+
+ public:
+ bool dataAvailable() const override { return false; }
+ void writeData(uint8_t c) override {};
+ uint8_t readData() override;
+};
+
#endif // __DEV_SERIAL_HH__