Commit 29bb973d authored by Sandrine Bailleux's avatar Sandrine Bailleux
Browse files

juno: BL2: Load BL30


Signed-off-by: default avatarRyan Harkin <ryan.harkin@linaro.org>
parent 3c74eb6c
...@@ -28,11 +28,15 @@ ...@@ -28,11 +28,15 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <stdio.h>
#include <string.h>
#include <assert.h> #include <assert.h>
#include <arch_helpers.h> #include <arch_helpers.h>
#include <platform.h> #include <platform.h>
#include <bl2.h> #include <bl2.h>
#include <bl_common.h> #include <bl_common.h>
#include <scp_bootloader.h>
#include <debug.h>
/******************************************************************************* /*******************************************************************************
* Declarations of linker defined symbols which will help us find the layout * Declarations of linker defined symbols which will help us find the layout
...@@ -102,6 +106,54 @@ void bl2_early_platform_setup(meminfo *mem_layout, ...@@ -102,6 +106,54 @@ void bl2_early_platform_setup(meminfo *mem_layout,
bl2_tzram_layout.next = 0; bl2_tzram_layout.next = 0;
} }
/*******************************************************************************
* Load BL3-0 into Trusted RAM, then transfer it using the SCP Download
* protocol. The image is loaded into RAM in the same place that BL3-1 will be
* loaded later so here, we copy the RAM layout structure and use it to load
* the image into. When this function exits, the RAM layout remains untouched
* so the BL2 can load BL3-1 as normal.
******************************************************************************/
static int load_bl30(void)
{
meminfo *bl2_tzram_layout;
meminfo tzram_layout;
meminfo *tmp_tzram_layout = &tzram_layout;
unsigned long bl30_base;
unsigned int image_len;
unsigned int bl2_load, bl30_load;
int ret = -1;
/* Find out how much free trusted ram remains after BL2 load */
bl2_tzram_layout = bl2_plat_sec_mem_layout();
/* copy the TZRAM layout and use it */
memcpy(tmp_tzram_layout, bl2_tzram_layout, sizeof(meminfo));
/* Work out where to load BL3-0 before transferring to SCP */
bl2_load = tmp_tzram_layout->attr & LOAD_MASK;
assert((bl2_load == TOP_LOAD) || (bl2_load == BOT_LOAD));
bl30_load = (bl2_load == TOP_LOAD) ? BOT_LOAD : TOP_LOAD;
/* Load the BL3-0 image */
bl30_base = load_image(tmp_tzram_layout, BL30_IMAGE_NAME,
bl30_load, BL30_BASE);
if (bl30_base != 0) {
image_len = image_size(BL30_IMAGE_NAME);
INFO("BL2: BL3-0 loaded at 0x%lx, len=%d (0x%x)\n\r", bl30_base,
image_len, image_len);
flush_dcache_range(bl30_base, image_len);
ret = scp_bootloader_transfer((void *)bl30_base, image_len);
}
if (ret == 0)
INFO("BL2: BL3-0 loaded and transferred to SCP\n\r");
else
ERROR("BL2: BL3-0 load and transfer failure\n\r");
return ret;
}
/******************************************************************************* /*******************************************************************************
* Perform platform specific setup, i.e. initialize the IO layer, load BL3-0 * Perform platform specific setup, i.e. initialize the IO layer, load BL3-0
* image and initialise the memory location to use for passing arguments to * image and initialise the memory location to use for passing arguments to
...@@ -112,6 +164,10 @@ void bl2_platform_setup() ...@@ -112,6 +164,10 @@ void bl2_platform_setup()
/* Initialise the IO layer and register platform IO devices */ /* Initialise the IO layer and register platform IO devices */
io_setup(); io_setup();
/* Load BL3-0 */
if (load_bl30() != 0)
panic();
/* Populate the extents of memory available for loading BL3-3 */ /* Populate the extents of memory available for loading BL3-3 */
bl2_to_bl31_args.bl33_meminfo.total_base = DRAM_BASE; bl2_to_bl31_args.bl33_meminfo.total_base = DRAM_BASE;
bl2_to_bl31_args.bl33_meminfo.total_size = DRAM_SIZE; bl2_to_bl31_args.bl33_meminfo.total_size = DRAM_SIZE;
......
...@@ -58,6 +58,11 @@ static io_file_spec bl2_file_spec = { ...@@ -58,6 +58,11 @@ static io_file_spec bl2_file_spec = {
.mode = FOPEN_MODE_R .mode = FOPEN_MODE_R
}; };
static io_file_spec bl30_file_spec = {
.path = BL30_IMAGE_NAME,
.mode = FOPEN_MODE_R
};
static io_file_spec bl31_file_spec = { static io_file_spec bl31_file_spec = {
.path = BL31_IMAGE_NAME, .path = BL31_IMAGE_NAME,
.mode = FOPEN_MODE_R .mode = FOPEN_MODE_R
...@@ -81,6 +86,7 @@ typedef struct { ...@@ -81,6 +86,7 @@ typedef struct {
static plat_io_policy policies[] = { static plat_io_policy policies[] = {
{ FIP_IMAGE_NAME, &memmap_dev_handle, &fip_block_spec, open_memmap }, { FIP_IMAGE_NAME, &memmap_dev_handle, &fip_block_spec, open_memmap },
{ BL2_IMAGE_NAME, &fip_dev_handle, &bl2_file_spec, open_fip }, { BL2_IMAGE_NAME, &fip_dev_handle, &bl2_file_spec, open_fip },
{ BL30_IMAGE_NAME, &fip_dev_handle, &bl30_file_spec, open_fip },
{ BL31_IMAGE_NAME, &fip_dev_handle, &bl31_file_spec, open_fip }, { BL31_IMAGE_NAME, &fip_dev_handle, &bl31_file_spec, open_fip },
{ BL33_IMAGE_NAME, &fip_dev_handle, &bl33_file_spec, open_fip }, { BL33_IMAGE_NAME, &fip_dev_handle, &bl33_file_spec, open_fip },
{0, 0, 0} {0, 0, 0}
......
...@@ -54,6 +54,9 @@ ...@@ -54,6 +54,9 @@
/* Trusted Boot Firmware BL2 */ /* Trusted Boot Firmware BL2 */
#define BL2_IMAGE_NAME "bl2.bin" #define BL2_IMAGE_NAME "bl2.bin"
/* SCP Firmware BL3-0 */
#define BL30_IMAGE_NAME "bl30.bin"
/* EL3 Runtime Firmware BL3-1 */ /* EL3 Runtime Firmware BL3-1 */
#define BL31_IMAGE_NAME "bl31.bin" #define BL31_IMAGE_NAME "bl31.bin"
...@@ -155,6 +158,13 @@ ...@@ -155,6 +158,13 @@
******************************************************************************/ ******************************************************************************/
#define BL31_BASE 0x0400C000 #define BL31_BASE 0x0400C000
/*******************************************************************************
* BL3-0 specific defines.
* BL3-0 is loaded to the same place as BL3-1. Once BL3-0 is transferred to the
* SCP, it is discarded and BL3-1 is loaded over the top.
******************************************************************************/
#define BL30_BASE BL31_BASE
/******************************************************************************* /*******************************************************************************
* Platform specific page table and MMU setup constants * Platform specific page table and MMU setup constants
******************************************************************************/ ******************************************************************************/
......
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