diff options
author | Sandrine Bailleux <sandrine.bailleux@arm.com> | 2014-06-24 14:02:34 +0100 |
---|---|---|
committer | Sandrine Bailleux <sandrine.bailleux@arm.com> | 2014-07-01 10:59:43 +0100 |
commit | 8f55dfb4ba1a7c2cb5af355ff614923b6000864d (patch) | |
tree | 6b8f1b4958222304da14dffb482ae39e51d47c27 /bl1 | |
parent | 5e0f9bde13c4b10fd7545f47cb75046fcd94d16f (diff) |
Remove concept of top/bottom image loading
This concept is no longer required since we now support loading of
images at fixed addresses only.
The image loader now automatically detects the position of the image
inside the current memory layout and updates the layout such that
memory fragmentation is minimised.
The 'attr' field of the meminfo data structure, which used to hold
the bottom/top loading information, has been removed. Also the 'next'
field has been removed as it wasn't used anywhere.
The 'init_bl2_mem_layout()' function has been moved out of common
code and put in BL1-specific code. It has also been renamed into
'bl1_init_bl2_mem_layout'.
Fixes ARM-software/tf-issues#109
Change-Id: I3f54642ce7b763d5ee3b047ad0ab59eabbcf916d
Diffstat (limited to 'bl1')
-rw-r--r-- | bl1/bl1_main.c | 54 | ||||
-rw-r--r-- | bl1/bl1_private.h | 9 |
2 files changed, 49 insertions, 14 deletions
diff --git a/bl1/bl1_main.c b/bl1/bl1_main.c index 6771142e..897660cf 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 b54bf6ba..0a8fc45c 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 *****************************************/ |