blob: 72f2cf362d46eeb84113cd4d96942c376549c417 [file] [log] [blame]
wdenkfe8c2802002-11-03 00:38:21 +00001/*
wdenk8bde7f72003-06-27 21:31:46 +00002 * (C) Copyright 2000-2003
wdenkfe8c2802002-11-03 00:38:21 +00003 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
wdenkfe8c2802002-11-03 00:38:21 +00006 */
7
8/*
wdenk8bde7f72003-06-27 21:31:46 +00009 * Misc boot support
wdenkfe8c2802002-11-03 00:38:21 +000010 */
11#include <common.h>
12#include <command.h>
wdenkfe8c2802002-11-03 00:38:21 +000013#include <net.h>
wdenkfe8c2802002-11-03 00:38:21 +000014
Mike Frysingera641b972010-12-26 23:32:22 -050015#ifdef CONFIG_CMD_GO
16
Mike Frysingera4986452008-04-13 19:42:19 -040017/* Allow ports to override the default behavior */
18__attribute__((weak))
Kim Phillips088f1b12012-10-29 13:34:31 +000019unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc,
20 char * const argv[])
Mike Frysinger1f1d88d2008-01-29 18:21:05 -050021{
Mike Frysingera4986452008-04-13 19:42:19 -040022 return entry (argc, argv);
Mike Frysinger1f1d88d2008-01-29 18:21:05 -050023}
24
Kim Phillips088f1b12012-10-29 13:34:31 +000025static int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
wdenkfe8c2802002-11-03 00:38:21 +000026{
27 ulong addr, rc;
28 int rcode = 0;
29
Wolfgang Denk47e26b12010-07-17 01:06:04 +020030 if (argc < 2)
Simon Glass4c12eeb2011-12-10 08:44:01 +000031 return CMD_RET_USAGE;
wdenkfe8c2802002-11-03 00:38:21 +000032
33 addr = simple_strtoul(argv[1], NULL, 16);
34
wdenkdc7c9a12003-03-26 06:55:25 +000035 printf ("## Starting application at 0x%08lX ...\n", addr);
wdenkfe8c2802002-11-03 00:38:21 +000036
37 /*
38 * pass address parameter as argv[0] (aka command name),
39 * and all remaining args
40 */
Mike Frysingera4986452008-04-13 19:42:19 -040041 rc = do_go_exec ((void *)addr, argc - 1, argv + 1);
wdenkfe8c2802002-11-03 00:38:21 +000042 if (rc != 0) rcode = 1;
43
wdenkdc7c9a12003-03-26 06:55:25 +000044 printf ("## Application terminated, rc = 0x%lX\n", rc);
wdenkfe8c2802002-11-03 00:38:21 +000045 return rcode;
46}
47
wdenk8bde7f72003-06-27 21:31:46 +000048/* -------------------------------------------------------------------- */
wdenkfe8c2802002-11-03 00:38:21 +000049
wdenk0d498392003-07-01 21:06:45 +000050U_BOOT_CMD(
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020051 go, CONFIG_SYS_MAXARGS, 1, do_go,
Peter Tyser2fb26042009-01-27 18:03:12 -060052 "start application at address 'addr'",
wdenk8bde7f72003-06-27 21:31:46 +000053 "addr [arg ...]\n - start application at address 'addr'\n"
Wolfgang Denka89c33d2009-05-24 17:06:54 +020054 " passing 'arg' as arguments"
wdenk8bde7f72003-06-27 21:31:46 +000055);
wdenkfe8c2802002-11-03 00:38:21 +000056
Mike Frysingera641b972010-12-26 23:32:22 -050057#endif
58
wdenk0d498392003-07-01 21:06:45 +000059U_BOOT_CMD(
Wolfgang Denk0bba5452007-01-13 11:17:10 +010060 reset, 1, 0, do_reset,
Peter Tyser2fb26042009-01-27 18:03:12 -060061 "Perform RESET of the CPU",
Wolfgang Denka89c33d2009-05-24 17:06:54 +020062 ""
wdenk8bde7f72003-06-27 21:31:46 +000063);
Michael van Slingerland4e42e292016-01-13 19:31:17 +010064
65#ifdef CONFIG_CMD_POWEROFF
66U_BOOT_CMD(
67 poweroff, 1, 0, do_poweroff,
68 "Perform POWEROFF of the device",
69 ""
70);
71#endif