2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2003-12-08 01:34:36 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2003
|
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2020-05-10 17:40:00 +00:00
|
|
|
#include <bootstage.h>
|
2003-12-08 01:34:36 +00:00
|
|
|
#include <command.h>
|
2019-08-01 15:46:52 +00:00
|
|
|
#include <env.h>
|
2003-12-08 01:34:36 +00:00
|
|
|
#include <image.h>
|
2020-05-10 17:40:01 +00:00
|
|
|
#include <lmb.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2009-04-04 10:49:11 +00:00
|
|
|
#include <u-boot/zlib.h>
|
2007-08-16 20:05:11 +00:00
|
|
|
#include <bzlib.h>
|
2007-10-25 22:14:00 +00:00
|
|
|
#include <watchdog.h>
|
2003-12-08 01:34:36 +00:00
|
|
|
#include <asm/byteorder.h>
|
2008-01-31 12:58:13 +00:00
|
|
|
#ifdef CONFIG_SHOW_BOOT_PROGRESS
|
|
|
|
# include <status_led.h>
|
|
|
|
#endif
|
2003-12-08 01:34:36 +00:00
|
|
|
|
2006-03-31 16:32:53 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2003-12-08 01:34:36 +00:00
|
|
|
#define PHYSADDR(x) x
|
|
|
|
|
2004-02-12 00:47:09 +00:00
|
|
|
#define LINUX_MAX_ENVS 256
|
|
|
|
#define LINUX_MAX_ARGS 256
|
2003-12-08 01:34:36 +00:00
|
|
|
|
2008-01-31 12:57:17 +00:00
|
|
|
static ulong get_sp (void);
|
2020-06-26 06:13:33 +00:00
|
|
|
static void set_clocks_in_mhz (struct bd_info *kbd);
|
2008-01-31 12:57:17 +00:00
|
|
|
|
2008-10-17 02:52:08 +00:00
|
|
|
void arch_lmb_reserve(struct lmb *lmb)
|
2003-12-08 01:34:36 +00:00
|
|
|
{
|
2008-02-28 03:51:49 +00:00
|
|
|
ulong sp;
|
2008-01-08 17:12:17 +00:00
|
|
|
|
2007-08-16 20:05:11 +00:00
|
|
|
/*
|
|
|
|
* Booting a (Linux) kernel image
|
|
|
|
*
|
|
|
|
* Allocate space for command line and board info - the
|
|
|
|
* address should be as high as possible within the reach of
|
2008-10-16 13:01:15 +00:00
|
|
|
* the kernel (see CONFIG_SYS_BOOTMAPSZ settings), but in unused
|
2007-08-16 20:05:11 +00:00
|
|
|
* memory, which means far enough below the current stack
|
|
|
|
* pointer.
|
|
|
|
*/
|
2008-01-31 12:58:13 +00:00
|
|
|
sp = get_sp();
|
|
|
|
debug ("## Current stack ends at 0x%08lx ", sp);
|
2007-08-16 20:05:11 +00:00
|
|
|
|
2008-02-28 03:51:49 +00:00
|
|
|
/* adjust sp by 1K to be safe */
|
|
|
|
sp -= 1024;
|
2008-10-16 13:01:15 +00:00
|
|
|
lmb_reserve(lmb, sp, (CONFIG_SYS_SDRAM_BASE + gd->ram_size - sp));
|
2008-10-17 02:52:08 +00:00
|
|
|
}
|
|
|
|
|
2020-05-10 17:40:03 +00:00
|
|
|
int do_bootm_linux(int flag, int argc, char *const argv[],
|
|
|
|
bootm_headers_t *images)
|
2008-10-17 02:52:08 +00:00
|
|
|
{
|
|
|
|
int ret;
|
2020-06-26 06:13:33 +00:00
|
|
|
struct bd_info *kbd;
|
|
|
|
void (*kernel) (struct bd_info *, ulong, ulong, ulong, ulong);
|
2008-10-17 02:52:08 +00:00
|
|
|
struct lmb *lmb = &images->lmb;
|
|
|
|
|
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;
|
|
|
|
|
2008-01-31 12:58:13 +00:00
|
|
|
/* allocate space for kernel copy of board info */
|
2011-03-28 09:58:34 +00:00
|
|
|
ret = boot_get_kbd (lmb, &kbd);
|
2008-02-28 03:51:49 +00:00
|
|
|
if (ret) {
|
|
|
|
puts("ERROR with allocation of kernel bd\n");
|
|
|
|
goto error;
|
|
|
|
}
|
2008-01-31 12:58:13 +00:00
|
|
|
set_clocks_in_mhz(kbd);
|
2007-08-16 20:05:11 +00:00
|
|
|
|
2013-05-08 08:06:05 +00:00
|
|
|
ret = image_setup_linux(images);
|
2008-02-28 03:51:49 +00:00
|
|
|
if (ret)
|
|
|
|
goto error;
|
2003-12-08 01:34:36 +00:00
|
|
|
|
2020-06-26 06:13:33 +00:00
|
|
|
kernel = (void (*)(struct bd_info *, ulong, ulong, ulong, ulong))images->ep;
|
2013-05-08 08:06:05 +00:00
|
|
|
|
2007-08-16 20:05:11 +00:00
|
|
|
debug("## Transferring control to Linux (at address %08lx) ...\n",
|
|
|
|
(ulong) kernel);
|
2003-12-08 01:34:36 +00:00
|
|
|
|
2012-02-13 13:51:18 +00:00
|
|
|
bootstage_mark(BOOTSTAGE_ID_RUN_OS);
|
2003-12-08 01:34:36 +00:00
|
|
|
|
2007-08-16 20:05:11 +00:00
|
|
|
/*
|
|
|
|
* Linux Kernel Parameters (passing board info data):
|
2009-02-20 18:01:56 +00:00
|
|
|
* sp+00: Ignore, side effect of using jsr to jump to kernel
|
|
|
|
* sp+04: ptr to board info data
|
|
|
|
* sp+08: initrd_start or 0 if no initrd
|
|
|
|
* sp+12: initrd_end - unused if initrd_start is 0
|
|
|
|
* sp+16: Start of command line string
|
|
|
|
* sp+20: End of command line string
|
2007-08-16 20:05:11 +00:00
|
|
|
*/
|
2014-06-08 04:07:58 +00:00
|
|
|
(*kernel)(kbd, images->initrd_start, images->initrd_end,
|
|
|
|
images->cmdline_start, images->cmdline_end);
|
2007-08-16 20:05:11 +00:00
|
|
|
/* does not return */
|
2008-02-28 03:51:46 +00:00
|
|
|
error:
|
2008-08-15 13:24:45 +00:00
|
|
|
return 1;
|
2003-12-08 01:34:36 +00:00
|
|
|
}
|
2008-01-31 12:57:17 +00:00
|
|
|
|
|
|
|
static ulong get_sp (void)
|
|
|
|
{
|
|
|
|
ulong sp;
|
|
|
|
|
|
|
|
asm("movel %%a7, %%d0\n"
|
|
|
|
"movel %%d0, %0\n": "=d"(sp): :"%d0");
|
|
|
|
|
|
|
|
return sp;
|
|
|
|
}
|
2008-01-31 12:58:13 +00:00
|
|
|
|
2020-06-26 06:13:33 +00:00
|
|
|
static void set_clocks_in_mhz (struct bd_info *kbd)
|
2008-01-31 12:58:13 +00:00
|
|
|
{
|
|
|
|
char *s;
|
|
|
|
|
2017-08-03 18:22:12 +00:00
|
|
|
s = env_get("clocks_in_mhz");
|
|
|
|
if (s) {
|
2008-01-31 12:58:13 +00:00
|
|
|
/* convert all clock information to MHz */
|
|
|
|
kbd->bi_intfreq /= 1000000L;
|
|
|
|
kbd->bi_busfreq /= 1000000L;
|
|
|
|
}
|
|
|
|
}
|