X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=common%2Fbootm_os.c;h=1d58462509cc07111c0eeadcd0029ffcee2b9705;hb=d31f1c9236973a463a73cd2748bcc62939fc9247;hp=6fb7d658da69846035f6cfbc901f6360e14c8c95;hpb=9c6115822e894ead72fa4c094bf718eaabb9e103;p=oweals%2Fu-boot.git diff --git a/common/bootm_os.c b/common/bootm_os.c index 6fb7d658da..1d58462509 100644 --- a/common/bootm_os.c +++ b/common/bootm_os.c @@ -6,10 +6,13 @@ #include #include +#include +#include #include #include #include #include +#include #include #include @@ -318,8 +321,8 @@ static void do_bootvx_fdt(bootm_headers_t *images) puts("## vxWorks terminated\n"); } -int do_bootm_vxworks(int flag, int argc, char * const argv[], - bootm_headers_t *images) +static int do_bootm_vxworks_legacy(int flag, int argc, char * const argv[], + bootm_headers_t *images) { if (flag != BOOTM_STATE_OS_GO) return 0; @@ -335,6 +338,41 @@ int do_bootm_vxworks(int flag, int argc, char * const argv[], return 1; } + +int do_bootm_vxworks(int flag, int argc, char * const argv[], + bootm_headers_t *images) +{ + char *bootargs; + int pos; + unsigned long vxflags; + bool std_dtb = false; + + /* get bootargs env */ + bootargs = env_get("bootargs"); + + if (bootargs != NULL) { + for (pos = 0; pos < strlen(bootargs); pos++) { + /* find f=0xnumber flag */ + if ((bootargs[pos] == '=') && (pos >= 1) && + (bootargs[pos - 1] == 'f')) { + vxflags = simple_strtoul(&bootargs[pos + 1], + NULL, 16); + if (vxflags & VXWORKS_SYSFLG_STD_DTB) + std_dtb = true; + } + } + } + + if (std_dtb) { + if (flag & BOOTM_STATE_OS_PREP) + printf(" Using standard DTB\n"); + return do_bootm_linux(flag, argc, argv, images); + } else { + if (flag & BOOTM_STATE_OS_PREP) + printf(" !!! WARNING !!! Using legacy DTB\n"); + return do_bootm_vxworks_legacy(flag, argc, argv, images); + } +} #endif #if defined(CONFIG_CMD_ELF) @@ -462,6 +500,57 @@ static int do_bootm_tee(int flag, int argc, char * const argv[], } #endif +#ifdef CONFIG_BOOTM_EFI +static int do_bootm_efi(int flag, int argc, char * const argv[], + bootm_headers_t *images) +{ + int ret; + efi_status_t efi_ret; + void *image_buf; + + if (flag != BOOTM_STATE_OS_GO) + return 0; + + /* Locate FDT, if provided */ + ret = bootm_find_images(flag, argc, argv); + if (ret) + return ret; + + /* Initialize EFI drivers */ + efi_ret = efi_init_obj_list(); + if (efi_ret != EFI_SUCCESS) { + printf("## Failed to initialize UEFI sub-system: r = %lu\n", + efi_ret & ~EFI_ERROR_MASK); + return 1; + } + + /* Install device tree */ + efi_ret = efi_install_fdt(images->ft_len + ? images->ft_addr : EFI_FDT_USE_INTERNAL); + if (efi_ret != EFI_SUCCESS) { + printf("## Failed to install device tree: r = %lu\n", + efi_ret & ~EFI_ERROR_MASK); + return 1; + } + + /* Run EFI image */ + printf("## Transferring control to EFI (at address %08lx) ...\n", + images->ep); + bootstage_mark(BOOTSTAGE_ID_RUN_OS); + + image_buf = map_sysmem(images->ep, images->os.image_len); + + efi_ret = efi_run_image(image_buf, images->os.image_len); + if (efi_ret != EFI_SUCCESS) { + printf("## Failed to run EFI image: r = %lu\n", + efi_ret & ~EFI_ERROR_MASK); + return 1; + } + + return 0; +} +#endif + static boot_os_fn *boot_os[] = { [IH_OS_U_BOOT] = do_bootm_standalone, #ifdef CONFIG_BOOTM_LINUX @@ -498,6 +587,9 @@ static boot_os_fn *boot_os[] = { #ifdef CONFIG_BOOTM_OPTEE [IH_OS_TEE] = do_bootm_tee, #endif +#ifdef CONFIG_BOOTM_EFI + [IH_OS_EFI] = do_bootm_efi, +#endif }; /* Allow for arch specific config before we boot */