comparison g23m/condat/ms/src/aci/cmh_l2rr.c @ 0:509db1a7b7b8

initial import: leo2moko-r1
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 01 Jun 2015 03:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS (6147)
4 | Modul : CMH_L2RR
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 module defines the functions which are responsible
18 | for the responses of the protocol stack adapter for
19 | layer 2 relay.
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifndef CMH_L2RR_C
24 #define CMH_L2RR_C
25 #endif
26
27 #include "aci_all.h"
28
29 /*==== INCLUDES ===================================================*/
30 #include "aci_cmh.h"
31 #include "ati_cmd.h"
32 #include "aci_cmd.h"
33 #include "aci_lst.h"
34 #include "dti.h" /* functionality of the dti library */
35
36 #include "aci_io.h"
37
38 #include "aci_fd.h"
39
40 #include "dti_conn_mng.h"
41 #include "dti_cntrl_mng.h"
42
43 #include "aci.h"
44 #include "psa.h"
45 #include "psa_l2r.h"
46 #include "psa_cc.h"
47 #include "cmh.h"
48 #include "psa_ra.h"
49 #include "cmh_ra.h"
50 #include "cmh_l2r.h"
51 #include "cmh_cc.h"
52
53 #include "psa_tra.h"
54
55
56 #include "cmh_ra.h"
57 #ifdef UART
58 #include "psa_uart.h"
59 #include "cmh_uart.h"
60 #endif
61
62 #ifdef FF_PSI
63 #include "psa_psi.h"
64 #include "cmh_psi.h"
65 #include "ati_src_psi.h"
66 #endif /*FF_PSI*/
67
68 #ifdef DTI
69 #include "sap_dti.h"
70 #endif
71
72 /*==== CONSTANTS ==================================================*/
73
74
75 /*==== TYPES ======================================================*/
76
77
78 /*==== EXPORT =====================================================*/
79
80 /*==== VARIABLES ==================================================*/
81
82 /*==== FUNCTIONS ==================================================*/
83
84 /*
85 +-------------------------------------------------------------------+
86 | PROJECT : GSM-PS (6147) MODULE : CMH_L2RR |
87 | ROUTINE : cmhL2R_TRA_Enabled |
88 +-------------------------------------------------------------------+
89
90 PURPOSE : L2R entity enabled, data mode
91
92 */
93
94 GLOBAL void cmhL2R_TRA_Enabled ( void )
95 {
96 SHORT cId; /* holds call id */
97
98 TRACE_FUNCTION ("cmhL2R_TRA_Enabled()");
99
100 /* find active call */
101 cId = psaCC_ctbFindCall( NO_VLD_OWN, CS_ACT, NO_VLD_CT );
102
103 if( cId NEQ NO_ENTRY AND psaCC_ctb(cId)->curCmd EQ AT_CMD_O )
104 {
105 cmhCC_PrepareCmdEnd (cId, NULL, NULL);
106 }
107 }
108 /*
109 +-------------------------------------------------------------------+
110 | PROJECT : GSM-PS (6147) MODULE : CMH_L2RR |
111 | ROUTINE : cmhL2R_Deactivated |
112 +-------------------------------------------------------------------+
113
114 PURPOSE : L2R entity deactivated, connection disconnected
115
116 */
117
118 GLOBAL void cmhL2R_Deactivated ( void )
119 {
120 TRACE_FUNCTION ("cmhL2R_Deactivated()");
121
122 cmhCC_L2R_or_TRA_Deactivated(raShrdPrm.cId); /* see issue 7527 why raShrdPrm.cId */
123
124 l2rEntStat.curCmd = AT_CMD_NONE;
125 }
126
127 /*
128 +-------------------------------------------------------------------+
129 | PROJECT : GSM-PS (6147) MODULE : CMH_L2RR |
130 | ROUTINE : cmhTRA_Deactivated |
131 +-------------------------------------------------------------------+
132
133 PURPOSE : TRA entity deactivated, connection disconnected
134
135 */
136
137 GLOBAL void cmhTRA_Deactivated ( void )
138 {
139 TRACE_FUNCTION ("cmhTRA_Deactivated()");
140
141 cmhCC_L2R_or_TRA_Deactivated(raShrdPrm.cId);
142 }
143
144 /*
145 +-------------------------------------------------------------------+
146 | PROJECT : GSM-PS (6147) MODULE : CMH_L2RR |
147 | ROUTINE : cmhL2R_TRA_Disabled |
148 +-------------------------------------------------------------------+
149
150 PURPOSE : L2R entity disabled, escape from data mode
151
152 */
153
154 GLOBAL void cmhL2R_TRA_Disabled ( T_DTI_ENTITY_ID entityId )
155 {
156 S8 source = psaCC_ctb(raShrdPrm.cId)->calOwn;
157
158 TRACE_FUNCTION ("cmhL2R_TRA_Disabled()");
159 switch (entityId)
160 {
161 #ifdef UART
162 case DTI_ENTITY_UART:
163 /* return to command mode */
164 if (uartShrdPrm.dtr_clearcall EQ FALSE)
165 {
166 R_AT( RAT_OK, source )
167 ( AT_CMD_NONE );
168 }
169 break;
170 #endif
171 #if defined (FF_PSI) AND defined (DTI)
172 case DTI_ENTITY_PSI:
173 /* return to command mode */
174 if (psiShrdPrm.dtr_clearcall EQ FALSE)
175 {
176 R_AT( RAT_OK, source )
177 ( AT_CMD_NONE );
178 }
179 break;
180 #endif /*FF_PSI*/
181 }
182 }
183
184 /*
185 +-------------------------------------------------------------------+
186 | PROJECT : GSM-PS (6147) MODULE : CMH_L2RR |
187 | ROUTINE : cmhL2R_Failure |
188 +-------------------------------------------------------------------+
189
190 PURPOSE : L2R entity failure, connection will be disconnected
191
192 */
193
194 GLOBAL void cmhL2R_Failure ( void )
195 {
196
197 TRACE_EVENT_P1("RLP ERROR: 0x%04x", l2rShrdPrm.set_prm[l2rShrdPrm.owner].err_cause );
198
199 /*
200 *-------------------------------------------------------------------
201 * general failure indication
202 *-------------------------------------------------------------------
203 */
204 cmhCC_L2R_Failed();
205 }
206
207
208
209 /*
210 +--------------------------------------------------------------------+
211 | PROJECT : GSM-F&D (8411) MODULE : CMH_L2RR |
212 | STATE : code ROUTINE : L2R_connect_dti_cb |
213 +--------------------------------------------------------------------+
214
215 PURPOSE : Callback for connection between L2R and UART.
216
217 */
218 #ifdef DTI
219 GLOBAL BOOL L2R_connect_dti_cb(UBYTE dti_id, T_DTI_CONN_STATE result_type)
220 {
221 T_ACI_DTI_PRC *srcInfos;
222 #ifdef FF_PSI
223 T_ACI_DTI_PRC_PSI *srcInfos_psi;
224 #endif /*FF_PSI*/
225 T_DTI_ENTITY_ID entityId = DTI_ENTITY_UART;
226 T_DTI_CNTRL info;
227
228 TRACE_FUNCTION("L2R_connect_dti_cb");
229
230
231 if (dti_cntrl_get_info_from_dti_id( dti_id, &info) EQ FALSE)
232 {
233 TRACE_EVENT_P1("cannot find info for dti_id=%d", dti_id);
234 return FALSE;
235 }
236
237 if ((srcInfos = find_element (uart_src_params, info.src_id, cmhUARTtest_srcId)) NEQ NULL)
238 entityId = DTI_ENTITY_UART;
239 #if defined (FF_PSI) AND defined (DTI)
240 if ((srcInfos_psi = find_element (psi_src_params, info.src_id, cmhPSItest_srcId)) NEQ NULL)
241 entityId = DTI_ENTITY_PSI;
242 else if (srcInfos EQ NULL AND srcInfos_psi EQ NULL)
243 #else
244 else if (srcInfos EQ NULL)
245 #endif /*FF_PSI*/
246 {
247 TRACE_EVENT_P1 ("[ERR] L2R_connect_dti_cb: srcId=%d not found", info.src_id);
248 return FALSE;
249 }
250
251 switch( result_type)
252 {
253 case(DTI_CONN_STATE_CONNECTED):
254 cmhL2R_TRA_Enabled();
255 break;
256
257 case(DTI_CONN_STATE_DISCONNECTED):
258
259 dti_cntrl_clear_conn_parms( dti_id );
260
261 if (l2rEntStat.isTempDisconnected)
262 {
263 #ifdef FF_PSI
264 if (entityId EQ DTI_ENTITY_PSI)
265 BITFIELD_SET (srcInfos_psi->data_cntr, UART_DTI_SB_BIT);
266 else
267 #endif /*FF_PSI*/
268 BITFIELD_SET (srcInfos->data_cntr, UART_DTI_SB_BIT);
269 l2rEntStat.isTempDisconnected = FALSE;
270 cmhL2R_TRA_Disabled(entityId);
271 }
272 else
273 {
274 /* action already initiated in psa_l2r */
275 /* cmhL2R_Deactivate(); */
276 #ifdef FF_PSI
277 if (entityId EQ DTI_ENTITY_PSI)
278 BITFIELD_CLEAR (srcInfos_psi->data_cntr, UART_DTI_SB_BIT);
279 else
280 #endif /*FF_PSI*/
281 BITFIELD_CLEAR (srcInfos->data_cntr, UART_DTI_SB_BIT);
282 }
283
284 if (dti_cntrl_is_dti_id_to_reconnect(dti_id))
285 {
286 T_DTI_ENTITY_ID entity_list[] = {DTI_ENTITY_ACI};
287 dti_cntrl_clear_dti_id_to_reconnect(dti_id);
288 #ifdef FF_PSI
289 if (entityId EQ DTI_ENTITY_PSI)
290 dti_cntrl_est_dpath_indirect ( info.src_id,
291 entity_list,
292 1,
293 SPLIT,
294 atiPSI_dti_cb,
295 DTI_CPBLTY_CMD,
296 DTI_CID_NOTPRESENT);
297
298 else
299 #endif /*FF_PSI*/
300 dti_cntrl_est_dpath_indirect ( info.src_id,
301 entity_list,
302 1,
303 SPLIT,
304 atiUART_dti_cb,
305 DTI_CPBLTY_CMD,
306 DTI_CID_NOTPRESENT);
307 }
308
309 break;
310
311 case(DTI_CONN_STATE_CONNECTING):
312 case(DTI_CONN_STATE_DISCONNECTING):
313 break;
314 case(DTI_CONN_STATE_ERROR):
315 dti_cntrl_close_dpath_from_dti_id( dti_id );
316 break;
317
318 default:
319 TRACE_EVENT("L2R_connect_dti_cb call with not awaited value");
320 break;
321 }
322 return TRUE;
323 }
324 #endif /* DTI */
325
326 /*
327 +--------------------------------------------------------------------+
328 | PROJECT : GSM-F&D (8411) MODULE : CMH_L2RR |
329 | STATE : code ROUTINE : TRA_connect_dti_cb |
330 +--------------------------------------------------------------------+
331
332 PURPOSE : Callback for connection between TRA and UART.
333
334 */
335
336 #ifdef DTI
337 GLOBAL BOOL TRA_connect_dti_cb(UBYTE dti_id, T_DTI_CONN_STATE result_type)
338 {
339 T_ACI_DTI_PRC *srcInfos;
340 #ifdef FF_PSI
341 T_ACI_DTI_PRC_PSI *srcInfos_psi;
342 #endif /*FF_PSI*/
343 T_DTI_ENTITY_ID entityId = DTI_ENTITY_UART;
344 T_DTI_CNTRL info;
345
346 TRACE_FUNCTION("TRA_connect_dti_cb");
347
348
349 if (dti_cntrl_get_info_from_dti_id( dti_id, &info) EQ FALSE)
350 {
351 TRACE_EVENT_P1("cannot find info for dti_id=%d", dti_id);
352 return FALSE;
353 }
354
355 if ((srcInfos = find_element (uart_src_params, info.src_id, cmhUARTtest_srcId)) NEQ NULL)
356 entityId = DTI_ENTITY_UART;
357 #if defined (FF_PSI) AND defined (DTI)
358 if((srcInfos_psi= find_element (psi_src_params, info.src_id, cmhPSItest_srcId)) NEQ NULL)
359 entityId = DTI_ENTITY_PSI;
360 else if (srcInfos EQ NULL AND srcInfos_psi EQ NULL)
361 #else
362 else if (srcInfos EQ NULL)
363 #endif /*FF_PSI*/
364 {
365 TRACE_EVENT_P1 ("[ERR] TRA_connect_dti_cb: srcId=%d not found", info.src_id);
366 return FALSE;
367 }
368
369 switch( result_type)
370 {
371 case(DTI_CONN_STATE_CONNECTED):
372 cmhL2R_TRA_Enabled();
373 break;
374
375 case(DTI_CONN_STATE_DISCONNECTED):
376
377 dti_cntrl_clear_conn_parms( dti_id );
378
379 if (raEntStat.isTempDisconnected)
380 {
381 #ifdef FF_PSI
382 if (entityId EQ DTI_ENTITY_PSI)
383 BITFIELD_SET (srcInfos_psi->data_cntr, UART_DTI_SB_BIT);
384 else
385 #endif /*FF_PSI*/
386 BITFIELD_SET (srcInfos->data_cntr, UART_DTI_SB_BIT);
387 raEntStat.isTempDisconnected = FALSE;
388 cmhL2R_TRA_Disabled(entityId);
389 }
390 else
391 {
392 #ifdef FF_PSI
393 if (entityId EQ DTI_ENTITY_PSI)
394 BITFIELD_CLEAR (srcInfos_psi->data_cntr, UART_DTI_SB_BIT);
395 else
396 #endif /*FF_PSI*/
397 BITFIELD_CLEAR (srcInfos->data_cntr, UART_DTI_SB_BIT);
398 /* psaTRA_Deactivate(); */ /* This is done in psa_trap later, otherwise TRA will crash! */
399 }
400 break;
401
402 case(DTI_CONN_STATE_CONNECTING):
403 case(DTI_CONN_STATE_DISCONNECTING):
404 break;
405 case(DTI_CONN_STATE_ERROR):
406 dti_cntrl_close_dpath_from_dti_id( dti_id );
407 break;
408
409 default:
410 TRACE_EVENT("TRA_connect_dti_cb call with not awaited value");
411 break;
412 }
413 return TRUE;
414 }
415 #endif /* DTI */
416
417 /*==== EOF ========================================================*/
418