From 11f001cb7f26e9c50e688038ebdc9627ea5c4300 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 1 Feb 2018 16:46:18 +0900 Subject: [PATCH] bl1: add bl1_plat_handle_{pre,post}_image_load() Just like bl2_, add pre/post image load handlers for BL1. No argument is needed since BL2 is the only image loaded by BL1. Signed-off-by: Masahiro Yamada --- bl1/bl1_main.c | 17 +++++++++++++++-- docs/porting-guide.rst | 24 ++++++++++++++++++++++++ include/plat/common/platform.h | 9 +++++++++ plat/common/platform_helpers_default.c | 12 ++++++++++++ 4 files changed, 60 insertions(+), 2 deletions(-) diff --git a/bl1/bl1_main.c b/bl1/bl1_main.c index 821b6a357..91b5f0b16 100644 --- a/bl1/bl1_main.c +++ b/bl1/bl1_main.c @@ -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 */ @@ -178,6 +178,12 @@ void bl1_load_bl2(void) INFO("BL1: Loading BL2\n"); #if LOAD_IMAGE_V2 + err = bl1_plat_handle_pre_image_load(); + if (err) { + ERROR("Failure in pre image load handling of BL2 (%d)\n", err); + plat_error_handler(err); + } + err = load_auth_image(BL2_IMAGE_ID, image_info); #else /* Load the BL2 image */ @@ -194,6 +200,14 @@ void bl1_load_bl2(void) plat_error_handler(err); } +#if LOAD_IMAGE_V2 + /* Allow platform to handle image information. */ + err = bl1_plat_handle_post_image_load(); + if (err) { + ERROR("Failure in post image load handling of BL2 (%d)\n", err); + plat_error_handler(err); + } + /* * Create a new layout of memory for BL2 as seen by BL1 i.e. * tell it the amount of total and free memory available. @@ -201,7 +215,6 @@ void bl1_load_bl2(void) * to BL2. BL2 will read the memory layout before using its * memory for other purposes. */ -#if LOAD_IMAGE_V2 bl2_tzram_layout = (meminfo_t *) bl1_tzram_layout->total_base; #else bl2_tzram_layout = (meminfo_t *) bl1_tzram_layout->free_base; diff --git a/docs/porting-guide.rst b/docs/porting-guide.rst index 57da340a7..de05e0338 100644 --- a/docs/porting-guide.rst +++ b/docs/porting-guide.rst @@ -1259,6 +1259,30 @@ standard platforms return an image descriptor corresponding to BL2 or one of the firmware update images defined in the Trusted Board Boot Requirements specification. +Function : bl1\_plat\_handle\_pre\_image\_load() [optional] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:: + + Argument : void + Return : int + +This function can be used by the platforms to update/use image information +for BL2. This function is currently invoked in BL1 before loading BL2, +when LOAD\_IMAGE\_V2 is enabled. + +Function : bl1\_plat\_handle\_post\_image\_load() [optional] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:: + + Argument : void + Return : int + +This function can be used by the platforms to update/use image information +for BL2. This function is currently invoked in BL1 after loading BL2, +when LOAD\_IMAGE\_V2 is enabled. + Function : bl1\_plat\_fwu\_done() [optional] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/include/plat/common/platform.h b/include/plat/common/platform.h index 69a2957af..e2f1cfdc3 100644 --- a/include/plat/common/platform.h +++ b/include/plat/common/platform.h @@ -155,6 +155,15 @@ struct image_desc *bl1_plat_get_image_desc(unsigned int image_id); */ __dead2 void bl1_plat_fwu_done(void *client_cookie, void *reserved); +#if LOAD_IMAGE_V2 +/* + * This function can be used by the platforms to update/use image + * information for BL2. + */ +int bl1_plat_handle_pre_image_load(void); +int bl1_plat_handle_post_image_load(void); + +#endif /* LOAD_IMAGE_V2 */ /******************************************************************************* * Mandatory BL2 functions diff --git a/plat/common/platform_helpers_default.c b/plat/common/platform_helpers_default.c index 597a58506..ce1a73173 100644 --- a/plat/common/platform_helpers_default.c +++ b/plat/common/platform_helpers_default.c @@ -12,6 +12,8 @@ */ #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 @@ -23,6 +25,16 @@ void __dead2 plat_error_handler(int err) 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) { }