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