From: Rob Herring <robherring2@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 07/10] pxe: simplify menu display and selection
Date: Sun, 2 Dec 2012 21:00:26 -0600 [thread overview]
Message-ID: <1354503629-25621-8-git-send-email-robherring2@gmail.com> (raw)
In-Reply-To: <1354503629-25621-1-git-send-email-robherring2@gmail.com>
From: Rob Herring <rob.herring@calxeda.com>
Menus with lots of entries and long append lines are hard to read.
Just show a numbered list using the label or name and make the choice
by entering the number.
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
common/cmd_pxe.c | 34 ++++++++++++++++------------------
1 file changed, 16 insertions(+), 18 deletions(-)
diff --git a/common/cmd_pxe.c b/common/cmd_pxe.c
index 85a27e0..d697045 100644
--- a/common/cmd_pxe.c
+++ b/common/cmd_pxe.c
@@ -429,6 +429,7 @@ static int get_relfile_envaddr(const char *file_path, const char *envaddr_name)
* list - lets these form a list, which a pxe_menu struct will hold.
*/
struct pxe_label {
+ char num[4];
char *name;
char *menu;
char *kernel;
@@ -518,21 +519,9 @@ static void label_destroy(struct pxe_label *label)
static void label_print(void *data)
{
struct pxe_label *label = data;
- const char *c = label->menu ? label->menu : label->kernel;
+ const char *c = label->menu ? label->menu : label->name;
- printf("%s:\t%s\n", label->name, c);
-
- if (label->kernel)
- printf("\t\tkernel: %s\n", label->kernel);
-
- if (label->append)
- printf("\t\tappend: %s\n", label->append);
-
- if (label->initrd)
- printf("\t\tinitrd: %s\n", label->initrd);
-
- if (label->fdt)
- printf("\tfdt: %s\n", label->fdt);
+ printf("%s:\t%s\n", label->num, c);
}
/*
@@ -619,8 +608,10 @@ static int label_boot(struct pxe_label *label)
return 1;
}
- if (label->append)
+ if (label->append) {
setenv("bootargs", label->append);
+ printf("append: %s\n", label->append);
+ }
bootm_argv[1] = getenv("kernel_addr_r");
@@ -1267,6 +1258,8 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu *cfg)
struct list_head *pos;
struct menu *m;
int err;
+ int i = 1;
+ char *default_num = NULL;
/*
* Create a menu and add items for all the labels.
@@ -1279,18 +1272,23 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu *cfg)
list_for_each(pos, &cfg->labels) {
label = list_entry(pos, struct pxe_label, list);
- if (menu_item_add(m, label->name, label) != 1) {
+ sprintf(label->num, "%d", i++);
+ if (menu_item_add(m, label->num, label) != 1) {
menu_destroy(m);
return NULL;
}
+ if (cfg->default_label &&
+ (strcmp(label->name, cfg->default_label) == 0))
+ default_num = label->num;
+
}
/*
* After we've created items for each label in the menu, set the
* menu's default label if one was specified.
*/
- if (cfg->default_label) {
- err = menu_default_set(m, cfg->default_label);
+ if (default_num) {
+ err = menu_default_set(m, default_num);
if (err != 1) {
if (err != -ENOENT) {
menu_destroy(m);
--
1.7.10.4
next prev parent reply other threads:[~2012-12-03 3:00 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-03 3:00 [U-Boot] [PATCH 00/10] PXE support updates Rob Herring
2012-12-03 3:00 ` [U-Boot] [PATCH 01/10] pxe: Use ethact setting for pxe Rob Herring
2013-07-08 15:48 ` Joe Hershberger
2012-12-03 3:00 ` [U-Boot] [PATCH 02/10] pxe: make string parameters const Rob Herring
2012-12-03 3:00 ` [U-Boot] [PATCH 03/10] pxe: fix handling of different localboot values Rob Herring
2012-12-03 3:00 ` [U-Boot] [PATCH 04/10] bootz: un-staticize do_bootz Rob Herring
2012-12-03 3:00 ` [U-Boot] [PATCH 05/10] pxe: use bootz instead of bootm when enabled Rob Herring
2012-12-03 12:22 ` Wolfgang Denk
2012-12-03 14:16 ` Rob Herring
2012-12-03 19:17 ` [U-Boot] [PATCH v2] pxe: try bootz if bootm fails to find a valid image Rob Herring
2013-07-08 15:52 ` Joe Hershberger
2012-12-03 3:00 ` [U-Boot] [PATCH 06/10] pxe: always display a menu when present Rob Herring
2012-12-03 3:00 ` Rob Herring [this message]
2012-12-03 3:00 ` [U-Boot] [PATCH 08/10] pxe: add support for ontimeout token Rob Herring
2012-12-03 3:00 ` [U-Boot] [PATCH 09/10] pxe: add support for per arch and SoC default paths Rob Herring
2012-12-03 3:00 ` [U-Boot] [PATCH 10/10] pxe: add ipappend support Rob Herring
2013-05-14 19:48 ` [U-Boot] [PATCH 00/10] PXE support updates Rob Herring
2013-05-14 20:32 ` Joe Hershberger
2013-06-16 15:24 ` Rob Herring
2013-06-17 2:29 ` Joe Hershberger
2013-06-21 15:33 ` Joe Hershberger
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=1354503629-25621-8-git-send-email-robherring2@gmail.com \
--to=robherring2@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox