Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Nobuhiro Iwamatsu | 45ce6f9 | 2010-12-08 13:49:12 +0900 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2010 |
| 4 | * Renesas Solutions Corp. |
| 5 | * Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com> |
Nobuhiro Iwamatsu | 45ce6f9 | 2010-12-08 13:49:12 +0900 | [diff] [blame] | 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; |
Simon Glass | 00caae6 | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 44 | bootargs = env_get("bootargs"); |
Nobuhiro Iwamatsu | 45ce6f9 | 2010-12-08 13:49:12 +0900 | [diff] [blame] | 45 | |
| 46 | /* Clear zero page */ |
Wolfgang Denk | 0060517 | 2014-11-06 14:02:57 +0100 | [diff] [blame] | 47 | /* cppcheck-suppress nullPointer */ |
Nobuhiro Iwamatsu | 45ce6f9 | 2010-12-08 13:49:12 +0900 | [diff] [blame] | 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 | ); |