blob: 23496cafdf5cbd4cd0e218d823491edbdb215375 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
wdenkfe8c2802002-11-03 00:38:21 +00002/*
wdenk57b2d802003-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/*
wdenk57b2d802003-06-27 21:31:46 +00008 * Misc boot support
wdenkfe8c2802002-11-03 00:38:21 +00009 */
wdenkfe8c2802002-11-03 00:38:21 +000010#include <command.h>
wdenkfe8c2802002-11-03 00:38:21 +000011#include <net.h>
Tom Rini5c1444f2024-04-27 08:10:59 -060012#include <vsprintf.h>
wdenkfe8c2802002-11-03 00:38:21 +000013
Mike Frysinger2ed02412010-12-26 23:32:22 -050014#ifdef CONFIG_CMD_GO
15
Mike Frysinger0870e472008-04-13 19:42:19 -040016/* Allow ports to override the default behavior */
17__attribute__((weak))
Kim Phillipsdc00a682012-10-29 13:34:31 +000018unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc,
Simon Glassed38aef2020-05-10 11:40:03 -060019 char *const argv[])
Mike Frysingerf79507e2008-01-29 18:21:05 -050020{
Mike Frysinger0870e472008-04-13 19:42:19 -040021 return entry (argc, argv);
Mike Frysingerf79507e2008-01-29 18:21:05 -050022}
23
Simon Glassed38aef2020-05-10 11:40:03 -060024static int do_go(struct cmd_tbl *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 Denk3b683112010-07-17 01:06:04 +020029 if (argc < 2)
Simon Glassa06dfc72011-12-10 08:44:01 +000030 return CMD_RET_USAGE;
wdenkfe8c2802002-11-03 00:38:21 +000031
Simon Glass3ff49ec2021-07-24 09:03:29 -060032 addr = hextoul(argv[1], NULL);
wdenkfe8c2802002-11-03 00:38:21 +000033
wdenkc8434db2003-03-26 06:55:25 +000034 printf ("## Starting application at 0x%08lX ...\n", addr);
Pali Rohár937b7d82022-09-05 11:31:21 +020035 flush();
wdenkfe8c2802002-11-03 00:38:21 +000036
wdenk60164a82003-10-08 23:26:14 +000037 /*
Mike Frysingerf79507e2008-01-29 18:21:05 -050038 * pass address parameter as argv[0] (aka command name),
39 * and all remaining args
wdenk60164a82003-10-08 23:26:14 +000040 */
Mike Frysinger0870e472008-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
wdenkc8434db2003-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
wdenk57b2d802003-06-27 21:31:46 +000048/* -------------------------------------------------------------------- */
wdenkfe8c2802002-11-03 00:38:21 +000049
wdenkf287a242003-07-01 21:06:45 +000050U_BOOT_CMD(
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020051 go, CONFIG_SYS_MAXARGS, 1, do_go,
Peter Tyserdfb72b82009-01-27 18:03:12 -060052 "start application at address 'addr'",
wdenk57b2d802003-06-27 21:31:46 +000053 "addr [arg ...]\n - start application at address 'addr'\n"
Wolfgang Denkc54781c2009-05-24 17:06:54 +020054 " passing 'arg' as arguments"
wdenk57b2d802003-06-27 21:31:46 +000055);
wdenkfe8c2802002-11-03 00:38:21 +000056
Mike Frysinger2ed02412010-12-26 23:32:22 -050057#endif
58
wdenkf287a242003-07-01 21:06:45 +000059U_BOOT_CMD(
Igor Opaniuk814f3032021-04-01 02:01:55 +030060 reset, 2, 0, do_reset,
Peter Tyserdfb72b82009-01-27 18:03:12 -060061 "Perform RESET of the CPU",
Michal Simekbfd9bd52021-08-11 12:01:25 +020062 "- cold boot without level specifier\n"
63 "reset -w - warm reset if implemented"
wdenk57b2d802003-06-27 21:31:46 +000064);
Michael van Slingerland2451dec2016-01-13 19:31:17 +010065
66#ifdef CONFIG_CMD_POWEROFF
67U_BOOT_CMD(
68 poweroff, 1, 0, do_poweroff,
69 "Perform POWEROFF of the device",
70 ""
71);
72#endif