Add support for BL3-2 in BL2

This patch adds support for loading a BL3-2 image in BL2. In case a
BL3-2 image is found, it also passes information to BL3-1 about where it
is located and the extents of memory available to it. Information about
memory extents is populated by platform specific code.

The documentation has also been updated to reflect the above changes.

Change-Id: I526b2efb80babebab1318f2b02e319a86d6758b0
Co-authored-by: Jeenu Viswambharan <jeenu.viswambharan@arm.com>
diff --git a/plat/fvp/bl2_plat_setup.c b/plat/fvp/bl2_plat_setup.c
index 2e367d7..f0d6e44 100644
--- a/plat/fvp/bl2_plat_setup.c
+++ b/plat/fvp/bl2_plat_setup.c
@@ -122,6 +122,12 @@
 	/* Initialise the IO layer and register platform IO devices */
 	io_setup();
 
+	/*
+	 * Ensure that the secure DRAM memory used for passing BL31 arguments
+	 * does not overlap with the BL32_BASE.
+	 */
+	assert (BL32_BASE > TZDRAM_BASE + sizeof(bl31_args));
+
 	/* Use the Trusted DRAM for passing args to BL31 */
 	bl2_to_bl31_args = (bl31_args *) TZDRAM_BASE;
 
@@ -132,6 +138,22 @@
 	bl2_to_bl31_args->bl33_meminfo.free_size = DRAM_SIZE;
 	bl2_to_bl31_args->bl33_meminfo.attr = 0;
 	bl2_to_bl31_args->bl33_meminfo.next = 0;
+
+	/*
+	 * Populate the extents of memory available for loading BL32.
+	 * TODO: We are temporarily executing BL2 from TZDRAM; will eventually
+	 * move to Trusted SRAM
+	 */
+	bl2_to_bl31_args->bl32_meminfo.total_base = BL32_BASE;
+	bl2_to_bl31_args->bl32_meminfo.free_base = BL32_BASE;
+
+	bl2_to_bl31_args->bl32_meminfo.total_size =
+		(TZDRAM_BASE + TZDRAM_SIZE) - BL32_BASE;
+	bl2_to_bl31_args->bl32_meminfo.free_size =
+		(TZDRAM_BASE + TZDRAM_SIZE) - BL32_BASE;
+
+	bl2_to_bl31_args->bl32_meminfo.attr = BOT_LOAD;
+	bl2_to_bl31_args->bl32_meminfo.next = 0;
 }
 
 /*******************************************************************************
diff --git a/plat/fvp/platform.h b/plat/fvp/platform.h
index 76a9fca..11b62cc 100644
--- a/plat/fvp/platform.h
+++ b/plat/fvp/platform.h
@@ -236,6 +236,11 @@
 #define BL31_BASE			0x0400C000
 
 /*******************************************************************************
+ * BL32 specific defines.
+ ******************************************************************************/
+#define BL32_BASE			(TZDRAM_BASE + 0x2000)
+
+/*******************************************************************************
  * Platform specific page table and MMU setup constants
  ******************************************************************************/
 #define EL3_ADDR_SPACE_SIZE		(1ull << 32)