comparison src/g23m-aci/aci/ati_src_psi.c @ 1:fa8dc04885d8

src/g23m-*: import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:25:50 +0000
parents
children
comparison
equal deleted inserted replaced
0:4e78acac3d88 1:fa8dc04885d8
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS (6147)
4 | Modul : ATI_SRC_UARTC
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 #ifdef FF_PSI
21
22 #define ATI_SRC_PSI_C
23
24
25 #include "aci_all.h"
26 /*==== INCLUDES ===================================================*/
27 #include "aci_cmh.h"
28 #include "ati_cmd.h"
29 #include "aci_cmd.h"
30 #include "dti.h" /* functionality of the dti library */
31
32 #include "aci_lst.h"
33 #include "dti_conn_mng.h"
34 #include "dti_cntrl_mng.h"
35 #include "psa_psi.h"
36 #include "cmh_psi.h"
37 #include "aci_io.h"
38 #include "ati_src_psi.h"
39 #include "aci_mem.h"
40 #include "aci.h"
41 #include "psa.h"
42 #include "cmh.h"
43
44 /*==== CONSTANTS ==================================================*/
45
46 /*==== TYPES ======================================================*/
47
48 /*==== EXPORT =====================================================*/
49
50 #ifdef _SIMULATION_
51 EXTERN T_ACI_LIST *ati_src_list;
52 #endif /* _SIMULATION_ */
53
54 /*==== VARIABLES ==================================================*/
55
56 /*==== FUNCTIONS ==================================================*/
57
58 GLOBAL void psi_InitCmdStruct( T_ACI_DTI_PRC_PSI *cmd_struct )
59 {
60 cmd_struct->devId = 0;
61 cmd_struct->dlci = NOT_PRESENT_8BIT;
62 cmd_struct->RecState = NOT_INITIALIZED;
63 cmd_struct->LineState = LINE_CONNECTING;
64 cmd_struct->run_cmd = FALSE;
65 cmd_struct->first_output = FALSE;
66 cmd_struct->data_cntr = 0;
67 cmd_struct->MuxParms = NULL;
68 cmd_struct->large_type = FALSE;
69 cmd_struct->data_buffer.data_list = NULL;
70 cmd_struct->data_buffer.max_buffer_size = 0;
71 cmd_struct->data_buffer.create_time = 0;
72 cmd_struct->device_type = DEVICE_TYPE_UNKNOWN;
73 #ifdef FF_BAT
74 cmd_struct->active_client = 0xFE; /* BAT control channel */
75 cmd_struct->bat_client = NULL;
76 cmd_struct->max_clients = 0;
77 cmd_struct->queue = NULL; /* queue for pending BAT commands */
78 cmd_struct->send_data = NULL; /* T_desc2 of the control and broadcast cahnnel */
79 cmd_struct->search_str_ptr = NULL; /* search string pointer */
80 #endif /* FF_BAT */
81 }
82
83
84 /*
85 +-------------------------------------------------------------------+
86 | PROJECT : GSM-PS (6147) MODULE : |
87 | ROUTINE : psi_new_source |
88 +-------------------------------------------------------------------+
89
90 PURPOSE : create a new PSI source.
91 In case of BAT (DIO_DATA_PKT), do not create a ATI source.
92 For the phase 2 of the BAT project, where ATI is split fom ACI,
93 we need a psi_new_source() function on ACI level !!!
94 */
95 GLOBAL UBYTE psi_new_source( U32 devId, UBYTE dlci , U32 dio_driver_type) // RM 26-05-04 Nice
96 {
97 T_ACI_DTI_PRC_PSI *cmd_struct;
98 UBYTE src_id;
99
100 TRACE_FUNCTION("psi_new_source()");
101
102 src_id = ati_init(ATI_SRC_TYPE_PSI, psi_src_result_cb, psi_src_line_state_cb);
103
104 #ifdef FF_BAT
105 if (dio_driver_type EQ DIO_DATA_PKT)
106 {
107 /*
108 * we are only interested in getting a src_id for BAT, but not in a ATI source
109 * WHAT HAPPENS WITH THIS SOURCE ID WHEN A REAL ATI SOURCE IS OPENED ?
110 * DO WE HAVE IT THEN TWICE FOR TWO DIFFERENT SOURCES (BAT and ATI) ???
111 */
112
113 #ifndef _SIMULATION_
114 ati_finit(src_id); /* SAVES MEMORY !!!*/
115
116 { /* special SKA hack to make the BAT source marked as used */
117 int i;
118 U8 tst_src;
119
120 for (i = 0; i < CMD_SRC_MAX; i++)
121 {
122 tst_src = (0x01 << i) & used_sources;
123 if (!tst_src)
124 break;
125 }
126 if (tst_src)
127 {
128 TRACE_EVENT_P1("psi_new_source(): No more sources available ! used_sources: 0x%04X", used_sources);
129 return (0);
130 }
131 used_sources |= (0x01 << i);
132 }
133 #endif
134
135 }
136 #endif
137
138 TRACE_EVENT_P1 ("psi_new_source: srcId=%d", src_id);
139
140 ACI_MALLOC (cmd_struct, sizeof(T_ACI_DTI_PRC_PSI));
141
142 psi_InitCmdStruct( cmd_struct );
143
144 cmd_struct->srcId = src_id;
145 cmd_struct->devId = devId;
146 cmd_struct->dlci = dlci;
147
148 /*
149 * Determine the mode of the command source based on the
150 * source ID and 'dio_driver_type'.
151 */
152 if (src_id < CMD_SRC_MAX)
153 {
154 if (src_id EQ CMD_SRC_LCL)
155 {
156 aci_cmd_src_mode_set(src_id,CMD_MODE_ACI);
157 }
158 #ifdef FF_BAT
159 else if (dio_driver_type EQ DIO_DATA_PKT)
160 {
161 aci_cmd_src_mode_set(src_id,CMD_MODE_BAT);
162 sAT_PercentCSQ((T_ACI_CMD_SRC)src_id, CSQ_Enable); /* CSQ indication regular enabled for BAT source */
163 }
164 #endif
165 else
166 {
167 aci_cmd_src_mode_set(src_id,CMD_MODE_ATI);
168 }
169 }
170
171 if (insert_list (psi_src_params, cmd_struct) NEQ TRUE)
172 {
173 TRACE_EVENT ("new source is not able to creat");
174 }
175
176 cmhPSI_AddDeviceToDcbParameter(devId ,dio_driver_type);
177
178 return(src_id);
179 }
180
181
182 /*
183 +-------------------------------------------------------------------+
184 | PROJECT : GSM-PS (6147) MODULE : |
185 | ROUTINE : psi_erase_source |
186 +-------------------------------------------------------------------+
187
188 PURPOSE : erase an entry element from the psi_src_params list.
189 */
190 EXTERN void dti_cntrl_erase_entry(UBYTE dti_id);
191
192 GLOBAL void psi_erase_source( UBYTE srcId )
193 {
194 T_DTI_CNTRL info;
195
196 TRACE_FUNCTION("psi_erase_source");
197
198 ati_finit (srcId);
199
200 dti_cntrl_get_info_from_src_id (srcId, &info);
201
202 dti_cntrl_erase_entry( info.dti_id );
203
204 dti_cntrl_clear_conn_parms( info.dti_id );
205
206 TRACE_EVENT_P1("Source nb %d deleted", srcId);
207
208 }
209
210 /*
211 +-------------------------------------------------------------------+
212 | PROJECT : GSM-PS (6147) MODULE : PSA_PSI |
213 | ROUTINE : atiPSI_dti_cb |
214 +-------------------------------------------------------------------+
215
216 PURPOSE : callback for dti manager.
217
218 */
219 GLOBAL BOOL atiPSI_dti_cb( UBYTE dti_id, T_DTI_CONN_STATE result_type )
220 {
221 #ifdef _SIMULATION_
222 T_ATI_SRC_PARAMS *src_params;
223 #endif /* _SIMULATION_ */
224
225 T_ACI_DTI_PRC_PSI *srcInfos = NULL;
226 UBYTE saveState;
227 BOOL is_psi_src = TRUE; /* for simulation */
228 T_DTI_CNTRL info;
229
230 TRACE_FUNCTION("atiPSI_dti_cb");
231
232
233 if (dti_cntrl_get_info_from_dti_id( dti_id, &info) EQ FALSE)
234 {
235 TRACE_EVENT_P1("cannot find info for dti_id=%d", dti_id);
236 return FALSE;
237 }
238
239 srcInfos = find_element (psi_src_params, info.src_id, cmhPSItest_srcId);
240 if (srcInfos EQ NULL)
241 {
242 TRACE_EVENT_P1 ("[ERR] atiPSI_dti_cb: srcId=%d not found", info.src_id) ;
243 return FALSE ;
244 }
245
246 saveState = srcInfos->LineState;
247
248 #ifdef _SIMULATION_
249 src_params = find_element (ati_src_list, info.src_id, search_ati_src_id);
250 if (src_params EQ NULL)
251 {
252 TRACE_EVENT ("[ERR] SIMULATION: atiPSI_dti_cb: source ID not found");
253 return FALSE;
254 }
255 if (src_params->src_type EQ ATI_SRC_TYPE_TST)
256 {
257 is_psi_src = FALSE;
258 }
259 #endif /* _SIMULATION_ */
260
261 switch(result_type)
262 {
263 /* PSI and ACI connected */
264 case(DTI_CONN_STATE_CONNECTED):
265 /* first set the line state, then care for DCD */
266 srcInfos->LineState = LINE_CONNECTED;
267
268 ati_switch_mode(info.src_id, ATI_CMD_MODE);
269
270 if (saveState EQ LINE_CONNECTING)
271 {
272
273 if (is_psi_src)
274 {
275 /* creation of a new connection: set DCD */
276 io_setDCD ((T_ACI_CMD_SRC)info.src_id, IO_DCD_OFF);
277 }
278
279 #ifndef _SIMULATION_
280 #ifdef FF_BAT
281 if (aci_cmd_src_mode_get((T_ACI_CMD_SRC)info.src_id) NEQ CMD_MODE_BAT)
282 #endif
283 {
284 io_sendMessage (srcInfos->srcId, "AT-Command Interpreter ready",
285 ATI_NORMAL_OUTPUT);
286 }
287 #endif /* _SIMULATION_ */
288 }
289
290 if (is_psi_src)
291 {
292 /* tells PSI that ACI is ready to get some data */
293 cmhPSI_getdata ((T_ACI_CMD_SRC)srcInfos->srcId);
294 }
295 break;
296
297 /* PSI and data entity temporary disconnected */
298 case(DTI_CONN_STATE_CONNECTING):
299 break;
300
301 case(DTI_CONN_STATE_DISCONNECTING):
302 srcInfos->LineState = LINE_TMP_DISCONNECTING;
303 ati_switch_mode(info.src_id, ATI_DATA_MODE);
304 break;
305
306 case(DTI_CONN_STATE_DISCONNECTED):
307 srcInfos->LineState = LINE_TMP_DISCONNECTED;
308 dti_cntrl_clear_conn_parms( dti_id );
309 break;
310
311 case(DTI_CONN_STATE_ERROR):
312 dti_cntrl_close_dpath_from_dti_id( dti_id );
313 break;
314
315 default:
316 break;
317 }
318
319 /* Maybe drop call if DTR is asserted */
320 if (psiShrdPrm.dtr_clearcall EQ TRUE)
321 {
322 T_ACI_RETURN l_ret;
323
324 l_ret = sAT_H((T_ACI_CMD_SRC)info.src_id);
325 if (l_ret NEQ AT_EXCT AND l_ret NEQ AT_CMPL)
326 {
327 psiShrdPrm.dtr_clearcall = FALSE;
328 TRACE_ERROR("DTR-Drop sAT_H() error");
329 }
330 }
331
332 return TRUE;
333 }
334
335 /*
336 +-------------------------------------------------------------------+
337 | PROJECT : GSM-PS (6147) MODULE : CMH_DTIR |
338 | ROUTINE : psi_src_proc_chars |
339 +-------------------------------------------------------------------+
340
341 PURPOSE : Check if characters received are ok, and pack them into the command line.
342 return TRUE if ACI allows more data from DTI.
343 */
344
345 GLOBAL BOOL psi_src_proc_chars ( UBYTE *chars,
346 USHORT len,
347 T_ACI_DTI_PRC_PSI *elem )
348 {
349 if (len >= MAX_CMD_LEN)
350 {
351 TRACE_ERROR ("[ERR] [ATI]: command line too long");
352 return (TRUE);
353 }
354 if ((UBYTE)(elem->run_cmd))
355 {
356 ati_abort (elem->srcId);
357 }
358 else
359 {
360 ati_execute ((UBYTE)(elem->srcId), chars, len);
361 }
362 return (TRUE);
363 }
364
365 #endif /*FF_PSI*/
366 /*==== EOF =======================================================*/
367