2018-05-07 06:58:06 +09:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2004-04-19 06:13:41 +09:00
|
|
|
/*
|
2007-03-11 21:48:24 +09:00
|
|
|
* (C) Copyright 2007 Michal Simek
|
2004-04-19 06:13:41 +09:00
|
|
|
* (C) Copyright 2004 Atmark Techno, Inc.
|
|
|
|
*
|
2007-03-11 21:48:24 +09:00
|
|
|
* Michal SIMEK <monstr@monstr.eu>
|
2004-04-19 06:13:41 +09:00
|
|
|
* Yasushi SHOJI <yashi@atmark-techno.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
2019-08-02 00:46:52 +09:00
|
|
|
#include <env.h>
|
2016-02-23 14:55:43 +09:00
|
|
|
#include <fdt_support.h>
|
2007-03-11 21:48:24 +09:00
|
|
|
#include <image.h>
|
2009-04-04 19:49:11 +09:00
|
|
|
#include <u-boot/zlib.h>
|
2007-03-11 21:48:24 +09:00
|
|
|
#include <asm/byteorder.h>
|
2004-04-19 06:13:41 +09:00
|
|
|
|
2013-05-02 19:51:48 +09:00
|
|
|
int do_bootm_linux(int flag, int argc, char * const argv[],
|
|
|
|
bootm_headers_t *images)
|
2004-04-19 06:13:41 +09:00
|
|
|
{
|
2007-03-11 21:48:24 +09:00
|
|
|
/* First parameter is mapped to $r5 for kernel boot args */
|
2013-05-02 19:51:48 +09:00
|
|
|
void (*thekernel) (char *, ulong, ulong);
|
2017-08-04 03:22:12 +09:00
|
|
|
char *commandline = env_get("bootargs");
|
2010-04-15 19:27:17 +09:00
|
|
|
ulong rd_data_start, rd_data_end;
|
2007-03-11 21:48:24 +09:00
|
|
|
|
2013-07-02 20:57:44 +09: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-22 07:25:45 +09:00
|
|
|
if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
|
|
|
|
return 1;
|
|
|
|
|
2010-04-15 19:27:17 +09:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
char *of_flat_tree = NULL;
|
|
|
|
#if defined(CONFIG_OF_LIBFDT)
|
2010-10-14 04:57:34 +09:00
|
|
|
/* did generic code already find a device tree? */
|
|
|
|
if (images->ft_len)
|
|
|
|
of_flat_tree = images->ft_addr;
|
2010-04-15 19:27:17 +09:00
|
|
|
#endif
|
|
|
|
|
2013-05-02 19:51:48 +09:00
|
|
|
thekernel = (void (*)(char *, ulong, ulong))images->ep;
|
2010-04-15 19:27:17 +09:00
|
|
|
|
|
|
|
/* find ramdisk */
|
2013-05-02 19:51:48 +09:00
|
|
|
ret = boot_get_ramdisk(argc, argv, images, IH_ARCH_MICROBLAZE,
|
2010-04-15 19:27:17 +09:00
|
|
|
&rd_data_start, &rd_data_end);
|
|
|
|
if (ret)
|
|
|
|
return 1;
|
2007-03-11 21:48:24 +09:00
|
|
|
|
2012-02-13 22:51:18 +09:00
|
|
|
bootstage_mark(BOOTSTAGE_ID_RUN_OS);
|
2007-03-11 21:48:24 +09:00
|
|
|
|
2013-06-12 03:14:46 +09:00
|
|
|
if (!of_flat_tree && argc > 1)
|
|
|
|
of_flat_tree = (char *)simple_strtoul(argv[1], NULL, 16);
|
2013-05-02 19:49:18 +09:00
|
|
|
|
|
|
|
/* fixup the initrd now that we know where it should be */
|
2018-02-12 18:54:37 +09:00
|
|
|
if (images->rd_start && images->rd_end && of_flat_tree) {
|
2013-05-02 19:49:18 +09:00
|
|
|
ret = fdt_initrd(of_flat_tree, images->rd_start,
|
2014-04-18 17:40:59 +09:00
|
|
|
images->rd_end);
|
2013-05-02 19:49:18 +09:00
|
|
|
if (ret)
|
|
|
|
return 1;
|
2018-02-12 18:54:37 +09:00
|
|
|
}
|
2013-05-02 19:49:18 +09:00
|
|
|
|
2007-03-11 21:48:24 +09:00
|
|
|
#ifdef DEBUG
|
2013-05-02 19:51:48 +09:00
|
|
|
printf("## Transferring control to Linux (at address 0x%08lx) ",
|
|
|
|
(ulong)thekernel);
|
|
|
|
printf("ramdisk 0x%08lx, FDT 0x%08lx...\n",
|
|
|
|
rd_data_start, (ulong) of_flat_tree);
|
2007-03-11 21:48:24 +09:00
|
|
|
#endif
|
|
|
|
|
2010-04-16 19:01:32 +09:00
|
|
|
#ifdef XILINX_USE_DCACHE
|
|
|
|
flush_cache(0, XILINX_DCACHE_BYTE_SIZE);
|
|
|
|
#endif
|
2010-04-15 19:27:17 +09:00
|
|
|
/*
|
|
|
|
* Linux Kernel Parameters (passing device tree):
|
|
|
|
* r5: pointer to command line
|
|
|
|
* r6: pointer to ramdisk
|
|
|
|
* r7: pointer to the fdt, followed by the board info data
|
|
|
|
*/
|
2013-05-02 19:51:48 +09:00
|
|
|
thekernel(commandline, rd_data_start, (ulong)of_flat_tree);
|
2008-03-12 18:33:00 +09:00
|
|
|
/* does not return */
|
2008-09-11 05:48:09 +09:00
|
|
|
|
2008-08-15 22:24:45 +09:00
|
|
|
return 1;
|
2004-04-19 06:13:41 +09:00
|
|
|
}
|