1 /*
2  * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 /*!
8  @addtogroup cc_pal_mutex
9  @{
10  */
11 
12 /*!
13  @file
14  @brief This file contains functions for resource management (mutex operations).
15 
16  These functions are generally implemented as wrappers to different
17  operating-system calls.
18 
19  \note None of the described functions validate the input parameters, so that
20  the behavior of the APIs in case of an illegal parameter is dependent on the
21  behavior of the operating system.
22  */
23 
24 #ifndef _CC_PAL_MUTEX_H
25 #define _CC_PAL_MUTEX_H
26 
27 #include "cc_pal_mutex_plat.h"
28 #include "cc_pal_types_plat.h"
29 
30 #ifdef __cplusplus
31 extern "C"
32 {
33 #endif
34 
35 
36 
37 /*----------------------------
38       PUBLIC FUNCTIONS
39 -----------------------------------*/
40 
41 /*!
42   @brief This function creates a mutex.
43 
44 
45   @return \c 0 on success.
46   @return A non-zero value on failure.
47  */
48 CCError_t CC_PalMutexCreate(
49         /*! [out] A pointer to the handle of the created mutex. */
50         CC_PalMutex *pMutexId
51         );
52 
53 
54 /*!
55   @brief This function destroys a mutex.
56 
57 
58   @return \c 0 on success.
59   @return A non-zero value on failure.
60  */
61 CCError_t CC_PalMutexDestroy(
62         /*! [in] A pointer to handle of the mutex to destroy. */
63         CC_PalMutex *pMutexId
64         );
65 
66 
67 /*!
68   @brief This function waits for a mutex with \p aTimeOut.
69 
70   \p aTimeOut is specified in milliseconds. A value of \p aTimeOut=CC_INFINITE
71   means that the function will not return.
72 
73   @return \c 0 on success.
74   @return A non-zero value on failure.
75  */
76 CCError_t CC_PalMutexLock(
77         /*! [in] A pointer to handle of the mutex. */
78         CC_PalMutex *pMutexId,
79         /*! [in] The timeout in mSec, or CC_INFINITE. */
80         uint32_t aTimeOut
81         );
82 
83 
84 /*!
85   @brief This function releases the mutex.
86 
87   @return \c 0 on success.
88   @return A non-zero value on failure.
89  */
90 CCError_t CC_PalMutexUnlock(
91         /*! [in] A pointer to the handle of the mutex. */
92         CC_PalMutex *pMutexId
93         );
94 
95 
96 #ifdef __cplusplus
97 }
98 #endif
99 
100 /*!
101  @}
102  */
103 #endif
104 
105