SPM: PSA API working under Thread mode when level 1

This patch redirects PSA API into a customized 'thread call' ABI to
make it execute in thread mode, when:

- Runtime backend IPC and Isolation Level 1.

This 'thread call' ABI happens in 'Thread mode', and:

- Switch to SPM stack after PSA APIs are called. The working stack
  re-uses the NS Agent stack to save runtime memory or allocated a
  dedicated stack for it if no Trustzone NS Agent is available. No
  need to make SPM working under 'Handler mode' in this case.

- Lock scheduler to ensure PSA API context is not nested because of
  scheduling. The locking is performed by setting a flag, and the
  scheduler entry checks this flag to decide schedule or not.

- When PSA API returns, switch back to the caller stack. And trigger
  scheduler in the caller stack if a scheduling is expected. This
  helps the scheduler context management.

- SPM functionalities other than PSA API are still using SVC-based
  implementation, such as SPM initialization and log info flushing.

The content of this patch:

- Define interfaces, ABI dispatcher and architecture modifications
  to support handling PSA API under thread mode.

- Related header file and source path adjustment to help the build pass.

- Adjust IDLE partition stack size to make runtime execution work, the
  original size is too compact to run under debug build of specific
  platforms.

Change-Id: I52add3f57ef0f958d25725efb4eb702617586907
Signed-off-by: Ken Liu <Ken.Liu@arm.com>
Co-authored-by: Mingyang Sun <Mingyang.Sun@arm.com>
diff --git a/secure_fw/spm/include/tfm_arch.h b/secure_fw/spm/include/tfm_arch.h
index f7740c2..40d1199 100644
--- a/secure_fw/spm/include/tfm_arch.h
+++ b/secure_fw/spm/include/tfm_arch.h
@@ -69,12 +69,6 @@
     struct tfm_state_context_t state_ctx; /* ctx on SVC_PREPARE_DEPRIV_FLIH */
 };
 
-__attribute__ ((always_inline))
-__STATIC_INLINE void tfm_arch_trigger_pendsv(void)
-{
-    SCB->ICSR = SCB_ICSR_PENDSVSET_Msk;
-}
-
 /**
  * \brief Get Link Register
  * \details Returns the value of the Link Register (LR)
@@ -147,4 +141,18 @@
  */
 uint32_t tfm_arch_refresh_hardware_context(void *p_ctx_ctrl);
 
+/*
+ * Triggers scheduler. A return type is assigned in case
+ * SPM returns values by the context.
+ */
+uint32_t tfm_arch_trigger_pendsv(void);
+
+
+/*
+ * Switch to a new stack area, lock scheduler and call function.
+ * If 'stk_base' is ZERO, stack won't be switched and re-use caller stack.
+ */
+uint32_t arch_non_preempt_call(uintptr_t fn_addr, uintptr_t frame_addr,
+                               uint32_t stk_base, uint32_t stk_limit);
+
 #endif