Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2003 |
| 4 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
Simon Glass | 0726d9d | 2023-12-15 20:14:13 -0700 | [diff] [blame] | 7 | #include <bootm.h> |
Simon Glass | 1ea9789 | 2020-05-10 11:40:00 -0600 | [diff] [blame] | 8 | #include <bootstage.h> |
Simon Glass | 79fd214 | 2019-08-01 09:46:43 -0600 | [diff] [blame] | 9 | #include <env.h> |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 10 | #include <image.h> |
Daniel Schwierzeck | 8d7ff4d | 2015-01-14 21:44:13 +0100 | [diff] [blame] | 11 | #include <fdt_support.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 12 | #include <log.h> |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 13 | #include <asm/addrspace.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 14 | #include <asm/global_data.h> |
Purna Chandra Mandal | 432549f | 2016-04-18 18:31:38 +0530 | [diff] [blame] | 15 | #include <asm/io.h> |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 16 | |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 17 | DECLARE_GLOBAL_DATA_PTR; |
| 18 | |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 19 | #define LINUX_MAX_ENVS 256 |
| 20 | #define LINUX_MAX_ARGS 256 |
| 21 | |
Daniel Schwierzeck | 83010eb | 2012-06-03 23:46:04 +0200 | [diff] [blame] | 22 | static int linux_argc; |
| 23 | static char **linux_argv; |
Daniel Schwierzeck | eb782d6 | 2013-05-09 17:10:06 +0200 | [diff] [blame] | 24 | static char *linux_argp; |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 25 | |
Daniel Schwierzeck | 83010eb | 2012-06-03 23:46:04 +0200 | [diff] [blame] | 26 | static char **linux_env; |
| 27 | static char *linux_env_p; |
| 28 | static int linux_env_idx; |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 29 | |
Daniel Schwierzeck | eb782d6 | 2013-05-09 17:10:06 +0200 | [diff] [blame] | 30 | static void linux_cmdline_init(void) |
| 31 | { |
| 32 | linux_argc = 1; |
Daniel Schwierzeck | e61db37 | 2020-07-12 01:46:15 +0200 | [diff] [blame] | 33 | linux_argv = (char **)CKSEG1ADDR(gd->bd->bi_boot_params); |
Daniel Schwierzeck | eb782d6 | 2013-05-09 17:10:06 +0200 | [diff] [blame] | 34 | linux_argv[0] = 0; |
| 35 | linux_argp = (char *)(linux_argv + LINUX_MAX_ARGS); |
| 36 | } |
| 37 | |
| 38 | static void linux_cmdline_set(const char *value, size_t len) |
| 39 | { |
| 40 | linux_argv[linux_argc] = linux_argp; |
| 41 | memcpy(linux_argp, value, len); |
| 42 | linux_argp[len] = 0; |
| 43 | |
| 44 | linux_argp += len + 1; |
| 45 | linux_argc++; |
| 46 | } |
| 47 | |
| 48 | static void linux_cmdline_dump(void) |
| 49 | { |
| 50 | int i; |
| 51 | |
| 52 | debug("## cmdline argv at 0x%p, argp at 0x%p\n", |
| 53 | linux_argv, linux_argp); |
| 54 | |
| 55 | for (i = 1; i < linux_argc; i++) |
| 56 | debug(" arg %03d: %s\n", i, linux_argv[i]); |
| 57 | } |
| 58 | |
Simon Glass | df00afa | 2022-09-06 20:26:50 -0600 | [diff] [blame] | 59 | static void linux_cmdline_legacy(struct bootm_headers *images) |
Daniel Schwierzeck | eb782d6 | 2013-05-09 17:10:06 +0200 | [diff] [blame] | 60 | { |
| 61 | const char *bootargs, *next, *quote; |
| 62 | |
| 63 | linux_cmdline_init(); |
| 64 | |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 65 | bootargs = env_get("bootargs"); |
Daniel Schwierzeck | eb782d6 | 2013-05-09 17:10:06 +0200 | [diff] [blame] | 66 | if (!bootargs) |
| 67 | return; |
| 68 | |
| 69 | next = bootargs; |
| 70 | |
| 71 | while (bootargs && *bootargs && linux_argc < LINUX_MAX_ARGS) { |
| 72 | quote = strchr(bootargs, '"'); |
| 73 | next = strchr(bootargs, ' '); |
| 74 | |
| 75 | while (next && quote && quote < next) { |
| 76 | /* |
| 77 | * we found a left quote before the next blank |
| 78 | * now we have to find the matching right quote |
| 79 | */ |
| 80 | next = strchr(quote + 1, '"'); |
| 81 | if (next) { |
| 82 | quote = strchr(next + 1, '"'); |
| 83 | next = strchr(next + 1, ' '); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | if (!next) |
| 88 | next = bootargs + strlen(bootargs); |
| 89 | |
| 90 | linux_cmdline_set(bootargs, next - bootargs); |
| 91 | |
| 92 | if (*next) |
| 93 | next++; |
| 94 | |
| 95 | bootargs = next; |
| 96 | } |
Daniel Schwierzeck | f9749fa | 2015-01-14 21:44:13 +0100 | [diff] [blame] | 97 | } |
Daniel Schwierzeck | eb782d6 | 2013-05-09 17:10:06 +0200 | [diff] [blame] | 98 | |
Simon Glass | df00afa | 2022-09-06 20:26:50 -0600 | [diff] [blame] | 99 | static void linux_cmdline_append(struct bootm_headers *images) |
Daniel Schwierzeck | 2edd528 | 2015-01-14 21:44:13 +0100 | [diff] [blame] | 100 | { |
| 101 | char buf[24]; |
| 102 | ulong mem, rd_start, rd_size; |
| 103 | |
| 104 | /* append mem */ |
| 105 | mem = gd->ram_size >> 20; |
| 106 | sprintf(buf, "mem=%luM", mem); |
| 107 | linux_cmdline_set(buf, strlen(buf)); |
| 108 | |
| 109 | /* append rd_start and rd_size */ |
| 110 | rd_start = images->initrd_start; |
| 111 | rd_size = images->initrd_end - images->initrd_start; |
| 112 | |
| 113 | if (rd_size) { |
| 114 | sprintf(buf, "rd_start=0x%08lX", rd_start); |
| 115 | linux_cmdline_set(buf, strlen(buf)); |
| 116 | sprintf(buf, "rd_size=0x%lX", rd_size); |
| 117 | linux_cmdline_set(buf, strlen(buf)); |
| 118 | } |
| 119 | } |
| 120 | |
Daniel Schwierzeck | 46145fb | 2013-05-09 17:10:06 +0200 | [diff] [blame] | 121 | static void linux_env_init(void) |
| 122 | { |
| 123 | linux_env = (char **)(((ulong) linux_argp + 15) & ~15); |
| 124 | linux_env[0] = 0; |
| 125 | linux_env_p = (char *)(linux_env + LINUX_MAX_ENVS); |
| 126 | linux_env_idx = 0; |
| 127 | } |
| 128 | |
| 129 | static void linux_env_set(const char *env_name, const char *env_val) |
| 130 | { |
| 131 | if (linux_env_idx < LINUX_MAX_ENVS - 1) { |
| 132 | linux_env[linux_env_idx] = linux_env_p; |
| 133 | |
| 134 | strcpy(linux_env_p, env_name); |
| 135 | linux_env_p += strlen(env_name); |
| 136 | |
Daniel Schwierzeck | 735bb01 | 2015-11-01 17:36:15 +0100 | [diff] [blame] | 137 | if (CONFIG_IS_ENABLED(MALTA)) { |
Daniel Schwierzeck | 0dfa0b3 | 2013-05-30 19:04:20 +0200 | [diff] [blame] | 138 | linux_env_p++; |
| 139 | linux_env[++linux_env_idx] = linux_env_p; |
| 140 | } else { |
| 141 | *linux_env_p++ = '='; |
| 142 | } |
Daniel Schwierzeck | 46145fb | 2013-05-09 17:10:06 +0200 | [diff] [blame] | 143 | |
| 144 | strcpy(linux_env_p, env_val); |
| 145 | linux_env_p += strlen(env_val); |
| 146 | |
| 147 | linux_env_p++; |
| 148 | linux_env[++linux_env_idx] = 0; |
| 149 | } |
| 150 | } |
| 151 | |
Simon Glass | df00afa | 2022-09-06 20:26:50 -0600 | [diff] [blame] | 152 | static void linux_env_legacy(struct bootm_headers *images) |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 153 | { |
Daniel Schwierzeck | 83010eb | 2012-06-03 23:46:04 +0200 | [diff] [blame] | 154 | char env_buf[12]; |
Daniel Schwierzeck | 46145fb | 2013-05-09 17:10:06 +0200 | [diff] [blame] | 155 | const char *cp; |
Daniel Schwierzeck | eaadb1a | 2013-05-09 17:10:06 +0200 | [diff] [blame] | 156 | ulong rd_start, rd_size; |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 157 | |
Daniel Schwierzeck | 735bb01 | 2015-11-01 17:36:15 +0100 | [diff] [blame] | 158 | if (CONFIG_IS_ENABLED(MEMSIZE_IN_BYTES)) { |
| 159 | sprintf(env_buf, "%lu", (ulong)gd->ram_size); |
| 160 | debug("## Giving linux memsize in bytes, %lu\n", |
| 161 | (ulong)gd->ram_size); |
| 162 | } else { |
| 163 | sprintf(env_buf, "%lu", (ulong)(gd->ram_size >> 20)); |
| 164 | debug("## Giving linux memsize in MB, %lu\n", |
| 165 | (ulong)(gd->ram_size >> 20)); |
| 166 | } |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 167 | |
Daniel Schwierzeck | e61db37 | 2020-07-12 01:46:15 +0200 | [diff] [blame] | 168 | rd_start = CKSEG1ADDR(images->initrd_start); |
Daniel Schwierzeck | eaadb1a | 2013-05-09 17:10:06 +0200 | [diff] [blame] | 169 | rd_size = images->initrd_end - images->initrd_start; |
| 170 | |
Daniel Schwierzeck | 46145fb | 2013-05-09 17:10:06 +0200 | [diff] [blame] | 171 | linux_env_init(); |
| 172 | |
Daniel Schwierzeck | 83010eb | 2012-06-03 23:46:04 +0200 | [diff] [blame] | 173 | linux_env_set("memsize", env_buf); |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 174 | |
Daniel Schwierzeck | eaadb1a | 2013-05-09 17:10:06 +0200 | [diff] [blame] | 175 | sprintf(env_buf, "0x%08lX", rd_start); |
Daniel Schwierzeck | 83010eb | 2012-06-03 23:46:04 +0200 | [diff] [blame] | 176 | linux_env_set("initrd_start", env_buf); |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 177 | |
Daniel Schwierzeck | eaadb1a | 2013-05-09 17:10:06 +0200 | [diff] [blame] | 178 | sprintf(env_buf, "0x%lX", rd_size); |
Daniel Schwierzeck | 83010eb | 2012-06-03 23:46:04 +0200 | [diff] [blame] | 179 | linux_env_set("initrd_size", env_buf); |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 180 | |
Daniel Schwierzeck | 83010eb | 2012-06-03 23:46:04 +0200 | [diff] [blame] | 181 | sprintf(env_buf, "0x%08X", (uint) (gd->bd->bi_flashstart)); |
| 182 | linux_env_set("flash_start", env_buf); |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 183 | |
Daniel Schwierzeck | 83010eb | 2012-06-03 23:46:04 +0200 | [diff] [blame] | 184 | sprintf(env_buf, "0x%X", (uint) (gd->bd->bi_flashsize)); |
| 185 | linux_env_set("flash_size", env_buf); |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 186 | |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 187 | cp = env_get("ethaddr"); |
Daniel Schwierzeck | 83010eb | 2012-06-03 23:46:04 +0200 | [diff] [blame] | 188 | if (cp) |
Jason McMullan | cfbe457 | 2008-06-08 23:56:00 -0400 | [diff] [blame] | 189 | linux_env_set("ethaddr", cp); |
Jason McMullan | cfbe457 | 2008-06-08 23:56:00 -0400 | [diff] [blame] | 190 | |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 191 | cp = env_get("eth1addr"); |
Daniel Schwierzeck | 83010eb | 2012-06-03 23:46:04 +0200 | [diff] [blame] | 192 | if (cp) |
Jason McMullan | cfbe457 | 2008-06-08 23:56:00 -0400 | [diff] [blame] | 193 | linux_env_set("eth1addr", cp); |
Daniel Schwierzeck | 0dfa0b3 | 2013-05-30 19:04:20 +0200 | [diff] [blame] | 194 | |
Daniel Schwierzeck | 735bb01 | 2015-11-01 17:36:15 +0100 | [diff] [blame] | 195 | if (CONFIG_IS_ENABLED(MALTA)) { |
Paul Burton | 43c4f59 | 2013-11-26 17:45:25 +0000 | [diff] [blame] | 196 | sprintf(env_buf, "%un8r", gd->baudrate); |
| 197 | linux_env_set("modetty0", env_buf); |
| 198 | } |
Daniel Schwierzeck | 20a8b1c | 2015-11-01 17:36:14 +0100 | [diff] [blame] | 199 | } |
| 200 | |
Simon Glass | df00afa | 2022-09-06 20:26:50 -0600 | [diff] [blame] | 201 | static int boot_reloc_fdt(struct bootm_headers *images) |
Daniel Schwierzeck | 20a8b1c | 2015-11-01 17:36:14 +0100 | [diff] [blame] | 202 | { |
| 203 | /* |
| 204 | * In case of legacy uImage's, relocation of FDT is already done |
Simon Glass | d90f94f | 2023-12-15 20:14:19 -0700 | [diff] [blame] | 205 | * by bootm_run_states() and should not repeated in 'bootm prep'. |
Daniel Schwierzeck | 20a8b1c | 2015-11-01 17:36:14 +0100 | [diff] [blame] | 206 | */ |
| 207 | if (images->state & BOOTM_STATE_FDT) { |
| 208 | debug("## FDT already relocated\n"); |
| 209 | return 0; |
| 210 | } |
| 211 | |
| 212 | #if CONFIG_IS_ENABLED(MIPS_BOOT_FDT) && CONFIG_IS_ENABLED(OF_LIBFDT) |
Sughosh Ganu | 291bf9c | 2024-08-26 17:29:18 +0530 | [diff] [blame] | 213 | boot_fdt_add_mem_rsv_regions(images->ft_addr); |
| 214 | return boot_relocate_fdt(&images->ft_addr, &images->ft_len); |
Daniel Schwierzeck | 20a8b1c | 2015-11-01 17:36:14 +0100 | [diff] [blame] | 215 | #else |
| 216 | return 0; |
| 217 | #endif |
| 218 | } |
| 219 | |
Alexey Brodkin | 91a3159 | 2018-01-24 20:47:09 +0300 | [diff] [blame] | 220 | #if CONFIG_IS_ENABLED(MIPS_BOOT_FDT) && CONFIG_IS_ENABLED(OF_LIBFDT) |
Purna Chandra Mandal | 432549f | 2016-04-18 18:31:38 +0530 | [diff] [blame] | 221 | int arch_fixup_fdt(void *blob) |
Daniel Schwierzeck | 20a8b1c | 2015-11-01 17:36:14 +0100 | [diff] [blame] | 222 | { |
Stefan Roese | a13a2aa | 2020-08-12 13:16:36 +0200 | [diff] [blame] | 223 | u64 mem_start = virt_to_phys((void *)gd->ram_base); |
Daniel Schwierzeck | 20a8b1c | 2015-11-01 17:36:14 +0100 | [diff] [blame] | 224 | u64 mem_size = gd->ram_size; |
| 225 | |
| 226 | return fdt_fixup_memory_banks(blob, &mem_start, &mem_size, 1); |
Gabor Juhos | 72cb5f0 | 2013-01-07 02:53:41 +0000 | [diff] [blame] | 227 | } |
Alexey Brodkin | 91a3159 | 2018-01-24 20:47:09 +0300 | [diff] [blame] | 228 | #endif |
Gabor Juhos | 72cb5f0 | 2013-01-07 02:53:41 +0000 | [diff] [blame] | 229 | |
Simon Glass | df00afa | 2022-09-06 20:26:50 -0600 | [diff] [blame] | 230 | static int boot_setup_fdt(struct bootm_headers *images) |
Daniel Schwierzeck | 20a8b1c | 2015-11-01 17:36:14 +0100 | [diff] [blame] | 231 | { |
Horatiu Vultur | 3639e4e | 2019-04-24 17:21:29 +0200 | [diff] [blame] | 232 | images->initrd_start = virt_to_phys((void *)images->initrd_start); |
| 233 | images->initrd_end = virt_to_phys((void *)images->initrd_end); |
Simon Glass | 30762dd | 2023-11-12 08:27:44 -0700 | [diff] [blame] | 234 | |
Sughosh Ganu | 291bf9c | 2024-08-26 17:29:18 +0530 | [diff] [blame] | 235 | return image_setup_libfdt(images, images->ft_addr, true); |
Daniel Schwierzeck | 20a8b1c | 2015-11-01 17:36:14 +0100 | [diff] [blame] | 236 | } |
| 237 | |
Simon Glass | df00afa | 2022-09-06 20:26:50 -0600 | [diff] [blame] | 238 | static void boot_prep_linux(struct bootm_headers *images) |
Daniel Schwierzeck | c07dc60 | 2015-01-14 21:44:13 +0100 | [diff] [blame] | 239 | { |
Daniel Schwierzeck | 20a8b1c | 2015-11-01 17:36:14 +0100 | [diff] [blame] | 240 | if (CONFIG_IS_ENABLED(MIPS_BOOT_FDT) && images->ft_len) { |
| 241 | boot_reloc_fdt(images); |
Daniel Schwierzeck | 8d7ff4d | 2015-01-14 21:44:13 +0100 | [diff] [blame] | 242 | boot_setup_fdt(images); |
Daniel Schwierzeck | 20a8b1c | 2015-11-01 17:36:14 +0100 | [diff] [blame] | 243 | } else { |
Daniel Schwierzeck | 20a8b1c | 2015-11-01 17:36:14 +0100 | [diff] [blame] | 244 | if (CONFIG_IS_ENABLED(MIPS_BOOT_CMDLINE_LEGACY)) { |
| 245 | linux_cmdline_legacy(images); |
| 246 | |
Zubair Lutfullah Kakakhel | 4c55ab4 | 2017-07-11 16:47:51 +0100 | [diff] [blame] | 247 | if (!CONFIG_IS_ENABLED(MIPS_BOOT_ENV_LEGACY)) |
Daniel Schwierzeck | 20a8b1c | 2015-11-01 17:36:14 +0100 | [diff] [blame] | 248 | linux_cmdline_append(images); |
| 249 | |
| 250 | linux_cmdline_dump(); |
| 251 | } |
Zubair Lutfullah Kakakhel | 4c55ab4 | 2017-07-11 16:47:51 +0100 | [diff] [blame] | 252 | |
| 253 | if (CONFIG_IS_ENABLED(MIPS_BOOT_ENV_LEGACY)) |
| 254 | linux_env_legacy(images); |
Daniel Schwierzeck | 20a8b1c | 2015-11-01 17:36:14 +0100 | [diff] [blame] | 255 | } |
Daniel Schwierzeck | c07dc60 | 2015-01-14 21:44:13 +0100 | [diff] [blame] | 256 | } |
| 257 | |
Simon Glass | df00afa | 2022-09-06 20:26:50 -0600 | [diff] [blame] | 258 | static void boot_jump_linux(struct bootm_headers *images) |
Gabor Juhos | 72cb5f0 | 2013-01-07 02:53:41 +0000 | [diff] [blame] | 259 | { |
Daniel Schwierzeck | 0b95a7c | 2013-05-09 17:10:06 +0200 | [diff] [blame] | 260 | typedef void __noreturn (*kernel_entry_t)(int, ulong, ulong, ulong); |
| 261 | kernel_entry_t kernel = (kernel_entry_t) images->ep; |
Daniel Schwierzeck | 0dfa0b3 | 2013-05-30 19:04:20 +0200 | [diff] [blame] | 262 | ulong linux_extra = 0; |
Gabor Juhos | 72cb5f0 | 2013-01-07 02:53:41 +0000 | [diff] [blame] | 263 | |
Daniel Schwierzeck | 0b95a7c | 2013-05-09 17:10:06 +0200 | [diff] [blame] | 264 | debug("## Transferring control to Linux (at address %p) ...\n", kernel); |
Gabor Juhos | 72cb5f0 | 2013-01-07 02:53:41 +0000 | [diff] [blame] | 265 | |
| 266 | bootstage_mark(BOOTSTAGE_ID_RUN_OS); |
| 267 | |
Daniel Schwierzeck | 735bb01 | 2015-11-01 17:36:15 +0100 | [diff] [blame] | 268 | if (CONFIG_IS_ENABLED(MALTA)) |
Daniel Schwierzeck | 0dfa0b3 | 2013-05-30 19:04:20 +0200 | [diff] [blame] | 269 | linux_extra = gd->ram_size; |
| 270 | |
Simon Glass | f499b4d | 2023-02-05 15:36:19 -0700 | [diff] [blame] | 271 | #if IS_ENABLED(CONFIG_BOOTSTAGE_FDT) |
Daniel Schwierzeck | 1a4797c | 2015-01-14 21:44:13 +0100 | [diff] [blame] | 272 | bootstage_fdt_add_report(); |
| 273 | #endif |
Simon Glass | cd19795 | 2023-02-05 15:36:20 -0700 | [diff] [blame] | 274 | #if IS_ENABLED(CONFIG_BOOTSTAGE_REPORT) |
Daniel Schwierzeck | 1a4797c | 2015-01-14 21:44:13 +0100 | [diff] [blame] | 275 | bootstage_report(); |
| 276 | #endif |
Gabor Juhos | 72cb5f0 | 2013-01-07 02:53:41 +0000 | [diff] [blame] | 277 | |
developer | 5cbbd71 | 2020-04-21 09:28:25 +0200 | [diff] [blame] | 278 | if (CONFIG_IS_ENABLED(RESTORE_EXCEPTION_VECTOR_BASE)) |
| 279 | trap_restore(); |
| 280 | |
Daniel Schwierzeck | d1b29d2 | 2015-02-22 16:58:30 +0100 | [diff] [blame] | 281 | if (images->ft_len) |
| 282 | kernel(-2, (ulong)images->ft_addr, 0, 0); |
| 283 | else |
| 284 | kernel(linux_argc, (ulong)linux_argv, (ulong)linux_env, |
| 285 | linux_extra); |
Gabor Juhos | 72cb5f0 | 2013-01-07 02:53:41 +0000 | [diff] [blame] | 286 | } |
| 287 | |
Simon Glass | 0726d9d | 2023-12-15 20:14:13 -0700 | [diff] [blame] | 288 | int do_bootm_linux(int flag, struct bootm_info *bmi) |
Gabor Juhos | 72cb5f0 | 2013-01-07 02:53:41 +0000 | [diff] [blame] | 289 | { |
Simon Glass | 0726d9d | 2023-12-15 20:14:13 -0700 | [diff] [blame] | 290 | struct bootm_headers *images = bmi->images; |
| 291 | |
Gabor Juhos | 7f959fd | 2013-01-07 02:53:42 +0000 | [diff] [blame] | 292 | /* No need for those on MIPS */ |
Daniel Schwierzeck | eb782d6 | 2013-05-09 17:10:06 +0200 | [diff] [blame] | 293 | if (flag & BOOTM_STATE_OS_BD_T) |
Gabor Juhos | 7f959fd | 2013-01-07 02:53:42 +0000 | [diff] [blame] | 294 | return -1; |
| 295 | |
Daniel Schwierzeck | 20a8b1c | 2015-11-01 17:36:14 +0100 | [diff] [blame] | 296 | /* |
| 297 | * Cmdline init has been moved to 'bootm prep' because it has to be |
| 298 | * done after relocation of ramdisk to always pass correct values |
| 299 | * for rd_start and rd_size to Linux kernel. |
| 300 | */ |
| 301 | if (flag & BOOTM_STATE_OS_CMDLINE) |
Daniel Schwierzeck | eb782d6 | 2013-05-09 17:10:06 +0200 | [diff] [blame] | 302 | return 0; |
Daniel Schwierzeck | eb782d6 | 2013-05-09 17:10:06 +0200 | [diff] [blame] | 303 | |
Gabor Juhos | 7f959fd | 2013-01-07 02:53:42 +0000 | [diff] [blame] | 304 | if (flag & BOOTM_STATE_OS_PREP) { |
| 305 | boot_prep_linux(images); |
| 306 | return 0; |
| 307 | } |
| 308 | |
Daniel Schwierzeck | 20a8b1c | 2015-11-01 17:36:14 +0100 | [diff] [blame] | 309 | if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) { |
Gabor Juhos | 7f959fd | 2013-01-07 02:53:42 +0000 | [diff] [blame] | 310 | boot_jump_linux(images); |
| 311 | return 0; |
| 312 | } |
Jason McMullan | cfbe457 | 2008-06-08 23:56:00 -0400 | [diff] [blame] | 313 | |
Marian Balakowicz | df8ff33 | 2008-03-12 10:33:00 +0100 | [diff] [blame] | 314 | /* does not return */ |
Kumar Gala | 48626aa | 2008-08-15 08:24:45 -0500 | [diff] [blame] | 315 | return 1; |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 316 | } |