36 #include <sys/ioctl.h>
38 #if defined(__FreeBSD__)
42 #include <sys/termios.h>
62 #include "debug/Terminal.hh"
63 #include "debug/TerminalVerbose.hh"
102 else if (revent & POLLNVAL)
143 fatal(
"Terminal already has already been associated with a UART.\n");
155 warn_once(
"Sockets disabled, not accepting terminal connections");
161 ": can't bind address terminal port %d inuse PID %d\n",
167 p2 =
name().rfind(
'.') - 1;
168 p1 =
name().rfind(
'.', p2);
169 ccprintf(cerr,
"Listening for %s connection on port %d\n",
170 name().substr(p1+1,p2-p1), port);
180 panic(
"%s: cannot accept a connection if not listening!",
name());
184 char message[] =
"terminal already attached!\n";
195 ccprintf(stream,
"==== m5 slave terminal: Terminal %d ====",
number);
201 write((
const uint8_t *)stream.str().c_str(), stream.str().size());
205 for (
size_t i = 0;
i <
txbuf.
size();
i +=
sizeof(buf)) {
206 const size_t chunk_len(std::min(
txbuf.
size() -
i,
sizeof(buf)));
208 write((
const uint8_t *)buf, chunk_len);
233 len =
read(buf,
sizeof(buf));
246 panic(
"Terminal not properly attached.\n");
251 }
while (ret == -1 && errno == EINTR);
270 panic(
"Terminal not properly attached.\n");
279 #define MORE_PENDING (ULL(1) << 61)
280 #define RECEIVE_SUCCESS (ULL(0) << 62)
281 #define RECEIVE_NONE (ULL(2) << 62)
282 #define RECEIVE_ERROR (ULL(3) << 62)
292 DPRINTF(TerminalVerbose,
"in: \'%c\' %#02x more: %d\n",
311 DPRINTF(TerminalVerbose,
"console_in: return: %#x\n", value);
321 static char last =
'\0';
323 if ((c !=
'\n' && c !=
'\r') || (last !=
'\n' && last !=
'\r')) {
324 if (c ==
'\n' || c ==
'\r') {
325 int size = linebuf.size();
326 char *buffer =
new char[size + 1];
327 linebuf.read(buffer, size);
332 linebuf.write(&c, 1);
348 DPRINTF(TerminalVerbose,
"out: \'%c\' %#02x\n",
349 isprint(c) ? c :
' ', (
int)c);
354 TerminalParams::create()
void ccprintf(cp::Print &print)
std::ostream * stream() const
Get the output underlying output stream.
size_t size() const
Return the number of elements stored in the buffer.
virtual void process()=0
virtual process function that is invoked when the callback queue is executed.
virtual bool listen(int port, bool reuse=true)
static void output(const char *filename)
void regDataAvailCallback(Callback *c)
Register a data available callback into the transport layer.
bool empty() const
Is the buffer empty?
void schedule(PollEvent *event)
Temporarily migrate execution to a different event queue.
static bool allDisabled()
ssize_t atomic_write(int fd, const void *s, size_t n)
Callback * termDataAvail
Currently registered transport layer callbacks.
virtual int accept(bool nodelay=false)
void write(InputIterator in, size_t len)
Add elements to the end of the ring buffers and advance.
void peek(OutputIterator out, size_t len) const
Copy buffer contents without advancing the read pointer.
void read(OutputIterator out, size_t len)
Copy buffer contents and advance the read pointer.
ListenEvent * listenEvent
virtual const std::string name() const
ListenEvent(Terminal *t, int fd, int e)
void remove(PollEvent *event)
Abstract superclass for simulation objects.
if(it_gpu==gpuTypeMap.end())
Terminal(const Params *p)
DataEvent(Terminal *t, int fd, int e)