* [PATCH] serial: efi-stdio: implement DEC save/restore cursor
@ 2026-05-01 9:08 Ahmad Fatoum
2026-05-07 10:38 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2026-05-01 9:08 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
term_getsize() employs the DEC save/restore cursor control sequences
(\e7 and \e8) in its determination of the terminal's size.
efi_process_escape() did not handle them and instead expected that all
\e are directly followed by a [.
Implement support for \e7 and \e8 and have the function silently skip
any other non-bracket \eX escape.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
drivers/serial/efi-stdio.c | 26 ++++++++++++++++++++------
1 file changed, 20 insertions(+), 6 deletions(-)
diff --git a/drivers/serial/efi-stdio.c b/drivers/serial/efi-stdio.c
index b474fe635d15..1e7f5a4a3973 100644
--- a/drivers/serial/efi-stdio.c
+++ b/drivers/serial/efi-stdio.c
@@ -39,6 +39,10 @@ struct efi_console_priv {
const char **mode_names;
int *mode_num;
unsigned int var_mode;
+
+ /* saved cursor position for \e7/\e8 */
+ unsigned long saved_row;
+ unsigned long saved_col;
};
static inline struct efi_console_priv *to_efi(struct console_device *cdev)
@@ -274,16 +278,26 @@ static int efi_process_square_bracket(struct efi_console_priv *priv, const char
static int efi_process_escape(struct efi_console_priv *priv, const char *inp)
{
- char c;
-
- c = *inp;
-
+ /* skip ESC, so inp points at the char after it */
inp++;
- if (*inp == '[')
+ switch (*inp) {
+ case '[':
return efi_process_square_bracket(priv, inp) + 1;
+ case '7':
+ /* DEC save cursor position */
+ priv->saved_row = priv->out->mode->cursor_row;
+ priv->saved_col = priv->out->mode->cursor_column;
+ break;
+ case '8':
+ /* DEC restore cursor position */
+ priv->out->set_cursor_position(priv->out,
+ priv->saved_col, priv->saved_row);
+ break;
+ }
- return 1;
+ /* We have consumed ESC + one character following it */
+ return 2;
}
static void efi_console_add_char(struct efi_console_priv *priv, int c)
--
2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-07 10:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-01 9:08 [PATCH] serial: efi-stdio: implement DEC save/restore cursor Ahmad Fatoum
2026-05-07 10:38 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox