1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2010
4  *   Renesas Solutions Corp.
5  *   Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
6  */
7 
8 /*
9  * Linux SuperH zImage loading and boot
10  */
11 
12 #include <common.h>
13 #include <command.h>
14 #include <env.h>
15 #include <irq_func.h>
16 #include <asm/io.h>
17 #include <asm/zimage.h>
18 
do_sh_zimageboot(struct cmd_tbl * cmdtp,int flag,int argc,char * const argv[])19 int do_sh_zimageboot(struct cmd_tbl *cmdtp, int flag, int argc,
20 		     char *const argv[])
21 {
22 	ulong (*zboot_entry)(int, char * const []) = NULL;
23 	char *s0, *s1;
24 	unsigned char *param = NULL;
25 	char *cmdline;
26 	char *bootargs;
27 
28 	disable_interrupts();
29 
30 	if (argc >= 3) {
31 		/* argv[1] holds the address of the zImage */
32 		s0 = argv[1];
33 		/* argv[2] holds the address of zero page */
34 		s1 = argv[2];
35 	} else {
36 		goto exit;
37 	}
38 
39 	if (s0)
40 		zboot_entry = (ulong (*)(int, char * const []))simple_strtoul(s0, NULL, 16);
41 
42 	/* empty_zero_page */
43 	if (s1)
44 		param = (unsigned char*)simple_strtoul(s1, NULL, 16);
45 
46 	/* Linux kernel command line */
47 	cmdline = (char *)param + COMMAND_LINE;
48 	bootargs = env_get("bootargs");
49 
50 	/* Clear zero page */
51 	/* cppcheck-suppress nullPointer */
52 	memset(param, 0, 0x1000);
53 
54 	/* Set commandline */
55 	strcpy(cmdline, bootargs);
56 
57 	/* Boot */
58 	zboot_entry(0, NULL);
59 
60 exit:
61 	return -1;
62 }
63 
64 U_BOOT_CMD(
65 	zimageboot, 3, 0,	do_sh_zimageboot,
66 	"Boot zImage for Renesas SH",
67 	""
68 );
69