[PATCH 05/12] go command: shutdown barebox before calling an application
Sascha Hauer
s.hauer at pengutronix.de
Tue Mar 30 07:06:48 EDT 2010
Also, do not allow to continue barebox after returning from the
application since we don't know anything about the state we are in.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
commands/go.c | 19 ++++++++++++-------
1 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/commands/go.c b/commands/go.c
index 588d6fc..0262940 100644
--- a/commands/go.c
+++ b/commands/go.c
@@ -35,6 +35,7 @@ static int do_go(struct command *cmdtp, int argc, char *argv[])
void *addr;
int rcode = 1;
int fd = -1;
+ int (*func)(int argc, char *argv[]);
if (argc < 2)
return COMMAND_ERROR_USAGE;
@@ -54,17 +55,21 @@ static int do_go(struct command *cmdtp, int argc, char *argv[])
} else
addr = (void *)simple_strtoul(argv[1], NULL, 16);
- printf ("## Starting application at 0x%08lX ...\n", addr);
+ printf("## Starting application at 0x%08lX ...\n", addr);
console_flush();
-#ifdef ARCH_HAS_EXECUTE
- rcode = arch_execute(addr, argc, &argv[1]);
-#else
- rcode = ((ulong (*)(int, char *[]))addr) (--argc, &argv[1]);
-#endif
+ func = addr;
- printf ("## Application terminated, rcode = 0x%lX\n", rcode);
+ shutdown_barebox();
+ func(argc - 1, &argv[1]);
+
+ /*
+ * The application returned. Since we have shutdown barebox and
+ * we know nothing about the state of the cpu/memory we can't
+ * do anything here.
+ */
+ while (1);
out:
if (fd > 0)
close(fd);
--
1.7.0
More information about the barebox
mailing list