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