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