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