• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #if defined(CONFIG_OHOS_SEC_BOOT_SUPPORT)
14 #include "../product/hisec/sec_boot.h"
15 #endif
16 
17 #ifdef CONFIG_CMD_GO
18 #if defined(CONFIG_CMD_USB)
19 #include <usb.h>
20 #endif
21 
22 /* Allow ports to override the default behavior */
23 __attribute__((weak))
do_go_exec(ulong (* entry)(int,char * const[]),int argc,char * const argv[])24 unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc,
25 				 char * const argv[])
26 {
27 	return entry (argc, argv);
28 }
29 
do_go(cmd_tbl_t * cmdtp,int flag,int argc,char * const argv[])30 static int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
31 {
32 	ulong	addr, rc;
33 	int     rcode = 0;
34 
35 	if (argc < 2)
36 		return CMD_RET_USAGE;
37 
38 #if defined(CONFIG_CMD_USB)
39 	/*
40 	 * turn off USB to prevent the host controller from writing to the
41 	 * SDRAM while Linux is booting. This could happen (at least for OHCI
42 	 * controller), because the HCCA (Host Controller Communication Area)
43 	 * lies within the SDRAM and the host controller writes continously to
44 	 * this area (as busmaster!). The HccaFrameNumber is for example
45 	 * updated every 1 ms within the HCCA structure in SDRAM! For more
46 	 * details see the OpenHCI specification.
47 	 */
48 	usb_stop();
49 #endif
50 
51 #if defined(CONFIG_OHOS_SEC_BOOT_SUPPORT)
52     if (CONFIG_OHOS_SEC_BOOT_ENABLE) {
53         int ret = check_security_boot(CONFIG_OHOS_X509_BIN_START_ADDR);
54         if (ret) {
55             printf("## Check security boot falied, sig_addr:%#X\n", CONFIG_OHOS_X509_BIN_START_ADDR);
56             while (1);
57         }
58     }
59 #endif
60 
61 	addr = simple_strtoul(argv[1], NULL, 16);
62 
63 	printf ("## Starting application at 0x%08lX ...\n", addr);
64 
65 	cleanup_before_linux();
66 
67 	/*
68 	 * pass address parameter as argv[0] (aka command name),
69 	 * and all remaining args
70 	 */
71 	rc = do_go_exec ((void *)addr, argc - 1, argv + 1);
72 	if (rc != 0) rcode = 1;
73 
74 	printf ("## Application terminated, rc = 0x%lX\n", rc);
75 	return rcode;
76 }
77 
78 /* -------------------------------------------------------------------- */
79 
80 U_BOOT_CMD(
81 	go, CONFIG_SYS_MAXARGS, 1,	do_go,
82 	"start application at address 'addr'",
83 	"addr [arg ...]\n    - start application at address 'addr'\n"
84 	"      passing 'arg' as arguments"
85 );
86 
87 #endif
88 
89 U_BOOT_CMD(
90 	reset, 1, 0,	do_reset,
91 	"Perform RESET of the CPU",
92 	""
93 );
94 
95 #ifdef CONFIG_CMD_POWEROFF
96 U_BOOT_CMD(
97 	poweroff, 1, 0,	do_poweroff,
98 	"Perform POWEROFF of the device",
99 	""
100 );
101 #endif
102