xref: /openbmc/u-boot/cmd/boot.c (revision fabbeb33)
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 <common.h>
11 #include <command.h>
12 #include <net.h>
13 
14 #ifdef CONFIG_CMD_GO
15 
16 /* Allow ports to override the default behavior */
17 __attribute__((weak))
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 
24 static int do_go(cmd_tbl_t *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 = simple_strtoul(argv[1], NULL, 16);
33 
34 	printf ("## Starting application at 0x%08lX ...\n", addr);
35 
36 	/*
37 	 * pass address parameter as argv[0] (aka command name),
38 	 * and all remaining args
39 	 */
40 	rc = do_go_exec ((void *)addr, argc - 1, argv + 1);
41 	if (rc != 0) rcode = 1;
42 
43 	printf ("## Application terminated, rc = 0x%lX\n", rc);
44 	return rcode;
45 }
46 
47 /* -------------------------------------------------------------------- */
48 
49 U_BOOT_CMD(
50 	go, CONFIG_SYS_MAXARGS, 1,	do_go,
51 	"start application at address 'addr'",
52 	"addr [arg ...]\n    - start application at address 'addr'\n"
53 	"      passing 'arg' as arguments"
54 );
55 
56 #endif
57 
58 U_BOOT_CMD(
59 	reset, 1, 0,	do_reset,
60 	"Perform RESET of the CPU",
61 	""
62 );
63 
64 #ifdef CONFIG_CMD_POWEROFF
65 U_BOOT_CMD(
66 	poweroff, 1, 0,	do_poweroff,
67 	"Perform POWEROFF of the device",
68 	""
69 );
70 #endif
71