2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2016-08-12 12:31:15 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2000-2009
|
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <bootm.h>
|
|
|
|
#include <command.h>
|
2019-12-28 17:45:03 +00:00
|
|
|
#include <image.h>
|
2019-11-14 19:57:42 +00:00
|
|
|
#include <irq_func.h>
|
2016-08-12 12:31:15 +00:00
|
|
|
#include <lmb.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2016-08-12 12:31:15 +00:00
|
|
|
#include <linux/compiler.h>
|
|
|
|
|
|
|
|
int __weak bootz_setup(ulong image, ulong *start, ulong *end)
|
|
|
|
{
|
|
|
|
/* Please define bootz_setup() for your platform */
|
|
|
|
|
|
|
|
puts("Your platform's zImage format isn't supported yet!\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* zImage booting support
|
|
|
|
*/
|
2020-05-10 17:40:03 +00:00
|
|
|
static int bootz_start(struct cmd_tbl *cmdtp, int flag, int argc,
|
2022-09-07 02:26:50 +00:00
|
|
|
char *const argv[], struct bootm_headers *images)
|
2016-08-12 12:31:15 +00:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
ulong zi_start, zi_end;
|
|
|
|
|
|
|
|
ret = do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START,
|
|
|
|
images, 1);
|
|
|
|
|
|
|
|
/* Setup Linux kernel zImage entry point */
|
|
|
|
if (!argc) {
|
2019-12-28 17:45:02 +00:00
|
|
|
images->ep = image_load_addr;
|
2016-08-12 12:31:15 +00:00
|
|
|
debug("* kernel: default image load address = 0x%08lx\n",
|
2019-12-28 17:45:02 +00:00
|
|
|
image_load_addr);
|
2016-08-12 12:31:15 +00:00
|
|
|
} else {
|
2021-07-24 15:03:29 +00:00
|
|
|
images->ep = hextoul(argv[0], NULL);
|
2016-08-12 12:31:15 +00:00
|
|
|
debug("* kernel: cmdline image address = 0x%08lx\n",
|
|
|
|
images->ep);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = bootz_setup(images->ep, &zi_start, &zi_end);
|
|
|
|
if (ret != 0)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
lmb_reserve(&images->lmb, images->ep, zi_end - zi_start);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not
|
|
|
|
* have a header that provide this informaiton.
|
|
|
|
*/
|
2020-07-28 14:57:48 +00:00
|
|
|
if (bootm_find_images(flag, argc, argv, images->ep, zi_end - zi_start))
|
2016-08-12 12:31:15 +00:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-05-10 17:40:03 +00:00
|
|
|
int do_bootz(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
2016-08-12 12:31:15 +00:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Consume 'bootz' */
|
|
|
|
argc--; argv++;
|
|
|
|
|
|
|
|
if (bootz_start(cmdtp, flag, argc, argv, &images))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We are doing the BOOTM_STATE_LOADOS state ourselves, so must
|
|
|
|
* disable interrupts ourselves
|
|
|
|
*/
|
|
|
|
bootm_disable_interrupts();
|
|
|
|
|
|
|
|
images.os.os = IH_OS_LINUX;
|
|
|
|
ret = do_bootm_states(cmdtp, flag, argc, argv,
|
2017-01-23 15:51:45 +00:00
|
|
|
#ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
|
|
|
|
BOOTM_STATE_RAMDISK |
|
|
|
|
#endif
|
2023-10-24 15:43:50 +00:00
|
|
|
BOOTM_STATE_MEASURE |
|
2016-08-12 12:31:15 +00:00
|
|
|
BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO |
|
|
|
|
BOOTM_STATE_OS_GO,
|
|
|
|
&images, 1);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2023-10-07 19:13:08 +00:00
|
|
|
U_BOOT_LONGHELP(bootz,
|
2016-08-12 12:31:15 +00:00
|
|
|
"[addr [initrd[:size]] [fdt]]\n"
|
|
|
|
" - boot Linux zImage stored in memory\n"
|
|
|
|
"\tThe argument 'initrd' is optional and specifies the address\n"
|
|
|
|
"\tof the initrd in memory. The optional argument ':size' allows\n"
|
|
|
|
"\tspecifying the size of RAW initrd.\n"
|
|
|
|
#if defined(CONFIG_OF_LIBFDT)
|
|
|
|
"\tWhen booting a Linux kernel which requires a flat device-tree\n"
|
|
|
|
"\ta third argument is required which is the address of the\n"
|
|
|
|
"\tdevice-tree blob. To boot that kernel without an initrd image,\n"
|
|
|
|
"\tuse a '-' for the second argument. If you do not pass a third\n"
|
|
|
|
"\ta bd_info struct will be passed instead\n"
|
|
|
|
#endif
|
2023-10-07 19:13:08 +00:00
|
|
|
);
|
2016-08-12 12:31:15 +00:00
|
|
|
|
|
|
|
U_BOOT_CMD(
|
|
|
|
bootz, CONFIG_SYS_MAXARGS, 1, do_bootz,
|
|
|
|
"boot Linux zImage image from memory", bootz_help_text
|
|
|
|
);
|