xref: /openbmc/u-boot/arch/sh/lib/zimageboot.c (revision dd1033e4)
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 <asm/io.h>
14 #include <asm/zimage.h>
15 
16 int do_sh_zimageboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
17 {
18 	ulong (*zboot_entry)(int, char * const []) = NULL;
19 	char *s0, *s1;
20 	unsigned char *param = NULL;
21 	char *cmdline;
22 	char *bootargs;
23 
24 	disable_interrupts();
25 
26 	if (argc >= 3) {
27 		/* argv[1] holds the address of the zImage */
28 		s0 = argv[1];
29 		/* argv[2] holds the address of zero page */
30 		s1 = argv[2];
31 	} else {
32 		goto exit;
33 	}
34 
35 	if (s0)
36 		zboot_entry = (ulong (*)(int, char * const []))simple_strtoul(s0, NULL, 16);
37 
38 	/* empty_zero_page */
39 	if (s1)
40 		param = (unsigned char*)simple_strtoul(s1, NULL, 16);
41 
42 	/* Linux kernel command line */
43 	cmdline = (char *)param + COMMAND_LINE;
44 	bootargs = env_get("bootargs");
45 
46 	/* Clear zero page */
47 	/* cppcheck-suppress nullPointer */
48 	memset(param, 0, 0x1000);
49 
50 	/* Set commandline */
51 	strcpy(cmdline, bootargs);
52 
53 	/* Boot */
54 	zboot_entry(0, NULL);
55 
56 exit:
57 	return -1;
58 }
59 
60 U_BOOT_CMD(
61 	zimageboot, 3, 0,	do_sh_zimageboot,
62 	"Boot zImage for Renesas SH",
63 	""
64 );
65