AArch32: Support in SP_MIN to receive arguments from BL2
This patch adds support in SP_MIN to receive generic and
platform specific arguments from BL2.
The new signature is as following:
void sp_min_early_platform_setup(void *from_bl2,
void *plat_params_from_bl2);
ARM platforms have been modified to use this support.
Note: Platforms may break if using old signature.
Default value for RESET_TO_SP_MIN is changed to 0.
Change-Id: I008d4b09fd3803c7b6231587ebf02a047bdba8d0
diff --git a/bl32/sp_min/sp_min.mk b/bl32/sp_min/sp_min.mk
index a8b572e..ac7f03e 100644
--- a/bl32/sp_min/sp_min.mk
+++ b/bl32/sp_min/sp_min.mk
@@ -58,6 +58,6 @@
include ${SP_MIN_PLAT_MAKEFILE}
endif
-RESET_TO_SP_MIN := 1
+RESET_TO_SP_MIN := 0
$(eval $(call add_define,RESET_TO_SP_MIN))
$(eval $(call assert_boolean,RESET_TO_SP_MIN))
diff --git a/include/bl32/sp_min/platform_sp_min.h b/include/bl32/sp_min/platform_sp_min.h
index ae9dd58..c8c3fc5 100644
--- a/include/bl32/sp_min/platform_sp_min.h
+++ b/include/bl32/sp_min/platform_sp_min.h
@@ -34,7 +34,8 @@
/*******************************************************************************
* Mandatory SP_MIN functions
******************************************************************************/
-void sp_min_early_platform_setup(void);
+void sp_min_early_platform_setup(void *from_bl2,
+ void *plat_params_from_bl2);
void sp_min_plat_arch_setup(void);
void sp_min_platform_setup(void);
entry_point_info_t *sp_min_plat_get_bl33_ep_info(void);
diff --git a/include/plat/arm/common/plat_arm.h b/include/plat/arm/common/plat_arm.h
index 581573b..29fcffe 100644
--- a/include/plat/arm/common/plat_arm.h
+++ b/include/plat/arm/common/plat_arm.h
@@ -180,7 +180,8 @@
void arm_tsp_early_platform_setup(void);
/* SP_MIN utility functions */
-void arm_sp_min_early_platform_setup(void);
+void arm_sp_min_early_platform_setup(void *from_bl2,
+ void *plat_params_from_bl2);
/* FIP TOC validity check */
int arm_io_is_toc_valid(void);
diff --git a/plat/arm/board/fvp/sp_min/fvp_sp_min_setup.c b/plat/arm/board/fvp/sp_min/fvp_sp_min_setup.c
index d3bef82..735c4f0 100644
--- a/plat/arm/board/fvp/sp_min/fvp_sp_min_setup.c
+++ b/plat/arm/board/fvp/sp_min/fvp_sp_min_setup.c
@@ -31,9 +31,10 @@
#include <plat_arm.h>
#include "../fvp_private.h"
-void sp_min_early_platform_setup(void)
+void sp_min_early_platform_setup(void *from_bl2,
+ void *plat_params_from_bl2)
{
- arm_sp_min_early_platform_setup();
+ arm_sp_min_early_platform_setup(from_bl2, plat_params_from_bl2);
/* Initialize the platform config for future decision making */
fvp_config_setup();
diff --git a/plat/arm/common/sp_min/arm_sp_min_setup.c b/plat/arm/common/sp_min/arm_sp_min_setup.c
index 927f30f..d48556e 100644
--- a/plat/arm/common/sp_min/arm_sp_min_setup.c
+++ b/plat/arm/common/sp_min/arm_sp_min_setup.c
@@ -30,6 +30,7 @@
#include <assert.h>
#include <console.h>
+#include <debug.h>
#include <mmio.h>
#include <plat_arm.h>
#include <platform.h>
@@ -58,10 +59,6 @@
#pragma weak sp_min_platform_setup
#pragma weak sp_min_plat_arch_setup
-#ifndef RESET_TO_SP_MIN
-#error (" RESET_TO_SP_MIN flag is expected to be set.")
-#endif
-
/*******************************************************************************
* Return a pointer to the 'entry_point_info' structure of the next image for the
@@ -86,15 +83,20 @@
}
/*******************************************************************************
- * Perform early platform setup. We expect SP_MIN is the first boot loader
- * image and RESET_TO_SP_MIN build option to be set.
+ * Perform early platform setup.
******************************************************************************/
-void arm_sp_min_early_platform_setup(void)
+void arm_sp_min_early_platform_setup(void *from_bl2,
+ void *plat_params_from_bl2)
{
/* Initialize the console to provide early debug support */
console_init(PLAT_ARM_BOOT_UART_BASE, PLAT_ARM_BOOT_UART_CLK_IN_HZ,
ARM_CONSOLE_BAUDRATE);
+#if RESET_TO_SP_MIN
+ /* There are no parameters from BL2 if SP_MIN is a reset vector */
+ assert(from_bl2 == NULL);
+ assert(plat_params_from_bl2 == NULL);
+
/* Populate entry point information for BL33 */
SET_PARAM_HEAD(&bl33_image_ep_info,
PARAM_EP,
@@ -104,18 +106,46 @@
* Tell SP_MIN where the non-trusted software image
* is located and the entry state information
*/
-#ifdef PRELOADED_BL33_BASE
- bl33_image_ep_info.pc = PRELOADED_BL33_BASE;
-#else
bl33_image_ep_info.pc = plat_get_ns_image_entrypoint();
-#endif
bl33_image_ep_info.spsr = arm_get_spsr_for_bl33_entry();
SET_SECURITY_STATE(bl33_image_ep_info.h.attr, NON_SECURE);
+
+#else /* RESET_TO_SP_MIN */
+
+ /*
+ * Check params passed from BL2 should not be NULL,
+ */
+ bl_params_t *params_from_bl2 = (bl_params_t *)from_bl2;
+ assert(params_from_bl2 != NULL);
+ assert(params_from_bl2->h.type == PARAM_BL_PARAMS);
+ assert(params_from_bl2->h.version >= VERSION_2);
+
+ bl_params_node_t *bl_params = params_from_bl2->head;
+
+ /*
+ * Copy BL33 entry point information.
+ * They are stored in Secure RAM, in BL2's address space.
+ */
+ while (bl_params) {
+ if (bl_params->image_id == BL33_IMAGE_ID) {
+ bl33_image_ep_info = *bl_params->ep_info;
+ break;
+ }
+
+ bl_params = bl_params->next_params_info;
+ }
+
+ if (bl33_image_ep_info.pc == 0)
+ panic();
+
+#endif /* RESET_TO_SP_MIN */
+
}
-void sp_min_early_platform_setup(void)
+void sp_min_early_platform_setup(void *from_bl2,
+ void *plat_params_from_bl2)
{
- arm_sp_min_early_platform_setup();
+ arm_sp_min_early_platform_setup(from_bl2, plat_params_from_bl2);
/*
* Initialize Interconnect for this cluster during cold boot.
@@ -146,10 +176,10 @@
/*
* Do initial security configuration to allow DRAM/device access
* (if earlier BL has not already done so).
- * TODO: If RESET_TO_SP_MIN is not set, the security setup needs
- * to be skipped.
*/
+#if RESET_TO_SP_MIN
plat_arm_security_setup();
+#endif
/* Enable and initialize the System level generic timer */
mmio_write_32(ARM_SYS_CNTCTL_BASE + CNTCR_OFF,