Core: Initialize IPC SPM in handler mode

- IPC SPM needs to update non-secure entry thread context in PSP
  while this thread shared the same stack with initial thread mode,
  so SPM can not run with PSP.
- While running with MSP, there needs to be a way to reset the MSP
  value to initial value after SPM initialization is done. Exception
  return can be an ideal way, so put SPM initialization in handler
  mode and finally return to thread mode from handler mode.
- Set non-secure entry thread as the first 'current' thread, and
  reset the current PSP/PSPLIMIT to initial value in case there
  are used content makes PSP shifted to an unexpected value.

Change-Id: Ic17b3288478c014a0f21eb602b45b9c5e515960e
Signed-off-by: Ken Liu <ken.liu@arm.com>
diff --git a/secure_fw/spm/spm_api.h b/secure_fw/spm/spm_api.h
index e61b411..7c4a9a6 100644
--- a/secure_fw/spm/spm_api.h
+++ b/secure_fw/spm/spm_api.h
@@ -665,9 +665,6 @@
                          enum tfm_memory_access_e access,
                          uint32_t privileged);
 
-/* This function should be called before schedule function */
-void tfm_spm_init(void);
-
 /*
  * PendSV specified function.
  *
@@ -680,6 +677,13 @@
  */
 void tfm_pendsv_do_schedule(struct tfm_state_context_ext *ctxb);
 
+/**
+ * \brief                      SPM initialization implementation
+ *
+ * \details                    This function must be called under handler mode.
+ */
+void tfm_spm_init(void);
+
 #endif /* ifdef(TFM_PSA_API) */
 
 #endif /*__SPM_API_H__ */