summaryrefslogtreecommitdiff
path: root/plat/arm/common
diff options
context:
space:
mode:
Diffstat (limited to 'plat/arm/common')
-rw-r--r--plat/arm/common/arm_bl31_setup.c38
-rw-r--r--plat/arm/common/arm_common.c1
-rw-r--r--plat/arm/common/arm_common.mk11
3 files changed, 49 insertions, 1 deletions
diff --git a/plat/arm/common/arm_bl31_setup.c b/plat/arm/common/arm_bl31_setup.c
index c5456639..ed2c3fbc 100644
--- a/plat/arm/common/arm_bl31_setup.c
+++ b/plat/arm/common/arm_bl31_setup.c
@@ -15,6 +15,8 @@
#include <plat_arm.h>
#include <platform.h>
#include <ras.h>
+#include <utils.h>
+#include <arm_xlat_tables.h>
/*
* Placeholder variables for copying the arguments that have been passed to
@@ -35,10 +37,20 @@ CASSERT(BL31_BASE >= ARM_TB_FW_CONFIG_LIMIT, assert_bl31_base_overflows);
#pragma weak bl31_plat_arch_setup
#pragma weak bl31_plat_get_next_image_ep_info
-#define MAP_BL31_TOTAL MAP_REGION_FLAT( \
+#define MAP_BL31_TOTAL MAP_REGION_FLAT( \
BL31_BASE, \
BL31_END - BL31_BASE, \
MT_MEMORY | MT_RW | MT_SECURE)
+#if RECLAIM_INIT_CODE
+IMPORT_SYM(unsigned long, __INIT_CODE_START__, BL_INIT_CODE_BASE);
+IMPORT_SYM(unsigned long, __INIT_CODE_END__, BL_INIT_CODE_END);
+
+#define MAP_BL_INIT_CODE MAP_REGION_FLAT( \
+ BL_INIT_CODE_BASE, \
+ BL_INIT_CODE_END \
+ - BL_INIT_CODE_BASE, \
+ MT_CODE | MT_SECURE)
+#endif
/*******************************************************************************
* Return a pointer to the 'entry_point_info' structure of the next image for the
@@ -233,7 +245,28 @@ void arm_bl31_plat_runtime_setup(void)
/* Initialize the runtime console */
arm_console_runtime_init();
+#if RECLAIM_INIT_CODE
+ arm_free_init_memory();
+#endif
+}
+
+#if RECLAIM_INIT_CODE
+/*
+ * Zero out and make RW memory used to store image boot time code so it can
+ * be reclaimed during runtime
+ */
+void arm_free_init_memory(void)
+{
+ int ret = xlat_change_mem_attributes(BL_INIT_CODE_BASE,
+ BL_INIT_CODE_END - BL_INIT_CODE_BASE,
+ MT_RW_DATA);
+
+ if (ret != 0) {
+ ERROR("Could not reclaim initialization code");
+ panic();
+ }
}
+#endif
void __init bl31_platform_setup(void)
{
@@ -255,6 +288,9 @@ void __init arm_bl31_plat_arch_setup(void)
{
const mmap_region_t bl_regions[] = {
MAP_BL31_TOTAL,
+#if RECLAIM_INIT_CODE
+ MAP_BL_INIT_CODE,
+#endif
ARM_MAP_BL_RO,
#if USE_ROMLIB
ARM_MAP_ROMLIB_CODE,
diff --git a/plat/arm/common/arm_common.c b/plat/arm/common/arm_common.c
index ae06ef28..a21d189e 100644
--- a/plat/arm/common/arm_common.c
+++ b/plat/arm/common/arm_common.c
@@ -38,6 +38,7 @@ void arm_setup_romlib(void)
* as an array specifying the generic memory regions which can be;
* - Code section;
* - Read-only data section;
+ * - Init code section, if applicable
* - Coherent memory region, if applicable.
*/
diff --git a/plat/arm/common/arm_common.mk b/plat/arm/common/arm_common.mk
index a8df5bad..276f7801 100644
--- a/plat/arm/common/arm_common.mk
+++ b/plat/arm/common/arm_common.mk
@@ -273,3 +273,14 @@ endif
include ${IMG_PARSER_LIB_MK}
endif
+
+# RECLAIM_INIT_CODE can only be set when LOAD_IMAGE_V2=2 and xlat tables v2
+# are used
+ifeq (${RECLAIM_INIT_CODE}, 1)
+ ifeq (${LOAD_IMAGE_V2}, 0)
+ $(error "LOAD_IMAGE_V2 must be enabled to use RECLAIM_INIT_CODE")
+ endif
+ ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
+ $(error "To reclaim init code xlat tables v2 must be used")
+ endif
+endif