Skip to contentSkip to conversation

common, menu: enhancements

PATCH Superseded Heiko Schocher 4 participants 19 messages Jan 15, 2012 – Feb 17, 2012

lore
Share & tools
lore
#0 lore raw

cover common, menu: enhancements

- add possibility to read a line with defining a timeout
- add possibility to define a statusline in the menu, which is printed for every menu
- show menu instead starting the u-boot shell

Heiko Schocher (3):
common: add possibility for readline_into_buffer timeout common, menu: add statusline support
common, menu: show menu on startup if CONFIG_MENU_SHOW is defined

 common/cmd_nvedit.c |    2 +-
 common/main.c       |   25 +++++++++++++++++++++----
 common/menu.c       |   11 ++++++++++-
 doc/README.menu     |    5 +++++
 include/common.h    |    3 ++-
 include/menu.h      |    3 +++
 6 files changed, 42 insertions(+), 7 deletions(-)

---
- This patchserie is needed for the cam_enc_4xx menu update patch (send soon)
- checkpatch shows no error/warnings

Signature · 1 line
1.7.7.4
#1 lore raw

PATCH 1/3 common: add possibility for readline_into_buffer timeout

add possibility to add a timeout when reading a line into a buffer.

---
 common/cmd_nvedit.c |    2 +-
 common/main.c       |   21 +++++++++++++++++----
 common/menu.c       |    3 ++-
 include/common.h    |    3 ++-
 4 files changed, 22 insertions(+), 7 deletions(-)
common/cmd_nvedit.c +1 -1
index 63afc82..20080dc 100644
@@ -502,7 +502,7 @@ int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	else
 		buffer[0] = '\0';
 
-	readline_into_buffer("edit: ", buffer);
+	readline_into_buffer("edit: ", buffer, 0);
 
 	return setenv(argv[1], buffer);
 }
common/main.c +17 -4
index e96c95a..08070f3 100644
@@ -685,7 +685,8 @@ static void cread_add_str(char *str, int strsize, int insert, unsigned long *num
 	}
 }
 
-static int cread_line(const char *const prompt, char *buf, unsigned int *len)
+static int cread_line(const char *const prompt, char *buf, unsigned int *len,
+		int timeout)
 {
 	unsigned long num = 0;
 	unsigned long eol_num = 0;
@@ -695,6 +696,7 @@ static int cread_line(const char *const prompt, char *buf, unsigned int *len)
 	int esc_len = 0;
 	char esc_save[8];
 	int init_len = strlen(buf);
+	int first = 1;
 
 	if (init_len)
 		cread_add_str(buf, init_len, 1, &num, &eol_num, buf, *len);
@@ -707,6 +709,17 @@ static int cread_line(const char *const prompt, char *buf, unsigned int *len)
 			WATCHDOG_RESET();
 		}
 #endif
+		if ((first) && (timeout)) {
+			ulong start = get_timer(0);
+			ulong delay = timeout * CONFIG_SYS_HZ;
+
+			while (!tstc()) {	/* while no incoming data */
+				if (get_timer(start) > delay)
+					return -2;	/* timed out */
+				WATCHDOG_RESET();
+			}
+			first = 0;
+		}
 
 		ichar = getcmd_getch();
 
@@ -922,11 +935,11 @@ int readline (const char *const prompt)
 	 */
 	console_buffer[0] = '\0';
 
-	return readline_into_buffer(prompt, console_buffer);
+	return readline_into_buffer(prompt, console_buffer, 0);
 }
 
 
-int readline_into_buffer (const char *const prompt, char * buffer)
+int readline_into_buffer(const char *const prompt, char *buffer, int timeout)
 {
 	char *p = buffer;
 #ifdef CONFIG_CMDLINE_EDITING
@@ -949,7 +962,7 @@ int readline_into_buffer (const char *const prompt, char * buffer)
 		if (prompt)
 			puts (prompt);
 
-		rc = cread_line(prompt, p, &len);
+		rc = cread_line(prompt, p, &len, timeout);
 		return rc < 0 ? rc : len;
 
 	} else {
common/menu.c +2 -1
index 5e0817c..3b1e0d0 100644
@@ -222,7 +222,8 @@ static inline int menu_interactive_choice(struct menu *m, void **choice)
 
 		menu_display(m);
 
-		readret = readline_into_buffer("Enter choice: ", cbuf);
+		readret = readline_into_buffer("Enter choice: ", cbuf,
+				m->timeout);
 
 		if (readret >= 0) {
 			choice_item = menu_item_by_key(m, cbuf);
include/common.h +2 -1
index 3df1def..7a9b3a2 100644
@@ -265,7 +265,8 @@ int	run_command	(const char *cmd, int flag);
 int run_command2(const char *cmd, int flag);
 #endif
 int	readline	(const char *const prompt);
-int	readline_into_buffer	(const char *const prompt, char * buffer);
+int	readline_into_buffer(const char *const prompt, char *buffer,
+			int timeout);
 int	parse_line (char *, char *[]);
 void	init_cmd_timeout(void);
 void	reset_cmd_timeout(void);
Signature · 1 line
1.7.7.4
#2 lore raw

PATCH 1/3 common: add possibility for readline_into_buffer timeout

common/main.c

Quoted 4 lines · On Sunday 15 January 2012 02:53:40 Heiko Schocher wrote:
common/main.c +1 -0
 
+		if ((first) && (timeout)) {

those inner parens make no sense

common/main.c static int cread_line(const char *const prompt, char *buf, unsigned int *len) · line 714

Quoted 2 lines
common/main.c +2 -0
+			ulong start = get_timer(0);
+			ulong delay = timeout * CONFIG_SYS_HZ;

what do you want the timeout to be in ? milliseconds ? then make that part of the API (add comments to the relevant funcs), and drop the CONFIG_SYS_HZ usage.
-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/20120115/347da045/attachment.pgp>

#3 lore raw

PATCH 1/3 common: add possibility for readline_into_buffer timeout

Hello Mike,

Quoted 7 lines · Mike Frysinger

common/main.c

Quoted 4 lines · On Sunday 15 January 2012 02:53:40 Heiko Schocher wrote:
common/main.c +1 -0
 
+		if ((first) && (timeout)) {

those inner parens make no sense

Yep, fixed.

Quoted 4 lines

common/main.c static int cread_line(const char *const prompt, char *buf, unsigned int *len) · line 714

Quoted 2 lines
common/main.c +2 -0
+			ulong start = get_timer(0);
+			ulong delay = timeout * CONFIG_SYS_HZ;

what do you want the timeout to be in ? milliseconds ? then make that part

seconds, similiar to bootdelay.

Quoted 2 lines

of the API (add comments to the relevant funcs), and drop the CONFIG_SYS_HZ usage.

Fix this (Do it like bootdelay is done, using endticks())

Thanks for the review.

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#4 lore raw

PATCH v2 1/3 common: add possibility for readline_into_buffer timeout

In reply to Heiko Schocher

add possibility to add a timeout when reading a line into a buffer.

---
- changes for v2:
- add comments from Mike Frysinger <[email protected]>:
- remove useless inner parens
- rework timeout handling in readline_into_buffer():
use endtick(), drop CONIG_SYS_HZ usage

 common/cmd_nvedit.c |    2 +-
 common/main.c       |   20 ++++++++++++++++----
 common/menu.c       |    3 ++-
 include/common.h    |    3 ++-
 4 files changed, 21 insertions(+), 7 deletions(-)
common/cmd_nvedit.c +1 -1
index 63afc82..20080dc 100644
@@ -502,7 +502,7 @@ int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	else
 		buffer[0] = '\0';
 
-	readline_into_buffer("edit: ", buffer);
+	readline_into_buffer("edit: ", buffer, 0);
 
 	return setenv(argv[1], buffer);
 }
common/main.c +16 -4
index e96c95a..248744b 100644
@@ -685,7 +685,8 @@ static void cread_add_str(char *str, int strsize, int insert, unsigned long *num
 	}
 }
 
-static int cread_line(const char *const prompt, char *buf, unsigned int *len)
+static int cread_line(const char *const prompt, char *buf, unsigned int *len,
+		int timeout)
 {
 	unsigned long num = 0;
 	unsigned long eol_num = 0;
@@ -695,6 +696,7 @@ static int cread_line(const char *const prompt, char *buf, unsigned int *len)
 	int esc_len = 0;
 	char esc_save[8];
 	int init_len = strlen(buf);
+	int first = 1;
 
 	if (init_len)
 		cread_add_str(buf, init_len, 1, &num, &eol_num, buf, *len);
@@ -707,6 +709,16 @@ static int cread_line(const char *const prompt, char *buf, unsigned int *len)
 			WATCHDOG_RESET();
 		}
 #endif
+		if (first && timeout) {
+			uint64_t etime = endtick(timeout);
+
+			while (!tstc()) {	/* while no incoming data */
+				if (get_ticks() >= etime)
+					return -2;	/* timed out */
+				WATCHDOG_RESET();
+			}
+			first = 0;
+		}
 
 		ichar = getcmd_getch();
 
@@ -922,11 +934,11 @@ int readline (const char *const prompt)
 	 */
 	console_buffer[0] = '\0';
 
-	return readline_into_buffer(prompt, console_buffer);
+	return readline_into_buffer(prompt, console_buffer, 0);
 }
 
 
-int readline_into_buffer (const char *const prompt, char * buffer)
+int readline_into_buffer(const char *const prompt, char *buffer, int timeout)
 {
 	char *p = buffer;
 #ifdef CONFIG_CMDLINE_EDITING
@@ -949,7 +961,7 @@ int readline_into_buffer (const char *const prompt, char * buffer)
 		if (prompt)
 			puts (prompt);
 
-		rc = cread_line(prompt, p, &len);
+		rc = cread_line(prompt, p, &len, timeout);
 		return rc < 0 ? rc : len;
 
 	} else {
common/menu.c +2 -1
index 5e0817c..3b1e0d0 100644
@@ -222,7 +222,8 @@ static inline int menu_interactive_choice(struct menu *m, void **choice)
 
 		menu_display(m);
 
-		readret = readline_into_buffer("Enter choice: ", cbuf);
+		readret = readline_into_buffer("Enter choice: ", cbuf,
+				m->timeout);
 
 		if (readret >= 0) {
 			choice_item = menu_item_by_key(m, cbuf);
include/common.h +2 -1
index 3df1def..7a9b3a2 100644
@@ -265,7 +265,8 @@ int	run_command	(const char *cmd, int flag);
 int run_command2(const char *cmd, int flag);
 #endif
 int	readline	(const char *const prompt);
-int	readline_into_buffer	(const char *const prompt, char * buffer);
+int	readline_into_buffer(const char *const prompt, char *buffer,
+			int timeout);
 int	parse_line (char *, char *[]);
 void	init_cmd_timeout(void);
 void	reset_cmd_timeout(void);
Signature · 1 line
1.7.7.4
#6 lore raw

PATCH v2 1/3 common: add possibility for readline_into_buffer timeout

In reply to Heiko Schocher

Hello Heiko,

it seems there is a problem with this patch for some architectures. On Microblaze I run into linker errors:

common/libcommon.o: In function `cread_line':
u-boot-bref/common/main.c:717: undefined reference to get_ticks' u-boot-mbref/common/main.c:717: undefined reference to get_tbclk' u-boot-mbref/common/main.c:720: undefined reference to `get_ticks'

AFAICS some architectures lacking these symbols. What is the default U-Boot design line here. Should we implement the missing symbols for Microblaze or can you introduce a CONFIG_ option to disable this new feature?

br,
Stephan

Am Dienstag, den 17.01.2012, 08:13 +0100 schrieb Heiko Schocher:

Quoted 122 lines

add possibility to add a timeout when reading a line into a buffer.

---
- changes for v2:
- add comments from Mike Frysinger <[email protected]>:
- remove useless inner parens
- rework timeout handling in readline_into_buffer():
use endtick(), drop CONIG_SYS_HZ usage

 common/cmd_nvedit.c |    2 +-
 common/main.c       |   20 ++++++++++++++++----
 common/menu.c       |    3 ++-
 include/common.h    |    3 ++-
 4 files changed, 21 insertions(+), 7 deletions(-)
common/cmd_nvedit.c +1 -1
index 63afc82..20080dc 100644
@@ -502,7 +502,7 @@ int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	else
 		buffer[0] = '\0';
 
-	readline_into_buffer("edit: ", buffer);
+	readline_into_buffer("edit: ", buffer, 0);
 
 	return setenv(argv[1], buffer);
 }
common/main.c +16 -4
index e96c95a..248744b 100644
@@ -685,7 +685,8 @@ static void cread_add_str(char *str, int strsize, int insert, unsigned long *num
 	}
 }
 
-static int cread_line(const char *const prompt, char *buf, unsigned int *len)
+static int cread_line(const char *const prompt, char *buf, unsigned int *len,
+		int timeout)
 {
 	unsigned long num = 0;
 	unsigned long eol_num = 0;
@@ -695,6 +696,7 @@ static int cread_line(const char *const prompt, char *buf, unsigned int *len)
 	int esc_len = 0;
 	char esc_save[8];
 	int init_len = strlen(buf);
+	int first = 1;
 
 	if (init_len)
 		cread_add_str(buf, init_len, 1, &num, &eol_num, buf, *len);
@@ -707,6 +709,16 @@ static int cread_line(const char *const prompt, char *buf, unsigned int *len)
 			WATCHDOG_RESET();
 		}
 #endif
+		if (first && timeout) {
+			uint64_t etime = endtick(timeout);
+
+			while (!tstc()) {	/* while no incoming data */
+				if (get_ticks() >= etime)
+					return -2;	/* timed out */
+				WATCHDOG_RESET();
+			}
+			first = 0;
+		}
 
 		ichar = getcmd_getch();
 
@@ -922,11 +934,11 @@ int readline (const char *const prompt)
 	 */
 	console_buffer[0] = '\0';
 
-	return readline_into_buffer(prompt, console_buffer);
+	return readline_into_buffer(prompt, console_buffer, 0);
 }
 
 
-int readline_into_buffer (const char *const prompt, char * buffer)
+int readline_into_buffer(const char *const prompt, char *buffer, int timeout)
 {
 	char *p = buffer;
 #ifdef CONFIG_CMDLINE_EDITING
@@ -949,7 +961,7 @@ int readline_into_buffer (const char *const prompt, char * buffer)
 		if (prompt)
 			puts (prompt);
 
-		rc = cread_line(prompt, p, &len);
+		rc = cread_line(prompt, p, &len, timeout);
 		return rc < 0 ? rc : len;
 
 	} else {
common/menu.c +2 -1
index 5e0817c..3b1e0d0 100644
@@ -222,7 +222,8 @@ static inline int menu_interactive_choice(struct menu *m, void **choice)
 
 		menu_display(m);
 
-		readret = readline_into_buffer("Enter choice: ", cbuf);
+		readret = readline_into_buffer("Enter choice: ", cbuf,
+				m->timeout);
 
 		if (readret >= 0) {
 			choice_item = menu_item_by_key(m, cbuf);
include/common.h +2 -1
index 3df1def..7a9b3a2 100644
@@ -265,7 +265,8 @@ int	run_command	(const char *cmd, int flag);
 int run_command2(const char *cmd, int flag);
 #endif
 int	readline	(const char *const prompt);
-int	readline_into_buffer	(const char *const prompt, char * buffer);
+int	readline_into_buffer(const char *const prompt, char *buffer,
+			int timeout);
 int	parse_line (char *, char *[]);
 void	init_cmd_timeout(void);
 void	reset_cmd_timeout(void);
#7 lore raw

PATCH v2 1/3 common: add possibility for readline_into_buffer timeout

Quoted 1 line · On Friday 17 February 2012 16:33:32 Stephan Linz wrote:

Hello Heiko,

please don't top post

Quoted 8 lines

it seems there is a problem with this patch for some architectures. On Microblaze I run into linker errors:

common/libcommon.o: In function `cread_line':
u-boot-bref/common/main.c:717: undefined reference to get_ticks' u-boot-mbref/common/main.c:717: undefined reference to get_tbclk' u-boot-mbref/common/main.c:720: undefined reference to `get_ticks'

Quoted 4 lines

AFAICS some architectures lacking these symbols. What is the default U-Boot design line here. Should we implement the missing symbols for Microblaze or can you introduce a CONFIG_ option to disable this new feature?

to keep your sanity, you should implement get_{ticks,tbclk}. look at the Blackfin implementation ... i think you should be able to copy & paste those into your own.
-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/20120217/b1116077/attachment.pgp>

#8 lore raw

PATCH 2/3 common, menu: add statusline support

In reply to Heiko Schocher

add the possibility to show a statusline when printing a menu

---
 common/menu.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
common/menu.c +8 -0
index 3b1e0d0..754a9f9 100644
@@ -113,6 +113,13 @@ static inline void *menu_item_destroy(struct menu *m,
 	return NULL;
 }
 
+void __menu_display_statusline(struct menu *m)
+{
+	return;
+}
+void menu_display_statusline(struct menu *m)
+	__attribute__ ((weak, alias("__menu_display_statusline")));
+
 /*
  * Display a menu so the user can make a choice of an item. First display its
  * title, if any, and then each item in the menu.
@@ -123,6 +130,7 @@ static inline void menu_display(struct menu *m)
 		puts(m->title);
 		putc('\n');
 	}
+	menu_display_statusline(m);
 
 	menu_items_iter(m, menu_item_print, NULL);
 }
Signature · 1 line
1.7.7.4
#9 lore raw

PATCH 2/3 common, menu: add statusline support

Quoted 1 line · On Sunday 15 January 2012 02:53:41 Heiko Schocher wrote:

add the possibility to show a statusline when printing a menu

do you have any examples ?

Quoted 1 line

+void menu_display_statusline(struct menu *m)

a prototype needs to be in menu.h, and documented
-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/20120115/42689b88/attachment.pgp>

#10 lore raw

PATCH 2/3 common, menu: add statusline support

Hello Mike,

Quoted 4 lines · Mike Frysinger
Quoted 1 line · On Sunday 15 January 2012 02:53:41 Heiko Schocher wrote:

add the possibility to show a statusline when printing a menu

do you have any examples ?

Used in the cam_enc_4xx update patch, see:

[U-Boot] arm, davinci: cam_enc_4xx board updates
http://patchwork.ozlabs.org/patch/136165/

Quoted 3 lines
Quoted 1 line

+void menu_display_statusline(struct menu *m)

a prototype needs to be in menu.h, and documented

Fixed.

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#11 lore raw

PATCH v2 2/3 common, menu: add statusline support

In reply to Heiko Schocher

add the possibility to show a statusline when printing a menu

Cc Jason Hobbs <[email protected]>
Cc Mike Frysinger <[email protected]>

---
- changes for v2:
- add comments from Mike Frysinger <[email protected]>:
- add a prototype for the new function menu_display_statusline in menu.h and document it in doc/README.menu

 common/menu.c   |    8 ++++++++
 doc/README.menu |    5 +++++
 include/menu.h  |    1 +
 3 files changed, 14 insertions(+), 0 deletions(-)
common/menu.c +8 -0
index 3b1e0d0..754a9f9 100644
@@ -113,6 +113,13 @@ static inline void *menu_item_destroy(struct menu *m,
 	return NULL;
 }
 
+void __menu_display_statusline(struct menu *m)
+{
+	return;
+}
+void menu_display_statusline(struct menu *m)
+	__attribute__ ((weak, alias("__menu_display_statusline")));
+
 /*
  * Display a menu so the user can make a choice of an item. First display its
  * title, if any, and then each item in the menu.
@@ -123,6 +130,7 @@ static inline void menu_display(struct menu *m)
 		puts(m->title);
 		putc('\n');
 	}
+	menu_display_statusline(m);
 
 	menu_items_iter(m, menu_item_print, NULL);
 }
doc/README.menu +5 -0
index 0dad6a2..4ddf914 100644
@@ -69,6 +69,11 @@ int menu_get_choice(struct menu *m, void **choice);
  */
 int menu_destroy(struct menu *m);
 
+/*
+ * menu_display_statusline(struct menu *m);
+ * shows a statusline for every menu_display call.
+ */
+void menu_display_statusline(struct menu *m);
 
 Example Code
 ------------
include/menu.h +1 -0
index cf14a9c..b806a02 100644
@@ -26,5 +26,6 @@ int menu_default_set(struct menu *m, char *item_key);
 int menu_get_choice(struct menu *m, void **choice);
 int menu_item_add(struct menu *m, char *item_key, void *item_data);
 int menu_destroy(struct menu *m);
+void menu_display_statusline(struct menu *m);
 
 #endif /* __MENU_H__ */
Signature · 1 line
1.7.7.4
#13 lore raw

PATCH 3/3 common, menu: show menu on startup if CONFIG_MENU_SHOW is defined

In reply to Heiko Schocher

show a menu on startup instead running the shell.

---
 common/main.c   |    4 ++++
 doc/README.menu |    5 +++++
 include/menu.h  |    3 +++
 3 files changed, 12 insertions(+), 0 deletions(-)
common/main.c +4 -0
index 08070f3..2199ae7 100644
@@ -41,6 +41,7 @@
 
 #include <post.h>
 #include <linux/ctype.h>
+#include <menu.h>
 
 #if defined(CONFIG_SILENT_CONSOLE) || defined(CONFIG_POST) || defined(CONFIG_CMDLINE_EDITING)
 DECLARE_GLOBAL_DATA_PTR;
@@ -372,6 +373,9 @@ void main_loop (void)
 
 	debug ("### main_loop entered: bootdelay=%d\n\n", bootdelay);
 
+#if defined(CONFIG_MENU_SHOW)
+	bootdelay = menu_show();
+#endif
 # ifdef CONFIG_BOOT_RETRY_TIME
 	init_cmd_timeout ();
 # endif	/* CONFIG_BOOT_RETRY_TIME */
doc/README.menu +5 -0
index 0dad6a2..ba7dcad 100644
@@ -25,6 +25,11 @@ the interfaces should be available.
 Menus are composed of items. Each item has a key used to identify it in
 the menu, and an opaque pointer to data controlled by the consumer.
 
+If you want to show a menu, instead starting the shell, define
+CONFIG_MENU_SHOW. You have to code the int menu_show(void) function,
+which handle your menu. This function returns the remaining
+bootdelay.
+
 Interfaces
 ----------
 #include "menu.h"
include/menu.h +3 -0
index cf14a9c..4cda33d 100644
@@ -27,4 +27,7 @@ int menu_get_choice(struct menu *m, void **choice);
 int menu_item_add(struct menu *m, char *item_key, void *item_data);
 int menu_destroy(struct menu *m);
 
+#if defined(CONFIG_MENU_SHOW)
+int menu_show(void);
+#endif
 #endif /* __MENU_H__ */
Signature · 1 line
1.7.7.4
#14 lore raw

PATCH 3/3 common, menu: show menu on startup if CONFIG_MENU_SHOW is defined

common/main.c void main_loop (void) · line 378

Quoted 6 lines · On Sunday 15 January 2012 02:53:42 Heiko Schocher wrote:
common/main.c +3 -0
 
+#if defined(CONFIG_MENU_SHOW)
+	bootdelay = menu_show();
+#endif

should the current bootdelay get passed in ?
-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/20120115/7f752804/attachment.pgp>

#15 lore raw

PATCH 3/3 common, menu: show menu on startup if CONFIG_MENU_SHOW is defined

Hello Mike,

Quoted 9 lines · Mike Frysinger

common/main.c void main_loop (void) · line 378

Quoted 6 lines · On Sunday 15 January 2012 02:53:42 Heiko Schocher wrote:
common/main.c +3 -0
 
+#if defined(CONFIG_MENU_SHOW)
+	bootdelay = menu_show();
+#endif

should the current bootdelay get passed in ?

Yep, fixed.

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#16 lore raw

PATCH v2 3/3 common, menu: show menu on startup if CONFIG_MENU_SHOW is defined

In reply to Heiko Schocher

show a menu on startup instead running the shell.

Cc Jason Hobbs <[email protected]>
Cc Mike Frysinger <[email protected]>

---
- changes for v2:
- add comments from Mike Frysinger <[email protected]>
- pass current bootdelay to menu_show

 common/main.c   |    4 ++++
 doc/README.menu |    5 +++++
 include/menu.h  |    3 +++
 3 files changed, 12 insertions(+), 0 deletions(-)
common/main.c +4 -0
index 248744b..91e888f 100644
@@ -41,6 +41,7 @@
 
 #include <post.h>
 #include <linux/ctype.h>
+#include <menu.h>
 
 #if defined(CONFIG_SILENT_CONSOLE) || defined(CONFIG_POST) || defined(CONFIG_CMDLINE_EDITING)
 DECLARE_GLOBAL_DATA_PTR;
@@ -372,6 +373,9 @@ void main_loop (void)
 
 	debug ("### main_loop entered: bootdelay=%d\n\n", bootdelay);
 
+#if defined(CONFIG_MENU_SHOW)
+	bootdelay = menu_show(bootdelay);
+#endif
 # ifdef CONFIG_BOOT_RETRY_TIME
 	init_cmd_timeout ();
 # endif	/* CONFIG_BOOT_RETRY_TIME */
doc/README.menu +5 -0
index 4ddf914..6ce6bba 100644
@@ -25,6 +25,11 @@ the interfaces should be available.
 Menus are composed of items. Each item has a key used to identify it in
 the menu, and an opaque pointer to data controlled by the consumer.
 
+If you want to show a menu, instead starting the shell, define
+CONFIG_MENU_SHOW. You have to code the int menu_show(int bootdelay)
+function, which handle your menu. This function returns the remaining
+bootdelay.
+
 Interfaces
 ----------
 #include "menu.h"
include/menu.h +3 -0
index b806a02..7af5fdb 100644
@@ -28,4 +28,7 @@ int menu_item_add(struct menu *m, char *item_key, void *item_data);
 int menu_destroy(struct menu *m);
 void menu_display_statusline(struct menu *m);
 
+#if defined(CONFIG_MENU_SHOW)
+int menu_show(int bootdelay);
+#endif
 #endif /* __MENU_H__ */
Signature · 1 line
1.7.7.4
#17 lore raw

PATCH v2 3/3 common, menu: show menu on startup if CONFIG_MENU_SHOW is defined

Dear Heiko,

Quoted 5 lines · Heiko Schocher

show a menu on startup instead running the shell.

Cc Jason Hobbs <[email protected]>
Cc Mike Frysinger <[email protected]>

A couple of minor fixes in your README addition below, otherwise:

Quoted 10 lines

---
- changes for v2:
- add comments from Mike Frysinger <[email protected]>
- pass current bootdelay to menu_show

 common/main.c   |    4 ++++
 doc/README.menu |    5 +++++
 include/menu.h  |    3 +++
 3 files changed, 12 insertions(+), 0 deletions(-)

...

doc/README.menu the interfaces should be available. · line 28

Quoted 9 lines
doc/README.menu +1 -0
index 4ddf914..6ce6bba 100644
@@ -25,6 +25,11 @@ the interfaces should be available.
 Menus are composed of items. Each item has a key used to identify it in
 the menu, and an opaque pointer to data controlled by the consumer.
 
+If you want to show a menu, instead starting the shell, define

"instead of starting the shell"

doc/README.menu the interfaces should be available. · line 30

Quoted 2 lines
doc/README.menu +2 -0
+CONFIG_MENU_SHOW. You have to code the int menu_show(int bootdelay)
+function, which handle your menu. This function returns the remaining

"which handles"

Quoted 20 lines
doc/README.menu +2 -0
+bootdelay.
+
 Interfaces
 ----------
 #include "menu.h"
include/menu.h +3 -0
index b806a02..7af5fdb 100644
@@ -28,4 +28,7 @@ int menu_item_add(struct menu *m, char *item_key, void *item_data);
 int menu_destroy(struct menu *m);
 void menu_display_statusline(struct menu *m);
 
+#if defined(CONFIG_MENU_SHOW)
+int menu_show(int bootdelay);
+#endif
 #endif /* __MENU_H__ */
Signature · 1 line
1.7.7.4
#18 lore raw

PATCH v3 3/3 common, menu: show menu on startup if CONFIG_MENU_SHOW is defined

In reply to Heiko Schocher

show a menu on startup instead running the shell.

---
- changes for v2:
- add comments from Mike Frysinger <[email protected]>
- pass current bootdelay to menu_show
- changes for v3:
- add Acked-by: Jason Hobbs <[email protected]>
- add comment from Jason Hobbs <[email protected]>
- spelling fixes in README

---
 common/main.c   |    4 ++++
 doc/README.menu |    5 +++++
 include/menu.h  |    3 +++
 3 files changed, 12 insertions(+), 0 deletions(-)
common/main.c +4 -0
index 248744b..91e888f 100644
@@ -41,6 +41,7 @@
 
 #include <post.h>
 #include <linux/ctype.h>
+#include <menu.h>
 
 #if defined(CONFIG_SILENT_CONSOLE) || defined(CONFIG_POST) || defined(CONFIG_CMDLINE_EDITING)
 DECLARE_GLOBAL_DATA_PTR;
@@ -372,6 +373,9 @@ void main_loop (void)
 
 	debug ("### main_loop entered: bootdelay=%d\n\n", bootdelay);
 
+#if defined(CONFIG_MENU_SHOW)
+	bootdelay = menu_show(bootdelay);
+#endif
 # ifdef CONFIG_BOOT_RETRY_TIME
 	init_cmd_timeout ();
 # endif	/* CONFIG_BOOT_RETRY_TIME */
doc/README.menu +5 -0
index 4ddf914..bc33012 100644
@@ -25,6 +25,11 @@ the interfaces should be available.
 Menus are composed of items. Each item has a key used to identify it in
 the menu, and an opaque pointer to data controlled by the consumer.
 
+If you want to show a menu, instead of starting the shell, define
+CONFIG_MENU_SHOW. You have to code the int menu_show(int bootdelay)
+function, which handles your menu. This function returns the remaining
+bootdelay.
+
 Interfaces
 ----------
 #include "menu.h"
include/menu.h +3 -0
index b806a02..7af5fdb 100644
@@ -28,4 +28,7 @@ int menu_item_add(struct menu *m, char *item_key, void *item_data);
 int menu_destroy(struct menu *m);
 void menu_display_statusline(struct menu *m);
 
+#if defined(CONFIG_MENU_SHOW)
+int menu_show(int bootdelay);
+#endif
 #endif /* __MENU_H__ */
Signature · 1 line
1.7.7.4