Platform: Add SPE platform-specific hw initialization
Adding tfm_spm_hal_post_init() and tfm_spm_hal_post_init_platform()
functions.
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.
These functions can be used for initializing platform-specific hw
resources (e.g. IPC, UART) thus freeing up application main() function
from the platform details.
tfm_spm_hal_post_init() function is intended for initialization common
to all platforms, while tfm_spm_hal_post_init_platform() implements
platform-specific initialization.
Signed-off-by: Andrei Narkevitch <ainh@cypress.com>
Change-Id: I7e5c9941c86a1be7fe718d1ebee7427526e8dd83
diff --git a/platform/ext/common/tfm_platform.c b/platform/ext/common/tfm_platform.c
new file mode 100644
index 0000000..2eeddf5
--- /dev/null
+++ b/platform/ext/common/tfm_platform.c
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include "target_cfg.h"
+#include "platform/include/tfm_spm_hal.h"
+
+/* platform-specific hw initialization */
+__WEAK enum tfm_plat_err_t tfm_spm_hal_post_init_platform(void)
+{
+ return TFM_PLAT_ERR_SUCCESS;
+}
+
+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;
+}