aboutsummaryrefslogtreecommitdiff
path: root/bl1
diff options
context:
space:
mode:
authordanh-arm <dan.handley@arm.com>2014-07-10 14:45:19 +0100
committerdanh-arm <dan.handley@arm.com>2014-07-10 14:45:19 +0100
commit6a2231560b0243defba0721d15e824d21e5ae60b (patch)
tree69701cadcfb47c20202d65ad3e12e970d57c81a3 /bl1
parent3fc938b56a55985ba46c37cf5526df0a7daa775c (diff)
parent6063379902302dfcdfa9b8978b8a0dce44bd78f7 (diff)
downloadtrusted-firmware-a-6a2231560b0243defba0721d15e824d21e5ae60b.tar.gz
Merge pull request #157 from sandrine-bailleux/sb/tf-issue-109
TF issue 109
Diffstat (limited to 'bl1')
-rw-r--r--bl1/bl1_main.c54
-rw-r--r--bl1/bl1_private.h9
2 files changed, 49 insertions, 14 deletions
diff --git a/bl1/bl1_main.c b/bl1/bl1_main.c
index 6771142e44..897660cfff 100644
--- a/bl1/bl1_main.c
+++ b/bl1/bl1_main.c
@@ -65,6 +65,38 @@ static void __dead2 bl1_run_bl2(entry_point_info_t *bl2_ep)
bl2_ep->args.arg7);
}
+/*******************************************************************************
+ * The next function has a weak definition. Platform specific code can override
+ * it if it wishes to.
+ ******************************************************************************/
+#pragma weak bl1_init_bl2_mem_layout
+
+/*******************************************************************************
+ * Function that takes a memory layout into which BL2 has been loaded and
+ * populates a new memory layout for BL2 that ensures that BL1's data sections
+ * resident in secure RAM are not visible to BL2.
+ ******************************************************************************/
+void bl1_init_bl2_mem_layout(const meminfo_t *bl1_mem_layout,
+ meminfo_t *bl2_mem_layout)
+{
+ const size_t bl1_size = BL1_RAM_LIMIT - BL1_RAM_BASE;
+
+ assert(bl1_mem_layout != NULL);
+ assert(bl2_mem_layout != NULL);
+
+ /* Check that BL1's memory is lying outside of the free memory */
+ assert((BL1_RAM_LIMIT <= bl1_mem_layout->free_base) ||
+ (BL1_RAM_BASE >= bl1_mem_layout->free_base + bl1_mem_layout->free_size));
+
+ /* Remove BL1 RW data from the scope of memory visible to BL2 */
+ *bl2_mem_layout = *bl1_mem_layout;
+ reserve_mem(&bl2_mem_layout->total_base,
+ &bl2_mem_layout->total_size,
+ BL1_RAM_BASE,
+ bl1_size);
+
+ flush_dcache_range((unsigned long)bl2_mem_layout, sizeof(meminfo_t));
+}
/*******************************************************************************
* Function to perform late architectural and platform specific initialization.
@@ -78,7 +110,6 @@ void bl1_main(void)
#if DEBUG
unsigned long sctlr_el3 = read_sctlr_el3();
#endif
- unsigned int load_type = TOP_LOAD;
image_info_t bl2_image_info = { {0} };
entry_point_info_t bl2_ep = { {0} };
meminfo_t *bl1_tzram_layout;
@@ -105,17 +136,15 @@ void bl1_main(void)
SET_PARAM_HEAD(&bl2_image_info, PARAM_IMAGE_BINARY, VERSION_1, 0);
SET_PARAM_HEAD(&bl2_ep, PARAM_EP, VERSION_1, 0);
- /*
- * Find out how much free trusted ram remains after BL1 load
- * & load the BL2 image at its top
- */
+ /* Find out how much free trusted ram remains after BL1 load */
bl1_tzram_layout = bl1_plat_sec_mem_layout();
+
+ /* Load the BL2 image */
err = load_image(bl1_tzram_layout,
- (const char *) BL2_IMAGE_NAME,
- load_type,
- BL2_BASE,
- &bl2_image_info,
- &bl2_ep);
+ BL2_IMAGE_NAME,
+ BL2_BASE,
+ &bl2_image_info,
+ &bl2_ep);
if (err) {
/*
* TODO: print failure to load BL2 but also add a tzwdog timer
@@ -132,10 +161,7 @@ void bl1_main(void)
* memory for other purposes.
*/
bl2_tzram_layout = (meminfo_t *) bl1_tzram_layout->free_base;
- init_bl2_mem_layout(bl1_tzram_layout,
- bl2_tzram_layout,
- load_type,
- bl2_image_info.image_base);
+ bl1_init_bl2_mem_layout(bl1_tzram_layout, bl2_tzram_layout);
bl1_plat_set_bl2_ep_info(&bl2_image_info, &bl2_ep);
bl2_ep.args.arg1 = (unsigned long)bl2_tzram_layout;
diff --git a/bl1/bl1_private.h b/bl1/bl1_private.h
index b54bf6ba17..0a8fc45c41 100644
--- a/bl1/bl1_private.h
+++ b/bl1/bl1_private.h
@@ -31,6 +31,15 @@
#ifndef __BL1_PRIVATE_H__
#define __BL1_PRIVATE_H__
+/*******************************************************************************
+ * Declarations of linker defined symbols which will tell us where BL1 lives
+ * in Trusted RAM
+ ******************************************************************************/
+extern uint64_t __BL1_RAM_START__;
+extern uint64_t __BL1_RAM_END__;
+#define BL1_RAM_BASE (uint64_t)(&__BL1_RAM_START__)
+#define BL1_RAM_LIMIT (uint64_t)(&__BL1_RAM_END__)
+
/******************************************
* Function prototypes
*****************************************/