48 #include <sys/ioctl.h> 50 #if defined(__FreeBSD__) 54 #include <sys/termios.h> 74 #include "debug/Terminal.hh" 75 #include "debug/TerminalVerbose.hh" 114 else if (revent & POLLNVAL)
151 switch (p->outfile) {
154 case Enums::TerminalDump::stdoutput:
156 case Enums::TerminalDump::stderror:
158 case Enums::TerminalDump::file:
161 panic(
"Invalid option\n");
173 warn_once(
"Sockets disabled, not accepting terminal connections");
179 ": can't bind address terminal port %d inuse PID %d\n",
184 ccprintf(cerr,
"%s: Listening for connections on port %d\n",
195 panic(
"%s: cannot accept a connection if not listening!",
name());
199 char message[] =
"terminal already attached!\n";
210 ccprintf(stream,
"==== m5 slave terminal: Terminal %d ====",
number);
216 write((
const uint8_t *)stream.str().c_str(), stream.str().size());
220 for (
size_t i = 0;
i <
txbuf.
size();
i +=
sizeof(buf)) {
221 const size_t chunk_len(std::min(
txbuf.
size() -
i,
sizeof(buf)));
223 write((
const uint8_t *)buf, chunk_len);
248 len =
read(buf,
sizeof(buf));
259 panic(
"Terminal not properly attached.\n");
264 }
while (ret == -1 && errno == EINTR);
283 panic(
"Terminal not properly attached.\n");
292 #define MORE_PENDING (ULL(1) << 61) 293 #define RECEIVE_SUCCESS (ULL(0) << 62) 294 #define RECEIVE_NONE (ULL(2) << 62) 295 #define RECEIVE_ERROR (ULL(3) << 62) 305 DPRINTF(TerminalVerbose,
"in: \'%c\' %#02x more: %d\n",
324 DPRINTF(TerminalVerbose,
"console_in: return: %#x\n", value);
334 static char last =
'\0';
336 if ((c !=
'\n' && c !=
'\r') || (last !=
'\n' && last !=
'\r')) {
337 if (c ==
'\n' || c ==
'\r') {
338 int size = linebuf.size();
339 char *buffer =
new char[size + 1];
340 linebuf.read(buffer, size);
345 linebuf.write(&c, 1);
361 DPRINTF(TerminalVerbose,
"out: \'%c\' %#02x\n",
362 isprint(c) ? c :
' ', (
int)c);
367 TerminalParams::create()
#define panic(...)
This implements a cprintf based panic() function.
void ccprintf(cp::Print &print)
uint8_t readData() override
Read a character from the device.
virtual bool listen(int port, bool reuse=true)
OutputStream * terminalDump(const TerminalParams *p)
void notifyInterface()
Notify the host interface of pending data.
void writeData(uint8_t c) override
Transmit a character from the host interface to the device.
Overload hash function for BasicBlockRange type.
std::ostream * stream() const
Get the output underlying output stream.
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)
bool dataAvailable() const override
Check if there is pending data from the serial device.
void peek(OutputIterator out, size_t len) const
Copy buffer contents without advancing the read pointer.
virtual int accept(bool nodelay=false)
const FlagsType none
Nothing extra to print.
void write(InputIterator in, size_t len)
Add elements to the end of the ring buffers and advance.
Base class for serial devices such as terminals.
virtual const std::string name() const
bool empty() const
Is the queue empty?
void read(OutputIterator out, size_t len)
Copy buffer contents and advance the read pointer.
OutputStream * findOrCreate(const std::string &name, bool binary=false)
ListenEvent * listenEvent
EventQueue * eventQueue() const
ListenEvent(Terminal *t, int fd, int e)
void remove(PollEvent *event)
Terminal(const Params *p)
DataEvent(Terminal *t, int fd, int e)