Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Nobuhiro Iwamatsu | fb7f445 | 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 | fb7f445 | 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 | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 13 | #include <command.h> |
| 14 | #include <env.h> |
Simon Glass | 8f3f761 | 2019-11-14 12:57:42 -0700 | [diff] [blame] | 15 | #include <irq_func.h> |
Nobuhiro Iwamatsu | fb7f445 | 2010-12-08 13:49:12 +0900 | [diff] [blame] | 16 | #include <asm/io.h> |
| 17 | #include <asm/zimage.h> |
| 18 | |
Simon Glass | ed38aef | 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 | fb7f445 | 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) |
| 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 Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 48 | bootargs = env_get("bootargs"); |
Nobuhiro Iwamatsu | fb7f445 | 2010-12-08 13:49:12 +0900 | [diff] [blame] | 49 | |
| 50 | /* Clear zero page */ |
Wolfgang Denk | 6ae8083 | 2014-11-06 14:02:57 +0100 | [diff] [blame] | 51 | /* cppcheck-suppress nullPointer */ |
Nobuhiro Iwamatsu | fb7f445 | 2010-12-08 13:49:12 +0900 | [diff] [blame] | 52 | memset(param, 0, 0x1000); |
| 53 | |
| 54 | /* Set commandline */ |
| 55 | strcpy(cmdline, bootargs); |
| 56 | |
| 57 | /* Boot */ |
| 58 | zboot_entry(0, NULL); |
| 59 | |
| 60 | exit: |
| 61 | return -1; |
| 62 | } |
| 63 | |
| 64 | U_BOOT_CMD( |
| 65 | zimageboot, 3, 0, do_sh_zimageboot, |
| 66 | "Boot zImage for Renesas SH", |
| 67 | "" |
| 68 | ); |