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 <command.h>
13#include <env.h>
14#include <irq_func.h>
15#include <vsprintf.h>
16#include <asm/io.h>
17#include <asm/zimage.h>
18
19int 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 []))hextoul(s0,
41									NULL);
42
43	/* empty_zero_page */
44	if (s1)
45		param = (unsigned char *)hextoul(s1, NULL);
46
47	/* Linux kernel command line */
48	cmdline = (char *)param + COMMAND_LINE;
49	bootargs = env_get("bootargs");
50
51	/* Clear zero page */
52	/* cppcheck-suppress nullPointer */
53	memset(param, 0, 0x1000);
54
55	/* Set commandline */
56	strcpy(cmdline, bootargs);
57
58	/* Boot */
59	zboot_entry(0, NULL);
60
61exit:
62	return -1;
63}
64
65U_BOOT_CMD(
66	zimageboot, 3, 0,	do_sh_zimageboot,
67	"Boot zImage for Renesas SH",
68	""
69);
70