[U-Boot] [RFC/PATCH 1/2] r2dplus: add menu example support
Jean-Christophe PLAGNIOL-VILLARD
plagnioj at jcrosoft.com
Sat Jun 13 21:13:02 CEST 2009
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 at 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 at 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
More information about the U-Boot
mailing list