[U-Boot] [PATCH 2/3] samsung: misc: add gpt restore option to lcd menu

Przemyslaw Marczak p.marczak at samsung.com
Fri Feb 28 15:30:41 CET 2014


Function cmd_process() runs commands with directly given list
of arguments but it doesn't expand given macros. Command gpt
expects expanded macro e.g. $partitions as an argument so it
needs to be called with function run_command().

Changes:
- extend array mode_name by lower case commands names - used by find_cmd()
- put each command arguments into one string - used by run_command()
- use run_command() instead of cmd_process()

Change-Id: I2749d0b3661e2430bedd215d4024f5ae68f358db
Signed-off-by: Przemyslaw Marczak <p.marczak at samsung.com>
cc: Minkyu Kang <mk7.kang at samsung.com>
---
 board/samsung/common/misc.c |   52 +++++++++++++++++++++----------------------
 include/samsung/misc.h      |    1 +
 2 files changed, 26 insertions(+), 27 deletions(-)

diff --git a/board/samsung/common/misc.c b/board/samsung/common/misc.c
index 1d6f4e4..c66d262 100644
--- a/board/samsung/common/misc.c
+++ b/board/samsung/common/misc.c
@@ -115,12 +115,13 @@ int check_keys(void)
  * 4 BOOT_MODE_EXIT
  */
 static char *
-mode_name[BOOT_MODE_EXIT + 1] = {
-	"DEVICE",
-	"THOR",
-	"UMS",
-	"DFU",
-	"EXIT"
+mode_name[BOOT_MODE_EXIT + 1][2] = {
+	{"DEVICE", ""},
+	{"THOR", "thor"},
+	{"UMS", "ums"},
+	{"DFU", "dfu"},
+	{"GPT", "gpt"},
+	{"EXIT", ""},
 };
 
 static char *
@@ -129,18 +130,18 @@ mode_info[BOOT_MODE_EXIT + 1] = {
 	"downloader",
 	"mass storage",
 	"firmware update",
+	"restore",
 	"and run normal boot"
 };
 
-#define MODE_CMD_ARGC	4
-
 static char *
-mode_cmd[BOOT_MODE_EXIT + 1][MODE_CMD_ARGC] = {
-	{"", "", "", ""},
-	{"thor", "0", "mmc", "0"},
-	{"ums", "0", "mmc", "0"},
-	{"dfu", "0", "mmc", "0"},
-	{"", "", "", ""},
+mode_cmd[BOOT_MODE_EXIT + 1] = {
+	"",
+	"thor 0 mmc 0",
+	"ums 0 mmc 0",
+	"dfu 0 mmc 0",
+	"gpt write mmc 0 $partitions",
+	"",
 };
 
 static void display_board_info(void)
@@ -181,11 +182,10 @@ static void display_board_info(void)
 static int mode_leave_menu(int mode)
 {
 	char *exit_option;
-	char *exit_boot = "boot";
+	char *exit_reset = "reset";
 	char *exit_back = "back";
 	cmd_tbl_t *cmd;
 	int cmd_result;
-	int cmd_repeatable;
 	int leave;
 
 	lcd_clear();
@@ -199,31 +199,29 @@ static int mode_leave_menu(int mode)
 		leave = 0;
 		break;
 	default:
-		cmd = find_cmd(mode_cmd[mode][0]);
+		cmd = find_cmd(mode_name[mode][1]);
 		if (cmd) {
-			printf("Enter: %s %s\n", mode_name[mode],
+			printf("Enter: %s %s\n", mode_name[mode][0],
 						 mode_info[mode]);
-			lcd_printf("\n\n\t%s %s\n", mode_name[mode],
+			lcd_printf("\n\n\t%s %s\n", mode_name[mode][0],
 						    mode_info[mode]);
 			lcd_puts("\n\tDo not turn off device before finish!\n");
 
-			cmd_result = cmd_process(0, MODE_CMD_ARGC,
-						 *(mode_cmd + mode),
-						 &cmd_repeatable, NULL);
+			cmd_result = run_command(mode_cmd[mode], 0);
 
 			if (cmd_result == CMD_RET_SUCCESS) {
 				printf("Command finished\n");
 				lcd_clear();
 				lcd_printf("\n\n\t%s finished\n",
-					   mode_name[mode]);
+					   mode_name[mode][0]);
 
-				exit_option = exit_boot;
+				exit_option = exit_reset;
 				leave = 1;
 			} else {
 				printf("Command error\n");
 				lcd_clear();
 				lcd_printf("\n\n\t%s command error\n",
-					   mode_name[mode]);
+					   mode_name[mode][0]);
 
 				exit_option = exit_back;
 				leave = 0;
@@ -263,7 +261,7 @@ static void display_download_menu(int mode)
 
 	for (i = 0; i <= BOOT_MODE_EXIT; i++)
 		lcd_printf("\t%s  %s - %s\n\n", selection[i],
-						mode_name[i],
+						mode_name[i][0],
 						mode_info[i]);
 }
 
@@ -304,7 +302,7 @@ static void download_menu(void)
 
 		if (run) {
 			if (mode_leave_menu(mode))
-				break;
+				run_command("reset", 0);
 
 			display_download_menu(mode);
 		}
diff --git a/include/samsung/misc.h b/include/samsung/misc.h
index 47beb1f..ac0fc0b 100644
--- a/include/samsung/misc.h
+++ b/include/samsung/misc.h
@@ -17,6 +17,7 @@ enum {
 	BOOT_MODE_THOR,
 	BOOT_MODE_UMS,
 	BOOT_MODE_DFU,
+	BOOT_MODE_GPT,
 	BOOT_MODE_EXIT,
 };
 
-- 
1.7.9.5



More information about the U-Boot mailing list