summaryrefslogtreecommitdiff
path: root/src/dev/terminal.cc
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.cc
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.cc')
-rw-r--r--src/dev/terminal.cc24
1 files changed, 6 insertions, 18 deletions
diff --git a/src/dev/terminal.cc b/src/dev/terminal.cc
index 9f0ea5ea3..4f9881ddd 100644
--- a/src/dev/terminal.cc
+++ b/src/dev/terminal.cc
@@ -107,7 +107,7 @@ Terminal::DataEvent::process(int revent)
* Terminal code
*/
Terminal::Terminal(const Params *p)
- : SimObject(p), termDataAvail(NULL), listenEvent(NULL), dataEvent(NULL),
+ : SerialDevice(p), listenEvent(NULL), dataEvent(NULL),
number(p->number), data_fd(-1), txbuf(16384), rxbuf(16384),
outfile(p->output ? simout.findOrCreate(p->name) : NULL)
#if TRACING_ON == 1
@@ -133,16 +133,6 @@ Terminal::~Terminal()
delete dataEvent;
}
-void
-Terminal::regDataAvailCallback(Callback *c)
-{
- // This can happen if the user has connected multiple UARTs to the
- // same terminal. In that case, each of them tries to register
- // callbacks.
- if (termDataAvail)
- fatal("Terminal already has already been associated with a UART.\n");
- termDataAvail = c;
-}
///////////////////////////////////////////////////////////////////////
// socket creation and terminal attach
@@ -233,9 +223,7 @@ Terminal::data()
len = read(buf, sizeof(buf));
if (len) {
rxbuf.write((char *)buf, len);
- // Inform the UART there is data available
- assert(termDataAvail);
- termDataAvail->process();
+ notifyInterface();
}
}
@@ -282,7 +270,7 @@ Terminal::write(const uint8_t *buf, size_t len)
#define RECEIVE_ERROR (ULL(3) << 62)
uint8_t
-Terminal::in()
+Terminal::readData()
{
uint8_t c;
@@ -301,7 +289,7 @@ Terminal::console_in()
uint64_t value;
if (dataAvailable()) {
- value = RECEIVE_SUCCESS | in();
+ value = RECEIVE_SUCCESS | readData();
if (!rxbuf.empty())
value |= MORE_PENDING;
} else {
@@ -314,7 +302,7 @@ Terminal::console_in()
}
void
-Terminal::out(char c)
+Terminal::writeData(uint8_t c)
{
#if TRACING_ON == 1
if (DTRACE(Terminal)) {
@@ -343,7 +331,7 @@ Terminal::out(char c)
write(c);
if (outfile)
- outfile->stream()->write(&c, 1);
+ outfile->stream()->put((char)c);
DPRINTF(TerminalVerbose, "out: \'%c\' %#02x\n",
isprint(c) ? c : ' ', (int)c);