2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2007-05-13 11:58:00 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2003
|
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*
|
2008-09-17 02:08:36 +00:00
|
|
|
* (c) Copyright 2008 Nobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com>
|
|
|
|
* (c) Copyright 2008 Renesas Solutions Corp.
|
2007-05-13 11:58:00 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
2020-05-10 17:40:03 +00:00
|
|
|
#include <env.h>
|
2020-05-10 17:40:01 +00:00
|
|
|
#include <image.h>
|
2007-05-13 11:58:00 +00:00
|
|
|
#include <asm/byteorder.h>
|
2021-09-10 20:47:16 +00:00
|
|
|
#include <asm/global_data.h>
|
2010-12-08 04:46:36 +00:00
|
|
|
#include <asm/zimage.h>
|
2007-05-13 11:58:00 +00:00
|
|
|
|
2021-09-10 20:47:16 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifdef CONFIG_SYS_DEBUG
|
2008-09-17 02:08:36 +00:00
|
|
|
static void hexdump(unsigned char *buf, int len)
|
2007-05-13 11:58:00 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
if ((i % 16) == 0)
|
2008-09-17 02:08:36 +00:00
|
|
|
printf("%s%08x: ", i ? "\n" : "",
|
|
|
|
(unsigned int)&buf[i]);
|
|
|
|
printf("%02x ", buf[i]);
|
2007-05-13 11:58:00 +00:00
|
|
|
}
|
2008-09-17 02:08:36 +00:00
|
|
|
printf("\n");
|
2007-05-13 11:58:00 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-09-28 03:14:57 +00:00
|
|
|
#ifdef CONFIG_SH_SDRAM_OFFSET
|
|
|
|
#define GET_INITRD_START(initrd, linux) (initrd - linux + CONFIG_SH_SDRAM_OFFSET)
|
|
|
|
#else
|
|
|
|
#define GET_INITRD_START(initrd, linux) (initrd - linux)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void set_sh_linux_param(unsigned long param_addr, unsigned long data)
|
|
|
|
{
|
|
|
|
*(unsigned long *)(param_addr) = data;
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned long sh_check_cmd_arg(char *cmdline, char *key, int base)
|
|
|
|
{
|
|
|
|
unsigned long val = 0;
|
|
|
|
char *p = strstr(cmdline, key);
|
|
|
|
if (p) {
|
|
|
|
p += strlen(key);
|
|
|
|
val = simple_strtol(p, NULL, base);
|
|
|
|
}
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2020-05-10 17:40:03 +00:00
|
|
|
int do_bootm_linux(int flag, int argc, char *const argv[],
|
|
|
|
bootm_headers_t *images)
|
2007-05-13 11:58:00 +00:00
|
|
|
{
|
2008-09-17 02:08:36 +00:00
|
|
|
/* Linux kernel load address */
|
2008-08-15 13:24:36 +00:00
|
|
|
void (*kernel) (void) = (void (*)(void))images->ep;
|
2008-09-17 02:08:36 +00:00
|
|
|
/* empty_zero_page */
|
2008-09-18 10:34:36 +00:00
|
|
|
unsigned char *param
|
|
|
|
= (unsigned char *)image_get_load(images->legacy_hdr_os);
|
2008-09-17 02:08:36 +00:00
|
|
|
/* Linux kernel command line */
|
2010-09-28 03:14:57 +00:00
|
|
|
char *cmdline = (char *)param + COMMAND_LINE;
|
2008-09-17 02:08:36 +00:00
|
|
|
/* PAGE_SIZE */
|
2008-09-18 10:34:36 +00:00
|
|
|
unsigned long size = images->ep - (unsigned long)param;
|
2017-08-03 18:22:12 +00:00
|
|
|
char *bootargs = env_get("bootargs");
|
2007-05-13 11:58:00 +00:00
|
|
|
|
2013-07-02 11:57:44 +00:00
|
|
|
/*
|
|
|
|
* allow the PREP bootm subcommand, it is required for bootm to work
|
|
|
|
*/
|
|
|
|
if (flag & BOOTM_STATE_OS_PREP)
|
|
|
|
return 0;
|
|
|
|
|
bootm: Add subcommands
Add the ability to break the steps of the bootm command into several
subcommands: start, loados, ramdisk, fdt, bdt, cmdline, prep, go.
This allows us to do things like manipulate device trees before
they are passed to a booting kernel or setup memory for a secondary
core in multicore situations.
Not all OS types support all subcommands (currently only start, loados,
ramdisk, fdt, and go are supported).
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
2008-10-21 22:25:45 +00:00
|
|
|
if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
|
|
|
|
return 1;
|
|
|
|
|
2010-12-08 04:46:36 +00:00
|
|
|
/* Clear zero page */
|
|
|
|
memset(param, 0, size);
|
2010-09-28 03:14:57 +00:00
|
|
|
|
|
|
|
/* Set commandline */
|
2008-09-17 02:08:36 +00:00
|
|
|
strcpy(cmdline, bootargs);
|
2007-09-22 17:12:30 +00:00
|
|
|
|
2010-09-28 03:14:57 +00:00
|
|
|
/* Initrd */
|
|
|
|
if (images->rd_start || images->rd_end) {
|
2010-10-19 08:14:15 +00:00
|
|
|
unsigned long ramdisk_flags = 0;
|
2010-09-28 03:14:57 +00:00
|
|
|
int val = sh_check_cmd_arg(bootargs, CMD_ARG_RD_PROMPT, 10);
|
|
|
|
if (val == 1)
|
|
|
|
ramdisk_flags |= RD_PROMPT;
|
|
|
|
else
|
|
|
|
ramdisk_flags &= ~RD_PROMPT;
|
2010-10-27 20:48:30 +00:00
|
|
|
|
2010-09-28 03:14:57 +00:00
|
|
|
val = sh_check_cmd_arg(bootargs, CMD_ARG_RD_DOLOAD, 10);
|
|
|
|
if (val == 1)
|
|
|
|
ramdisk_flags |= RD_DOLOAD;
|
|
|
|
else
|
|
|
|
ramdisk_flags &= ~RD_DOLOAD;
|
|
|
|
|
|
|
|
set_sh_linux_param((unsigned long)param + MOUNT_ROOT_RDONLY, 0x0001);
|
|
|
|
set_sh_linux_param((unsigned long)param + RAMDISK_FLAGS, ramdisk_flags);
|
|
|
|
set_sh_linux_param((unsigned long)param + ORIG_ROOT_DEV, 0x0200);
|
|
|
|
set_sh_linux_param((unsigned long)param + LOADER_TYPE, 0x0001);
|
|
|
|
set_sh_linux_param((unsigned long)param + INITRD_START,
|
|
|
|
GET_INITRD_START(images->rd_start, CONFIG_SYS_SDRAM_BASE));
|
|
|
|
set_sh_linux_param((unsigned long)param + INITRD_SIZE,
|
|
|
|
images->rd_end - images->rd_start);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Boot kernel */
|
2007-05-13 11:58:00 +00:00
|
|
|
kernel();
|
2008-03-12 09:33:00 +00:00
|
|
|
|
2010-12-08 04:46:36 +00:00
|
|
|
/* does not return */
|
2008-08-15 13:24:45 +00:00
|
|
|
return 1;
|
2007-05-13 11:58:00 +00:00
|
|
|
}
|
2021-09-10 20:47:16 +00:00
|
|
|
|
|
|
|
static ulong get_sp(void)
|
|
|
|
{
|
|
|
|
ulong ret;
|
|
|
|
|
|
|
|
asm("mov r15, %0" : "=r"(ret) : );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void arch_lmb_reserve(struct lmb *lmb)
|
|
|
|
{
|
|
|
|
arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 4096);
|
|
|
|
}
|