Hello Curtis Dunham,
I'd like you to do a code review. Please visit
https://gem5-review.googlesource.com/4290
to review the following change.
Change subject: dev: Add a dummy serial device
......................................................................
dev: Add a dummy serial device
Add a dummy serial device that discards any output and doesn't provide
any input. This device can be used to terminate UARTs that don't have
a default device (e.g., a terminal) attached.
Change-Id: I4a6b0b5037ce360f59bfb5c566e1698d113a1d26
Signed-off-by: Andreas Sandberg <[email protected]>
Reviewed-by: Curtis Dunham <[email protected]>
---
M src/dev/Serial.py
M src/dev/serial.cc
M src/dev/serial.hh
3 files changed, 57 insertions(+), 0 deletions(-)
diff --git a/src/dev/Serial.py b/src/dev/Serial.py
index b0bdc2c..0e653ad 100644
--- a/src/dev/Serial.py
+++ b/src/dev/Serial.py
@@ -43,3 +43,7 @@
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 c75cdf9..3318cc8 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), deviceDataAvail(nullptr)
@@ -70,3 +71,39 @@
deviceDataAvail->process();
}
+
+
+
+SerialNullDevice::SerialNullDevice(const SerialNullDeviceParams *p)
+ : SerialDevice(p)
+{
+}
+
+SerialNullDevice::~SerialNullDevice()
+{
+}
+
+bool
+SerialNullDevice::dataAvailable() const
+{
+ return false;
+}
+
+void
+SerialNullDevice::out(char c)
+{
+}
+
+uint8_t
+SerialNullDevice::in()
+{
+ 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 d131c48..c902723 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.
@@ -97,4 +98,19 @@
Callback *deviceDataAvail;
};
+/**
+ * Dummy serial device that discards all data sent to it.
+ */
+class SerialNullDevice : public SerialDevice
+{
+ public:
+ SerialNullDevice(const SerialNullDeviceParams *p);
+ ~SerialNullDevice();
+
+ public:
+ bool dataAvailable() const override;
+ void out(char c) override;
+ uint8_t in() override;
+};
+
#endif // __DEV_SERIAL_HH__
--
To view, visit https://gem5-review.googlesource.com/4290
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4a6b0b5037ce360f59bfb5c566e1698d113a1d26
Gerrit-Change-Number: 4290
Gerrit-PatchSet: 1
Gerrit-Owner: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Curtis Dunham <[email protected]>
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev