comparison g23m-aci/aci/psa_uartp.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 (6147)
4 | Modul : PSA_UARTP
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 processing functions for the
18 | primitives sent to the protocol stack adapter by the DTI
19 | interface.
20 +-----------------------------------------------------------------------------
21 */
22
23 #include "config.h"
24 #include "fixedconf.h"
25 #include "condat-features.h"
26 #include "aci_conf.h"
27
28 #ifdef UART
29
30 #ifndef PSA_UARTP_C
31 #define PSA_UARTP_C
32 #endif
33
34 #include "aci_all.h"
35
36 /*==== INCLUDES ===================================================*/
37 #include "aci_cmh.h"
38 #include "ati_cmd.h"
39 #include "aci_cmd.h"
40 #include "dti.h" /* functionality of the dti library */
41
42 #include "aci.h"
43 #include "aci_lst.h"
44
45 #include "dti_conn_mng.h"
46 #include "dti_cntrl_mng.h"
47 #include "psa_uart.h"
48 #include "ati_io.h"
49 #include "cmh_uart.h"
50
51 #include "aci_mem.h"
52
53 #include "ati_src_uart.h"
54
55 #include "sap_dti.h"
56
57 /*==== CONSTANTS ==================================================*/
58
59
60 /*==== TYPES ======================================================*/
61
62
63 /*==== EXPORT =====================================================*/
64
65 EXTERN void cmhUART_erase_elem_received_cmd (UBYTE srcId);
66
67 /*==== VARIABLES ==================================================*/
68
69 /*==== FUNCTIONS ==================================================*/
70
71 /* for tracing of establishing of CMD channels for dual port version */
72 #ifdef RMV_15_04_03
73 CHAR gob_tst_buf[80];
74 #endif
75
76 /********** UART related primitives *************************/
77
78 /*
79 +-------------------------------------------------------------------+
80 | PROJECT : GSM-PS (6147) MODULE : PSA_UART |
81 | ROUTINE : psa_uart_parameters_cnf |
82 +-------------------------------------------------------------------+
83
84 PURPOSE : .
85
86 */
87
88 GLOBAL void psa_uart_parameters_cnf( T_UART_PARAMETERS_CNF *uart_parameters_cnf )
89 {
90 TRACE_FUNCTION("psa_uart_parameters_cnf");
91
92 cmhUART_ParmsUpdated( uart_parameters_cnf->device );
93
94 PFREE(uart_parameters_cnf);
95 }
96
97
98 /*
99 +-------------------------------------------------------------------+
100 | PROJECT : GSM-PS (6147) MODULE : PSA_UART |
101 | ROUTINE : psa_uart_parameters_ind |
102 +-------------------------------------------------------------------+
103
104 PURPOSE : .
105
106 TODO: set uart_instances parameter for aci here..
107
108 */
109
110 GLOBAL void psa_uart_parameters_ind( T_UART_PARAMETERS_IND *uart_parameters_ind )
111 {
112 UBYTE i;
113 UBYTE srcId;
114
115 TRACE_FUNCTION("psa_uart_parameters_ind");
116
117 /* for tracing of establishing of CMD channels for dual port version */
118 #ifdef RMV_15_04_03
119 memset (gob_tst_buf, 0, 80);
120 sprintf(gob_tst_buf+strlen(gob_tst_buf), "pi:%d ", uart_parameters_ind->uart_instances);
121 #endif
122
123 /*FF_ATI*/
124 for (i=0;i<uart_parameters_ind->uart_instances;i++)
125 {
126 srcId = uart_new_source (i, UART_DLCI_NOT_MULTIPLEXED);
127 cmhUART_startConnection (srcId, DEVICE_TYPE_URT);
128 }
129
130 PFREE(uart_parameters_ind);
131
132 #if defined (RMV_01_04_03) AND defined (DTI)
133 {
134 /* this is the same as AT%DATA=2,"UART",1,,"SER","UART",0, which is issued by RIL */
135 BOOL rv = dti_cntrl_set_redirect_from_device ((UBYTE)DTI_MODE_PERM,
136 DTI_ENTITY_UART,
137 1,
138 0,
139 DTI_ENTITY_UART,
140 0,
141 0,
142 DTI_CPBLTY_SER,
143 0);
144
145 if (rv EQ TRUE)
146 {
147 TRACE_EVENT("dti_cntrl_set_redirect_from_device returned TRUE");
148 }
149 else
150 {
151 TRACE_EVENT("dti_cntrl_set_redirect_from_device returned FALSE");
152 }
153 }
154 #endif
155 }
156
157
158
159
160 /*
161 +-------------------------------------------------------------------+
162 | PROJECT : GSM-PS (6147) MODULE : PSA_UART |
163 | ROUTINE : psa_uart_dti_cnf |
164 +-------------------------------------------------------------------+
165
166 PURPOSE : .
167
168 */
169 GLOBAL void psa_uart_dti_cnf( T_UART_DTI_CNF *uart_dti_cnf )
170 {
171 T_ACI_DTI_PRC *src_infos = NULL;
172 T_DTI_CONN_LINK_ID link_id;
173
174 TRACE_FUNCTION("psa_uart_dti_cnf");
175
176 src_infos = cmhUART_find_dlci (uart_src_params,
177 uart_dti_cnf->device,
178 uart_dti_cnf->dlci);
179
180 /* for tracing of establishing of CMD channels for dual port version */
181 #ifdef RMV_15_04_03
182 sprintf(gob_tst_buf+strlen(gob_tst_buf), "utc:%d ", uart_dti_cnf->device);
183 #endif
184
185 if (src_infos == NULL)
186 {
187 TRACE_EVENT ("psa_uart_dti_cnf: src_infos EQ NULL");
188 PFREE(uart_dti_cnf);
189 return;
190 }
191 #ifdef DTI
192 link_id = dti_cntrl_get_link_id( DTI_ENTITY_UART, uart_dti_cnf->device, uart_dti_cnf->dlci );
193
194 if (uart_dti_cnf->dti_conn EQ UART_DISCONNECT_DTI)
195 {
196 /* tell DTI MNG that connection is closed */
197 dti_cntrl_entity_disconnected( link_id, DTI_ENTITY_UART );
198 }
199 else if (uart_dti_cnf->dti_conn EQ UART_CONNECT_DTI)
200 {
201 /* tell DTI MNG that connection is completed */
202 dti_cntrl_entity_connected( link_id, DTI_ENTITY_UART, DTI_OK );
203 }
204 #endif
205 PFREE(uart_dti_cnf);
206 }
207 /*
208 +---------------------------------------------------------------------+
209 | PROJECT : GSM-PS (6147) MODULE : PSA_UART |
210 | ROUTINE : psa_UART_error_IND |
211 +---------------------------------------------------------------------+
212
213 PURPOSE :
214
215 */
216 EXTERN void uart_erase_source( UBYTE srcId );
217
218 GLOBAL void psa_uart_error_ind( T_UART_ERROR_IND *uart_error_ind )
219 {
220 T_ACI_DTI_PRC *cmd;
221 T_DTI_CONN_LINK_ID link_id;
222 CHAR buf[40];
223
224 TRACE_FUNCTION("psa_uart_error_ind");
225
226 /* for tracing of establishing of CMD channels for dual port version */
227 #ifdef RMV_15_04_03
228 sprintf(gob_tst_buf+strlen(gob_tst_buf), "uei ");
229 #endif
230
231 cmd = cmhUART_find_dlci( uart_src_params,
232 uart_error_ind->device,
233 uart_error_ind->dlci);
234 #ifdef DTI
235 switch( uart_error_ind->error )
236 {
237 case( UART_ERROR_NO_CHANNEL ):
238 sprintf(buf, "Channel number %d cannot be created", cmd->srcId);
239 TRACE_EVENT(buf);
240 link_id = dti_cntrl_get_link_id( DTI_ENTITY_UART, uart_error_ind->device, uart_error_ind->dlci );
241
242 /* tell DTI manager that establishment has failed */
243 dti_cntrl_entity_connected( link_id, DTI_ENTITY_UART, DTI_ERROR);
244 break;
245
246 case( UART_ERROR_MUX_ESTABLISH_FAIL ):
247 case( UART_ERROR_MUX_NO_RESPONSE ):
248 default:
249 TRACE_EVENT("UART_ERROR_IND received with cause other than UART_ERROR_NO_CHANNEL");
250 break;
251 }
252 #endif
253 PFREE(uart_error_ind);
254 }
255
256 /*
257 +---------------------------------------------------------------------+
258 | PROJECT : GSM-PS (6147) MODULE :PSA_UART |
259 | ROUTINE : psa_uart_disable_cnf |
260 +---------------------------------------------------------------------+
261
262 PURPOSE :
263
264 */
265
266 GLOBAL void psa_uart_disable_cnf(T_UART_DISABLE_CNF *uart_disable_cnf)
267 {
268 TRACE_FUNCTION("psa_uart_disable_cnf");
269
270 PFREE(uart_disable_cnf);
271 }
272
273 /*
274 +---------------------------------------------------------------------+
275 | PROJECT : GSM-PS (6147) MODULE :PSA_UART |
276 | ROUTINE : psa_uart_ring_cnf |
277 +---------------------------------------------------------------------+
278
279 PURPOSE :
280
281 */
282
283 GLOBAL void psa_uart_ring_cnf(T_UART_RING_CNF *uart_ring_cnf)
284 {
285 T_ACI_DTI_PRC *src_infos = NULL;
286
287 TRACE_FUNCTION("psa_uart_ring_cnf");
288
289 src_infos = cmhUART_find_dlci (uart_src_params,
290 uart_ring_cnf->device,
291 uart_ring_cnf->dlci);
292
293 if (src_infos EQ NULL)
294 {
295 TRACE_EVENT_P2 ("[ERR] psa_uart_ring_cnf: not found: device=%d; dlci=%d",
296 uart_ring_cnf->device, uart_ring_cnf->dlci);
297 }
298 else
299 {
300 BITFIELD_CLEAR (src_infos->data_cntr, UART_RING_RUNNING);
301 }
302 PFREE(uart_ring_cnf);
303 }
304
305 /*
306 +---------------------------------------------------------------------+
307 | PROJECT : GSM-PS (6147) MODULE :PSA_UART |
308 | ROUTINE : psa_uart_dcd_cnf |
309 +---------------------------------------------------------------------+
310
311 PURPOSE :
312
313 */
314
315 GLOBAL void psa_uart_dcd_cnf(T_UART_DCD_CNF *uart_dcd_cnf )
316 {
317 TRACE_FUNCTION("psa_uart_dcd_cnf");
318
319 PFREE(uart_dcd_cnf);
320 }
321 /*
322 +---------------------------------------------------------------------+
323 | PROJECT : GSM-PS (6147) MODULE : PSA_UART |
324 | ROUTINE : psa_uart_escape_cnf |
325 +---------------------------------------------------------------------+
326
327 PURPOSE :
328
329 */
330
331 GLOBAL void psa_uart_escape_cnf(T_UART_ESCAPE_CNF *uart_escape_cnf )
332 {
333 TRACE_FUNCTION("psa_uart_escape_cnf");
334
335 PFREE(uart_escape_cnf);
336 }
337
338
339 /*
340 +---------------------------------------------------------------------+
341 | PROJECT : GSM-PS (6147) MODULE : PSA_UART |
342 | ROUTINE : psa_uart_dti_ind |
343 +---------------------------------------------------------------------+
344
345 PURPOSE :
346
347 this primitive is sent by UART to indicate that a dti-channel has been
348 closed (or opened, theoretically) without previous request from ACI.
349
350 */
351 GLOBAL void psa_uart_dti_ind( T_UART_DTI_IND
352 *uart_dti_ind )
353 {
354 T_DTI_CONN_LINK_ID link_id = DTI_LINK_ID_NOTPRESENT;
355 T_ACI_DTI_PRC *src_infos = NULL;
356
357 TRACE_FUNCTION("psa_uart_dti_ind");
358
359 src_infos = cmhUART_find_dlci (uart_src_params,
360 uart_dti_ind->device,
361 uart_dti_ind->dlci);
362 #ifdef DTI
363 if (src_infos EQ NULL)
364 {
365 TRACE_EVENT_P2 ("[ERR] psa_uart_dti_ind: not found: device=%d; dlci=%d",
366 uart_dti_ind->device, uart_dti_ind->dlci);
367 }
368 else
369 {
370 link_id = dti_cntrl_get_link_id( DTI_ENTITY_UART, uart_dti_ind->device, uart_dti_ind->dlci );
371
372 if (uart_dti_ind->dti_conn EQ UART_DISCONNECT_DTI)
373 {
374 /* tell DTI MNG that connection is closed */
375 dti_cntrl_entity_disconnected( link_id, DTI_ENTITY_UART );
376
377 }
378 else if (uart_dti_ind->dti_conn EQ UART_CONNECT_DTI)
379 {
380 dti_cntrl_entity_connected( link_id, DTI_ENTITY_UART, DTI_OK );
381 }
382 }
383 #endif
384 PFREE(uart_dti_ind);
385 }
386
387 /*
388 +---------------------------------------------------------------------+
389 | PROJECT : GSM-PS (6147) MODULE : PSA_UART |
390 | ROUTINE : psa_uart_detected_ind |
391 +---------------------------------------------------------------------+
392
393 PURPOSE :
394
395 TODO!!!
396
397 */
398
399 GLOBAL void psa_uart_detected_ind(T_UART_DETECTED_IND *uart_detected_ind )
400 {
401 TRACE_FUNCTION("psa_uart_detected_ind()");
402
403 cmhUART_DetectedESC_DTR ( uart_detected_ind->device,
404 uart_detected_ind->dlci,
405 uart_detected_ind->cause );
406
407 PFREE(uart_detected_ind);
408 }
409
410
411 /********* DTI related prims ****************************/
412
413
414
415
416 /*
417 +-------------------------------------------------------------------+
418 | PROJECT : GSM-PS (6147) MODULE : PSA_UART |
419 | ROUTINE : trace_buffer |
420 +-------------------------------------------------------------------+
421
422 PURPOSE :
423
424 */
425 /*
426 LOCAL void trace_buffer (UBYTE *buffer, int len)
427 {
428 char trcBuf[80];
429 char *writeP;
430 int i;
431
432 sprintf (trcBuf, "Buffer Len.: %d", len);
433 TRACE_EVENT (trcBuf);
434
435 writeP = trcBuf;
436 for (i = 0; i < len; i++)
437 {
438 writeP += sprintf (writeP, "%02X ", buffer[i]);
439 }
440 *writeP = '\0';
441 TRACE_EVENT ("===================================================");
442 TRACE_EVENT (trcBuf);
443 TRACE_EVENT ("===================================================");
444 }
445 */
446 /************ MUX related primitives ******************************/
447
448 /*
449 +---------------------------------------------------------------------+
450 | PROJECT : GSM-PS (6147) MODULE :PSA_UART |
451 | ROUTINE : psa_uart_mux_start_cnf |
452 +---------------------------------------------------------------------+
453
454 PURPOSE :
455
456 */
457
458 GLOBAL void psa_uart_mux_start_cnf(T_UART_MUX_START_CNF *uart_mux_start_cnf)
459 {
460 TRACE_FUNCTION("psa_uart_mux_start_cnf");
461
462 PFREE(uart_mux_start_cnf);
463 }
464
465 /*
466 +---------------------------------------------------------------------------------+
467 | PROJECT : GSM-PS (6147) MODULE : PSA_UART |
468 | ROUTINE : psa_uart_mux_dlc_establish_ind |
469 +---------------------------------------------------------------------------------+
470
471 PURPOSE : New dlci channel created... Device multiplexed.
472
473 */
474
475 GLOBAL void psa_uart_mux_dlc_establish_ind
476 ( T_UART_MUX_DLC_ESTABLISH_IND *uart_mux_dlc_establish_ind )
477 {
478 UBYTE srcId;
479 T_ACI_DTI_PRC *cmd;
480 BOOL Need_New_Source;
481
482 TRACE_FUNCTION("psa_uart_mux_dlc_establish_ind");
483
484 /* send response to UART */
485 psaUART_MuxRes(uart_mux_dlc_establish_ind->device,
486 uart_mux_dlc_establish_ind->dlci,
487 uart_mux_dlc_establish_ind->n1);
488
489 /* search if it is the first multiplexed channel to be established for this
490 particular device */
491 cmd = cmhUART_find_dlci (uart_src_params,
492 uart_mux_dlc_establish_ind->device,
493 UART_DLCI_NOT_MULTIPLEXED);
494
495 if (cmd EQ NULL)
496 /* means device has not been found: may (possibly ??) happen if some errors_ind
497 from UART have lead to erasing all previous sources of the device */
498 Need_New_Source = TRUE;
499 else if (cmd->dlci NEQ UART_DLCI_NOT_MULTIPLEXED)
500 /* then a new source is needed
501 (device aready has multiplexed channels) */
502 Need_New_Source = TRUE;
503 else
504 Need_New_Source = FALSE;
505
506 #ifdef DTI
507 /* create new source */
508 if( Need_New_Source )
509 {
510 srcId = uart_new_source( uart_mux_dlc_establish_ind->device,
511 uart_mux_dlc_establish_ind->dlci );
512
513 cmd = find_element (uart_src_params, srcId, cmhUARTtest_srcId);
514 if (cmd EQ NULL)
515 {
516 TRACE_EVENT_P1("[ERR] psa_uart_mux_dlc_establish_ind: "
517 "srcId=%d not found", srcId) ;
518 return ;
519 }
520 /* start new uart dti channel */
521 cmhUART_startConnection (srcId, DEVICE_TYPE_MUX);
522 }
523 else /* use previous one */
524 {
525 T_DTI_ENTITY_ID entity_list[] = {DTI_ENTITY_ACI};
526
527 /*lint -e613 (Warning --Possible use of null pointer) */
528 srcId = cmd->srcId;
529 uart_InitCmdStruct( cmd );
530 cmd->dlci = uart_mux_dlc_establish_ind->dlci;
531 cmd->LineState = LINE_CONNECTING;
532 /*lint +e613 (Warning --Possible use of null pointer) */
533
534 cmhUART_ChangeDeviceType (srcId, DEVICE_TYPE_MUX);
535
536 dti_cntrl_est_dpath_indirect ( srcId,
537 entity_list,
538 1,
539 SPLIT,
540 atiUART_dti_cb,
541 DTI_CPBLTY_CMD,
542 DTI_CID_NOTPRESENT);
543
544 dti_cntrl_change_sub_no(srcId, uart_mux_dlc_establish_ind->dlci);
545 }
546
547 #endif
548
549 PFREE(uart_mux_dlc_establish_ind);
550 }
551
552
553 /*
554 +---------------------------------------------------------------------------------+
555 | PROJECT : GSM-PS (6147) MODULE : PSA_UART |
556 | ROUTINE : psa_uart_mux_dlc_release_ind |
557 +---------------------------------------------------------------------------------+
558
559 PURPOSE :
560
561 */
562 GLOBAL void psa_uart_mux_dlc_release_ind( T_UART_MUX_DLC_RELEASE_IND *uart_mux_dlc_release_ind )
563 {
564 T_ACI_DTI_PRC *cmd;
565 CHAR buf[40];
566
567 TRACE_FUNCTION("psa_uart_mux_dlc_release_ind");
568
569 cmd = cmhUART_find_dlci (uart_src_params,
570 uart_mux_dlc_release_ind->device,
571 uart_mux_dlc_release_ind->dlci);
572
573 sprintf(buf,"Channel number %d cannot be created",cmd->srcId);
574 TRACE_EVENT(buf);
575
576 uart_erase_source (cmd->srcId);
577 cmhUART_erase_elem_received_cmd (cmd->srcId);
578 PFREE(uart_mux_dlc_release_ind);
579 }
580
581 /*
582 +---------------------------------------------------------------------------------+
583 | PROJECT : GSM-PS (6147) MODULE : PSA_UART |
584 | ROUTINE : psa_uart_mux_close_ind |
585 +---------------------------------------------------------------------------------+
586
587 PURPOSE :
588
589 */
590 GLOBAL void psa_uart_mux_close_ind( T_UART_MUX_CLOSE_IND *uart_mux_close_ind )
591 {
592 T_ACI_DTI_PRC *cmd;
593 UBYTE srcId;
594
595 TRACE_FUNCTION("psa_uart_mux_close_ind");
596
597 TRACE_EVENT_P1("MUX closed on device number: %d", uart_mux_close_ind->device);
598
599 do
600 {
601 cmd = cmhUART_find_dlci (uart_src_params,
602 uart_mux_close_ind->device,
603 UART_DLCI_NOT_MULTIPLEXED);
604
605 if( cmd EQ NULL )
606 break;
607
608 TRACE_EVENT_P1("Mux Channel with src id %d was released", cmd->srcId);
609
610 uart_erase_source( cmd->srcId );
611 cmhUART_erase_elem_received_cmd( cmd->srcId );
612
613 } while( TRUE );
614
615
616
617 /* reconnect device to uart in non-MUX mode */
618 srcId = uart_new_source( uart_mux_close_ind->device, UART_DLCI_NOT_MULTIPLEXED );
619
620 /* start uart dti channel */
621 cmhUART_startConnection (srcId, DEVICE_TYPE_URT);
622
623 PFREE(uart_mux_close_ind);
624 }
625
626 #endif /* UART */