diff options
author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-01-26 11:42:01 +0900 |
---|---|---|
committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-02-02 00:19:24 +0900 |
commit | 8951b058fce077dab7afcd86c532ec0fc0200352 (patch) | |
tree | 373c8092855175830461c56df2db55565c91d1fd /plat/socionext | |
parent | 0ac60c0801f85bad206a3be978f2dcc2ca9a7829 (diff) |
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 <yamada.masahiro@socionext.com>
Diffstat (limited to 'plat/socionext')
-rw-r--r-- | plat/socionext/uniphier/platform.mk | 17 | ||||
-rw-r--r-- | plat/socionext/uniphier/uniphier.h | 8 | ||||
-rw-r--r-- | plat/socionext/uniphier/uniphier_bl2_setup.c | 34 |
3 files changed, 57 insertions, 2 deletions
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 <desc_image_load.h> #include <errno.h> #include <io/io_storage.h> +#include <image_decompress.h> #include <platform.h> #include <platform_def.h> +#ifdef UNIPHIER_DECOMPRESS_GZIP +#include <tf_gunzip.h> +#endif #include <xlat_tables_v2.h> #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(); |