blob: 89b00a0896c02d5a349c569a5f2ce5243668b986 [file] [log] [blame]
Kevin Peng477fa942019-07-29 10:55:17 +08001/*
2 * Copyright (c) 2017-2019, 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
12extern "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 semaphore
22 * \param[in] name Name of the semaphore
23 *
Kevin Peng383e8402019-08-05 16:35:44 +080024 * \return Returns handle of the semaphore created, or NULL in case of error
Kevin Peng477fa942019-07-29 10:55:17 +080025 */
Kevin Peng383e8402019-08-05 16:35:44 +080026void *os_wrapper_semaphore_create(uint32_t max_count, uint32_t initial_count,
27 const char *name);
Kevin Peng477fa942019-07-29 10:55:17 +080028
29/**
30 * \brief Acquires the semaphore
31 *
Kevin Peng383e8402019-08-05 16:35:44 +080032 * \param[in] hanlde Semaphore handle
33 * \param[in] timeout Timeout value
Kevin Peng477fa942019-07-29 10:55:17 +080034 *
35 * \return \ref OS_WRAPPER_SUCCESS in case of successful acquision, or
36 * \ref OS_WRAPPER_ERROR in case of error
37 */
Kevin Peng383e8402019-08-05 16:35:44 +080038uint32_t os_wrapper_semaphore_acquire(void *handle, uint32_t timeout);
Kevin Peng477fa942019-07-29 10:55:17 +080039
40/**
41 * \brief Releases the semaphore
42 *
Kevin Peng383e8402019-08-05 16:35:44 +080043 * \param[in] hanlde Semaphore handle
Kevin Peng477fa942019-07-29 10:55:17 +080044 *
45 * \return \ref OS_WRAPPER_SUCCESS in case of successful release, or
46 * \ref OS_WRAPPER_ERROR in case of error
47 */
Kevin Peng383e8402019-08-05 16:35:44 +080048uint32_t os_wrapper_semaphore_release(void *handle);
Kevin Peng477fa942019-07-29 10:55:17 +080049
50/**
51 * \brief Deletes the semaphore
52 *
Kevin Peng383e8402019-08-05 16:35:44 +080053 * \param[in] handle Semaphore handle
Kevin Peng477fa942019-07-29 10:55:17 +080054 *
55 * \return \ref OS_WRAPPER_SUCCESS in case of successful release, or
56 * \ref OS_WRAPPER_ERROR in case of error
57 */
Kevin Peng383e8402019-08-05 16:35:44 +080058uint32_t os_wrapper_semaphore_delete(void *handle);
Kevin Peng477fa942019-07-29 10:55:17 +080059
60#ifdef __cplusplus
61}
62#endif
63
64#endif /* __OS_WRAPPER_SEMAPHORE_H__ */