Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,23 @@
#include "riscv.h"
#include "riscv_private.h"

/*
* The control mode flag for keyboard.
*
* ICANON: Enable canonical mode.
* ECHO: Echo input characters.
* ISIG: When any of the characters INTR, QUIT,
* SUSP, or DSUSP are received, generate the
* corresponding signal.
*
* It is essential to re-enable ISIG upon exit.
* Otherwise, the default signal handler will
* not catch the signal. E.g., SIGINT generated by
* CTRL + c.
*
*/
#define TERMIOS_C_CFLAG (ICANON | ECHO | ISIG)

/* Emulate 8250 (plain, without loopback mode support) */

#define U8250_INT_THRE 1
Expand All @@ -19,7 +36,7 @@ static void reset_keyboard_input()
/* Re-enable echo, etc. on keyboard. */
struct termios term;
tcgetattr(0, &term);
term.c_lflag |= ICANON | ECHO;
term.c_lflag |= TERMIOS_C_CFLAG;
tcsetattr(0, TCSANOW, &term);
}

Expand All @@ -31,7 +48,7 @@ void capture_keyboard_input()

struct termios term;
tcgetattr(0, &term);
term.c_lflag &= ~(ICANON | ECHO | ISIG); /* Disable echo as well */
term.c_lflag &= ~TERMIOS_C_CFLAG; /* Disable echo as well */
tcsetattr(0, TCSANOW, &term);
}

Expand Down
Loading