3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * (c) Copyright 2008 Nobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com>
6 * (c) Copyright 2008 Renesas Solutions Corp.
8 * SPDX-License-Identifier: GPL-2.0+
13 #include <asm/byteorder.h>
14 #include <asm/zimage.h>
16 #ifdef CONFIG_SYS_DEBUG
17 static void hexdump(unsigned char *buf, int len)
21 for (i = 0; i < len; i++) {
23 printf("%s%08x: ", i ? "\n" : "",
24 (unsigned int)&buf[i]);
25 printf("%02x ", buf[i]);
31 #ifdef CONFIG_SH_SDRAM_OFFSET
32 #define GET_INITRD_START(initrd, linux) (initrd - linux + CONFIG_SH_SDRAM_OFFSET)
34 #define GET_INITRD_START(initrd, linux) (initrd - linux)
37 static void set_sh_linux_param(unsigned long param_addr, unsigned long data)
39 *(unsigned long *)(param_addr) = data;
42 static unsigned long sh_check_cmd_arg(char *cmdline, char *key, int base)
44 unsigned long val = 0;
45 char *p = strstr(cmdline, key);
48 val = simple_strtol(p, NULL, base);
53 int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *images)
55 /* Linux kernel load address */
56 void (*kernel) (void) = (void (*)(void))images->ep;
59 = (unsigned char *)image_get_load(images->legacy_hdr_os);
60 /* Linux kernel command line */
61 char *cmdline = (char *)param + COMMAND_LINE;
63 unsigned long size = images->ep - (unsigned long)param;
64 char *bootargs = env_get("bootargs");
67 * allow the PREP bootm subcommand, it is required for bootm to work
69 if (flag & BOOTM_STATE_OS_PREP)
72 if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
76 memset(param, 0, size);
79 strcpy(cmdline, bootargs);
82 if (images->rd_start || images->rd_end) {
83 unsigned long ramdisk_flags = 0;
84 int val = sh_check_cmd_arg(bootargs, CMD_ARG_RD_PROMPT, 10);
86 ramdisk_flags |= RD_PROMPT;
88 ramdisk_flags &= ~RD_PROMPT;
90 val = sh_check_cmd_arg(bootargs, CMD_ARG_RD_DOLOAD, 10);
92 ramdisk_flags |= RD_DOLOAD;
94 ramdisk_flags &= ~RD_DOLOAD;
96 set_sh_linux_param((unsigned long)param + MOUNT_ROOT_RDONLY, 0x0001);
97 set_sh_linux_param((unsigned long)param + RAMDISK_FLAGS, ramdisk_flags);
98 set_sh_linux_param((unsigned long)param + ORIG_ROOT_DEV, 0x0200);
99 set_sh_linux_param((unsigned long)param + LOADER_TYPE, 0x0001);
100 set_sh_linux_param((unsigned long)param + INITRD_START,
101 GET_INITRD_START(images->rd_start, CONFIG_SYS_SDRAM_BASE));
102 set_sh_linux_param((unsigned long)param + INITRD_SIZE,
103 images->rd_end - images->rd_start);
109 /* does not return */