summaryrefslogtreecommitdiff
path: root/src/dev/terminal.hh
diff options
context:
space:
mode:
authorAndreas Sandberg <andreas.sandberg@arm.com>2017-07-20 11:20:17 +0100
committerAndreas Sandberg <andreas.sandberg@arm.com>2017-11-08 10:32:54 +0000
commitd6c204c67d42a3cea9d603888ec52a8d8dacf1a3 (patch)
tree3c5c0f263d122a4d13901e432ff408bfa905f1f3 /src/dev/terminal.hh
parent344911b885114b8401482679202aaee89fa8b29b (diff)
downloadgem5-d6c204c67d42a3cea9d603888ec52a8d8dacf1a3.tar.xz
dev: Refactor UART->Terminal interface
The UART models currently assume that they are always wired to a terminal. While true at the moment, this isn't necessarily a valid assumption. This change introduces the SerialDevice class that defines the interface for serial devices. Currently, Terminal is the only class that implements this interface. Change-Id: I74fefafbbaf5ac1ec0d4ec0b5a0f4b246fdad305 Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-by: Curtis Dunham <curtis.dunham@arm.com> Reviewed-on: https://gem5-review.googlesource.com/4289 Reviewed-by: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/dev/terminal.hh')
-rw-r--r--src/dev/terminal.hh33
1 files changed, 7 insertions, 26 deletions
diff --git a/src/dev/terminal.hh b/src/dev/terminal.hh
index 41c2a9e26..8b6ec0b7f 100644
--- a/src/dev/terminal.hh
+++ b/src/dev/terminal.hh
@@ -43,30 +43,15 @@
#include "base/pollevent.hh"
#include "base/socket.hh"
#include "cpu/intr_control.hh"
+#include "dev/serial.hh"
#include "params/Terminal.hh"
#include "sim/sim_object.hh"
class OutputStream;
class TerminalListener;
-class Terminal : public SimObject
+class Terminal : public SerialDevice
{
- public:
- /**
- * Register a data available callback into the transport layer.
- *
- * The terminal needs to call the underlying transport layer to
- * inform it of available data. The transport layer uses this
- * method to register a callback that informs it of pending data.
- *
- * @param c Callback instance from transport layer.
- */
- void regDataAvailCallback(Callback *c);
-
- protected:
- /** Currently registered transport layer callbacks */
- Callback *termDataAvail;
-
protected:
class ListenEvent : public PollEvent
{
@@ -129,13 +114,15 @@ class Terminal : public SimObject
size_t write(const uint8_t *buf, size_t len);
void detach();
+ public: // SerialDevice interface
+ uint8_t readData() override;
+ void writeData(uint8_t c) override;
+ bool dataAvailable() const override { return !rxbuf.empty(); }
+
public:
/////////////////
// OS interface
- // Get a character from the terminal.
- uint8_t in();
-
// get a character from the terminal in the console specific format
// corresponds to GETC:
// retval<63:61>
@@ -149,12 +136,6 @@ class Terminal : public SimObject
//
// Interrupts are cleared when the buffer is empty.
uint64_t console_in();
-
- // Send a character to the terminal
- void out(char c);
-
- // Ask the terminal if data is available
- bool dataAvailable() { return !rxbuf.empty(); }
};
#endif // __DEV_TERMINAL_HH__