comparison gpf/frame/vsi_sem.c @ 0:75a11d740a02

initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 09 Jun 2016 00:02:41 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:75a11d740a02
1 /*
2 +------------------------------------------------------------------------------
3 | File: vsi_sem.c
4 +------------------------------------------------------------------------------
5 | Copyright 2002 Texas Instruments Berlin, AG
6 | All rights reserved.
7 |
8 | This file is confidential and a trade secret of Texas
9 | Instruments Berlin, AG
10 | The receipt of or possession of this file does not convey
11 | any rights to reproduce or disclose its contents or to
12 | manufacture, use, or sell anything it may describe, in
13 | whole, or in part, without the specific written consent of
14 | Texas Instruments Berlin, AG.
15 +-----------------------------------------------------------------------------
16 | Purpose : This Module defines the virtual system interface part
17 | for the semaphore handling.
18 +-----------------------------------------------------------------------------
19 */
20
21 #ifndef __VSI_SEM_C__
22 #define __VSI_SEM_C__
23 #endif
24
25 /*==== INCLUDES ===================================================*/
26
27 #include "gpfconf.h"
28 #include "typedefs.h"
29 #include "vsi.h"
30 #include "os.h"
31 #include "frm_defs.h"
32 #include "frm_types.h"
33 #include "frm_glob.h"
34
35 /*==== TYPES ======================================================*/
36
37
38 /*==== CONSTANTS ==================================================*/
39
40
41 /*==== EXTERNALS ==================================================*/
42 /* -------------- S H A R E D - BEGIN ---------------- */
43 #ifdef _TOOLS_
44 #pragma data_seg("FRAME_SHARED")
45 #endif
46
47 /*==== VARIABLES ==================================================*/
48
49
50 #ifdef _TOOLS_
51 #pragma data_seg()
52 #endif
53 /* -------------- S H A R E D - END ---------------- */
54
55 /*==== FUNCTIONS ==================================================*/
56
57
58 #ifndef RUN_INT_RAM
59 /*
60 +--------------------------------------------------------------------+
61 | PROJECT : GSM-Frame (8415) MODULE : VSI_SEM |
62 | STATE : code ROUTINE : vsi_s_open |
63 +--------------------------------------------------------------------+
64
65 PURPOSE : opens a semaphore, creates if not exist
66
67 */
68
69 T_HANDLE vsi_s_open (T_HANDLE Caller, char *Name, USHORT Count)
70 {
71 OS_HANDLE SemHandle;
72
73 /*
74 * if semaphore already exists, return handle
75 */
76 if ( os_OpenSemaphore ( Caller, Name, &SemHandle ) != OS_ERROR )
77 return SemHandle;
78
79 /*
80 * if semaphore not exists, create
81 */
82 if ( os_CreateSemaphore ( Caller, Name, Count, &SemHandle, pf_TaskTable[Caller].MemPoolHandle ) != OS_ERROR )
83 return SemHandle;
84 else
85 vsi_o_assert( Caller, OS_SYST_ERR_MAX_SEMA, __FILE__, __LINE__,
86 "Number of created semaphores > MAX_SEMAPHORES" );
87
88 /*
89 * if semaphore cannot be created, return VSI_ERROR
90 */
91 return VSI_ERROR;
92 }
93 #endif
94
95 #ifndef RUN_INT_RAM
96 /*
97 +--------------------------------------------------------------------+
98 | PROJECT : GSM-Frame (8415) MODULE : VSI_SEM |
99 | STATE : code ROUTINE : vsi_s_close |
100 +--------------------------------------------------------------------+
101
102 PURPOSE : closes a semaphore
103
104 */
105
106 int vsi_s_close (T_HANDLE Caller, T_HANDLE SemHandle)
107 {
108
109 if ( os_CloseSemaphore ( Caller, SemHandle ) != OS_ERROR )
110 return VSI_OK;
111
112 return VSI_ERROR;
113 }
114 #endif
115
116 #ifndef RUN_FLASH
117 /*
118 +--------------------------------------------------------------------+
119 | PROJECT : GSM-Frame (8415) MODULE : VSI_SEM |
120 | STATE : code ROUTINE : vsi_s_get |
121 +--------------------------------------------------------------------+
122
123 PURPOSE : obtains a semaphore
124
125 */
126
127 int vsi_s_get (T_HANDLE Caller, T_HANDLE SemHandle)
128 {
129 LONG Status;
130
131 Status = os_ObtainSemaphore ( Caller, SemHandle, OS_SUSPEND );
132 if ( Status == OS_OK || Status == OS_WAITED )
133 return VSI_OK;
134
135 return VSI_ERROR;
136 }
137 #endif
138
139 #ifndef RUN_FLASH
140 /*
141 +--------------------------------------------------------------------+
142 | PROJECT : GSM-Frame (8415) MODULE : VSI_SEM |
143 | STATE : code ROUTINE : vsi_s_release |
144 +--------------------------------------------------------------------+
145
146 PURPOSE : releases a semaphore
147
148 */
149
150 int vsi_s_release (T_HANDLE Caller, T_HANDLE SemHandle)
151 {
152
153 if ( os_ReleaseSemaphore ( Caller, SemHandle ) != OS_ERROR )
154 return VSI_OK;
155
156 return VSI_ERROR;
157 }
158 #endif
159
160 #ifndef RUN_INT_RAM
161 /*
162 +--------------------------------------------------------------------+
163 | PROJECT : GSM-Frame (8415) MODULE : VSI_SEM |
164 | STATE : code ROUTINE : vsi_s_status |
165 +--------------------------------------------------------------------+
166
167 PURPOSE : request the current count of a semaphore
168
169 */
170
171 int vsi_s_status (T_HANDLE Caller, T_HANDLE SemHandle, USHORT *Count )
172 {
173
174 if ( os_QuerySemaphore ( Caller, SemHandle, Count ) != OS_ERROR )
175 return VSI_OK;
176
177 return VSI_ERROR;
178 }
179 #endif
180