Skip to contentSkip to conversation

Menu Frameworj

RFC New Jean-Christophe PLAGNIOL-VILLARD 4 participants 28 messages Jun 13, 2009 – Jun 16, 2009

lore
Share & tools
lore
#0 lore raw

Hi,

The following patch will introduce a menu framework
that allow us to create list menu to simplify u-boot and make it more convivial for the end-user.

This kind of menu is very usefull when you do not have a keyboard or a serial console attached to your board to allow you to interract with u-boot

For the develloper part,
The framework introduce two API

1) C
that allow you to create menu, submenu, entry and complex menu action

2) Command
that allow you as the C API to create menu, submenu, entry and complex menu action but this time the actions will be store in a env var and then be evaluated and excecuted.

NB the current code need somework to be mainline as doc, error message but it's functionnal. So feel free to test and improve

Best Regards,
J.

#1 lore raw

PATCH 1/2 Add menu Framework

Introduce a menu framework that allow us to create list menu to simplify u-boot and make it more convivial for the end-user.

This kind of menu is very usefull when you do not have a keyboard or a serial console attached to your board to allow you to interract with u-boot

For the develloper part,
The framework introduce two API

1) C
that allow you to create menu, submenu, entry and complex menu action

2) Command
that allow you as the C API to create menu, submenu, entry and complex menu action but this time the actions will be store in a env var and then be evaluated and excecuted.

---
 common/Makefile          |    1 +
 common/cmd_menu.c        |  527 ++++++++++++++++++++++++++++++++++++++++++++++
 include/config_cmd_all.h |    1 +
 include/console.h        |    5 +
 include/menu.h           |   85 ++++++++
 5 files changed, 619 insertions(+), 0 deletions(-)
 create mode 100644 common/cmd_menu.c
 create mode 100644 include/menu.h
common/Makefile +1 -0
index ee0cb33..ba9cfbd 100644
@@ -108,6 +108,7 @@ COBJS-y += cmd_load.o
 COBJS-$(CONFIG_LOGBUFFER) += cmd_log.o
 COBJS-$(CONFIG_ID_EEPROM) += cmd_mac.o
 COBJS-$(CONFIG_CMD_MEMORY) += cmd_mem.o
+COBJS-$(CONFIG_CMD_MENU) += cmd_menu.o
 COBJS-$(CONFIG_CMD_MFSL) += cmd_mfsl.o
 COBJS-$(CONFIG_CMD_MG_DISK) += cmd_mgdisk.o
 COBJS-$(CONFIG_MII) += miiphyutil.o
common/cmd_menu.c new file +527 -0

527 lines not on this page · raw message

include/config_cmd_all.h +1 -0
index c747b4b..b99a13f 100644
@@ -53,6 +53,7 @@
 #define CONFIG_CMD_LOADB	/* loadb			*/
 #define CONFIG_CMD_LOADS	/* loads			*/
 #define CONFIG_CMD_MEMORY	/* md mm nm mw cp cmp crc base loop mtest */
+#define CONFIG_CMD_MEMU		/* menu */
 #define CONFIG_CMD_MFSL		/* FSL support for Microblaze	*/
 #define CONFIG_CMD_MII		/* MII support			*/
 #define CONFIG_CMD_MISC		/* Misc functions like sleep etc*/
include/console.h +5 -0
index bc8b139..23c1b0c 100644
@@ -33,4 +33,9 @@
 extern device_t	*stdio_devices[] ;
 extern char *stdio_names[MAX_FILES] ;
 
+#define printf_reverse(fmt,args...)	printf("\e[7m" fmt "\e[m",##args)
+#define puts_reverse(fmt)		puts("\e[7m" fmt "\e[m")
+#define gotoXY(row, col)		printf("\e[%d;%dH", row, col)
+#define clear()				puts("\e[2J")
+
 #endif
include/menu.h new file +85 -0

85 lines not on this page · raw message

Signature · 1 line
1.6.3.1
#2 lore raw

PATCH 1/2 r2dplus: add menu example support

this patch is just an example to show you how to create your own menu using the C API. It will not be a part of the final version

---
 board/renesas/r2dplus/Makefile       |   12 ++++---
 board/renesas/r2dplus/menu_example.c |   57 ++++++++++++++++++++++++++++++++++
 board/renesas/r2dplus/r2dplus.c      |    3 ++
 include/configs/r2dplus.h            |    3 ++
 lib_sh/board.c                       |    4 ++
 5 files changed, 74 insertions(+), 5 deletions(-)
 create mode 100644 board/renesas/r2dplus/menu_example.c
board/renesas/r2dplus/Makefile +7 -5
index e96a8aa..5fbaeb9 100644
@@ -21,12 +21,14 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(BOARD).a
 
-COBJS	:= r2dplus.o
-SOBJS	:= lowlevel_init.o
+COBJS-y	= r2dplus.o
+COBJS-$(CONFIG_MENU_EXAMPLE) += menu_example.o
 
-SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
-OBJS	:= $(addprefix $(obj),$(COBJS))
-SOBJS	:= $(addprefix $(obj),$(SOBJS))
+SOBJS-y	= lowlevel_init.o
+
+SRCS	:= $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS-y))
+SOBJS	:= $(addprefix $(obj),$(SOBJS-y))
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) $(ARFLAGS) $@ $(OBJS) $(SOBJS)
board/renesas/r2dplus/menu_example.c new file +57 -0

57 lines not on this page · raw message

board/renesas/r2dplus/r2dplus.c +3 -0
index 0c08d68..9877a9c 100644
@@ -51,6 +51,9 @@ int dram_init(void)
 
 int board_late_init(void)
 {
+#ifdef CONFIG_CMD_MENU
+	menu_example_register();
+#endif
 	return 0;
 }
 
include/configs/r2dplus.h +3 -0
index 6fa1eaf..f8a0744 100644
@@ -24,6 +24,9 @@
 #define CONFIG_CMD_IDE
 #define CONFIG_CMD_EXT2
 #define CONFIG_DOS_PARTITION
+#define CONFIG_CMD_MENU
+#define CONFIG_CMD_MENU_MANAGEMENT
+#define CONFIG_MENU_EXAMPLE
 
 /* SCIF */
 #define CONFIG_SCIF_CONSOLE	1
lib_sh/board.c +4 -0
index 183110f..fb0d19d 100644
@@ -25,6 +25,7 @@
 #include <timestamp.h>
 #include <version.h>
 #include <watchdog.h>
+#include <menu.h>
 #include <net.h>
 #include <environment.h>
 
@@ -152,6 +153,9 @@ init_fnc_t *init_sequence[] =
 	INIT_FUNC_PCI_INIT	/* PCI init */
 	devices_init,
 	console_init_r,
+#ifdef CONFIG_CMD_MENU
+	menu_init,
+#endif
 	interrupt_init,
 #ifdef BOARD_LATE_INIT
 	board_late_init,
Signature · 1 line
1.6.3.1
#3 lore raw

PATCH 1/2 r2dplus: add menu example support

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 70 lines · In message <[email protected]> you wrote:

this patch is just an example to show you how to create your own menu using the C API. It will not be a part of the final version

---
 board/renesas/r2dplus/Makefile       |   12 ++++---
 board/renesas/r2dplus/menu_example.c |   57 ++++++++++++++++++++++++++++++++++
 board/renesas/r2dplus/r2dplus.c      |    3 ++
 include/configs/r2dplus.h            |    3 ++
 lib_sh/board.c                       |    4 ++
 5 files changed, 74 insertions(+), 5 deletions(-)
 create mode 100644 board/renesas/r2dplus/menu_example.c
board/renesas/r2dplus/Makefile +7 -5
index e96a8aa..5fbaeb9 100644
@@ -21,12 +21,14 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(BOARD).a
 
-COBJS	:= r2dplus.o
-SOBJS	:= lowlevel_init.o
+COBJS-y	= r2dplus.o
+COBJS-$(CONFIG_MENU_EXAMPLE) += menu_example.o
 
-SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
-OBJS	:= $(addprefix $(obj),$(COBJS))
-SOBJS	:= $(addprefix $(obj),$(SOBJS))
+SOBJS-y	= lowlevel_init.o
+
+SRCS	:= $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS-y))
+SOBJS	:= $(addprefix $(obj),$(SOBJS-y))
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) $(ARFLAGS) $@ $(OBJS) $(SOBJS)
board/renesas/r2dplus/menu_example.c new file +27 -0
new file mode 100644
index 0000000..6b9aa4f
@@ -0,0 +1,57 @@
+/*
+ * (C) Copyright 2009 Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <command.h>
+#include <console.h>
+#include <menu.h>
+

board/renesas/r2dplus/menu_example.c line 37

Quoted 10 lines
board/renesas/r2dplus/menu_example.c new file +10 -0
+struct menu boot;
+struct menu_entry boot_entry[5];
+
+static int menu_action_example(struct menu *m, struct menu_entry *me)
+{
+	clear();
+	gotoXY(0, 0);
+	printf("selected: %d\n", me->num);
+	return 0;
+}

Please do not add example code to a regular board.

NAK.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Look! There! Evil!.. pure and simple, total  evil  from  the  Eighth
Dimension!"                                         - Buckaroo Banzai
#4 lore raw

PATCH 1/2 r2dplus: add menu example support

Quoted 8 lines · Wolfgang Denk

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 3 lines · In message <[email protected]> you wrote:

this patch is just an example to show you how to create your own menu using the C API. It will not be a part of the final version

Please do not add example code to a regular board.

As I've said in the commit message it will not be present at the final version

It's just to show example code as I've test it on my r2dplus too

Best Regards,
J.

#5 lore raw

PATCH 1/2 Add menu Framework

In reply to Jean-Christophe PLAGNIOL-VILLARD

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 13 lines · In message <[email protected]> you wrote:

Introduce a menu framework that allow us to create list menu to simplify u-boot and make it more convivial for the end-user.

This kind of menu is very usefull when you do not have a keyboard or a serial console attached to your board to allow you to interract with u-boot

For the develloper part,
The framework introduce two API

1) C
that allow you to create menu, submenu, entry and complex menu action

Quoted 6 lines

2) Command
that allow you as the C API to create menu, submenu, entry and complex menu action but this time the actions will be store in a env var and then be evaluated and excecuted.

What's the sense of posting a summary when you repeat the whole text identically here?

common/cmd_menu.c line 330

Quoted 6 lines
common/cmd_menu.c new file +6 -0
+		while ((*dst = *src) != '\0') {
+			dst++;
+			src++;
+		}
+		*dst = (i == (argc - 1)) ? '\0' : ' ';
+		dst++;

This code repeats. Please factor out.

Quoted 7 lines
common/cmd_menu.c new file +7 -0
+	if (!strncmp(argv[0], "a", 1))
+		return do_menu_entry_add(cmdtp, flag, argc, argv);
+	if (!strncmp(argv[0], "l", 1))
+		return do_menu_entry_list(cmdtp, flag, argc, argv);
+	else
+		cmd_usage(cmdtp);
+	return 0;

...

common/cmd_menu.c line 513

Quoted 12 lines
common/cmd_menu.c new file +12 -0
+#if defined(CONFIG_CMD_MENU_MANAGEMENT)
+	if (!strncmp(argv[0], "a", 1))
+		return do_menu_add(cmdtp, flag, argc, argv);
+	if (!strncmp(argv[0], "e", 1))
+		return do_menu_entry(cmdtp, flag, argc, argv);
+#endif
+	if (!strncmp(argv[0], "l", 1))
+		return do_menu_list(cmdtp, flag, argc, argv);
+	if (!strncmp(argv[0], "s", 1))
+		return do_menu_show(cmdtp, flag, argc, argv);
+	else
+		cmd_usage(cmdtp);

Please use the existing command parser for such subcommands.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
You can't have everything... where would you put it?  - Steven Wright
#6 lore raw

PATCH 1/2 Add menu Framework

Quoted 6 lines
Quoted 6 lines
common/cmd_menu.c new file +6 -0
+#if defined(CONFIG_CMD_MENU_MANAGEMENT)
+	if (!strncmp(argv[0], "a", 1))
+		return do_menu_add(cmdtp, flag, argc, argv);
+	if (!strncmp(argv[0], "e", 1))
+		return do_menu_entry(cmdtp, flag, argc, argv);
+#endif
Quoted 8 lines

common/cmd_menu.c line 513

Quoted 6 lines
common/cmd_menu.c new file +6 -0
+	if (!strncmp(argv[0], "l", 1))
+		return do_menu_list(cmdtp, flag, argc, argv);
+	if (!strncmp(argv[0], "s", 1))
+		return do_menu_show(cmdtp, flag, argc, argv);
+	else
+		cmd_usage(cmdtp);

Please use the existing command parser for such subcommands.

ok which one?

Best Regards,
J.

#7 lore raw

PATCH 1/2 Add menu Framework

Hi Jean-Christophe,

Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
common/cmd_menu.c new file +6 -0
+#if defined(CONFIG_CMD_MENU_MANAGEMENT)
+	if (!strncmp(argv[0], "a", 1))
+		return do_menu_add(cmdtp, flag, argc, argv);
+	if (!strncmp(argv[0], "e", 1))
+		return do_menu_entry(cmdtp, flag, argc, argv);
+#endif
Quoted 8 lines

common/cmd_menu.c line 513

Quoted 6 lines
common/cmd_menu.c new file +6 -0
+	if (!strncmp(argv[0], "l", 1))
+		return do_menu_list(cmdtp, flag, argc, argv);
+	if (!strncmp(argv[0], "s", 1))
+		return do_menu_show(cmdtp, flag, argc, argv);
+	else
+		cmd_usage(cmdtp);

Please use the existing command parser for such subcommands.

Quoted 1 line

ok which one?

Build your own cmd_tbl_t and use find_cmd_tbl. For an example see boards/inka4x0/inkadiag.c

Cheers
Detlev

Signature · 5 lines
Who is General Failure and why is he reading my hard disk?
--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de
#8 lore raw

PATCH 1/2 Add menu Framework

Quoted 16 lines · Detlev Zundel

Hi Jean-Christophe,

Quoted 14 lines
Quoted 14 lines

common/cmd_menu.c line 513

Quoted 12 lines
common/cmd_menu.c new file +12 -0
+#if defined(CONFIG_CMD_MENU_MANAGEMENT)
+	if (!strncmp(argv[0], "a", 1))
+		return do_menu_add(cmdtp, flag, argc, argv);
+	if (!strncmp(argv[0], "e", 1))
+		return do_menu_entry(cmdtp, flag, argc, argv);
+#endif
+	if (!strncmp(argv[0], "l", 1))
+		return do_menu_list(cmdtp, flag, argc, argv);
+	if (!strncmp(argv[0], "s", 1))
+		return do_menu_show(cmdtp, flag, argc, argv);
+	else
+		cmd_usage(cmdtp);

Please use the existing command parser for such subcommands.

Quoted 4 lines
Quoted 1 line

ok which one?

Build your own cmd_tbl_t and use find_cmd_tbl. For an example see boards/inka4x0/inkadiag.c

ok tks

Best Regards,
J.

#9 lore raw

PATCH 1/2 Add menu Framework

In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 10 lines · On Saturday 13 June 2009 15:13:01 Jean-Christophe PLAGNIOL-VILLARD wrote:

Introduce a menu framework that allow us to create list menu to simplify u-boot and make it more convivial for the end-user.

This kind of menu is very usefull when you do not have a keyboard or a serial console attached to your board to allow you to interract with u-boot

For the develloper part,
The framework introduce two API

Quoted 7 lines

1) C
that allow you to create menu, submenu, entry and complex menu action

2) Command
that allow you as the C API to create menu, submenu, entry and complex menu action but this time the actions will be store in a env var and then be evaluated and excecuted.

so you could create a multiple choice menu without writing a single line of C code ? that would certainly be preferred as writing C code seems error prone and silly for a static menu setup.

could you give an example of using the menu command ? e.g. openmoko presents a menu with a few options:
- boot
- set console to usb
- set console to serial
- reset

so using only the menu command, how could you achieve the same thing ?

common/cmd_menu.c line 35

Quoted 1 line
common/cmd_menu.c new file +1 -0
+	INIT_LIST_HEAD(&(menus.list));

you use &(...) in a lot of places where the parenthesis are unnecessary

common/cmd_menu.c line 51

Quoted 4 lines
common/cmd_menu.c new file +4 -0
+	if (m->name)
+		free(m->name);
+	if (m->display)
+		free(m->display);

free(NULL) works fine, so the if() is unnecessary

common/cmd_menu.c line 66

Quoted 4 lines
common/cmd_menu.c new file +4 -0
+int menu_add(struct menu *m)
+{
+	if (!m || !m->name)
+		return -1;

would all of these sanity checks make more sense as debug-oly checks ? or does the code rely on these in the normal running of things ?

common/cmd_menu.c line 98

Quoted 1 line
common/cmd_menu.c new file +1 -0
+		if(strcmp(m->name, name) == 0)

should do a search to make sure you're using "if ()" and not "if()" and similar

Quoted 5 lines
common/cmd_menu.c new file +5 -0
+	do {
+		ch = getc();
+		switch(ch) {
+		case 0x1b:
+			escape = 1;

common/cmd_menu.c line 228

Quoted 10 lines
common/cmd_menu.c new file +8 -0
+			break;
+		case '[':
+			if (escape)
+				break;
+		case 'A': /* up */
+			escape = 0;
...
+		case 'B': /* down */
+			escape = 0;
...

i'm guessing you're parsing arrow keys here (comment should say "up key" rather than just "up"). but if you get just a '[' or 'A' or 'B', then this doesnt work right. you probably want something like:

switch (ch) {
	case 0x1b:
		escape = 1;
		break;
	case '[':
		if (escape == 1)
			escape = 2;
		break;
	case 'A':
		if (escape != 2)
			break;
	...

then again, this kind of key parsing is duplicated in quite a few places in u- boot. we really should have this centralized so people can say getkey() and have it return cooked values.

common/cmd_menu.c line 253

Quoted 4 lines
common/cmd_menu.c new file +4 -0
+int menu_action_exit(struct menu *m, struct menu_entry *me)
+{
+	return 0;
+}

what's the point ?

include/console.h line 39

Quoted 6 lines
include/console.h +4 -0
+#define printf_reverse(fmt,args...)	printf("\e[7m" fmt "\e[m",##args)
+#define puts_reverse(fmt)		puts("\e[7m" fmt "\e[m")
+#define gotoXY(row, col)		printf("\e[%d;%dH", row, col)
+#define clear()				puts("\e[2J")

i'm guessing this works with serial consoles and linux terminals. how does this work with framebuffer consoles ? (the answer may be obvious as i'm not familiar with the framebuffer console layers that may exist in u-boot) -mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090615/4a80b5fc/attachment.pgp

#10 lore raw

PATCH 1/2 Add menu Framework

Quoted 14 lines · Mike Frysinger
Quoted 13 lines · On Saturday 13 June 2009 15:13:01 Jean-Christophe PLAGNIOL-VILLARD wrote:

Introduce a menu framework that allow us to create list menu to simplify u-boot and make it more convivial for the end-user.

This kind of menu is very usefull when you do not have a keyboard or a serial console attached to your board to allow you to interract with u-boot

For the develloper part,
The framework introduce two API

1) C
that allow you to create menu, submenu, entry and complex menu action

Quoted 8 lines
Quoted 4 lines

2) Command
that allow you as the C API to create menu, submenu, entry and complex menu action but this time the actions will be store in a env var and then be evaluated and excecuted.

so you could create a multiple choice menu without writing a single line of C code ? that would certainly be preferred as writing C code seems error prone and silly for a static menu setup.

yes you can create menu without a C line
this was mandatory for this framework when he was created I've also some generic menu implemented to manage board settings as example ethernet setting
I'll finish to merge them mainline and I public them

Quoted 9 lines

could you give an example of using the menu command ? e.g. openmoko presents a menu with a few options:
- boot
- set console to usb
- set console to serial
- reset

so using only the menu command, how could you achieve the same thing ?

yes and I'll post an example

Quoted 11 lines

common/cmd_menu.c line 35

Quoted 2 lines
common/cmd_menu.c new file +1 -0
+	INIT_LIST_HEAD(&(menus.list));

you use &(...) in a lot of places where the parenthesis are unnecessary

common/cmd_menu.c line 51

Quoted 4 lines
common/cmd_menu.c new file +4 -0
+	if (m->name)
+		free(m->name);
+	if (m->display)
+		free(m->display);

free(NULL) works fine, so the if() is unnecessary

ok

Quoted 8 lines

common/cmd_menu.c line 66

Quoted 5 lines
common/cmd_menu.c new file +4 -0
+int menu_add(struct menu *m)
+{
+	if (!m || !m->name)
+		return -1;

would all of these sanity checks make more sense as debug-oly checks ? or does the code rely on these in the normal running of things ?

it prevent that you add a menu when you do not have enough memmory reverse for the malloc

Quoted 5 lines

common/cmd_menu.c line 98

Quoted 2 lines
common/cmd_menu.c new file +1 -0
+		if(strcmp(m->name, name) == 0)

should do a search to make sure you're using "if ()" and not "if()" and similar

I known I've not finish to clean it, the original version does not follow Linux coding style

Quoted 33 lines
Quoted 6 lines
common/cmd_menu.c new file +5 -0
+	do {
+		ch = getc();
+		switch(ch) {
+		case 0x1b:
+			escape = 1;

common/cmd_menu.c line 228

Quoted 10 lines
common/cmd_menu.c new file +8 -0
+			break;
+		case '[':
+			if (escape)
+				break;
+		case 'A': /* up */
+			escape = 0;
...
+		case 'B': /* down */
+			escape = 0;
...

i'm guessing you're parsing arrow keys here (comment should say "up key" rather than just "up"). but if you get just a '[' or 'A' or 'B', then this doesnt work right. you probably want something like:

switch (ch) {
	case 0x1b:
		escape = 1;
		break;
	case '[':
		if (escape == 1)
			escape = 2;
		break;
	case 'A':
		if (escape != 2)
			break;
	...
Quoted 3 lines

then again, this kind of key parsing is duplicated in quite a few places in u- boot. we really should have this centralized so people can say getkey() and have it return cooked values.

will take a look

Quoted 7 lines

common/cmd_menu.c line 253

Quoted 5 lines
common/cmd_menu.c new file +4 -0
+int menu_action_exit(struct menu *m, struct menu_entry *me)
+{
+	return 0;
+}

what's the point ?

just exit the menu with a prompt

Quoted 11 lines

include/console.h line 39

Quoted 7 lines
include/console.h +4 -0
+#define printf_reverse(fmt,args...)	printf("\e[7m" fmt "\e[m",##args)
+#define puts_reverse(fmt)		puts("\e[7m" fmt "\e[m")
+#define gotoXY(row, col)		printf("\e[%d;%dH", row, col)
+#define clear()				puts("\e[2J")

i'm guessing this works with serial consoles and linux terminals. how does this work with framebuffer consoles ? (the answer may be obvious as i'm not familiar with the framebuffer console layers that may exist in u-boot)

I've not yet test the framebuffer but IIRC yes

I've plan to test it ASAP

Best Regards,
J.

#11 lore raw
In reply to Jean-Christophe PLAGNIOL-VILLARD

Dear Jean-Christophe PLAGNIOL-VILLARD,

In message <[email protected]> you wrote:

Subject Typo: Frameworj

Quoted 3 lines

The following patch will introduce a menu framework
that allow us to create list menu to simplify u-boot and make it more convivial for the end-user.

convivial?

Quoted 3 lines

This kind of menu is very usefull when you do not have a keyboard or a serial console attached to your board to allow you to interract with u-boot

...

Quoted 2 lines

NB the current code need somework to be mainline as doc, error message but it's functionnal. So feel free to test and improve

Is this new invented code, or is this in any way an adaption of exiting code, like the menu interface as used on the Openmoko Freerunner etc. ?

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
When in doubt, mumble;   when in trouble, delegate;  when in  charge,
ponder.                                             -- James H. Boren
#12 lore raw
Quoted 15 lines · Wolfgang Denk

Dear Jean-Christophe PLAGNIOL-VILLARD,

In message <[email protected]> you wrote:

Subject Typo: Frameworj

Quoted 3 lines

The following patch will introduce a menu framework
that allow us to create list menu to simplify u-boot and make it more convivial for the end-user.

convivial?

Quoted 3 lines

This kind of menu is very usefull when you do not have a keyboard or a serial console attached to your board to allow you to interract with u-boot

Quoted 7 lines

...

Quoted 2 lines

NB the current code need somework to be mainline as doc, error message but it's functionnal. So feel free to test and improve

Is this new invented code, or is this in any way an adaption of exiting code, like the menu interface as used on the Openmoko Freerunner etc. ?

new code that I write myself why?
I do not read the openmoko code any way

Best Regards,
J.

#13 lore raw

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 5 lines · In message <[email protected]> you wrote:
Quoted 4 lines

Is this new invented code, or is this in any way an adaption of exiting code, like the menu interface as used on the Openmoko Freerunner etc. ?

new code that I write myself why?

This is bad. Re-inventing the wheel again and again does not make it better.

Quoted 1 line

I do not read the openmoko code any way

May I please ask you to read it now, and either adapt it or come up with a compatible implementation?

I'd rather see convergence and consolidation (i. e. pulling out-of-tree features into mainline) instead of ever growing divergence.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
You've no idea of what a poor opinion  I  have  of  myself,  and  how
little I deserve it.                                  - W. S. Gilbert
#14 lore raw
Quoted 11 lines · Wolfgang Denk

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 5 lines · In message <[email protected]> you wrote:
Quoted 4 lines

Is this new invented code, or is this in any way an adaption of exiting code, like the menu interface as used on the Openmoko Freerunner etc. ?

new code that I write myself why?

This is bad. Re-inventing the wheel again and again does not make it better.

I write what I need

Quoted 9 lines
Quoted 2 lines

I do not read the openmoko code any way

May I please ask you to read it now, and either adapt it or come up with a compatible implementation?

I'd rather see convergence and consolidation (i. e. pulling out-of-tree features into mainline) instead of ever growing divergence.

why? They have no wish to come mainline.
I'll no adapt the API I use for my own need to match theirs If they want to use it they can do it but I'll not do the effort for them

Best Regards,
J.

#15 lore raw

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 9 lines · In message <[email protected]> you wrote:
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines

Is this new invented code, or is this in any way an adaption of exiting code, like the menu interface as used on the Openmoko Freerunner etc. ?

new code that I write myself why?

This is bad. Re-inventing the wheel again and again does not make it better.

I write what I need

So do I. And I write it from scratch when I cannot find existing code that does what I need, or that I consider unacceptable for other easons. But whenever I find existing soplutions I try to reuse them. That's the core idea of software engineering.

Quoted 7 lines
Quoted 6 lines

May I please ask you to read it now, and either adapt it or come up with a compatible implementation?

I'd rather see convergence and consolidation (i. e. pulling out-of-tree features into mainline) instead of ever growing divergence.

why? They have no wish to come mainline.

But you do.

Quoted 2 lines

I'll no adapt the API I use for my own need to match theirs If they want to use it they can do it but I'll not do the effort for them

And I hereby state that I will not accept any new menu system code into U-Boot mainline until it has been at least checked if there is a way to unify this with the Openmoko approach.

You prefer your own code, so please prove that it is so much better than the Openmoko code. Otherwise your efforts would be better invested in pulling their code into mainline, and extending / adap- ting it such that it fits your purposes.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
If all the Chinese simultaneously jumped into the Pacific  off  a  10
foot platform erected 10 feet off their coast, it would cause a tidal
wave that would destroy everything in this country west of Nebraska.
#16 lore raw
Quoted 22 lines · Wolfgang Denk

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 9 lines · In message <[email protected]> you wrote:
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines

Is this new invented code, or is this in any way an adaption of exiting code, like the menu interface as used on the Openmoko Freerunner etc. ?

new code that I write myself why?

This is bad. Re-inventing the wheel again and again does not make it better.

I write what I need

So do I. And I write it from scratch when I cannot find existing code that does what I need, or that I consider unacceptable for other easons. But whenever I find existing soplutions I try to reuse them. That's the core idea of software engineering.

Quoted 3 lines
Quoted 3 lines

May I please ask you to read it now, and either adapt it or come up with a compatible implementation?

Quoted 6 lines
Quoted 4 lines
Quoted 3 lines

I'd rather see convergence and consolidation (i. e. pulling out-of-tree features into mainline) instead of ever growing divergence.

why? They have no wish to come mainline.

But you do.

I do not as I'm not pay to merge them stuff

Quoted 7 lines
Quoted 3 lines

I'll no adapt the API I use for my own need to match theirs If they want to use it they can do it but I'll not do the effort for them

And I hereby state that I will not accept any new menu system code into U-Boot mainline until it has been at least checked if there is a way to unify this with the Openmoko approach.

I'll not do it as Openmoko guys do not want to do the effort to come mainline I'm not pay to do this job. Feel free to ask them I'll not waste my time on this ask again

Quoted 5 lines

You prefer your own code, so please prove that it is so much better than the Openmoko code. Otherwise your efforts would be better invested in pulling their code into mainline, and extending / adap- ting it such that it fits your purposes.

I do think we need to not work this way if they want to come mainline THEY need to do this effort I will not do it for them

Best Regards,
J.

#17 lore raw

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 5 lines · In message <[email protected]> you wrote:
Quoted 4 lines
Quoted 2 lines

why? They have no wish to come mainline.

But you do.

I do not as I'm not pay to merge them stuff

You want to get *your* code into mainline, and this will not happen unless there is a good reason to accept your new, most likely incompatible.

Quoted 6 lines
Quoted 3 lines

And I hereby state that I will not accept any new menu system code into U-Boot mainline until it has been at least checked if there is a way to unify this with the Openmoko approach.

I'll not do it as Openmoko guys do not want to do the effort to come mainline I'm not pay to do this job. Feel free to ask them I'll not waste my time on this ask again

Frankly, that's a pretty stupid point of view. Closing one's eyes and intentionally ignoring existing solutions is a waste of efforts.

It's not that you were helping "the Openmoko guys". It's about you helping yourself to reduce the amount of work - short term (when it comes to designing and implementing it - ok, this chance has already been lost) and long term (whenit comes to maintaining it).

Quoted 6 lines
Quoted 4 lines

You prefer your own code, so please prove that it is so much better than the Openmoko code. Otherwise your efforts would be better invested in pulling their code into mainline, and extending / adap- ting it such that it fits your purposes.

I do think we need to not work this way if they want to come mainline THEY need to do this effort I will not do it for them

I don't care what Openmoko is doing. If my understanding is right, they don't even use U-Boot any more - it was helpful for them during development, but now they don't need and use it any more.

But I do care about code divergence, and I don't want to see thirty implementations of the very same feature, all of them different in mninor details. I cannot prevent that this happens in so many out-of-tree prots, but I can try to prevent that it happens in mainline.

My position is clear enough, I think.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Don't hit a man when he's down - kick him; it's easier.
#18 lore raw
Quoted 20 lines · Wolfgang Denk

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 5 lines · In message <[email protected]> you wrote:
Quoted 4 lines
Quoted 2 lines

why? They have no wish to come mainline.

But you do.

I do not as I'm not pay to merge them stuff

You want to get *your* code into mainline, and this will not happen unless there is a good reason to accept your new, most likely incompatible.

Quoted 6 lines
Quoted 3 lines

And I hereby state that I will not accept any new menu system code into U-Boot mainline until it has been at least checked if there is a way to unify this with the Openmoko approach.

I'll not do it as Openmoko guys do not want to do the effort to come mainline I'm not pay to do this job. Feel free to ask them I'll not waste my time on this ask again

Quoted 7 lines

Frankly, that's a pretty stupid point of view. Closing one's eyes and intentionally ignoring existing solutions is a waste of efforts.

It's not that you were helping "the Openmoko guys". It's about you helping yourself to reduce the amount of work - short term (when it comes to designing and implementing it - ok, this chance has already been lost) and long term (whenit comes to maintaining it).

you choice to refuse it, you are interrested in the openmoko stuff where I'm not.

Quoted 11 lines
Quoted 7 lines
Quoted 5 lines

You prefer your own code, so please prove that it is so much better than the Openmoko code. Otherwise your efforts would be better invested in pulling their code into mainline, and extending / adap- ting it such that it fits your purposes.

I do think we need to not work this way if they want to come mainline THEY need to do this effort I will not do it for them

I don't care what Openmoko is doing. If my understanding is right, they don't even use U-Boot any more - it was helpful for them during development, but now they don't need and use it any more.

if they do not use it anymore why do I have to waste time on it?

Quoted 6 lines

But I do care about code divergence, and I don't want to see thirty implementations of the very same feature, all of them different in mninor details. I cannot prevent that this happens in so many out-of-tree prots, but I can try to prevent that it happens in mainline.

so you choice to force me to be out-of-tree, it's well better tks.

Best Regards,

#19 lore raw
In reply to Wolfgang Denk
Quoted 4 lines · Wolfgang Denk

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 1 line · In message <[email protected]> you wrote:
Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line

why? They have no wish to come mainline.

But you do.

I do not as I'm not pay to merge them stuff

You want to get *your* code into mainline, and this will not happen unless there is a good reason to accept your new, most likely incompatible.

I looked at the openmoko stuff and it's all a big hack with stuff hardcoded and crammed in the wrong places

they hack common console to have it working
They do not support submenu
They support only one boot menu (horrible hack of the console) no command to create menu from the prompt

the only 2 think they have which I've not implemented is

1) auto select support for the menu which I could implement later
2) key name to describe menu action

Best Regards,
J.

#20 lore raw
In reply to Wolfgang Denk
Quoted 10 lines · On Sunday 14 June 2009 04:51:52 Wolfgang Denk wrote:
Quoted 5 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 3 lines

Is this new invented code, or is this in any way an adaption of exiting code, like the menu interface as used on the Openmoko Freerunner etc. ?

new code that I write myself why?

This is bad. Re-inventing the wheel again and again does not make it better.

Quoted 8 lines
Quoted 1 line

I do not read the openmoko code any way

May I please ask you to read it now, and either adapt it or come up with a compatible implementation?

I'd rather see convergence and consolidation (i. e. pulling out-of-tree features into mainline) instead of ever growing divergence.

especially considering the openmoko code has seen real world use
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090614/4cd3b907/attachment.pgp

#21 lore raw
Quoted 13 lines · Mike Frysinger
Quoted 12 lines · On Sunday 14 June 2009 04:51:52 Wolfgang Denk wrote:
Quoted 5 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 3 lines

Is this new invented code, or is this in any way an adaption of exiting code, like the menu interface as used on the Openmoko Freerunner etc. ?

new code that I write myself why?

This is bad. Re-inventing the wheel again and again does not make it better.

Quoted 1 line

I do not read the openmoko code any way

Quoted 8 lines
Quoted 6 lines

May I please ask you to read it now, and either adapt it or come up with a compatible implementation?

I'd rather see convergence and consolidation (i. e. pulling out-of-tree features into mainline) instead of ever growing divergence.

especially considering the openmoko code has seen real world use

what tell you this one does not?

This one does see real world too for sometimes

Best Regards,
J.

#22 lore raw

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 7 lines · In message <[email protected]> you wrote:
Quoted 6 lines
Quoted 4 lines

I'd rather see convergence and consolidation (i. e. pulling out-of-tree features into mainline) instead of ever growing divergence.

especially considering the openmoko code has seen real world use

what tell you this one does not?

Well, speaking for me: I did not run into any product on the market that runs this code. I did run into the Openmoko implementation,t hough, and a *lot* of other software developers did so, too. Even if they did not study the code, they know it exists, where you can download it from, and how it works on a real device.

Quoted 1 line

This one does see real world too for sometimes

Maybe. But I am not aware of it ever hitting any significant part of the free software community before.

Please note that I do not claim in any way your code was bad, or that the Openmoko code is so much better. I did not make any such comparison. But I insist that the two implementations must be compared, and it must be checked if there is a way to come up with a single, compatible implementation.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Fools ignore complexity. Pragmatists suffer it. Some  can  avoid  it.
Geniuses remove it.
     - Perlis's Programming Proverb #58, SIGPLAN Notices, Sept.  1982
#23 lore raw
Quoted 19 lines · Wolfgang Denk

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 7 lines · In message <[email protected]> you wrote:
Quoted 6 lines
Quoted 4 lines

I'd rather see convergence and consolidation (i. e. pulling out-of-tree features into mainline) instead of ever growing divergence.

especially considering the openmoko code has seen real world use

what tell you this one does not?

Well, speaking for me: I did not run into any product on the market that runs this code. I did run into the Openmoko implementation,t hough, and a *lot* of other software developers did so, too. Even if they did not study the code, they know it exists, where you can download it from, and how it works on a real device.

Quoted 1 line

This one does see real world too for sometimes

Quoted 8 lines

Maybe. But I am not aware of it ever hitting any significant part of the free software community before.

Please note that I do not claim in any way your code was bad, or that the Openmoko code is so much better. I did not make any such comparison. But I insist that the two implementations must be compared, and it must be checked if there is a way to come up with a single, compatible implementation.

So try to ask again Openmoko guys to come Mainline, I've ask them again and again but they have no wish to do it. So I'm bored by them. I'll not waste anytime on it.

If someone want to compare them feel free I prefer to not mix them as I'm anyway partial.

Best Regards,
J.

#24 lore raw

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 6 lines · In message <[email protected]> you wrote:
Quoted 6 lines

Please note that I do not claim in any way your code was bad, or that the Openmoko code is so much better. I did not make any such comparison. But I insist that the two implementations must be compared, and it must be checked if there is a way to come up with a single, compatible implementation.

Quoted 6 lines

So try to ask again Openmoko guys to come Mainline, I've ask them again and again but they have no wish to do it. So I'm bored by them. I'll not waste anytime on it.

If someone want to compare them feel free I prefer to not mix them as I'm anyway partial.

What a shame.

In this case you leave me no choice either: please consider your code put on hold until the requirements are met.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Far back in the mists of ancient time, in the great and glorious days
of the former Galactic Empire, life was wild, rich  and  largely  tax
free.         - Douglas Adams, _The Hitchhiker's Guide to the Galaxy_
#25 lore raw
In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 21 lines · On Sunday 14 June 2009 05:24:02 Jean-Christophe PLAGNIOL-VILLARD wrote:
Quoted 20 lines · Mike Frysinger
Quoted 18 lines · On Sunday 14 June 2009 04:51:52 Wolfgang Denk wrote:
Quoted 5 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 3 lines

Is this new invented code, or is this in any way an adaption of exiting code, like the menu interface as used on the Openmoko Freerunner etc. ?

new code that I write myself why?

This is bad. Re-inventing the wheel again and again does not make it better.

Quoted 1 line

I do not read the openmoko code any way

May I please ask you to read it now, and either adapt it or come up with a compatible implementation?

I'd rather see convergence and consolidation (i. e. pulling out-of-tree features into mainline) instead of ever growing divergence.

Quoted 5 lines
Quoted 1 line

especially considering the openmoko code has seen real world use

what tell you this one does not?

This one does see real world too for sometimes

sorry, what i meant was "wide" real world use. i didnt mean to imply you didnt actually test anything. openmoko is being hacked on around the world. ive used the menu system myself on my openmoko (not to say i prefer it -- i dont particularly care at this point). of course, if u-boot did support this, i would probably integrate it into the one or two ADI boards that have LCDs and keypads.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090614/25af489b/attachment.pgp

#26 lore raw
Quoted 26 lines · Mike Frysinger
Quoted 25 lines · On Sunday 14 June 2009 05:24:02 Jean-Christophe PLAGNIOL-VILLARD wrote:
Quoted 13 lines · Mike Frysinger
Quoted 12 lines · On Sunday 14 June 2009 04:51:52 Wolfgang Denk wrote:
Quoted 5 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 3 lines

Is this new invented code, or is this in any way an adaption of exiting code, like the menu interface as used on the Openmoko Freerunner etc. ?

new code that I write myself why?

This is bad. Re-inventing the wheel again and again does not make it better.

Quoted 1 line

I do not read the openmoko code any way

Quoted 8 lines
Quoted 6 lines

May I please ask you to read it now, and either adapt it or come up with a compatible implementation?

I'd rather see convergence and consolidation (i. e. pulling out-of-tree features into mainline) instead of ever growing divergence.

especially considering the openmoko code has seen real world use

what tell you this one does not?

Quoted 8 lines
Quoted 1 line

This one does see real world too for sometimes

sorry, what i meant was "wide" real world use. i didnt mean to imply you didnt actually test anything. openmoko is being hacked on around the world. ive used the menu system myself on my openmoko (not to say i prefer it -- i dont particularly care at this point). of course, if u-boot did support this, i would probably integrate it into the one or two ADI boards that have LCDs and keypads.

so as you have the openmoko you can compare them easely and be non partial so free to compare and make an opinion

Best Regards,
J.

#27 lore raw
Quoted 10 lines · On Sunday 14 June 2009 07:20:47 Jean-Christophe PLAGNIOL-VILLARD wrote:
Quoted 6 lines · Mike Frysinger

sorry, what i meant was "wide" real world use. i didnt mean to imply you didnt actually test anything. openmoko is being hacked on around the world. ive used the menu system myself on my openmoko (not to say i prefer it -- i dont particularly care at this point). of course, if u-boot did support this, i would probably integrate it into the one or two ADI boards that have LCDs and keypads.

so as you have the openmoko you can compare them easely and be non partial so free to compare and make an opinion

well, i guess it doesnt matter much if Wolfgang isnt going to accept it. ive got enough out-of-tree cruft to worry about myself without adding a menu system onto the stack ;).
-mike