diff options
author | Soby Mathew <soby.mathew@arm.com> | 2018-01-10 12:51:34 +0000 |
---|---|---|
committer | Soby Mathew <soby.mathew@arm.com> | 2018-02-26 16:31:11 +0000 |
commit | 101d01e2a2e34a568fb25c2ef2390fd71183413e (patch) | |
tree | c7c962e6580d07900ec7130a8568c47009d63511 /plat/common/plat_bl1_common.c | |
parent | 0c306cc062611d71cd79a2cf2b7aac022c741165 (diff) |
BL1: Deprecate the `bl1_init_bl2_mem_layout()` API
The `bl1_init_bl2_mem_layout()` API is now deprecated. The default weak
implementation of `bl1_plat_handle_post_image_load()` calculates the
BL2 memory layout and populates the same in x1(r1). This ensures
compatibility for the deprecated API.
Change-Id: Id44bdc1f572dc42ee6ceef4036b3a46803689315
Signed-off-by: Soby Mathew <soby.mathew@arm.com>
Diffstat (limited to 'plat/common/plat_bl1_common.c')
-rw-r--r-- | plat/common/plat_bl1_common.c | 59 |
1 files changed, 53 insertions, 6 deletions
diff --git a/plat/common/plat_bl1_common.c b/plat/common/plat_bl1_common.c index cee34ae2..a1972629 100644 --- a/plat/common/plat_bl1_common.c +++ b/plat/common/plat_bl1_common.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -7,6 +7,7 @@ #include <arch_helpers.h> #include <assert.h> #include <bl_common.h> +#include <bl1.h> #include <debug.h> #include <errno.h> #include <platform.h> @@ -43,11 +44,6 @@ int bl1_plat_handle_pre_image_load(unsigned int image_id) return 0; } -int bl1_plat_handle_post_image_load(unsigned int image_id) -{ - return 0; -} - /* * Following is the default definition that always * returns BL2 image details. @@ -75,3 +71,54 @@ int bl1_plat_mem_check(uintptr_t mem_base, unsigned int mem_size, assert(0); return -ENOMEM; } + +/* + * Default implementation for bl1_plat_handle_post_image_load(). This function + * populates the default arguments to BL2. The BL2 memory layout structure + * is allocated and the calculated layout is populated in arg1 to BL2. + */ +int bl1_plat_handle_post_image_load(unsigned int image_id) +{ + meminfo_t *bl2_tzram_layout; + meminfo_t *bl1_tzram_layout; + image_desc_t *image_desc; + entry_point_info_t *ep_info; + + if (image_id != BL2_IMAGE_ID) + return 0; + + /* Get the image descriptor */ + image_desc = bl1_plat_get_image_desc(BL2_IMAGE_ID); + assert(image_desc); + + /* Get the entry point info */ + ep_info = &image_desc->ep_info; + + /* Find out how much free trusted ram remains after BL1 load */ + bl1_tzram_layout = bl1_plat_sec_mem_layout(); + + /* + * Create a new layout of memory for BL2 as seen by BL1 i.e. + * tell it the amount of total and free memory available. + * This layout is created at the first free address visible + * 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; +#endif /* LOAD_IMAGE_V2 */ + +#if !ERROR_DEPRECATED + bl1_init_bl2_mem_layout(bl1_tzram_layout, bl2_tzram_layout); +#else + bl1_calc_bl2_mem_layout(bl1_tzram_layout, bl2_tzram_layout); +#endif + + ep_info->args.arg1 = (uintptr_t)bl2_tzram_layout; + + VERBOSE("BL1: BL2 memory layout address = %p\n", + (void *) bl2_tzram_layout); + return 0; +} |