aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSandrine Bailleux <sandrine.bailleux@arm.com>2014-03-12 16:05:25 +0000
committerSandrine Bailleux <sandrine.bailleux@arm.com>2014-03-12 16:05:25 +0000
commit68020e3ffad699587f8bec6fea1ddf8774e8f0dc (patch)
treeba6a64b01c1f7f57a4fd4b68f4d79349bc309d3a
parent6d6aea6e61130977284b6a3f8ef283635ed9c4b3 (diff)
juno: BL2: Load BL30
Signed-off-by: Ryan Harkin <ryan.harkin@linaro.org>
-rw-r--r--plat/juno/bl2_plat_setup.c56
-rw-r--r--plat/juno/plat_io_storage.c6
-rw-r--r--plat/juno/platform.h10
3 files changed, 72 insertions, 0 deletions
diff --git a/plat/juno/bl2_plat_setup.c b/plat/juno/bl2_plat_setup.c
index 28fac80..20dfc29 100644
--- a/plat/juno/bl2_plat_setup.c
+++ b/plat/juno/bl2_plat_setup.c
@@ -28,11 +28,15 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <stdio.h>
+#include <string.h>
#include <assert.h>
#include <arch_helpers.h>
#include <platform.h>
#include <bl2.h>
#include <bl_common.h>
+#include <scp_bootloader.h>
+#include <debug.h>
/*******************************************************************************
* Declarations of linker defined symbols which will help us find the layout
@@ -103,6 +107,54 @@ void bl2_early_platform_setup(meminfo *mem_layout,
}
/*******************************************************************************
+ * 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
* image and initialise the memory location to use for passing arguments to
* BL3-1.
@@ -112,6 +164,10 @@ void bl2_platform_setup()
/* Initialise the IO layer and register platform IO devices */
io_setup();
+ /* Load BL3-0 */
+ if (load_bl30() != 0)
+ panic();
+
/* 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_size = DRAM_SIZE;
diff --git a/plat/juno/plat_io_storage.c b/plat/juno/plat_io_storage.c
index ad16ca6..6f2d881 100644
--- a/plat/juno/plat_io_storage.c
+++ b/plat/juno/plat_io_storage.c
@@ -58,6 +58,11 @@ static io_file_spec bl2_file_spec = {
.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 = {
.path = BL31_IMAGE_NAME,
.mode = FOPEN_MODE_R
@@ -81,6 +86,7 @@ typedef struct {
static plat_io_policy policies[] = {
{ FIP_IMAGE_NAME, &memmap_dev_handle, &fip_block_spec, open_memmap },
{ 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 },
{ BL33_IMAGE_NAME, &fip_dev_handle, &bl33_file_spec, open_fip },
{0, 0, 0}
diff --git a/plat/juno/platform.h b/plat/juno/platform.h
index 1b902ea..1730532 100644
--- a/plat/juno/platform.h
+++ b/plat/juno/platform.h
@@ -54,6 +54,9 @@
/* Trusted Boot Firmware BL2 */
#define BL2_IMAGE_NAME "bl2.bin"
+/* SCP Firmware BL3-0 */
+#define BL30_IMAGE_NAME "bl30.bin"
+
/* EL3 Runtime Firmware BL3-1 */
#define BL31_IMAGE_NAME "bl31.bin"
@@ -156,6 +159,13 @@
#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
******************************************************************************/
#define ADDR_SPACE_SIZE (1ull << 32)