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> |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 13 | #include <command.h> |
| 14 | #include <env.h> |
Simon Glass | 36bf446 | 2019-11-14 12:57:42 -0700 | [diff] [blame] | 15 | #include <irq_func.h> |
Nobuhiro Iwamatsu | 45ce6f9 | 2010-12-08 13:49:12 +0900 | [diff] [blame] | 16 | #include <asm/io.h> |
| 17 | #include <asm/zimage.h> |
| 18 | |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 19 | int do_sh_zimageboot(struct cmd_tbl *cmdtp, int flag, int argc, |
| 20 | char *const argv[]) |
Nobuhiro Iwamatsu | 45ce6f9 | 2010-12-08 13:49:12 +0900 | [diff] [blame] | 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) |
Simon Glass | 7e5f460 | 2021-07-24 09:03:29 -0600 | [diff] [blame] | 40 | zboot_entry = (ulong (*)(int, char * const []))hextoul(s0, |
| 41 | NULL); |
Nobuhiro Iwamatsu | 45ce6f9 | 2010-12-08 13:49:12 +0900 | [diff] [blame] | 42 | |
| 43 | /* empty_zero_page */ |
| 44 | if (s1) |
Simon Glass | 7e5f460 | 2021-07-24 09:03:29 -0600 | [diff] [blame] | 45 | param = (unsigned char *)hextoul(s1, NULL); |
Nobuhiro Iwamatsu | 45ce6f9 | 2010-12-08 13:49:12 +0900 | [diff] [blame] | 46 | |
| 47 | /* Linux kernel command line */ |
| 48 | cmdline = (char *)param + COMMAND_LINE; |
Simon Glass | 00caae6 | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 49 | bootargs = env_get("bootargs"); |
Nobuhiro Iwamatsu | 45ce6f9 | 2010-12-08 13:49:12 +0900 | [diff] [blame] | 50 | |
| 51 | /* Clear zero page */ |
Wolfgang Denk | 0060517 | 2014-11-06 14:02:57 +0100 | [diff] [blame] | 52 | /* cppcheck-suppress nullPointer */ |
Nobuhiro Iwamatsu | 45ce6f9 | 2010-12-08 13:49:12 +0900 | [diff] [blame] | 53 | memset(param, 0, 0x1000); |
| 54 | |
| 55 | /* Set commandline */ |
| 56 | strcpy(cmdline, bootargs); |
| 57 | |
| 58 | /* Boot */ |
| 59 | zboot_entry(0, NULL); |
| 60 | |
| 61 | exit: |
| 62 | return -1; |
| 63 | } |
| 64 | |
| 65 | U_BOOT_CMD( |
| 66 | zimageboot, 3, 0, do_sh_zimageboot, |
| 67 | "Boot zImage for Renesas SH", |
| 68 | "" |
| 69 | ); |