]>
git.ipfire.org Git - thirdparty/u-boot.git/blob - arch/sh/lib/bootm.c
1 // SPDX-License-Identifier: GPL-2.0+
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 * (c) Copyright 2008 Nobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com>
7 * (c) Copyright 2008 Renesas Solutions Corp.
12 #include <asm/byteorder.h>
13 #include <asm/zimage.h>
15 #ifdef CONFIG_SYS_DEBUG
16 static void hexdump(unsigned char *buf
, int len
)
20 for (i
= 0; i
< len
; i
++) {
22 printf("%s%08x: ", i
? "\n" : "",
23 (unsigned int)&buf
[i
]);
24 printf("%02x ", buf
[i
]);
30 #ifdef CONFIG_SH_SDRAM_OFFSET
31 #define GET_INITRD_START(initrd, linux) (initrd - linux + CONFIG_SH_SDRAM_OFFSET)
33 #define GET_INITRD_START(initrd, linux) (initrd - linux)
36 static void set_sh_linux_param(unsigned long param_addr
, unsigned long data
)
38 *(unsigned long *)(param_addr
) = data
;
41 static unsigned long sh_check_cmd_arg(char *cmdline
, char *key
, int base
)
43 unsigned long val
= 0;
44 char *p
= strstr(cmdline
, key
);
47 val
= simple_strtol(p
, NULL
, base
);
52 int do_bootm_linux(int flag
, int argc
, char * const argv
[], bootm_headers_t
*images
)
54 /* Linux kernel load address */
55 void (*kernel
) (void) = (void (*)(void))images
->ep
;
58 = (unsigned char *)image_get_load(images
->legacy_hdr_os
);
59 /* Linux kernel command line */
60 char *cmdline
= (char *)param
+ COMMAND_LINE
;
62 unsigned long size
= images
->ep
- (unsigned long)param
;
63 char *bootargs
= env_get("bootargs");
66 * allow the PREP bootm subcommand, it is required for bootm to work
68 if (flag
& BOOTM_STATE_OS_PREP
)
71 if ((flag
!= 0) && (flag
!= BOOTM_STATE_OS_GO
))
75 memset(param
, 0, size
);
78 strcpy(cmdline
, bootargs
);
81 if (images
->rd_start
|| images
->rd_end
) {
82 unsigned long ramdisk_flags
= 0;
83 int val
= sh_check_cmd_arg(bootargs
, CMD_ARG_RD_PROMPT
, 10);
85 ramdisk_flags
|= RD_PROMPT
;
87 ramdisk_flags
&= ~RD_PROMPT
;
89 val
= sh_check_cmd_arg(bootargs
, CMD_ARG_RD_DOLOAD
, 10);
91 ramdisk_flags
|= RD_DOLOAD
;
93 ramdisk_flags
&= ~RD_DOLOAD
;
95 set_sh_linux_param((unsigned long)param
+ MOUNT_ROOT_RDONLY
, 0x0001);
96 set_sh_linux_param((unsigned long)param
+ RAMDISK_FLAGS
, ramdisk_flags
);
97 set_sh_linux_param((unsigned long)param
+ ORIG_ROOT_DEV
, 0x0200);
98 set_sh_linux_param((unsigned long)param
+ LOADER_TYPE
, 0x0001);
99 set_sh_linux_param((unsigned long)param
+ INITRD_START
,
100 GET_INITRD_START(images
->rd_start
, CONFIG_SYS_SDRAM_BASE
));
101 set_sh_linux_param((unsigned long)param
+ INITRD_SIZE
,
102 images
->rd_end
- images
->rd_start
);
108 /* does not return */