blob: 9150fce80b412d6faa6301e41a0b4f23e2bd263d [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
wdenkfe8c2802002-11-03 00:38:21 +00002/*
wdenk8bde7f72003-06-27 21:31:46 +00003 * (C) Copyright 2000-2003
wdenkfe8c2802002-11-03 00:38:21 +00004 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
wdenkfe8c2802002-11-03 00:38:21 +00005 */
6
7/*
wdenk8bde7f72003-06-27 21:31:46 +00008 * Misc boot support
wdenkfe8c2802002-11-03 00:38:21 +00009 */
10#include <common.h>
11#include <command.h>
wdenkfe8c2802002-11-03 00:38:21 +000012#include <net.h>
wdenkfe8c2802002-11-03 00:38:21 +000013
Mike Frysingera641b972010-12-26 23:32:22 -050014#ifdef CONFIG_CMD_GO
15
Mike Frysingera4986452008-04-13 19:42:19 -040016/* Allow ports to override the default behavior */
17__attribute__((weak))
Kim Phillips088f1b12012-10-29 13:34:31 +000018unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc,
19 char * const argv[])
Mike Frysinger1f1d88d2008-01-29 18:21:05 -050020{
Mike Frysingera4986452008-04-13 19:42:19 -040021 return entry (argc, argv);
Mike Frysinger1f1d88d2008-01-29 18:21:05 -050022}
23
Kim Phillips088f1b12012-10-29 13:34:31 +000024static int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
wdenkfe8c2802002-11-03 00:38:21 +000025{
26 ulong addr, rc;
27 int rcode = 0;
28
Wolfgang Denk47e26b12010-07-17 01:06:04 +020029 if (argc < 2)
Simon Glass4c12eeb2011-12-10 08:44:01 +000030 return CMD_RET_USAGE;
wdenkfe8c2802002-11-03 00:38:21 +000031
32 addr = simple_strtoul(argv[1], NULL, 16);
33
wdenkdc7c9a12003-03-26 06:55:25 +000034 printf ("## Starting application at 0x%08lX ...\n", addr);
wdenkfe8c2802002-11-03 00:38:21 +000035
36 /*
37 * pass address parameter as argv[0] (aka command name),
38 * and all remaining args
39 */
Mike Frysingera4986452008-04-13 19:42:19 -040040 rc = do_go_exec ((void *)addr, argc - 1, argv + 1);
wdenkfe8c2802002-11-03 00:38:21 +000041 if (rc != 0) rcode = 1;
42
wdenkdc7c9a12003-03-26 06:55:25 +000043 printf ("## Application terminated, rc = 0x%lX\n", rc);
wdenkfe8c2802002-11-03 00:38:21 +000044 return rcode;
45}
46
wdenk8bde7f72003-06-27 21:31:46 +000047/* -------------------------------------------------------------------- */
wdenkfe8c2802002-11-03 00:38:21 +000048
wdenk0d498392003-07-01 21:06:45 +000049U_BOOT_CMD(
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020050 go, CONFIG_SYS_MAXARGS, 1, do_go,
Peter Tyser2fb26042009-01-27 18:03:12 -060051 "start application at address 'addr'",
wdenk8bde7f72003-06-27 21:31:46 +000052 "addr [arg ...]\n - start application at address 'addr'\n"
Wolfgang Denka89c33d2009-05-24 17:06:54 +020053 " passing 'arg' as arguments"
wdenk8bde7f72003-06-27 21:31:46 +000054);
wdenkfe8c2802002-11-03 00:38:21 +000055
Mike Frysingera641b972010-12-26 23:32:22 -050056#endif
57
wdenk0d498392003-07-01 21:06:45 +000058U_BOOT_CMD(
Wolfgang Denk0bba5452007-01-13 11:17:10 +010059 reset, 1, 0, do_reset,
Peter Tyser2fb26042009-01-27 18:03:12 -060060 "Perform RESET of the CPU",
Wolfgang Denka89c33d2009-05-24 17:06:54 +020061 ""
wdenk8bde7f72003-06-27 21:31:46 +000062);
Michael van Slingerland4e42e292016-01-13 19:31:17 +010063
64#ifdef CONFIG_CMD_POWEROFF
65U_BOOT_CMD(
66 poweroff, 1, 0, do_poweroff,
67 "Perform POWEROFF of the device",
68 ""
69);
70#endif