comparison gsm-fw/g23m-aci/aci/cmh_uartr.c @ 775:eedbf248bac0

gsm-fw/g23m-aci subtree: initial import from LoCosto source
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 12 Oct 2014 01:45:14 +0000
parents
children c64bfc13292c
comparison
equal deleted inserted replaced
774:40a721fd9854 775:eedbf248bac0
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS (6147)
4 | Modul : CMH_UARTR
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 :
18 +-----------------------------------------------------------------------------
19 */
20
21 #ifdef UART
22
23 #ifndef CMH_UARTR_C
24 #define CMH_UARTR_C
25 #endif
26
27 #include "aci_all.h"
28 /*==== INCLUDES ===================================================*/
29 #include "aci_cmh.h"
30 #include "ati_cmd.h"
31 #include "aci_cmd.h"
32 #include "dti.h" /* functionality of the dti library */
33 #include "dti_conn_mng.h"
34 #include "dti_cntrl_mng.h"
35
36
37 #include "aci_io.h"
38
39 #include "psa_uart.h"
40
41 #include "aci_lst.h"
42 #include "cmh_uart.h"
43 #include "gaci.h"
44
45
46 #include "psa.h"
47 #ifdef FAX_AND_DATA
48 #include "aci_fd.h"
49 #endif
50 #include "cmh.h"
51
52 #include "aci_mem.h"
53
54 #include "psa_l2r.h"
55 #include "cmh_sm.h"
56
57 EXTERN T_ACI_UART_MUX_PARMS holdMuxParms;
58
59 /*==== CONSTANTS ==================================================*/
60
61 /*==== EXPORT =====================================================*/
62
63 /*==== VARIABLES ==================================================*/
64
65 /*==== FUNCTIONS ==================================================*/
66
67 /*
68 +-------------------------------------------------------------------+
69 | PROJECT : GSM-PS (6147) MODULE : PSA_UART |
70 | ROUTINE : cmhUART_ParmsUpdated |
71 +-------------------------------------------------------------------+
72
73 PURPOSE : .
74
75 */
76
77 GLOBAL void cmhUART_ParmsUpdated( UBYTE device )
78 {
79 T_ACI_DTI_PRC *src_infos = NULL;
80 T_ACI_DEVICE_TYPE curr_device_type;
81 T_ACI_UART_MUX_PARMS *MuxParms;
82 T_DTI_ENTITY_ID entity_list[] = {DTI_ENTITY_ACI};
83
84 TRACE_FUNCTION("cmhUART_ParmsUpdated");
85
86 src_infos = cmhUART_find_dlci (uart_src_params,
87 device,
88 UART_DLCI_NOT_MULTIPLEXED);
89
90 if (src_infos EQ NULL)
91 {
92 TRACE_EVENT ("Error: wrong device number");
93 return;
94 }
95
96 curr_device_type = cmhUART_GetDeviceType (src_infos->srcId);
97
98 if (curr_device_type EQ DEVICE_TYPE_URT)
99 {
100 switch ( uartEntcurCmd[src_infos->srcId] )
101 {
102 case AT_CMD_IPR:
103 /* do not send OK: this has been done at the beginning */
104 TRACE_EVENT("IPR successfully processed");
105 break;
106
107 case AT_CMD_ICF:
108 case AT_CMD_IFC:
109 #ifdef FF_FAX
110 case AT_CMD_FLO:
111 #endif
112 R_AT( RAT_OK, (T_ACI_CMD_SRC)src_infos->srcId )( uartEntcurCmd[src_infos->srcId] );
113 break;
114
115 default:
116 #ifdef DTI
117 /* request of a DTI channel to communicate with UART */
118 dti_cntrl_est_dpath_indirect ( src_infos->srcId,
119 entity_list,
120 1,
121 SPLIT,
122 atiUART_dti_cb,
123 DTI_CPBLTY_CMD,
124 DTI_CID_NOTPRESENT);
125 #endif
126 break;
127 }
128 /* reinitialize */
129 uartEntcurCmd[src_infos->srcId] = AT_CMD_NONE;
130 }
131 else if (curr_device_type EQ DEVICE_TYPE_UNKNOWN)
132 {
133 MuxParms = src_infos->MuxParms;
134 if( MuxParms EQ NULL )
135 {
136 TRACE_EVENT("Multiplexer could not be initialized: wrong parameters");
137 return;
138 }
139
140 psaUART_StartMux( device,
141 MuxParms->mode,
142 MuxParms->subset,
143 MuxParms->N1,
144 MuxParms->T1,
145 MuxParms->N2,
146 MuxParms->T2,
147 MuxParms->T3);
148
149 memcpy( (CHAR *)&holdMuxParms, (CHAR *)src_infos->MuxParms, sizeof(T_ACI_UART_MUX_PARMS));
150 ACI_MFREE( MuxParms );
151 src_infos->MuxParms = NULL;
152 }
153 else
154 {
155 TRACE_EVENT("Multiplexer could not be initialized: wrong state");
156 }
157 }
158
159 /*
160 +-------------------------------------------------------------------+
161 | PROJECT : GSM-PS (6147) MODULE : PSA_UART |
162 | ROUTINE : cmhUART_DetectedESC_DTR |
163 +-------------------------------------------------------------------+
164
165 PURPOSE : .
166
167 */
168
169 GLOBAL void cmhUART_DetectedESC_DTR( UBYTE device, UBYTE dlci, UBYTE cause )
170 {
171 T_DTI_ENTITY_ID peer_id;
172
173 T_ACI_DTI_PRC* src_infos = NULL;
174 T_DTI_ENTITY_ID entity_list[] = {DTI_ENTITY_ACI};
175
176 TRACE_FUNCTION("cmhUART_DetectedESC_DTR()");
177
178 uartShrdPrm.dtr_clearcall = FALSE;
179 uartShrdPrm.escape_seq = cause;
180
181 src_infos = cmhUART_find_dlci (uart_src_params,
182 device,
183 dlci);
184
185 if (src_infos EQ NULL)
186 {
187 TRACE_EVENT("[ERR] Wrong dlci");
188 return;
189 }
190
191 /* escape sequence detected */
192 if ((cause EQ UART_DETECT_ESC) OR
193 ((cause EQ UART_DETECT_DTR) AND
194 ((uartShrdPrm.dtr_behaviour EQ DTR_BEHAVIOUR_CommandMode) OR
195 (uartShrdPrm.dtr_behaviour EQ DTR_BEHAVIOUR_ClearCall)) ))
196 {
197 #ifdef DTI
198 peer_id = dti_cntrl_get_peer( DTI_ENTITY_UART, device, dlci );
199 if ( (uartShrdPrm.dtr_behaviour EQ DTR_BEHAVIOUR_ClearCall) AND
200 (cause EQ UART_DETECT_DTR) AND
201 ( (peer_id EQ DTI_ENTITY_TRA)
202 OR (peer_id EQ DTI_ENTITY_L2R)
203 /* OR (peer_id EQ DTI_ENTITY_ACI) don't disconnect if we are currently in CMD-Mode,
204 otherwise this would kill the next call attempt */
205 OR (peer_id EQ DTI_ENTITY_PPPS) /* also drop PPP sessions */
206 OR (peer_id EQ DTI_ENTITY_PPPC)
207 ) )
208 {
209 TRACE_EVENT("uartShrdPrm.dtr_clearcall = TRUE");
210 uartShrdPrm.dtr_clearcall = TRUE; /* this is only for CSD (TRA, L2R) */
211 }
212 /*
213 * Inform the relevant CMH or close the user plane.
214 */
215 switch ( peer_id )
216 {
217
218 #if defined FAX_AND_DATA
219 case ( DTI_ENTITY_L2R ):
220 {
221 psaL2R_ESC ( src_infos->srcId );
222 break;
223 }
224 #endif /* FAX_AND_DATA */
225
226 #if defined GPRS
227 case ( DTI_ENTITY_PPPS ):
228 {
229 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = pdp_context_find_node_from_dti_id ( EXTRACT_DTI_ID( dti_cntrl_get_link_id( DTI_ENTITY_UART, device, dlci ) ) );
230 if( !p_pdp_context_node )
231 {
232 TRACE_EVENT("ERROR: PDP context not defined");
233 return;
234 }
235 cmhSM_deactivateAContext(CMD_SRC_NONE, p_pdp_context_node->cid);
236 break;
237 }
238 #endif /* GPRS */
239 default:
240 {
241 dti_cntrl_est_dpath_indirect ( src_infos->srcId,
242 entity_list,
243 1,
244 SPLIT,
245 atiUART_dti_cb,
246 DTI_CPBLTY_CMD,
247 DTI_CID_NOTPRESENT);
248 break;
249 }
250 }
251 #endif
252 }
253 /* DTR line of serial link drops */
254 else if (cause EQ UART_DETECT_DTR)
255 {
256 if (uartShrdPrm.dtr_behaviour EQ DTR_BEHAVIOUR_Ignore)
257 {
258 TRACE_EVENT("DCE ignores DTR");
259 }
260 else
261 {
262 TRACE_EVENT("[ERR] Wrong dtr_behaviour value");
263 }
264 }
265 else
266 {
267 TRACE_EVENT("[ERR] Wrong cause value in UART_DETECTED_IND");
268 }
269 }
270
271 #endif /* UART */