]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
uniphier: support GZIP-compressed images
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Fri, 26 Jan 2018 02:42:01 +0000 (11:42 +0900)
committerMasahiro Yamada <yamada.masahiro@socionext.com>
Thu, 1 Feb 2018 15:19:24 +0000 (00:19 +0900)
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>
plat/socionext/uniphier/platform.mk
plat/socionext/uniphier/uniphier.h
plat/socionext/uniphier/uniphier_bl2_setup.c

index 18b56a0b2427be60c8a8f3fd950b1a0212288882..6de5164673e4a0254982e6e33d70e1f58b86f572 100644 (file)
@@ -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: %
index b1a05726ebfbe7ecfbcaae857189cf4007c0d24a..1768e3bee80b957d723001bdb9052a791dfdfd3a 100644 (file)
@@ -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__ */
index e72b6001d20501b64631fb67758f4af04d7aa717..9bf866a60df55d42f24bbafc113e680ccefa4dc9 100644 (file)
@@ -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();