Commit ddf2ca03 authored by Marek Vasut's avatar Marek Vasut
Browse files

feat(plat/rcar3): add optional support for gzip-compressed BL33



The BL33 size on this platform is limited to 1 MiB, add optional
support for decompressing and starting gzip-compressed BL33, which
may help with this size limitation. This functionality is disabled
by default, set RCAR_GEN3_BL33_GZIP=1 during build to enable it.

The BL33 at 0x50000000 should then be gzip compressed, however if
the BL33 does not have a valid gzip header, it is copied to the
correct location and started as-is, this is a fallback for legacy
systems and systems which update to gzip-compressed BL33.
Signed-off-by: default avatarMarek Vasut <marek.vasut+renesas@gmail.com>
Change-Id: Id93f1c7e6f17db1ffb952ea086562993473f6efa
parent a43179a6
...@@ -151,7 +151,8 @@ ...@@ -151,7 +151,8 @@
* BL33 * BL33
******************************************************************************/ ******************************************************************************/
#define BL33_BASE DRAM1_NS_BASE #define BL33_BASE DRAM1_NS_BASE
#define BL33_COMP_SIZE U(0x200000)
#define BL33_COMP_BASE (BL33_BASE - BL33_COMP_SIZE)
/******************************************************************************* /*******************************************************************************
* Platform specific page table and MMU setup constants * Platform specific page table and MMU setup constants
......
...@@ -15,12 +15,16 @@ ...@@ -15,12 +15,16 @@
#include <common/bl_common.h> #include <common/bl_common.h>
#include <common/debug.h> #include <common/debug.h>
#include <common/desc_image_load.h> #include <common/desc_image_load.h>
#include <common/image_decompress.h>
#include <drivers/console.h> #include <drivers/console.h>
#include <drivers/io/io_driver.h> #include <drivers/io/io_driver.h>
#include <drivers/io/io_storage.h> #include <drivers/io/io_storage.h>
#include <lib/mmio.h> #include <lib/mmio.h>
#include <lib/xlat_tables/xlat_tables_defs.h> #include <lib/xlat_tables/xlat_tables_defs.h>
#include <plat/common/platform.h> #include <plat/common/platform.h>
#if RCAR_GEN3_BL33_GZIP == 1
#include <tf_gunzip.h>
#endif
#include "avs_driver.h" #include "avs_driver.h"
#include "boot_init_dram.h" #include "boot_init_dram.h"
...@@ -357,16 +361,29 @@ static uint32_t is_ddr_backup_mode(void) ...@@ -357,16 +361,29 @@ static uint32_t is_ddr_backup_mode(void)
#endif #endif
} }
#if RCAR_GEN3_BL33_GZIP == 1
void bl2_plat_preload_setup(void)
{
image_decompress_init(BL33_COMP_BASE, BL33_COMP_SIZE, gunzip);
}
#endif
int bl2_plat_handle_pre_image_load(unsigned int image_id) int bl2_plat_handle_pre_image_load(unsigned int image_id)
{ {
u_register_t *boot_kind = (void *) BOOT_KIND_BASE; u_register_t *boot_kind = (void *) BOOT_KIND_BASE;
bl_mem_params_node_t *bl_mem_params; bl_mem_params_node_t *bl_mem_params;
bl_mem_params = get_bl_mem_params_node(image_id);
#if RCAR_GEN3_BL33_GZIP == 1
if (image_id == BL33_IMAGE_ID) {
image_decompress_prepare(&bl_mem_params->image_info);
}
#endif
if (image_id != BL31_IMAGE_ID) if (image_id != BL31_IMAGE_ID)
return 0; return 0;
bl_mem_params = get_bl_mem_params_node(image_id);
if (is_ddr_backup_mode() == RCAR_COLD_BOOT) if (is_ddr_backup_mode() == RCAR_COLD_BOOT)
goto cold_boot; goto cold_boot;
...@@ -433,6 +450,19 @@ int bl2_plat_handle_post_image_load(unsigned int image_id) ...@@ -433,6 +450,19 @@ int bl2_plat_handle_post_image_load(unsigned int image_id)
sizeof(entry_point_info_t)); sizeof(entry_point_info_t));
break; break;
case BL33_IMAGE_ID: case BL33_IMAGE_ID:
#if RCAR_GEN3_BL33_GZIP == 1
if ((mmio_read_32(BL33_COMP_BASE) & 0xffff) == 0x8b1f) {
/* decompress gzip-compressed image */
ret = image_decompress(&bl_mem_params->image_info);
if (ret != 0) {
return ret;
}
} else {
/* plain image, copy it in place */
memcpy((void *)BL33_BASE, (void *)BL33_COMP_BASE,
bl_mem_params->image_info.image_size);
}
#endif
memcpy(&params->bl33_ep_info, &bl_mem_params->ep_info, memcpy(&params->bl33_ep_info, &bl_mem_params->ep_info,
sizeof(entry_point_info_t)); sizeof(entry_point_info_t));
break; break;
......
...@@ -280,6 +280,11 @@ RCAR_SYSTEM_RESET_KEEPON_DDR := 0 ...@@ -280,6 +280,11 @@ RCAR_SYSTEM_RESET_KEEPON_DDR := 0
endif endif
$(eval $(call add_define,RCAR_SYSTEM_RESET_KEEPON_DDR)) $(eval $(call add_define,RCAR_SYSTEM_RESET_KEEPON_DDR))
ifndef RCAR_GEN3_BL33_GZIP
RCAR_GEN3_BL33_GZIP := 0
endif
$(eval $(call add_define,RCAR_GEN3_BL33_GZIP))
# RCAR_SYSTEM_RESET_KEEPON_DDR requires power control of PMIC etc. # RCAR_SYSTEM_RESET_KEEPON_DDR requires power control of PMIC etc.
# When executing SYSTEM_SUSPEND other than Salvator-X, Salvator-XS and Ebisu, # When executing SYSTEM_SUSPEND other than Salvator-X, Salvator-XS and Ebisu,
# processing equivalent to that implemented in PMIC_ROHM_BD9571 is necessary. # processing equivalent to that implemented in PMIC_ROHM_BD9571 is necessary.
...@@ -315,6 +320,13 @@ PLAT_INCLUDES += -Idrivers/renesas/common/ddr \ ...@@ -315,6 +320,13 @@ PLAT_INCLUDES += -Idrivers/renesas/common/ddr \
BL2_SOURCES += plat/renesas/rcar/bl2_plat_setup.c \ BL2_SOURCES += plat/renesas/rcar/bl2_plat_setup.c \
drivers/renesas/rcar/board/board.c drivers/renesas/rcar/board/board.c
ifeq (${RCAR_GEN3_BL33_GZIP},1)
include lib/zlib/zlib.mk
BL2_SOURCES += common/image_decompress.c \
$(ZLIB_SOURCES)
endif
ifeq (${RCAR_GEN3_ULCB},1) ifeq (${RCAR_GEN3_ULCB},1)
BL31_SOURCES += drivers/renesas/rcar/cpld/ulcb_cpld.c BL31_SOURCES += drivers/renesas/rcar/cpld/ulcb_cpld.c
endif endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment