comparison src/aci2/aci/cmh_psif.c @ 3:93999a60b835

src/aci2, src/condat2: import of g23m/condat source pieces from TCS211
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 26 Sep 2016 00:29:36 +0000
parents
children
comparison
equal deleted inserted replaced
2:c41a534f33c6 3:93999a60b835
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS (6147)
4 | Modul : CMH_PSIF
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 used by the command
18 | handler for the PSI module.
19 +-----------------------------------------------------------------------------
20 */
21 #ifdef FF_PSI
22
23 #define CMH_PSIF_C
24
25 #include "aci_all.h"
26 /*==== INCLUDES ===================================================*/
27 #include "aci_cmh.h"
28 #include "ati_cmd.h"
29 #include "aci_cmd.h"
30
31 #include "aci_lst.h"
32 #include "aci_io.h"
33
34
35 #ifdef DTI
36 #include "dti.h" /* functionality of the dti library */
37 #include "dti_conn_mng.h"
38 #include "dti_cntrl_mng.h"
39 #endif /* DTI */
40 #include "psa_psi.h"
41 #include "cmh_psi.h"
42
43 #include "aci_mem.h"
44 #ifdef FAX_AND_DATA
45 #include "psa.h"
46 #include "psa_l2r.h"
47 #endif /* FAX_AND_DATA */
48
49
50 GLOBAL T_ACI_LIST *psi_src_params = NULL;
51 GLOBAL T_ACI_LIST *psi_dcb_par = NULL;
52
53
54 /*
55 +--------------------------------------------------------------------+
56 | PROJECT : GSM-F&D (8411) MODULE : |
57 | STATE : code ROUTINE : cmhPSItest_srcId |
58 +--------------------------------------------------------------------+
59
60 PURPOSE : search function for source Id in the structure T_ACI_DTI_PRC_PSI.
61
62 */
63
64 GLOBAL BOOL cmhPSItest_srcId( UBYTE srcId, void *elem)
65 {
66 T_ACI_DTI_PRC_PSI *compared = (T_ACI_DTI_PRC_PSI *)elem;
67
68 if (compared -> srcId EQ srcId )
69 {
70 return TRUE;
71 }
72 else
73 {
74 return FALSE;
75 }
76 }
77
78 #ifdef DTI
79 /*
80 +--------------------------------------------------------------------+
81 | PROJECT : GSM-F&D (8411) MODULE : |
82 | STATE : code ROUTINE : cmhPSI_lst_init |
83 +--------------------------------------------------------------------+
84
85 PURPOSE : initializing of src params list of PSI entity
86
87 */
88 GLOBAL void cmhPSI_lst_init (void)
89 {
90 TRACE_FUNCTION ("cmhPSI_lst_init()");
91 psi_src_params = new_list ();
92
93 if ( !psi_dcb_par )
94 psi_dcb_par = new_list ();
95 }
96
97 /*
98 +--------------------------------------------------------------------+
99 | PROJECT : GSM-F&D (8411) MODULE : ACI_LST |
100 | STATE : code ROUTINE : cmhPSItest_device |
101 +--------------------------------------------------------------------+
102
103 PURPOSE : search function for device number in the structure T_ACI_DTI_PRC_PSI.
104 */
105
106 GLOBAL BOOL cmhPSItest_device (U32 devId, void *elem)
107 {
108 T_ACI_DTI_PRC_PSI *compared = (T_ACI_DTI_PRC_PSI *)elem;
109
110 if (compared ->devId EQ devId )
111 {
112 return TRUE;
113 }
114 else
115 {
116 return FALSE;
117 }
118 }
119
120 /*
121 +-------------------------------------------------------------------+
122 | PROJECT : GSM-PS (6147) MODULE : CMH_PSI |
123 | ROUTINE : cmhPSI_getdata |
124 +-------------------------------------------------------------------+
125
126 PURPOSE : tell DTI that ACI is ready to receive more datas.
127 */
128
129 GLOBAL void cmhPSI_getdata ( T_ACI_CMD_SRC srcId )
130 {
131 TRACE_FUNCTION ("cmhPSI_getdata");
132 psa_psi_DTI_getdata ( (UBYTE)srcId, DTI_ENTITY_PSI);
133
134 }
135
136 /*
137 +--------------------------------------------------------------------+
138 | PROJECT : GSM-F&D (8411) MODULE : |
139 | STATE : code ROUTINE : cmhPSI_find_dlci |
140 +--------------------------------------------------------------------+
141
142 PURPOSE : returns element with corresponding dlci and device.
143
144 If called dlci=UART_DLCI_NOT_MULTIPLEXED (UART entity
145 value for device not multiplexed) then function returns
146 element with corresponding device...
147
148 */
149 GLOBAL T_ACI_DTI_PRC_PSI *cmhPSI_find_dlci (T_ACI_LIST *search_list,
150 U32 devId, UBYTE dlci)
151 {
152 T_ACI_DTI_PRC_PSI *content = NULL;
153
154 if (search_list EQ NULL)
155 return NULL;
156
157 do
158 {
159 content = psi_find_next_element (search_list, content, devId,
160 cmhPSItest_device);
161 if (content EQ NULL)
162 return NULL;
163
164 if( dlci EQ UART_DLCI_NOT_MULTIPLEXED OR
165 content->dlci EQ UART_DLCI_NOT_MULTIPLEXED OR
166 content->dlci EQ dlci)
167 return content;
168 }
169 while (content NEQ NULL);
170
171 return NULL;
172 }
173
174 /*
175 +--------------------------------------------------------------------+
176 | PROJECT : GSM-F&D (8411) MODULE : |
177 | STATE : code ROUTINE : cmhPSI_Line_State_Ind |
178 +--------------------------------------------------------------------+
179
180 PURPOSE : evaluates and processes LINE STATE indications sent by PSI:
181 Escape Sequence Detection
182 DTR_DTR Line drop
183
184 */
185 GLOBAL void cmhPSI_Line_State_Ind (U32 devId, U16 line_state)
186 {
187 #ifdef DTI
188 T_DTI_ENTITY_ID peer_id;
189 T_ACI_DTI_PRC_PSI *src_infos = NULL;
190 T_DTI_ENTITY_ID entity_list[] = {DTI_ENTITY_ACI};
191
192 TRACE_FUNCTION("cmhPSI_Line_State_Ind()");
193
194
195 psiShrdPrm.dtr_clearcall = FALSE;
196
197 src_infos = cmhPSI_find_dlci (psi_src_params, devId, UART_DLCI_NOT_MULTIPLEXED);
198
199
200 if (src_infos EQ NULL)
201 {
202 TRACE_EVENT("[ERR] Wrong dlci");
203 return;
204 }
205
206 /* escape sequence detected */
207 if ((line_state EQ LINE_STD_ESCD_IND) OR
208 ((line_state EQ LINE_STD_DTR_LDR) AND
209 ((psiShrdPrm.dtr_behaviour EQ DTR_BEHAVIOUR_CommandMode) OR
210 (psiShrdPrm.dtr_behaviour EQ DTR_BEHAVIOUR_ClearCall)) ))
211 {
212 peer_id = dti_cntrl_get_peer( DTI_ENTITY_PSI, (UBYTE)(devId&DIO_DEVICE_MASK), UART_DLCI_NOT_MULTIPLEXED );
213
214 if ( (psiShrdPrm.dtr_behaviour EQ DTR_BEHAVIOUR_ClearCall) AND
215 (line_state EQ LINE_STD_DTR_LDR) AND
216 ( (peer_id EQ DTI_ENTITY_TRA)
217 OR (peer_id EQ DTI_ENTITY_L2R)
218 /*OR (peer_id EQ DTI_ENTITY_T30) also changed in cmhUART_DetectedESC_DTR (cmh_uartr.c) by KJF */
219 OR (peer_id EQ DTI_ENTITY_ACI) /* even disconnect if we are currently in CMD-Mode */
220 OR (peer_id EQ DTI_ENTITY_PPPS) /* also drop PPP sessions */
221 OR (peer_id EQ DTI_ENTITY_PPPC)
222 ) )
223
224 {
225 /* this is only for CSD (TRA, L2R, T30) */
226 psiShrdPrm.dtr_clearcall = TRUE;
227 }
228
229 #ifdef FAX_AND_DATA
230 if (peer_id EQ DTI_ENTITY_L2R)
231 {
232 psaL2R_ESC ( src_infos->srcId );
233 }
234 else
235 #endif
236 {
237 dti_cntrl_est_dpath_indirect ( src_infos->srcId,
238 entity_list,
239 1,
240 SPLIT,
241 atiPSI_dti_cb,
242 DTI_CPBLTY_CMD,
243 DTI_CID_NOTPRESENT);
244 }
245 }
246
247 /* DTR line of serial link drops */
248 else if (line_state EQ LINE_STD_DTR_LDR)
249 {
250 if (psiShrdPrm.dtr_behaviour EQ DTR_BEHAVIOUR_Ignore)
251 {
252 TRACE_EVENT("DCE ignores DTR");
253 }
254 else
255 {
256 TRACE_EVENT("[ERR] Wrong dtr_behaviour value");
257 }
258 }
259
260 else
261 {
262 TRACE_EVENT("[ERR] Wrong cause value in PSI_LINE_STATE_IND");
263 }
264 #else
265 TRACE_EVENT("[ERR] DTI DISABLED");
266 #endif /* DTI */
267 }
268
269 /*
270 +--------------------------------------------------------------------+
271 | PROJECT : GSM-F&D (8411) MODULE : ACI_LST |
272 | STATE : code ROUTINE : cmhPSI_erase_elem_received_cmd |
273 +--------------------------------------------------------------------+
274
275 PURPOSE : erase an entry element from the psi_src_params list.
276
277 */
278
279 GLOBAL void cmhPSI_erase_src_elem(UBYTE srcId)
280 {
281 T_ACI_DTI_PRC_PSI *content;
282
283 content = remove_element (psi_src_params, (UBYTE)srcId, cmhPSItest_srcId);
284 ACI_MFREE (content);
285 }
286
287
288 /*
289 +--------------------------------------------------------------------------------------------+
290 | PROJECT : GSM-F&D (8411) MODULE : ACI_URT |
291 | STATE : code ROUTINE : cmhPSI_translateBD_RATE_to_DIO4_BAUD |
292 +--------------------------------------------------------------------------------------------+
293
294 PURPOSE:
295 */
296
297 LOCAL UBYTE cmhPSI_translateBD_RATE_to_DIO4_BAUD ( T_ACI_BD_RATE rate )
298 {
299
300 switch ( rate )
301 {
302 case BD_RATE_AUTO: return (UBYTE) DIO4_BAUD_AUTO;
303 case BD_RATE_75: return (UBYTE) DIO4_BAUD_75;
304 case BD_RATE_150: return (UBYTE) DIO4_BAUD_150;
305 case BD_RATE_300: return (UBYTE) DIO4_BAUD_300;
306 case BD_RATE_600: return (UBYTE) DIO4_BAUD_600;
307 case BD_RATE_1200: return (UBYTE) DIO4_BAUD_1200;
308 case BD_RATE_2400: return (UBYTE) DIO4_BAUD_2400;
309 case BD_RATE_4800: return (UBYTE) DIO4_BAUD_4800;
310 case BD_RATE_7200: return (UBYTE) DIO4_BAUD_7200;
311 case BD_RATE_9600: return (UBYTE) DIO4_BAUD_9600;
312 case BD_RATE_14400: return (UBYTE) DIO4_BAUD_14400;
313 case BD_RATE_19200: return (UBYTE) DIO4_BAUD_19200;
314 case BD_RATE_28800: return (UBYTE) DIO4_BAUD_28800;
315 case BD_RATE_33900: return (UBYTE) DIO4_BAUD_33900;
316 case BD_RATE_38400: return (UBYTE) DIO4_BAUD_38400;
317 case BD_RATE_57600: return (UBYTE) DIO4_BAUD_57600;
318 case BD_RATE_115200: return (UBYTE) DIO4_BAUD_115200;
319 case BD_RATE_203125: return (UBYTE) DIO4_BAUD_203125;
320 case BD_RATE_406250: return (UBYTE) DIO4_BAUD_406250;
321 case BD_RATE_812500: return (UBYTE) DIO4_BAUD_812500;
322 default: return (UBYTE) DIO4_BAUD_NOT_VALID;
323 }
324 }
325
326 /*
327 +-----------------------------------------------------------------------------+
328 | PROJECT : GSM-PS (6147) MODULE : CMH_PSI |
329 | STATE : code ROUTINE : cmhPSI_dcbParFindDevice |
330 +-----------------------------------------------------------------------------+
331
332 PURPOSE: Finding the device entry in the 'psi_dcb_par' table
333
334 */
335 LOCAL BOOL cmhPSI_dcbParFindDevice (U32 criterium, void *elem)
336 {
337 if ( criterium EQ ((T_ACI_DEVICE_DCB_ENTRY *)elem)->devId )
338 return TRUE;
339
340 return FALSE;
341 }
342
343 /*
344 +-----------------------------------------------------------------------------+
345 | PROJECT : GSM-PS (6147) MODULE : CMH_PSI |
346 | STATE : code ROUTINE : cmhPSI_FindAll |
347 +-----------------------------------------------------------------------------+
348
349 PURPOSE: Find every entry
350
351 */
352 LOCAL BOOL cmhPSI_FindAll (U32 criterium, void *elem)
353 {
354 return TRUE;
355 }
356
357 /*
358 +-----------------------------------------------------------------------------+
359 | PROJECT : GSM-PS (6147) MODULE : CMH_PSI |
360 | STATE : code ROUTINE : cmhPSI_getDefaultPSIParameter |
361 +-----------------------------------------------------------------------------+
362
363 PURPOSE: copy default configuration parameter of serial, packet or
364 MUX device in dcb par structure (T_ACI_PSI_DCB_PAR)
365 */
366 LOCAL void cmhPSI_getDefaultPSIParameter(U32 dio_driver_type, T_ACI_PSI_DCB_PAR *dcbPar)
367 {
368 T_DIO_DCB_SER_MUX dcbPar1 =
369 {
370 DIO_TYPE_SER_MUX, /*device_type*/
371 DIO_SLEEP_NOT_CHAN, /*sleep_mode*/
372 (UBYTE)DIO4_BAUD_115200, /*baudrate*/
373 DIO_CF_8N1, /*char_frame*/
374 (UBYTE)DIO_FLOW_RTS_CTS, /*flow_control*/
375 XON_DEFAULT, /*xon*/
376 XOFF_DEFAULT, /*xoff*/
377 ESC_CHAR_DEFAULT, /*esc_char*/
378 DIO_GUARD_PER_NOT_VALID, /*guard_per*/
379 DIO_MODE_SER, /*device_mode*/
380 (UBYTE)DIO_MUX_MODE_NOT_VALID, /*mux_mode*/
381 };
382 T_DIO_DCB_SER dcbPar2 =
383 {
384 DIO_TYPE_SER, /*device_type*/
385 DIO_SLEEP_NOT_CHAN, /*sleep_mode*/
386 (UBYTE)DIO4_BAUD_115200, /*baudrate*/
387 DIO_CF_8N1, /*char_frame*/
388 (UBYTE)DIO_FLOW_RTS_CTS, /*flow_control*/
389 XON_DEFAULT, /*xon*/
390 XOFF_DEFAULT, /*xoff*/
391 ESC_CHAR_DEFAULT, /*esc_char*/
392 DIO_GUARD_PER_NOT_VALID, /*guard_per*/
393 };
394 T_DIO_DCB_PKT dcbPar3 =
395 {
396 DIO_TYPE_PKT, /*device_type*/
397 DIO_SLEEP_NOT_CHAN, /*sleep_mode*/
398 };
399
400 if (dio_driver_type EQ DIO_DATA_SER)
401 {
402 memcpy ((T_DIO_DCB_SER*)&dcbPar->dio_dcb_ser, &dcbPar2, sizeof (T_DIO_DCB_SER));
403 }
404 else if (dio_driver_type EQ DIO_DATA_MUX)
405 {
406 memcpy ((T_DIO_DCB_SER_MUX*)&dcbPar->dio_dcb_ser_mux, &dcbPar1, sizeof (T_DIO_DCB_SER_MUX));
407 }
408 else if (dio_driver_type EQ DIO_DATA_PKT)
409 {
410 memcpy ((T_DIO_DCB_PKT*)&dcbPar->dio_dcb_pkt, &dcbPar3, sizeof (T_DIO_DCB_PKT));
411 }
412 }
413
414 /*
415 +----------------------------------------------------------------------------------+
416 | PROJECT : GSM-PS (6147) MODULE : CMH_PSI |
417 | STATE : code ROUTINE : cmhPSI_AddDeviceToDcbParameter |
418 +----------------------------------------------------------------------------------+
419
420 PURPOSE: add DCB parameter for a new device
421
422 */
423 GLOBAL void cmhPSI_AddDeviceToDcbParameter( U32 devId,U32 dio_driver_type )
424 {
425 T_ACI_DEVICE_DCB_ENTRY *device_entry;
426
427 TRACE_FUNCTION("cmhPSI_AddDeviceToDcbParameter");
428
429 /*
430 * try to find the device
431 */
432 device_entry = psi_find_element(psi_dcb_par, devId, cmhPSI_dcbParFindDevice);
433
434 /*
435 * if the device is new add it to the list
436 */
437 if ( device_entry EQ NULL )
438 {
439 ACI_MALLOC (device_entry, sizeof (T_ACI_DEVICE_DCB_ENTRY));
440
441 device_entry->devId = devId;
442 /*
443 * Default values by adding a new device
444 */
445 cmhPSI_getDefaultPSIParameter(dio_driver_type, &(device_entry->dcbPar));
446
447 insert_list (psi_dcb_par, device_entry);
448 }
449 }
450
451 /*
452 +---------------------------------------------------------------------------------------+
453 | PROJECT : GSM-PS (6147) MODULE : CMH_PSI |
454 | STATE : code ROUTINE : cmhPSI_RemoveDeviceFromDcbParameter |
455 +---------------------------------------------------------------------------------------+
456
457 PURPOSE: remove DCB parameter for a device from 'psi_dcb_par' table
458
459 */
460 GLOBAL void cmhPSI_RemoveDeviceFromDcbParameter( U32 devId )
461 {
462 T_ACI_DEVICE_DCB_ENTRY *device_entry;
463
464 TRACE_FUNCTION("cmhPSI_RemoveDeviceFromDcbParameter()");
465
466 /*
467 * Find the device and remove it.
468 */
469 device_entry = psi_remove_element(psi_dcb_par, devId, cmhPSI_dcbParFindDevice);
470
471 if ( device_entry NEQ NULL )
472 {
473 ACI_MFREE ( device_entry );
474 }
475 }
476
477 /*
478 +---------------------------------------------------------------------------------------+
479 | PROJECT : GSM-PS (6147) MODULE : CMH_PSI |
480 | STATE : code ROUTINE : cmhPSI_CleanDcbParameterList |
481 +---------------------------------------------------------------------------------------+
482
483 PURPOSE: clean the 'psi_dcb_par' table
484
485 */
486 GLOBAL void cmhPSI_CleanDcbParameterList( void )
487 {
488 T_ACI_DEVICE_DCB_ENTRY *device_entry;
489
490 TRACE_FUNCTION("cmhPSI_CleanDcbParameterList ()");
491
492 /*
493 * Find the device and remove it.
494 */
495 while ( NULL NEQ (device_entry = psi_remove_element(psi_dcb_par, 0, cmhPSI_FindAll)) )
496 {
497 ACI_MFREE ( device_entry );
498 }
499 }
500
501 /*
502 +---------------------------------------------------------------------------------+
503 | PROJECT : GSM-PS (6147) MODULE : CMH_PSI |
504 | STATE : code ROUTINE : cmhPSI_GetDcbParOverDevice |
505 +---------------------------------------------------------------------------------+
506
507 PURPOSE: returns the DCB parameter for this device
508
509 */
510 GLOBAL T_ACI_DEVICE_DCB_ENTRY* cmhPSI_GetDcbParOverDevice( U32 devId )
511 {
512 T_ACI_DEVICE_DCB_ENTRY *device_entry;
513
514 TRACE_FUNCTION("cmhPSI_GetDcbParOverDevice ()");
515
516 /*
517 * return DCB parameter for device
518 */
519 device_entry = psi_find_element(psi_dcb_par, devId, cmhPSI_dcbParFindDevice);
520
521 if ( device_entry EQ NULL )
522 {
523 TRACE_EVENT_P1("[ERR] cmhPSI_GetDcbParOverDevice: device=%d not found", devId) ;
524 return NULL;
525 }
526
527 return device_entry;
528 }
529
530
531
532
533 /*
534 +---------------------------------------------------------------------------------+
535 | PROJECT : GSM-PS (6147) MODULE : CMH_PSI |
536 | STATE : code ROUTINE : cmhPSI_GetDeviceParOverSrcID |
537 +---------------------------------------------------------------------------------+
538
539 PURPOSE: returns the DCB parameter for this source ID
540
541 */
542 GLOBAL T_ACI_DEVICE_DCB_ENTRY* cmhPSI_GetDeviceParOverSrcID( UBYTE srcId )
543 {
544 T_ACI_DEVICE_DCB_ENTRY *device_entry;
545 T_ACI_DTI_PRC_PSI *cmd_struct;
546
547 TRACE_FUNCTION("cmhPSI_GetDeviceParOverSrcID ()");
548
549 if( !ati_is_src_type(srcId, ATI_SRC_TYPE_PSI) )
550 {
551 /* not a PSI source */
552 return(NULL);
553 }
554
555 /*
556 * find the device connected to this source ID
557 */
558 cmd_struct = find_element (psi_src_params, srcId, cmhPSItest_srcId);
559
560 if (cmd_struct EQ NULL)
561 {
562 TRACE_EVENT_P1("[ERR] cmhPSI_GetDeviceParOverSrcID: srcId=%d not found", srcId) ;
563 return NULL;
564 }
565
566 /*
567 * return DCB parameter for device
568 */
569 device_entry = psi_find_element(psi_dcb_par, cmd_struct->devId, cmhPSI_dcbParFindDevice);
570
571 if ( device_entry EQ NULL )
572 {
573 TRACE_EVENT_P1("[ERR] cmhPSI_GetDeviceParOverSrcID: device=%d not found", cmd_struct->devId) ;
574 return NULL;
575 }
576
577 return device_entry;
578 }
579
580 /*
581 +---------------------------------------------------------------------------------+
582 | PROJECT : GSM-PS (6147) MODULE : CMH_PSI |
583 | STATE : code ROUTINE : cmhPSI_GetParityOverSrcID |
584 +---------------------------------------------------------------------------------+
585
586 PURPOSE: returns parity for this source ID
587 */
588 GLOBAL UBYTE cmhPSI_GetParityOverSrcID( UBYTE srcId )
589 {
590 T_ACI_DEVICE_DCB_ENTRY *device_entry = cmhPSI_GetDeviceParOverSrcID( srcId );
591 UBYTE parity;
592 U32 character_frame;
593 U32 device_type;
594
595 if ( device_entry EQ NULL )
596 {
597 return UART_IO_PA_NONE;
598 }
599 else
600 {
601 device_type = device_entry->devId & DIO_TYPE_DAT_MASK;
602 if (device_type EQ DIO_DATA_SER)
603 {
604 character_frame = device_entry->dcbPar.dio_dcb_ser.char_frame;
605 }
606 else if (device_type EQ DIO_DATA_MUX)
607 {
608 character_frame = device_entry->dcbPar.dio_dcb_ser_mux.char_frame;
609 }
610 else /*if (device_type EQ DIO_DATA_PKT)*/
611 {
612 return AT_FAIL;
613 }
614
615 switch (character_frame)
616 {
617 case DIO_CF_8N2:
618 case DIO_CF_8N1:
619 case DIO_CF_7N2:
620 case DIO_CF_7N1:
621 default:
622 parity = UART_IO_PA_NONE;
623 break;
624 case DIO_CF_8O1:
625 case DIO_CF_7O1:
626 parity = UART_IO_PA_ODD;
627 break;
628 case DIO_CF_8E1:
629 case DIO_CF_7E1:
630 parity = UART_IO_PA_EVEN;
631 break;
632 case DIO_CF_8S1:
633 case DIO_CF_7S1:
634 case DIO_CF_8M1:
635 case DIO_CF_7M1:
636 parity = UART_IO_PA_SPACE;
637 break;
638 }
639 }
640 return parity;
641 }
642 /*
643 +---------------------------------------------------------------------------------+
644 | PROJECT : GSM-PS (6147) MODULE : CMH_PSI |
645 | STATE : code ROUTINE : cmhPSI_GetDataBitOverSrcID |
646 +---------------------------------------------------------------------------------+
647
648 PURPOSE: returns data bits for this source ID
649 */
650 GLOBAL UBYTE cmhPSI_GetDataBitOverSrcID( UBYTE srcId )
651 {
652 T_ACI_DEVICE_DCB_ENTRY *device_entry = cmhPSI_GetDeviceParOverSrcID( srcId );
653 UBYTE data_bit;
654 U32 character_frame;
655 U32 device_type;
656
657 if ( device_entry EQ NULL )
658 {
659 return UART_IO_BPC_8;
660 }
661 else
662 {
663 device_type = device_entry->devId & DIO_TYPE_DAT_MASK;
664 if (device_type EQ DIO_DATA_SER)
665 {
666 character_frame = device_entry->dcbPar.dio_dcb_ser.char_frame;
667 }
668 else if (device_type EQ DIO_DATA_MUX)
669 {
670 character_frame = device_entry->dcbPar.dio_dcb_ser_mux.char_frame;
671 }
672 else /*if (device_type EQ DIO_DATA_PKT)*/
673 {
674 return AT_FAIL;
675 }
676 switch (character_frame)
677 {
678 case DIO_CF_8N2:
679 case DIO_CF_8N1:
680 case DIO_CF_8S1:
681 case DIO_CF_8O1:
682 case DIO_CF_8E1:
683 case DIO_CF_8M1:
684 default:
685 data_bit = UART_IO_BPC_8;
686 break;
687 case DIO_CF_7N2:
688 case DIO_CF_7N1:
689 case DIO_CF_7O1:
690 case DIO_CF_7E1:
691 case DIO_CF_7S1:
692 case DIO_CF_7M1:
693 data_bit = UART_IO_BPC_7;
694 break;
695 }
696 }
697 return data_bit;
698 }
699 /*
700 +---------------------------------------------------------------------------------+
701 | PROJECT : GSM-PS (6147) MODULE : CMH_PSI |
702 | STATE : code ROUTINE : cmhPSI_GetStopBitOverSrcID |
703 +---------------------------------------------------------------------------------+
704
705 PURPOSE: returns stop bits for this source ID
706 */
707 GLOBAL UBYTE cmhPSI_GetStopBitOverSrcID( UBYTE srcId )
708 {
709 T_ACI_DEVICE_DCB_ENTRY *device_entry = cmhPSI_GetDeviceParOverSrcID( srcId );
710 UBYTE stop_bit;
711 U32 character_frame;
712 U32 device_type;
713 if ( device_entry EQ NULL )
714 {
715 return UART_IO_SB_1;
716 }
717 else
718 {
719 device_type = device_entry->devId & DIO_TYPE_DAT_MASK;
720 if (device_type EQ DIO_DATA_SER)
721 {
722 character_frame = device_entry->dcbPar.dio_dcb_ser.char_frame;
723 }
724 else if (device_type EQ DIO_DATA_MUX)
725 {
726 character_frame = device_entry->dcbPar.dio_dcb_ser_mux.char_frame;
727 }
728 else /*if (device_type EQ DIO_DATA_PKT)*/
729 {
730 return AT_FAIL;
731 }
732 switch (character_frame)
733 {
734 case DIO_CF_8N1:
735 case DIO_CF_8S1:
736 case DIO_CF_8O1:
737 case DIO_CF_8E1:
738 case DIO_CF_8M1:
739 case DIO_CF_7N1:
740 case DIO_CF_7O1:
741 case DIO_CF_7E1:
742 case DIO_CF_7S1:
743 default:
744 stop_bit = UART_IO_SB_1;
745 break;
746 case DIO_CF_8N2:
747 case DIO_CF_7N2:
748 stop_bit = UART_IO_SB_2;
749 break;
750 }
751 }
752 return stop_bit;
753 }
754
755
756 /*
757 +------------------------------------------------------------------------------+
758 | PROJECT : GSM-PS (6147) MODULE : CMH_PSI |
759 | STATE : code ROUTINE : cmhPSI_SetDcbParToUnchanged |
760 +------------------------------------------------------------------------------+
761
762 PURPOSE: set the PSI DCB parameter to unchanged
763
764 */
765 GLOBAL void cmhPSI_SetDcbParToUnchanged( T_ACI_DEVICE_DCB_ENTRY *dcbntry )
766 {
767 U32 device_type;
768 device_type = dcbntry->devId & DIO_TYPE_DAT_MASK;
769 if (device_type EQ DIO_DATA_SER)
770 {
771 dcbntry->dcbPar.dio_dcb_ser.baudrate = DIO4_BAUD_NOT_VALID; /* baud rate */
772 dcbntry->dcbPar.dio_dcb_ser.char_frame = DIO_CF_NOT_VALID; /* bits per character */
773 dcbntry->dcbPar.dio_dcb_ser.flow_control = DIO_FLOW_NOT_VALID; /* flow control mode RX */
774
775 dcbntry->dcbPar.dio_dcb_ser.xon = XON_NOT_VALID;
776 dcbntry->dcbPar.dio_dcb_ser.xoff = XOFF_NOT_VALID;
777 /*
778 * Set escape parameters
779 */
780 dcbntry->dcbPar.dio_dcb_ser.esc_char = ESC_CHAR_NOT_VALID;
781 dcbntry->dcbPar.dio_dcb_ser.guard_period = DIO_GUARD_PER_NOT_VALID;
782 }
783 else if (device_type EQ DIO_DATA_MUX)
784 {
785 dcbntry->dcbPar.dio_dcb_ser_mux.baudrate = DIO4_BAUD_NOT_VALID; /* baud rate */
786 dcbntry->dcbPar.dio_dcb_ser_mux.char_frame = DIO_CF_NOT_VALID; /* bits per character */
787 dcbntry->dcbPar.dio_dcb_ser_mux.flow_control = DIO_FLOW_NOT_VALID; /* flow control mode RX */
788
789 dcbntry->dcbPar.dio_dcb_ser_mux.xon = XON_NOT_VALID;
790 dcbntry->dcbPar.dio_dcb_ser_mux.xoff = XOFF_NOT_VALID;
791 /*
792 * Set escape parameters
793 */
794 dcbntry->dcbPar.dio_dcb_ser_mux.esc_char = ESC_CHAR_NOT_VALID;
795 dcbntry->dcbPar.dio_dcb_ser_mux.guard_period = DIO_GUARD_PER_NOT_VALID;
796 }
797 }
798
799 /*
800 +------------------------------------------------------------------------------+
801 | PROJECT : GSM-PS (6147) MODULE : CMH_PSI |
802 | STATE : code ROUTINE : cmhPSI_SetDataRate |
803 +------------------------------------------------------------------------------+
804
805 PURPOSE: set the PSI data rate
806
807 */
808 GLOBAL T_ACI_RETURN cmhPSI_SetDataRate ( UBYTE srcId, T_ACI_BD_RATE rate)
809 {
810 T_ACI_DEVICE_DCB_ENTRY *device_entry = cmhPSI_GetDeviceParOverSrcID( srcId );
811 U32 device_type;
812
813 if ( device_entry EQ NULL )
814 {
815 TRACE_EVENT_P1("[ERR] cmhPSI_SetDataRate: device for source ID = %d not found", srcId);
816 return AT_FAIL;
817 }
818 device_type = device_entry->devId & DIO_TYPE_DAT_MASK;
819 cmhPSI_SetDcbParToUnchanged( device_entry );
820 if (device_type EQ DIO_DATA_SER)
821 {
822 device_entry->dcbPar.dio_dcb_ser.baudrate = cmhPSI_translateBD_RATE_to_DIO4_BAUD( rate );
823 }
824 else if (device_type EQ DIO_DATA_MUX)
825 {
826 device_entry->dcbPar.dio_dcb_ser_mux.baudrate = cmhPSI_translateBD_RATE_to_DIO4_BAUD( rate );
827 }
828 else /*if (device_type EQ DIO_DATA_PKT)*/
829 {
830 return AT_FAIL;
831 }
832 psaPSI_SetConfReq(device_entry);
833 return AT_EXCT;
834 }
835
836 /*
837 +------------------------------------------------------------------------------+
838 | PROJECT : GSM-PS (6147) MODULE : CMH_PSI |
839 | STATE : code ROUTINE : cmhPSI_SetCharacterFraming |
840 +------------------------------------------------------------------------------+
841
842 PURPOSE: set the PSI character framing
843
844 */
845 GLOBAL T_ACI_RETURN cmhPSI_SetCharacterFraming ( UBYTE srcId,
846 T_ACI_BS_FRM format,
847 T_ACI_BS_PAR parity )
848 {
849 T_ACI_DEVICE_DCB_ENTRY *device_entry = cmhPSI_GetDeviceParOverSrcID( srcId );
850 U32 device_type;
851
852 if ( device_entry EQ NULL )
853 {
854 TRACE_EVENT_P1("[ERR] cmhPSI_SetCharacterFraming: device for source ID = %d not found", srcId);
855 return AT_FAIL;
856 }
857 device_type = device_entry->devId & DIO_TYPE_DAT_MASK;
858 cmhPSI_SetDcbParToUnchanged( device_entry );
859
860 /*
861 * translate AT command parameter to PSI parameter
862 */
863 if (device_type EQ DIO_DATA_SER)
864 {
865 switch (format)
866 {
867 case BS_FRM_NotPresent:
868 break;
869 case BS_FRM_Dat8_Par0_St2:
870 device_entry->dcbPar.dio_dcb_ser.char_frame = DIO_CF_8N2;
871 break;
872 case BS_FRM_Dat8_Par0_St1:
873 device_entry->dcbPar.dio_dcb_ser.char_frame = DIO_CF_8N1;
874 break;
875 case BS_FRM_Dat7_Par0_St2:
876 device_entry->dcbPar.dio_dcb_ser.char_frame = DIO_CF_7N2;
877 break;
878 case BS_FRM_Dat7_Par0_St1:
879 device_entry->dcbPar.dio_dcb_ser.char_frame = DIO_CF_7N1;
880 break;
881 case BS_FRM_Dat8_Par1_St1:
882 break;
883 case BS_FRM_Dat7_Par1_St1:
884 break;
885 default:
886 return AT_FAIL;
887 }
888 if (format EQ BS_FRM_Dat8_Par1_St1 OR format EQ BS_FRM_Dat7_Par1_St1)
889 {
890 switch (parity)
891 {
892 case BS_PAR_NotPresent:
893 /* this case is handled by format translation */
894 break;
895 case BS_PAR_Odd:
896 device_entry->dcbPar.dio_dcb_ser.char_frame =
897 (format EQ BS_FRM_Dat8_Par1_St1 ? DIO_CF_8O1: DIO_CF_7O1);
898 break;
899 case BS_PAR_Even:
900 device_entry->dcbPar.dio_dcb_ser.char_frame =
901 (format EQ BS_FRM_Dat8_Par1_St1 ? DIO_CF_8E1: DIO_CF_7E1);
902 break;
903 case BS_PAR_Mark:
904 device_entry->dcbPar.dio_dcb_ser.char_frame =
905 (format EQ BS_FRM_Dat8_Par1_St1 ? DIO_CF_8M1: DIO_CF_7M1);
906 break;
907 case BS_PAR_Space:
908 device_entry->dcbPar.dio_dcb_ser.char_frame =
909 (format EQ BS_FRM_Dat8_Par1_St1 ? DIO_CF_8S1: DIO_CF_7S1);
910 break;
911 default:
912 return AT_FAIL;
913 }
914 }
915 }
916 else if (device_type EQ DIO_DATA_MUX)
917 {
918 switch (format)
919 {
920 case BS_FRM_NotPresent:
921 break;
922 case BS_FRM_Dat8_Par0_St2:
923 device_entry->dcbPar.dio_dcb_ser_mux.char_frame = DIO_CF_8N2;
924 break;
925 case BS_FRM_Dat8_Par0_St1:
926 device_entry->dcbPar.dio_dcb_ser_mux.char_frame = DIO_CF_8N1;
927 break;
928 case BS_FRM_Dat7_Par0_St2:
929 device_entry->dcbPar.dio_dcb_ser_mux.char_frame = DIO_CF_7N2;
930 break;
931 case BS_FRM_Dat7_Par0_St1:
932 device_entry->dcbPar.dio_dcb_ser_mux.char_frame = DIO_CF_7N1;
933 break;
934 case BS_FRM_Dat8_Par1_St1:
935 break;
936 case BS_FRM_Dat7_Par1_St1:
937 break;
938 default:
939 return AT_FAIL;
940 }
941 if (format EQ BS_FRM_Dat8_Par1_St1 OR format EQ BS_FRM_Dat7_Par1_St1)
942 {
943 switch (parity)
944 {
945 case BS_PAR_NotPresent:
946 /* this case is handled by format translation */
947 break;
948 case BS_PAR_Odd:
949 device_entry->dcbPar.dio_dcb_ser_mux.char_frame =
950 (format EQ BS_FRM_Dat8_Par1_St1 ? DIO_CF_8O1: DIO_CF_7O1);
951 break;
952 case BS_PAR_Even:
953 device_entry->dcbPar.dio_dcb_ser_mux.char_frame =
954 (format EQ BS_FRM_Dat8_Par1_St1 ? DIO_CF_8E1: DIO_CF_7E1);
955 break;
956 case BS_PAR_Mark:
957 device_entry->dcbPar.dio_dcb_ser_mux.char_frame =
958 (format EQ BS_FRM_Dat8_Par1_St1 ? DIO_CF_8M1: DIO_CF_7M1);
959 break;
960 case BS_PAR_Space:
961 device_entry->dcbPar.dio_dcb_ser_mux.char_frame =
962 (format EQ BS_FRM_Dat8_Par1_St1 ? DIO_CF_8S1: DIO_CF_7S1);
963 break;
964 default:
965 return AT_FAIL;
966 }
967 }
968 }
969 psaPSI_SetConfReq(device_entry);
970 return AT_EXCT;
971 }
972
973 /*
974 +------------------------------------------------------------------------------+
975 | PROJECT : GSM-PS (6147) MODULE : CMH_PSI |
976 | STATE : code ROUTINE : cmhPSI_SetFlowControl |
977 +------------------------------------------------------------------------------+
978
979 PURPOSE: set the PSI flow control
980
981 */
982 GLOBAL T_ACI_RETURN cmhPSI_SetFlowControl (UBYTE srcId, T_ACI_RX_FLOW_CTRL DCE_by_DTE)
983 {
984 U32 flow_control = DIO_FLOW_NONE;
985 T_ACI_DEVICE_DCB_ENTRY *device_entry = cmhPSI_GetDeviceParOverSrcID( srcId );
986 U32 device_type;
987
988 if ( device_entry EQ NULL )
989 {
990 TRACE_EVENT_P1("[ERR] cmhPSI_SetFlowControl: device for source ID = %d not found", srcId);
991 return AT_FAIL;
992 }
993 device_type = device_entry->devId & DIO_TYPE_DAT_MASK;
994 /*
995 * translate AT command parameter to PSI parameter
996 */
997 switch ( DCE_by_DTE )
998 {
999 case RX_FLOW_NONE:
1000 flow_control = DIO_FLOW_NONE;
1001 break;
1002 case RX_FLOW_SOFTWARE:
1003 flow_control = DIO_FLOW_XON_XOFF;
1004 break;
1005 case RX_FLOW_HARDWARE:
1006 flow_control = DIO_FLOW_RTS_CTS;
1007 break;
1008 case RX_FLOW_NotPresent:
1009 return AT_CMPL;
1010 }
1011 cmhPSI_SetDcbParToUnchanged( device_entry );
1012
1013 /*
1014 * translate AT command parameter to PSI parameter
1015 */
1016
1017 if (device_type EQ DIO_DATA_SER)
1018 {
1019 device_entry->dcbPar.dio_dcb_ser.flow_control= flow_control;
1020 }
1021 else if (device_type EQ DIO_DATA_MUX)
1022 {
1023 device_entry->dcbPar.dio_dcb_ser_mux.flow_control= flow_control;
1024 }
1025 else /*if (device_type EQ DIO_DATA_PKT)*/
1026 {
1027 return AT_FAIL;
1028 }
1029
1030 psaPSI_SetConfReq(device_entry);
1031
1032 return AT_EXCT;
1033 }
1034
1035
1036 /*
1037 +------------------------------------------------------------------------------+
1038 | PROJECT : GSM-PS (6147) MODULE : CMH_PSI |
1039 | STATE : code ROUTINE : cmhPSI_SetEscape |
1040 +------------------------------------------------------------------------------+
1041
1042 PURPOSE: set the escape request on or off
1043
1044 */
1045
1046 GLOBAL const T_ACI_RETURN cmhPSI_SetEscape( UBYTE srcId, UBYTE detection )
1047 {
1048 T_ACI_DEVICE_DCB_ENTRY *device_entry = cmhPSI_GetDeviceParOverSrcID( srcId );
1049 U32 device_type;
1050
1051 TRACE_FUNCTION("cmhPSI_SetEscape()");
1052
1053 if ( device_entry EQ NULL )
1054 {
1055 TRACE_EVENT_P1("[ERR] cmhPSI_SetEscape: device for source ID = %d not found", srcId);
1056 return AT_FAIL;
1057 }
1058 device_type = device_entry->devId & DIO_TYPE_DAT_MASK;
1059 cmhPSI_SetDcbParToUnchanged( device_entry );
1060
1061 if( detection EQ ESC_DETECTION_OFF)
1062 {
1063 if (device_type EQ DIO_DATA_SER)
1064 {
1065 device_entry->dcbPar.dio_dcb_ser.guard_period= DIO_ESC_OFF;
1066 }
1067 else if (device_type EQ DIO_DATA_MUX)
1068 {
1069 device_entry->dcbPar.dio_dcb_ser_mux.guard_period= DIO_ESC_OFF;
1070 }
1071 else /*if (device_type EQ DIO_DATA_PKT)*/
1072 {
1073 return AT_FAIL;
1074 }
1075 }
1076 psaPSI_SetConfReq(device_entry);
1077
1078 return AT_EXCT;
1079 }
1080
1081 /*
1082 +--------------------------------------------------------------------------------+
1083 | PROJECT : GSM-PS (6147) MODULE : CMH_PSIF |
1084 | STATE : code ROUTINE : cmhPSI_GetFktInterfaceFormat |
1085 +--------------------------------------------------------------------------------+
1086
1087 PURPOSE: translate the PSI DCB parameter to the AT command format parameter
1088
1089 ATTENTION: internal function, DCB paramter is not checking of validity
1090
1091 */
1092 GLOBAL T_ACI_BS_FRM cmhPSI_GetFktInterfaceFormat( T_ACI_DEVICE_DCB_ENTRY *dcbntry )
1093 {
1094 T_ACI_BS_FRM format = BS_FRM_NotPresent;
1095 U32 char_frame = DIO_CF_NOT_VALID;
1096 U32 device_type;
1097
1098 device_type = dcbntry->devId & DIO_TYPE_DAT_MASK;
1099 if (device_type EQ DIO_DATA_SER)
1100 {
1101 char_frame = dcbntry->dcbPar.dio_dcb_ser.char_frame;
1102 }
1103 else if (device_type EQ DIO_DATA_MUX)
1104 {
1105 char_frame = dcbntry->dcbPar.dio_dcb_ser_mux.char_frame;
1106 }
1107 switch (char_frame)
1108 {
1109 case DIO_CF_8N2:
1110 format = BS_FRM_Dat8_Par0_St2;
1111 break;
1112 case DIO_CF_8N1:
1113 format = BS_FRM_Dat8_Par0_St1;
1114 break;
1115 case DIO_CF_7N2:
1116 format = BS_FRM_Dat7_Par0_St2;
1117 break;
1118 case DIO_CF_7N1:
1119 format = BS_FRM_Dat7_Par0_St1;
1120 break;
1121 case DIO_CF_8O1:
1122 case DIO_CF_8E1:
1123 case DIO_CF_8M1:
1124 case DIO_CF_8S1:
1125 format = BS_FRM_Dat8_Par1_St1;
1126 break;
1127 case DIO_CF_7O1:
1128 case DIO_CF_7E1:
1129 case DIO_CF_7M1:
1130 case DIO_CF_7S1:
1131 format = BS_FRM_Dat7_Par1_St1;
1132 break;
1133 default:
1134 break;
1135 }
1136 return format;
1137 }
1138
1139 /*
1140 +--------------------------------------------------------------------------------+
1141 | PROJECT : GSM-PS (6147) MODULE : CMH_PSI |
1142 | STATE : code ROUTINE : cmhUART_GetFktInterfaceParity |
1143 +--------------------------------------------------------------------------------+
1144
1145 PURPOSE: translate the PSI COM parameter to the AT command parity parameter
1146
1147 ATTENTION: internal function, COM paramter is is not checking of validity
1148
1149 */
1150 GLOBAL T_ACI_BS_PAR cmhPSI_GetFktInterfaceParity( T_ACI_DEVICE_DCB_ENTRY *dcbntry )
1151 {
1152 T_ACI_BS_PAR parity = BS_PAR_NotPresent;
1153 U32 char_frame = DIO_CF_NOT_VALID;
1154 U32 device_type;
1155
1156 device_type = dcbntry->devId & DIO_TYPE_DAT_MASK;
1157 if (device_type EQ DIO_DATA_SER)
1158 {
1159 char_frame = dcbntry->dcbPar.dio_dcb_ser.char_frame;
1160 }
1161 else if (device_type EQ DIO_DATA_MUX)
1162 {
1163 char_frame = dcbntry->dcbPar.dio_dcb_ser_mux.char_frame;
1164 }
1165 switch (char_frame)
1166 {
1167 case DIO_CF_8O1:
1168 case DIO_CF_7O1:
1169 parity = BS_PAR_Odd;
1170 break;
1171 case DIO_CF_8E1:
1172 case DIO_CF_7E1:
1173 parity = BS_PAR_Even;
1174 break;
1175 case DIO_CF_8M1:
1176 case DIO_CF_7M1:
1177 parity = BS_PAR_Even;
1178 break;
1179 case DIO_CF_8S1:
1180 case DIO_CF_7S1:
1181 parity = BS_PAR_Space;
1182 break;
1183 default:
1184 break;
1185 }
1186 return parity;
1187 }
1188 #endif /* DTI */
1189 /*
1190 +--------------------------------------------------------------------+
1191 | PROJECT : GSM-F&D (8411) MODULE : ACI_LST |
1192 | STATE : code ROUTINE : cmhPSI_clean_all_elem |
1193 +--------------------------------------------------------------------+
1194
1195 PURPOSE : clean the psi_src_params list.
1196
1197 */
1198
1199 GLOBAL void cmhPSI_clean_all_elem( )
1200 {
1201 T_ACI_DTI_PRC_PSI *psi_src_infos = NULL;
1202
1203 while (1)
1204 {
1205 psi_src_infos = (T_ACI_DTI_PRC_PSI *)remove_first_element(psi_src_params);
1206
1207 if (psi_src_infos EQ NULL)
1208 {
1209 break;
1210 }
1211
1212 if (psi_src_infos->MuxParms NEQ NULL)
1213 {
1214 ACI_MFREE (psi_src_infos->MuxParms);
1215 }
1216 memset (psi_src_infos, 0x00, sizeof(T_ACI_DTI_PRC_PSI));
1217 ACI_MFREE (psi_src_infos);
1218 }
1219
1220
1221
1222 }
1223
1224 #endif /*FF_PSI*/
1225 /*==== EOF =======================================================*/
1226