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