comparison src/g23m-fad/fad/fad_kerp.c @ 174:90eb61ecd093

src/g23m-fad: initial import from TCS3.2/LoCosto
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 12 Oct 2016 05:40:46 +0000
parents
children
comparison
equal deleted inserted replaced
173:bf64d785238a 174:90eb61ecd093
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-F&D (8411)
4 | Modul : FAD_KERP
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 processing
18 | of incomming primitives for the component
19 | Fax Adaptation 3.45 of the mobile station
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifndef FAD_KERP_C
24 #define FAD_KERP_C
25 #endif
26
27 #define ENTITY_FAD
28
29 /*==== INCLUDES ===================================================*/
30
31 #include <string.h>
32 #include "typedefs.h"
33 #include "pconst.cdg"
34 #include "vsi.h"
35 #include "macdef.h"
36 #include "pconst.cdg"
37 #include "custom.h"
38 #include "gsm.h"
39 #include "cnf_fad.h"
40 #include "mon_fad.h"
41 #include "prim.h"
42 #include "pei.h"
43 #include "tok.h"
44 #include "ccdapi.h"
45 #include "fad.h"
46
47 #ifdef _TARGET_
48 #include "ra_l1int.h"
49 #endif
50
51 /*==== CONST =======================================================*/
52
53 /*==== TYPES =======================================================*/
54
55 /*==== VAR EXPORT ==================================================*/
56
57 /*==== VAR LOCAL ===================================================*/
58
59 /*==== FUNCTIONS ===================================================*/
60
61 /*
62 +--------------------------------------------------------------------+
63 | PROJECT : GSM-F&D (8411) MODULE : FAD_KERP |
64 | STATE : code ROUTINE : ker_fad_activate_req |
65 +--------------------------------------------------------------------+
66
67 PURPOSE : Process primitive FAD_ACTIVATE_REQ received from T30.
68
69 */
70
71 GLOBAL void ker_fad_activate_req (T_FAD_ACTIVATE_REQ *fad_activate_req)
72 {
73 TRACE_EVENT ("ker_fad_activate_req()");
74 PACCESS (fad_activate_req);
75
76 /*******************************/
77 /*
78 * Initialize Shared Fax/Data memory
79 */
80
81 fad_data = &fad_data_base[0];
82 ker_init ();
83 snd_init ();
84 rcv_init ();
85
86 /*
87 * reset RBM
88 */
89 rbm_reset ();
90
91 fad_data_magic_num = FAD_DATA_MAGIC_NUM; /* memory is initialized */
92
93 /*******************************/
94
95 if (GET_STATE (KER) EQ KER_NULL)
96 {
97 sig_ker_snd_activate_req (fad_activate_req);
98 sbm_init (FRAME_SIZE);
99 rbm_init (fad_activate_req->frames_per_prim);
100 sig_ker_snd_sync_req (FALSE);
101 {
102 PALLOC (fad_activate_cnf, FAD_ACTIVATE_CNF);
103 /*
104 * calculate the RX and TX buffersizes and notify it
105 * to T30
106 */
107 fad_activate_cnf->buf_size_rx
108 = fad_activate_req->frames_per_prim * FRAME_SIZE * RBM_PQ_MAX_PRIM;
109 fad_activate_cnf->buf_size_tx
110 = fad_activate_req->frames_per_prim * FRAME_SIZE * SBM_MAX_PRIMS;
111 PSENDX (T30, fad_activate_cnf);
112 }
113 SET_STATE (KER, IDLE);
114
115 #ifdef _TARGET_
116 {
117 T_RA_DATATRANS_REQ RA_datatrans_req;
118 l1i_ra_datatrans_req(&RA_datatrans_req);
119 }
120 #endif
121
122 }
123
124 PFREE (fad_activate_req);
125 }
126
127
128 /*
129 +----------------------------------------------------------------------+
130 | PROJECT : GSM-F&D (8411) MODULE : FAD_KERP |
131 | STATE : code ROUTINE : ker_fad_deactivate_req |
132 +----------------------------------------------------------------------+
133
134 PURPOSE : Process primitive FAD_DEACTIVATE_REQ received from T30.
135
136 */
137
138 GLOBAL void ker_fad_deactivate_req (T_FAD_DEACTIVATE_REQ *fad_deactivate_req)
139 {
140 TRACE_EVENT ("ker_fad_deactivate_req()");
141
142 PACCESS (fad_deactivate_req);
143
144 sig_ker_snd_sync_req (FALSE);
145 rbm_deinit(TRUE);
146 SET_STATE (KER, KER_NULL);
147
148 {
149 PALLOC (fad_deactivate_cnf, FAD_DEACTIVATE_CNF);
150 PSENDX (T30, fad_deactivate_cnf);
151 }
152
153 PFREE (fad_deactivate_req);
154 }
155
156 /*
157 +--------------------------------------------------------------------+
158 | PROJECT : GSM-F&D (8411) MODULE : FAD_KERP |
159 | STATE : code ROUTINE : ker_fad_modify_req |
160 +--------------------------------------------------------------------+
161
162 PURPOSE : Process primitive FAD_MODIFY_REQ received from T30.
163
164 */
165
166 GLOBAL void ker_fad_modify_req (T_FAD_MODIFY_REQ *fad_modify_req)
167 {
168 TRACE_EVENT ("ker_fad_modify_req()");
169 PACCESS (fad_modify_req);
170
171 if (GET_STATE (KER) NEQ KER_NULL)
172 {
173 fad_data->snd.trans_rate = fad_modify_req->trans_rate;
174 fad_data->rcv.FlagFound = 0;
175 TRACE_EVENT_P1("MODIFY %d bps", fad_data->snd.trans_rate);
176 }
177
178 PFREE (fad_modify_req);
179 }
180
181 /*
182 +--------------------------------------------------------------------+
183 | PROJECT : GSM-F&D (8411) MODULE : FAD_KERP |
184 | STATE : code ROUTINE : ker_fad_data_req |
185 +--------------------------------------------------------------------+
186
187 PURPOSE : Process primitive FAD_DATA_REQ received from T30.
188
189 */
190
191 GLOBAL void ker_fad_data_req (T_FAD_DATA_REQ *fad_data_req)
192 {
193 T_SBM *sbm = &fad_data->sbm;
194 USHORT err_cause = 0;
195
196 #ifdef _SIMULATION_
197 TRACE_FUNCTION ("ker_fad_data_req()");
198 #endif
199
200 PACCESS (fad_data_req);
201
202 switch (GET_STATE (KER))
203 {
204 case KER_NULL:
205 err_cause = ERR_LOCAL_DATA_NULL;
206 break;
207
208 case IDLE:
209 if (fad_data_req->trans_rate EQ R_BCS)
210 {
211 SET_STATE (KER, BCS_REC);
212 sig_ker_snd_preamble_req (fad_data_req);
213 }
214 else
215 {
216 if (fad_data_req->trans_rate EQ R_7200)
217 {
218 sbm->syncCycle = SYNC_CYCLE_7200;
219 sbm->framesUntilSync = (SYNC_CYCLE_7200-1);
220 }
221 else if (fad_data_req->trans_rate EQ R_12000)
222 {
223 sbm->syncCycle = SYNC_CYCLE_12000;
224 sbm->framesUntilSync = (SYNC_CYCLE_12000-1);
225 }
226
227 SET_STATE (KER, MSG_REC);
228 sig_ker_snd_train_req (fad_data_req, TRUE);
229 }
230 break;
231
232 case BCS_REC:
233 if (fad_data_req->trans_rate EQ R_BCS)
234 sig_ker_snd_bcs_req (fad_data_req);
235 else
236 err_cause = ERR_LOCAL_MSG_RATE;
237 break;
238
239 case MSG_REC_TCF:
240 err_cause = ERR_LOCAL_DATA_TCF_SND;
241 break;
242
243 case MSG_REC:
244 if (fad_data_req->trans_rate NEQ R_BCS)
245 sig_ker_snd_msg_req (fad_data_req);
246 else
247 err_cause = ERR_LOCAL_BCS_RATE;
248 break;
249
250 case BCS_TRA:
251 if (fad_data_req->trans_rate EQ R_BCS)
252 fad_data->snd.fad_data_req = fad_data_req; /* store data, send later */
253 break;
254
255 case MSG_TRA_TCF:
256 err_cause = ERR_LOCAL_DATA_TCF_RCV;
257 break;
258
259 case MSG_TRA:
260 err_cause = ERR_LOCAL_DATA_MSG;
261 break;
262
263 default:
264 err_cause = ERR_LOCAL_DATA_UNDEF;
265 break;
266 }
267
268 if (err_cause)
269 {
270 ker_SetError (err_cause);
271 sig_ker_snd_sync_req (FALSE);
272 SET_STATE (KER, IDLE);
273 PFREE (fad_data_req);
274 }
275
276 }
277
278 /*
279 +--------------------------------------------------------------------+
280 | PROJECT : GSM-F&D (8411) MODULE : FAD_KERP |
281 | STATE : code ROUTINE : ker_fad_snd_tcf_req |
282 +--------------------------------------------------------------------+
283
284 PURPOSE : Process primitive FAD_SND_TCF_REQ received from T30.
285
286 */
287
288 GLOBAL void ker_fad_snd_tcf_req (T_FAD_SND_TCF_REQ *fad_snd_tcf_req)
289 {
290 T_SBM *sbm = &fad_data->sbm;
291
292 TRACE_FUNCTION ("ker_fad_snd_tcf_req()");
293 PACCESS (fad_snd_tcf_req);
294
295 if (GET_STATE (KER) EQ IDLE)
296 {
297 SET_STATE (KER, MSG_REC_TCF);
298
299 if (fad_snd_tcf_req->trans_rate EQ R_7200)
300 {
301 sbm->syncCycle = SYNC_CYCLE_7200;
302 sbm->framesUntilSync = (SYNC_CYCLE_7200-1);
303 }
304 else if (fad_snd_tcf_req->trans_rate EQ R_12000)
305 {
306 sbm->syncCycle = SYNC_CYCLE_12000;
307 sbm->framesUntilSync = (SYNC_CYCLE_12000-1);
308 }
309
310 sig_ker_snd_tcf_req ();
311 }
312
313 PFREE (fad_snd_tcf_req);
314 }
315
316
317 /*
318 +--------------------------------------------------------------------+
319 | PROJECT : GSM-F&D (8411) MODULE : FAD_KERP |
320 | STATE : code ROUTINE : ker_fad_rcv_tcf_req |
321 +--------------------------------------------------------------------+
322
323 PURPOSE : Process primitive FAD_RCV_TCF_REQ received from T30.
324
325 */
326
327 GLOBAL void ker_fad_rcv_tcf_req (T_FAD_RCV_TCF_REQ *fad_rcv_tcf_req)
328 {
329 T_SBM *sbm = &fad_data->sbm;
330
331 TRACE_FUNCTION ("ker_fad_rcv_tcf_req()");
332
333 PACCESS (fad_rcv_tcf_req);
334
335 if (GET_STATE (KER) EQ IDLE)
336 {
337 if (fad_rcv_tcf_req->trans_rate EQ R_7200)
338 {
339 sbm->syncCycle = SYNC_CYCLE_7200;
340 sbm->framesUntilSync = (SYNC_CYCLE_7200-1);
341 }
342 else if (fad_rcv_tcf_req->trans_rate EQ R_12000)
343 {
344 sbm->syncCycle = SYNC_CYCLE_12000;
345 sbm->framesUntilSync = (SYNC_CYCLE_12000-1);
346 }
347
348 SET_STATE (KER, MSG_TRA_TCF);
349 sig_ker_rcv_await_tcf_req ();
350 }
351
352 PFREE (fad_rcv_tcf_req);
353 }
354
355 /*
356 +--------------------------------------------------------------------+
357 | PROJECT : GSM-F&D (8411) MODULE : FAD_KERP |
358 | STATE : code ROUTINE : ker_fad_ready_req |
359 +--------------------------------------------------------------------+
360
361 PURPOSE : Process primitive FAD_READY_REQ received from T30.
362
363 */
364
365 GLOBAL void ker_fad_ready_req (T_FAD_READY_REQ *fad_ready_req)
366 {
367
368 TRACE_FUNCTION ("ker_fad_ready_req()");
369 PACCESS (fad_ready_req);
370
371 /* PZ 25.5.99
372 if (GET_STATE (KER) EQ MSG_TRA)
373 sig_ker_rcv_ready_req ();
374 */
375 sig_ker_rcv_ready_req ();
376
377 PFREE (fad_ready_req);
378 }
379
380
381 /*
382 +--------------------------------------------------------------------+
383 | PROJECT : GSM-F&D (8411) MODULE : FAD_KERP |
384 | STATE : code ROUTINE : ker_fad_ignore_req |
385 +--------------------------------------------------------------------+
386
387 PURPOSE : Process primitive FAD_IGNORE_REQ received from T30.
388
389 */
390
391 GLOBAL void ker_fad_ignore_req (T_FAD_IGNORE_REQ *fad_ignore_req)
392 {
393 TRACE_FUNCTION ("ker_fad_ignore_req()");
394 PACCESS (fad_ignore_req);
395
396 if (GET_STATE (KER) EQ MSG_TRA)
397 fad_data->ker.forward_data = FALSE;
398
399 PFREE (fad_ignore_req);
400 }
401
402
403