blob: f14a5fefbfc68725160d8f468debdbe9ff67328c [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Tom Rini5db28902016-08-12 08:31:15 -04002/*
3 * (C) Copyright 2000-2009
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
Tom Rini5db28902016-08-12 08:31:15 -04005 */
6
7#include <common.h>
8#include <bootm.h>
9#include <command.h>
Simon Glass8e8ccfe2019-12-28 10:45:03 -070010#include <image.h>
Simon Glass36bf4462019-11-14 12:57:42 -070011#include <irq_func.h>
Tom Rini5db28902016-08-12 08:31:15 -040012#include <lmb.h>
13#include <linux/compiler.h>
14
15int __weak bootz_setup(ulong image, ulong *start, ulong *end)
16{
17 /* Please define bootz_setup() for your platform */
18
19 puts("Your platform's zImage format isn't supported yet!\n");
20 return -1;
21}
22
23/*
24 * zImage booting support
25 */
26static int bootz_start(cmd_tbl_t *cmdtp, int flag, int argc,
27 char * const argv[], bootm_headers_t *images)
28{
29 int ret;
30 ulong zi_start, zi_end;
31
32 ret = do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START,
33 images, 1);
34
35 /* Setup Linux kernel zImage entry point */
36 if (!argc) {
Simon Glassbb872dd2019-12-28 10:45:02 -070037 images->ep = image_load_addr;
Tom Rini5db28902016-08-12 08:31:15 -040038 debug("* kernel: default image load address = 0x%08lx\n",
Simon Glassbb872dd2019-12-28 10:45:02 -070039 image_load_addr);
Tom Rini5db28902016-08-12 08:31:15 -040040 } else {
41 images->ep = simple_strtoul(argv[0], NULL, 16);
42 debug("* kernel: cmdline image address = 0x%08lx\n",
43 images->ep);
44 }
45
46 ret = bootz_setup(images->ep, &zi_start, &zi_end);
47 if (ret != 0)
48 return 1;
49
50 lmb_reserve(&images->lmb, images->ep, zi_end - zi_start);
51
52 /*
53 * Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not
54 * have a header that provide this informaiton.
55 */
56 if (bootm_find_images(flag, argc, argv))
57 return 1;
58
59 return 0;
60}
61
62int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
63{
64 int ret;
65
66 /* Consume 'bootz' */
67 argc--; argv++;
68
69 if (bootz_start(cmdtp, flag, argc, argv, &images))
70 return 1;
71
72 /*
73 * We are doing the BOOTM_STATE_LOADOS state ourselves, so must
74 * disable interrupts ourselves
75 */
76 bootm_disable_interrupts();
77
78 images.os.os = IH_OS_LINUX;
79 ret = do_bootm_states(cmdtp, flag, argc, argv,
Cédric Schieli4943dc22017-01-23 16:51:45 +010080#ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
81 BOOTM_STATE_RAMDISK |
82#endif
Tom Rini5db28902016-08-12 08:31:15 -040083 BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO |
84 BOOTM_STATE_OS_GO,
85 &images, 1);
86
87 return ret;
88}
89
90#ifdef CONFIG_SYS_LONGHELP
91static char bootz_help_text[] =
92 "[addr [initrd[:size]] [fdt]]\n"
93 " - boot Linux zImage stored in memory\n"
94 "\tThe argument 'initrd' is optional and specifies the address\n"
95 "\tof the initrd in memory. The optional argument ':size' allows\n"
96 "\tspecifying the size of RAW initrd.\n"
97#if defined(CONFIG_OF_LIBFDT)
98 "\tWhen booting a Linux kernel which requires a flat device-tree\n"
99 "\ta third argument is required which is the address of the\n"
100 "\tdevice-tree blob. To boot that kernel without an initrd image,\n"
101 "\tuse a '-' for the second argument. If you do not pass a third\n"
102 "\ta bd_info struct will be passed instead\n"
103#endif
104 "";
105#endif
106
107U_BOOT_CMD(
108 bootz, CONFIG_SYS_MAXARGS, 1, do_bootz,
109 "boot Linux zImage image from memory", bootz_help_text
110);