Root/drivers/staging/csr/csr_framework_ext.h

1#ifndef CSR_FRAMEWORK_EXT_H__
2#define CSR_FRAMEWORK_EXT_H__
3/*****************************************************************************
4
5            (c) Cambridge Silicon Radio Limited 2010
6            All rights reserved and confidential information of CSR
7
8            Refer to LICENSE.txt included with this source for details
9            on the license terms.
10
11*****************************************************************************/
12
13#include "csr_result.h"
14#include "csr_framework_ext_types.h"
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20/* Result codes */
21#define CSR_FE_RESULT_NO_MORE_EVENTS ((CsrResult) 0x0001)
22#define CSR_FE_RESULT_INVALID_POINTER ((CsrResult) 0x0002)
23#define CSR_FE_RESULT_INVALID_HANDLE ((CsrResult) 0x0003)
24#define CSR_FE_RESULT_NO_MORE_MUTEXES ((CsrResult) 0x0004)
25#define CSR_FE_RESULT_TIMEOUT ((CsrResult) 0x0005)
26#define CSR_FE_RESULT_NO_MORE_THREADS ((CsrResult) 0x0006)
27
28/* Thread priorities */
29#define CSR_THREAD_PRIORITY_HIGHEST ((u16) 0)
30#define CSR_THREAD_PRIORITY_HIGH ((u16) 1)
31#define CSR_THREAD_PRIORITY_NORMAL ((u16) 2)
32#define CSR_THREAD_PRIORITY_LOW ((u16) 3)
33#define CSR_THREAD_PRIORITY_LOWEST ((u16) 4)
34
35#define CSR_EVENT_WAIT_INFINITE ((u16) 0xFFFF)
36
37/*----------------------------------------------------------------------------*
38 * NAME
39 * CsrEventCreate
40 *
41 * DESCRIPTION
42 * Creates an event and returns a handle to the created event.
43 *
44 * RETURNS
45 * Possible values:
46 * CSR_RESULT_SUCCESS in case of success
47 * CSR_FE_RESULT_NO_MORE_EVENTS in case of out of event resources
48 * CSR_FE_RESULT_INVALID_POINTER in case the eventHandle pointer is invalid
49 *
50 *----------------------------------------------------------------------------*/
51CsrResult CsrEventCreate(CsrEventHandle *eventHandle);
52
53/*----------------------------------------------------------------------------*
54 * NAME
55 * CsrEventWait
56 *
57 * DESCRIPTION
58 * Wait fore one or more of the event bits to be set.
59 *
60 * RETURNS
61 * Possible values:
62 * CSR_RESULT_SUCCESS in case of success
63 * CSR_FE_RESULT_TIMEOUT in case of timeout
64 * CSR_FE_RESULT_INVALID_HANDLE in case the eventHandle is invalid
65 * CSR_FE_RESULT_INVALID_POINTER in case the eventBits pointer is invalid
66 *
67 *----------------------------------------------------------------------------*/
68CsrResult CsrEventWait(CsrEventHandle *eventHandle, u16 timeoutInMs, u32 *eventBits);
69
70/*----------------------------------------------------------------------------*
71 * NAME
72 * CsrEventSet
73 *
74 * DESCRIPTION
75 * Set an event.
76 *
77 * RETURNS
78 * Possible values:
79 * CSR_RESULT_SUCCESS in case of success
80 * CSR_FE_RESULT_INVALID_HANDLE in case the eventHandle is invalid
81 *
82 *----------------------------------------------------------------------------*/
83CsrResult CsrEventSet(CsrEventHandle *eventHandle, u32 eventBits);
84
85/*----------------------------------------------------------------------------*
86 * NAME
87 * CsrEventDestroy
88 *
89 * DESCRIPTION
90 * Destroy the event associated.
91 *
92 * RETURNS
93 * void
94 *
95 *----------------------------------------------------------------------------*/
96void CsrEventDestroy(CsrEventHandle *eventHandle);
97
98/*----------------------------------------------------------------------------*
99 * NAME
100 * CsrMutexCreate
101 *
102 * DESCRIPTION
103 * Create a mutex and return a handle to the created mutex.
104 *
105 * RETURNS
106 * Possible values:
107 * CSR_RESULT_SUCCESS in case of success
108 * CSR_FE_RESULT_NO_MORE_MUTEXES in case of out of mutex resources
109 * CSR_FE_RESULT_INVALID_POINTER in case the mutexHandle pointer is invalid
110 *
111 *----------------------------------------------------------------------------*/
112CsrResult CsrMutexCreate(CsrMutexHandle *mutexHandle);
113
114/*----------------------------------------------------------------------------*
115 * NAME
116 * CsrMutexLock
117 *
118 * DESCRIPTION
119 * Lock the mutex refered to by the provided handle.
120 *
121 * RETURNS
122 * Possible values:
123 * CSR_RESULT_SUCCESS in case of success
124 * CSR_FE_RESULT_INVALID_HANDLE in case the mutexHandle is invalid
125 *
126 *----------------------------------------------------------------------------*/
127CsrResult CsrMutexLock(CsrMutexHandle *mutexHandle);
128
129/*----------------------------------------------------------------------------*
130 * NAME
131 * CsrMutexUnlock
132 *
133 * DESCRIPTION
134 * Unlock the mutex refered to by the provided handle.
135 *
136 * RETURNS
137 * Possible values:
138 * CSR_RESULT_SUCCESS in case of success
139 * CSR_FE_RESULT_INVALID_HANDLE in case the mutexHandle is invalid
140 *
141 *----------------------------------------------------------------------------*/
142CsrResult CsrMutexUnlock(CsrMutexHandle *mutexHandle);
143
144/*----------------------------------------------------------------------------*
145 * NAME
146 * CsrMutexDestroy
147 *
148 * DESCRIPTION
149 * Destroy the previously created mutex.
150 *
151 * RETURNS
152 * void
153 *
154 *----------------------------------------------------------------------------*/
155void CsrMutexDestroy(CsrMutexHandle *mutexHandle);
156
157/*----------------------------------------------------------------------------*
158 * NAME
159 * CsrGlobalMutexLock
160 *
161 * DESCRIPTION
162 * Lock the global mutex. The global mutex is a single pre-initialised
163 * shared mutex, spinlock or similar that does not need to be created prior
164 * to use. The limitation is that there is only one single lock shared
165 * between all code. Consequently, it must only be used very briefly to
166 * either protect simple one-time initialisation or to protect the creation
167 * of a dedicated mutex by calling CsrMutexCreate.
168 *
169 *----------------------------------------------------------------------------*/
170void CsrGlobalMutexLock(void);
171
172/*----------------------------------------------------------------------------*
173 * NAME
174 * CsrGlobalMutexUnlock
175 *
176 * DESCRIPTION
177 * Unlock the global mutex.
178 *
179 *----------------------------------------------------------------------------*/
180void CsrGlobalMutexUnlock(void);
181
182/*----------------------------------------------------------------------------*
183 * NAME
184 * CsrThreadCreate
185 *
186 * DESCRIPTION
187 * Create thread function and return a handle to the created thread.
188 *
189 * RETURNS
190 * Possible values:
191 * CSR_RESULT_SUCCESS in case of success
192 * CSR_FE_RESULT_NO_MORE_THREADS in case of out of thread resources
193 * CSR_FE_RESULT_INVALID_POINTER in case one of the supplied pointers is invalid
194 *
195 *----------------------------------------------------------------------------*/
196CsrResult CsrThreadCreate(void (*threadFunction)(void *pointer), void *pointer,
197    u32 stackSize, u16 priority,
198    const char *threadName, CsrThreadHandle *threadHandle);
199
200/*----------------------------------------------------------------------------*
201 * NAME
202 * CsrThreadGetHandle
203 *
204 * DESCRIPTION
205 * Return thread handle of calling thread.
206 *
207 * RETURNS
208 * Possible values:
209 * CSR_RESULT_SUCCESS in case of success
210 * CSR_FE_RESULT_INVALID_POINTER in case the threadHandle pointer is invalid
211 *
212 *----------------------------------------------------------------------------*/
213CsrResult CsrThreadGetHandle(CsrThreadHandle *threadHandle);
214
215/*----------------------------------------------------------------------------*
216 * NAME
217 * CsrThreadEqual
218 *
219 * DESCRIPTION
220 * Compare thread handles
221 *
222 * RETURNS
223 * Possible values:
224 * CSR_RESULT_SUCCESS in case thread handles are identical
225 * CSR_FE_RESULT_INVALID_POINTER in case either threadHandle pointer is invalid
226 * CSR_RESULT_FAILURE otherwise
227 *
228 *----------------------------------------------------------------------------*/
229CsrResult CsrThreadEqual(CsrThreadHandle *threadHandle1, CsrThreadHandle *threadHandle2);
230
231/*----------------------------------------------------------------------------*
232 * NAME
233 * CsrThreadSleep
234 *
235 * DESCRIPTION
236 * Sleep for a given period.
237 *
238 * RETURNS
239 * void
240 *
241 *----------------------------------------------------------------------------*/
242void CsrThreadSleep(u16 sleepTimeInMs);
243
244#ifdef __cplusplus
245}
246#endif
247
248#endif
249

Archive Download this file



interactive