aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Hu <david.hu@arm.com>2019-11-27 11:21:50 +0800
committerDavid Hu <david.hu@arm.com>2019-11-27 11:21:50 +0800
commit3b9f5c35a8f0893659c0820c79a53334df19e214 (patch)
treea29fcbe4c9441c472784d766dc707fabc7f8c788
parent743391ae453b3475f1f10438790e13b2285dac81 (diff)
downloadtrusted-firmware-m-3b9f5c35a8f0893659c0820c79a53334df19e214.tar.gz
Platform: Update post HW init function in Secure side
Update the post hardware init functions in Secure side and the implementation on PSoC platforms, to align with those on master branch. Change-Id: I0f4c76e7156d9939651e301f610cec6edda29bf0 Signed-off-by: David Hu <david.hu@arm.com>
-rw-r--r--platform/ext/common/tfm_platform.c27
-rw-r--r--platform/ext/target/cypress/psoc62/spm_hal.c5
-rw-r--r--platform/ext/target/cypress/psoc64/spm_hal.c4
-rw-r--r--platform/ext/target/cypress/psoc64_1m/spm_hal.c4
-rw-r--r--platform/include/tfm_spm_hal.h19
-rw-r--r--secure_fw/core/tfm_core.c2
6 files changed, 32 insertions, 29 deletions
diff --git a/platform/ext/common/tfm_platform.c b/platform/ext/common/tfm_platform.c
index 8b31163a93..48e56f1aff 100644
--- a/platform/ext/common/tfm_platform.c
+++ b/platform/ext/common/tfm_platform.c
@@ -7,25 +7,22 @@
#include "target_cfg.h"
#include "platform/include/tfm_spm_hal.h"
+#include "uart_stdout.h"
-/**
- * \brief This function initializes platform peripherals.
- *
- * Contrarily to SystemInit() intended for a high-priority hw initialization
- * (for example clock and power subsystems), and called on a very early boot
- * stage from startup code, this function is called from C code, hence
- * variables and other drivers data are protected from being cleared up by the
- * C library init.
- * Implemented as a "weak" function, it can be overwritten by a platform
- * specific implementation.
- *
- * \return Returns values as specified by the \ref tfm_plat_err_t
- */
+/* platform-specific hw initialization */
+__WEAK enum tfm_plat_err_t tfm_spm_hal_post_init_platform(void)
+{
+ return TFM_PLAT_ERR_SUCCESS;
+}
-__WEAK enum tfm_plat_err_t tfm_spm_hal_post_platform_init(void)
+enum tfm_plat_err_t tfm_spm_hal_post_init(void)
{
+ if (tfm_spm_hal_post_init_platform() != TFM_PLAT_ERR_SUCCESS) {
+ return TFM_PLAT_ERR_SYSTEM_ERR;
+ }
+
__enable_irq();
stdio_init();
+
return TFM_PLAT_ERR_SUCCESS;
}
-
diff --git a/platform/ext/target/cypress/psoc62/spm_hal.c b/platform/ext/target/cypress/psoc62/spm_hal.c
index de2464c08c..c049c380fa 100644
--- a/platform/ext/target/cypress/psoc62/spm_hal.c
+++ b/platform/ext/target/cypress/psoc62/spm_hal.c
@@ -374,10 +374,9 @@ enum tfm_plat_err_t tfm_spm_hal_init_debug(void)
return TFM_PLAT_ERR_SUCCESS;
}
-enum tfm_plat_err_t tfm_spm_hal_post_platform_init(void)
+enum tfm_plat_err_t tfm_spm_hal_post_init_platform(void)
{
platform_init();
- __enable_irq();
- stdio_init();
+
return TFM_PLAT_ERR_SUCCESS;
}
diff --git a/platform/ext/target/cypress/psoc64/spm_hal.c b/platform/ext/target/cypress/psoc64/spm_hal.c
index dfafb6733c..a48757624f 100644
--- a/platform/ext/target/cypress/psoc64/spm_hal.c
+++ b/platform/ext/target/cypress/psoc64/spm_hal.c
@@ -404,11 +404,9 @@ void mock_tfm_shared_data(void)
memcpy(boot_data, mock_data, sizeof(mock_data));
}
-enum tfm_plat_err_t tfm_spm_hal_post_platform_init(void)
+enum tfm_plat_err_t tfm_spm_hal_post_init_platform(void)
{
platform_init();
- __enable_irq();
- stdio_init();
/* FIXME: Use the actual data from mcuboot */
mock_tfm_shared_data();
diff --git a/platform/ext/target/cypress/psoc64_1m/spm_hal.c b/platform/ext/target/cypress/psoc64_1m/spm_hal.c
index 98c4e6efbd..0dbf39d5c5 100644
--- a/platform/ext/target/cypress/psoc64_1m/spm_hal.c
+++ b/platform/ext/target/cypress/psoc64_1m/spm_hal.c
@@ -422,11 +422,9 @@ void mock_tfm_shared_data(void)
memcpy(boot_data, mock_data, sizeof(mock_data));
}
-enum tfm_plat_err_t tfm_spm_hal_post_platform_init(void)
+enum tfm_plat_err_t tfm_spm_hal_post_init_platform(void)
{
platform_init();
- __enable_irq();
- stdio_init();
/* FIXME: Use the actual data from mcuboot */
mock_tfm_shared_data();
diff --git a/platform/include/tfm_spm_hal.h b/platform/include/tfm_spm_hal.h
index 991e5c1e57..37dd9edc18 100644
--- a/platform/include/tfm_spm_hal.h
+++ b/platform/include/tfm_spm_hal.h
@@ -70,19 +70,30 @@ struct tfm_spm_partition_memory_data_t
#endif
/**
- * \brief This function initializes platform peripherals.
+ * \brief This function initializes peripherals common to all platforms.
*
* Contrarily to SystemInit() intended for a high-priority hw initialization
* (for example clock and power subsystems), and called on a very early boot
* stage from startup code, this function is called from C code, hence variables
* and other drivers data are protected from being cleared up by the C library
* init.
- * Implemented as a "weak" function (platform/ext/common/tfm_platform.c),
- * it can be overwritten by a platform specific implementation.
+ * In addition to performing initialization common to all platforms, it also
+ * calls tfm_spm_hal_post_init_platform() function which implements
+ * initialization of platform-specific peripherals and other hw.
*
* \return Returns values as specified by the \ref tfm_plat_err_t
*/
-enum tfm_plat_err_t tfm_spm_hal_post_platform_init(void);
+enum tfm_plat_err_t tfm_spm_hal_post_init(void);
+
+/**
+ * \brief This function initializes platform-specific peripherals and hardware.
+ *
+ * Called from tfm_spm_hal_post_init(), this function is intended for
+ * platform-specific portion of hardware initialization.
+ *
+ * \return Returns values as specified by the \ref tfm_plat_err_t
+ */
+enum tfm_plat_err_t tfm_spm_hal_post_init_platform(void);
/**
* \brief This function initialises the HW used for isolation, and sets the
diff --git a/secure_fw/core/tfm_core.c b/secure_fw/core/tfm_core.c
index beab5d5bc3..8073c0f8c9 100644
--- a/secure_fw/core/tfm_core.c
+++ b/secure_fw/core/tfm_core.c
@@ -87,7 +87,7 @@ int32_t tfm_core_init(void)
}
/* Performs platform specific initialization */
- plat_err = tfm_spm_hal_post_platform_init();
+ plat_err = tfm_spm_hal_post_init();
if (plat_err != TFM_PLAT_ERR_SUCCESS) {
return TFM_ERROR_GENERIC;
}