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/bl1/bl1_main.c b/bl1/bl1_main.c
index ab9fa8c..5dfb564 100644
--- a/bl1/bl1_main.c
+++ b/bl1/bl1_main.c
@@ -50,7 +50,8 @@
unsigned long sctlr_el3 = read_sctlr();
unsigned long bl2_base;
unsigned int load_type = TOP_LOAD, spsr;
- meminfo bl1_tzram_layout, *bl2_tzram_layout = 0x0;
+ meminfo *bl1_tzram_layout;
+ meminfo *bl2_tzram_layout = 0x0;
/*
* Ensure that MMU/Caches and coherency are turned on
@@ -73,8 +74,8 @@
* Find out how much free trusted ram remains after BL1 load
* & load the BL2 image at its top
*/
- bl1_tzram_layout = bl1_get_sec_mem_layout();
- bl2_base = load_image(&bl1_tzram_layout,
+ bl1_tzram_layout = bl1_plat_sec_mem_layout();
+ bl2_base = load_image(bl1_tzram_layout,
(const char *) BL2_IMAGE_NAME,
load_type, BL2_BASE);
@@ -85,8 +86,8 @@
* to BL2. BL2 will read the memory layout before using its
* memory for other purposes.
*/
- bl2_tzram_layout = (meminfo *) bl1_tzram_layout.free_base;
- init_bl2_mem_layout(&bl1_tzram_layout,
+ bl2_tzram_layout = (meminfo *) bl1_tzram_layout->free_base;
+ init_bl2_mem_layout(bl1_tzram_layout,
bl2_tzram_layout,
load_type,
bl2_base);