SPM: Common partition runtime entry point
Involve the common partition runtime entry point to perform generic
runtime initialization jobs such as heap initialization before the
practical partition entry point get called. This entry point is part
of SPRTL which is shared for all partitions.
This patch involves the 'sprt_main' as the first step. And, if one
partition is light enough (no heap, no other extra settings), it is
optional to apply the common partition runtime entry as partition
first entry, and the real partition entry is put under 'sub_entry'.
This patch also fixes region address alignments in link scripts.
Change-Id: I9169f6377d476a3e1dad025c75a790aba6b6ad10
Signed-off-by: Summer Qin <summer.qin@arm.com>
Co-authored-by: Kevin Peng <kevin.peng@arm.com>
diff --git a/secure_fw/spm/ffm/backend_ipc.c b/secure_fw/spm/ffm/backend_ipc.c
index f43cfbc..22a7794 100644
--- a/secure_fw/spm/ffm/backend_ipc.c
+++ b/secure_fw/spm/ffm/backend_ipc.c
@@ -9,6 +9,7 @@
#include <stdint.h>
#include "critical_section.h"
#include "compiler_ext_defs.h"
+#include "runtime_defs.h"
#include "spm_ipc.h"
#include "tfm_hal_isolation.h"
#include "tfm_hal_platform.h"
@@ -41,6 +42,20 @@
#endif
+static void prv_process_metadata(struct partition_t *p_pt)
+{
+ struct runtime_metadata_t *p_rtmd = NULL;
+
+ if (p_pt->p_ldinf->entry) {
+ ARCH_CTXCTRL_ALLOCATE_STACK(&p_pt->ctx_ctrl, sizeof(*p_rtmd));
+ p_rtmd = (struct runtime_metadata_t *)ARCH_CTXCTRL_ALLOCATED_PTR(
+ &p_pt->ctx_ctrl);
+ p_rtmd->entry = p_pt->p_ldinf->entry;
+ }
+
+ p_pt->p_metadata = p_rtmd;
+}
+
/*
* Send message and wake up the SP who is waiting on message queue, block the
* current thread and trigger scheduler.
@@ -101,6 +116,8 @@
return PSA_SUCCESS;
}
+extern void sprt_main(void);
+
/* Parameters are treated as assuredly */
static void ipc_comp_init_assuredly(struct partition_t *p_pt,
uint32_t service_setting)
@@ -120,6 +137,8 @@
LOAD_ALLOCED_STACK_ADDR(p_pldi),
p_pldi->stack_size);
+ prv_process_metadata(p_pt);
+
THRD_INIT(&p_pt->thrd, &p_pt->ctx_ctrl,
TO_THREAD_PRIORITY(PARTITION_PRIORITY(p_pldi->flags)));
@@ -130,7 +149,7 @@
#endif
thrd_start(&p_pt->thrd,
- POSITION_TO_ENTRY(p_pldi->entry, thrd_fn_t),
+ POSITION_TO_ENTRY(sprt_main, thrd_fn_t),
THRD_GENERAL_EXIT);
}