Remove useless copies of meminfo structures

Platform setup code has to reserve some memory for storing the
memory layout information.  It is populated in early platform setup
code.

blx_get_sec_mem_layout() functions used to return a copy of this
structure.  This patch modifies blx_get_sec_mem_layout() functions
so that they now directly return a pointer to their memory layout
structure.  It ensures that the memory layout returned by
blx_get_sec_mem_layout() is always up-to-date and also avoids a
useless copy of the meminfo structure.

Also rename blx_get_sec_mem_layout() to blx_plat_sec_mem_layout()
to make it clear those functions are platform specific.

Change-Id: Ic7a6f9d6b6236b14865ab48a9f5eff545ce56551
diff --git a/docs/change-log.md b/docs/change-log.md
index 4e5b9aa..e813cb1 100644
--- a/docs/change-log.md
+++ b/docs/change-log.md
@@ -73,6 +73,11 @@
     CPU_SUSPEND and CPU_OFF apis simultaneously across cpus & clusters should
     not result in unexpected behaviour.
 
+*   The API to return the memory layout structures for each bootloader stage has
+    undergone change. A pointer to these structures is returned instead of their
+    copy.
+
+
 ARM Trusted Firmware - version 0.2
 ==================================
 
diff --git a/docs/porting-guide.md b/docs/porting-guide.md
index c0e6ace..aa1451f 100644
--- a/docs/porting-guide.md
+++ b/docs/porting-guide.md
@@ -436,14 +436,15 @@
 This function helps fulfill requirement 5 above.
 
 
-### Function : bl1_get_sec_mem_layout() [mandatory]
+### Function : bl1_plat_sec_mem_layout() [mandatory]
 
     Argument : void
-    Return   : meminfo
+    Return   : meminfo *
 
-This function executes with the MMU and data caches enabled. The `meminfo`
-structure returned by this function must contain the extents and availability of
-secure RAM for the BL1 stage.
+This function should only be called on the cold boot path. It executes with the
+MMU and data caches enabled. The pointer returned by this function must point to
+a `meminfo` structure containing the extents and availability of secure RAM for
+the BL1 stage.
 
     meminfo.total_base = Base address of secure RAM visible to BL1
     meminfo.total_size = Size of secure RAM visible to BL1
@@ -533,7 +534,7 @@
 The platform must copy the contents of the `meminfo` structure into a private
 variable as the original memory may be subsequently overwritten by BL2. The
 copied structure is made available to all BL2 code through the
-`bl2_get_sec_mem_layout()` function.
+`bl2_plat_sec_mem_layout()` function.
 
 
 ### Function : bl2_plat_arch_setup() [mandatory]
@@ -576,17 +577,17 @@
 structure can be populated.
 
 
-### Function : bl2_get_sec_mem_layout() [mandatory]
+### Function : bl2_plat_sec_mem_layout() [mandatory]
 
     Argument : void
-    Return   : meminfo
+    Return   : meminfo *
 
-This function may execute with the MMU and data caches enabled if the platform
-port does the necessary initialization in `bl2_plat_arch_setup()`. It is only
-called by the primary CPU.
+This function should only be called on the cold boot path. It may execute with
+the MMU and data caches enabled if the platform port does the necessary
+initialization in `bl2_plat_arch_setup()`. It is only called by the primary CPU.
 
-The purpose of this function is to return a `meminfo` structure populated with
-the extents of secure RAM available for BL2 to use. See
+The purpose of this function is to return a pointer to a `meminfo` structure
+populated with the extents of secure RAM available for BL2 to use. See
 `bl2_early_platform_setup()` above.
 
 
@@ -663,7 +664,7 @@
 The platform must copy the contents of the `meminfo` structure into a private
 variable as the original memory may be subsequently overwritten by BL3-1. The
 copied structure is made available to all BL3-1 code through the
-`bl31_get_sec_mem_layout()` function.
+`bl31_plat_sec_mem_layout()` function.
 
 
 ### Function : bl31_plat_arch_setup() [mandatory]
@@ -713,17 +714,18 @@
 copied during `bl31_early_platform_setup()`).
 
 
-### Function : bl31_get_sec_mem_layout() [mandatory]
+### Function : bl31_plat_sec_mem_layout() [mandatory]
 
     Argument : void
-    Return   : meminfo
+    Return   : meminfo *
 
-This function may execute with the MMU and data caches enabled if the platform
-port does the necessary initializations in `bl31_plat_arch_setup()`. It is only
-called by the primary CPU.
+This function should only be called on the cold boot path. This function may
+execute with the MMU and data caches enabled if the platform port does the
+necessary initializations in `bl31_plat_arch_setup()`. It is only called by the
+primary CPU.
 
-The purpose of this function is to return a `meminfo` structure populated with
-the extents of secure RAM available for BL3-1 to use. See
+The purpose of this function is to return a pointer to a `meminfo` structure
+populated with the extents of secure RAM available for BL3-1 to use. See
 `bl31_early_platform_setup()` above.