All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [RFC] Menu Frameworj
@ 2009-06-13 19:10 Jean-Christophe PLAGNIOL-VILLARD
  2009-06-13 19:13 ` [U-Boot] [RFC/PATCH 1/2] Add menu Framework Jean-Christophe PLAGNIOL-VILLARD
  2009-06-13 23:09 ` [U-Boot] [RFC] Menu Frameworj Wolfgang Denk
  0 siblings, 2 replies; 28+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2009-06-13 19:10 UTC (permalink / raw)
  To: u-boot

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.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [RFC/PATCH 1/2] Add menu Framework
  2009-06-13 19:10 [U-Boot] [RFC] Menu Frameworj Jean-Christophe PLAGNIOL-VILLARD
@ 2009-06-13 19:13 ` Jean-Christophe PLAGNIOL-VILLARD
  2009-06-13 19:13   ` [U-Boot] [RFC/PATCH 1/2] r2dplus: add menu example support Jean-Christophe PLAGNIOL-VILLARD
                     ` (2 more replies)
  2009-06-13 23:09 ` [U-Boot] [RFC] Menu Frameworj Wolfgang Denk
  1 sibling, 3 replies; 28+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2009-06-13 19:13 UTC (permalink / raw)
  To: u-boot

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.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 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

diff --git a/common/Makefile b/common/Makefile
index ee0cb33..ba9cfbd 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -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
diff --git a/common/cmd_menu.c b/common/cmd_menu.c
new file mode 100644
index 0000000..cd7a0c0
--- /dev/null
+++ b/common/cmd_menu.c
@@ -0,0 +1,527 @@
+/*
+ * (C) Copyright 2009 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
+ *
+ * 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>
+#ifdef CONFIG_SYS_HUSH_PARSER
+#include <hush.h>
+#endif
+
+static struct menu menus;
+
+int menu_init(void)
+{
+	INIT_LIST_HEAD(&(menus.list));
+
+	return 0;
+}
+
+void menu_free(struct menu *m)
+{
+	struct list_head *pos;
+	struct menu_entry *me;
+
+	if (!m)
+		return;
+	if (m->name)
+		free(m->name);
+
+	if (m->display)
+		free(m->display);
+
+	list_for_each(pos, &(m->entries.list)) {
+		me = list_entry(pos, struct menu_entry, list);
+		menu_entry_free(me);
+		list_del(pos);
+	}
+
+
+	free(m);
+}
+
+int menu_add(struct menu *m)
+{
+	if (!m || !m->name)
+		return -1;
+
+	list_add_tail(&(m->list), &(menus.list));
+	m->nb_entries = 1;
+
+	INIT_LIST_HEAD(&(m->entries.list));
+
+	return 0;
+}
+
+int menu_add_entry(struct menu *m, struct menu_entry *me)
+{
+	if (!m || !me || !me->display)
+		return -1;
+
+	me->num = m->nb_entries;
+	m->nb_entries++;
+	list_add_tail(&(me->list), &(m->entries.list));
+
+	return 0;
+}
+
+struct menu* menu_get_by_name(char *name)
+{
+	struct list_head *pos;
+	struct menu* m;
+
+	if (!name)
+		return NULL;
+
+	list_for_each(pos, &(menus.list)) {
+		m = list_entry(pos, struct menu, list);
+		if(strcmp(m->name, name) == 0)
+			return m;
+	}
+
+	return NULL;
+}
+
+struct menu_entry* menu_entry_get_by_num(struct menu* m, int num)
+{
+	struct list_head *pos;
+	struct menu_entry* me;
+
+	if (!m || num < 1 || m->nb_entries > num)
+		return NULL;
+
+	list_for_each(pos, &(m->entries.list)) {
+		me = list_entry(pos, struct menu_entry, list);
+		if(me->num == num)
+			return me;
+	}
+
+	return NULL;
+}
+
+void menu_entry_free(struct menu_entry *me)
+{
+	if (!me)
+		return;
+
+	if (me->display)
+		free(me->display);
+
+	free(me);
+}
+
+static void print_menu_entry(struct menu_entry *me, int reverse)
+{
+	gotoXY(me->num + 1, 3);
+	if (reverse)
+		printf_reverse("%d: %s", me->num, me->display);
+	else
+		printf("%d: %s", me->num, me->display);
+}
+
+int menu_set_selected_entry(struct menu *m, struct menu_entry* me)
+{
+	struct list_head *pos;
+	struct menu_entry* tmp;
+
+	if (!m || !me)
+		return -1;
+
+	list_for_each(pos, &(m->entries.list)) {
+		tmp = list_entry(pos, struct menu_entry, list);
+		if(me == tmp) {
+			m->selected = me;
+			return 0;
+		}
+	}
+
+	return -1;
+}
+
+int menu_set_selected(struct menu *m, int num)
+{
+	struct menu_entry *me;
+
+	me = menu_entry_get_by_num(m, num);
+
+	if (!me)
+		return -1;
+
+	m->selected = me;
+
+	return 0;
+}
+
+int menu_show(struct menu *m)
+{
+	struct list_head *pos;
+	struct menu_entry *me;
+	int ch;
+	int escape = 0;
+
+	if(!m)
+		return -1;
+
+	clear();
+	gotoXY(1, 2);
+	if(m->display) {
+		puts(m->display);
+	} else {
+		puts("Menu : ");
+		puts(m->name);
+	}
+
+	list_for_each(pos, &(m->entries.list)) {
+		me = list_entry(pos, struct menu_entry, list);
+		if(m->selected != me)
+			print_menu_entry(me, 0);
+	}
+
+	if (!m->selected) {
+		m->selected = list_first_entry(&(m->entries.list),
+						struct menu_entry, list);
+	}
+
+	print_menu_entry(m->selected, 1);
+
+	do {
+		ch = getc();
+		switch(ch) {
+		case 0x1b:
+			escape = 1;
+			break;
+		case '[':
+			if (escape)
+				break;
+		case 'A': /* up */
+			escape = 0;
+			print_menu_entry(m->selected, 0);
+			m->selected = list_entry(m->selected->list.prev, struct menu_entry,
+						 list);
+			if (&(m->selected->list) == &(m->entries.list)) {
+				m->selected = list_entry(m->selected->list.prev, struct menu_entry,
+							 list);
+			}
+			print_menu_entry(m->selected, 1);
+			break;
+		case 'B': /* down */
+			escape = 0;
+			print_menu_entry(m->selected, 0);
+			m->selected = list_entry(m->selected->list.next, struct menu_entry,
+						 list);
+			if (&(m->selected->list) == &(m->entries.list)) {
+				m->selected = list_entry(m->selected->list.next, struct menu_entry,
+							 list);
+			}
+			print_menu_entry(m->selected, 1);
+			break;
+		case '\n':
+		case '\r':
+			if (!m->selected->fn(m, m->selected))
+				return m->selected->num;
+		default:
+			break;
+		}
+	} while(1);
+
+	return 0;
+}
+
+int menu_action_exit(struct menu *m, struct menu_entry *me)
+{
+	return 0;
+}
+
+int menu_action_run(struct menu *m, struct menu_entry *me)
+{
+	char *s = getenv(me->priv);
+
+	if (!s)
+		return -1;
+
+#if !defined(CONFIG_SYS_HUSH_PARSER)
+	return run_command (s, 0);
+#else
+	return parse_string_outer(s, FLAG_PARSE_SEMICOLON
+				   | FLAG_EXIT_FROM_LOOP);
+#endif
+}
+
+/*
+ * Commands
+ */
+
+#if defined(CONFIG_CMD_MENU_MANAGEMENT)
+/*
+ * menu entry add <menu> <command> <selected> <description>
+ */
+int do_menu_entry_add(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
+{
+	struct menu_entry *me;
+	struct menu *m;
+	int len;
+	int i;
+	char *src, *dst;
+
+	if (argc < 5)
+		return -1;
+
+	m = menu_get_by_name(argv[1]);
+
+	if (!m)
+		return -1;
+
+	me = menu_entry_alloc();
+
+	if (!me)
+		return -1;
+
+	me->fn = menu_action_run;
+
+	len = strlen(argv[2]) + 1;
+
+	me->priv = calloc(len, sizeof(char));
+	if (!me->priv)
+		goto free;
+
+	strncpy(me->priv, argv[2], len);
+
+	len = 0;
+
+	for (i = 4; i < argc; i++) {
+		len += strlen(argv[i]) + 1;
+	}
+
+	me->display = calloc(len, sizeof(char));
+
+	if (!me->display)
+		goto free;
+
+	dst = me->display;
+
+	for (i = 4; i < argc; i++) {
+		src = argv[i];
+
+		while ((*dst = *src) != '\0') {
+			dst++;
+			src++;
+		}
+		*dst = (i == (argc - 1)) ? '\0' : ' ';
+		dst++;
+	}
+
+	if (menu_add_entry(m, me))
+		goto free;
+
+	if (simple_strtoul(argv[3], NULL, 16))
+		m->selected = me;
+
+	return 0;
+free:
+	if (me->priv)
+		free(me->priv);
+	menu_entry_free(me);
+	return -1;
+}
+
+static void print_entries(struct menu *m)
+{
+	struct list_head *pos;
+	struct menu_entry *me;
+
+	list_for_each(pos, &(m->entries.list)) {
+		me = list_entry(pos, struct menu_entry, list);
+		printf("%d: %s\n", me->num, me->display);
+	}
+}
+
+/*
+ * menu entry list [menu]
+ */
+int do_menu_entry_list(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
+{
+	struct list_head *pos;
+	struct menu *m = NULL;
+
+	if (argc > 2)
+		m = menu_get_by_name(argv[1]);
+
+	if (m) {
+		print_entries(m);
+		return 0;
+	}
+
+	list_for_each(pos, &(menus.list)) {
+		m = list_entry(pos, struct menu, list);
+		printf("%s: %s\n", m->name, m->display);
+		print_entries(m);
+	}
+
+	return 0;
+}
+
+/*
+ * menu add <name> <description>
+ */
+int do_menu_add(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
+{
+	struct menu *m;
+	int len = 0;
+	int i;
+	char *src, *dst;
+
+	if (argc < 2)
+		return -1;
+
+	m = menu_alloc();
+
+	if (!m)
+		return -1;
+
+	len = strlen(argv[1]) + 1;
+
+	m->name = calloc(len, sizeof(char));;
+	if (!m->name)
+		goto free;
+
+	strncpy(m->name, argv[1], len);
+
+	len = 0;
+
+	for (i = 2; i < argc; i++) {
+		len += strlen(argv[i]) + 1;
+	}
+
+	m->display = calloc(len, sizeof(char));
+
+	if (!m->display)
+		goto free;
+
+	dst = m->display;
+
+	for (i = 2; i < argc; i++) {
+		src = argv[i];
+
+		while ((*dst = *src) != '\0') {
+			dst++;
+			src++;
+		}
+		*dst = (i == (argc - 1)) ? '\0' : ' ';
+		dst++;
+	}
+
+	if (menu_add(m)) {
+		fprintf(stderr, "Menu %s add fail\n", m->name);
+		goto free;
+	}
+
+	return 0;
+free:
+	menu_free(m);
+	return -1;
+}
+#endif /* CONFIG_CMD_MENU_MANAGEMENT */
+
+/*
+ * menu show [menu]
+ */
+int do_menu_show(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
+{
+	struct menu *m;
+
+	if (argc > 1)
+		m = menu_get_by_name(argv[1]);
+	else
+		m = menu_get_by_name("boot");
+
+	if (!m)
+		return -1;
+
+	return menu_show(m);
+}
+
+/*
+ * menu list
+ */
+int do_menu_list(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
+{
+	struct list_head *pos;
+	struct menu* m;
+
+	list_for_each(pos, &(menus.list)) {
+		m = list_entry(pos, struct menu, list);
+		printf("%s: %s\n", m->name, m->display);
+	}
+
+	return 0;
+}
+
+#if defined(CONFIG_CMD_MENU_MANAGEMENT)
+int do_menu_entry(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
+{
+	/* Strip off leading 'entry' command argument */
+	argc--;
+	argv++;
+
+	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;
+}
+#endif /* CONFIG_CMD_MENU_MANAGEMENT */
+
+int do_menu(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
+{
+	/* Strip off leading 'menu' command argument */
+	argc--;
+	argv++;
+
+#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);
+	return 0;
+}
+
+U_BOOT_CMD(
+	menu,	CONFIG_SYS_MAXARGS,	1,	do_menu,
+	"menu",
+	"list\n"
+	"menu show [menu]\n"
+#if defined(CONFIG_CMD_MENU_MANAGEMENT)
+	"menu add <name> <description>\n"
+	"menu entry list [menu]\n"
+	"menu entry add <menu> <command> <selected> <description>\n"
+#endif
+);
diff --git a/include/config_cmd_all.h b/include/config_cmd_all.h
index c747b4b..b99a13f 100644
--- a/include/config_cmd_all.h
+++ b/include/config_cmd_all.h
@@ -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*/
diff --git a/include/console.h b/include/console.h
index bc8b139..23c1b0c 100644
--- a/include/console.h
+++ b/include/console.h
@@ -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
diff --git a/include/menu.h b/include/menu.h
new file mode 100644
index 0000000..33b88e0
--- /dev/null
+++ b/include/menu.h
@@ -0,0 +1,85 @@
+/*
+ * (C) Copyright 2009 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
+ *
+ * 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
+ */
+
+#ifndef __MENU_H__
+#define __MENU_H__
+
+#include <linux/list.h>
+#include <malloc.h>
+
+struct menu;
+
+struct menu_entry {
+	int num;
+	char *display;
+	int (*fn)(struct menu *m, struct menu_entry *me);
+
+	struct list_head list;
+	void *priv;
+};
+
+struct menu {
+	char *name;
+	char *display;
+
+	struct list_head list;
+	struct menu_entry entries;
+	int nb_entries;
+	struct menu_entry *selected;
+	void *priv;
+};
+
+/*
+ * menu functions
+ */
+static inline struct menu* menu_alloc(void)
+{
+	return calloc(1, sizeof(struct menu));
+}
+
+
+int menu_init(void);
+void menu_free(struct menu *m);
+int menu_add(struct menu* m);
+struct menu* menu_get_by_name(char *name);
+int menu_show(struct menu *m);
+int menu_set_selected_entry(struct menu *m, struct menu_entry* me);
+int menu_set_selected(struct menu *m, int num);
+
+/*
+ * menu entry functions
+ */
+static inline struct menu_entry* menu_entry_alloc(void)
+{
+	return calloc(1, sizeof(struct menu_entry));
+}
+void menu_entry_free(struct menu_entry *me);
+int menu_add_entry(struct menu *m, struct menu_entry* me);
+struct menu_entry* menu_entry_get_by_num(struct menu* m, int num);
+
+/*
+ * menu entry action functions
+ */
+int menu_action_run(struct menu *m, struct menu_entry *me);
+int menu_action_exit(struct menu *m, struct menu_entry *me);
+
+#endif /* __MENU_H__ */
-- 
1.6.3.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [U-Boot] [RFC/PATCH 1/2] r2dplus: add menu example support
  2009-06-13 19:13 ` [U-Boot] [RFC/PATCH 1/2] Add menu Framework Jean-Christophe PLAGNIOL-VILLARD
@ 2009-06-13 19:13   ` Jean-Christophe PLAGNIOL-VILLARD
  2009-06-13 23:15     ` Wolfgang Denk
  2009-06-13 23:14   ` [U-Boot] [RFC/PATCH 1/2] Add menu Framework Wolfgang Denk
  2009-06-15  6:04   ` Mike Frysinger
  2 siblings, 1 reply; 28+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2009-06-13 19:13 UTC (permalink / raw)
  To: u-boot

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

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 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

diff --git a/board/renesas/r2dplus/Makefile b/board/renesas/r2dplus/Makefile
index e96a8aa..5fbaeb9 100644
--- a/board/renesas/r2dplus/Makefile
+++ b/board/renesas/r2dplus/Makefile
@@ -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)
diff --git a/board/renesas/r2dplus/menu_example.c b/board/renesas/r2dplus/menu_example.c
new file mode 100644
index 0000000..6b9aa4f
--- /dev/null
+++ b/board/renesas/r2dplus/menu_example.c
@@ -0,0 +1,57 @@
+/*
+ * (C) Copyright 2009 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
+ *
+ * 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>
+
+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;
+}
+
+int menu_example_register(void)
+{
+	int i;
+
+	memset(&boot, 0, sizeof(struct menu));
+	boot.name = "boot";
+	boot.display = "Boot Menu";
+
+	menu_add(&boot);
+
+	for (i = 0; i < 5; i++) {
+		memset(&boot_entry[i], 0, sizeof(struct menu_entry));
+		boot_entry[i].display = "test";
+		boot_entry[i].fn = menu_action_example;
+		menu_add_entry(&boot, &boot_entry[i]);
+	}
+
+	return 0;
+}
diff --git a/board/renesas/r2dplus/r2dplus.c b/board/renesas/r2dplus/r2dplus.c
index 0c08d68..9877a9c 100644
--- a/board/renesas/r2dplus/r2dplus.c
+++ b/board/renesas/r2dplus/r2dplus.c
@@ -51,6 +51,9 @@ int dram_init(void)
 
 int board_late_init(void)
 {
+#ifdef CONFIG_CMD_MENU
+	menu_example_register();
+#endif
 	return 0;
 }
 
diff --git a/include/configs/r2dplus.h b/include/configs/r2dplus.h
index 6fa1eaf..f8a0744 100644
--- a/include/configs/r2dplus.h
+++ b/include/configs/r2dplus.h
@@ -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
diff --git a/lib_sh/board.c b/lib_sh/board.c
index 183110f..fb0d19d 100644
--- a/lib_sh/board.c
+++ b/lib_sh/board.c
@@ -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,
-- 
1.6.3.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [U-Boot] [RFC] Menu Frameworj
  2009-06-13 19:10 [U-Boot] [RFC] Menu Frameworj Jean-Christophe PLAGNIOL-VILLARD
  2009-06-13 19:13 ` [U-Boot] [RFC/PATCH 1/2] Add menu Framework Jean-Christophe PLAGNIOL-VILLARD
@ 2009-06-13 23:09 ` Wolfgang Denk
  2009-06-14  8:27   ` Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 1 reply; 28+ messages in thread
From: Wolfgang Denk @ 2009-06-13 23:09 UTC (permalink / raw)
  To: u-boot

Dear Jean-Christophe PLAGNIOL-VILLARD,

In message <20090613191011.GK25406@game.jcrosoft.org> you wrote:

Subject Typo: Frameworj

> 	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?

> 	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
...
> 	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

-- 
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

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [RFC/PATCH 1/2] Add menu Framework
  2009-06-13 19:13 ` [U-Boot] [RFC/PATCH 1/2] Add menu Framework Jean-Christophe PLAGNIOL-VILLARD
  2009-06-13 19:13   ` [U-Boot] [RFC/PATCH 1/2] r2dplus: add menu example support Jean-Christophe PLAGNIOL-VILLARD
@ 2009-06-13 23:14   ` Wolfgang Denk
  2009-06-15 13:04     ` Jean-Christophe PLAGNIOL-VILLARD
  2009-06-15  6:04   ` Mike Frysinger
  2 siblings, 1 reply; 28+ messages in thread
From: Wolfgang Denk @ 2009-06-13 23:14 UTC (permalink / raw)
  To: u-boot

Dear Jean-Christophe PLAGNIOL-VILLARD,

In message <1244920382-21434-1-git-send-email-plagnioj@jcrosoft.com> 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
> 
> 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.
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

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

> +		while ((*dst = *src) != '\0') {
> +			dst++;
> +			src++;
> +		}
> +		*dst = (i == (argc - 1)) ? '\0' : ' ';
> +		dst++;

This code repeats. Please factor out.

> +	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;
...
> +#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

-- 
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

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [RFC/PATCH 1/2] r2dplus: add menu example support
  2009-06-13 19:13   ` [U-Boot] [RFC/PATCH 1/2] r2dplus: add menu example support Jean-Christophe PLAGNIOL-VILLARD
@ 2009-06-13 23:15     ` Wolfgang Denk
  2009-06-15 13:04       ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 28+ messages in thread
From: Wolfgang Denk @ 2009-06-13 23:15 UTC (permalink / raw)
  To: u-boot

Dear Jean-Christophe PLAGNIOL-VILLARD,

In message <1244920382-21434-2-git-send-email-plagnioj@jcrosoft.com> 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
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
>  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
> 
> diff --git a/board/renesas/r2dplus/Makefile b/board/renesas/r2dplus/Makefile
> index e96a8aa..5fbaeb9 100644
> --- a/board/renesas/r2dplus/Makefile
> +++ b/board/renesas/r2dplus/Makefile
> @@ -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)
> diff --git a/board/renesas/r2dplus/menu_example.c b/board/renesas/r2dplus/menu_example.c
> new file mode 100644
> index 0000000..6b9aa4f
> --- /dev/null
> +++ b/board/renesas/r2dplus/menu_example.c
> @@ -0,0 +1,57 @@
> +/*
> + * (C) Copyright 2009 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> + *
> + * 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>
> +
> +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

-- 
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

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [RFC] Menu Frameworj
  2009-06-13 23:09 ` [U-Boot] [RFC] Menu Frameworj Wolfgang Denk
@ 2009-06-14  8:27   ` Jean-Christophe PLAGNIOL-VILLARD
  2009-06-14  8:51     ` Wolfgang Denk
  0 siblings, 1 reply; 28+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2009-06-14  8:27 UTC (permalink / raw)
  To: u-boot

On 01:09 Sun 14 Jun     , Wolfgang Denk wrote:
> Dear Jean-Christophe PLAGNIOL-VILLARD,
> 
> In message <20090613191011.GK25406@game.jcrosoft.org> you wrote:
> 
> Subject Typo: Frameworj
> 
> > 	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?
> 
> > 	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
> ...
> > 	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.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [RFC] Menu Frameworj
  2009-06-14  8:27   ` Jean-Christophe PLAGNIOL-VILLARD
@ 2009-06-14  8:51     ` Wolfgang Denk
  2009-06-14  9:22       ` Jean-Christophe PLAGNIOL-VILLARD
  2009-06-14  9:24       ` Mike Frysinger
  0 siblings, 2 replies; 28+ messages in thread
From: Wolfgang Denk @ 2009-06-14  8:51 UTC (permalink / raw)
  To: u-boot

Dear Jean-Christophe PLAGNIOL-VILLARD,

In message <20090614082707.GA22856@game.jcrosoft.org> you wrote:
>
> > 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 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

-- 
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

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [RFC] Menu Frameworj
  2009-06-14  8:51     ` Wolfgang Denk
@ 2009-06-14  9:22       ` Jean-Christophe PLAGNIOL-VILLARD
  2009-06-14 10:22         ` Wolfgang Denk
  2009-06-14  9:24       ` Mike Frysinger
  1 sibling, 1 reply; 28+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2009-06-14  9:22 UTC (permalink / raw)
  To: u-boot

On 10:51 Sun 14 Jun     , Wolfgang Denk wrote:
> Dear Jean-Christophe PLAGNIOL-VILLARD,
> 
> In message <20090614082707.GA22856@game.jcrosoft.org> you wrote:
> >
> > > 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
> 
> > 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.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [RFC] Menu Frameworj
  2009-06-14  9:24       ` Mike Frysinger
@ 2009-06-14  9:24         ` Jean-Christophe PLAGNIOL-VILLARD
  2009-06-14 10:26           ` Wolfgang Denk
  2009-06-14 11:15           ` Mike Frysinger
  0 siblings, 2 replies; 28+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2009-06-14  9:24 UTC (permalink / raw)
  To: u-boot

On 05:24 Sun 14 Jun     , Mike Frysinger wrote:
> On Sunday 14 June 2009 04:51:52 Wolfgang Denk wrote:
> > Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > 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 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
what tell you this one does not?

This one does see real world too for sometimes

Best Regards,
J.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [RFC] Menu Frameworj
  2009-06-14  8:51     ` Wolfgang Denk
  2009-06-14  9:22       ` Jean-Christophe PLAGNIOL-VILLARD
@ 2009-06-14  9:24       ` Mike Frysinger
  2009-06-14  9:24         ` Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 1 reply; 28+ messages in thread
From: Mike Frysinger @ 2009-06-14  9:24 UTC (permalink / raw)
  To: u-boot

On Sunday 14 June 2009 04:51:52 Wolfgang Denk wrote:
> Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > 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 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 

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [RFC] Menu Frameworj
  2009-06-14  9:22       ` Jean-Christophe PLAGNIOL-VILLARD
@ 2009-06-14 10:22         ` Wolfgang Denk
  2009-06-14 10:29           ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 28+ messages in thread
From: Wolfgang Denk @ 2009-06-14 10:22 UTC (permalink / raw)
  To: u-boot

Dear Jean-Christophe PLAGNIOL-VILLARD,

In message <20090614092233.GE22856@game.jcrosoft.org> you wrote:
>
> > > > 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.

> > 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.

> 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

-- 
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.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [RFC] Menu Frameworj
  2009-06-14  9:24         ` Jean-Christophe PLAGNIOL-VILLARD
@ 2009-06-14 10:26           ` Wolfgang Denk
  2009-06-14 10:35             ` Jean-Christophe PLAGNIOL-VILLARD
  2009-06-14 11:15           ` Mike Frysinger
  1 sibling, 1 reply; 28+ messages in thread
From: Wolfgang Denk @ 2009-06-14 10:26 UTC (permalink / raw)
  To: u-boot

Dear Jean-Christophe PLAGNIOL-VILLARD,

In message <20090614092402.GF22856@game.jcrosoft.org> you wrote:
>
> > > 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.

> 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

-- 
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

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [RFC] Menu Frameworj
  2009-06-14 10:22         ` Wolfgang Denk
@ 2009-06-14 10:29           ` Jean-Christophe PLAGNIOL-VILLARD
  2009-06-14 10:44             ` Wolfgang Denk
  0 siblings, 1 reply; 28+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2009-06-14 10:29 UTC (permalink / raw)
  To: u-boot

On 12:22 Sun 14 Jun     , Wolfgang Denk wrote:
> Dear Jean-Christophe PLAGNIOL-VILLARD,
> 
> In message <20090614092233.GE22856@game.jcrosoft.org> you wrote:
> >
> > > > > 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.

> 
> > > 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.
I do not as I'm not pay to merge them stuff
> 
> > 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
> 
> 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.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [RFC] Menu Frameworj
  2009-06-14 10:26           ` Wolfgang Denk
@ 2009-06-14 10:35             ` Jean-Christophe PLAGNIOL-VILLARD
  2009-06-14 10:46               ` Wolfgang Denk
  0 siblings, 1 reply; 28+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2009-06-14 10:35 UTC (permalink / raw)
  To: u-boot

On 12:26 Sun 14 Jun     , Wolfgang Denk wrote:
> Dear Jean-Christophe PLAGNIOL-VILLARD,
> 
> In message <20090614092402.GF22856@game.jcrosoft.org> you wrote:
> >
> > > > 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.
> 
> > 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.
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.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [RFC] Menu Frameworj
  2009-06-14 10:29           ` Jean-Christophe PLAGNIOL-VILLARD
@ 2009-06-14 10:44             ` Wolfgang Denk
  2009-06-14 11:00               ` Jean-Christophe PLAGNIOL-VILLARD
  2009-06-14 15:05               ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 2 replies; 28+ messages in thread
From: Wolfgang Denk @ 2009-06-14 10:44 UTC (permalink / raw)
  To: u-boot

Dear Jean-Christophe PLAGNIOL-VILLARD,

In message <20090614102930.GA22102@game.jcrosoft.org> you wrote:
>
> > > 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.

> > 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).

> > 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

-- 
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.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [RFC] Menu Frameworj
  2009-06-14 10:35             ` Jean-Christophe PLAGNIOL-VILLARD
@ 2009-06-14 10:46               ` Wolfgang Denk
  0 siblings, 0 replies; 28+ messages in thread
From: Wolfgang Denk @ 2009-06-14 10:46 UTC (permalink / raw)
  To: u-boot

Dear Jean-Christophe PLAGNIOL-VILLARD,

In message <20090614103542.GB22102@game.jcrosoft.org> you wrote:
>
> > 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.

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

-- 
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_

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [RFC] Menu Frameworj
  2009-06-14 10:44             ` Wolfgang Denk
@ 2009-06-14 11:00               ` Jean-Christophe PLAGNIOL-VILLARD
  2009-06-14 15:05               ` Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 0 replies; 28+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2009-06-14 11:00 UTC (permalink / raw)
  To: u-boot

On 12:44 Sun 14 Jun     , Wolfgang Denk wrote:
> Dear Jean-Christophe PLAGNIOL-VILLARD,
> 
> In message <20090614102930.GA22102@game.jcrosoft.org> you wrote:
> >
> > > > 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.
> 
> > > 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).
you choice to refuse it, you are interrested in the openmoko stuff where I'm
not.
> 
> > > 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?
> 
> 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,

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [RFC] Menu Frameworj
  2009-06-14  9:24         ` Jean-Christophe PLAGNIOL-VILLARD
  2009-06-14 10:26           ` Wolfgang Denk
@ 2009-06-14 11:15           ` Mike Frysinger
  2009-06-14 11:20             ` Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 1 reply; 28+ messages in thread
From: Mike Frysinger @ 2009-06-14 11:15 UTC (permalink / raw)
  To: u-boot

On Sunday 14 June 2009 05:24:02 Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 05:24 Sun 14 Jun     , Mike Frysinger wrote:
> > On Sunday 14 June 2009 04:51:52 Wolfgang Denk wrote:
> > > Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > > 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 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
>
> 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 

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [RFC] Menu Frameworj
  2009-06-14 11:15           ` Mike Frysinger
@ 2009-06-14 11:20             ` Jean-Christophe PLAGNIOL-VILLARD
  2009-06-14 11:49               ` Mike Frysinger
  0 siblings, 1 reply; 28+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2009-06-14 11:20 UTC (permalink / raw)
  To: u-boot

On 07:15 Sun 14 Jun     , Mike Frysinger wrote:
> On Sunday 14 June 2009 05:24:02 Jean-Christophe PLAGNIOL-VILLARD wrote:
> > On 05:24 Sun 14 Jun     , Mike Frysinger wrote:
> > > On Sunday 14 June 2009 04:51:52 Wolfgang Denk wrote:
> > > > Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > > > 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 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
> >
> > 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.
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.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [RFC] Menu Frameworj
  2009-06-14 11:20             ` Jean-Christophe PLAGNIOL-VILLARD
@ 2009-06-14 11:49               ` Mike Frysinger
  0 siblings, 0 replies; 28+ messages in thread
From: Mike Frysinger @ 2009-06-14 11:49 UTC (permalink / raw)
  To: u-boot

On Sunday 14 June 2009 07:20:47 Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 07:15 Sun 14 Jun     , Mike Frysinger wrote:
> > 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

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [RFC] Menu Frameworj
  2009-06-14 10:44             ` Wolfgang Denk
  2009-06-14 11:00               ` Jean-Christophe PLAGNIOL-VILLARD
@ 2009-06-14 15:05               ` Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 0 replies; 28+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2009-06-14 15:05 UTC (permalink / raw)
  To: u-boot

On 12:44 Sun 14 Jun     , Wolfgang Denk wrote:
> Dear Jean-Christophe PLAGNIOL-VILLARD,
> 
> In message <20090614102930.GA22102@game.jcrosoft.org> you wrote:
> >
> > > > 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.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [RFC/PATCH 1/2] Add menu Framework
  2009-06-13 19:13 ` [U-Boot] [RFC/PATCH 1/2] Add menu Framework Jean-Christophe PLAGNIOL-VILLARD
  2009-06-13 19:13   ` [U-Boot] [RFC/PATCH 1/2] r2dplus: add menu example support Jean-Christophe PLAGNIOL-VILLARD
  2009-06-13 23:14   ` [U-Boot] [RFC/PATCH 1/2] Add menu Framework Wolfgang Denk
@ 2009-06-15  6:04   ` Mike Frysinger
  2009-06-15  8:16     ` Jean-Christophe PLAGNIOL-VILLARD
  2 siblings, 1 reply; 28+ messages in thread
From: Mike Frysinger @ 2009-06-15  6:04 UTC (permalink / raw)
  To: u-boot

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
>
> 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 ?

> +	INIT_LIST_HEAD(&(menus.list));

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

> +	if (m->name)
> +		free(m->name);
> +	if (m->display)
> +		free(m->display);

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

> +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 ?

> +		if(strcmp(m->name, name) == 0)

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

> +	do {
> +		ch = getc();
> +		switch(ch) {
> +		case 0x1b:
> +			escape = 1;
> +			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.

> +int menu_action_exit(struct menu *m, struct menu_entry *me)
> +{
> +	return 0;
> +}

what's the point ?

> --- a/include/console.h
> +++ b/include/console.h
> +#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 

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [RFC/PATCH 1/2] Add menu Framework
  2009-06-15  6:04   ` Mike Frysinger
@ 2009-06-15  8:16     ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 28+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2009-06-15  8:16 UTC (permalink / raw)
  To: u-boot

On 02:04 Mon 15 Jun     , Mike Frysinger wrote:
> 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
> >
> > 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
> 
> 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
> 
> > +	INIT_LIST_HEAD(&(menus.list));
> 
> you use &(...) in a lot of places where the parenthesis are unnecessary
> 
> > +	if (m->name)
> > +		free(m->name);
> > +	if (m->display)
> > +		free(m->display);
> 
> free(NULL) works fine, so the if() is unnecessary
ok
> 
> > +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
> 
> > +		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
> 
> > +	do {
> > +		ch = getc();
> > +		switch(ch) {
> > +		case 0x1b:
> > +			escape = 1;
> > +			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.
will take a look
> 
> > +int menu_action_exit(struct menu *m, struct menu_entry *me)
> > +{
> > +	return 0;
> > +}
> 
> what's the point ?
just exit the menu with a prompt
> 
> > --- a/include/console.h
> > +++ b/include/console.h
> > +#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.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [RFC/PATCH 1/2] r2dplus: add menu example support
  2009-06-13 23:15     ` Wolfgang Denk
@ 2009-06-15 13:04       ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 28+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2009-06-15 13:04 UTC (permalink / raw)
  To: u-boot

On 01:15 Sun 14 Jun     , Wolfgang Denk wrote:
> Dear Jean-Christophe PLAGNIOL-VILLARD,
> 
> In message <1244920382-21434-2-git-send-email-plagnioj@jcrosoft.com> 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.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [RFC/PATCH 1/2] Add menu Framework
  2009-06-13 23:14   ` [U-Boot] [RFC/PATCH 1/2] Add menu Framework Wolfgang Denk
@ 2009-06-15 13:04     ` Jean-Christophe PLAGNIOL-VILLARD
  2009-06-16 10:54       ` Detlev Zundel
  0 siblings, 1 reply; 28+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2009-06-15 13:04 UTC (permalink / raw)
  To: u-boot

> > +#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.
ok which one?

Best Regards,
J.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [RFC/PATCH 1/2] Add menu Framework
  2009-06-15 13:04     ` Jean-Christophe PLAGNIOL-VILLARD
@ 2009-06-16 10:54       ` Detlev Zundel
  2009-06-16 15:17         ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 28+ messages in thread
From: Detlev Zundel @ 2009-06-16 10:54 UTC (permalink / raw)
  To: u-boot

Hi Jean-Christophe,

>> > +#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.
> ok which one?

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

Cheers
  Detlev

-- 
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

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [RFC/PATCH 1/2] Add menu Framework
  2009-06-16 10:54       ` Detlev Zundel
@ 2009-06-16 15:17         ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 28+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2009-06-16 15:17 UTC (permalink / raw)
  To: u-boot

On 12:54 Tue 16 Jun     , Detlev Zundel wrote:
> Hi Jean-Christophe,
> 
> >> > +#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.
> > 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.

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2009-06-16 15:17 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-13 19:10 [U-Boot] [RFC] Menu Frameworj Jean-Christophe PLAGNIOL-VILLARD
2009-06-13 19:13 ` [U-Boot] [RFC/PATCH 1/2] Add menu Framework Jean-Christophe PLAGNIOL-VILLARD
2009-06-13 19:13   ` [U-Boot] [RFC/PATCH 1/2] r2dplus: add menu example support Jean-Christophe PLAGNIOL-VILLARD
2009-06-13 23:15     ` Wolfgang Denk
2009-06-15 13:04       ` Jean-Christophe PLAGNIOL-VILLARD
2009-06-13 23:14   ` [U-Boot] [RFC/PATCH 1/2] Add menu Framework Wolfgang Denk
2009-06-15 13:04     ` Jean-Christophe PLAGNIOL-VILLARD
2009-06-16 10:54       ` Detlev Zundel
2009-06-16 15:17         ` Jean-Christophe PLAGNIOL-VILLARD
2009-06-15  6:04   ` Mike Frysinger
2009-06-15  8:16     ` Jean-Christophe PLAGNIOL-VILLARD
2009-06-13 23:09 ` [U-Boot] [RFC] Menu Frameworj Wolfgang Denk
2009-06-14  8:27   ` Jean-Christophe PLAGNIOL-VILLARD
2009-06-14  8:51     ` Wolfgang Denk
2009-06-14  9:22       ` Jean-Christophe PLAGNIOL-VILLARD
2009-06-14 10:22         ` Wolfgang Denk
2009-06-14 10:29           ` Jean-Christophe PLAGNIOL-VILLARD
2009-06-14 10:44             ` Wolfgang Denk
2009-06-14 11:00               ` Jean-Christophe PLAGNIOL-VILLARD
2009-06-14 15:05               ` Jean-Christophe PLAGNIOL-VILLARD
2009-06-14  9:24       ` Mike Frysinger
2009-06-14  9:24         ` Jean-Christophe PLAGNIOL-VILLARD
2009-06-14 10:26           ` Wolfgang Denk
2009-06-14 10:35             ` Jean-Christophe PLAGNIOL-VILLARD
2009-06-14 10:46               ` Wolfgang Denk
2009-06-14 11:15           ` Mike Frysinger
2009-06-14 11:20             ` Jean-Christophe PLAGNIOL-VILLARD
2009-06-14 11:49               ` Mike Frysinger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.