For some reason 'u-boot -D' does not restore the terminal correctly when
the 'reset' command is used. Call the terminal restore function explicitly
in this case.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
void reset_cpu(ulong ignored)
{
+ /* Do this here while it still has an effect */
+ os_fd_restore();
if (state_uninit())
os_exit(2);
static struct termios orig_term;
static bool term_setup;
-static void os_fd_restore(void)
+void os_fd_restore(void)
{
- if (term_setup)
+ if (term_setup) {
tcsetattr(0, TCSANOW, &orig_term);
+ term_setup = false;
+ }
}
/* Put tty into raw mode so <tab> and <ctrl+c> work */
if (term_setup)
return;
- term_setup = true;
/* If not a tty, don't complain */
if (tcgetattr(fd, &orig_term))
if (tcsetattr(fd, TCSANOW, &term))
return;
+ term_setup = true;
atexit(os_fd_restore);
}
*/
void os_tty_raw(int fd, bool allow_sigs);
+/**
+ * Restore the tty to its original mode
+ *
+ * Call this to restore the original terminal mode, after it has been changed
+ * by os_tty_raw(). This is an internal function.
+ */
+void os_fd_restore(void);
+
/**
* Acquires some memory from the underlying os.
*