blob: c2e285ff0f62c38e5acb33b05345c233b47d7359 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Nobuhiro Iwamatsu45ce6f92010-12-08 13:49:12 +09002/*
3 * (C) Copyright 2010
4 * Renesas Solutions Corp.
5 * Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
Nobuhiro Iwamatsu45ce6f92010-12-08 13:49:12 +09006 */
7
8/*
9 * Linux SuperH zImage loading and boot
10 */
11
12#include <common.h>
Simon Glass09140112020-05-10 11:40:03 -060013#include <command.h>
14#include <env.h>
Simon Glass36bf4462019-11-14 12:57:42 -070015#include <irq_func.h>
Nobuhiro Iwamatsu45ce6f92010-12-08 13:49:12 +090016#include <asm/io.h>
17#include <asm/zimage.h>
18
Simon Glass09140112020-05-10 11:40:03 -060019int do_sh_zimageboot(struct cmd_tbl *cmdtp, int flag, int argc,
20 char *const argv[])
Nobuhiro Iwamatsu45ce6f92010-12-08 13:49:12 +090021{
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)
Simon Glass7e5f4602021-07-24 09:03:29 -060040 zboot_entry = (ulong (*)(int, char * const []))hextoul(s0,
41 NULL);
Nobuhiro Iwamatsu45ce6f92010-12-08 13:49:12 +090042
43 /* empty_zero_page */
44 if (s1)
Simon Glass7e5f4602021-07-24 09:03:29 -060045 param = (unsigned char *)hextoul(s1, NULL);
Nobuhiro Iwamatsu45ce6f92010-12-08 13:49:12 +090046
47 /* Linux kernel command line */
48 cmdline = (char *)param + COMMAND_LINE;
Simon Glass00caae62017-08-03 12:22:12 -060049 bootargs = env_get("bootargs");
Nobuhiro Iwamatsu45ce6f92010-12-08 13:49:12 +090050
51 /* Clear zero page */
Wolfgang Denk00605172014-11-06 14:02:57 +010052 /* cppcheck-suppress nullPointer */
Nobuhiro Iwamatsu45ce6f92010-12-08 13:49:12 +090053 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);