xref: /openbmc/u-boot/cmd/boot.c (revision a0594cefb7682dc0c32084d088b3ac0a85ed7395)
1  /*
2   * (C) Copyright 2000-2003
3   * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4   *
5   * SPDX-License-Identifier:	GPL-2.0+
6   */
7  
8  /*
9   * Misc boot support
10   */
11  #include <common.h>
12  #include <command.h>
13  #include <net.h>
14  
15  #ifdef CONFIG_CMD_GO
16  
17  /* Allow ports to override the default behavior */
18  __attribute__((weak))
19  unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc,
20  				 char * const argv[])
21  {
22  	return entry (argc, argv);
23  }
24  
25  static int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
26  {
27  	ulong	addr, rc;
28  	int     rcode = 0;
29  
30  	if (argc < 2)
31  		return CMD_RET_USAGE;
32  
33  	addr = simple_strtoul(argv[1], NULL, 16);
34  
35  	printf ("## Starting application at 0x%08lX ...\n", addr);
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, 1, 0,	do_reset,
61  	"Perform RESET of the CPU",
62  	""
63  );
64  
65  #ifdef CONFIG_CMD_POWEROFF
66  U_BOOT_CMD(
67  	poweroff, 1, 0,	do_poweroff,
68  	"Perform POWEROFF of the device",
69  	""
70  );
71  #endif
72