X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=common%2Fbootm_os.c;h=6fb7d658da69846035f6cfbc901f6360e14c8c95;hb=a360e42216d5c43e28ed067b6e1c48d00cd4763f;hp=9ec84bd0dbe0349741b09b44010f3e4f75709be8;hpb=e4a94ce4ac77396b181663c0493c50bc2d5b9143;p=oweals%2Fu-boot.git diff --git a/common/bootm_os.c b/common/bootm_os.c index 9ec84bd0db..6fb7d658da 100644 --- a/common/bootm_os.c +++ b/common/bootm_os.c @@ -1,16 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * (C) Copyright 2000-2009 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. - * - * SPDX-License-Identifier: GPL-2.0+ */ #include #include +#include #include -#include +#include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -21,9 +22,9 @@ static int do_bootm_standalone(int flag, int argc, char * const argv[], int (*appl)(int, char *const[]); /* Don't start if "autostart" is set to "no" */ - s = getenv("autostart"); + s = env_get("autostart"); if ((s != NULL) && !strcmp(s, "no")) { - setenv_hex("filesize", images->os.image_len); + env_set_hex("filesize", images->os.image_len); return 0; } appl = (int (*)(int, char * const []))images->ep; @@ -56,7 +57,6 @@ static int do_bootm_netbsd(int flag, int argc, char * const argv[], void (*loader)(bd_t *, image_header_t *, char *, char *); image_header_t *os_hdr, *hdr; ulong kernel_data, kernel_len; - char *consdev; char *cmdline; if (flag != BOOTM_STATE_OS_GO) @@ -88,17 +88,6 @@ static int do_bootm_netbsd(int flag, int argc, char * const argv[], os_hdr = hdr; } - consdev = ""; -#if defined(CONFIG_8xx_CONS_SMC1) - consdev = "smc1"; -#elif defined(CONFIG_8xx_CONS_SMC2) - consdev = "smc2"; -#elif defined(CONFIG_8xx_CONS_SCC2) - consdev = "scc2"; -#elif defined(CONFIG_8xx_CONS_SCC3) - consdev = "scc3"; -#endif - if (argc > 0) { ulong len; int i; @@ -108,7 +97,7 @@ static int do_bootm_netbsd(int flag, int argc, char * const argv[], cmdline = malloc(len); copy_args(cmdline, argc, argv, ' '); } else { - cmdline = getenv("bootargs"); + cmdline = env_get("bootargs"); if (cmdline == NULL) cmdline = ""; } @@ -127,7 +116,7 @@ static int do_bootm_netbsd(int flag, int argc, char * const argv[], * arg[2]: char pointer to the console device to use * arg[3]: char pointer to the boot arguments */ - (*loader)(gd->bd, os_hdr, consdev, cmdline); + (*loader)(gd->bd, os_hdr, "", cmdline); return 1; } @@ -239,14 +228,14 @@ static int do_bootm_plan9(int flag, int argc, char * const argv[], #endif /* See README.plan9 */ - s = getenv("confaddr"); + s = env_get("confaddr"); if (s != NULL) { char *confaddr = (char *)simple_strtoul(s, NULL, 16); if (argc > 0) { copy_args(confaddr, argc, argv, '\n'); } else { - s = getenv("bootargs"); + s = env_get("bootargs"); if (s != NULL) strcpy(confaddr, s); } @@ -272,7 +261,7 @@ static int do_bootm_plan9(int flag, int argc, char * const argv[], #if defined(CONFIG_BOOTM_VXWORKS) && \ (defined(CONFIG_PPC) || defined(CONFIG_ARM)) -void do_bootvx_fdt(bootm_headers_t *images) +static void do_bootvx_fdt(bootm_headers_t *images) { #if defined(CONFIG_OF_LIBFDT) int ret; @@ -288,11 +277,12 @@ void do_bootvx_fdt(bootm_headers_t *images) if (ret) return; + /* Update ethernet nodes */ fdt_fixup_ethernet(*of_flat_tree); ret = fdt_add_subnode(*of_flat_tree, 0, "chosen"); if ((ret >= 0 || ret == -FDT_ERR_EXISTS)) { - bootline = getenv("bootargs"); + bootline = env_get("bootargs"); if (bootline) { ret = fdt_find_and_setprop(*of_flat_tree, "/chosen", "bootargs", @@ -328,8 +318,8 @@ void do_bootvx_fdt(bootm_headers_t *images) puts("## vxWorks terminated\n"); } -static int do_bootm_vxworks(int flag, int argc, char * const argv[], - bootm_headers_t *images) +int do_bootm_vxworks(int flag, int argc, char * const argv[], + bootm_headers_t *images) { if (flag != BOOTM_STATE_OS_GO) return 0; @@ -353,6 +343,7 @@ static int do_bootm_qnxelf(int flag, int argc, char * const argv[], { char *local_args[2]; char str[16]; + int dcache; if (flag != BOOTM_STATE_OS_GO) return 0; @@ -367,8 +358,19 @@ static int do_bootm_qnxelf(int flag, int argc, char * const argv[], sprintf(str, "%lx", images->ep); /* write entry-point into string */ local_args[0] = argv[0]; local_args[1] = str; /* and provide it via the arguments */ + + /* + * QNX images require the data cache is disabled. + */ + dcache = dcache_status(); + if (dcache) + dcache_disable(); + do_bootelf(NULL, 0, 2, local_args); + if (dcache) + dcache_enable(); + return 1; } #endif @@ -432,6 +434,34 @@ static int do_bootm_openrtos(int flag, int argc, char * const argv[], } #endif +#ifdef CONFIG_BOOTM_OPTEE +static int do_bootm_tee(int flag, int argc, char * const argv[], + bootm_headers_t *images) +{ + int ret; + + /* Verify OS type */ + if (images->os.os != IH_OS_TEE) { + return 1; + }; + + /* Validate OPTEE header */ + ret = optee_verify_bootm_image(images->os.image_start, + images->os.load, + images->os.image_len); + if (ret) + return ret; + + /* Locate FDT etc */ + ret = bootm_find_images(flag, argc, argv); + if (ret) + return ret; + + /* From here we can run the regular linux boot path */ + return do_bootm_linux(flag, argc, argv, images); +} +#endif + static boot_os_fn *boot_os[] = { [IH_OS_U_BOOT] = do_bootm_standalone, #ifdef CONFIG_BOOTM_LINUX @@ -453,7 +483,7 @@ static boot_os_fn *boot_os[] = { [IH_OS_PLAN9] = do_bootm_plan9, #endif #if defined(CONFIG_BOOTM_VXWORKS) && \ - (defined(CONFIG_PPC) || defined(CONFIG_ARM)) + (defined(CONFIG_PPC) || defined(CONFIG_ARM) || defined(CONFIG_RISCV)) [IH_OS_VXWORKS] = do_bootm_vxworks, #endif #if defined(CONFIG_CMD_ELF) @@ -465,6 +495,9 @@ static boot_os_fn *boot_os[] = { #ifdef CONFIG_BOOTM_OPENRTOS [IH_OS_OPENRTOS] = do_bootm_openrtos, #endif +#ifdef CONFIG_BOOTM_OPTEE + [IH_OS_TEE] = do_bootm_tee, +#endif }; /* Allow for arch specific config before we boot */ @@ -473,14 +506,22 @@ __weak void arch_preboot_os(void) /* please define platform specific arch_preboot_os() */ } +/* Allow for board specific config before we boot */ +__weak void board_preboot_os(void) +{ + /* please define board specific board_preboot_os() */ +} + int boot_selected_os(int argc, char * const argv[], int state, bootm_headers_t *images, boot_os_fn *boot_fn) { arch_preboot_os(); + board_preboot_os(); boot_fn(state, argc, argv, images); /* Stand-alone may return when 'autostart' is 'no' */ if (images->os.type == IH_TYPE_STANDALONE || + IS_ENABLED(CONFIG_SANDBOX) || state == BOOTM_STATE_OS_FAKE_GO) /* We expect to return */ return 0; bootstage_error(BOOTSTAGE_ID_BOOT_OS_RETURNED);