blob: 2bdca0cd82d0ef25e63e3a94a69d4fe34eeb2d41 [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_MUTEX_H__
9#define __OS_WRAPPER_MUTEX_H__
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15#include "common.h"
16
17/**
18 * \brief Creates a mutex for mutual exclusion of resources
19 *
20 * \return The ID of the created mutex on success or \ref OS_WRAPPER_ERROR on
21 * error
22 */
23uint32_t os_wrapper_mutex_create(void);
24
25/**
26 * \brief Acquires a mutex that is created by \ref os_wrapper_mutex_create()
27 *
28 * \param[in] mutex_id The ID of the mutex to acquire. Should be one of the IDs
29 * returned by \ref os_wrapper_mutex_create()
30 * \param[in] timeout The maximum amount of time(in tick periods) for the
31 * thread to wait for the mutex to be available.
32 * If timeout is zero, the function will return immediately.
33 * Setting timeout to \ref OS_WRAPPER_WAIT_FOREVER will
34 * cause the thread to wait indefinitely
35 *
36 * \return \ref OS_WRAPPER_SUCCESS on success or \ref OS_WRAPPER_ERROR on error
37 */
38uint32_t os_wrapper_mutex_acquire(uint32_t mutex_id, uint32_t timeout);
39
40/**
41 * \brief Releases the mutex acquired previously
42 *
43 * \param[in] mutex_id The ID of the mutex that has been acquired
44 *
45 * \return \ref OS_WRAPPER_SUCCESS on success or \ref OS_WRAPPER_ERROR on error
46 */
47uint32_t os_wrapper_mutex_release(uint32_t mutex_id);
48
49/**
50 * \brief Deletes a mutex that is created by \ref os_wrapper_mutex_create()
51 *
52 * \param[in] mutex_id The ID of the mutex to be deleted
53 *
54 * \return \ref OS_WRAPPER_SUCCESS on success or \ref OS_WRAPPER_ERROR on error
55 */
56uint32_t os_wrapper_mutex_delete(uint32_t mutex_id);
57
58#ifdef __cplusplus
59}
60#endif
61
62#endif /* __OS_WRAPPER_MUTEX_H__ */