summaryrefslogtreecommitdiff
path: root/src/dev
diff options
context:
space:
mode:
Diffstat (limited to 'src/dev')
-rw-r--r--src/dev/Serial.py4
-rw-r--r--src/dev/serial.cc22
-rw-r--r--src/dev/serial.hh15
3 files changed, 41 insertions, 0 deletions
diff --git a/src/dev/Serial.py b/src/dev/Serial.py
index bbc792b67..7871b487b 100644
--- a/src/dev/Serial.py
+++ b/src/dev/Serial.py
@@ -42,3 +42,7 @@ class SerialDevice(SimObject):
type = 'SerialDevice'
abstract = True
cxx_header = "dev/serial.hh"
+
+class SerialNullDevice(SerialDevice):
+ type = 'SerialNullDevice'
+ cxx_header = "dev/serial.hh"
diff --git a/src/dev/serial.cc b/src/dev/serial.cc
index 63e8a382b..68fc94c57 100644
--- a/src/dev/serial.cc
+++ b/src/dev/serial.cc
@@ -41,6 +41,7 @@
#include "base/misc.hh"
#include "params/SerialDevice.hh"
+#include "params/SerialNullDevice.hh"
SerialDevice::SerialDevice(const SerialDeviceParams *p)
: SimObject(p), interfaceCallback(nullptr)
@@ -71,3 +72,24 @@ SerialDevice::notifyInterface()
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);
+}
diff --git a/src/dev/serial.hh b/src/dev/serial.hh
index 4ea2f5ea8..230ecaa74 100644
--- a/src/dev/serial.hh
+++ b/src/dev/serial.hh
@@ -44,6 +44,7 @@
#include "sim/sim_object.hh"
struct SerialDeviceParams;
+struct SerialNullDeviceParams;
/**
* Base class for serial devices such as terminals.
@@ -140,4 +141,18 @@ class SerialDevice : public SimObject
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__