From: Mike Frysinger <vapier@gentoo.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC/PATCH 1/2] Add menu Framework
Date: Mon, 15 Jun 2009 02:04:54 -0400 [thread overview]
Message-ID: <200906150205.07788.vapier@gentoo.org> (raw)
In-Reply-To: <1244920382-21434-1-git-send-email-plagnioj@jcrosoft.com>
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
next prev parent reply other threads:[~2009-06-15 6:04 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200906150205.07788.vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox