Interface: Split os_wrapper to multiple headers

To enable the ability to optionally install the os_wrapper headers for
different build configurations and make the os_wrapper more clear in
the file structure.
This patch splits the os_wrapper.h to multiple files by modules.

Change-Id: I48ad677f745fdee20a5a9b5e366e862d7b7dc58e
Signed-off-by: Kevin Peng <kevin.peng@arm.com>
diff --git a/app/os_wrapper_cmsis_rtos_v2.c b/app/os_wrapper_cmsis_rtos_v2.c
index 2a7c7e4..0fe3799 100644
--- a/app/os_wrapper_cmsis_rtos_v2.c
+++ b/app/os_wrapper_cmsis_rtos_v2.c
@@ -5,7 +5,9 @@
  *
  */
 
-#include "os_wrapper.h"
+#include "os_wrapper/thread.h"
+#include "os_wrapper/mutex.h"
+#include "os_wrapper/semaphore.h"
 
 #include <string.h>
 #include "cmsis_os2.h"
diff --git a/interface/include/os_wrapper.h b/interface/include/os_wrapper.h
deleted file mode 100644
index 90d2cd5..0000000
--- a/interface/include/os_wrapper.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-#ifndef __OS_WRAPPER_H__
-#define __OS_WRAPPER_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdint.h>
-
-#define OS_WRAPPER_SUCCESS            (0x0)
-#define OS_WRAPPER_ERROR              (0xFFFFFFFFU)
-#define OS_WRAPPER_WAIT_FOREVER       (0xFFFFFFFFU)
-#define OS_WRAPPER_DEFAULT_STACK_SIZE (-1)
-
-/* prototype for the thread entry function */
-typedef void (*os_wrapper_thread_func) (void *argument);
-
-/**
- * \brief Creates a new semaphore
- *
- * \param[in] max_count       Highest count of the semaphore
- * \param[in] initial_count   Starting count of the semaphore
- * \param[in] name            Name of the semaphore
- *
- * \return Returns ID of the semaphore created, or \ref OS_WRAPPER_ERROR in case
- *         of error
- */
-uint32_t os_wrapper_semaphore_create(uint32_t max_count, uint32_t initial_count,
-                                     const char *name);
-
-/**
- * \brief Acquires the semaphore
- *
- * \param[in] semaphore_id Semaphore ID
- * \param[in] timeout      Timeout value
- *
- * \return \ref OS_WRAPPER_SUCCESS in case of successful acquision, or
- *         \ref OS_WRAPPER_ERROR in case of error
- */
-uint32_t os_wrapper_semaphore_acquire(uint32_t semaphore_id, uint32_t timeout);
-
-/**
- * \brief Releases the semaphore
- *
- * \param[in] semaphore_id Semaphore ID
- *
- * \return \ref OS_WRAPPER_SUCCESS in case of successful release, or
- *         \ref OS_WRAPPER_ERROR in case of error
- */
-uint32_t os_wrapper_semaphore_release(uint32_t semaphore_id);
-
-/**
- * \brief Deletes the semaphore
- *
- * \param[in] semaphore_id Semaphore ID
- *
- * \return \ref OS_WRAPPER_SUCCESS in case of successful release, or
- *         \ref OS_WRAPPER_ERROR in case of error
- */
-uint32_t os_wrapper_semaphore_delete(uint32_t semaphore_id);
-
-/**
- * \brief Creates a mutex for mutual exclusion of resources
- *
- * \return The ID of the created mutex on success or \ref OS_WRAPPER_ERROR on
- *         error
- */
-uint32_t os_wrapper_mutex_create(void);
-
-/**
- * \brief Acquires a mutex that is created by \ref os_wrapper_mutex_create()
- *
- * \param[in] mutex_id The ID of the mutex to acquire. Should be one of the IDs
- *                     returned by \ref os_wrapper_mutex_create()
- * \param[in] timeout  The maximum amount of time(in tick periods) for the
- *                     thread to wait for the mutex to be available.
- *                     If timeout is zero, the function will return immediately.
- *                     Setting timeout to \ref OS_WRAPPER_WAIT_FOREVER will
- *                     cause the thread to wait indefinitely
- *
- * \return \ref OS_WRAPPER_SUCCESS on success or \ref OS_WRAPPER_ERROR on error
- */
-uint32_t os_wrapper_mutex_acquire(uint32_t mutex_id, uint32_t timeout);
-
-/**
- * \brief Releases the mutex acquired previously
- *
- * \param[in] mutex_id The ID of the mutex that has been acquired
- *
- * \return \ref OS_WRAPPER_SUCCESS on success or \ref OS_WRAPPER_ERROR on error
- */
-uint32_t os_wrapper_mutex_release(uint32_t mutex_id);
-
-/**
- * \brief Deletes a mutex that is created by \ref os_wrapper_mutex_create()
- *
- * \param[in] mutex_id The ID of the mutex to be deleted
- *
- * \return \ref OS_WRAPPER_SUCCESS on success or \ref OS_WRAPPER_ERROR on error
- */
-uint32_t os_wrapper_mutex_delete(uint32_t mutex_id);
-
-/**
- * \brief Creates a new thread
- *
- * \param[in] name        Name of the thread
- * \param[in] stack_size  Size of stack to be allocated for this thread. It can
- *                        be \ref OS_WRAPPER_DEFAULT_STACK_SIZE to use the
- *                        default value provided by the underlying RTOS
- * \param[in] func        Pointer to the function invoked by thread
- * \param[in] arg         Argument to pass to the function invoked by thread
- * \param[in] priority    Initial thread priority
- *
- * \return Returns thread ID, or \ref OS_WRAPPER_ERROR in case of error
- */
-uint32_t os_wrapper_thread_new(const char *name, int32_t stack_size,
-                               os_wrapper_thread_func func, void *arg,
-                               uint32_t priority);
-/**
- * \brief Gets current thread ID
- *
- * \return Returns thread ID, or \ref OS_WRAPPER_ERROR in case of error
- */
-uint32_t os_wrapper_thread_get_id(void);
-
-/**
- * \brief Gets thread priority
- *
- * \param[in] id Thread ID
- *
- * \return Returns thread priority value, or \ref OS_WRAPPER_ERROR in case of
- *         error
- */
-uint32_t os_wrapper_thread_get_priority(uint32_t id);
-
-/**
- * \brief Exits the calling thread
- */
-void os_wrapper_thread_exit(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __OS_WRAPPER_H__ */
diff --git a/interface/include/os_wrapper/common.h b/interface/include/os_wrapper/common.h
new file mode 100644
index 0000000..6494723
--- /dev/null
+++ b/interface/include/os_wrapper/common.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#ifndef __OS_WRAPPER_COMMON_H__
+#define __OS_WRAPPER_COMMON_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+
+#define OS_WRAPPER_SUCCESS            (0x0)
+#define OS_WRAPPER_ERROR              (0xFFFFFFFFU)
+#define OS_WRAPPER_WAIT_FOREVER       (0xFFFFFFFFU)
+#define OS_WRAPPER_DEFAULT_STACK_SIZE (-1)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OS_WRAPPER_COMMON_H__ */
diff --git a/interface/include/os_wrapper/mutex.h b/interface/include/os_wrapper/mutex.h
new file mode 100644
index 0000000..2bdca0c
--- /dev/null
+++ b/interface/include/os_wrapper/mutex.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#ifndef __OS_WRAPPER_MUTEX_H__
+#define __OS_WRAPPER_MUTEX_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "common.h"
+
+/**
+ * \brief Creates a mutex for mutual exclusion of resources
+ *
+ * \return The ID of the created mutex on success or \ref OS_WRAPPER_ERROR on
+ *         error
+ */
+uint32_t os_wrapper_mutex_create(void);
+
+/**
+ * \brief Acquires a mutex that is created by \ref os_wrapper_mutex_create()
+ *
+ * \param[in] mutex_id The ID of the mutex to acquire. Should be one of the IDs
+ *                     returned by \ref os_wrapper_mutex_create()
+ * \param[in] timeout  The maximum amount of time(in tick periods) for the
+ *                     thread to wait for the mutex to be available.
+ *                     If timeout is zero, the function will return immediately.
+ *                     Setting timeout to \ref OS_WRAPPER_WAIT_FOREVER will
+ *                     cause the thread to wait indefinitely
+ *
+ * \return \ref OS_WRAPPER_SUCCESS on success or \ref OS_WRAPPER_ERROR on error
+ */
+uint32_t os_wrapper_mutex_acquire(uint32_t mutex_id, uint32_t timeout);
+
+/**
+ * \brief Releases the mutex acquired previously
+ *
+ * \param[in] mutex_id The ID of the mutex that has been acquired
+ *
+ * \return \ref OS_WRAPPER_SUCCESS on success or \ref OS_WRAPPER_ERROR on error
+ */
+uint32_t os_wrapper_mutex_release(uint32_t mutex_id);
+
+/**
+ * \brief Deletes a mutex that is created by \ref os_wrapper_mutex_create()
+ *
+ * \param[in] mutex_id The ID of the mutex to be deleted
+ *
+ * \return \ref OS_WRAPPER_SUCCESS on success or \ref OS_WRAPPER_ERROR on error
+ */
+uint32_t os_wrapper_mutex_delete(uint32_t mutex_id);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OS_WRAPPER_MUTEX_H__ */
diff --git a/interface/include/os_wrapper/semaphore.h b/interface/include/os_wrapper/semaphore.h
new file mode 100644
index 0000000..38b9a16
--- /dev/null
+++ b/interface/include/os_wrapper/semaphore.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#ifndef __OS_WRAPPER_SEMAPHORE_H__
+#define __OS_WRAPPER_SEMAPHORE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "common.h"
+
+/**
+ * \brief Creates a new semaphore
+ *
+ * \param[in] max_count       Highest count of the semaphore
+ * \param[in] initial_count   Starting count of the semaphore
+ * \param[in] name            Name of the semaphore
+ *
+ * \return Returns ID of the semaphore created, or \ref OS_WRAPPER_ERROR in case
+ *         of error
+ */
+uint32_t os_wrapper_semaphore_create(uint32_t max_count, uint32_t initial_count,
+                                     const char *name);
+
+/**
+ * \brief Acquires the semaphore
+ *
+ * \param[in] semaphore_id Semaphore ID
+ * \param[in] timeout      Timeout value
+ *
+ * \return \ref OS_WRAPPER_SUCCESS in case of successful acquision, or
+ *         \ref OS_WRAPPER_ERROR in case of error
+ */
+uint32_t os_wrapper_semaphore_acquire(uint32_t semaphore_id, uint32_t timeout);
+
+/**
+ * \brief Releases the semaphore
+ *
+ * \param[in] semaphore_id Semaphore ID
+ *
+ * \return \ref OS_WRAPPER_SUCCESS in case of successful release, or
+ *         \ref OS_WRAPPER_ERROR in case of error
+ */
+uint32_t os_wrapper_semaphore_release(uint32_t semaphore_id);
+
+/**
+ * \brief Deletes the semaphore
+ *
+ * \param[in] semaphore_id Semaphore ID
+ *
+ * \return \ref OS_WRAPPER_SUCCESS in case of successful release, or
+ *         \ref OS_WRAPPER_ERROR in case of error
+ */
+uint32_t os_wrapper_semaphore_delete(uint32_t semaphore_id);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OS_WRAPPER_SEMAPHORE_H__ */
diff --git a/interface/include/os_wrapper/thread.h b/interface/include/os_wrapper/thread.h
new file mode 100644
index 0000000..cfd2e13
--- /dev/null
+++ b/interface/include/os_wrapper/thread.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#ifndef __OS_WRAPPER_THREAD_H__
+#define __OS_WRAPPER_THREAD_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "common.h"
+
+/* prototype for the thread entry function */
+typedef void (*os_wrapper_thread_func) (void *argument);
+
+/**
+ * \brief Creates a new thread
+ *
+ * \param[in] name        Name of the thread
+ * \param[in] stack_size  Size of stack to be allocated for this thread. It can
+ *                        be \ref OS_WRAPPER_DEFAULT_STACK_SIZE to use the
+ *                        default value provided by the underlying RTOS
+ * \param[in] func        Pointer to the function invoked by thread
+ * \param[in] arg         Argument to pass to the function invoked by thread
+ * \param[in] priority    Initial thread priority
+ *
+ * \return Returns thread ID, or \ref OS_WRAPPER_ERROR in case of error
+ */
+uint32_t os_wrapper_thread_new(const char *name, int32_t stack_size,
+                               os_wrapper_thread_func func, void *arg,
+                               uint32_t priority);
+/**
+ * \brief Gets current thread ID
+ *
+ * \return Returns thread ID, or \ref OS_WRAPPER_ERROR in case of error
+ */
+uint32_t os_wrapper_thread_get_id(void);
+
+/**
+ * \brief Gets thread priority
+ *
+ * \param[in] id Thread ID
+ *
+ * \return Returns thread priority value, or \ref OS_WRAPPER_ERROR in case of
+ *         error
+ */
+uint32_t os_wrapper_thread_get_priority(uint32_t id);
+
+/**
+ * \brief Exits the calling thread
+ */
+void os_wrapper_thread_exit(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OS_WRAPPER_THREAD_H__ */
diff --git a/interface/src/tfm_ns_interface.c b/interface/src/tfm_ns_interface.c
index 916af19..7ec8c40 100644
--- a/interface/src/tfm_ns_interface.c
+++ b/interface/src/tfm_ns_interface.c
@@ -7,7 +7,7 @@
 #include <stdint.h>
 #include <stdbool.h>
 
-#include "os_wrapper.h"
+#include "os_wrapper/mutex.h"
 
 #include "tfm_api.h"
 #include "tfm_ns_interface.h"
diff --git a/test/suites/sst/non_secure/ns_test_helpers.c b/test/suites/sst/non_secure/ns_test_helpers.c
index 9dc18bc..1947e25 100644
--- a/test/suites/sst/non_secure/ns_test_helpers.c
+++ b/test/suites/sst/non_secure/ns_test_helpers.c
@@ -7,7 +7,8 @@
 
 #include "ns_test_helpers.h"
 
-#include "os_wrapper.h"
+#include "os_wrapper/thread.h"
+#include "os_wrapper/semaphore.h"
 
 #include "tfm_nspm_api.h"