From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH] serial: efi-stdio: implement DEC save/restore cursor
Date: Fri, 1 May 2026 11:08:00 +0200 [thread overview]
Message-ID: <20260501090801.1041468-1-a.fatoum@barebox.org> (raw)
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
next reply other threads:[~2026-05-01 9:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-01 9:08 Ahmad Fatoum [this message]
2026-05-07 10:38 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260501090801.1041468-1-a.fatoum@barebox.org \
--to=a.fatoum@barebox.org \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox