:: Re: [maemo-leste] [PATCH] bootmenu:…
Inizio della pagina
Delete this message
Reply to this message
Autore: Pali Rohár
Data:  
To: Heinrich Schuchardt
CC: Simon Glass, Thirupathaiah Annapureddy, u-boot, maemo-leste
Oggetto: Re: [maemo-leste] [PATCH] bootmenu: Allow to quit it via CTRL+C
On Saturday 26 December 2020 20:10:10 Heinrich Schuchardt wrote:
> Am 26. Dezember 2020 20:03:56 MEZ schrieb "Pali Rohár" <pali@???>:
> >On Saturday 26 December 2020 19:44:23 Heinrich Schuchardt wrote:
> >> Am 26. Dezember 2020 19:02:25 MEZ schrieb "Pali Rohár"
> ><pali@???>:
> >> >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.
> >>
> >> Wouldn't the escape key be a better choice?
> >
> >I can add also escape key. But has escape key stable ANSI sequence
> >which
> >is needed to catch? If you tell me which bytes to catch (for escape
> >key)
> >I will add it.
>
> 0x1b is Escape


Does not work. 0x1b is not escape key. It is start of the ANSI escape
sequence which matches also existing keys up and down.

> >
> >> On the sandbox CTRL-C makes you quit U-Boot.
> >>
> >> When hitting CTRL-C late on other systems it might interrupt a
> >follow-up command.
> >
> >I understand your concerns. But all other commands catch also CTRL+C so
> >I think that bootmenu command should it too.
> >
> >> --
> >>
> >> The following is not directly related to your patch:
> >>
> >> Is it really a good design that a user cannot be stopped from
> >reaching the console?
> >
> >Currently "U-Boot console" option is always added to menu list. But
> >option is doing only one thing: exiting the current U-Boot command and
> >returning back to the monitor mode.
> >
> >> I could think of use cases in the context of secure booting where you
> >want to show a menu but you do not want to give access to the command
> >line.
> >
> >If bootmenu is not started from monitor mode then this "U-Boot console"
> >command just enter into monitor mode. And I think that you can already
> >block monitor mode and therefore has ability of this secure boot
> >scheme.
> >
> >> Best regards
> >>
> >> Heinrich
> >>
> >> >
> >> >Signed-off-by: Pali Rohár <pali@???>
> >> >---
> >> > cmd/bootmenu.c | 16 +++++++++++++++-
> >> > 1 file changed, 15 insertions(+), 1 deletion(-)
> >> >
> >> >diff --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);

> >>
>