|
|
@@ -35,7 +35,7 @@ Signed-off-by: Weijie Gao <[email protected]>
|
|
|
}
|
|
|
|
|
|
switch (key) {
|
|
|
-@@ -112,6 +113,12 @@ static char *bootmenu_choice_entry(void
|
|
|
+@@ -114,6 +115,12 @@ static char *bootmenu_choice_entry(void
|
|
|
++menu->active;
|
|
|
/* no menu key selected, regenerate menu */
|
|
|
return NULL;
|
|
|
@@ -48,7 +48,7 @@ Signed-off-by: Weijie Gao <[email protected]>
|
|
|
case BKEY_SELECT:
|
|
|
iter = menu->first;
|
|
|
for (i = 0; i < menu->active; ++i)
|
|
|
-@@ -169,6 +176,9 @@ static int prepare_bootmenu_entry(struct
|
|
|
+@@ -182,6 +189,9 @@ static int prepare_bootmenu_entry(struct
|
|
|
unsigned short int i = *index;
|
|
|
struct bootmenu_entry *entry = NULL;
|
|
|
struct bootmenu_entry *iter = *current;
|
|
|
@@ -58,7 +58,7 @@ Signed-off-by: Weijie Gao <[email protected]>
|
|
|
|
|
|
while ((option = bootmenu_getoption(i))) {
|
|
|
|
|
|
-@@ -183,11 +193,24 @@ static int prepare_bootmenu_entry(struct
|
|
|
+@@ -196,11 +206,24 @@ static int prepare_bootmenu_entry(struct
|
|
|
if (!entry)
|
|
|
return -ENOMEM;
|
|
|
|
|
|
@@ -84,15 +84,15 @@ Signed-off-by: Weijie Gao <[email protected]>
|
|
|
|
|
|
entry->command = strdup(sep + 1);
|
|
|
if (!entry->command) {
|
|
|
-@@ -333,6 +356,7 @@ static struct bootmenu_data *bootmenu_cr
|
|
|
- menu->delay = delay;
|
|
|
+@@ -347,6 +370,7 @@ static struct bootmenu_data *bootmenu_cr
|
|
|
menu->active = 0;
|
|
|
+ menu->last_active = -1;
|
|
|
menu->first = NULL;
|
|
|
+ menu->last_choiced = false;
|
|
|
|
|
|
default_str = env_get("bootmenu_default");
|
|
|
if (default_str)
|
|
|
-@@ -368,9 +392,9 @@ static struct bootmenu_data *bootmenu_cr
|
|
|
+@@ -382,9 +406,9 @@ static struct bootmenu_data *bootmenu_cr
|
|
|
|
|
|
/* Add Quit entry if exiting bootmenu is disabled */
|
|
|
if (!IS_ENABLED(CONFIG_BOOTMENU_DISABLE_UBOOT_CONSOLE))
|
|
|
@@ -106,7 +106,7 @@ Signed-off-by: Weijie Gao <[email protected]>
|
|
|
free(entry);
|
|
|
--- a/common/menu.c
|
|
|
+++ b/common/menu.c
|
|
|
-@@ -48,6 +48,33 @@ struct menu {
|
|
|
+@@ -49,6 +49,33 @@ struct menu {
|
|
|
int item_cnt;
|
|
|
};
|
|
|
|
|
|
@@ -140,7 +140,7 @@ Signed-off-by: Weijie Gao <[email protected]>
|
|
|
/*
|
|
|
* An iterator function for menu items. callback will be called for each item
|
|
|
* in m, with m, a pointer to the item, and extra being passed to callback. If
|
|
|
-@@ -426,7 +453,7 @@ int menu_destroy(struct menu *m)
|
|
|
+@@ -437,7 +464,7 @@ int menu_destroy(struct menu *m)
|
|
|
}
|
|
|
|
|
|
enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu,
|
|
|
@@ -149,7 +149,7 @@ Signed-off-by: Weijie Gao <[email protected]>
|
|
|
{
|
|
|
enum bootmenu_key key = BKEY_NONE;
|
|
|
int i, c;
|
|
|
-@@ -461,6 +488,19 @@ enum bootmenu_key bootmenu_autoboot_loop
|
|
|
+@@ -472,6 +499,19 @@ enum bootmenu_key bootmenu_autoboot_loop
|
|
|
break;
|
|
|
default:
|
|
|
key = BKEY_NONE;
|
|
|
@@ -169,7 +169,7 @@ Signed-off-by: Weijie Gao <[email protected]>
|
|
|
break;
|
|
|
}
|
|
|
break;
|
|
|
-@@ -481,7 +521,8 @@ enum bootmenu_key bootmenu_autoboot_loop
|
|
|
+@@ -492,7 +532,8 @@ enum bootmenu_key bootmenu_autoboot_loop
|
|
|
return key;
|
|
|
}
|
|
|
|
|
|
@@ -179,7 +179,7 @@ Signed-off-by: Weijie Gao <[email protected]>
|
|
|
{
|
|
|
enum bootmenu_key key;
|
|
|
|
|
|
-@@ -513,6 +554,20 @@ enum bootmenu_key bootmenu_conv_key(int
|
|
|
+@@ -524,6 +565,20 @@ enum bootmenu_key bootmenu_conv_key(int
|
|
|
case ' ':
|
|
|
key = BKEY_SPACE;
|
|
|
break;
|
|
|
@@ -200,15 +200,16 @@ Signed-off-by: Weijie Gao <[email protected]>
|
|
|
default:
|
|
|
key = BKEY_NONE;
|
|
|
break;
|
|
|
-@@ -522,11 +577,16 @@ enum bootmenu_key bootmenu_conv_key(int
|
|
|
+@@ -533,11 +588,17 @@ enum bootmenu_key bootmenu_conv_key(int
|
|
|
}
|
|
|
|
|
|
enum bootmenu_key bootmenu_loop(struct bootmenu_data *menu,
|
|
|
- struct cli_ch_state *cch)
|
|
|
-+ struct cli_ch_state *cch, int *choice)
|
|
|
++ struct cli_ch_state *cch,
|
|
|
++ int *choice)
|
|
|
{
|
|
|
enum bootmenu_key key;
|
|
|
- int c;
|
|
|
+ int c, errchar = 0;
|
|
|
|
|
|
+ if (menu->last_choiced) {
|
|
|
+ menu->last_choiced = false;
|
|
|
@@ -218,7 +219,7 @@ Signed-off-by: Weijie Gao <[email protected]>
|
|
|
c = cli_ch_process(cch, 0);
|
|
|
if (!c) {
|
|
|
while (!c && !tstc()) {
|
|
|
-@@ -540,7 +600,7 @@ enum bootmenu_key bootmenu_loop(struct b
|
|
|
+@@ -552,7 +613,7 @@ enum bootmenu_key bootmenu_loop(struct b
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -238,7 +239,7 @@ Signed-off-by: Weijie Gao <[email protected]>
|
|
|
struct cli_ch_state;
|
|
|
struct menu;
|
|
|
|
|
|
-@@ -19,6 +21,8 @@ int menu_get_choice(struct menu *m, void
|
|
|
+@@ -20,6 +22,8 @@ int menu_get_choice(struct menu *m, void
|
|
|
int menu_item_add(struct menu *m, char *item_key, void *item_data);
|
|
|
int menu_destroy(struct menu *m);
|
|
|
int menu_default_choice(struct menu *m, void **choice);
|
|
|
@@ -247,15 +248,15 @@ Signed-off-by: Weijie Gao <[email protected]>
|
|
|
|
|
|
/**
|
|
|
* menu_show() Show a boot menu
|
|
|
-@@ -41,6 +45,7 @@ struct bootmenu_data {
|
|
|
- int active; /* active menu entry */
|
|
|
+@@ -43,6 +47,7 @@ struct bootmenu_data {
|
|
|
+ int last_active; /* last active menu entry */
|
|
|
int count; /* total count of menu entries */
|
|
|
struct bootmenu_entry *first; /* first menu entry */
|
|
|
+ bool last_choiced;
|
|
|
};
|
|
|
|
|
|
/** enum bootmenu_key - keys that can be returned by the bootmenu */
|
|
|
-@@ -51,6 +56,7 @@ enum bootmenu_key {
|
|
|
+@@ -53,6 +58,7 @@ enum bootmenu_key {
|
|
|
BKEY_SELECT,
|
|
|
BKEY_QUIT,
|
|
|
BKEY_SAVE,
|
|
|
@@ -263,7 +264,7 @@ Signed-off-by: Weijie Gao <[email protected]>
|
|
|
|
|
|
/* 'extra' keys, which are used by menus but not cedit */
|
|
|
BKEY_PLUS,
|
|
|
-@@ -81,7 +87,7 @@ enum bootmenu_key {
|
|
|
+@@ -83,7 +89,7 @@ enum bootmenu_key {
|
|
|
* anything else: KEY_NONE
|
|
|
*/
|
|
|
enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu,
|
|
|
@@ -272,7 +273,7 @@ Signed-off-by: Weijie Gao <[email protected]>
|
|
|
|
|
|
/**
|
|
|
* bootmenu_loop() - handle waiting for a keypress when autoboot is disabled
|
|
|
-@@ -107,7 +113,7 @@ enum bootmenu_key bootmenu_autoboot_loop
|
|
|
+@@ -109,7 +115,7 @@ enum bootmenu_key bootmenu_autoboot_loop
|
|
|
* Space: BKEY_SPACE
|
|
|
*/
|
|
|
enum bootmenu_key bootmenu_loop(struct bootmenu_data *menu,
|
|
|
@@ -281,7 +282,7 @@ Signed-off-by: Weijie Gao <[email protected]>
|
|
|
|
|
|
/**
|
|
|
* bootmenu_conv_key() - Convert a U-Boot keypress into a menu key
|
|
|
-@@ -115,6 +121,7 @@ enum bootmenu_key bootmenu_loop(struct b
|
|
|
+@@ -117,6 +123,7 @@ enum bootmenu_key bootmenu_loop(struct b
|
|
|
* @ichar: Keypress to convert (ASCII, including control characters)
|
|
|
* Returns: Menu key that corresponds to @ichar, or BKEY_NONE if none
|
|
|
*/
|