FreeCalypso > hg > freecalypso-citrine
comparison g23m-gsm/dl/dl_dcch3.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 | Project : GSM-PS | |
4 | Modul : DL_DCCH3 | |
5 +----------------------------------------------------------------------------- | |
6 | Copyright 2002 Texas Instruments Berlin, AG | |
7 | All rights reserved. | |
8 | | |
9 | This file is confidential and a trade secret of Texas | |
10 | Instruments Berlin, AG | |
11 | The receipt of or possession of this file does not convey | |
12 | any rights to reproduce or disclose its contents or to | |
13 | manufacture, use, or sell anything it may describe, in | |
14 | whole, or in part, without the specific written consent of | |
15 | Texas Instruments Berlin, AG. | |
16 +----------------------------------------------------------------------------- | |
17 | Purpose : This Modul defines the functions for the slow | |
18 | dedicated control channel (SAPI 3) of the component DL | |
19 +----------------------------------------------------------------------------- | |
20 */ | |
21 | |
22 #ifndef DL_DCCH3_C | |
23 #define DL_DCCH3_C | |
24 | |
25 #include "config.h" | |
26 #include "fixedconf.h" | |
27 #include "condat-features.h" | |
28 | |
29 #define ENTITY_DL | |
30 | |
31 /*==== INCLUDES ===================================================*/ | |
32 | |
33 #include "typedefs.h" | |
34 #include <string.h> | |
35 #include "pconst.cdg" | |
36 #include "vsi.h" | |
37 #include "custom.h" | |
38 #include "gsm.h" | |
39 #include "mon_dl.h" | |
40 #include "prim.h" | |
41 #include "pei.h" | |
42 #include "tok.h" | |
43 #include "ccdapi.h" | |
44 #include "dl.h" | |
45 #include "dl_trc.h" | |
46 | |
47 | |
48 /*==== EXPORT =====================================================*/ | |
49 | |
50 /*==== PRIVAT =====================================================*/ | |
51 | |
52 /*==== VARIABLES ==================================================*/ | |
53 | |
54 /*==== FUNCTIONS ==================================================*/ | |
55 /* | |
56 +--------------------------------------------------------------------+ | |
57 | PROJECT : GSM-PS (6147) MODULE : DL_DCCH3 | | |
58 | STATE : code ROUTINE : dcch3_init_dl_data | | |
59 +--------------------------------------------------------------------+ | |
60 | |
61 PURPOSE : Initialisation of SDCCH data (SAPI 3) for an instance. | |
62 | |
63 */ | |
64 | |
65 GLOBAL void dcch3_init_dl_data (void) | |
66 { | |
67 GET_INSTANCE_DATA; | |
68 T_CCH *pcch = &dl_data->cch[C_DCCH3]; | |
69 | |
70 TRACE_FUNCTION ("dcch3_init_dl_data()"); | |
71 | |
72 memset (pcch, 0, sizeof (T_CCH)); | |
73 com_clear_queue (PS_SAPI_3); | |
74 | |
75 if (dl_data->dcch3_in_msg) | |
76 { | |
77 COM_FREE_POINTER (dl_data->dcch3_in_msg); | |
78 dl_data->dcch3_in_msg = NULL; | |
79 } | |
80 | |
81 dl_data->dcch3_disc_request = FALSE; | |
82 set_channel_state(C_DCCH3, STATE_DISABLED); | |
83 } | |
84 | |
85 /* | |
86 +--------------------------------------------------------------------+ | |
87 | PROJECT : GSM-PS (6147) MODULE : DL_DCCH3 | | |
88 | STATE : code ROUTINE : dcch3_enable | | |
89 +--------------------------------------------------------------------+ | |
90 | |
91 PURPOSE : Enabling SAPI 3 connections. | |
92 | |
93 */ | |
94 | |
95 GLOBAL void dcch3_enable (UBYTE ch_type) | |
96 { | |
97 GET_INSTANCE_DATA; | |
98 TRACE_FUNCTION ("dcch3_enable()"); | |
99 | |
100 switch (dl_data->state[C_DCCH3]) | |
101 { | |
102 case STATE_DISABLED: | |
103 set_channel_state (C_DCCH3, STATE_IDLE_DL); | |
104 dl_data->cch[C_DCCH3].ch_type = ch_type; | |
105 break; | |
106 default: | |
107 break; | |
108 } | |
109 } | |
110 | |
111 /* | |
112 +--------------------------------------------------------------------+ | |
113 | PROJECT : GSM-PS (6147) MODULE : DL_DCCH3 | | |
114 | STATE : code ROUTINE : dcch3_establish_req | | |
115 +--------------------------------------------------------------------+ | |
116 | |
117 PURPOSE : Establish Request for SDCCH (SAPI 3). | |
118 | |
119 */ | |
120 | |
121 GLOBAL void dcch3_establish_req (T_DL_ESTABLISH_REQ * est_req) | |
122 { | |
123 GET_INSTANCE_DATA; | |
124 TRACE_FUNCTION ("dcch3_establish_req()"); | |
125 | |
126 DL_OFFLINE_TRACE (TRACE_DL_EVENT, C_DCCH3, est_req->ch_type, "est req"); | |
127 | |
128 | |
129 switch (dl_data->state[C_DCCH3]) | |
130 { | |
131 case STATE_IDLE_DL: | |
132 case STATE_DISABLED: | |
133 case STATE_MULTIPLE_FRAME_ESTABLISHED: | |
134 case STATE_TIMER_RECOVERY: | |
135 { | |
136 T_CCH *pcch = &dl_data->cch[C_DCCH3]; | |
137 | |
138 pcch->ch_type = est_req->ch_type; | |
139 | |
140 dl_data->dcch3_disc_request = FALSE; | |
141 dl_data->dcch3_unserved = com_queue_awaiting_transmission (PS_SAPI_3) ? | |
142 DL_UNSERVED : DL_ALL_DONE; | |
143 | |
144 com_clear_queue (PS_SAPI_3); | |
145 pcch->vtx = SABM_CMD; | |
146 pcch->time_flag = TRUE; | |
147 pcch->rc = 0; | |
148 set_channel_state (C_DCCH3, STATE_AWAITING_ESTABLISHMENT); | |
149 TRACE_EVENT_WIN_P5 ("EST_REQ: %s SAPI=%u vtx=%s (%s#%u)", CH_TYPE_NAME[pcch->ch_type], | |
150 est_req->sapi, VTX_NAME[pcch->vtx], | |
151 __FILE10__, __LINE__); | |
152 } | |
153 | |
154 break; | |
155 default: | |
156 break; | |
157 } | |
158 COM_FREE_POINTER (est_req); | |
159 } | |
160 | |
161 /* | |
162 +--------------------------------------------------------------------+ | |
163 | PROJECT : GSM-PS (6147) MODULE : DL_SDCCH | | |
164 | STATE : code ROUTINE : sdcch3_release_req | | |
165 +--------------------------------------------------------------------+ | |
166 | |
167 PURPOSE : Release Request for SDCCH (SAPI 3). | |
168 | |
169 */ | |
170 | |
171 GLOBAL BOOL dcch3_release_req (T_DL_RELEASE_REQ * release_req) | |
172 { | |
173 GET_INSTANCE_DATA; | |
174 BOOL bFree = TRUE; | |
175 | |
176 TRACE_FUNCTION ("dcch3_release_req()"); | |
177 | |
178 if (release_req->mode EQ DL_LOCAL_END_RELEASE) | |
179 { | |
180 DL_OFFLINE_TRACE (TRACE_DL_EVENT, C_DCCH3, release_req->ch_type, "local end release req"); | |
181 bFree = FALSE; | |
182 } | |
183 else | |
184 { | |
185 DL_OFFLINE_TRACE (TRACE_DL_EVENT, C_DCCH3, release_req->ch_type, "normal release req"); | |
186 dl_data->cch[C_DCCH3].ch_type = release_req->ch_type; | |
187 switch (dl_data->state[C_DCCH3]) | |
188 { | |
189 default: | |
190 bFree = FALSE; | |
191 break; | |
192 | |
193 case STATE_AWAITING_ESTABLISHMENT: | |
194 case STATE_MULTIPLE_FRAME_ESTABLISHED: | |
195 case STATE_TIMER_RECOVERY: | |
196 if (!dl_data->dcch3_disc_request AND (dl_data->cch[C_DCCH3].vtx EQ RR_CMD)) | |
197 { | |
198 dl_data->dcch3_disc_request = TRUE; | |
199 } | |
200 else | |
201 { | |
202 com_prepare_DISC (C_DCCH3, release_req->sapi); | |
203 } | |
204 break; | |
205 | |
206 case STATE_AWAITING_RELEASE: | |
207 dl_data->cch[C_DCCH3].T200_counter = 0; | |
208 break; | |
209 } | |
210 } | |
211 | |
212 if (bFree EQ FALSE) | |
213 { | |
214 PREUSE (release_req, release_cnf, DL_RELEASE_CNF); | |
215 release_cnf->indication = | |
216 com_queue_awaiting_transmission (PS_SAPI_3) ? DL_UNSERVED : DL_ALL_DONE; | |
217 PSENDX (RR, release_cnf); | |
218 dcch3_init_dl_data (); | |
219 } | |
220 | |
221 return bFree; | |
222 } | |
223 | |
224 | |
225 /* | |
226 +--------------------------------------------------------------------+ | |
227 | PROJECT : GSM-PS (6147) MODULE : DL_DCCH3 | | |
228 | STATE : code ROUTINE : dcch3_mdl_release_req | | |
229 +--------------------------------------------------------------------+ | |
230 | |
231 PURPOSE : Release Request from Mobility Management for SDCCH (SAPI 3). | |
232 | |
233 */ | |
234 | |
235 GLOBAL void dcch3_mdl_release_req (void) | |
236 { | |
237 GET_INSTANCE_DATA; | |
238 TRACE_FUNCTION ("dcch3_mdl_release_req()"); | |
239 | |
240 DL_OFFLINE_TRACE (TRACE_DL_EVENT, C_DCCH3, dl_data->cch[C_DCCH3].ch_type, "mdl rel req"); | |
241 | |
242 switch (dl_data->state[C_DCCH3]) | |
243 { | |
244 case STATE_AWAITING_ESTABLISHMENT: | |
245 case STATE_TIMER_RECOVERY: | |
246 case STATE_AWAITING_RELEASE: | |
247 drr_dl_release_cnf (dl_data->cch[C_DCCH3].ch_type, PS_SAPI_3, TRUE); | |
248 break; | |
249 | |
250 case STATE_MULTIPLE_FRAME_ESTABLISHED: | |
251 drr_dl_release_ind (dl_data->cch[C_DCCH3].ch_type, PS_SAPI_3, NOT_PRESENT_8BIT, TRUE); | |
252 break; | |
253 | |
254 default: | |
255 break; | |
256 } | |
257 } | |
258 | |
259 /* | |
260 +--------------------------------------------------------------------+ | |
261 | PROJECT : GSM-PS (6147) MODULE : DL_DCCH3 | | |
262 | STATE : code ROUTINE : dcch3_data_req | | |
263 +--------------------------------------------------------------------+ | |
264 | |
265 PURPOSE : Data Request on SDCCH (SAPI 3). | |
266 | |
267 */ | |
268 | |
269 GLOBAL void dcch3_data_req (T_DL_DATA_REQ * data_req) | |
270 { | |
271 GET_INSTANCE_DATA; | |
272 TRACE_FUNCTION ("dcch3_data_req()"); | |
273 | |
274 switch (dl_data->state[C_DCCH3]) | |
275 { | |
276 case STATE_MULTIPLE_FRAME_ESTABLISHED: | |
277 case STATE_TIMER_RECOVERY: | |
278 com_store_queue (PS_SAPI_3, data_req); | |
279 break; | |
280 | |
281 default: | |
282 COM_FREE_POINTER (data_req); | |
283 break; | |
284 } | |
285 } | |
286 | |
287 /* | |
288 +--------------------------------------------------------------------+ | |
289 | PROJECT : GSM-PS (6147) MODULE : DL_SDCCH | | |
290 | STATE : code ROUTINE : dcch3_check_disc | | |
291 +--------------------------------------------------------------------+ | |
292 | |
293 PURPOSE : DISC command frame on DCCH3. | |
294 | |
295 */ | |
296 | |
297 GLOBAL int dcch3_check_disc (int send) | |
298 { | |
299 GET_INSTANCE_DATA; | |
300 TRACE_FUNCTION ("dcch3_check_disc()"); | |
301 | |
302 if (dl_data->dcch3_disc_request AND !(dl_data->cch[C_DCCH3].vtx EQ RR_CMD)) | |
303 { | |
304 com_prepare_DISC (C_DCCH3, PS_SAPI_3); | |
305 return uplink_awaiting_release (C_DCCH3, PS_SAPI_3); | |
306 } | |
307 else | |
308 return send; | |
309 } | |
310 #endif /* DL_DCCH3_C */ |