diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/bootflow.c | 43 | ||||
-rw-r--r-- | cmd/booti.c | 7 | ||||
-rw-r--r-- | cmd/bootmenu.c | 41 | ||||
-rw-r--r-- | cmd/cedit.c | 2 | ||||
-rw-r--r-- | cmd/ide.c | 1 | ||||
-rw-r--r-- | cmd/legacy-mtd-utils.c | 1 | ||||
-rw-r--r-- | cmd/mtdparts.c | 1 |
7 files changed, 73 insertions, 23 deletions
diff --git a/cmd/bootflow.c b/cmd/bootflow.c index d4f7d336150..551dffbb8b8 100644 --- a/cmd/bootflow.c +++ b/cmd/bootflow.c @@ -14,6 +14,8 @@ #include <console.h> #include <dm.h> #include <env.h> +#include <expo.h> +#include <log.h> #include <mapmem.h> /** @@ -105,24 +107,39 @@ __maybe_unused static int bootflow_handle_menu(struct bootstd_priv *std, bool text_mode, struct bootflow **bflowp) { + struct expo *exp; struct bootflow *bflow; - int ret; + int ret, seq; - ret = bootflow_menu_run(std, text_mode, &bflow); - if (ret) { - if (ret == -EAGAIN) { - printf("Nothing chosen\n"); - std->cur_bootflow = NULL; - } else { - printf("Menu failed (err=%d)\n", ret); + ret = bootflow_menu_start(std, text_mode, &exp); + if (ret) + return log_msg_ret("bhs", ret); + + ret = -ERESTART; + do { + if (ret == -ERESTART) { + ret = expo_render(exp); + if (ret) + return log_msg_ret("bhr", ret); } + ret = bootflow_menu_poll(exp, &seq); + } while (ret == -EAGAIN || ret == -ERESTART); - return ret; + if (ret == -EPIPE) { + printf("Nothing chosen\n"); + std->cur_bootflow = NULL; + } else if (ret) { + printf("Menu failed (err=%d)\n", ret); + } else { + bflow = alist_getw(&std->bootflows, seq, struct bootflow); + printf("Selected: %s\n", bflow->os_name ? bflow->os_name : + bflow->name); + std->cur_bootflow = bflow; + *bflowp = bflow; } - - printf("Selected: %s\n", bflow->os_name ? bflow->os_name : bflow->name); - std->cur_bootflow = bflow; - *bflowp = bflow; + expo_destroy(exp); + if (ret) + return ret; return 0; } diff --git a/cmd/booti.c b/cmd/booti.c index f5ae58139da..7e6d9426299 100644 --- a/cmd/booti.c +++ b/cmd/booti.c @@ -131,11 +131,8 @@ int do_booti(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) bootm_disable_interrupts(); images.os.os = IH_OS_LINUX; - if (IS_ENABLED(CONFIG_RISCV)) - if (IS_ENABLED(CONFIG_64BIT)) - images.os.arch = IH_ARCH_RISCV64; - else - images.os.arch = IH_ARCH_RISCV; + if (IS_ENABLED(CONFIG_RISCV_SMODE)) + images.os.arch = IH_ARCH_RISCV; else if (IS_ENABLED(CONFIG_ARM64)) images.os.arch = IH_ARCH_ARM64; diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c index a5c979079f4..d3108778c6f 100644 --- a/cmd/bootmenu.c +++ b/cmd/bootmenu.c @@ -114,6 +114,14 @@ static char *bootmenu_choice_entry(void *data) ++menu->active; /* no menu key selected, regenerate menu */ return NULL; + case BKEY_SHORTCUT: + /* invalid shortcut, regenerate menu */ + if (cch->shortcut_key >= menu->count - 1) + return NULL; + /* shortcut_key value for Exit is is -1 */ + menu->active = cch->shortcut_key < 0 ? menu->count - 1 : + cch->shortcut_key; + fallthrough; case BKEY_SELECT: iter = menu->first; for (i = 0; i < menu->active; ++i) @@ -161,6 +169,21 @@ static void bootmenu_destroy(struct bootmenu_data *menu) free(menu); } +static char bootmenu_entry_shortcut_key(int index) +{ + switch (index) { + /* 1-9 shortcut key (0 reserved) */ + case 0 ... 8: + return '1' + index; + /* a-z shortcut key */ + case 9 ... 34: + return 'a' + index - 9; + /* We support shortcut for up to 34 options (0 reserved) */ + default: + return -ENOENT; + } +} + /** * prepare_bootmenu_entry() - generate the bootmenu_xx entries * @@ -184,6 +207,8 @@ static int prepare_bootmenu_entry(struct bootmenu_data *menu, struct bootmenu_entry *iter = *current; while ((option = bootmenu_getoption(i))) { + char shortcut_key; + int len; /* bootmenu_[num] format is "[title]=[commands]" */ sep = strchr(option, '='); @@ -196,12 +221,22 @@ static int prepare_bootmenu_entry(struct bootmenu_data *menu, if (!entry) return -ENOMEM; - entry->title = strndup(option, sep - option); + /* Add shotcut key option: %c. %s\0 */ + len = sep - option + 4; + + entry->title = malloc(len); if (!entry->title) { free(entry); return -ENOMEM; } + shortcut_key = bootmenu_entry_shortcut_key(i); + /* Use emtpy space if entry doesn't support shortcut key */ + snprintf(entry->title, len, "%c%c %s", + shortcut_key > 0 ? shortcut_key : ' ', + shortcut_key > 0 ? '.' : ' ', + option); + entry->command = strdup(sep + 1); if (!entry->command) { free(entry->title); @@ -388,9 +423,9 @@ static struct bootmenu_data *bootmenu_create(int uefi, int delay) /* Add Quit entry if exiting bootmenu is disabled */ if (!IS_ENABLED(CONFIG_BOOTMENU_DISABLE_UBOOT_CONSOLE)) - entry->title = strdup("Exit"); + entry->title = strdup("0. Exit"); else - entry->title = strdup("Quit"); + entry->title = strdup("0. Quit"); if (!entry->title) { free(entry); diff --git a/cmd/cedit.c b/cmd/cedit.c index f696356419e..20f48ae0007 100644 --- a/cmd/cedit.c +++ b/cmd/cedit.c @@ -287,6 +287,8 @@ static int do_cedit_run(struct cmd_tbl *cmdtp, int flag, int argc, log_err("Failed (err=%dE)\n", ret); return CMD_RET_FAILURE; } + expo_destroy(cur_exp); + cur_exp = NULL; return 0; } diff --git a/cmd/ide.c b/cmd/ide.c index 036489fda97..ed30f946866 100644 --- a/cmd/ide.c +++ b/cmd/ide.c @@ -19,7 +19,6 @@ #include <dm/device-internal.h> #include <dm/uclass-internal.h> -#include <ide.h> #include <ata.h> #ifdef CONFIG_LED_STATUS diff --git a/cmd/legacy-mtd-utils.c b/cmd/legacy-mtd-utils.c index 1a5271000bf..34a6da01947 100644 --- a/cmd/legacy-mtd-utils.c +++ b/cmd/legacy-mtd-utils.c @@ -4,7 +4,6 @@ #include <linux/mtd/mtd.h> #include <linux/mtd/partitions.h> #include <linux/string.h> -#include <mtd.h> static int get_part(const char *partname, int *idx, loff_t *off, loff_t *size, loff_t *maxsize, int devtype) diff --git a/cmd/mtdparts.c b/cmd/mtdparts.c index a021b2d198d..571b79f091d 100644 --- a/cmd/mtdparts.c +++ b/cmd/mtdparts.c @@ -74,6 +74,7 @@ #include <env.h> #include <log.h> #include <malloc.h> +#include <mtd.h> #include <asm/global_data.h> #include <jffs2/load_kernel.h> #include <linux/list.h> |