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.sandberg@arm.com> Reviewed-by: Curtis Dunham <curtis.dunham@arm.com> Reviewed-on: https://gem5-review.googlesource.com/4290 Reviewed-by: Gabe Black <gabeblack@google.com>
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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__
|
||||
|
||||
Reference in New Issue
Block a user