diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/Kconfig | 8 | ||||
-rw-r--r-- | common/Kconfig.boot | 5 | ||||
-rw-r--r-- | common/Makefile | 1 | ||||
-rw-r--r-- | common/avb_verify.c | 2 | ||||
-rw-r--r-- | common/board_info.c | 37 | ||||
-rw-r--r-- | common/board_r.c | 6 | ||||
-rw-r--r-- | common/bootm.c | 5 | ||||
-rw-r--r-- | common/bootstage.c | 20 | ||||
-rw-r--r-- | common/fdt_support.c | 20 | ||||
-rw-r--r-- | common/image-fit.c | 6 | ||||
-rw-r--r-- | common/image.c | 24 | ||||
-rw-r--r-- | common/log.c | 16 | ||||
-rw-r--r-- | common/log_console.c | 26 | ||||
-rw-r--r-- | common/scp03.c | 53 | ||||
-rw-r--r-- | common/spl/Kconfig | 26 | ||||
-rw-r--r-- | common/spl/spl.c | 29 | ||||
-rw-r--r-- | common/spl/spl_fit.c | 27 |
17 files changed, 244 insertions, 67 deletions
diff --git a/common/Kconfig b/common/Kconfig index 2bb3798f80..482f123534 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -588,6 +588,14 @@ config AVB_BUF_SIZE endif # AVB_VERIFY +config SCP03 + bool "Build SCP03 - Secure Channel Protocol O3 - controls" + depends on OPTEE || SANDBOX + depends on TEE + help + This option allows U-Boot to enable and or provision SCP03 on an OPTEE + controlled Secured Element. + config SPL_HASH bool # "Support hashing API (SHA1, SHA256, etc.)" help diff --git a/common/Kconfig.boot b/common/Kconfig.boot index 70c02b9e30..9c335f4f8c 100644 --- a/common/Kconfig.boot +++ b/common/Kconfig.boot @@ -138,7 +138,7 @@ config FIT_BEST_MATCH config FIT_IMAGE_POST_PROCESS bool "Enable post-processing of FIT artifacts after loading by U-Boot" - depends on TI_SECURE_DEVICE + depends on TI_SECURE_DEVICE || SOCFPGA_SECURE_VAB_AUTH help Allows doing any sort of manipulation to blobs after they got extracted from FIT images like stripping off headers or modifying the size of the @@ -449,6 +449,7 @@ config BOOTSTAGE_REPORT config BOOTSTAGE_RECORD_COUNT int "Number of boot stage records to store" + depends on BOOTSTAGE default 30 help This is the size of the bootstage record list and is the maximum @@ -456,6 +457,7 @@ config BOOTSTAGE_RECORD_COUNT config SPL_BOOTSTAGE_RECORD_COUNT int "Number of boot stage records to store for SPL" + depends on SPL_BOOTSTAGE default 5 help This is the size of the bootstage record list and is the maximum @@ -463,6 +465,7 @@ config SPL_BOOTSTAGE_RECORD_COUNT config TPL_BOOTSTAGE_RECORD_COUNT int "Number of boot stage records to store for TPL" + depends on TPL_BOOTSTAGE default 5 help This is the size of the bootstage record list and is the maximum diff --git a/common/Makefile b/common/Makefile index daeea67cf2..215b8b26fd 100644 --- a/common/Makefile +++ b/common/Makefile @@ -137,3 +137,4 @@ obj-$(CONFIG_CMD_LOADB) += xyzModem.o obj-$(CONFIG_$(SPL_TPL_)YMODEM_SUPPORT) += xyzModem.o obj-$(CONFIG_AVB_VERIFY) += avb_verify.o +obj-$(CONFIG_SCP03) += scp03.o diff --git a/common/avb_verify.c b/common/avb_verify.c index db10d0f21f..0520a71455 100644 --- a/common/avb_verify.c +++ b/common/avb_verify.c @@ -369,7 +369,7 @@ static struct mmc_part *get_partition(AvbOps *ops, const char *partition) } ret = part_get_info_by_name(mmc_blk, partition, &part->info); - if (!ret) { + if (ret < 0) { printf("Can't find partition '%s'\n", partition); goto err; } diff --git a/common/board_info.c b/common/board_info.c index b54aa30a94..1cfe34f706 100644 --- a/common/board_info.c +++ b/common/board_info.c @@ -1,31 +1,52 @@ // SPDX-License-Identifier: GPL-2.0+ #include <common.h> +#include <dm.h> #include <init.h> +#include <sysinfo.h> #include <asm/global_data.h> #include <linux/libfdt.h> #include <linux/compiler.h> +DECLARE_GLOBAL_DATA_PTR; + int __weak checkboard(void) { return 0; } /* - * If the root node of the DTB has a "model" property, show it. + * Check sysinfo for board information. Failing that if the root node of the DTB + * has a "model" property, show it. + * * Then call checkboard(). */ int __weak show_board_info(void) { -#ifdef CONFIG_OF_CONTROL - DECLARE_GLOBAL_DATA_PTR; - const char *model; + if (IS_ENABLED(CONFIG_OF_CONTROL)) { + struct udevice *dev; + const char *model; + char str[80]; + int ret = -ENOSYS; + + if (IS_ENABLED(CONFIG_SYSINFO)) { + /* This might provide more detail */ + ret = uclass_first_device_err(UCLASS_SYSINFO, &dev); + if (!ret) + ret = sysinfo_get_str(dev, + SYSINFO_ID_BOARD_MODEL, + sizeof(str), str); + } - model = fdt_getprop(gd->fdt_blob, 0, "model", NULL); + /* Fail back to the main 'model' if available */ + if (ret) + model = fdt_getprop(gd->fdt_blob, 0, "model", NULL); + else + model = str; - if (model) - printf("Model: %s\n", model); -#endif + if (model) + printf("Model: %s\n", model); + } return checkboard(); } diff --git a/common/board_r.c b/common/board_r.c index 9793439adf..c835ff8e26 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -626,6 +626,9 @@ static init_fnc_t init_sequence_r[] = { #ifdef CONFIG_DM initr_dm, #endif +#ifdef CONFIG_ADDR_MAP + initr_addr_map, +#endif #if defined(CONFIG_ARM) || defined(CONFIG_NDS32) || defined(CONFIG_RISCV) || \ defined(CONFIG_SANDBOX) board_init, /* Setup chipselects */ @@ -661,9 +664,6 @@ static init_fnc_t init_sequence_r[] = { initr_manual_reloc_cmdtable, #endif arch_initr_trap, -#ifdef CONFIG_ADDR_MAP - initr_addr_map, -#endif #if defined(CONFIG_BOARD_EARLY_INIT_R) board_early_init_r, #endif diff --git a/common/bootm.c b/common/bootm.c index defaed8426..ea71522d0c 100644 --- a/common/bootm.c +++ b/common/bootm.c @@ -583,10 +583,11 @@ int bootm_process_cmdline(char *buf, int maxlen, int flags) if (ret) return log_msg_ret("silent", ret); } - if (IS_ENABLED(CONFIG_BOOTARGS_SUBST) && (flags & BOOTM_CL_SUBST)) { + if (IS_ENABLED(CONFIG_BOOTARGS_SUBST) && IS_ENABLED(CONFIG_CMDLINE) && + (flags & BOOTM_CL_SUBST)) { ret = process_subst(buf, maxlen); if (ret) - return log_msg_ret("silent", ret); + return log_msg_ret("subst", ret); } return 0; diff --git a/common/bootstage.c b/common/bootstage.c index d5b78b9f48..4621105682 100644 --- a/common/bootstage.c +++ b/common/bootstage.c @@ -9,6 +9,8 @@ * permits accurate timestamping of each. */ +#define LOG_CATEGORY LOGC_BOOT + #include <common.h> #include <bootstage.h> #include <hang.h> @@ -127,12 +129,16 @@ ulong bootstage_add_record(enum bootstage_id id, const char *name, /* Only record the first event for each */ rec = find_id(data, id); - if (!rec && data->rec_count < RECORD_COUNT) { - rec = &data->record[data->rec_count++]; - rec->time_us = mark; - rec->name = name; - rec->flags = flags; - rec->id = id; + if (!rec) { + if (data->rec_count < RECORD_COUNT) { + rec = &data->record[data->rec_count++]; + rec->time_us = mark; + rec->name = name; + rec->flags = flags; + rec->id = id; + } else { + log_warning("Bootstage space exhasuted\n"); + } } /* Tell the board about this progress */ @@ -349,7 +355,7 @@ void bootstage_report(void) } if (data->rec_count > RECORD_COUNT) printf("Overflowed internal boot id table by %d entries\n" - "Please increase CONFIG_(SPL_)BOOTSTAGE_RECORD_COUNT\n", + "Please increase CONFIG_(SPL_TPL_)BOOTSTAGE_RECORD_COUNT\n", data->rec_count - RECORD_COUNT); puts("\nAccumulated time:\n"); diff --git a/common/fdt_support.c b/common/fdt_support.c index 08d540bfc8..e624bbdf40 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -1668,22 +1668,36 @@ u64 fdt_get_base_address(const void *fdt, int node) } /* - * Read a property of size <prop_len>. Currently only supports 1 or 2 cells. + * Read a property of size <prop_len>. Currently only supports 1 or 2 cells, + * or 3 cells specially for a PCI address. */ static int fdt_read_prop(const fdt32_t *prop, int prop_len, int cell_off, uint64_t *val, int cells) { - const fdt32_t *prop32 = &prop[cell_off]; - const unaligned_fdt64_t *prop64 = (const fdt64_t *)&prop[cell_off]; + const fdt32_t *prop32; + const unaligned_fdt64_t *prop64; if ((cell_off + cells) > prop_len) return -FDT_ERR_NOSPACE; + prop32 = &prop[cell_off]; + + /* + * Special handling for PCI address in PCI bus <ranges> + * + * PCI child address is made up of 3 cells. Advance the cell offset + * by 1 so that the PCI child address can be correctly read. + */ + if (cells == 3) + cell_off += 1; + prop64 = (const fdt64_t *)&prop[cell_off]; + switch (cells) { case 1: *val = fdt32_to_cpu(*prop32); break; case 2: + case 3: *val = fdt64_to_cpu(*prop64); break; default: diff --git a/common/image-fit.c b/common/image-fit.c index 28b3d2b191..b972042f43 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -1512,6 +1512,10 @@ int fit_image_check_arch(const void *fit, int noffset, uint8_t arch) uint8_t image_arch; int aarch32_support = 0; + /* Let's assume that sandbox can load any architecture */ + if (IS_ENABLED(CONFIG_SANDBOX)) + return true; + if (IS_ENABLED(CONFIG_ARM64_SUPPORT_AARCH32)) aarch32_support = 1; @@ -1651,7 +1655,7 @@ int fit_check_format(const void *fit, ulong size) /* mandatory / node 'timestamp' property */ if (!fdt_getprop(fit, 0, FIT_TIMESTAMP_PROP, NULL)) { log_debug("Wrong FIT format: no timestamp\n"); - return -ENODATA; + return -EBADMSG; } } diff --git a/common/image.c b/common/image.c index a6500f5f5c..51854aae5d 100644 --- a/common/image.c +++ b/common/image.c @@ -462,13 +462,16 @@ int image_decomp(int comp, ulong load, ulong image_start, int type, else ret = -ENOSPC; break; -#ifdef CONFIG_GZIP +#ifndef USE_HOSTCC +#if CONFIG_IS_ENABLED(GZIP) case IH_COMP_GZIP: { ret = gunzip(load_buf, unc_len, image_buf, &image_len); break; } #endif /* CONFIG_GZIP */ -#ifdef CONFIG_BZIP2 +#endif +#ifndef USE_HOSTCC +#if CONFIG_IS_ENABLED(BZIP2) case IH_COMP_BZIP2: { uint size = unc_len; @@ -484,7 +487,9 @@ int image_decomp(int comp, ulong load, ulong image_start, int type, break; } #endif /* CONFIG_BZIP2 */ -#ifdef CONFIG_LZMA +#endif +#ifndef USE_HOSTCC +#if CONFIG_IS_ENABLED(LZMA) case IH_COMP_LZMA: { SizeT lzma_len = unc_len; @@ -494,7 +499,9 @@ int image_decomp(int comp, ulong load, ulong image_start, int type, break; } #endif /* CONFIG_LZMA */ -#ifdef CONFIG_LZO +#endif +#ifndef USE_HOSTCC +#if CONFIG_IS_ENABLED(LZO) case IH_COMP_LZO: { size_t size = unc_len; @@ -503,7 +510,9 @@ int image_decomp(int comp, ulong load, ulong image_start, int type, break; } #endif /* CONFIG_LZO */ -#ifdef CONFIG_LZ4 +#endif +#ifndef USE_HOSTCC +#if CONFIG_IS_ENABLED(LZ4) case IH_COMP_LZ4: { size_t size = unc_len; @@ -512,7 +521,9 @@ int image_decomp(int comp, ulong load, ulong image_start, int type, break; } #endif /* CONFIG_LZ4 */ -#ifdef CONFIG_ZSTD +#endif +#ifndef USE_HOSTCC +#if CONFIG_IS_ENABLED(ZSTD) case IH_COMP_ZSTD: { size_t size = unc_len; ZSTD_DStream *dstream; @@ -562,6 +573,7 @@ int image_decomp(int comp, ulong load, ulong image_start, int type, break; } #endif /* CONFIG_ZSTD */ +#endif default: printf("Unimplemented compression type %d\n", comp); return -ENOSYS; diff --git a/common/log.c b/common/log.c index 6b0034c3ba..ea407c6db9 100644 --- a/common/log.c +++ b/common/log.c @@ -153,7 +153,7 @@ static bool log_passes_filters(struct log_device *ldev, struct log_rec *rec) { struct log_filter *filt; - if (rec->force_debug) + if (rec->flags & LOGRECF_FORCE_DEBUG) return true; /* If there are no filters, filter on the default log level */ @@ -218,8 +218,11 @@ static int log_dispatch(struct log_rec *rec, const char *fmt, va_list args) if ((ldev->flags & LOGDF_ENABLE) && log_passes_filters(ldev, rec)) { if (!rec->msg) { - vsnprintf(buf, sizeof(buf), fmt, args); + int len; + + len = vsnprintf(buf, sizeof(buf), fmt, args); rec->msg = buf; + gd->log_cont = len && buf[len - 1] != '\n'; } ldev->drv->emit(ldev, rec); } @@ -245,7 +248,11 @@ int _log(enum log_category_t cat, enum log_level_t level, const char *file, rec.cat = cat; rec.level = level & LOGL_LEVEL_MASK; - rec.force_debug = level & LOGL_FORCE_DEBUG; + rec.flags = 0; + if (level & LOGL_FORCE_DEBUG) + rec.flags |= LOGRECF_FORCE_DEBUG; + if (gd->log_cont) + rec.flags |= LOGRECF_CONT; rec.file = file; rec.line = line; rec.func = func; @@ -255,7 +262,8 @@ int _log(enum log_category_t cat, enum log_level_t level, const char *file, gd->log_drop_count++; /* display dropped traces with console puts and DEBUG_UART */ - if (rec.level <= CONFIG_LOG_DEFAULT_LEVEL || rec.force_debug) { + if (rec.level <= CONFIG_LOG_DEFAULT_LEVEL || + rec.flags & LOGRECF_FORCE_DEBUG) { char buf[CONFIG_SYS_CBSIZE]; va_start(args, fmt); diff --git a/common/log_console.c b/common/log_console.c index 6abb13c93b..3f6177499e 100644 --- a/common/log_console.c +++ b/common/log_console.c @@ -15,6 +15,7 @@ DECLARE_GLOBAL_DATA_PTR; static int log_console_emit(struct log_device *ldev, struct log_rec *rec) { int fmt = gd->log_fmt; + bool add_space = false; /* * The output format is designed to give someone a fighting chance of @@ -26,18 +27,21 @@ static int log_console_emit(struct log_device *ldev, struct log_rec *rec) * - function is an identifier and ends with () * - message has a space before it unless it is on its own */ - if (fmt & BIT(LOGF_LEVEL)) - printf("%s.", log_get_level_name(rec->level)); - if (fmt & BIT(LOGF_CAT)) - printf("%s,", log_get_cat_name(rec->cat)); - if (fmt & BIT(LOGF_FILE)) - printf("%s:", rec->file); - if (fmt & BIT(LOGF_LINE)) - printf("%d-", rec->line); - if (fmt & BIT(LOGF_FUNC)) - printf("%s()", rec->func); + if (!(rec->flags & LOGRECF_CONT) && fmt != BIT(LOGF_MSG)) { + add_space = true; + if (fmt & BIT(LOGF_LEVEL)) + printf("%s.", log_get_level_name(rec->level)); + if (fmt & BIT(LOGF_CAT)) + printf("%s,", log_get_cat_name(rec->cat)); + if (fmt & BIT(LOGF_FILE)) + printf("%s:", rec->file); + if (fmt & BIT(LOGF_LINE)) + printf("%d-", rec->line); + if (fmt & BIT(LOGF_FUNC)) + printf("%s()", rec->func); + } if (fmt & BIT(LOGF_MSG)) - printf("%s%s", fmt != BIT(LOGF_MSG) ? " " : "", rec->msg); + printf("%s%s", add_space ? " " : "", rec->msg); return 0; } diff --git a/common/scp03.c b/common/scp03.c new file mode 100644 index 0000000000..09ef7b5ba3 --- /dev/null +++ b/common/scp03.c @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2021, Foundries.IO + * + */ + +#include <common.h> +#include <scp03.h> +#include <tee.h> +#include <tee/optee_ta_scp03.h> + +static int scp03_enable(bool provision) +{ + const struct tee_optee_ta_uuid uuid = PTA_SCP03_UUID; + struct tee_open_session_arg session; + struct tee_invoke_arg invoke; + struct tee_param param; + struct udevice *tee = NULL; + + tee = tee_find_device(tee, NULL, NULL, NULL); + if (!tee) + return -ENODEV; + + memset(&session, 0, sizeof(session)); + tee_optee_ta_uuid_to_octets(session.uuid, &uuid); + if (tee_open_session(tee, &session, 0, NULL)) + return -ENXIO; + + memset(¶m, 0, sizeof(param)); + param.attr = TEE_PARAM_ATTR_TYPE_VALUE_INPUT; + param.u.value.a = provision; + + memset(&invoke, 0, sizeof(invoke)); + invoke.func = PTA_CMD_ENABLE_SCP03; + invoke.session = session.session; + + if (tee_invoke_func(tee, &invoke, 1, ¶m)) + return -EIO; + + tee_close_session(tee, session.session); + + return 0; +} + +int tee_enable_scp03(void) +{ + return scp03_enable(false); +} + +int tee_provision_scp03(void) +{ + return scp03_enable(true); +} diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 774541c02b..0711cbf951 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -276,6 +276,19 @@ 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 SPL_READ_ONLY + bool + depends on SPL_OF_PLATDATA + # Bind cannot be supported because the udevice structs are in read-only + # memory so we cannot update the linked lists. + select SPL_OF_PLATDATA_NO_BIND + select SPL_OF_PLATDATA_RT + help + Some platforms (e.g. x86 Apollo Lake) load SPL into a read-only + section of memory. This means that of-platdata must make a copy (in + writeable memory) of anything it wants to modify, such as + device-private data. + config SPL_BANNER_PRINT bool "Enable output of the SPL banner 'U-Boot SPL ...'" default y @@ -487,7 +500,7 @@ config SPL_CACHE_SUPPORT future requests for that data can be served faster. Enable this option to build the drivers in drivers/cache as part of an SPL build. -config SPL_CPU_SUPPORT +config SPL_CPU bool "Support CPU drivers" help Enable this to support CPU drivers in SPL. These drivers can set @@ -1440,6 +1453,17 @@ config TPL_STACK The address of the initial stack-pointer for the TPL stage. Usually this will be the (aligned) top-of-stack. +config TPL_READ_ONLY + bool + depends on TPL_OF_PLATDATA + select TPL_OF_PLATDATA_NO_BIND + select TPL_OF_PLATDATA_RT + help + Some platforms (e.g. x86 Apollo Lake) load SPL into a read-only + section of memory. This means that of-platdata must make a copy (in + writeable memory) of anything it wants to modify, such as + device-private data. + config TPL_BOOTROM_SUPPORT bool "Support returning to the BOOTROM (from TPL)" help diff --git a/common/spl/spl.c b/common/spl/spl.c index e3d84082f4..556a91ab53 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -16,6 +16,7 @@ #include <init.h> #include <irq_func.h> #include <log.h> +#include <mapmem.h> #include <serial.h> #include <spl.h> #include <asm/global_data.h> @@ -168,7 +169,7 @@ __weak void spl_board_prepare_for_boot(void) __weak struct image_header *spl_get_load_buffer(ssize_t offset, size_t size) { - return (struct image_header *)(CONFIG_SYS_TEXT_BASE + offset); + return map_sysmem(CONFIG_SYS_TEXT_BASE + offset, 0); } void spl_set_header_raw_uboot(struct spl_image_info *spl_image) @@ -386,6 +387,22 @@ static inline int write_spl_handoff(void) { return 0; } #endif /* HANDOFF */ +/** + * get_bootstage_id() - Get the bootstage ID to emit + * + * @start: true if this is for starting SPL, false for ending it + * @return bootstage ID to use + */ +static enum bootstage_id get_bootstage_id(bool start) +{ + enum u_boot_phase phase = spl_phase(); + + if (IS_ENABLED(CONFIG_TPL_BUILD) && phase == PHASE_TPL) + return start ? BOOTSTAGE_ID_START_TPL : BOOTSTAGE_ID_END_TPL; + else + return start ? BOOTSTAGE_ID_START_SPL : BOOTSTAGE_ID_END_SPL; +} + static int spl_common_init(bool setup_malloc) { int ret; @@ -416,8 +433,8 @@ static int spl_common_init(bool setup_malloc) __func__, ret); } #endif /* CONFIG_BOOTSTAGE_STASH */ - bootstage_mark_name(spl_phase() == PHASE_TPL ? BOOTSTAGE_ID_START_TPL : - BOOTSTAGE_ID_START_SPL, SPL_TPL_NAME); + bootstage_mark_name(get_bootstage_id(true), + spl_phase_name(spl_phase())); #if CONFIG_IS_ENABLED(LOG) ret = log_init(); if (ret) { @@ -694,7 +711,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2) #endif switch (spl_image.os) { case IH_OS_U_BOOT: - debug("Jumping to U-Boot\n"); + debug("Jumping to %s...\n", spl_phase_name(spl_next_phase())); break; #if CONFIG_IS_ENABLED(ATF) case IH_OS_ARM_TRUSTED_FIRMWARE: @@ -732,8 +749,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2) debug("SPL malloc() used 0x%lx bytes (%ld KB)\n", gd->malloc_ptr, gd->malloc_ptr / 1024); #endif - bootstage_mark_name(spl_phase() == PHASE_TPL ? BOOTSTAGE_ID_END_TPL : - BOOTSTAGE_ID_END_SPL, "end " SPL_TPL_NAME); + 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); @@ -741,7 +757,6 @@ void board_init_r(gd_t *dummy1, ulong dummy2) debug("Failed to stash bootstage: err=%d\n", ret); #endif - debug("loaded - jumping to %s...\n", spl_phase_name(spl_next_phase())); spl_board_prepare_for_boot(); jump_to_image_no_args(&spl_image); } diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index 75c8ff065b..49508fc518 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -11,6 +11,7 @@ #include <image.h> #include <log.h> #include <malloc.h> +#include <mapmem.h> #include <spl.h> #include <sysinfo.h> #include <asm/cache.h> @@ -235,11 +236,11 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector, size_t length; int len; ulong size; - ulong load_addr, load_ptr; + ulong load_addr; + void *load_ptr; void *src; ulong overhead; int nr_sectors; - int align_len = ARCH_DMA_MINALIGN - 1; uint8_t image_comp = -1, type = -1; const void *data; const void *fit = ctx->fit; @@ -269,11 +270,13 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector, } if (external_data) { + void *src_ptr; + /* External data */ if (fit_image_get_data_size(fit, node, &len)) return -ENOENT; - load_ptr = (load_addr + align_len) & ~align_len; + src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len); length = len; overhead = get_aligned_image_overhead(info, offset); @@ -281,12 +284,12 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector, if (info->read(info, sector + get_aligned_image_offset(info, offset), - nr_sectors, (void *)load_ptr) != nr_sectors) + nr_sectors, src_ptr) != nr_sectors) return -EIO; - debug("External data: dst=%lx, offset=%x, size=%lx\n", - load_ptr, offset, (unsigned long)length); - src = (void *)load_ptr + overhead; + debug("External data: dst=%p, offset=%x, size=%lx\n", + src_ptr, offset, (unsigned long)length); + src = src_ptr + overhead; } else { /* Embedded data */ if (fit_image_get_data(fit, node, &data, &length)) { @@ -295,7 +298,7 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector, } debug("Embedded data: dst=%lx, size=%lx\n", load_addr, (unsigned long)length); - src = (void *)data; + src = (void *)data; /* cast away const */ } if (CONFIG_IS_ENABLED(FIT_SIGNATURE)) { @@ -309,16 +312,16 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector, if (CONFIG_IS_ENABLED(FIT_IMAGE_POST_PROCESS)) board_fit_image_post_process(&src, &length); + load_ptr = map_sysmem(load_addr, length); if (IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP) { size = length; - if (gunzip((void *)load_addr, CONFIG_SYS_BOOTM_LEN, - src, &size)) { + if (gunzip(load_ptr, CONFIG_SYS_BOOTM_LEN, src, &size)) { puts("Uncompressing error\n"); return -EIO; } length = size; } else { - memcpy((void *)load_addr, src, length); + memcpy(load_ptr, src, length); } if (image_info) { @@ -383,7 +386,7 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image, } /* Make the load-address of the FDT available for the SPL framework */ - spl_image->fdt_addr = (void *)image_info.load_addr; + spl_image->fdt_addr = map_sysmem(image_info.load_addr, 0); if (CONFIG_IS_ENABLED(FIT_IMAGE_TINY)) return 0; |