1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2000-2003
4  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5  */
6 
7 /*
8  * Misc boot support
9  */
10 #include <command.h>
11 #include <net.h>
12 #include <vsprintf.h>
13 
14 #ifdef CONFIG_CMD_GO
15 
16 /* Allow ports to override the default behavior */
17 __attribute__((weak))
do_go_exec(ulong (* entry)(int,char * const[]),int argc,char * const argv[])18 unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc,
19 				 char *const argv[])
20 {
21 	return entry (argc, argv);
22 }
23 
do_go(struct cmd_tbl * cmdtp,int flag,int argc,char * const argv[])24 static int do_go(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
25 {
26 	ulong	addr, rc;
27 	int     rcode = 0;
28 
29 	if (argc < 2)
30 		return CMD_RET_USAGE;
31 
32 	addr = hextoul(argv[1], NULL);
33 
34 	printf ("## Starting application at 0x%08lX ...\n", addr);
35 	flush();
36 
37 	/*
38 	 * pass address parameter as argv[0] (aka command name),
39 	 * and all remaining args
40 	 */
41 	rc = do_go_exec ((void *)addr, argc - 1, argv + 1);
42 	if (rc != 0) rcode = 1;
43 
44 	printf ("## Application terminated, rc = 0x%lX\n", rc);
45 	return rcode;
46 }
47 
48 /* -------------------------------------------------------------------- */
49 
50 U_BOOT_CMD(
51 	go, CONFIG_SYS_MAXARGS, 1,	do_go,
52 	"start application at address 'addr'",
53 	"addr [arg ...]\n    - start application at address 'addr'\n"
54 	"      passing 'arg' as arguments"
55 );
56 
57 #endif
58 
59 U_BOOT_CMD(
60 	reset, 2, 0,	do_reset,
61 	"Perform RESET of the CPU",
62 	"- cold boot without level specifier\n"
63 	"reset -w - warm reset if implemented"
64 );
65 
66 #ifdef CONFIG_CMD_POWEROFF
67 U_BOOT_CMD(
68 	poweroff, 1, 0,	do_poweroff,
69 	"Perform POWEROFF of the device",
70 	""
71 );
72 #endif
73