From 8951b058fce077dab7afcd86c532ec0fc0200352 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 26 Jan 2018 11:42:01 +0900 Subject: uniphier: support GZIP-compressed images Allow to handle GZIP-compressed images by giving FIP_GZIP=1 from the command line. - Images are GZIP-compressed, then packed into FIP. If Trusted Board Boot is enabled, certificates are generated based on the compressed images. - GZIP decompressor is linked into BL2 to decompress images at run-time. Signed-off-by: Masahiro Yamada --- plat/socionext/uniphier/platform.mk | 17 ++++++++++++++ plat/socionext/uniphier/uniphier.h | 8 +++++-- plat/socionext/uniphier/uniphier_bl2_setup.c | 34 ++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 2 deletions(-) (limited to 'plat/socionext') diff --git a/plat/socionext/uniphier/platform.mk b/plat/socionext/uniphier/platform.mk index 18b56a0b..6de51646 100644 --- a/plat/socionext/uniphier/platform.mk +++ b/plat/socionext/uniphier/platform.mk @@ -103,6 +103,23 @@ $(ROTPK_HASH): $(ROT_KEY) endif +ifeq (${FIP_GZIP},1) + +include lib/zlib/zlib.mk + +BL2_SOURCES += common/image_decompress.c \ + $(ZLIB_SOURCES) + +$(eval $(call add_define,UNIPHIER_DECOMPRESS_GZIP)) + +# compress all images loaded by BL2 +SCP_BL2_PRE_TOOL_FILTER := GZIP +BL31_PRE_TOOL_FILTER := GZIP +BL32_PRE_TOOL_FILTER := GZIP +BL33_PRE_TOOL_FILTER := GZIP + +endif + .PHONY: bl2_gzip bl2_gzip: $(BUILD_PLAT)/bl2.bin.gz %.gz: % diff --git a/plat/socionext/uniphier/uniphier.h b/plat/socionext/uniphier/uniphier.h index b1a05726..1768e3be 100644 --- a/plat/socionext/uniphier/uniphier.h +++ b/plat/socionext/uniphier/uniphier.h @@ -82,7 +82,11 @@ unsigned int uniphier_calc_core_pos(u_register_t mpidr); #define UNIPHIER_BLOCK_BUF_BASE ((UNIPHIER_SCP_BASE) + \ (UNIPHIER_SCP_MAX_SIZE)) -#define UNIPHIER_BLOCK_BUF_SIZE ((UNIPHIER_NS_DRAM_LIMIT) - \ - (UNIPHIER_BLOCK_BUF_BASE)) +#define UNIPHIER_BLOCK_BUF_SIZE 0x00100000 + +#define UNIPHIER_IMAGE_BUF_BASE ((UNIPHIER_BLOCK_BUF_BASE) + \ + (UNIPHIER_BLOCK_BUF_SIZE)) +#define UNIPHIER_IMAGE_BUF_SIZE ((UNIPHIER_NS_DRAM_LIMIT) - \ + (UNIPHIER_IMAGE_BUF_BASE)) #endif /* __UNIPHIER_H__ */ diff --git a/plat/socionext/uniphier/uniphier_bl2_setup.c b/plat/socionext/uniphier/uniphier_bl2_setup.c index e72b6001..9bf866a6 100644 --- a/plat/socionext/uniphier/uniphier_bl2_setup.c +++ b/plat/socionext/uniphier/uniphier_bl2_setup.c @@ -9,8 +9,12 @@ #include #include #include +#include #include #include +#ifdef UNIPHIER_DECOMPRESS_GZIP +#include +#endif #include #include "uniphier.h" @@ -115,8 +119,38 @@ bl_params_t *plat_get_next_bl_params(void) return get_next_bl_params_from_mem_params_desc(); } +void bl2_plat_preload_setup(void) +{ +#ifdef UNIPHIER_DECOMPRESS_GZIP + image_decompress_init(UNIPHIER_IMAGE_BUF_BASE, + UNIPHIER_IMAGE_BUF_SIZE, + gunzip); +#endif +} + +int bl2_plat_handle_pre_image_load(unsigned int image_id) +{ +#ifdef UNIPHIER_DECOMPRESS_GZIP + image_decompress_prepare(uniphier_get_image_info(image_id)); +#endif + return 0; +} + int bl2_plat_handle_post_image_load(unsigned int image_id) { +#ifdef UNIPHIER_DECOMPRESS_GZIP + struct image_info *image_info; + int ret; + + image_info = uniphier_get_image_info(image_id); + + if (!(image_info->h.attr & IMAGE_ATTRIB_SKIP_LOADING)) { + ret = image_decompress(uniphier_get_image_info(image_id)); + if (ret) + return ret; + } +#endif + if (image_id == SCP_BL2_IMAGE_ID && uniphier_bl2_kick_scp) uniphier_scp_start(); -- cgit v1.2.3