FreeCalypso > hg > freecalypso-sw
comparison gsm-fw/gpf/frame/vsi_sem.c @ 316:79080922d8e4
GPF: FRAME C sources and include files imported from LoCosto source
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Thu, 10 Apr 2014 04:06:05 +0000 |
parents | |
children | 2c760f6b1fe0 |
comparison
equal
deleted
inserted
replaced
315:1b4beffc8055 | 316:79080922d8e4 |
---|---|
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 "typedefs.h" | |
28 #include "vsi.h" | |
29 #include "os.h" | |
30 #include "frm_defs.h" | |
31 #include "frm_types.h" | |
32 #include "frm_glob.h" | |
33 | |
34 /*==== TYPES ======================================================*/ | |
35 | |
36 | |
37 /*==== CONSTANTS ==================================================*/ | |
38 | |
39 | |
40 /*==== EXTERNALS ==================================================*/ | |
41 /* -------------- S H A R E D - BEGIN ---------------- */ | |
42 #ifdef _TOOLS_ | |
43 #pragma data_seg("FRAME_SHARED") | |
44 #endif | |
45 | |
46 /*==== VARIABLES ==================================================*/ | |
47 | |
48 | |
49 #ifdef _TOOLS_ | |
50 #pragma data_seg() | |
51 #endif | |
52 /* -------------- S H A R E D - END ---------------- */ | |
53 | |
54 /*==== FUNCTIONS ==================================================*/ | |
55 | |
56 | |
57 #ifndef RUN_INT_RAM | |
58 /* | |
59 +--------------------------------------------------------------------+ | |
60 | PROJECT : GSM-Frame (8415) MODULE : VSI_SEM | | |
61 | STATE : code ROUTINE : vsi_s_open | | |
62 +--------------------------------------------------------------------+ | |
63 | |
64 PURPOSE : opens a semaphore, creates if not exist | |
65 | |
66 */ | |
67 | |
68 T_HANDLE vsi_s_open (T_HANDLE Caller, char *Name, USHORT Count) | |
69 { | |
70 OS_HANDLE SemHandle; | |
71 | |
72 /* | |
73 * if semaphore already exists, return handle | |
74 */ | |
75 if ( os_OpenSemaphore ( Caller, Name, &SemHandle ) != OS_ERROR ) | |
76 return SemHandle; | |
77 | |
78 /* | |
79 * if semaphore not exists, create | |
80 */ | |
81 if ( os_CreateSemaphore ( Caller, Name, Count, &SemHandle, pf_TaskTable[Caller].MemPoolHandle ) != OS_ERROR ) | |
82 return SemHandle; | |
83 else | |
84 vsi_o_assert( Caller, OS_SYST_ERR_MAX_SEMA, __FILE__, __LINE__, | |
85 "Number of created semaphores > MAX_SEMAPHORES" ); | |
86 | |
87 /* | |
88 * if semaphore cannot be created, return VSI_ERROR | |
89 */ | |
90 return VSI_ERROR; | |
91 } | |
92 #endif | |
93 | |
94 #ifndef RUN_INT_RAM | |
95 /* | |
96 +--------------------------------------------------------------------+ | |
97 | PROJECT : GSM-Frame (8415) MODULE : VSI_SEM | | |
98 | STATE : code ROUTINE : vsi_s_close | | |
99 +--------------------------------------------------------------------+ | |
100 | |
101 PURPOSE : closes a semaphore | |
102 | |
103 */ | |
104 | |
105 int vsi_s_close (T_HANDLE Caller, T_HANDLE SemHandle) | |
106 { | |
107 | |
108 if ( os_CloseSemaphore ( Caller, SemHandle ) != OS_ERROR ) | |
109 return VSI_OK; | |
110 | |
111 return VSI_ERROR; | |
112 } | |
113 #endif | |
114 | |
115 #ifndef RUN_FLASH | |
116 /* | |
117 +--------------------------------------------------------------------+ | |
118 | PROJECT : GSM-Frame (8415) MODULE : VSI_SEM | | |
119 | STATE : code ROUTINE : vsi_s_get | | |
120 +--------------------------------------------------------------------+ | |
121 | |
122 PURPOSE : obtains a semaphore | |
123 | |
124 */ | |
125 | |
126 int vsi_s_get (T_HANDLE Caller, T_HANDLE SemHandle) | |
127 { | |
128 LONG Status; | |
129 | |
130 Status = os_ObtainSemaphore ( Caller, SemHandle, OS_SUSPEND ); | |
131 if ( Status == OS_OK || Status == OS_WAITED ) | |
132 return VSI_OK; | |
133 | |
134 return VSI_ERROR; | |
135 } | |
136 #endif | |
137 | |
138 #ifndef RUN_FLASH | |
139 /* | |
140 +--------------------------------------------------------------------+ | |
141 | PROJECT : GSM-Frame (8415) MODULE : VSI_SEM | | |
142 | STATE : code ROUTINE : vsi_s_release | | |
143 +--------------------------------------------------------------------+ | |
144 | |
145 PURPOSE : releases a semaphore | |
146 | |
147 */ | |
148 | |
149 int vsi_s_release (T_HANDLE Caller, T_HANDLE SemHandle) | |
150 { | |
151 | |
152 if ( os_ReleaseSemaphore ( Caller, SemHandle ) != OS_ERROR ) | |
153 return VSI_OK; | |
154 | |
155 return VSI_ERROR; | |
156 } | |
157 #endif | |
158 | |
159 #ifndef RUN_INT_RAM | |
160 /* | |
161 +--------------------------------------------------------------------+ | |
162 | PROJECT : GSM-Frame (8415) MODULE : VSI_SEM | | |
163 | STATE : code ROUTINE : vsi_s_status | | |
164 +--------------------------------------------------------------------+ | |
165 | |
166 PURPOSE : request the current count of a semaphore | |
167 | |
168 */ | |
169 | |
170 int vsi_s_status (T_HANDLE Caller, T_HANDLE SemHandle, USHORT *Count ) | |
171 { | |
172 | |
173 if ( os_QuerySemaphore ( Caller, SemHandle, Count ) != OS_ERROR ) | |
174 return VSI_OK; | |
175 | |
176 return VSI_ERROR; | |
177 } | |
178 #endif | |
179 |