Message ID | 1431313647-6804-1-git-send-email-sjg@chromium.org |
---|---|
State | Accepted |
Delegated to: | Simon Glass |
Headers | show |
Hi Simon, On Sun, May 10, 2015 at 10:07 PM, Simon Glass <sjg@chromium.org> wrote: > 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> > --- This is probably what breaks my terminal most times a test fails by crashing. I guess this still won't address that. Why do we need to mess with the terminal? Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
Hi Joe, On 11 May 2015 at 14:00, Joe Hershberger <joe.hershberger@gmail.com> wrote: > Hi Simon, > > On Sun, May 10, 2015 at 10:07 PM, Simon Glass <sjg@chromium.org> wrote: >> 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> >> --- > > This is probably what breaks my terminal most times a test fails by > crashing. I guess this still won't address that. Why do we need to > mess with the terminal? To put it into 'raw' mode so that we can use our normal tstc() / getc() functions and don't need to wait for an end-of-line. > > Reviewed-by: Joe Hershberger <joe.hershberger@ni.com> Regards, Simon
On 11 May 2015 at 16:40, Simon Glass <sjg@chromium.org> wrote: > Hi Joe, > > On 11 May 2015 at 14:00, Joe Hershberger <joe.hershberger@gmail.com> wrote: >> Hi Simon, >> >> On Sun, May 10, 2015 at 10:07 PM, Simon Glass <sjg@chromium.org> wrote: >>> 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> >>> --- >> >> This is probably what breaks my terminal most times a test fails by >> crashing. I guess this still won't address that. Why do we need to >> mess with the terminal? > > To put it into 'raw' mode so that we can use our normal tstc() / > getc() functions and don't need to wait for an end-of-line. > >> >> Reviewed-by: Joe Hershberger <joe.hershberger@ni.com> Applied to u-boot-dm.
diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c index b6aae37..02c4cd3 100644 --- a/arch/sandbox/cpu/cpu.c +++ b/arch/sandbox/cpu/cpu.c @@ -22,6 +22,8 @@ unsigned long map_len; void reset_cpu(ulong ignored) { + /* Do this here while it still has an effect */ + os_fd_restore(); if (state_uninit()) os_exit(2); diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index e6dd17e..8a4d719 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -107,10 +107,12 @@ void os_exit(int exit_code) 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 */ @@ -120,7 +122,6 @@ void os_tty_raw(int fd, bool allow_sigs) if (term_setup) return; - term_setup = true; /* If not a tty, don't complain */ if (tcgetattr(fd, &orig_term)) @@ -134,6 +135,7 @@ void os_tty_raw(int fd, bool allow_sigs) if (tcsetattr(fd, TCSANOW, &term)) return; + term_setup = true; atexit(os_fd_restore); } diff --git a/include/os.h b/include/os.h index ffbdce8..954a48c 100644 --- a/include/os.h +++ b/include/os.h @@ -112,6 +112,14 @@ void os_exit(int exit_code) __attribute__((noreturn)); 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. * * \param length Number of bytes to be allocated
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> --- arch/sandbox/cpu/cpu.c | 2 ++ arch/sandbox/cpu/os.c | 8 +++++--- include/os.h | 8 ++++++++ 3 files changed, 15 insertions(+), 3 deletions(-)