SysLink API Reference  2.21.03.11
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
OsalSemaphore.h
Go to the documentation of this file.
1 
12 /*
13  * ============================================================================
14  *
15  * Copyright (c) 2008-2012, Texas Instruments Incorporated
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions
19  * are met:
20  *
21  * * Redistributions of source code must retain the above copyright
22  * notice, this list of conditions and the following disclaimer.
23  *
24  * * Redistributions in binary form must reproduce the above copyright
25  * notice, this list of conditions and the following disclaimer in the
26  * documentation and/or other materials provided with the distribution.
27  *
28  * * Neither the name of Texas Instruments Incorporated nor the names of
29  * its contributors may be used to endorse or promote products derived
30  * from this software without specific prior written permission.
31  *
32  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
33  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
34  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
35  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
36  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
37  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
38  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
39  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
40  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
41  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
42  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43  * Contact information for paper mail:
44  * Texas Instruments
45  * Post Office Box 655303
46  * Dallas, Texas 75265
47  * Contact information:
48  * http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm?
49  * DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact
50  * ============================================================================
51  *
52  */
53 
54 
55 
56 #ifndef OSALSEMAPHORE_H_0xF6D6
57 #define OSALSEMAPHORE_H_0xF6D6
58 
59 
60 /* OSAL and utils */
61 
62 
63 #if defined (__cplusplus)
64 extern "C" {
65 #endif
66 
67 
72 #define OSALSEMAPHORE_MODULEID (UInt16) 0xF6D6
73 
74 /* =============================================================================
75  * All success and failure codes for the module
76  * =============================================================================
77  */
82 #define OSALSEMAPHORE_STATUSCODEBASE (OSALSEMAPHORE_MODULEID << 12u)
83 
88 #define OSALSEMAPHORE_MAKE_FAILURE(x) ((Int) (0x80000000 \
89  + (OSALSEMAPHORE_STATUSCODEBASE +(x))))
90 
94 #define OSALSEMAPHORE_MAKE_SUCCESS(x) (OSALSEMAPHORE_STATUSCODEBASE + (x))
95 
100 #define OSALSEMAPHORE_E_MEMORY OSALSEMAPHORE_MAKE_FAILURE(1)
101 
106 #define OSALSEMAPHORE_E_INVALIDARG OSALSEMAPHORE_MAKE_FAILURE(2)
107 
112 #define OSALSEMAPHORE_E_FAIL OSALSEMAPHORE_MAKE_FAILURE(3)
113 
118 #define OSALSEMAPHORE_E_TIMEOUT OSALSEMAPHORE_MAKE_FAILURE(4)
119 
124 #define OSALSEMAPHORE_E_HANDLE OSALSEMAPHORE_MAKE_FAILURE(5)
125 
131 #define OSALSEMAPHORE_E_WAITNONE OSALSEMAPHORE_MAKE_FAILURE(6)
132 
137 #define OSALSEMAPHORE_E_RESOURCE OSALSEMAPHORE_MAKE_FAILURE(7)
138 
143 #define OSALSEMAPHORE_SUCCESS OSALSEMAPHORE_MAKE_SUCCESS(0)
144 
145 
146 /* =============================================================================
147  * Macros and types
148  * =============================================================================
149  */
154 #define OSALSEMAPHORE_WAIT_FOREVER (~((UInt32) 0u))
155 
160 #define OSALSEMAPHORE_WAIT_NONE ((UInt32) 0u)
161 
166 #define OSALSEMAPHORE_TYPE_VALUE(type) (type & 0x0000FFFF)
167 
172 #define OSALSEMAPHORE_INTTYPE_VALUE(type) (type & 0xFFFF0000)
173 
178 typedef struct OsalSemaphore_Object * OsalSemaphore_Handle;
179 
183 typedef enum {
191 
195 typedef enum {
203 
204 
205 /* =============================================================================
206  * APIs
207  * =============================================================================
208  */
209 /* Creates the semaphore object. */
210 OsalSemaphore_Handle OsalSemaphore_create (UInt32 semType);
211 
212 /* Deletes the semaphore object */
213 Int OsalSemaphore_delete (OsalSemaphore_Handle * semHandle);
214 
215 /* Wait on the said Semaphore in the kernel thread context */
216 Int OsalSemaphore_pend (OsalSemaphore_Handle semHandle, UInt32 timeout);
217 
218 /* Signal the semaphore and make it available for other threads. */
219 Int OsalSemaphore_post (OsalSemaphore_Handle semHandle);
220 
221 
222 #if defined (__cplusplus)
223 }
224 #endif /* defined (__cplusplus) */
225 
226 #endif /* ifndef OSALSEMAPHORE_H_0xF6D6 */
Copyright 2014, Texas Instruments Incorporated