diff options
author | davidcunado-arm <david.cunado@arm.com> | 2018-02-06 05:12:28 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-06 05:12:28 +0000 |
commit | 9fd2f13bd608832260300640970f73c62357c684 (patch) | |
tree | 149d13158075ab08cccff2710ee8bedd0406d2c1 /plat | |
parent | 10787b0519afce1e887a935789b2d624849856a9 (diff) | |
parent | 8951b058fce077dab7afcd86c532ec0fc0200352 (diff) | |
download | platform_external_arm-trusted-firmware-9fd2f13bd608832260300640970f73c62357c684.tar.gz platform_external_arm-trusted-firmware-9fd2f13bd608832260300640970f73c62357c684.tar.bz2 platform_external_arm-trusted-firmware-9fd2f13bd608832260300640970f73c62357c684.zip |
Merge pull request #1224 from masahir0y/gzip
Support GZIP-compressed images for faster loading and verification
Diffstat (limited to 'plat')
-rw-r--r-- | plat/arm/common/arm_common.mk | 8 | ||||
-rw-r--r-- | plat/arm/css/common/css_common.mk | 4 | ||||
-rw-r--r-- | plat/common/aarch32/platform_helpers.S | 35 | ||||
-rw-r--r-- | plat/common/aarch64/platform_helpers.S | 34 | ||||
-rw-r--r-- | plat/common/platform_helpers_default.c | 55 | ||||
-rw-r--r-- | plat/hisilicon/hikey/platform.mk | 6 | ||||
-rw-r--r-- | plat/hisilicon/hikey960/platform.mk | 6 | ||||
-rw-r--r-- | plat/qemu/platform.mk | 6 | ||||
-rw-r--r-- | plat/socionext/uniphier/platform.mk | 17 | ||||
-rw-r--r-- | plat/socionext/uniphier/uniphier.h | 12 | ||||
-rw-r--r-- | plat/socionext/uniphier/uniphier_bl2_setup.c | 42 | ||||
-rw-r--r-- | plat/socionext/uniphier/uniphier_image_desc.c | 11 |
12 files changed, 143 insertions, 93 deletions
diff --git a/plat/arm/common/arm_common.mk b/plat/arm/common/arm_common.mk index e6ce18a72..48e70717a 100644 --- a/plat/arm/common/arm_common.mk +++ b/plat/arm/common/arm_common.mk @@ -1,5 +1,5 @@ # -# Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved. +# Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause # @@ -87,10 +87,10 @@ $(eval $(call add_define,MBEDTLS_SHA256_SMALLER)) # Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images # in the FIP if the platform requires. ifneq ($(BL32_EXTRA1),) -$(eval $(call FIP_ADD_IMG,BL32_EXTRA1,--tos-fw-extra1)) +$(eval $(call TOOL_ADD_IMG,bl32_extra1,--tos-fw-extra1)) endif ifneq ($(BL32_EXTRA2),) -$(eval $(call FIP_ADD_IMG,BL32_EXTRA2,--tos-fw-extra2)) +$(eval $(call TOOL_ADD_IMG,bl32_extra2,--tos-fw-extra2)) endif # Enable PSCI_STAT_COUNT/RESIDENCY APIs on ARM platforms @@ -211,7 +211,7 @@ ifneq (${TRUSTED_BOARD_BOOT},0) BL2_SOURCES += ${AUTH_SOURCES} \ plat/common/tbbr/plat_tbbr.c - $(eval $(call FWU_FIP_ADD_IMG,NS_BL2U,--fwu)) + $(eval $(call TOOL_ADD_IMG,ns_bl2u,--fwu,FWU_)) # We expect to locate the *.mk files under the directories specified below ifeq (${ARM_CRYPTOCELL_INTEG},0) diff --git a/plat/arm/css/common/css_common.mk b/plat/arm/css/common/css_common.mk index 63e305916..cfbb3e92c 100644 --- a/plat/arm/css/common/css_common.mk +++ b/plat/arm/css/common/css_common.mk @@ -1,5 +1,5 @@ # -# Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved. +# Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause # @@ -49,7 +49,7 @@ $(eval $(call add_define,CSS_LOAD_SCP_IMAGES)) ifeq (${CSS_LOAD_SCP_IMAGES},1) NEED_SCP_BL2 := yes ifneq (${TRUSTED_BOARD_BOOT},0) - $(eval $(call FWU_FIP_ADD_IMG,SCP_BL2U,--scp-fwu-cfg)) + $(eval $(call TOOL_ADD_IMG,scp_bl2u,--scp-fwu-cfg,FWU_)) endif ifeq (${CSS_USE_SCMI_SDS_DRIVER},1) diff --git a/plat/common/aarch32/platform_helpers.S b/plat/common/aarch32/platform_helpers.S index 0a0e92714..d61853942 100644 --- a/plat/common/aarch32/platform_helpers.S +++ b/plat/common/aarch32/platform_helpers.S @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -15,10 +15,7 @@ .weak plat_disable_acp .weak bl1_plat_prepare_exit .weak platform_mem_init - .weak plat_error_handler .weak plat_panic_handler - .weak bl2_plat_preload_setup - .weak plat_try_next_boot_source /* ----------------------------------------------------- * Placeholder function which should be redefined by @@ -95,16 +92,6 @@ func bl1_plat_prepare_exit endfunc bl1_plat_prepare_exit /* ----------------------------------------------------- - * void plat_error_handler(int err) __dead2; - * Endless loop by default. - * ----------------------------------------------------- - */ -func plat_error_handler - wfi - b plat_error_handler -endfunc plat_error_handler - - /* ----------------------------------------------------- * void plat_panic_handler(void) __dead2; * Endless loop by default. * ----------------------------------------------------- @@ -112,23 +99,3 @@ endfunc plat_error_handler func plat_panic_handler b plat_panic_handler endfunc plat_panic_handler - - - /* ----------------------------------------------------- - * Placeholder function which should be redefined by - * each platfrom. - * ----------------------------------------------------- - */ -func bl2_plat_preload_setup - bx lr -endfunc bl2_plat_preload_setup - - /* ----------------------------------------------------- - * Placeholder function which should be redefined by - * each platfrom. - * ----------------------------------------------------- - */ -func plat_try_next_boot_source - mov r0, #0 - bx lr -endfunc plat_try_next_boot_source diff --git a/plat/common/aarch64/platform_helpers.S b/plat/common/aarch64/platform_helpers.S index 852675277..033a12f8e 100644 --- a/plat/common/aarch64/platform_helpers.S +++ b/plat/common/aarch64/platform_helpers.S @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -16,10 +16,7 @@ .weak plat_reset_handler .weak plat_disable_acp .weak bl1_plat_prepare_exit - .weak plat_error_handler .weak plat_panic_handler - .weak bl2_plat_preload_setup - .weak plat_try_next_boot_source #if !ENABLE_PLAT_COMPAT .globl platform_get_core_pos @@ -159,16 +156,6 @@ func bl1_plat_prepare_exit endfunc bl1_plat_prepare_exit /* ----------------------------------------------------- - * void plat_error_handler(int err) __dead2; - * Endless loop by default. - * ----------------------------------------------------- - */ -func plat_error_handler - wfi - b plat_error_handler -endfunc plat_error_handler - - /* ----------------------------------------------------- * void plat_panic_handler(void) __dead2; * Endless loop by default. * ----------------------------------------------------- @@ -177,22 +164,3 @@ func plat_panic_handler wfi b plat_panic_handler endfunc plat_panic_handler - - /* ----------------------------------------------------- - * Placeholder function which should be redefined by - * each platfrom. - * ----------------------------------------------------- - */ -func bl2_plat_preload_setup - ret -endfunc bl2_plat_preload_setup - - /* ----------------------------------------------------- - * Placeholder function which should be redefined by - * each platfrom. - * ----------------------------------------------------- - */ -func plat_try_next_boot_source - mov x0, #0 - ret -endfunc plat_try_next_boot_source diff --git a/plat/common/platform_helpers_default.c b/plat/common/platform_helpers_default.c new file mode 100644 index 000000000..ce1a73173 --- /dev/null +++ b/plat/common/platform_helpers_default.c @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include <arch_helpers.h> +#include <platform.h> + +/* + * Placeholder functions which can be redefined by each platfrom. + */ + +#pragma weak plat_error_handler +#pragma weak bl1_plat_handle_pre_image_load +#pragma weak bl1_plat_handle_post_image_load +#pragma weak bl2_plat_preload_setup +#pragma weak bl2_plat_handle_pre_image_load +#pragma weak bl2_plat_handle_post_image_load +#pragma weak plat_try_next_boot_source + +void __dead2 plat_error_handler(int err) +{ + while (1) + wfi(); +} + +int bl1_plat_handle_pre_image_load(void) +{ + return 0; +} + +int bl1_plat_handle_post_image_load(void) +{ + return 0; +} + +void bl2_plat_preload_setup(void) +{ +} + +int bl2_plat_handle_pre_image_load(unsigned int image_id) +{ + return 0; +} + +int bl2_plat_handle_post_image_load(unsigned int image_id) +{ + return 0; +} + +int plat_try_next_boot_source(void) +{ + return 0; +} diff --git a/plat/hisilicon/hikey/platform.mk b/plat/hisilicon/hikey/platform.mk index b11d2085e..d43b20b3e 100644 --- a/plat/hisilicon/hikey/platform.mk +++ b/plat/hisilicon/hikey/platform.mk @@ -1,5 +1,5 @@ # -# Copyright (c) 2017, ARM Limited and Contributors. All rights reserved. +# Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause # @@ -36,10 +36,10 @@ $(eval $(call add_define,PLAT_PARTITION_MAX_ENTRIES)) # Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images # in the FIP if the platform requires. ifneq ($(BL32_EXTRA1),) -$(eval $(call FIP_ADD_IMG,BL32_EXTRA1,--tos-fw-extra1)) +$(eval $(call TOOL_ADD_IMG,bl32_extra1,--tos-fw-extra1)) endif ifneq ($(BL32_EXTRA2),) -$(eval $(call FIP_ADD_IMG,BL32_EXTRA2,--tos-fw-extra2)) +$(eval $(call TOOL_ADD_IMG,bl32_extra2,--tos-fw-extra2)) endif ENABLE_PLAT_COMPAT := 0 diff --git a/plat/hisilicon/hikey960/platform.mk b/plat/hisilicon/hikey960/platform.mk index cb97deb6d..cd063058e 100644 --- a/plat/hisilicon/hikey960/platform.mk +++ b/plat/hisilicon/hikey960/platform.mk @@ -1,5 +1,5 @@ # -# Copyright (c) 2017, ARM Limited and Contributors. All rights reserved. +# Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause # @@ -29,10 +29,10 @@ $(eval $(call add_define,CRASH_CONSOLE_BASE)) # Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images # in the FIP if the platform requires. ifneq ($(BL32_EXTRA1),) -$(eval $(call FIP_ADD_IMG,BL32_EXTRA1,--tos-fw-extra1)) +$(eval $(call TOOL_ADD_IMG,bl32_extra1,--tos-fw-extra1)) endif ifneq ($(BL32_EXTRA2),) -$(eval $(call FIP_ADD_IMG,BL32_EXTRA2,--tos-fw-extra2)) +$(eval $(call TOOL_ADD_IMG,bl32_extra2,--tos-fw-extra2)) endif ENABLE_PLAT_COMPAT := 0 diff --git a/plat/qemu/platform.mk b/plat/qemu/platform.mk index 43ab846b4..3d15a7467 100644 --- a/plat/qemu/platform.mk +++ b/plat/qemu/platform.mk @@ -1,5 +1,5 @@ # -# Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved. +# Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause # @@ -133,10 +133,10 @@ BL31_SOURCES += lib/cpus/aarch64/aem_generic.S \ # Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images # in the FIP if the platform requires. ifneq ($(BL32_EXTRA1),) -$(eval $(call FIP_ADD_IMG,BL32_EXTRA1,--tos-fw-extra1)) +$(eval $(call TOOL_ADD_IMG,bl32_extra1,--tos-fw-extra1)) endif ifneq ($(BL32_EXTRA2),) -$(eval $(call FIP_ADD_IMG,BL32_EXTRA2,--tos-fw-extra2)) +$(eval $(call TOOL_ADD_IMG,bl32_extra2,--tos-fw-extra2)) endif # Disable the PSCI platform compatibility layer diff --git a/plat/socionext/uniphier/platform.mk b/plat/socionext/uniphier/platform.mk index 18b56a0b2..6de516467 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 2af30dff8..1768e3bee 100644 --- a/plat/socionext/uniphier/uniphier.h +++ b/plat/socionext/uniphier/uniphier.h @@ -42,7 +42,9 @@ int uniphier_usb_init(unsigned int soc, uintptr_t *block_dev_spec); int uniphier_io_setup(unsigned int soc); int uniphier_check_image(unsigned int image_id); -void uniphier_image_descs_fixup(void); + +struct image_info; +struct image_info *uniphier_get_image_info(unsigned int image_id); int uniphier_scp_is_running(void); void uniphier_scp_start(void); @@ -80,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 29108c0bb..54b30e5b1 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" @@ -93,8 +97,12 @@ void bl2_el3_plat_arch_setup(void) } } - if (skip_scp) - uniphier_image_descs_fixup(); + if (skip_scp) { + struct image_info *image_info; + + image_info = uniphier_get_image_info(SCP_BL2_IMAGE_ID); + image_info->h.attr |= IMAGE_ATTRIB_SKIP_LOADING; + } } void bl2_platform_setup(void) @@ -116,8 +124,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(); diff --git a/plat/socionext/uniphier/uniphier_image_desc.c b/plat/socionext/uniphier/uniphier_image_desc.c index 1e474c53f..f4651db05 100644 --- a/plat/socionext/uniphier/uniphier_image_desc.c +++ b/plat/socionext/uniphier/uniphier_image_desc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -86,12 +86,11 @@ static struct bl_mem_params_node uniphier_image_descs[] = { }; REGISTER_BL_IMAGE_DESCS(uniphier_image_descs) -/* SCP is optional. Allow run-time fixup of the descriptor array. */ -void uniphier_image_descs_fixup(void) +struct image_info *uniphier_get_image_info(unsigned int image_id) { struct bl_mem_params_node *desc; - desc = get_bl_mem_params_node(SCP_BL2_IMAGE_ID); - assert(desc != NULL); - desc->image_info.h.attr |= IMAGE_ATTRIB_SKIP_LOADING; + desc = get_bl_mem_params_node(image_id); + assert(desc); + return &desc->image_info; } |