Andreas Sandberg has submitted this change and it was merged. ( https://gem5-review.googlesource.com/4290 )

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 <andreas.sandb...@arm.com>
Reviewed-by: Curtis Dunham <curtis.dun...@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/4290
Reviewed-by: Gabe Black <gabebl...@google.com>
---
M src/dev/Serial.py
M src/dev/serial.cc
M src/dev/serial.hh
3 files changed, 41 insertions(+), 0 deletions(-)

Approvals:
  Gabe Black: Looks good to me, approved
  Andreas Sandberg: Looks good to me, approved



diff --git a/src/dev/Serial.py b/src/dev/Serial.py
index bbc792b..7871b48 100644
--- a/src/dev/Serial.py
+++ b/src/dev/Serial.py
@@ -42,3 +42,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 63e8a38..68fc94c 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 @@
         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 4ea2f5e..230ecaa 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 @@
     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__

--
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: merged
Gerrit-Change-Id: I4a6b0b5037ce360f59bfb5c566e1698d113a1d26
Gerrit-Change-Number: 4290
Gerrit-PatchSet: 4
Gerrit-Owner: Andreas Sandberg <andreas.sandb...@arm.com>
Gerrit-Reviewer: Andreas Sandberg <andreas.sandb...@arm.com>
Gerrit-Reviewer: Curtis Dunham <curtis.dun...@arm.com>
Gerrit-Reviewer: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Jason Lowe-Power <ja...@lowepower.com>
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to