From: "Pali Rohár" <pali@kernel.org>
To: u-boot@lists.denx.de
Subject: [PATCH] bootmenu: Allow to quit it via CTRL+C
Date: Sat, 26 Dec 2020 19:02:25 +0100 [thread overview]
Message-ID: <20201226180225.17563-1-pali@kernel.org> (raw)
When CTRL+C is pressed interrupt bootmenu and jump into U-Boot console.
As the last entry in bootmenu is always U-Boot console just choose the last
entry when CTRL+C is pressed.
It is useful when bootmenu is part of boot process and you want to
interrupt boot process by scripts which control U-Boot (serial) console.
Signed-off-by: Pali Roh?r <pali@kernel.org>
---
| 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
--git a/cmd/bootmenu.c b/cmd/bootmenu.c
index 1ba7b622e5..9b56bfaa9a 100644
--- a/cmd/bootmenu.c
+++ b/cmd/bootmenu.c
@@ -45,6 +45,7 @@ enum bootmenu_key {
KEY_UP,
KEY_DOWN,
KEY_SELECT,
+ KEY_QUIT,
};
static char *bootmenu_getoption(unsigned short int n)
@@ -109,6 +110,9 @@ static void bootmenu_autoboot_loop(struct bootmenu_data *menu,
case '\r':
*key = KEY_SELECT;
break;
+ case 0x3: /* ^C */
+ *key = KEY_QUIT;
+ break;
default:
*key = KEY_NONE;
break;
@@ -187,6 +191,10 @@ static void bootmenu_loop(struct bootmenu_data *menu,
/* enter key was pressed */
if (c == '\r')
*key = KEY_SELECT;
+
+ /* ^C was pressed */
+ if (c == 0x3)
+ *key = KEY_QUIT;
}
static char *bootmenu_choice_entry(void *data)
@@ -222,6 +230,12 @@ static char *bootmenu_choice_entry(void *data)
for (i = 0; i < menu->active; ++i)
iter = iter->next;
return iter->key;
+ case KEY_QUIT:
+ /* Quit by choosing the last entry - U-Boot console */
+ iter = menu->first;
+ while (iter->next)
+ iter = iter->next;
+ return iter->key;
default:
break;
}
@@ -389,7 +403,7 @@ static void menu_display_statusline(struct menu *m)
printf(ANSI_CURSOR_POSITION, menu->count + 5, 1);
puts(ANSI_CLEAR_LINE);
printf(ANSI_CURSOR_POSITION, menu->count + 6, 1);
- puts(" Press UP/DOWN to move, ENTER to select");
+ puts(" Press UP/DOWN to move, ENTER to select, CTRL+C to quit");
puts(ANSI_CLEAR_LINE_TO_END);
printf(ANSI_CURSOR_POSITION, menu->count + 7, 1);
puts(ANSI_CLEAR_LINE);
--
2.20.1
next reply other threads:[~2020-12-26 18:02 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-26 18:02 Pali Rohár [this message]
2020-12-26 18:44 ` [PATCH] bootmenu: Allow to quit it via CTRL+C Heinrich Schuchardt
2020-12-26 19:03 ` Pali Rohár
2020-12-26 19:10 ` Heinrich Schuchardt
2020-12-26 19:15 ` Pali Rohár
2020-12-26 19:44 ` Heinrich Schuchardt
2020-12-26 19:50 ` Pali Rohár
2020-12-26 22:15 ` Heinrich Schuchardt
2020-12-26 22:35 ` Pali Rohár
2020-12-26 22:32 ` [maemo-leste] " Pavel Machek
2020-12-26 22:42 ` Pali Rohár
2020-12-26 22:48 ` Pavel Machek
2020-12-26 23:04 ` Heinrich Schuchardt
2020-12-26 23:16 ` Pali Rohár
2020-12-27 0:04 ` [PATCH v2] bootmenu: Allow to quit it via ESC/CTRL+C Pali Rohár
2020-12-29 3:32 ` Simon Glass
2021-01-18 13:01 ` Tom Rini
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=20201226180225.17563-1-pali@kernel.org \
--to=pali@kernel.org \
--cc=u-boot@lists.denx.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.