1b6396403SSimon Glass /* 2b6396403SSimon Glass * (C) Copyright 2000-2009 3b6396403SSimon Glass * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 4b6396403SSimon Glass * 5b6396403SSimon Glass * SPDX-License-Identifier: GPL-2.0+ 6b6396403SSimon Glass */ 7b6396403SSimon Glass 8b6396403SSimon Glass #include <common.h> 9b6396403SSimon Glass #include <bootm.h> 10b6396403SSimon Glass #include <fdt_support.h> 11*b08c8c48SMasahiro Yamada #include <linux/libfdt.h> 12b6396403SSimon Glass #include <malloc.h> 13b6396403SSimon Glass #include <vxworks.h> 14b6396403SSimon Glass 15b6396403SSimon Glass DECLARE_GLOBAL_DATA_PTR; 16b6396403SSimon Glass 17b6396403SSimon Glass static int do_bootm_standalone(int flag, int argc, char * const argv[], 18b6396403SSimon Glass bootm_headers_t *images) 19b6396403SSimon Glass { 20b6396403SSimon Glass char *s; 21b6396403SSimon Glass int (*appl)(int, char *const[]); 22b6396403SSimon Glass 23b6396403SSimon Glass /* Don't start if "autostart" is set to "no" */ 2400caae6dSSimon Glass s = env_get("autostart"); 25b6396403SSimon Glass if ((s != NULL) && !strcmp(s, "no")) { 26018f5303SSimon Glass env_set_hex("filesize", images->os.image_len); 27b6396403SSimon Glass return 0; 28b6396403SSimon Glass } 29b6396403SSimon Glass appl = (int (*)(int, char * const []))images->ep; 30b6396403SSimon Glass appl(argc, argv); 31b6396403SSimon Glass return 0; 32b6396403SSimon Glass } 33b6396403SSimon Glass 34b6396403SSimon Glass /*******************************************************************/ 35b6396403SSimon Glass /* OS booting routines */ 36b6396403SSimon Glass /*******************************************************************/ 37b6396403SSimon Glass 38b6396403SSimon Glass #if defined(CONFIG_BOOTM_NETBSD) || defined(CONFIG_BOOTM_PLAN9) 39b6396403SSimon Glass static void copy_args(char *dest, int argc, char * const argv[], char delim) 40b6396403SSimon Glass { 41b6396403SSimon Glass int i; 42b6396403SSimon Glass 43b6396403SSimon Glass for (i = 0; i < argc; i++) { 44b6396403SSimon Glass if (i > 0) 45b6396403SSimon Glass *dest++ = delim; 46b6396403SSimon Glass strcpy(dest, argv[i]); 47b6396403SSimon Glass dest += strlen(argv[i]); 48b6396403SSimon Glass } 49b6396403SSimon Glass } 50b6396403SSimon Glass #endif 51b6396403SSimon Glass 52b6396403SSimon Glass #ifdef CONFIG_BOOTM_NETBSD 53b6396403SSimon Glass static int do_bootm_netbsd(int flag, int argc, char * const argv[], 54b6396403SSimon Glass bootm_headers_t *images) 55b6396403SSimon Glass { 56b6396403SSimon Glass void (*loader)(bd_t *, image_header_t *, char *, char *); 57b6396403SSimon Glass image_header_t *os_hdr, *hdr; 58b6396403SSimon Glass ulong kernel_data, kernel_len; 59b6396403SSimon Glass char *cmdline; 60b6396403SSimon Glass 61b6396403SSimon Glass if (flag != BOOTM_STATE_OS_GO) 62b6396403SSimon Glass return 0; 63b6396403SSimon Glass 64b6396403SSimon Glass #if defined(CONFIG_FIT) 65b6396403SSimon Glass if (!images->legacy_hdr_valid) { 66b6396403SSimon Glass fit_unsupported_reset("NetBSD"); 67b6396403SSimon Glass return 1; 68b6396403SSimon Glass } 69b6396403SSimon Glass #endif 70b6396403SSimon Glass hdr = images->legacy_hdr_os; 71b6396403SSimon Glass 72b6396403SSimon Glass /* 73b6396403SSimon Glass * Booting a (NetBSD) kernel image 74b6396403SSimon Glass * 75b6396403SSimon Glass * This process is pretty similar to a standalone application: 76b6396403SSimon Glass * The (first part of an multi-) image must be a stage-2 loader, 77b6396403SSimon Glass * which in turn is responsible for loading & invoking the actual 78b6396403SSimon Glass * kernel. The only differences are the parameters being passed: 79b6396403SSimon Glass * besides the board info strucure, the loader expects a command 80b6396403SSimon Glass * line, the name of the console device, and (optionally) the 81b6396403SSimon Glass * address of the original image header. 82b6396403SSimon Glass */ 83b6396403SSimon Glass os_hdr = NULL; 84b6396403SSimon Glass if (image_check_type(&images->legacy_hdr_os_copy, IH_TYPE_MULTI)) { 85b6396403SSimon Glass image_multi_getimg(hdr, 1, &kernel_data, &kernel_len); 86b6396403SSimon Glass if (kernel_len) 87b6396403SSimon Glass os_hdr = hdr; 88b6396403SSimon Glass } 89b6396403SSimon Glass 90b6396403SSimon Glass if (argc > 0) { 91b6396403SSimon Glass ulong len; 92b6396403SSimon Glass int i; 93b6396403SSimon Glass 94b6396403SSimon Glass for (i = 0, len = 0; i < argc; i += 1) 95b6396403SSimon Glass len += strlen(argv[i]) + 1; 96b6396403SSimon Glass cmdline = malloc(len); 97b6396403SSimon Glass copy_args(cmdline, argc, argv, ' '); 98b6396403SSimon Glass } else { 9900caae6dSSimon Glass cmdline = env_get("bootargs"); 100b6396403SSimon Glass if (cmdline == NULL) 101b6396403SSimon Glass cmdline = ""; 102b6396403SSimon Glass } 103b6396403SSimon Glass 104b6396403SSimon Glass loader = (void (*)(bd_t *, image_header_t *, char *, char *))images->ep; 105b6396403SSimon Glass 106b6396403SSimon Glass printf("## Transferring control to NetBSD stage-2 loader (at address %08lx) ...\n", 107b6396403SSimon Glass (ulong)loader); 108b6396403SSimon Glass 109b6396403SSimon Glass bootstage_mark(BOOTSTAGE_ID_RUN_OS); 110b6396403SSimon Glass 111b6396403SSimon Glass /* 112b6396403SSimon Glass * NetBSD Stage-2 Loader Parameters: 113b6396403SSimon Glass * arg[0]: pointer to board info data 114b6396403SSimon Glass * arg[1]: image load address 115b6396403SSimon Glass * arg[2]: char pointer to the console device to use 116b6396403SSimon Glass * arg[3]: char pointer to the boot arguments 117b6396403SSimon Glass */ 1185b8e76c3SHeiko Schocher (*loader)(gd->bd, os_hdr, "", cmdline); 119b6396403SSimon Glass 120b6396403SSimon Glass return 1; 121b6396403SSimon Glass } 122b6396403SSimon Glass #endif /* CONFIG_BOOTM_NETBSD*/ 123b6396403SSimon Glass 124b6396403SSimon Glass #ifdef CONFIG_LYNXKDI 125b6396403SSimon Glass static int do_bootm_lynxkdi(int flag, int argc, char * const argv[], 126b6396403SSimon Glass bootm_headers_t *images) 127b6396403SSimon Glass { 128b6396403SSimon Glass image_header_t *hdr = &images->legacy_hdr_os_copy; 129b6396403SSimon Glass 130b6396403SSimon Glass if (flag != BOOTM_STATE_OS_GO) 131b6396403SSimon Glass return 0; 132b6396403SSimon Glass 133b6396403SSimon Glass #if defined(CONFIG_FIT) 134b6396403SSimon Glass if (!images->legacy_hdr_valid) { 135b6396403SSimon Glass fit_unsupported_reset("Lynx"); 136b6396403SSimon Glass return 1; 137b6396403SSimon Glass } 138b6396403SSimon Glass #endif 139b6396403SSimon Glass 140b6396403SSimon Glass lynxkdi_boot((image_header_t *)hdr); 141b6396403SSimon Glass 142b6396403SSimon Glass return 1; 143b6396403SSimon Glass } 144b6396403SSimon Glass #endif /* CONFIG_LYNXKDI */ 145b6396403SSimon Glass 146b6396403SSimon Glass #ifdef CONFIG_BOOTM_RTEMS 147b6396403SSimon Glass static int do_bootm_rtems(int flag, int argc, char * const argv[], 148b6396403SSimon Glass bootm_headers_t *images) 149b6396403SSimon Glass { 150b6396403SSimon Glass void (*entry_point)(bd_t *); 151b6396403SSimon Glass 152b6396403SSimon Glass if (flag != BOOTM_STATE_OS_GO) 153b6396403SSimon Glass return 0; 154b6396403SSimon Glass 155b6396403SSimon Glass #if defined(CONFIG_FIT) 156b6396403SSimon Glass if (!images->legacy_hdr_valid) { 157b6396403SSimon Glass fit_unsupported_reset("RTEMS"); 158b6396403SSimon Glass return 1; 159b6396403SSimon Glass } 160b6396403SSimon Glass #endif 161b6396403SSimon Glass 162b6396403SSimon Glass entry_point = (void (*)(bd_t *))images->ep; 163b6396403SSimon Glass 164b6396403SSimon Glass printf("## Transferring control to RTEMS (at address %08lx) ...\n", 165b6396403SSimon Glass (ulong)entry_point); 166b6396403SSimon Glass 167b6396403SSimon Glass bootstage_mark(BOOTSTAGE_ID_RUN_OS); 168b6396403SSimon Glass 169b6396403SSimon Glass /* 170b6396403SSimon Glass * RTEMS Parameters: 171b6396403SSimon Glass * r3: ptr to board info data 172b6396403SSimon Glass */ 173b6396403SSimon Glass (*entry_point)(gd->bd); 174b6396403SSimon Glass 175b6396403SSimon Glass return 1; 176b6396403SSimon Glass } 177b6396403SSimon Glass #endif /* CONFIG_BOOTM_RTEMS */ 178b6396403SSimon Glass 179b6396403SSimon Glass #if defined(CONFIG_BOOTM_OSE) 180b6396403SSimon Glass static int do_bootm_ose(int flag, int argc, char * const argv[], 181b6396403SSimon Glass bootm_headers_t *images) 182b6396403SSimon Glass { 183b6396403SSimon Glass void (*entry_point)(void); 184b6396403SSimon Glass 185b6396403SSimon Glass if (flag != BOOTM_STATE_OS_GO) 186b6396403SSimon Glass return 0; 187b6396403SSimon Glass 188b6396403SSimon Glass #if defined(CONFIG_FIT) 189b6396403SSimon Glass if (!images->legacy_hdr_valid) { 190b6396403SSimon Glass fit_unsupported_reset("OSE"); 191b6396403SSimon Glass return 1; 192b6396403SSimon Glass } 193b6396403SSimon Glass #endif 194b6396403SSimon Glass 195b6396403SSimon Glass entry_point = (void (*)(void))images->ep; 196b6396403SSimon Glass 197b6396403SSimon Glass printf("## Transferring control to OSE (at address %08lx) ...\n", 198b6396403SSimon Glass (ulong)entry_point); 199b6396403SSimon Glass 200b6396403SSimon Glass bootstage_mark(BOOTSTAGE_ID_RUN_OS); 201b6396403SSimon Glass 202b6396403SSimon Glass /* 203b6396403SSimon Glass * OSE Parameters: 204b6396403SSimon Glass * None 205b6396403SSimon Glass */ 206b6396403SSimon Glass (*entry_point)(); 207b6396403SSimon Glass 208b6396403SSimon Glass return 1; 209b6396403SSimon Glass } 210b6396403SSimon Glass #endif /* CONFIG_BOOTM_OSE */ 211b6396403SSimon Glass 212b6396403SSimon Glass #if defined(CONFIG_BOOTM_PLAN9) 213b6396403SSimon Glass static int do_bootm_plan9(int flag, int argc, char * const argv[], 214b6396403SSimon Glass bootm_headers_t *images) 215b6396403SSimon Glass { 216b6396403SSimon Glass void (*entry_point)(void); 217b6396403SSimon Glass char *s; 218b6396403SSimon Glass 219b6396403SSimon Glass if (flag != BOOTM_STATE_OS_GO) 220b6396403SSimon Glass return 0; 221b6396403SSimon Glass 222b6396403SSimon Glass #if defined(CONFIG_FIT) 223b6396403SSimon Glass if (!images->legacy_hdr_valid) { 224b6396403SSimon Glass fit_unsupported_reset("Plan 9"); 225b6396403SSimon Glass return 1; 226b6396403SSimon Glass } 227b6396403SSimon Glass #endif 228b6396403SSimon Glass 229b6396403SSimon Glass /* See README.plan9 */ 23000caae6dSSimon Glass s = env_get("confaddr"); 231b6396403SSimon Glass if (s != NULL) { 232b6396403SSimon Glass char *confaddr = (char *)simple_strtoul(s, NULL, 16); 233b6396403SSimon Glass 234b6396403SSimon Glass if (argc > 0) { 235b6396403SSimon Glass copy_args(confaddr, argc, argv, '\n'); 236b6396403SSimon Glass } else { 23700caae6dSSimon Glass s = env_get("bootargs"); 238b6396403SSimon Glass if (s != NULL) 239b6396403SSimon Glass strcpy(confaddr, s); 240b6396403SSimon Glass } 241b6396403SSimon Glass } 242b6396403SSimon Glass 243b6396403SSimon Glass entry_point = (void (*)(void))images->ep; 244b6396403SSimon Glass 245b6396403SSimon Glass printf("## Transferring control to Plan 9 (at address %08lx) ...\n", 246b6396403SSimon Glass (ulong)entry_point); 247b6396403SSimon Glass 248b6396403SSimon Glass bootstage_mark(BOOTSTAGE_ID_RUN_OS); 249b6396403SSimon Glass 250b6396403SSimon Glass /* 251b6396403SSimon Glass * Plan 9 Parameters: 252b6396403SSimon Glass * None 253b6396403SSimon Glass */ 254b6396403SSimon Glass (*entry_point)(); 255b6396403SSimon Glass 256b6396403SSimon Glass return 1; 257b6396403SSimon Glass } 258b6396403SSimon Glass #endif /* CONFIG_BOOTM_PLAN9 */ 259b6396403SSimon Glass 260b6396403SSimon Glass #if defined(CONFIG_BOOTM_VXWORKS) && \ 261b6396403SSimon Glass (defined(CONFIG_PPC) || defined(CONFIG_ARM)) 262b6396403SSimon Glass 263b6396403SSimon Glass void do_bootvx_fdt(bootm_headers_t *images) 264b6396403SSimon Glass { 265b6396403SSimon Glass #if defined(CONFIG_OF_LIBFDT) 266b6396403SSimon Glass int ret; 267b6396403SSimon Glass char *bootline; 268b6396403SSimon Glass ulong of_size = images->ft_len; 269b6396403SSimon Glass char **of_flat_tree = &images->ft_addr; 270b6396403SSimon Glass struct lmb *lmb = &images->lmb; 271b6396403SSimon Glass 272b6396403SSimon Glass if (*of_flat_tree) { 273b6396403SSimon Glass boot_fdt_add_mem_rsv_regions(lmb, *of_flat_tree); 274b6396403SSimon Glass 275b6396403SSimon Glass ret = boot_relocate_fdt(lmb, of_flat_tree, &of_size); 276b6396403SSimon Glass if (ret) 277b6396403SSimon Glass return; 278b6396403SSimon Glass 279a223e2bcSHannes Schmelzer /* Update ethernet nodes */ 280a223e2bcSHannes Schmelzer fdt_fixup_ethernet(*of_flat_tree); 281a223e2bcSHannes Schmelzer 282b6396403SSimon Glass ret = fdt_add_subnode(*of_flat_tree, 0, "chosen"); 283b6396403SSimon Glass if ((ret >= 0 || ret == -FDT_ERR_EXISTS)) { 28400caae6dSSimon Glass bootline = env_get("bootargs"); 285b6396403SSimon Glass if (bootline) { 286b6396403SSimon Glass ret = fdt_find_and_setprop(*of_flat_tree, 287b6396403SSimon Glass "/chosen", "bootargs", 288b6396403SSimon Glass bootline, 289b6396403SSimon Glass strlen(bootline) + 1, 1); 290b6396403SSimon Glass if (ret < 0) { 291b6396403SSimon Glass printf("## ERROR: %s : %s\n", __func__, 292b6396403SSimon Glass fdt_strerror(ret)); 293b6396403SSimon Glass return; 294b6396403SSimon Glass } 295b6396403SSimon Glass } 296b6396403SSimon Glass } else { 297b6396403SSimon Glass printf("## ERROR: %s : %s\n", __func__, 298b6396403SSimon Glass fdt_strerror(ret)); 299b6396403SSimon Glass return; 300b6396403SSimon Glass } 301b6396403SSimon Glass } 302b6396403SSimon Glass #endif 303b6396403SSimon Glass 304b6396403SSimon Glass boot_prep_vxworks(images); 305b6396403SSimon Glass 306b6396403SSimon Glass bootstage_mark(BOOTSTAGE_ID_RUN_OS); 307b6396403SSimon Glass 308b6396403SSimon Glass #if defined(CONFIG_OF_LIBFDT) 309b6396403SSimon Glass printf("## Starting vxWorks at 0x%08lx, device tree at 0x%08lx ...\n", 310b6396403SSimon Glass (ulong)images->ep, (ulong)*of_flat_tree); 311b6396403SSimon Glass #else 312b6396403SSimon Glass printf("## Starting vxWorks at 0x%08lx\n", (ulong)images->ep); 313b6396403SSimon Glass #endif 314b6396403SSimon Glass 315b6396403SSimon Glass boot_jump_vxworks(images); 316b6396403SSimon Glass 317b6396403SSimon Glass puts("## vxWorks terminated\n"); 318b6396403SSimon Glass } 319b6396403SSimon Glass 320b6396403SSimon Glass static int do_bootm_vxworks(int flag, int argc, char * const argv[], 321b6396403SSimon Glass bootm_headers_t *images) 322b6396403SSimon Glass { 323b6396403SSimon Glass if (flag != BOOTM_STATE_OS_GO) 324b6396403SSimon Glass return 0; 325b6396403SSimon Glass 326b6396403SSimon Glass #if defined(CONFIG_FIT) 327b6396403SSimon Glass if (!images->legacy_hdr_valid) { 328b6396403SSimon Glass fit_unsupported_reset("VxWorks"); 329b6396403SSimon Glass return 1; 330b6396403SSimon Glass } 331b6396403SSimon Glass #endif 332b6396403SSimon Glass 333b6396403SSimon Glass do_bootvx_fdt(images); 334b6396403SSimon Glass 335b6396403SSimon Glass return 1; 336b6396403SSimon Glass } 337b6396403SSimon Glass #endif 338b6396403SSimon Glass 339b6396403SSimon Glass #if defined(CONFIG_CMD_ELF) 340b6396403SSimon Glass static int do_bootm_qnxelf(int flag, int argc, char * const argv[], 341b6396403SSimon Glass bootm_headers_t *images) 342b6396403SSimon Glass { 343b6396403SSimon Glass char *local_args[2]; 344b6396403SSimon Glass char str[16]; 345995eab8bSEmmanuel Vadot int dcache; 346b6396403SSimon Glass 347b6396403SSimon Glass if (flag != BOOTM_STATE_OS_GO) 348b6396403SSimon Glass return 0; 349b6396403SSimon Glass 350b6396403SSimon Glass #if defined(CONFIG_FIT) 351b6396403SSimon Glass if (!images->legacy_hdr_valid) { 352b6396403SSimon Glass fit_unsupported_reset("QNX"); 353b6396403SSimon Glass return 1; 354b6396403SSimon Glass } 355b6396403SSimon Glass #endif 356b6396403SSimon Glass 357b6396403SSimon Glass sprintf(str, "%lx", images->ep); /* write entry-point into string */ 358b6396403SSimon Glass local_args[0] = argv[0]; 359b6396403SSimon Glass local_args[1] = str; /* and provide it via the arguments */ 360995eab8bSEmmanuel Vadot 361995eab8bSEmmanuel Vadot /* 362995eab8bSEmmanuel Vadot * QNX images require the data cache is disabled. 363995eab8bSEmmanuel Vadot */ 364995eab8bSEmmanuel Vadot dcache = dcache_status(); 365995eab8bSEmmanuel Vadot if (dcache) 366995eab8bSEmmanuel Vadot dcache_disable(); 367995eab8bSEmmanuel Vadot 368b6396403SSimon Glass do_bootelf(NULL, 0, 2, local_args); 369b6396403SSimon Glass 370995eab8bSEmmanuel Vadot if (dcache) 371995eab8bSEmmanuel Vadot dcache_enable(); 372995eab8bSEmmanuel Vadot 373b6396403SSimon Glass return 1; 374b6396403SSimon Glass } 375b6396403SSimon Glass #endif 376b6396403SSimon Glass 377b6396403SSimon Glass #ifdef CONFIG_INTEGRITY 378b6396403SSimon Glass static int do_bootm_integrity(int flag, int argc, char * const argv[], 379b6396403SSimon Glass bootm_headers_t *images) 380b6396403SSimon Glass { 381b6396403SSimon Glass void (*entry_point)(void); 382b6396403SSimon Glass 383b6396403SSimon Glass if (flag != BOOTM_STATE_OS_GO) 384b6396403SSimon Glass return 0; 385b6396403SSimon Glass 386b6396403SSimon Glass #if defined(CONFIG_FIT) 387b6396403SSimon Glass if (!images->legacy_hdr_valid) { 388b6396403SSimon Glass fit_unsupported_reset("INTEGRITY"); 389b6396403SSimon Glass return 1; 390b6396403SSimon Glass } 391b6396403SSimon Glass #endif 392b6396403SSimon Glass 393b6396403SSimon Glass entry_point = (void (*)(void))images->ep; 394b6396403SSimon Glass 395b6396403SSimon Glass printf("## Transferring control to INTEGRITY (at address %08lx) ...\n", 396b6396403SSimon Glass (ulong)entry_point); 397b6396403SSimon Glass 398b6396403SSimon Glass bootstage_mark(BOOTSTAGE_ID_RUN_OS); 399b6396403SSimon Glass 400b6396403SSimon Glass /* 401b6396403SSimon Glass * INTEGRITY Parameters: 402b6396403SSimon Glass * None 403b6396403SSimon Glass */ 404b6396403SSimon Glass (*entry_point)(); 405b6396403SSimon Glass 406b6396403SSimon Glass return 1; 407b6396403SSimon Glass } 408b6396403SSimon Glass #endif 409b6396403SSimon Glass 41067ddd955SMarek Vasut #ifdef CONFIG_BOOTM_OPENRTOS 41167ddd955SMarek Vasut static int do_bootm_openrtos(int flag, int argc, char * const argv[], 41267ddd955SMarek Vasut bootm_headers_t *images) 41367ddd955SMarek Vasut { 41467ddd955SMarek Vasut void (*entry_point)(void); 41567ddd955SMarek Vasut 41667ddd955SMarek Vasut if (flag != BOOTM_STATE_OS_GO) 41767ddd955SMarek Vasut return 0; 41867ddd955SMarek Vasut 41967ddd955SMarek Vasut entry_point = (void (*)(void))images->ep; 42067ddd955SMarek Vasut 42167ddd955SMarek Vasut printf("## Transferring control to OpenRTOS (at address %08lx) ...\n", 42267ddd955SMarek Vasut (ulong)entry_point); 42367ddd955SMarek Vasut 42467ddd955SMarek Vasut bootstage_mark(BOOTSTAGE_ID_RUN_OS); 42567ddd955SMarek Vasut 42667ddd955SMarek Vasut /* 42767ddd955SMarek Vasut * OpenRTOS Parameters: 42867ddd955SMarek Vasut * None 42967ddd955SMarek Vasut */ 43067ddd955SMarek Vasut (*entry_point)(); 43167ddd955SMarek Vasut 43267ddd955SMarek Vasut return 1; 43367ddd955SMarek Vasut } 43467ddd955SMarek Vasut #endif 43567ddd955SMarek Vasut 436b6396403SSimon Glass static boot_os_fn *boot_os[] = { 437b6396403SSimon Glass [IH_OS_U_BOOT] = do_bootm_standalone, 438b6396403SSimon Glass #ifdef CONFIG_BOOTM_LINUX 439b6396403SSimon Glass [IH_OS_LINUX] = do_bootm_linux, 440b6396403SSimon Glass #endif 441b6396403SSimon Glass #ifdef CONFIG_BOOTM_NETBSD 442b6396403SSimon Glass [IH_OS_NETBSD] = do_bootm_netbsd, 443b6396403SSimon Glass #endif 444b6396403SSimon Glass #ifdef CONFIG_LYNXKDI 445b6396403SSimon Glass [IH_OS_LYNXOS] = do_bootm_lynxkdi, 446b6396403SSimon Glass #endif 447b6396403SSimon Glass #ifdef CONFIG_BOOTM_RTEMS 448b6396403SSimon Glass [IH_OS_RTEMS] = do_bootm_rtems, 449b6396403SSimon Glass #endif 450b6396403SSimon Glass #if defined(CONFIG_BOOTM_OSE) 451b6396403SSimon Glass [IH_OS_OSE] = do_bootm_ose, 452b6396403SSimon Glass #endif 453b6396403SSimon Glass #if defined(CONFIG_BOOTM_PLAN9) 454b6396403SSimon Glass [IH_OS_PLAN9] = do_bootm_plan9, 455b6396403SSimon Glass #endif 456b6396403SSimon Glass #if defined(CONFIG_BOOTM_VXWORKS) && \ 457b6396403SSimon Glass (defined(CONFIG_PPC) || defined(CONFIG_ARM)) 458b6396403SSimon Glass [IH_OS_VXWORKS] = do_bootm_vxworks, 459b6396403SSimon Glass #endif 460b6396403SSimon Glass #if defined(CONFIG_CMD_ELF) 461b6396403SSimon Glass [IH_OS_QNX] = do_bootm_qnxelf, 462b6396403SSimon Glass #endif 463b6396403SSimon Glass #ifdef CONFIG_INTEGRITY 464b6396403SSimon Glass [IH_OS_INTEGRITY] = do_bootm_integrity, 465b6396403SSimon Glass #endif 46667ddd955SMarek Vasut #ifdef CONFIG_BOOTM_OPENRTOS 46767ddd955SMarek Vasut [IH_OS_OPENRTOS] = do_bootm_openrtos, 46867ddd955SMarek Vasut #endif 469b6396403SSimon Glass }; 470b6396403SSimon Glass 471b6396403SSimon Glass /* Allow for arch specific config before we boot */ 47282c3a4c4SJeroen Hofstee __weak void arch_preboot_os(void) 473b6396403SSimon Glass { 474b6396403SSimon Glass /* please define platform specific arch_preboot_os() */ 475b6396403SSimon Glass } 476b6396403SSimon Glass 477b6396403SSimon Glass int boot_selected_os(int argc, char * const argv[], int state, 478b6396403SSimon Glass bootm_headers_t *images, boot_os_fn *boot_fn) 479b6396403SSimon Glass { 480b6396403SSimon Glass arch_preboot_os(); 481b6396403SSimon Glass boot_fn(state, argc, argv, images); 482b6396403SSimon Glass 483b6396403SSimon Glass /* Stand-alone may return when 'autostart' is 'no' */ 484b6396403SSimon Glass if (images->os.type == IH_TYPE_STANDALONE || 485b9c771b0SSimon Glass IS_ENABLED(CONFIG_SANDBOX) || 486b6396403SSimon Glass state == BOOTM_STATE_OS_FAKE_GO) /* We expect to return */ 487b6396403SSimon Glass return 0; 488b6396403SSimon Glass bootstage_error(BOOTSTAGE_ID_BOOT_OS_RETURNED); 489851bda81SLukasz Majewski debug("\n## Control returned to monitor - resetting...\n"); 490851bda81SLukasz Majewski 491b6396403SSimon Glass return BOOTM_ERR_RESET; 492b6396403SSimon Glass } 493b6396403SSimon Glass 494b6396403SSimon Glass boot_os_fn *bootm_os_get_boot_func(int os) 495b6396403SSimon Glass { 496b6396403SSimon Glass #ifdef CONFIG_NEEDS_MANUAL_RELOC 497b6396403SSimon Glass static bool relocated; 498b6396403SSimon Glass 499b6396403SSimon Glass if (!relocated) { 500b6396403SSimon Glass int i; 501b6396403SSimon Glass 502b6396403SSimon Glass /* relocate boot function table */ 503b6396403SSimon Glass for (i = 0; i < ARRAY_SIZE(boot_os); i++) 504b6396403SSimon Glass if (boot_os[i] != NULL) 505b6396403SSimon Glass boot_os[i] += gd->reloc_off; 506b6396403SSimon Glass 507b6396403SSimon Glass relocated = true; 508b6396403SSimon Glass } 509b6396403SSimon Glass #endif 510b6396403SSimon Glass return boot_os[os]; 511b6396403SSimon Glass } 512