From 2da4a15e7e947d2d304ec1ba392556c3e0393e13 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 6 Jan 2023 08:52:22 -0600 Subject: menu: Rename KEY_... to BKEY_... This enum values conflict with linux/input.h so rename them. Signed-off-by: Simon Glass --- cmd/bootmenu.c | 10 +++++----- cmd/eficonfig.c | 26 +++++++++++++------------- 2 files changed, 18 insertions(+), 18 deletions(-) (limited to 'cmd') diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c index e5a10f5d5c4..1a14e8a1909 100644 --- a/cmd/bootmenu.c +++ b/cmd/bootmenu.c @@ -86,7 +86,7 @@ static char *bootmenu_choice_entry(void *data) { struct bootmenu_data *menu = data; struct bootmenu_entry *iter; - enum bootmenu_key key = KEY_NONE; + enum bootmenu_key key = BKEY_NONE; int esc = 0; int i; @@ -100,22 +100,22 @@ static char *bootmenu_choice_entry(void *data) } switch (key) { - case KEY_UP: + case BKEY_UP: if (menu->active > 0) --menu->active; /* no menu key selected, regenerate menu */ return NULL; - case KEY_DOWN: + case BKEY_DOWN: if (menu->active < menu->count - 1) ++menu->active; /* no menu key selected, regenerate menu */ return NULL; - case KEY_SELECT: + case BKEY_SELECT: iter = menu->first; for (i = 0; i < menu->active; ++i) iter = iter->next; return iter->key; - case KEY_QUIT: + case BKEY_QUIT: /* Quit by choosing the last entry - U-Boot console */ iter = menu->first; while (iter->next) diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c index ce7175a5666..8f246bc271f 100644 --- a/cmd/eficonfig.c +++ b/cmd/eficonfig.c @@ -187,31 +187,31 @@ static char *eficonfig_choice_entry(void *data) int esc = 0; struct list_head *pos, *n; struct eficonfig_entry *entry; - enum bootmenu_key key = KEY_NONE; + enum bootmenu_key key = BKEY_NONE; struct efimenu *efi_menu = data; while (1) { bootmenu_loop((struct bootmenu_data *)efi_menu, &key, &esc); switch (key) { - case KEY_UP: + case BKEY_UP: if (efi_menu->active > 0) --efi_menu->active; /* no menu key selected, regenerate menu */ return NULL; - case KEY_DOWN: + case BKEY_DOWN: if (efi_menu->active < efi_menu->count - 1) ++efi_menu->active; /* no menu key selected, regenerate menu */ return NULL; - case KEY_SELECT: + case BKEY_SELECT: list_for_each_safe(pos, n, &efi_menu->list) { entry = list_entry(pos, struct eficonfig_entry, list); if (entry->num == efi_menu->active) return entry->key; } break; - case KEY_QUIT: + case BKEY_QUIT: /* Quit by choosing the last entry */ entry = list_last_entry(&efi_menu->list, struct eficonfig_entry, list); return entry->key; @@ -1864,14 +1864,14 @@ static efi_status_t eficonfig_choice_change_boot_order(struct efimenu *efi_menu) { int esc = 0; struct list_head *pos, *n; - enum bootmenu_key key = KEY_NONE; + enum bootmenu_key key = BKEY_NONE; struct eficonfig_entry *entry, *tmp; while (1) { bootmenu_loop(NULL, &key, &esc); switch (key) { - case KEY_PLUS: + case BKEY_PLUS: if (efi_menu->active > 0) { list_for_each_safe(pos, n, &efi_menu->list) { entry = list_entry(pos, struct eficonfig_entry, list); @@ -1885,11 +1885,11 @@ static efi_status_t eficonfig_choice_change_boot_order(struct efimenu *efi_menu) list_add(&tmp->list, &entry->list); } fallthrough; - case KEY_UP: + case BKEY_UP: if (efi_menu->active > 0) --efi_menu->active; return EFI_NOT_READY; - case KEY_MINUS: + case BKEY_MINUS: if (efi_menu->active < efi_menu->count - 3) { list_for_each_safe(pos, n, &efi_menu->list) { entry = list_entry(pos, struct eficonfig_entry, list); @@ -1905,11 +1905,11 @@ static efi_status_t eficonfig_choice_change_boot_order(struct efimenu *efi_menu) ++efi_menu->active; } return EFI_NOT_READY; - case KEY_DOWN: + case BKEY_DOWN: if (efi_menu->active < efi_menu->count - 1) ++efi_menu->active; return EFI_NOT_READY; - case KEY_SELECT: + case BKEY_SELECT: /* "Save" */ if (efi_menu->active == efi_menu->count - 2) return EFI_SUCCESS; @@ -1919,7 +1919,7 @@ static efi_status_t eficonfig_choice_change_boot_order(struct efimenu *efi_menu) return EFI_ABORTED; break; - case KEY_SPACE: + case BKEY_SPACE: if (efi_menu->active < efi_menu->count - 2) { list_for_each_safe(pos, n, &efi_menu->list) { entry = list_entry(pos, struct eficonfig_entry, list); @@ -1932,7 +1932,7 @@ static efi_status_t eficonfig_choice_change_boot_order(struct efimenu *efi_menu) } } break; - case KEY_QUIT: + case BKEY_QUIT: return EFI_ABORTED; default: /* Pressed key is not valid, no need to regenerate the menu */ -- cgit v1.2.3 From 5712976b26f7865f348aba51c9fa367c456e1795 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 6 Jan 2023 08:52:23 -0600 Subject: menu: Update bootmenu_autoboot_loop() to return the code Use the return value to save having to pass around a pointer. This also resolves any ambiguity about what *key contains when the function is called. Signed-off-by: Simon Glass --- cmd/bootmenu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c index 1a14e8a1909..086d04148ab 100644 --- a/cmd/bootmenu.c +++ b/cmd/bootmenu.c @@ -93,7 +93,7 @@ static char *bootmenu_choice_entry(void *data) while (1) { if (menu->delay >= 0) { /* Autoboot was not stopped */ - bootmenu_autoboot_loop(menu, &key, &esc); + key = bootmenu_autoboot_loop(menu, &esc); } else { /* Some key was pressed, so autoboot was stopped */ bootmenu_loop(menu, &key, &esc); -- cgit v1.2.3 From d0ca98dbd99c2534c9e96e4c226e52ab80f2248f Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 6 Jan 2023 08:52:24 -0600 Subject: menu: Update bootmenu_loop() to return the code Use the return value to save having to pass around a pointer. This also resolves any ambiguity about what *key contains when the function is called. Signed-off-by: Simon Glass --- cmd/bootmenu.c | 2 +- cmd/eficonfig.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'cmd') diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c index 086d04148ab..43553dbcc9b 100644 --- a/cmd/bootmenu.c +++ b/cmd/bootmenu.c @@ -96,7 +96,7 @@ static char *bootmenu_choice_entry(void *data) key = bootmenu_autoboot_loop(menu, &esc); } else { /* Some key was pressed, so autoboot was stopped */ - bootmenu_loop(menu, &key, &esc); + key = bootmenu_loop(menu, &esc); } switch (key) { diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c index 8f246bc271f..96cb1a367f3 100644 --- a/cmd/eficonfig.c +++ b/cmd/eficonfig.c @@ -191,7 +191,7 @@ static char *eficonfig_choice_entry(void *data) struct efimenu *efi_menu = data; while (1) { - bootmenu_loop((struct bootmenu_data *)efi_menu, &key, &esc); + key = bootmenu_loop((struct bootmenu_data *)efi_menu, &esc); switch (key) { case BKEY_UP: @@ -1868,7 +1868,7 @@ static efi_status_t eficonfig_choice_change_boot_order(struct efimenu *efi_menu) struct eficonfig_entry *entry, *tmp; while (1) { - bootmenu_loop(NULL, &key, &esc); + key = bootmenu_loop(NULL, &esc); switch (key) { case BKEY_PLUS: -- cgit v1.2.3 From 32bab0eae51b55898d1e2804e6614d9143840581 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 6 Jan 2023 08:52:26 -0600 Subject: menu: Make use of CLI character processing Avoid duplicating some of the escape-sequence processing here and use the CLI function instead. Signed-off-by: Simon Glass --- cmd/bootmenu.c | 9 ++++++--- cmd/eficonfig.c | 12 ++++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'cmd') diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c index 43553dbcc9b..3236ca5d799 100644 --- a/cmd/bootmenu.c +++ b/cmd/bootmenu.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include @@ -84,19 +85,21 @@ static void bootmenu_print_entry(void *data) static char *bootmenu_choice_entry(void *data) { + struct cli_ch_state s_cch, *cch = &s_cch; struct bootmenu_data *menu = data; struct bootmenu_entry *iter; enum bootmenu_key key = BKEY_NONE; - int esc = 0; int i; + cli_ch_init(cch); + while (1) { if (menu->delay >= 0) { /* Autoboot was not stopped */ - key = bootmenu_autoboot_loop(menu, &esc); + key = bootmenu_autoboot_loop(menu, cch); } else { /* Some key was pressed, so autoboot was stopped */ - key = bootmenu_loop(menu, &esc); + key = bootmenu_loop(menu, cch); } switch (key) { diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c index 96cb1a367f3..d830e4af53b 100644 --- a/cmd/eficonfig.c +++ b/cmd/eficonfig.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -184,14 +185,16 @@ static void eficonfig_display_statusline(struct menu *m) */ static char *eficonfig_choice_entry(void *data) { - int esc = 0; + struct cli_ch_state s_cch, *cch = &s_cch; struct list_head *pos, *n; struct eficonfig_entry *entry; enum bootmenu_key key = BKEY_NONE; struct efimenu *efi_menu = data; + cli_ch_init(cch); + while (1) { - key = bootmenu_loop((struct bootmenu_data *)efi_menu, &esc); + key = bootmenu_loop((struct bootmenu_data *)efi_menu, cch); switch (key) { case BKEY_UP: @@ -1862,13 +1865,14 @@ static void eficonfig_display_change_boot_order(struct efimenu *efi_menu) */ static efi_status_t eficonfig_choice_change_boot_order(struct efimenu *efi_menu) { - int esc = 0; + struct cli_ch_state s_cch, *cch = &s_cch; struct list_head *pos, *n; enum bootmenu_key key = BKEY_NONE; struct eficonfig_entry *entry, *tmp; + cli_ch_init(cch); while (1) { - key = bootmenu_loop(NULL, &esc); + key = bootmenu_loop(NULL, cch); switch (key) { case BKEY_PLUS: -- cgit v1.2.3 From 858fefd5fc3ae9006a0f545d7744e6f95270b14d Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 6 Jan 2023 08:52:27 -0600 Subject: image: Add a function to find a script in an image Split this functionality out of the 'source' command so it can be used from another place. For now leave it where it is, but a future patch will move it out of cmd/ Signed-off-by: Simon Glass --- cmd/source.c | 217 ++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 116 insertions(+), 101 deletions(-) (limited to 'cmd') diff --git a/cmd/source.c b/cmd/source.c index 94da5d8d6ad..1186a541bc7 100644 --- a/cmd/source.c +++ b/cmd/source.c @@ -24,7 +24,6 @@ #include #include -#if defined(CONFIG_FIT) /** * get_default_image() - Return default property from /images * @@ -40,149 +39,165 @@ static const char *get_default_image(const void *fit) return fdt_getprop(fit, images_noffset, FIT_DEFAULT_PROP, NULL); } -#endif -int image_source_script(ulong addr, const char *fit_uname, const char *confname) +int image_locate_script(void *buf, int size, const char *fit_uname, + const char *confname, char **datap, uint *lenp) { ulong len; -#if defined(CONFIG_LEGACY_IMAGE_FORMAT) const struct legacy_img_hdr *hdr; -#endif u32 *data; int verify; - void *buf; -#if defined(CONFIG_FIT) const void* fit_hdr; int noffset; const void *fit_data; size_t fit_len; -#endif verify = env_get_yesno("verify"); - buf = map_sysmem(addr, 0); switch (genimg_get_format(buf)) { -#if defined(CONFIG_LEGACY_IMAGE_FORMAT) case IMAGE_FORMAT_LEGACY: - hdr = buf; + if (IS_ENABLED(CONFIG_LEGACY_IMAGE_FORMAT)) { + hdr = buf; - if (!image_check_magic (hdr)) { - puts ("Bad magic number\n"); - return 1; - } + if (!image_check_magic(hdr)) { + puts("Bad magic number\n"); + return 1; + } - if (!image_check_hcrc (hdr)) { - puts ("Bad header crc\n"); - return 1; - } + if (!image_check_hcrc(hdr)) { + puts("Bad header crc\n"); + return 1; + } + + if (verify) { + if (!image_check_dcrc(hdr)) { + puts("Bad data crc\n"); + return 1; + } + } - if (verify) { - if (!image_check_dcrc (hdr)) { - puts ("Bad data crc\n"); + if (!image_check_type(hdr, IH_TYPE_SCRIPT)) { + puts("Bad image type\n"); return 1; } - } - if (!image_check_type (hdr, IH_TYPE_SCRIPT)) { - puts ("Bad image type\n"); - return 1; - } + /* get length of script */ + data = (u32 *)image_get_data(hdr); - /* get length of script */ - data = (u32 *)image_get_data (hdr); + len = uimage_to_cpu(*data); + if (!len) { + puts("Empty Script\n"); + return 1; + } - if ((len = uimage_to_cpu (*data)) == 0) { - puts ("Empty Script\n"); - return 1; + /* + * scripts are just multi-image files with one + * component, so seek past the zero-terminated sequence + * of image lengths to get to the actual image data + */ + while (*data++); } - - /* - * scripts are just multi-image files with one component, seek - * past the zero-terminated sequence of image lengths to get - * to the actual image data - */ - while (*data++); break; -#endif -#if defined(CONFIG_FIT) case IMAGE_FORMAT_FIT: - fit_hdr = buf; - if (fit_check_format(fit_hdr, IMAGE_SIZE_INVAL)) { - puts ("Bad FIT image format\n"); - return 1; - } - - if (!fit_uname) { - /* If confname is empty, use the default */ - if (confname && *confname) - noffset = fit_conf_get_node(fit_hdr, confname); - else - noffset = fit_conf_get_node(fit_hdr, NULL); - if (noffset < 0) { - if (!confname) - goto fallback; - printf("Could not find config %s\n", confname); + if (IS_ENABLED(CONFIG_FIT)) { + fit_hdr = buf; + if (fit_check_format(fit_hdr, IMAGE_SIZE_INVAL)) { + puts("Bad FIT image format\n"); return 1; } - if (verify && fit_config_verify(fit_hdr, noffset)) - return 1; + if (!fit_uname) { + /* If confname is empty, use the default */ + if (confname && *confname) + noffset = fit_conf_get_node(fit_hdr, confname); + else + noffset = fit_conf_get_node(fit_hdr, NULL); + if (noffset < 0) { + if (!confname) + goto fallback; + printf("Could not find config %s\n", confname); + return 1; + } + + if (verify && fit_config_verify(fit_hdr, noffset)) + return 1; + + noffset = fit_conf_get_prop_node(fit_hdr, + noffset, + FIT_SCRIPT_PROP, + IH_PHASE_NONE); + if (noffset < 0) { + if (!confname) + goto fallback; + printf("Could not find script in %s\n", confname); + return 1; + } + } else { +fallback: + if (!fit_uname || !*fit_uname) + fit_uname = get_default_image(fit_hdr); + if (!fit_uname) { + puts("No FIT subimage unit name\n"); + return 1; + } + + /* get script component image node offset */ + noffset = fit_image_get_node(fit_hdr, fit_uname); + if (noffset < 0) { + printf("Can't find '%s' FIT subimage\n", + fit_uname); + return 1; + } + } - noffset = fit_conf_get_prop_node(fit_hdr, noffset, - FIT_SCRIPT_PROP, - IH_PHASE_NONE); - if (noffset < 0) { - if (!confname) - goto fallback; - printf("Could not find script in %s\n", confname); + if (!fit_image_check_type(fit_hdr, noffset, + IH_TYPE_SCRIPT)) { + puts("Not a image image\n"); return 1; } - } else { -fallback: - if (!fit_uname || !*fit_uname) - fit_uname = get_default_image(fit_hdr); - if (!fit_uname) { - puts("No FIT subimage unit name\n"); + + /* verify integrity */ + if (verify && !fit_image_verify(fit_hdr, noffset)) { + puts("Bad Data Hash\n"); return 1; } - /* get script component image node offset */ - noffset = fit_image_get_node(fit_hdr, fit_uname); - if (noffset < 0) { - printf("Can't find '%s' FIT subimage\n", - fit_uname); + /* get script subimage data address and length */ + if (fit_image_get_data(fit_hdr, noffset, &fit_data, &fit_len)) { + puts("Could not find script subimage data\n"); return 1; } - } - - if (!fit_image_check_type (fit_hdr, noffset, IH_TYPE_SCRIPT)) { - puts("Not a script image\n"); - return 1; - } - - /* verify integrity */ - if (verify && !fit_image_verify(fit_hdr, noffset)) { - puts("Bad Data Hash\n"); - return 1; - } - /* get script subimage data address and length */ - if (fit_image_get_data (fit_hdr, noffset, &fit_data, &fit_len)) { - puts ("Could not find script subimage data\n"); - return 1; + data = (u32 *)fit_data; + len = (ulong)fit_len; } - - data = (u32 *)fit_data; - len = (ulong)fit_len; break; -#endif default: - puts ("Wrong image format for \"source\" command\n"); - return 1; + puts("Wrong image format for \"source\" command\n"); + return -EPERM; } - debug("** Script length: %ld\n", len); - return run_command_list((char *)data, len, 0); + *datap = (char *)data; + *lenp = len; + + return 0; +} + +int image_source_script(ulong addr, const char *fit_uname, const char *confname) +{ + char *data; + void *buf; + uint len; + int ret; + + buf = map_sysmem(addr, 0); + ret = image_locate_script(buf, 0, fit_uname, confname, &data, &len); + unmap_sysmem(buf); + if (ret) + return CMD_RET_FAILURE; + + debug("** Script length: %d\n", len); + return run_command_list(data, len, 0); } /**************************************************/ -- cgit v1.2.3 From 30f3333d8860fd97e131e24ad33a80f4d46e98b1 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 6 Jan 2023 08:52:28 -0600 Subject: image: Move common image code to image_board and command We should use the cmd/ directory for commands rather than for common code used elsewhere in U-Boot. Move the common 'source' code into image-board.c to achieve this. The image_source_script() function needs to call run_command_list() so seems to belong better in the command library. Move and rename it. Signed-off-by: Simon Glass --- cmd/source.c | 181 +---------------------------------------------------------- 1 file changed, 1 insertion(+), 180 deletions(-) (limited to 'cmd') diff --git a/cmd/source.c b/cmd/source.c index 1186a541bc7..92c7835bf50 100644 --- a/cmd/source.c +++ b/cmd/source.c @@ -24,184 +24,6 @@ #include #include -/** - * get_default_image() - Return default property from /images - * - * Return: Pointer to value of default property (or NULL) - */ -static const char *get_default_image(const void *fit) -{ - int images_noffset; - - images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH); - if (images_noffset < 0) - return NULL; - - return fdt_getprop(fit, images_noffset, FIT_DEFAULT_PROP, NULL); -} - -int image_locate_script(void *buf, int size, const char *fit_uname, - const char *confname, char **datap, uint *lenp) -{ - ulong len; - const struct legacy_img_hdr *hdr; - u32 *data; - int verify; - const void* fit_hdr; - int noffset; - const void *fit_data; - size_t fit_len; - - verify = env_get_yesno("verify"); - - switch (genimg_get_format(buf)) { - case IMAGE_FORMAT_LEGACY: - if (IS_ENABLED(CONFIG_LEGACY_IMAGE_FORMAT)) { - hdr = buf; - - if (!image_check_magic(hdr)) { - puts("Bad magic number\n"); - return 1; - } - - if (!image_check_hcrc(hdr)) { - puts("Bad header crc\n"); - return 1; - } - - if (verify) { - if (!image_check_dcrc(hdr)) { - puts("Bad data crc\n"); - return 1; - } - } - - if (!image_check_type(hdr, IH_TYPE_SCRIPT)) { - puts("Bad image type\n"); - return 1; - } - - /* get length of script */ - data = (u32 *)image_get_data(hdr); - - len = uimage_to_cpu(*data); - if (!len) { - puts("Empty Script\n"); - return 1; - } - - /* - * scripts are just multi-image files with one - * component, so seek past the zero-terminated sequence - * of image lengths to get to the actual image data - */ - while (*data++); - } - break; - case IMAGE_FORMAT_FIT: - if (IS_ENABLED(CONFIG_FIT)) { - fit_hdr = buf; - if (fit_check_format(fit_hdr, IMAGE_SIZE_INVAL)) { - puts("Bad FIT image format\n"); - return 1; - } - - if (!fit_uname) { - /* If confname is empty, use the default */ - if (confname && *confname) - noffset = fit_conf_get_node(fit_hdr, confname); - else - noffset = fit_conf_get_node(fit_hdr, NULL); - if (noffset < 0) { - if (!confname) - goto fallback; - printf("Could not find config %s\n", confname); - return 1; - } - - if (verify && fit_config_verify(fit_hdr, noffset)) - return 1; - - noffset = fit_conf_get_prop_node(fit_hdr, - noffset, - FIT_SCRIPT_PROP, - IH_PHASE_NONE); - if (noffset < 0) { - if (!confname) - goto fallback; - printf("Could not find script in %s\n", confname); - return 1; - } - } else { -fallback: - if (!fit_uname || !*fit_uname) - fit_uname = get_default_image(fit_hdr); - if (!fit_uname) { - puts("No FIT subimage unit name\n"); - return 1; - } - - /* get script component image node offset */ - noffset = fit_image_get_node(fit_hdr, fit_uname); - if (noffset < 0) { - printf("Can't find '%s' FIT subimage\n", - fit_uname); - return 1; - } - } - - if (!fit_image_check_type(fit_hdr, noffset, - IH_TYPE_SCRIPT)) { - puts("Not a image image\n"); - return 1; - } - - /* verify integrity */ - if (verify && !fit_image_verify(fit_hdr, noffset)) { - puts("Bad Data Hash\n"); - return 1; - } - - /* get script subimage data address and length */ - if (fit_image_get_data(fit_hdr, noffset, &fit_data, &fit_len)) { - puts("Could not find script subimage data\n"); - return 1; - } - - data = (u32 *)fit_data; - len = (ulong)fit_len; - } - break; - default: - puts("Wrong image format for \"source\" command\n"); - return -EPERM; - } - - *datap = (char *)data; - *lenp = len; - - return 0; -} - -int image_source_script(ulong addr, const char *fit_uname, const char *confname) -{ - char *data; - void *buf; - uint len; - int ret; - - buf = map_sysmem(addr, 0); - ret = image_locate_script(buf, 0, fit_uname, confname, &data, &len); - unmap_sysmem(buf); - if (ret) - return CMD_RET_FAILURE; - - debug("** Script length: %d\n", len); - return run_command_list(data, len, 0); -} - -/**************************************************/ -#if defined(CONFIG_CMD_SOURCE) static int do_source(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { @@ -228,7 +50,7 @@ static int do_source(struct cmd_tbl *cmdtp, int flag, int argc, } printf ("## Executing script at %08lx\n", addr); - rcode = image_source_script(addr, fit_uname, confname); + rcode = cmd_source_script(addr, fit_uname, confname); return rcode; } @@ -250,4 +72,3 @@ U_BOOT_CMD( source, 2, 0, do_source, "run script from memory", source_help_text ); -#endif -- cgit v1.2.3 From 0e38bd848d41bcfc7a113603ee37805016a09a42 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 6 Jan 2023 08:52:32 -0600 Subject: video: Add font functions to the vidconsole API Support for fonts currently depends on the type of vidconsole in use. Add two new methods to enumerate fonts and to set the font. Fix a few other method comments while we are here. Signed-off-by: Simon Glass --- cmd/font.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'cmd') diff --git a/cmd/font.c b/cmd/font.c index 3e522f3aaa1..7b4347f32b5 100644 --- a/cmd/font.c +++ b/cmd/font.c @@ -15,7 +15,11 @@ static int do_font_list(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - vidconsole_list_fonts(); + struct udevice *dev; + + if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev)) + return CMD_RET_FAILURE; + vidconsole_list_fonts(dev); return 0; } @@ -47,6 +51,7 @@ static int do_font_select(struct cmd_tbl *cmdtp, int flag, int argc, static int do_font_size(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { + const char *font_name; struct udevice *dev; uint size; int ret; @@ -56,9 +61,11 @@ static int do_font_size(struct cmd_tbl *cmdtp, int flag, int argc, if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev)) return CMD_RET_FAILURE; + font_name = vidconsole_get_font_size(dev, &size); size = dectoul(argv[1], NULL); - ret = vidconsole_select_font(dev, NULL, size); + + ret = vidconsole_select_font(dev, font_name, size); if (ret) { printf("Failed (error %d)\n", ret); return CMD_RET_FAILURE; -- cgit v1.2.3 From 2175e76a51e53798ee4e19903b368a7e6c98356a Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 6 Jan 2023 08:52:33 -0600 Subject: bootstd: Read the Operating System name for distro/scripts Add the concept of an OS name to the bootflow. This typically includes the OS name, version and kernel version. Implement this for the distro and script bootmeths so that it works with Armbian and older version of Fedora. Signed-off-by: Simon Glass --- cmd/bootflow.c | 1 + 1 file changed, 1 insertion(+) (limited to 'cmd') diff --git a/cmd/bootflow.c b/cmd/bootflow.c index 313103d2775..6b8ac8c8504 100644 --- a/cmd/bootflow.c +++ b/cmd/bootflow.c @@ -337,6 +337,7 @@ static int do_bootflow_info(struct cmd_tbl *cmdtp, int flag, int argc, printf("Filename: %s\n", bflow->fname); printf("Buffer: %lx\n", (ulong)map_to_sysmem(bflow->buf)); printf("Size: %x (%d bytes)\n", bflow->size, bflow->size); + printf("OS: %s\n", bflow->os_name ? bflow->os_name : "(none)"); printf("Error: %d\n", bflow->err); if (dump && bflow->buf) { /* Set some sort of maximum on the size */ -- cgit v1.2.3 From 24d8e1b37b90760a6c9867f37210aa4b1f2e8f63 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 6 Jan 2023 08:52:34 -0600 Subject: bootstd: Allow reading a logo for the OS Some operating systems provide a logo in bmp format. Read this in if present so it can be displayed in the menu. Signed-off-by: Simon Glass --- cmd/bootflow.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'cmd') diff --git a/cmd/bootflow.c b/cmd/bootflow.c index 6b8ac8c8504..495ef85f25b 100644 --- a/cmd/bootflow.c +++ b/cmd/bootflow.c @@ -338,6 +338,12 @@ static int do_bootflow_info(struct cmd_tbl *cmdtp, int flag, int argc, printf("Buffer: %lx\n", (ulong)map_to_sysmem(bflow->buf)); printf("Size: %x (%d bytes)\n", bflow->size, bflow->size); printf("OS: %s\n", bflow->os_name ? bflow->os_name : "(none)"); + printf("Logo: %s\n", bflow->logo ? + simple_xtoa((ulong)map_to_sysmem(bflow->logo)) : "(none)"); + if (bflow->logo) { + printf("Logo size: %x (%d bytes)\n", bflow->logo_size, + bflow->logo_size); + } printf("Error: %d\n", bflow->err); if (dump && bflow->buf) { /* Set some sort of maximum on the size */ -- cgit v1.2.3 From 02d929bfb25af22171dbd100f38ffd8fa6bf6238 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 6 Jan 2023 08:52:40 -0600 Subject: bootstd: Support creating a boot menu Create an expo to handle the boot menu. For now this is quite simple, with just a header, some menu items and a pointer to show the current one. Signed-off-by: Simon Glass --- cmd/bootflow.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'cmd') diff --git a/cmd/bootflow.c b/cmd/bootflow.c index 495ef85f25b..2b6ed26fdcb 100644 --- a/cmd/bootflow.c +++ b/cmd/bootflow.c @@ -389,6 +389,37 @@ static int do_bootflow_boot(struct cmd_tbl *cmdtp, int flag, int argc, return 0; } + +static int do_bootflow_menu(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct bootstd_priv *std; + struct bootflow *bflow; + bool text_mode = false; + int ret; + + if (argc > 1 && *argv[1] == '-') + text_mode = strchr(argv[1], 't'); + + ret = bootstd_get_priv(&std); + if (ret) + return CMD_RET_FAILURE; + + ret = bootflow_menu_run(std, text_mode, &bflow); + if (ret) { + if (ret == -EAGAIN) + printf("Nothing chosen\n"); + else + printf("Menu failed (err=%d)\n", ret); + + return CMD_RET_FAILURE; + } + + printf("Selected: %s\n", bflow->os_name ? bflow->os_name : bflow->name); + std->cur_bootflow = bflow; + + return 0; +} #endif /* CONFIG_CMD_BOOTFLOW_FULL */ #ifdef CONFIG_SYS_LONGHELP @@ -398,7 +429,8 @@ static char bootflow_help_text[] = "bootflow list [-e] - list scanned bootflows (-e errors)\n" "bootflow select [|] - select a bootflow\n" "bootflow info [-d] - show info on current bootflow (-d dump bootflow)\n" - "bootflow boot - boot current bootflow (or first available if none selected)"; + "bootflow boot - boot current bootflow (or first available if none selected)\n" + "bootflow menu [-t] - show a menu of available bootflows"; #else "scan - boot first available bootflow\n"; #endif @@ -410,6 +442,7 @@ U_BOOT_CMD_WITH_SUBCMDS(bootflow, "Boot flows", bootflow_help_text, U_BOOT_SUBCMD_MKENT(list, 2, 1, do_bootflow_list), U_BOOT_SUBCMD_MKENT(select, 2, 1, do_bootflow_select), U_BOOT_SUBCMD_MKENT(info, 2, 1, do_bootflow_info), - U_BOOT_SUBCMD_MKENT(boot, 1, 1, do_bootflow_boot) + U_BOOT_SUBCMD_MKENT(boot, 1, 1, do_bootflow_boot), + U_BOOT_SUBCMD_MKENT(menu, 2, 1, do_bootflow_menu), #endif ); -- cgit v1.2.3