Dualcpu: Move NS mailbox thread management to RTOS specific file

The NS mailbox thread management is NS RTOS specific.

- Add a new tfm_ns_mailbox_rtos_api.c to collect all the NS mailbox
  APIs which rely on RTOS specific implementations.
- Move those API implementations from platform to
  tfm_ns_mailbox_rtos_api.c.
- Rename those APIs to replace HAL keyword with OS keyword, to
  indicate that their implementations are RTOS specific.

Change-Id: Ic2885bc1676964719d1524b39d6518444610e1aa
Signed-off-by: David Hu <david.hu@arm.com>
diff --git a/interface/include/tfm_multi_core_api.h b/interface/include/tfm_multi_core_api.h
index 908b137..752cf96 100644
--- a/interface/include/tfm_multi_core_api.h
+++ b/interface/include/tfm_multi_core_api.h
@@ -14,8 +14,6 @@
 
 #include <stdint.h>
 
-#include "os_wrapper/common.h"
-
 /**
  * \brief Called on the non-secure CPU.
  *        Flags that the non-secure side has completed its initialization.
@@ -38,36 +36,6 @@
  */
 int32_t tfm_platform_ns_wait_for_s_cpu_ready(void);
 
-#ifdef FORWARD_PROT_MSG
-static inline uint32_t tfm_ns_multi_core_lock_acquire(void)
-{
-    return OS_WRAPPER_SUCCESS;
-}
-
-static inline uint32_t tfm_ns_multi_core_lock_release(void)
-{
-    return OS_WRAPPER_SUCCESS;
-}
-#else /* FORWARD_PROT_MSG */
-/**
- * \brief Acquire the multi-core lock for synchronizing PSA client call(s)
- *        The actual implementation depends on the use scenario.
- *
- * \return \ref OS_WRAPPER_SUCCESS on success
- * \return \ref OS_WRAPPER_ERROR on error
- */
-uint32_t tfm_ns_multi_core_lock_acquire(void);
-
-/**
- * \brief Release the multi-core lock for synchronizing PSA client call(s)
- *        The actual implementation depends on the use scenario.
- *
- * \return \ref OS_WRAPPER_SUCCESS on success
- * \return \ref OS_WRAPPER_ERROR on error
- */
-uint32_t tfm_ns_multi_core_lock_release(void);
-#endif /* FORWARD_PROT_MSG */
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/interface/include/tfm_ns_mailbox.h b/interface/include/tfm_ns_mailbox.h
index bdca18c..a2902d6 100644
--- a/interface/include/tfm_ns_mailbox.h
+++ b/interface/include/tfm_ns_mailbox.h
@@ -64,26 +64,6 @@
                                    int32_t client_id,
                                    int32_t *reply);
 
-#ifdef TFM_MULTI_CORE_MULTI_CLIENT_CALL
-/**
- * \brief Get the handle of the current non-secure task executing mailbox
- *        functionalities
- *
- * \note This function should be implemented according to platform, NS OS
- *       and actual use scenario.
- *       This function can be ignored or return NULL if sleep/wake-up mechanism
- *       is not required in PSA Client API implementation.
- *
- * \return Return the handle of task.
- */
-const void *tfm_ns_mailbox_get_task_handle(void);
-#else
-static inline const void *tfm_ns_mailbox_get_task_handle(void)
-{
-    return NULL;
-}
-#endif
-
 /**
  * \brief Wake up the owner task of the first replied mailbox message in the
  *        NSPE mailbox queue.
@@ -152,38 +132,102 @@
  */
 void tfm_ns_mailbox_hal_exit_critical_isr(void);
 
+#ifdef FORWARD_PROT_MSG
+static inline int32_t tfm_ns_mailbox_os_lock_init(void)
+{
+    return MAILBOX_SUCCESS;
+}
+
+static inline uint32_t tfm_ns_mailbox_os_lock_acquire(void)
+{
+    return MAILBOX_SUCCESS;
+}
+
+static inline uint32_t tfm_ns_mailbox_os_lock_release(void)
+{
+    return MAILBOX_SUCCESS;
+}
+#else /* FORWARD_PROT_MSG */
+/**
+ * \brief Initialize the multi-core lock for synchronizing PSA client call(s)
+ *        The actual implementation depends on the non-secure use scenario.
+ *
+ * \return \ref MAILBOX_SUCCESS on success
+ * \return \ref MAILBOX_GENERIC_ERROR on error
+ */
+int32_t tfm_ns_mailbox_os_lock_init(void);
+
+/**
+ * \brief Acquire the multi-core lock for synchronizing PSA client call(s)
+ *        The actual implementation depends on the non-secure use scenario.
+ *
+ * \return \ref MAILBOX_SUCCESS on success
+ * \return \ref MAILBOX_GENERIC_ERROR on error
+ */
+int32_t tfm_ns_mailbox_os_lock_acquire(void);
+
+/**
+ * \brief Release the multi-core lock for synchronizing PSA client call(s)
+ *        The actual implementation depends on the non-secure use scenario.
+ *
+ * \return \ref MAILBOX_SUCCESS on success
+ * \return \ref MAILBOX_GENERIC_ERROR on error
+ */
+int32_t tfm_ns_mailbox_os_lock_release(void);
+#endif /* FORWARD_PROT_MSG */
+
 #ifdef TFM_MULTI_CORE_MULTI_CLIENT_CALL
 /**
- * \brief Performs platform and NS OS specific waiting mechanism to wait for
+ * \brief Get the handle of the current non-secure task executing mailbox
+ *        functionalities
+ *
+ * \note This function should be implemented according to NS OS and
+ *       actual use scenario.
+ *       This function can be ignored or return NULL if sleep/wake-up mechanism
+ *       is not required in PSA Client API implementation.
+ *
+ * \return Return the handle of task.
+ */
+const void *tfm_ns_mailbox_os_get_task_handle(void);
+
+/**
+ * \brief Performs use scenario and NS OS specific waiting mechanism to wait for
  *        the reply of the specified mailbox message to be returned from SPE.
  *
- * \note This function is implemented by platform and NS OS specific waiting
- *       mechanism according to use scenario.
+ * \note This function is implemented by NS OS specific waiting mechanism
+ *       according to use scenario.
  *
  * \param[in] handle            The handle of mailbox message.
  */
-void tfm_ns_mailbox_hal_wait_reply(mailbox_msg_handle_t handle);
+void tfm_ns_mailbox_os_wait_reply(mailbox_msg_handle_t handle);
 
 /*
- * \brief Performs platform and NS OS specific mechanism in a mailbox IRQ
+ * \brief Performs use scenario and NS OS specific mechanism in a mailbox IRQ
  *        handler, to wake up a sleeping task which is waiting for its mailbox
  *        message reply.
  *
- * \note The underlying platform and NS OS specific function called inside this
- *       function should be able to work in an IRQ handler.
+ * \note The underlying NS OS specific function called inside this function
+ *       should be able to work in an IRQ handler.
  *
- * \note This function is implemented by platform and NS OS specific waiting
+ * \note This function is implemented by NS OS specific waiting
  *       mechanism according to use scenario.
  *
  * \param[in] task_handle       The handle to the task to be woken up.
  * \param[in] handle            The mailbox handle which can be used as thread
  *                              flag.
  */
-void tfm_ns_mailbox_hal_wake_task_isr(const void *task_handle,
-                                      mailbox_msg_handle_t handle);
-#else
-#define tfm_ns_mailbox_hal_wait_reply(handle)        do {} while (0)
-#endif
+void tfm_ns_mailbox_os_wake_task_isr(const void *task_handle,
+                                     mailbox_msg_handle_t handle);
+#else /* TFM_MULTI_CORE_MULTI_CLIENT_CALL */
+#define tfm_ns_mailbox_os_wait_reply(handle)        do {} while (0)
+
+static inline const void *tfm_ns_mailbox_os_get_task_handle(void)
+{
+    return NULL;
+}
+
+#define tfm_ns_mailbox_os_wake_task_isr(task, handle)    do {} while (0)
+#endif /* TFM_MULTI_CORE_MULTI_CLIENT_CALL */
 
 #ifdef TFM_MULTI_CORE_TEST
 /**