]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
b6396403 SG |
2 | /* |
3 | * (C) Copyright 2000-2009 | |
4 | * Wolfgang Denk, DENX Software Engineering, [email protected]. | |
b6396403 SG |
5 | */ |
6 | ||
b6396403 | 7 | #include <bootm.h> |
52f24238 | 8 | #include <bootstage.h> |
9edefc27 | 9 | #include <cpu_func.h> |
ecc7fdaa | 10 | #include <efi_loader.h> |
2abf14df | 11 | #include <elf.h> |
c7694dd4 | 12 | #include <env.h> |
b6396403 | 13 | #include <fdt_support.h> |
4d72caa5 SG |
14 | #include <image.h> |
15 | #include <lmb.h> | |
f7ae49fc | 16 | #include <log.h> |
401d1c4f | 17 | #include <asm/global_data.h> |
b08c8c48 | 18 | #include <linux/libfdt.h> |
b6396403 | 19 | #include <malloc.h> |
ecc7fdaa | 20 | #include <mapmem.h> |
b6396403 | 21 | #include <vxworks.h> |
c225e7cf | 22 | #include <tee/optee.h> |
b6396403 SG |
23 | |
24 | DECLARE_GLOBAL_DATA_PTR; | |
25 | ||
a48336e5 | 26 | static int do_bootm_standalone(int flag, struct bootm_info *bmi) |
b6396403 | 27 | { |
a48336e5 | 28 | struct bootm_headers *images = bmi->images; |
b6396403 SG |
29 | int (*appl)(int, char *const[]); |
30 | ||
78398652 | 31 | if (!env_get_autostart()) { |
018f5303 | 32 | env_set_hex("filesize", images->os.image_len); |
b6396403 SG |
33 | return 0; |
34 | } | |
35 | appl = (int (*)(int, char * const []))images->ep; | |
a48336e5 | 36 | appl(bmi->argc, bmi->argv); |
b6396403 SG |
37 | return 0; |
38 | } | |
39 | ||
40 | /*******************************************************************/ | |
41 | /* OS booting routines */ | |
42 | /*******************************************************************/ | |
43 | ||
44 | #if defined(CONFIG_BOOTM_NETBSD) || defined(CONFIG_BOOTM_PLAN9) | |
09140113 | 45 | static void copy_args(char *dest, int argc, char *const argv[], char delim) |
b6396403 SG |
46 | { |
47 | int i; | |
48 | ||
49 | for (i = 0; i < argc; i++) { | |
50 | if (i > 0) | |
51 | *dest++ = delim; | |
52 | strcpy(dest, argv[i]); | |
53 | dest += strlen(argv[i]); | |
54 | } | |
55 | } | |
56 | #endif | |
57 | ||
0ab5e027 SG |
58 | static void __maybe_unused fit_unsupported_reset(const char *msg) |
59 | { | |
60 | if (CONFIG_IS_ENABLED(FIT_VERBOSE)) { | |
61 | printf("! FIT images not supported for '%s' - must reset board to recover!\n", | |
62 | msg); | |
63 | } | |
64 | } | |
65 | ||
b6396403 | 66 | #ifdef CONFIG_BOOTM_NETBSD |
a48336e5 | 67 | static int do_bootm_netbsd(int flag, struct bootm_info *bmi) |
b6396403 | 68 | { |
a48336e5 | 69 | struct bootm_headers *images = bmi->images; |
f3543e69 SG |
70 | void (*loader)(struct bd_info *bd, struct legacy_img_hdr *hdr, |
71 | char *console, char *cmdline); | |
72 | struct legacy_img_hdr *os_hdr, *hdr; | |
b6396403 | 73 | ulong kernel_data, kernel_len; |
b6396403 SG |
74 | char *cmdline; |
75 | ||
76 | if (flag != BOOTM_STATE_OS_GO) | |
77 | return 0; | |
78 | ||
79 | #if defined(CONFIG_FIT) | |
80 | if (!images->legacy_hdr_valid) { | |
81 | fit_unsupported_reset("NetBSD"); | |
82 | return 1; | |
83 | } | |
84 | #endif | |
85 | hdr = images->legacy_hdr_os; | |
86 | ||
87 | /* | |
88 | * Booting a (NetBSD) kernel image | |
89 | * | |
90 | * This process is pretty similar to a standalone application: | |
91 | * The (first part of an multi-) image must be a stage-2 loader, | |
92 | * which in turn is responsible for loading & invoking the actual | |
93 | * kernel. The only differences are the parameters being passed: | |
94 | * besides the board info strucure, the loader expects a command | |
95 | * line, the name of the console device, and (optionally) the | |
96 | * address of the original image header. | |
97 | */ | |
98 | os_hdr = NULL; | |
99 | if (image_check_type(&images->legacy_hdr_os_copy, IH_TYPE_MULTI)) { | |
100 | image_multi_getimg(hdr, 1, &kernel_data, &kernel_len); | |
101 | if (kernel_len) | |
102 | os_hdr = hdr; | |
103 | } | |
104 | ||
a48336e5 | 105 | if (bmi->argc > 0) { |
b6396403 SG |
106 | ulong len; |
107 | int i; | |
108 | ||
a48336e5 SG |
109 | for (i = 0, len = 0; i < bmi->argc; i += 1) |
110 | len += strlen(bmi->argv[i]) + 1; | |
b6396403 | 111 | cmdline = malloc(len); |
a48336e5 | 112 | copy_args(cmdline, bmi->argc, bmi->argv, ' '); |
b6396403 | 113 | } else { |
00caae6d | 114 | cmdline = env_get("bootargs"); |
b6396403 SG |
115 | if (cmdline == NULL) |
116 | cmdline = ""; | |
117 | } | |
118 | ||
f3543e69 | 119 | loader = (void (*)(struct bd_info *, struct legacy_img_hdr *, char *, char *))images->ep; |
b6396403 SG |
120 | |
121 | printf("## Transferring control to NetBSD stage-2 loader (at address %08lx) ...\n", | |
122 | (ulong)loader); | |
123 | ||
124 | bootstage_mark(BOOTSTAGE_ID_RUN_OS); | |
125 | ||
126 | /* | |
127 | * NetBSD Stage-2 Loader Parameters: | |
128 | * arg[0]: pointer to board info data | |
129 | * arg[1]: image load address | |
130 | * arg[2]: char pointer to the console device to use | |
131 | * arg[3]: char pointer to the boot arguments | |
132 | */ | |
5b8e76c3 | 133 | (*loader)(gd->bd, os_hdr, "", cmdline); |
b6396403 SG |
134 | |
135 | return 1; | |
136 | } | |
137 | #endif /* CONFIG_BOOTM_NETBSD*/ | |
138 | ||
b6396403 | 139 | #ifdef CONFIG_BOOTM_RTEMS |
a48336e5 | 140 | static int do_bootm_rtems(int flag, struct bootm_info *bmi) |
b6396403 | 141 | { |
a48336e5 | 142 | struct bootm_headers *images = bmi->images; |
b75d8dc5 | 143 | void (*entry_point)(struct bd_info *); |
b6396403 SG |
144 | |
145 | if (flag != BOOTM_STATE_OS_GO) | |
146 | return 0; | |
147 | ||
148 | #if defined(CONFIG_FIT) | |
149 | if (!images->legacy_hdr_valid) { | |
150 | fit_unsupported_reset("RTEMS"); | |
151 | return 1; | |
152 | } | |
153 | #endif | |
154 | ||
b75d8dc5 | 155 | entry_point = (void (*)(struct bd_info *))images->ep; |
b6396403 SG |
156 | |
157 | printf("## Transferring control to RTEMS (at address %08lx) ...\n", | |
158 | (ulong)entry_point); | |
159 | ||
160 | bootstage_mark(BOOTSTAGE_ID_RUN_OS); | |
161 | ||
162 | /* | |
163 | * RTEMS Parameters: | |
164 | * r3: ptr to board info data | |
165 | */ | |
166 | (*entry_point)(gd->bd); | |
167 | ||
168 | return 1; | |
169 | } | |
170 | #endif /* CONFIG_BOOTM_RTEMS */ | |
171 | ||
172 | #if defined(CONFIG_BOOTM_OSE) | |
a48336e5 | 173 | static int do_bootm_ose(int flag, struct bootm_info *bmi) |
b6396403 | 174 | { |
a48336e5 | 175 | struct bootm_headers *images = bmi->images; |
b6396403 SG |
176 | void (*entry_point)(void); |
177 | ||
178 | if (flag != BOOTM_STATE_OS_GO) | |
179 | return 0; | |
180 | ||
181 | #if defined(CONFIG_FIT) | |
182 | if (!images->legacy_hdr_valid) { | |
183 | fit_unsupported_reset("OSE"); | |
184 | return 1; | |
185 | } | |
186 | #endif | |
187 | ||
188 | entry_point = (void (*)(void))images->ep; | |
189 | ||
190 | printf("## Transferring control to OSE (at address %08lx) ...\n", | |
191 | (ulong)entry_point); | |
192 | ||
193 | bootstage_mark(BOOTSTAGE_ID_RUN_OS); | |
194 | ||
195 | /* | |
196 | * OSE Parameters: | |
197 | * None | |
198 | */ | |
199 | (*entry_point)(); | |
200 | ||
201 | return 1; | |
202 | } | |
203 | #endif /* CONFIG_BOOTM_OSE */ | |
204 | ||
205 | #if defined(CONFIG_BOOTM_PLAN9) | |
a48336e5 | 206 | static int do_bootm_plan9(int flag, struct bootm_info *bmi) |
b6396403 | 207 | { |
a48336e5 | 208 | struct bootm_headers *images = bmi->images; |
b6396403 SG |
209 | void (*entry_point)(void); |
210 | char *s; | |
211 | ||
212 | if (flag != BOOTM_STATE_OS_GO) | |
213 | return 0; | |
214 | ||
215 | #if defined(CONFIG_FIT) | |
216 | if (!images->legacy_hdr_valid) { | |
217 | fit_unsupported_reset("Plan 9"); | |
218 | return 1; | |
219 | } | |
220 | #endif | |
221 | ||
222 | /* See README.plan9 */ | |
00caae6d | 223 | s = env_get("confaddr"); |
b6396403 | 224 | if (s != NULL) { |
7e5f460e | 225 | char *confaddr = (char *)hextoul(s, NULL); |
b6396403 | 226 | |
a48336e5 SG |
227 | if (bmi->argc) { |
228 | copy_args(confaddr, bmi->argc, bmi->argv, '\n'); | |
b6396403 | 229 | } else { |
00caae6d | 230 | s = env_get("bootargs"); |
b6396403 SG |
231 | if (s != NULL) |
232 | strcpy(confaddr, s); | |
233 | } | |
234 | } | |
235 | ||
236 | entry_point = (void (*)(void))images->ep; | |
237 | ||
238 | printf("## Transferring control to Plan 9 (at address %08lx) ...\n", | |
239 | (ulong)entry_point); | |
240 | ||
241 | bootstage_mark(BOOTSTAGE_ID_RUN_OS); | |
242 | ||
243 | /* | |
244 | * Plan 9 Parameters: | |
245 | * None | |
246 | */ | |
247 | (*entry_point)(); | |
248 | ||
249 | return 1; | |
250 | } | |
251 | #endif /* CONFIG_BOOTM_PLAN9 */ | |
252 | ||
253 | #if defined(CONFIG_BOOTM_VXWORKS) && \ | |
254 | (defined(CONFIG_PPC) || defined(CONFIG_ARM)) | |
255 | ||
d9d7c20b | 256 | static void do_bootvx_fdt(struct bootm_headers *images) |
b6396403 SG |
257 | { |
258 | #if defined(CONFIG_OF_LIBFDT) | |
259 | int ret; | |
260 | char *bootline; | |
261 | ulong of_size = images->ft_len; | |
262 | char **of_flat_tree = &images->ft_addr; | |
263 | struct lmb *lmb = &images->lmb; | |
264 | ||
265 | if (*of_flat_tree) { | |
266 | boot_fdt_add_mem_rsv_regions(lmb, *of_flat_tree); | |
267 | ||
268 | ret = boot_relocate_fdt(lmb, of_flat_tree, &of_size); | |
269 | if (ret) | |
270 | return; | |
271 | ||
a223e2bc HS |
272 | /* Update ethernet nodes */ |
273 | fdt_fixup_ethernet(*of_flat_tree); | |
274 | ||
b6396403 SG |
275 | ret = fdt_add_subnode(*of_flat_tree, 0, "chosen"); |
276 | if ((ret >= 0 || ret == -FDT_ERR_EXISTS)) { | |
00caae6d | 277 | bootline = env_get("bootargs"); |
b6396403 SG |
278 | if (bootline) { |
279 | ret = fdt_find_and_setprop(*of_flat_tree, | |
280 | "/chosen", "bootargs", | |
281 | bootline, | |
282 | strlen(bootline) + 1, 1); | |
283 | if (ret < 0) { | |
284 | printf("## ERROR: %s : %s\n", __func__, | |
285 | fdt_strerror(ret)); | |
286 | return; | |
287 | } | |
288 | } | |
289 | } else { | |
290 | printf("## ERROR: %s : %s\n", __func__, | |
291 | fdt_strerror(ret)); | |
292 | return; | |
293 | } | |
294 | } | |
295 | #endif | |
296 | ||
297 | boot_prep_vxworks(images); | |
298 | ||
299 | bootstage_mark(BOOTSTAGE_ID_RUN_OS); | |
300 | ||
301 | #if defined(CONFIG_OF_LIBFDT) | |
302 | printf("## Starting vxWorks at 0x%08lx, device tree at 0x%08lx ...\n", | |
303 | (ulong)images->ep, (ulong)*of_flat_tree); | |
304 | #else | |
305 | printf("## Starting vxWorks at 0x%08lx\n", (ulong)images->ep); | |
306 | #endif | |
efc3f952 | 307 | flush(); |
b6396403 SG |
308 | |
309 | boot_jump_vxworks(images); | |
310 | ||
311 | puts("## vxWorks terminated\n"); | |
312 | } | |
313 | ||
a48336e5 | 314 | static int do_bootm_vxworks_legacy(int flag, struct bootm_info *bmi) |
b6396403 | 315 | { |
a48336e5 SG |
316 | struct bootm_headers *images = bmi->images; |
317 | ||
b6396403 SG |
318 | if (flag != BOOTM_STATE_OS_GO) |
319 | return 0; | |
320 | ||
b6396403 SG |
321 | do_bootvx_fdt(images); |
322 | ||
323 | return 1; | |
324 | } | |
1e26f648 | 325 | |
a48336e5 | 326 | int do_bootm_vxworks(int flag, struct bootm_info *bmi) |
1e26f648 LZ |
327 | { |
328 | char *bootargs; | |
329 | int pos; | |
330 | unsigned long vxflags; | |
331 | bool std_dtb = false; | |
332 | ||
333 | /* get bootargs env */ | |
334 | bootargs = env_get("bootargs"); | |
335 | ||
336 | if (bootargs != NULL) { | |
337 | for (pos = 0; pos < strlen(bootargs); pos++) { | |
338 | /* find f=0xnumber flag */ | |
339 | if ((bootargs[pos] == '=') && (pos >= 1) && | |
340 | (bootargs[pos - 1] == 'f')) { | |
7e5f460e | 341 | vxflags = hextoul(&bootargs[pos + 1], NULL); |
1e26f648 LZ |
342 | if (vxflags & VXWORKS_SYSFLG_STD_DTB) |
343 | std_dtb = true; | |
344 | } | |
345 | } | |
346 | } | |
347 | ||
348 | if (std_dtb) { | |
349 | if (flag & BOOTM_STATE_OS_PREP) | |
350 | printf(" Using standard DTB\n"); | |
a48336e5 | 351 | return do_bootm_linux(flag, bmi); |
1e26f648 LZ |
352 | } else { |
353 | if (flag & BOOTM_STATE_OS_PREP) | |
354 | printf(" !!! WARNING !!! Using legacy DTB\n"); | |
a48336e5 | 355 | return do_bootm_vxworks_legacy(flag, bmi); |
1e26f648 LZ |
356 | } |
357 | } | |
b6396403 SG |
358 | #endif |
359 | ||
360 | #if defined(CONFIG_CMD_ELF) | |
a48336e5 | 361 | static int do_bootm_qnxelf(int flag, struct bootm_info *bmi) |
b6396403 | 362 | { |
a48336e5 | 363 | struct bootm_headers *images = bmi->images; |
b6396403 SG |
364 | char *local_args[2]; |
365 | char str[16]; | |
995eab8b | 366 | int dcache; |
b6396403 SG |
367 | |
368 | if (flag != BOOTM_STATE_OS_GO) | |
369 | return 0; | |
370 | ||
371 | #if defined(CONFIG_FIT) | |
372 | if (!images->legacy_hdr_valid) { | |
373 | fit_unsupported_reset("QNX"); | |
374 | return 1; | |
375 | } | |
376 | #endif | |
377 | ||
378 | sprintf(str, "%lx", images->ep); /* write entry-point into string */ | |
a48336e5 | 379 | local_args[0] = bmi->argv[0]; |
b6396403 | 380 | local_args[1] = str; /* and provide it via the arguments */ |
995eab8b EV |
381 | |
382 | /* | |
383 | * QNX images require the data cache is disabled. | |
384 | */ | |
385 | dcache = dcache_status(); | |
386 | if (dcache) | |
387 | dcache_disable(); | |
388 | ||
b6396403 SG |
389 | do_bootelf(NULL, 0, 2, local_args); |
390 | ||
995eab8b EV |
391 | if (dcache) |
392 | dcache_enable(); | |
393 | ||
b6396403 SG |
394 | return 1; |
395 | } | |
396 | #endif | |
397 | ||
2abf14df MM |
398 | #if defined(CONFIG_BOOTM_ELF) |
399 | static int do_bootm_elf(int flag, struct bootm_info *bmi) | |
400 | { | |
401 | Bootelf_flags flags = { .autostart = 1 }; | |
402 | ||
403 | if (flag != BOOTM_STATE_OS_GO) | |
404 | return 0; | |
405 | ||
406 | bootelf(bmi->images->ep, flags, 0, NULL); | |
407 | ||
408 | return 1; | |
409 | } | |
410 | #endif | |
411 | ||
b6396403 | 412 | #ifdef CONFIG_INTEGRITY |
a48336e5 | 413 | static int do_bootm_integrity(int flag, struct bootm_info *bmi) |
b6396403 | 414 | { |
a48336e5 | 415 | struct bootm_headers *images = bmi->images; |
b6396403 SG |
416 | void (*entry_point)(void); |
417 | ||
418 | if (flag != BOOTM_STATE_OS_GO) | |
419 | return 0; | |
420 | ||
421 | #if defined(CONFIG_FIT) | |
422 | if (!images->legacy_hdr_valid) { | |
423 | fit_unsupported_reset("INTEGRITY"); | |
424 | return 1; | |
425 | } | |
426 | #endif | |
427 | ||
428 | entry_point = (void (*)(void))images->ep; | |
429 | ||
430 | printf("## Transferring control to INTEGRITY (at address %08lx) ...\n", | |
431 | (ulong)entry_point); | |
432 | ||
433 | bootstage_mark(BOOTSTAGE_ID_RUN_OS); | |
434 | ||
435 | /* | |
436 | * INTEGRITY Parameters: | |
437 | * None | |
438 | */ | |
439 | (*entry_point)(); | |
440 | ||
441 | return 1; | |
442 | } | |
443 | #endif | |
444 | ||
67ddd955 | 445 | #ifdef CONFIG_BOOTM_OPENRTOS |
a48336e5 | 446 | static int do_bootm_openrtos(int flag, struct bootm_info *bmi) |
67ddd955 | 447 | { |
a48336e5 | 448 | struct bootm_headers *images = bmi->images; |
67ddd955 MV |
449 | void (*entry_point)(void); |
450 | ||
451 | if (flag != BOOTM_STATE_OS_GO) | |
452 | return 0; | |
453 | ||
454 | entry_point = (void (*)(void))images->ep; | |
455 | ||
456 | printf("## Transferring control to OpenRTOS (at address %08lx) ...\n", | |
457 | (ulong)entry_point); | |
458 | ||
459 | bootstage_mark(BOOTSTAGE_ID_RUN_OS); | |
460 | ||
461 | /* | |
462 | * OpenRTOS Parameters: | |
463 | * None | |
464 | */ | |
465 | (*entry_point)(); | |
466 | ||
467 | return 1; | |
468 | } | |
469 | #endif | |
470 | ||
c225e7cf | 471 | #ifdef CONFIG_BOOTM_OPTEE |
a48336e5 | 472 | static int do_bootm_tee(int flag, struct bootm_info *bmi) |
c225e7cf | 473 | { |
a48336e5 | 474 | struct bootm_headers *images = bmi->images; |
c225e7cf BD |
475 | int ret; |
476 | ||
c225e7cf BD |
477 | /* Validate OPTEE header */ |
478 | ret = optee_verify_bootm_image(images->os.image_start, | |
479 | images->os.load, | |
480 | images->os.image_len); | |
481 | if (ret) | |
482 | return ret; | |
483 | ||
c225e7cf | 484 | /* From here we can run the regular linux boot path */ |
a48336e5 | 485 | return do_bootm_linux(flag, bmi); |
c225e7cf BD |
486 | } |
487 | #endif | |
488 | ||
ecc7fdaa | 489 | #ifdef CONFIG_BOOTM_EFI |
a48336e5 | 490 | static int do_bootm_efi(int flag, struct bootm_info *bmi) |
ecc7fdaa | 491 | { |
a48336e5 | 492 | struct bootm_headers *images = bmi->images; |
7017fc54 | 493 | int ret; |
ecc7fdaa CC |
494 | void *image_buf; |
495 | ||
496 | if (flag != BOOTM_STATE_OS_GO) | |
497 | return 0; | |
498 | ||
7017fc54 AT |
499 | /* We expect to return */ |
500 | images->os.type = IH_TYPE_STANDALONE; | |
ecc7fdaa | 501 | |
7017fc54 | 502 | image_buf = map_sysmem(images->ep, images->os.image_len); |
ecc7fdaa CC |
503 | |
504 | /* Run EFI image */ | |
505 | printf("## Transferring control to EFI (at address %08lx) ...\n", | |
506 | images->ep); | |
507 | bootstage_mark(BOOTSTAGE_ID_RUN_OS); | |
508 | ||
7017fc54 AT |
509 | ret = efi_binary_run(image_buf, images->os.image_len, |
510 | images->ft_len | |
511 | ? images->ft_addr : EFI_FDT_USE_INTERNAL); | |
bf758125 | 512 | |
7017fc54 | 513 | return ret; |
ecc7fdaa CC |
514 | } |
515 | #endif | |
516 | ||
b6396403 SG |
517 | static boot_os_fn *boot_os[] = { |
518 | [IH_OS_U_BOOT] = do_bootm_standalone, | |
519 | #ifdef CONFIG_BOOTM_LINUX | |
520 | [IH_OS_LINUX] = do_bootm_linux, | |
521 | #endif | |
522 | #ifdef CONFIG_BOOTM_NETBSD | |
523 | [IH_OS_NETBSD] = do_bootm_netbsd, | |
524 | #endif | |
b6396403 SG |
525 | #ifdef CONFIG_BOOTM_RTEMS |
526 | [IH_OS_RTEMS] = do_bootm_rtems, | |
527 | #endif | |
528 | #if defined(CONFIG_BOOTM_OSE) | |
529 | [IH_OS_OSE] = do_bootm_ose, | |
530 | #endif | |
531 | #if defined(CONFIG_BOOTM_PLAN9) | |
532 | [IH_OS_PLAN9] = do_bootm_plan9, | |
533 | #endif | |
534 | #if defined(CONFIG_BOOTM_VXWORKS) && \ | |
08337cd6 | 535 | (defined(CONFIG_PPC) || defined(CONFIG_ARM) || defined(CONFIG_RISCV)) |
b6396403 SG |
536 | [IH_OS_VXWORKS] = do_bootm_vxworks, |
537 | #endif | |
538 | #if defined(CONFIG_CMD_ELF) | |
539 | [IH_OS_QNX] = do_bootm_qnxelf, | |
540 | #endif | |
541 | #ifdef CONFIG_INTEGRITY | |
542 | [IH_OS_INTEGRITY] = do_bootm_integrity, | |
543 | #endif | |
67ddd955 MV |
544 | #ifdef CONFIG_BOOTM_OPENRTOS |
545 | [IH_OS_OPENRTOS] = do_bootm_openrtos, | |
546 | #endif | |
c225e7cf BD |
547 | #ifdef CONFIG_BOOTM_OPTEE |
548 | [IH_OS_TEE] = do_bootm_tee, | |
549 | #endif | |
ecc7fdaa CC |
550 | #ifdef CONFIG_BOOTM_EFI |
551 | [IH_OS_EFI] = do_bootm_efi, | |
552 | #endif | |
2abf14df MM |
553 | #if defined(CONFIG_BOOTM_ELF) |
554 | [IH_OS_ELF] = do_bootm_elf, | |
555 | #endif | |
b6396403 SG |
556 | }; |
557 | ||
558 | /* Allow for arch specific config before we boot */ | |
82c3a4c4 | 559 | __weak void arch_preboot_os(void) |
b6396403 SG |
560 | { |
561 | /* please define platform specific arch_preboot_os() */ | |
562 | } | |
b6396403 | 563 | |
fd3d1212 MV |
564 | /* Allow for board specific config before we boot */ |
565 | __weak void board_preboot_os(void) | |
566 | { | |
567 | /* please define board specific board_preboot_os() */ | |
568 | } | |
569 | ||
725ddf1f | 570 | int boot_selected_os(int state, struct bootm_info *bmi, boot_os_fn *boot_fn) |
b6396403 SG |
571 | { |
572 | arch_preboot_os(); | |
fd3d1212 | 573 | board_preboot_os(); |
a48336e5 | 574 | |
725ddf1f | 575 | boot_fn(state, bmi); |
b6396403 SG |
576 | |
577 | /* Stand-alone may return when 'autostart' is 'no' */ | |
725ddf1f | 578 | if (bmi->images->os.type == IH_TYPE_STANDALONE || |
b9c771b0 | 579 | IS_ENABLED(CONFIG_SANDBOX) || |
b6396403 SG |
580 | state == BOOTM_STATE_OS_FAKE_GO) /* We expect to return */ |
581 | return 0; | |
582 | bootstage_error(BOOTSTAGE_ID_BOOT_OS_RETURNED); | |
851bda81 LM |
583 | debug("\n## Control returned to monitor - resetting...\n"); |
584 | ||
b6396403 SG |
585 | return BOOTM_ERR_RESET; |
586 | } | |
587 | ||
588 | boot_os_fn *bootm_os_get_boot_func(int os) | |
589 | { | |
b6396403 SG |
590 | return boot_os[os]; |
591 | } |