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