Interface: Refine OS wrapper APIs
For the following OS wrapper APIs
os_wrapper_thread_new
os_wrapper_thread_get_id
os_wrapper_thread_get_priority
os_wrapper_semaphore_create
os_wrapper_mutex_create
They return the corresponding IDs or priorities on success and
OS_WRAPPER_ERROR on failure.
This makes the "OS_WRAPPER_ERROR" value invalid for thread IDs,
mutex IDs...etc on all OSes.
But it could be a valid value on some OSes.
This patch fixes this problem by
1. Changing mutex, semaphore and thread IDs to handles
2. For os_wrapper_thread_get_priority, putting outputs to
parameters and returning only success or error.
For the others, treating NULL return as error and others for
valid handles.
Change-Id: I19aa0415ce0ba4388fb96602fea8f10f702d8c45
Signed-off-by: Kevin Peng <kevin.peng@arm.com>
diff --git a/interface/include/os_wrapper/mutex.h b/interface/include/os_wrapper/mutex.h
index 2bdca0c..e55ef70 100644
--- a/interface/include/os_wrapper/mutex.h
+++ b/interface/include/os_wrapper/mutex.h
@@ -17,16 +17,15 @@
/**
* \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
+ * \return The handle of the created mutex on success or NULL on error
*/
-uint32_t os_wrapper_mutex_create(void);
+void *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] handle The handle of the mutex to acquire. Should be one of the
+ * handles 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.
@@ -35,25 +34,26 @@
*
* \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);
+uint32_t os_wrapper_mutex_acquire(void *handle, uint32_t timeout);
/**
* \brief Releases the mutex acquired previously
*
- * \param[in] mutex_id The ID of the mutex that has been acquired
+
+ * \param[in] handle The handle 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);
+uint32_t os_wrapper_mutex_release(void *handle);
/**
* \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
+ * \param[in] handle The handle 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);
+uint32_t os_wrapper_mutex_delete(void *handle);
#ifdef __cplusplus
}