blob: c38f0933f894d56b47b9f69d69804380e1b4e755 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Nobuhiro Iwamatsufb7f4452010-12-08 13:49:12 +09002/*
3 * (C) Copyright 2010
4 * Renesas Solutions Corp.
5 * Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
Nobuhiro Iwamatsufb7f4452010-12-08 13:49:12 +09006 */
7
8/*
9 * Linux SuperH zImage loading and boot
10 */
11
12#include <common.h>
Simon Glassed38aef2020-05-10 11:40:03 -060013#include <command.h>
14#include <env.h>
Simon Glass8f3f7612019-11-14 12:57:42 -070015#include <irq_func.h>
Nobuhiro Iwamatsufb7f4452010-12-08 13:49:12 +090016#include <asm/io.h>
17#include <asm/zimage.h>
18
Simon Glassed38aef2020-05-10 11:40:03 -060019int do_sh_zimageboot(struct cmd_tbl *cmdtp, int flag, int argc,
20 char *const argv[])
Nobuhiro Iwamatsufb7f4452010-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)
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;
Simon Glass64b723f2017-08-03 12:22:12 -060048 bootargs = env_get("bootargs");
Nobuhiro Iwamatsufb7f4452010-12-08 13:49:12 +090049
50 /* Clear zero page */
Wolfgang Denk6ae80832014-11-06 14:02:57 +010051 /* cppcheck-suppress nullPointer */
Nobuhiro Iwamatsufb7f4452010-12-08 13:49:12 +090052 memset(param, 0, 0x1000);
53
54 /* Set commandline */
55 strcpy(cmdline, bootargs);
56
57 /* Boot */
58 zboot_entry(0, NULL);
59
60exit:
61 return -1;
62}
63
64U_BOOT_CMD(
65 zimageboot, 3, 0, do_sh_zimageboot,
66 "Boot zImage for Renesas SH",
67 ""
68);