2 * go- execute some code anywhere (misc boot support)
4 * (C) Copyright 2000-2003
5 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
7 * See file CREDITS for list of people who contributed to this
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
30 #include <linux/ctype.h>
33 static int do_go(struct command
*cmdtp
, int argc
, char *argv
[])
38 int (*func
)(int argc
, char *argv
[]);
41 return COMMAND_ERROR_USAGE
;
43 if (!isdigit(*argv
[1])) {
44 fd
= open(argv
[1], O_RDONLY
);
50 addr
= memmap(fd
, PROT_READ
);
51 if (addr
== (void *)-1) {
56 addr
= (void *)simple_strtoul(argv
[1], NULL
, 16);
58 printf("## Starting application at 0x%08lX ...\n", addr
);
65 func(argc
- 1, &argv
[1]);
68 * The application returned. Since we have shutdown barebox and
69 * we know nothing about the state of the cpu/memory we can't
80 static const __maybe_unused
char cmd_go_help
[] =
81 "Usage: go addr [arg ...]\n"
82 "Start application at address 'addr' passing 'arg' as arguments.\n"
83 "If addr does not start with a digit it is interpreted as a filename\n"
84 "in which case the file is memmapped and executed\n";
88 .usage
= "start application at address or file",
89 BAREBOX_CMD_HELP(cmd_go_help
)