diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/Kconfig | 2 | ||||
-rw-r--r-- | common/Makefile | 6 | ||||
-rw-r--r-- | common/bloblist.c | 14 | ||||
-rw-r--r-- | common/board_f.c | 6 | ||||
-rw-r--r-- | common/board_r.c | 2 | ||||
-rw-r--r-- | common/bootstage.c | 14 | ||||
-rw-r--r-- | common/dlmalloc.c | 12 | ||||
-rw-r--r-- | common/init/board_init.c | 4 | ||||
-rw-r--r-- | common/spl/Kconfig | 16 | ||||
-rw-r--r-- | common/spl/Kconfig.nxp | 2 | ||||
-rw-r--r-- | common/spl/spl.c | 226 | ||||
-rw-r--r-- | common/spl/spl_ext.c | 4 | ||||
-rw-r--r-- | common/spl/spl_fat.c | 4 | ||||
-rw-r--r-- | common/spl/spl_fit.c | 127 | ||||
-rw-r--r-- | common/spl/spl_mmc.c | 2 | ||||
-rw-r--r-- | common/spl/spl_nand.c | 10 | ||||
-rw-r--r-- | common/spl/spl_nor.c | 8 | ||||
-rw-r--r-- | common/spl/spl_spi.c | 2 | ||||
-rw-r--r-- | common/spl/spl_ubi.c | 2 | ||||
-rw-r--r-- | common/spl/spl_xip.c | 2 |
20 files changed, 227 insertions, 238 deletions
diff --git a/common/Kconfig b/common/Kconfig index 21eaa5e815f..5e79b542217 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -1012,7 +1012,7 @@ endchoice config BLOBLIST_ADDR hex "Address of bloblist" - default 0xc000 if SANDBOX + default 0xb000 if SANDBOX depends on BLOBLIST_FIXED help Sets the address of the bloblist, set up by the first part of U-Boot diff --git a/common/Makefile b/common/Makefile index 5c1617206f0..cdeadf72026 100644 --- a/common/Makefile +++ b/common/Makefile @@ -74,11 +74,7 @@ endif # CONFIG_SPL_BUILD obj-$(CONFIG_CROS_EC) += cros_ec.o obj-y += dlmalloc.o -ifdef CONFIG_SYS_MALLOC_F -ifneq ($(CONFIG_$(SPL_TPL_)SYS_MALLOC_F_LEN),0x0) -obj-y += malloc_simple.o -endif -endif +obj-$(CONFIG_$(SPL_TPL_)SYS_MALLOC_F) += malloc_simple.o obj-$(CONFIG_CYCLIC) += cyclic.o obj-$(CONFIG_$(SPL_TPL_)EVENT) += event.o diff --git a/common/bloblist.c b/common/bloblist.c index 2144b10e1d0..a22f6c12b0c 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -51,6 +51,7 @@ static struct tag_name { /* BLOBLISTT_PROJECT_AREA */ { BLOBLISTT_U_BOOT_SPL_HANDOFF, "SPL hand-off" }, + { BLOBLISTT_VBE, "VBE" }, { BLOBLISTT_U_BOOT_VIDEO, "SPL video handoff" }, /* BLOBLISTT_VENDOR_AREA */ @@ -476,6 +477,17 @@ int bloblist_init(void) log_debug("Found existing bloblist size %lx at %lx\n", size, addr); } + if (ret) + return log_msg_ret("ini", ret); + gd->flags |= GD_FLG_BLOBLIST_READY; + + return 0; +} - return ret; +int bloblist_maybe_init(void) +{ + if (CONFIG_IS_ENABLED(BLOBLIST) && !(gd->flags & GD_FLG_BLOBLIST_READY)) + return bloblist_init(); + + return 0; } diff --git a/common/board_f.c b/common/board_f.c index aef395b1354..d4d7d01f8f6 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -794,7 +794,7 @@ static int initf_bootstage(void) static int initf_dm(void) { -#if defined(CONFIG_DM) && CONFIG_VAL(SYS_MALLOC_F_LEN) +#if defined(CONFIG_DM) && CONFIG_IS_ENABLED(SYS_MALLOC_F) int ret; bootstage_start(BOOTSTAGE_ID_ACCUM_DM_F, "dm_f"); @@ -841,9 +841,7 @@ static const init_fnc_t init_sequence_f[] = { log_init, initf_bootstage, /* uses its own timer, so does not need DM */ event_init, -#ifdef CONFIG_BLOBLIST - bloblist_init, -#endif + bloblist_maybe_init, setup_spl_handoff, #if defined(CONFIG_CONSOLE_RECORD_INIT_F) console_record_init, diff --git a/common/board_r.c b/common/board_r.c index e30963339cf..52786901be5 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -191,7 +191,7 @@ static int initr_malloc(void) { ulong start; -#if CONFIG_VAL(SYS_MALLOC_F_LEN) +#if CONFIG_IS_ENABLED(SYS_MALLOC_F) debug("Pre-reloc malloc() used %#lx bytes (%ld KB)\n", gd->malloc_ptr, gd->malloc_ptr / 1024); #endif diff --git a/common/bootstage.c b/common/bootstage.c index 326c40f1561..a68d883c684 100644 --- a/common/bootstage.c +++ b/common/bootstage.c @@ -502,6 +502,20 @@ int bootstage_unstash(const void *base, int size) return 0; } +int _bootstage_stash_default(void) +{ + return bootstage_stash(map_sysmem(CONFIG_BOOTSTAGE_STASH_ADDR, 0), + CONFIG_BOOTSTAGE_STASH_SIZE); +} + +int _bootstage_unstash_default(void) +{ + const void *stash = map_sysmem(CONFIG_BOOTSTAGE_STASH_ADDR, + CONFIG_BOOTSTAGE_STASH_SIZE); + + return bootstage_unstash(stash, CONFIG_BOOTSTAGE_STASH_SIZE); +} + int bootstage_get_size(void) { struct bootstage_data *data = gd->bootstage; diff --git a/common/dlmalloc.c b/common/dlmalloc.c index aa933bdf577..87a09d38fb3 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -1291,7 +1291,7 @@ Void_t* mALLOc(bytes) size_t bytes; INTERNAL_SIZE_T nb; -#if CONFIG_VAL(SYS_MALLOC_F_LEN) +#if CONFIG_IS_ENABLED(SYS_MALLOC_F) if (!(gd->flags & GD_FLG_FULL_MALLOC_INIT)) return malloc_simple(bytes); #endif @@ -1572,7 +1572,7 @@ void fREe(mem) Void_t* mem; mchunkptr fwd; /* misc temp for linking */ int islr; /* track whether merging with last_remainder */ -#if CONFIG_VAL(SYS_MALLOC_F_LEN) +#if CONFIG_IS_ENABLED(SYS_MALLOC_F) /* free() is a no-op - all the memory will be freed on relocation */ if (!(gd->flags & GD_FLG_FULL_MALLOC_INIT)) { VALGRIND_FREELIKE_BLOCK(mem, SIZE_SZ); @@ -1735,7 +1735,7 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes; /* realloc of null is supposed to be same as malloc */ if (oldmem == NULL) return mALLOc(bytes); -#if CONFIG_VAL(SYS_MALLOC_F_LEN) +#if CONFIG_IS_ENABLED(SYS_MALLOC_F) if (!(gd->flags & GD_FLG_FULL_MALLOC_INIT)) { /* This is harder to support and should not be needed */ panic("pre-reloc realloc() is not supported"); @@ -1957,7 +1957,7 @@ Void_t* mEMALIGn(alignment, bytes) size_t alignment; size_t bytes; if ((long)bytes < 0) return NULL; -#if CONFIG_VAL(SYS_MALLOC_F_LEN) +#if CONFIG_IS_ENABLED(SYS_MALLOC_F) if (!(gd->flags & GD_FLG_FULL_MALLOC_INIT)) { return memalign_simple(alignment, bytes); } @@ -2153,7 +2153,7 @@ Void_t* cALLOc(n, elem_size) size_t n; size_t elem_size; return NULL; else { -#if CONFIG_VAL(SYS_MALLOC_F_LEN) +#if CONFIG_IS_ENABLED(SYS_MALLOC_F) if (!(gd->flags & GD_FLG_FULL_MALLOC_INIT)) { memset(mem, 0, sz); return mem; @@ -2455,7 +2455,7 @@ int mALLOPt(param_number, value) int param_number; int value; int initf_malloc(void) { -#if CONFIG_VAL(SYS_MALLOC_F_LEN) +#if CONFIG_IS_ENABLED(SYS_MALLOC_F) assert(gd->malloc_base); /* Set up by crt0.S */ gd->malloc_limit = CONFIG_VAL(SYS_MALLOC_F_LEN); gd->malloc_ptr = 0; diff --git a/common/init/board_init.c b/common/init/board_init.c index ab8c508ad83..ed2365daa35 100644 --- a/common/init/board_init.c +++ b/common/init/board_init.c @@ -79,7 +79,7 @@ ulong board_init_f_alloc_reserve(ulong top) { /* Reserve early malloc arena */ #ifndef CFG_MALLOC_F_ADDR -#if CONFIG_VAL(SYS_MALLOC_F_LEN) +#if CONFIG_IS_ENABLED(SYS_MALLOC_F) top -= CONFIG_VAL(SYS_MALLOC_F_LEN); #endif #endif @@ -159,7 +159,7 @@ void board_init_f_init_reserve(ulong base) * Use gd as it is now properly set for all architectures. */ -#if CONFIG_VAL(SYS_MALLOC_F_LEN) +#if CONFIG_IS_ENABLED(SYS_MALLOC_F) /* go down one 'early malloc arena' */ gd->malloc_base = base; #if CONFIG_IS_ENABLED(ZERO_MEM_BEFORE_USE) diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 1c2fe78e3e0..46323597942 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -402,21 +402,21 @@ config SPL_SEPARATE_BSS location is used. Normally we put the device tree at the end of BSS but with this option enabled, it goes at _image_binary_end. -config SYS_SPL_MALLOC +config SPL_SYS_MALLOC bool "Enable malloc pool in SPL" depends on SPL_FRAMEWORK -config HAS_CUSTOM_SPL_MALLOC_START +config SPL_HAS_CUSTOM_MALLOC_START bool "For the SPL malloc pool, define a custom starting address" - depends on SYS_SPL_MALLOC + depends on SPL_SYS_MALLOC -config CUSTOM_SYS_SPL_MALLOC_ADDR +config SPL_CUSTOM_SYS_MALLOC_ADDR hex "SPL malloc addr" - depends on HAS_CUSTOM_SPL_MALLOC_START + depends on SPL_HAS_CUSTOM_MALLOC_START -config SYS_SPL_MALLOC_SIZE +config SPL_SYS_MALLOC_SIZE hex "Size of the SPL malloc pool" - depends on SYS_SPL_MALLOC + depends on SPL_SYS_MALLOC default 0x100000 config SPL_READ_ONLY @@ -1063,7 +1063,7 @@ config SPL_OS_BOOT Enable booting directly to an OS from SPL. for more info read doc/README.falcon -config SYS_SPL_ARGS_ADDR +config SPL_PAYLOAD_ARGS_ADDR hex "Address in memory to load 'args' file for Falcon Mode to" depends on SPL_OS_BOOT default 0x88000000 if ARCH_OMAP2PLUS diff --git a/common/spl/Kconfig.nxp b/common/spl/Kconfig.nxp index fc696cf0cee..53e9b9f8d34 100644 --- a/common/spl/Kconfig.nxp +++ b/common/spl/Kconfig.nxp @@ -59,7 +59,7 @@ config SPL_RELOC_TEXT_BASE config SPL_RELOC_STACK hex "Address of the start of the stack SPL will use after relocation." help - If unspecified, this is equal to CFG_SYS_SPL_MALLOC_START. Starting + If unspecified, this is equal to CFG_SPL_SYS_MALLOC_START. Starting address of the malloc pool used in SPL. When this option is set the full malloc is used in SPL and it is set up by spl_init() and before that, the simple malloc() can be used if CONFIG_SYS_MALLOC_F is defined. diff --git a/common/spl/spl.c b/common/spl/spl.c index cd294e81b2a..0cf887fd626 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -256,102 +256,6 @@ void spl_set_header_raw_uboot(struct spl_image_info *spl_image) } #endif -#if CONFIG_IS_ENABLED(LOAD_FIT_FULL) -/* Parse and load full fitImage in SPL */ -static int spl_load_fit_image(struct spl_image_info *spl_image, - const struct legacy_img_hdr *header) -{ - struct bootm_headers images; - const char *fit_uname_config = NULL; - uintptr_t fdt_hack; - const char *uname; - ulong fw_data = 0, dt_data = 0, img_data = 0; - ulong fw_len = 0, dt_len = 0, img_len = 0; - int idx, conf_noffset; - int ret; - -#ifdef CONFIG_SPL_FIT_SIGNATURE - images.verify = 1; -#endif - ret = fit_image_load(&images, (ulong)header, - NULL, &fit_uname_config, - IH_ARCH_DEFAULT, IH_TYPE_STANDALONE, -1, - FIT_LOAD_OPTIONAL, &fw_data, &fw_len); - if (ret >= 0) { - printf("DEPRECATED: 'standalone = ' property."); - printf("Please use either 'firmware =' or 'kernel ='\n"); - } else { - ret = fit_image_load(&images, (ulong)header, NULL, - &fit_uname_config, IH_ARCH_DEFAULT, - IH_TYPE_FIRMWARE, -1, FIT_LOAD_OPTIONAL, - &fw_data, &fw_len); - } - - if (ret < 0) { - ret = fit_image_load(&images, (ulong)header, NULL, - &fit_uname_config, IH_ARCH_DEFAULT, - IH_TYPE_KERNEL, -1, FIT_LOAD_OPTIONAL, - &fw_data, &fw_len); - } - - if (ret < 0) - return ret; - - spl_image->size = fw_len; - spl_image->entry_point = fw_data; - spl_image->load_addr = fw_data; - if (fit_image_get_os(header, ret, &spl_image->os)) - spl_image->os = IH_OS_INVALID; - spl_image->name = genimg_get_os_name(spl_image->os); - - debug(SPL_TPL_PROMPT "payload image: %32s load addr: 0x%lx size: %d\n", - spl_image->name, spl_image->load_addr, spl_image->size); - -#ifdef CONFIG_SPL_FIT_SIGNATURE - images.verify = 1; -#endif - ret = fit_image_load(&images, (ulong)header, NULL, &fit_uname_config, - IH_ARCH_DEFAULT, IH_TYPE_FLATDT, -1, - FIT_LOAD_OPTIONAL, &dt_data, &dt_len); - if (ret >= 0) { - spl_image->fdt_addr = (void *)dt_data; - - if (spl_image->os == IH_OS_U_BOOT) { - /* HACK: U-Boot expects FDT at a specific address */ - fdt_hack = spl_image->load_addr + spl_image->size; - fdt_hack = (fdt_hack + 3) & ~3; - debug("Relocating FDT to %p\n", spl_image->fdt_addr); - memcpy((void *)fdt_hack, spl_image->fdt_addr, dt_len); - } - } - - conf_noffset = fit_conf_get_node((const void *)header, - fit_uname_config); - if (conf_noffset < 0) - return 0; - - for (idx = 0; - uname = fdt_stringlist_get((const void *)header, conf_noffset, - FIT_LOADABLE_PROP, idx, - NULL), uname; - idx++) - { -#ifdef CONFIG_SPL_FIT_SIGNATURE - images.verify = 1; -#endif - ret = fit_image_load(&images, (ulong)header, - &uname, &fit_uname_config, - IH_ARCH_DEFAULT, IH_TYPE_LOADABLE, -1, - FIT_LOAD_OPTIONAL_NON_ZERO, - &img_data, &img_len); - if (ret < 0) - return ret; - } - - return 0; -} -#endif - __weak int spl_parse_board_header(struct spl_image_info *spl_image, const struct spl_boot_device *bootdev, const void *image_header, size_t size) @@ -371,12 +275,14 @@ int spl_parse_image_header(struct spl_image_info *spl_image, const struct spl_boot_device *bootdev, const struct legacy_img_hdr *header) { -#if CONFIG_IS_ENABLED(LOAD_FIT_FULL) - int ret = spl_load_fit_image(spl_image, header); + int ret; - if (!ret) - return ret; -#endif + if (CONFIG_IS_ENABLED(LOAD_FIT_FULL)) { + ret = spl_load_fit_image(spl_image, header); + + if (!ret) + return ret; + } if (image_get_magic(header) == IH_MAGIC) { int ret; @@ -523,7 +429,7 @@ static int spl_common_init(bool setup_malloc) { int ret; -#if CONFIG_VAL(SYS_MALLOC_F_LEN) +#if CONFIG_IS_ENABLED(SYS_MALLOC_F) if (setup_malloc) { #ifdef CFG_MALLOC_F_ADDR gd->malloc_base = CFG_MALLOC_F_ADDR; @@ -538,17 +444,11 @@ static int spl_common_init(bool setup_malloc) ret); return ret; } -#ifdef CONFIG_BOOTSTAGE_STASH if (!u_boot_first_phase()) { - const void *stash = map_sysmem(CONFIG_BOOTSTAGE_STASH_ADDR, - CONFIG_BOOTSTAGE_STASH_SIZE); - - ret = bootstage_unstash(stash, CONFIG_BOOTSTAGE_STASH_SIZE); + ret = bootstage_unstash_default(); if (ret) - debug("%s: Failed to unstash bootstage: ret=%d\n", - __func__, ret); + log_debug("Failed to unstash bootstage: ret=%d\n", ret); } -#endif /* CONFIG_BOOTSTAGE_STASH */ bootstage_mark_name(get_bootstage_id(true), spl_phase_name(spl_phase())); #if CONFIG_IS_ENABLED(LOG) @@ -744,27 +644,21 @@ void board_init_r(gd_t *dummy1, ulong dummy2) BOOT_DEVICE_NONE, }; struct spl_image_info spl_image; - int ret; + int ret, os; debug(">>" SPL_TPL_PROMPT "board_init_r()\n"); spl_set_bd(); -#if defined(CONFIG_SYS_SPL_MALLOC) - mem_malloc_init(SYS_SPL_MALLOC_START, CONFIG_SYS_SPL_MALLOC_SIZE); - gd->flags |= GD_FLG_FULL_MALLOC_INIT; -#endif + if (IS_ENABLED(CONFIG_SPL_SYS_MALLOC)) { + mem_malloc_init(SPL_SYS_MALLOC_START, SPL_SYS_MALLOC_SIZE); + gd->flags |= GD_FLG_FULL_MALLOC_INIT; + } if (!(gd->flags & GD_FLG_SPL_INIT)) { if (spl_init()) hang(); } -#if !defined(CONFIG_PPC) && !defined(CONFIG_ARCH_MX6) - /* - * timer_init() does not exist on PPC systems. The timer is initialized - * and enabled (decrementer) in interrupt_init() here. - */ timer_init(); -#endif if (CONFIG_IS_ENABLED(BLOBLIST)) { ret = bloblist_init(); if (ret) { @@ -784,13 +678,11 @@ void board_init_r(gd_t *dummy1, ulong dummy2) } } -#if CONFIG_IS_ENABLED(BOARD_INIT) - spl_board_init(); -#endif + if (CONFIG_IS_ENABLED(BOARD_INIT)) + spl_board_init(); -#if defined(CONFIG_SPL_WATCHDOG) && CONFIG_IS_ENABLED(WDT) - initr_watchdog(); -#endif + if (IS_ENABLED(CONFIG_SPL_WATCHDOG) && CONFIG_IS_ENABLED(WDT)) + initr_watchdog(); if (IS_ENABLED(CONFIG_SPL_OS_BOOT) || CONFIG_IS_ENABLED(HANDOFF) || IS_ENABLED(CONFIG_SPL_ATF)) @@ -814,9 +706,8 @@ void board_init_r(gd_t *dummy1, ulong dummy2) } memset(&spl_image, '\0', sizeof(spl_image)); -#ifdef CONFIG_SYS_SPL_ARGS_ADDR - spl_image.arg = (void *)CONFIG_SYS_SPL_ARGS_ADDR; -#endif + if (IS_ENABLED(CONFIG_SPL_OS_BOOT)) + spl_image.arg = (void *)SPL_PAYLOAD_ARGS_ADDR; spl_image.boot_device = BOOT_DEVICE_NONE; board_boot_order(spl_boot_list); @@ -833,66 +724,39 @@ void board_init_r(gd_t *dummy1, ulong dummy2) } spl_perform_fixups(&spl_image); - if (CONFIG_IS_ENABLED(HANDOFF)) { - ret = write_spl_handoff(); - if (ret) - printf(SPL_TPL_PROMPT - "SPL hand-off write failed (err=%d)\n", ret); - } - if (CONFIG_IS_ENABLED(BLOBLIST)) { - ret = bloblist_finish(); - if (ret) - printf("Warning: Failed to finish bloblist (ret=%d)\n", - ret); - } - switch (spl_image.os) { - case IH_OS_U_BOOT: + os = spl_image.os; + if (os == IH_OS_U_BOOT) { debug("Jumping to %s...\n", spl_phase_name(spl_next_phase())); - break; -#if CONFIG_IS_ENABLED(ATF) - case IH_OS_ARM_TRUSTED_FIRMWARE: + } else if (CONFIG_IS_ENABLED(ATF) && os == IH_OS_ARM_TRUSTED_FIRMWARE) { debug("Jumping to U-Boot via ARM Trusted Firmware\n"); - spl_fixup_fdt(spl_image.fdt_addr); + spl_fixup_fdt(spl_image_fdt_addr(&spl_image)); spl_invoke_atf(&spl_image); - break; -#endif -#if CONFIG_IS_ENABLED(OPTEE_IMAGE) - case IH_OS_TEE: + } else if (CONFIG_IS_ENABLED(OPTEE_IMAGE) && os == IH_OS_TEE) { debug("Jumping to U-Boot via OP-TEE\n"); - spl_board_prepare_for_optee(spl_image.fdt_addr); + spl_board_prepare_for_optee(spl_image_fdt_addr(&spl_image)); jump_to_image_optee(&spl_image); - break; -#endif -#if CONFIG_IS_ENABLED(OPENSBI) - case IH_OS_OPENSBI: + } else if (CONFIG_IS_ENABLED(OPENSBI) && os == IH_OS_OPENSBI) { debug("Jumping to U-Boot via RISC-V OpenSBI\n"); spl_invoke_opensbi(&spl_image); - break; -#endif -#if CONFIG_IS_ENABLED(OS_BOOT) - case IH_OS_LINUX: + } else if (CONFIG_IS_ENABLED(OS_BOOT) && os == IH_OS_LINUX) { debug("Jumping to Linux\n"); -#if defined(CONFIG_SYS_SPL_ARGS_ADDR) - spl_fixup_fdt((void *)CONFIG_SYS_SPL_ARGS_ADDR); -#endif + if (IS_ENABLED(CONFIG_SPL_OS_BOOT)) + spl_fixup_fdt((void *)SPL_PAYLOAD_ARGS_ADDR); spl_board_prepare_for_linux(); jump_to_image_linux(&spl_image); -#endif - default: + } else { debug("Unsupported OS image.. Jumping nevertheless..\n"); } -#if CONFIG_VAL(SYS_MALLOC_F_LEN) && !defined(CONFIG_SYS_SPL_MALLOC_SIZE) - debug("SPL malloc() used 0x%lx bytes (%ld KB)\n", gd->malloc_ptr, - gd->malloc_ptr / 1024); -#endif + if (CONFIG_IS_ENABLED(SYS_MALLOC_F) && + !IS_ENABLED(CONFIG_SPL_SYS_MALLOC_SIZE)) + debug("SPL malloc() used 0x%lx bytes (%ld KB)\n", + gd_malloc_ptr(), gd_malloc_ptr() / 1024); + bootstage_mark_name(get_bootstage_id(false), "end phase"); -#ifdef CONFIG_BOOTSTAGE_STASH - ret = bootstage_stash((void *)CONFIG_BOOTSTAGE_STASH_ADDR, - CONFIG_BOOTSTAGE_STASH_SIZE); + ret = bootstage_stash_default(); if (ret) debug("Failed to stash bootstage: err=%d\n", ret); -#endif if (IS_ENABLED(CONFIG_SPL_VIDEO_REMOVE)) { struct udevice *dev; @@ -906,6 +770,18 @@ void board_init_r(gd_t *dummy1, ulong dummy2) dev->name, rc); } } + if (CONFIG_IS_ENABLED(HANDOFF)) { + ret = write_spl_handoff(); + if (ret) + printf(SPL_TPL_PROMPT + "SPL hand-off write failed (err=%d)\n", ret); + } + if (CONFIG_IS_ENABLED(BLOBLIST)) { + ret = bloblist_finish(); + if (ret) + printf("Warning: Failed to finish bloblist (ret=%d)\n", + ret); + } spl_board_prepare_for_boot(); jump_to_image_no_args(&spl_image); @@ -983,7 +859,7 @@ ulong spl_relocate_stack_gd(void) if (CONFIG_IS_ENABLED(SYS_REPORT_STACK_F_USAGE)) spl_relocate_stack_check(); -#if defined(CONFIG_SPL_SYS_MALLOC_SIMPLE) && CONFIG_VAL(SYS_MALLOC_F_LEN) +#if defined(CONFIG_SPL_SYS_MALLOC_SIMPLE) && CONFIG_IS_ENABLED(SYS_MALLOC_F) if (CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN) { debug("SPL malloc() before relocation used 0x%lx bytes (%ld KB)\n", gd->malloc_ptr, gd->malloc_ptr / 1024); diff --git a/common/spl/spl_ext.c b/common/spl/spl_ext.c index 2bf34344391..902564a6077 100644 --- a/common/spl/spl_ext.c +++ b/common/spl/spl_ext.c @@ -97,7 +97,7 @@ int spl_load_image_ext_os(struct spl_image_info *spl_image, puts("spl: ext4fs_open failed\n"); goto defaults; } - err = ext4fs_read((void *)CONFIG_SYS_SPL_ARGS_ADDR, 0, filelen, &actlen); + err = ext4fs_read((void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR, 0, filelen, &actlen); if (err < 0) { printf("spl: error reading image %s, err - %d, falling back to default\n", file, err); @@ -127,7 +127,7 @@ defaults: if (err < 0) puts("spl: ext4fs_open failed\n"); - err = ext4fs_read((void *)CONFIG_SYS_SPL_ARGS_ADDR, 0, filelen, &actlen); + err = ext4fs_read((void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR, 0, filelen, &actlen); if (err < 0) { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT printf("%s: error reading image %s, err - %d\n", diff --git a/common/spl/spl_fat.c b/common/spl/spl_fat.c index f8a5b80a3bd..c6e2526ade1 100644 --- a/common/spl/spl_fat.c +++ b/common/spl/spl_fat.c @@ -128,7 +128,7 @@ int spl_load_image_fat_os(struct spl_image_info *spl_image, #if defined(CONFIG_SPL_ENV_SUPPORT) && defined(CONFIG_SPL_OS_BOOT) file = env_get("falcon_args_file"); if (file) { - err = file_fat_read(file, (void *)CONFIG_SYS_SPL_ARGS_ADDR, 0); + err = file_fat_read(file, (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR, 0); if (err <= 0) { printf("spl: error reading image %s, err - %d, falling back to default\n", file, err); @@ -153,7 +153,7 @@ defaults: #endif err = file_fat_read(CONFIG_SPL_FS_LOAD_ARGS_NAME, - (void *)CONFIG_SYS_SPL_ARGS_ADDR, 0); + (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR, 0); if (err <= 0) { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT printf("%s: error reading image %s, err - %d\n", diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index b1668c0396c..93480a5a60d 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -44,7 +44,7 @@ static int find_node_from_desc(const void *fit, int node, const char *str) for (child = fdt_first_subnode(fit, node); child >= 0; child = fdt_next_subnode(fit, child)) { int len; - const char *desc = fdt_getprop(fit, child, "description", &len); + const char *desc = fdt_getprop(fit, child, FIT_DESC_PROP, &len); if (!desc) continue; @@ -208,7 +208,7 @@ static int get_aligned_image_size(struct spl_load_info *info, int data_size, } /** - * spl_load_fit_image(): load the image described in a certain FIT node + * load_simple_fit(): load the image described in a certain FIT node * @info: points to information about the device to load data from * @sector: the start sector of the FIT image on the device * @ctx: points to the FIT context structure @@ -221,9 +221,9 @@ static int get_aligned_image_size(struct spl_load_info *info, int data_size, * * Return: 0 on success or a negative error number. */ -static int spl_load_fit_image(struct spl_load_info *info, ulong sector, - const struct spl_fit_info *ctx, int node, - struct spl_image_info *image_info) +static int load_simple_fit(struct spl_load_info *info, ulong sector, + const struct spl_fit_info *ctx, int node, + struct spl_image_info *image_info) { int offset; size_t length; @@ -386,8 +386,7 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image, else return node; } else { - ret = spl_load_fit_image(info, sector, ctx, node, - &image_info); + ret = load_simple_fit(info, sector, ctx, node, &image_info); if (ret < 0) return ret; } @@ -426,8 +425,8 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image, __func__); } image_info.load_addr = (ulong)tmpbuffer; - ret = spl_load_fit_image(info, sector, ctx, - node, &image_info); + ret = load_simple_fit(info, sector, ctx, node, + &image_info); if (ret < 0) break; @@ -477,10 +476,11 @@ static int spl_fit_record_loadable(const struct spl_fit_info *ctx, int index, node = spl_fit_get_image_node(ctx, "loadables", index); ret = fdt_record_loadable(blob, index, name, image->load_addr, - image->size, image->entry_point, - fdt_getprop(ctx->fit, node, "type", NULL), - fdt_getprop(ctx->fit, node, "os", NULL), - fdt_getprop(ctx->fit, node, "arch", NULL)); + image->size, image->entry_point, + fdt_getprop(ctx->fit, node, FIT_TYPE_PROP, NULL), + fdt_getprop(ctx->fit, node, FIT_OS_PROP, NULL), + fdt_getprop(ctx->fit, node, FIT_ARCH_PROP, NULL)); + return ret; } @@ -531,7 +531,7 @@ static void *spl_get_fit_load_buffer(size_t size) buf = malloc_cache_aligned(size); if (!buf) { pr_err("Could not get FIT buffer of %lu bytes\n", (ulong)size); - pr_err("\tcheck CONFIG_SYS_SPL_MALLOC_SIZE\n"); + pr_err("\tcheck CONFIG_SPL_SYS_MALLOC_SIZE\n"); buf = spl_get_load_buffer(0, size); } return buf; @@ -617,7 +617,7 @@ static int spl_fit_load_fpga(struct spl_fit_info *ctx, warn_deprecated("'fpga' property in config node. Use 'loadables'"); /* Load the image and set up the fpga_image structure */ - ret = spl_load_fit_image(info, sector, ctx, node, &fpga_image); + ret = load_simple_fit(info, sector, ctx, node, &fpga_image); if (ret) { printf("%s: Cannot load the FPGA: %i\n", __func__, ret); return ret; @@ -742,7 +742,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, } /* Load the image and set up the spl_image structure */ - ret = spl_load_fit_image(info, sector, &ctx, node, spl_image); + ret = load_simple_fit(info, sector, &ctx, node, spl_image); if (ret) return ret; @@ -783,7 +783,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, continue; image_info.load_addr = 0; - ret = spl_load_fit_image(info, sector, &ctx, node, &image_info); + ret = load_simple_fit(info, sector, &ctx, node, &image_info); if (ret < 0) { printf("%s: can't load image loadables index %d (ret = %d)\n", __func__, index, ret); @@ -828,3 +828,96 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, return 0; } + +/* Parse and load full fitImage in SPL */ +int spl_load_fit_image(struct spl_image_info *spl_image, + const struct legacy_img_hdr *header) +{ + struct bootm_headers images; + const char *fit_uname_config = NULL; + uintptr_t fdt_hack; + const char *uname; + ulong fw_data = 0, dt_data = 0, img_data = 0; + ulong fw_len = 0, dt_len = 0, img_len = 0; + int idx, conf_noffset; + int ret; + +#ifdef CONFIG_SPL_FIT_SIGNATURE + images.verify = 1; +#endif + ret = fit_image_load(&images, (ulong)header, + NULL, &fit_uname_config, + IH_ARCH_DEFAULT, IH_TYPE_STANDALONE, -1, + FIT_LOAD_OPTIONAL, &fw_data, &fw_len); + if (ret >= 0) { + printf("DEPRECATED: 'standalone = ' property."); + printf("Please use either 'firmware =' or 'kernel ='\n"); + } else { + ret = fit_image_load(&images, (ulong)header, NULL, + &fit_uname_config, IH_ARCH_DEFAULT, + IH_TYPE_FIRMWARE, -1, FIT_LOAD_OPTIONAL, + &fw_data, &fw_len); + } + + if (ret < 0) { + ret = fit_image_load(&images, (ulong)header, NULL, + &fit_uname_config, IH_ARCH_DEFAULT, + IH_TYPE_KERNEL, -1, FIT_LOAD_OPTIONAL, + &fw_data, &fw_len); + } + + if (ret < 0) + return ret; + + spl_image->size = fw_len; + spl_image->entry_point = fw_data; + spl_image->load_addr = fw_data; + if (fit_image_get_os(header, ret, &spl_image->os)) + spl_image->os = IH_OS_INVALID; + spl_image->name = genimg_get_os_name(spl_image->os); + + debug(SPL_TPL_PROMPT "payload image: %32s load addr: 0x%lx size: %d\n", + spl_image->name, spl_image->load_addr, spl_image->size); + +#ifdef CONFIG_SPL_FIT_SIGNATURE + images.verify = 1; +#endif + ret = fit_image_load(&images, (ulong)header, NULL, &fit_uname_config, + IH_ARCH_DEFAULT, IH_TYPE_FLATDT, -1, + FIT_LOAD_OPTIONAL, &dt_data, &dt_len); + if (ret >= 0) { + spl_image->fdt_addr = (void *)dt_data; + + if (spl_image->os == IH_OS_U_BOOT) { + /* HACK: U-Boot expects FDT at a specific address */ + fdt_hack = spl_image->load_addr + spl_image->size; + fdt_hack = (fdt_hack + 3) & ~3; + debug("Relocating FDT to %p\n", spl_image->fdt_addr); + memcpy((void *)fdt_hack, spl_image->fdt_addr, dt_len); + } + } + + conf_noffset = fit_conf_get_node((const void *)header, + fit_uname_config); + if (conf_noffset < 0) + return 0; + + for (idx = 0; + uname = fdt_stringlist_get((const void *)header, conf_noffset, + FIT_LOADABLE_PROP, idx, + NULL), uname; + idx++) { +#ifdef CONFIG_SPL_FIT_SIGNATURE + images.verify = 1; +#endif + ret = fit_image_load(&images, (ulong)header, + &uname, &fit_uname_config, + IH_ARCH_DEFAULT, IH_TYPE_LOADABLE, -1, + FIT_LOAD_OPTIONAL_NON_ZERO, + &img_data, &img_len); + if (ret < 0) + return ret; + } + + return 0; +} diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index 20f687e1389..0ab85d2168c 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -235,7 +235,7 @@ static int mmc_load_image_raw_os(struct spl_image_info *spl_image, count = blk_dread(mmc_get_blk_desc(mmc), CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR, CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS, - (void *) CONFIG_SYS_SPL_ARGS_ADDR); + (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR); if (count != CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS) { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT puts("mmc_load_image_raw_os: mmc block read error\n"); diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c index dc45204fc0e..6cc34004f49 100644 --- a/common/spl/spl_nand.c +++ b/common/spl/spl_nand.c @@ -159,11 +159,11 @@ static int spl_nand_load_image(struct spl_image_info *spl_image, CONFIG_CMD_SPL_WRITE_SIZE, (void *)CONFIG_TEXT_BASE); /* copy to destintion */ - for (dst = (int *)CONFIG_SYS_SPL_ARGS_ADDR, - src = (int *)CONFIG_TEXT_BASE; - src < (int *)(CONFIG_TEXT_BASE + - CONFIG_CMD_SPL_WRITE_SIZE); - src++, dst++) { + for (dst = (int *)CONFIG_SPL_PAYLOAD_ARGS_ADDR, + src = (int *)CONFIG_TEXT_BASE; + src < (int *)(CONFIG_TEXT_BASE + + CONFIG_CMD_SPL_WRITE_SIZE); + src++, dst++) { writel(readl(src), dst); } diff --git a/common/spl/spl_nor.c b/common/spl/spl_nor.c index 5b65b96a77d..79d4f1d7aa8 100644 --- a/common/spl/spl_nor.c +++ b/common/spl/spl_nor.c @@ -54,8 +54,8 @@ static int spl_nor_load_image(struct spl_image_info *spl_image, CONFIG_SYS_OS_BASE, (void *)header); -#if defined CONFIG_SYS_SPL_ARGS_ADDR && defined CONFIG_CMD_SPL_NOR_OFS - memcpy((void *)CONFIG_SYS_SPL_ARGS_ADDR, +#if defined CONFIG_SPL_PAYLOAD_ARGS_ADDR && defined CONFIG_CMD_SPL_NOR_OFS + memcpy((void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR, (void *)CONFIG_CMD_SPL_NOR_OFS, CONFIG_CMD_SPL_WRITE_SIZE); #endif @@ -74,8 +74,8 @@ static int spl_nor_load_image(struct spl_image_info *spl_image, (void *)(CONFIG_SYS_OS_BASE + sizeof(struct legacy_img_hdr)), spl_image->size); -#ifdef CONFIG_SYS_SPL_ARGS_ADDR - spl_image->arg = (void *)CONFIG_SYS_SPL_ARGS_ADDR; +#ifdef CONFIG_SPL_PAYLOAD_ARGS_ADDR + spl_image->arg = (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR; #endif return 0; diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c index 2aff025f76e..d69069a75bf 100644 --- a/common/spl/spl_spi.c +++ b/common/spl/spl_spi.c @@ -47,7 +47,7 @@ static int spi_load_image_os(struct spl_image_info *spl_image, /* Read device tree. */ spi_flash_read(flash, CFG_SYS_SPI_ARGS_OFFS, CFG_SYS_SPI_ARGS_SIZE, - (void *)CONFIG_SYS_SPL_ARGS_ADDR); + (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR); return 0; } diff --git a/common/spl/spl_ubi.c b/common/spl/spl_ubi.c index bcac25cd021..d7ab9efd110 100644 --- a/common/spl/spl_ubi.c +++ b/common/spl/spl_ubi.c @@ -50,7 +50,7 @@ int spl_ubi_load_image(struct spl_image_info *spl_image, volumes[0].vol_id = CONFIG_SPL_UBI_LOAD_KERNEL_ID; volumes[0].load_addr = (void *)CONFIG_SYS_LOAD_ADDR; volumes[1].vol_id = CONFIG_SPL_UBI_LOAD_ARGS_ID; - volumes[1].load_addr = (void *)CONFIG_SYS_SPL_ARGS_ADDR; + volumes[1].load_addr = (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR; ret = ubispl_load_volumes(&info, volumes, 2); if (!ret) { diff --git a/common/spl/spl_xip.c b/common/spl/spl_xip.c index 77c23ba0597..959915ffa61 100644 --- a/common/spl/spl_xip.c +++ b/common/spl/spl_xip.c @@ -14,7 +14,7 @@ static int spl_xip(struct spl_image_info *spl_image, { #if CONFIG_IS_ENABLED(OS_BOOT) if (!spl_start_uboot()) { - spl_image->arg = (void *)CONFIG_SYS_SPL_ARGS_ADDR; + spl_image->arg = (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR; spl_image->name = "Linux"; spl_image->os = IH_OS_LINUX; spl_image->load_addr = CONFIG_SYS_LOAD_ADDR; |