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
|
|
|
* See file CREDITS for list of people who contributed to this
|
|
|
|
* project.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
|
|
|
#include <asm/byteorder.h>
|
2010-12-08 04:46:36 +00:00
|
|
|
#include <asm/zimage.h>
|
2007-05-13 11:58:00 +00:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2010-06-28 20:00:46 +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;
|
2008-09-17 02:08:36 +00:00
|
|
|
char *bootargs = getenv("bootargs");
|
2007-05-13 11:58:00 +00:00
|
|
|
|
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
|
|
|
}
|