mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-19 02:54:24 +00:00
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
This commit is contained in:
parent
dc98e5370a
commit
ee12f6f749
10 changed files with 49 additions and 40 deletions
|
@ -50,7 +50,8 @@ void bl1_main(void)
|
||||||
unsigned long sctlr_el3 = read_sctlr();
|
unsigned long sctlr_el3 = read_sctlr();
|
||||||
unsigned long bl2_base;
|
unsigned long bl2_base;
|
||||||
unsigned int load_type = TOP_LOAD, spsr;
|
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
|
* Ensure that MMU/Caches and coherency are turned on
|
||||||
|
@ -73,8 +74,8 @@ void bl1_main(void)
|
||||||
* Find out how much free trusted ram remains after BL1 load
|
* Find out how much free trusted ram remains after BL1 load
|
||||||
* & load the BL2 image at its top
|
* & load the BL2 image at its top
|
||||||
*/
|
*/
|
||||||
bl1_tzram_layout = bl1_get_sec_mem_layout();
|
bl1_tzram_layout = bl1_plat_sec_mem_layout();
|
||||||
bl2_base = load_image(&bl1_tzram_layout,
|
bl2_base = load_image(bl1_tzram_layout,
|
||||||
(const char *) BL2_IMAGE_NAME,
|
(const char *) BL2_IMAGE_NAME,
|
||||||
load_type, BL2_BASE);
|
load_type, BL2_BASE);
|
||||||
|
|
||||||
|
@ -85,8 +86,8 @@ void bl1_main(void)
|
||||||
* to BL2. BL2 will read the memory layout before using its
|
* to BL2. BL2 will read the memory layout before using its
|
||||||
* memory for other purposes.
|
* memory for other purposes.
|
||||||
*/
|
*/
|
||||||
bl2_tzram_layout = (meminfo *) bl1_tzram_layout.free_base;
|
bl2_tzram_layout = (meminfo *) bl1_tzram_layout->free_base;
|
||||||
init_bl2_mem_layout(&bl1_tzram_layout,
|
init_bl2_mem_layout(bl1_tzram_layout,
|
||||||
bl2_tzram_layout,
|
bl2_tzram_layout,
|
||||||
load_type,
|
load_type,
|
||||||
bl2_base);
|
bl2_base);
|
||||||
|
|
|
@ -46,7 +46,8 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
void bl2_main(void)
|
void bl2_main(void)
|
||||||
{
|
{
|
||||||
meminfo bl2_tzram_layout, *bl31_tzram_layout;
|
meminfo *bl2_tzram_layout;
|
||||||
|
meminfo *bl31_tzram_layout;
|
||||||
el_change_info *ns_image_info;
|
el_change_info *ns_image_info;
|
||||||
unsigned long bl31_base, el_status;
|
unsigned long bl31_base, el_status;
|
||||||
unsigned int bl2_load, bl31_load, mode;
|
unsigned int bl2_load, bl31_load, mode;
|
||||||
|
@ -62,7 +63,7 @@ void bl2_main(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Find out how much free trusted ram remains after BL2 load */
|
/* Find out how much free trusted ram remains after BL2 load */
|
||||||
bl2_tzram_layout = bl2_get_sec_mem_layout();
|
bl2_tzram_layout = bl2_plat_sec_mem_layout();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Load BL31. BL1 tells BL2 whether it has been TOP or BOTTOM loaded.
|
* Load BL31. BL1 tells BL2 whether it has been TOP or BOTTOM loaded.
|
||||||
|
@ -70,10 +71,10 @@ void bl2_main(void)
|
||||||
* loaded opposite to BL2. This allows BL31 to reclaim BL2 memory
|
* loaded opposite to BL2. This allows BL31 to reclaim BL2 memory
|
||||||
* while maintaining its free space in one contiguous chunk.
|
* while maintaining its free space in one contiguous chunk.
|
||||||
*/
|
*/
|
||||||
bl2_load = bl2_tzram_layout.attr & LOAD_MASK;
|
bl2_load = bl2_tzram_layout->attr & LOAD_MASK;
|
||||||
assert((bl2_load == TOP_LOAD) || (bl2_load == BOT_LOAD));
|
assert((bl2_load == TOP_LOAD) || (bl2_load == BOT_LOAD));
|
||||||
bl31_load = (bl2_load == TOP_LOAD) ? BOT_LOAD : TOP_LOAD;
|
bl31_load = (bl2_load == TOP_LOAD) ? BOT_LOAD : TOP_LOAD;
|
||||||
bl31_base = load_image(&bl2_tzram_layout, BL31_IMAGE_NAME,
|
bl31_base = load_image(bl2_tzram_layout, BL31_IMAGE_NAME,
|
||||||
bl31_load, BL31_BASE);
|
bl31_load, BL31_BASE);
|
||||||
|
|
||||||
/* Assert if it has not been possible to load BL31 */
|
/* Assert if it has not been possible to load BL31 */
|
||||||
|
@ -84,7 +85,7 @@ void bl2_main(void)
|
||||||
* will gobble up all the BL2 memory.
|
* will gobble up all the BL2 memory.
|
||||||
*/
|
*/
|
||||||
bl31_tzram_layout = (meminfo *) get_el_change_mem_ptr();
|
bl31_tzram_layout = (meminfo *) get_el_change_mem_ptr();
|
||||||
init_bl31_mem_layout(&bl2_tzram_layout, bl31_tzram_layout, bl31_load);
|
init_bl31_mem_layout(bl2_tzram_layout, bl31_tzram_layout, bl31_load);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* BL2 also needs to tell BL31 where the non-trusted software image
|
* BL2 also needs to tell BL31 where the non-trusted software image
|
||||||
|
|
|
@ -73,6 +73,11 @@ Detailed changes since last release
|
||||||
CPU_SUSPEND and CPU_OFF apis simultaneously across cpus & clusters should
|
CPU_SUSPEND and CPU_OFF apis simultaneously across cpus & clusters should
|
||||||
not result in unexpected behaviour.
|
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
|
ARM Trusted Firmware - version 0.2
|
||||||
==================================
|
==================================
|
||||||
|
|
||||||
|
|
|
@ -436,14 +436,15 @@ implementation of the generic timer counter and initializes the console.
|
||||||
This function helps fulfill requirement 5 above.
|
This function helps fulfill requirement 5 above.
|
||||||
|
|
||||||
|
|
||||||
### Function : bl1_get_sec_mem_layout() [mandatory]
|
### Function : bl1_plat_sec_mem_layout() [mandatory]
|
||||||
|
|
||||||
Argument : void
|
Argument : void
|
||||||
Return : meminfo
|
Return : meminfo *
|
||||||
|
|
||||||
This function executes with the MMU and data caches enabled. The `meminfo`
|
This function should only be called on the cold boot path. It executes with the
|
||||||
structure returned by this function must contain the extents and availability of
|
MMU and data caches enabled. The pointer returned by this function must point to
|
||||||
secure RAM for the BL1 stage.
|
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_base = Base address of secure RAM visible to BL1
|
||||||
meminfo.total_size = Size of secure RAM visible to BL1
|
meminfo.total_size = Size of secure RAM visible to BL1
|
||||||
|
@ -533,7 +534,7 @@ by the primary CPU. The arguments to this function are:
|
||||||
The platform must copy the contents of the `meminfo` structure into a private
|
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
|
variable as the original memory may be subsequently overwritten by BL2. The
|
||||||
copied structure is made available to all BL2 code through 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]
|
### Function : bl2_plat_arch_setup() [mandatory]
|
||||||
|
@ -576,17 +577,17 @@ initialized by the platform to point to memory where an `el_change_info`
|
||||||
structure can be populated.
|
structure can be populated.
|
||||||
|
|
||||||
|
|
||||||
### Function : bl2_get_sec_mem_layout() [mandatory]
|
### Function : bl2_plat_sec_mem_layout() [mandatory]
|
||||||
|
|
||||||
Argument : void
|
Argument : void
|
||||||
Return : meminfo
|
Return : meminfo *
|
||||||
|
|
||||||
This function may execute with the MMU and data caches enabled if the platform
|
This function should only be called on the cold boot path. It may execute with
|
||||||
port does the necessary initialization in `bl2_plat_arch_setup()`. It is only
|
the MMU and data caches enabled if the platform port does the necessary
|
||||||
called by the primary CPU.
|
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 purpose of this function is to return a pointer to a `meminfo` structure
|
||||||
the extents of secure RAM available for BL2 to use. See
|
populated with the extents of secure RAM available for BL2 to use. See
|
||||||
`bl2_early_platform_setup()` above.
|
`bl2_early_platform_setup()` above.
|
||||||
|
|
||||||
|
|
||||||
|
@ -663,7 +664,7 @@ by the primary CPU. The arguments to this function are:
|
||||||
The platform must copy the contents of the `meminfo` structure into a private
|
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
|
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
|
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]
|
### Function : bl31_plat_arch_setup() [mandatory]
|
||||||
|
@ -713,17 +714,18 @@ function must return a pointer to the `el_change_info` structure (that was
|
||||||
copied during `bl31_early_platform_setup()`).
|
copied during `bl31_early_platform_setup()`).
|
||||||
|
|
||||||
|
|
||||||
### Function : bl31_get_sec_mem_layout() [mandatory]
|
### Function : bl31_plat_sec_mem_layout() [mandatory]
|
||||||
|
|
||||||
Argument : void
|
Argument : void
|
||||||
Return : meminfo
|
Return : meminfo *
|
||||||
|
|
||||||
This function may execute with the MMU and data caches enabled if the platform
|
This function should only be called on the cold boot path. This function may
|
||||||
port does the necessary initializations in `bl31_plat_arch_setup()`. It is only
|
execute with the MMU and data caches enabled if the platform port does the
|
||||||
called by the primary CPU.
|
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 purpose of this function is to return a pointer to a `meminfo` structure
|
||||||
the extents of secure RAM available for BL3-1 to use. See
|
populated with the extents of secure RAM available for BL3-1 to use. See
|
||||||
`bl31_early_platform_setup()` above.
|
`bl31_early_platform_setup()` above.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
* Function prototypes
|
* Function prototypes
|
||||||
*****************************************/
|
*****************************************/
|
||||||
extern void bl1_platform_setup(void);
|
extern void bl1_platform_setup(void);
|
||||||
extern meminfo bl1_get_sec_mem_layout(void);
|
extern meminfo *bl1_plat_sec_mem_layout(void);
|
||||||
|
|
||||||
#endif /*__ASSEMBLY__*/
|
#endif /*__ASSEMBLY__*/
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ extern unsigned long long bl2_entrypoint;
|
||||||
* Function prototypes
|
* Function prototypes
|
||||||
*****************************************/
|
*****************************************/
|
||||||
extern void bl2_platform_setup(void);
|
extern void bl2_platform_setup(void);
|
||||||
extern meminfo bl2_get_sec_mem_layout(void);
|
extern meminfo *bl2_plat_sec_mem_layout(void);
|
||||||
extern meminfo bl2_get_ns_mem_layout(void);
|
extern meminfo bl2_get_ns_mem_layout(void);
|
||||||
|
|
||||||
#endif /* __BL2_H__ */
|
#endif /* __BL2_H__ */
|
||||||
|
|
|
@ -42,7 +42,7 @@ extern unsigned long bl31_entrypoint;
|
||||||
* Function prototypes
|
* Function prototypes
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
extern void bl31_platform_setup(void);
|
extern void bl31_platform_setup(void);
|
||||||
extern meminfo bl31_get_sec_mem_layout(void);
|
extern meminfo *bl31_plat_sec_mem_layout(void);
|
||||||
extern el_change_info* bl31_get_next_image_info(unsigned long);
|
extern el_change_info* bl31_get_next_image_info(unsigned long);
|
||||||
extern void gic_cpuif_deactivate(unsigned int);
|
extern void gic_cpuif_deactivate(unsigned int);
|
||||||
extern void gic_cpuif_setup(unsigned int);
|
extern void gic_cpuif_setup(unsigned int);
|
||||||
|
|
|
@ -63,9 +63,9 @@ extern unsigned long __BL1_RAM_END__;
|
||||||
/* Data structure which holds the extents of the trusted SRAM for BL1*/
|
/* Data structure which holds the extents of the trusted SRAM for BL1*/
|
||||||
static meminfo bl1_tzram_layout;
|
static meminfo bl1_tzram_layout;
|
||||||
|
|
||||||
meminfo bl1_get_sec_mem_layout(void)
|
meminfo *bl1_plat_sec_mem_layout(void)
|
||||||
{
|
{
|
||||||
return bl1_tzram_layout;
|
return &bl1_tzram_layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
|
@ -72,9 +72,9 @@ static meminfo bl2_tzram_layout
|
||||||
__attribute__ ((aligned(PLATFORM_CACHE_LINE_SIZE),
|
__attribute__ ((aligned(PLATFORM_CACHE_LINE_SIZE),
|
||||||
section("tzfw_coherent_mem")));
|
section("tzfw_coherent_mem")));
|
||||||
|
|
||||||
meminfo bl2_get_sec_mem_layout(void)
|
meminfo *bl2_plat_sec_mem_layout(void)
|
||||||
{
|
{
|
||||||
return bl2_tzram_layout;
|
return &bl2_tzram_layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
|
@ -85,9 +85,9 @@ static meminfo bl31_tzram_layout
|
||||||
__attribute__ ((aligned(PLATFORM_CACHE_LINE_SIZE),
|
__attribute__ ((aligned(PLATFORM_CACHE_LINE_SIZE),
|
||||||
section("tzfw_coherent_mem")));
|
section("tzfw_coherent_mem")));
|
||||||
|
|
||||||
meminfo bl31_get_sec_mem_layout(void)
|
meminfo *bl31_plat_sec_mem_layout(void)
|
||||||
{
|
{
|
||||||
return bl31_tzram_layout;
|
return &bl31_tzram_layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
Loading…
Add table
Reference in a new issue