1 /* 2 * Copyright (c) 2017-2020, Arm Limited. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 * 6 */ 7 8 #ifndef __OS_WRAPPER_SEMAPHORE_H__ 9 #define __OS_WRAPPER_SEMAPHORE_H__ 10 11 #ifdef __cplusplus 12 extern "C" { 13 #endif 14 15 #include "common.h" 16 17 /** 18 * \brief Creates a new semaphore 19 * 20 * \param[in] max_count Highest count of the semaphore 21 * \param[in] initial_count Starting count of the available semaphore 22 * \param[in] name Name of the semaphore 23 * 24 * \return Returns handle of the semaphore created, or NULL in case of error 25 */ 26 void *os_wrapper_semaphore_create(uint32_t max_count, uint32_t initial_count, 27 const char *name); 28 29 /** 30 * \brief Acquires the semaphore 31 * 32 * \param[in] hanlde Semaphore handle 33 * \param[in] timeout Timeout value 34 * 35 * \return \ref OS_WRAPPER_SUCCESS in case of successful acquision, or 36 * \ref OS_WRAPPER_ERROR in case of error 37 */ 38 uint32_t os_wrapper_semaphore_acquire(void *handle, uint32_t timeout); 39 40 /** 41 * \brief Releases the semaphore 42 * 43 * \param[in] hanlde Semaphore handle 44 * 45 * \return \ref OS_WRAPPER_SUCCESS in case of successful release, or 46 * \ref OS_WRAPPER_ERROR in case of error 47 */ 48 uint32_t os_wrapper_semaphore_release(void *handle); 49 50 /** 51 * \brief Deletes the semaphore 52 * 53 * \param[in] handle Semaphore handle 54 * 55 * \return \ref OS_WRAPPER_SUCCESS in case of successful release, or 56 * \ref OS_WRAPPER_ERROR in case of error 57 */ 58 uint32_t os_wrapper_semaphore_delete(void *handle); 59 60 #ifdef __cplusplus 61 } 62 #endif 63 64 #endif /* __OS_WRAPPER_SEMAPHORE_H__ */ 65