FreeCalypso > hg > freecalypso-citrine
comparison g23m-aci/aci/psa_uarts.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_UARTS_C | |
31 #define PSA_UARTS_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 #include "dti_conn_mng.h" | |
45 #include "dti_cntrl_mng.h" | |
46 #include "psa_uart.h" | |
47 #include "cmh_uart.h" | |
48 | |
49 #include "aci_mem.h" | |
50 | |
51 #include "aci_io.h" | |
52 | |
53 #include "sap_dti.h" | |
54 | |
55 | |
56 /*==== CONSTANTS ==================================================*/ | |
57 | |
58 | |
59 /*==== TYPES ======================================================*/ | |
60 | |
61 | |
62 /*==== EXPORT =====================================================*/ | |
63 | |
64 /*==== VARIABLES ==================================================*/ | |
65 | |
66 | |
67 /*==== FUNCTIONS ==================================================*/ | |
68 | |
69 LOCAL USHORT get_desc_size (T_desc2 *data) | |
70 { | |
71 USHORT size = 0; | |
72 T_desc2 *next_data; | |
73 | |
74 next_data = data; | |
75 while (next_data NEQ NULL) | |
76 { | |
77 size += next_data->len; | |
78 next_data = (T_desc2*)next_data->next; | |
79 } | |
80 | |
81 return (size); | |
82 } | |
83 | |
84 /* | |
85 +-------------------------------------------------------------------+ | |
86 | PROJECT : GSM-PS (6147) MODULE : PSA_IPA | | |
87 | ROUTINE : psa_dti_data_req | | |
88 +-------------------------------------------------------------------+ | |
89 | |
90 PURPOSE : | |
91 | |
92 */ | |
93 GLOBAL void psaDTI_data_req ( | |
94 T_desc2 *data, | |
95 T_ACI_DTI_PRC *src_infos, | |
96 T_DTI_ENTITY_ID peer_id | |
97 ) | |
98 { | |
99 USHORT data_len = 0; | |
100 | |
101 TRACE_FUNCTION("psaDTI_data_req"); | |
102 | |
103 { | |
104 PALLOC_DESC2(dti_data_ind, DTI2_DATA_IND); | |
105 | |
106 data_len = get_desc_size (data); | |
107 | |
108 dti_data_ind->desc_list2.list_len = data_len; | |
109 dti_data_ind->desc_list2.first = (ULONG)data; | |
110 | |
111 dti_data_ind->parameters.p_id = 0; /*dummy_ubyte; */ | |
112 | |
113 if (BITFIELD_CHECK (src_infos->data_cntr, UART_DTI_FLOW_OFF)) | |
114 dti_data_ind->parameters.st_lines.st_flow = DTI_FLOW_OFF; | |
115 else | |
116 dti_data_ind->parameters.st_lines.st_flow = DTI_FLOW_ON; | |
117 | |
118 if (BITFIELD_CHECK (src_infos->data_cntr, UART_DTI_SB_BIT)) | |
119 { | |
120 TRACE_EVENT("SB is ON"); | |
121 dti_data_ind->parameters.st_lines.st_line_sb = DTI_SB_ON; | |
122 } | |
123 else | |
124 { | |
125 TRACE_EVENT("SB is OFF"); | |
126 dti_data_ind->parameters.st_lines.st_line_sb = DTI_SB_OFF; | |
127 } | |
128 | |
129 dti_data_ind->parameters.st_lines.st_line_sa = DTI_SA_ON; | |
130 dti_data_ind->parameters.st_lines.st_break_len = DTI_BREAK_OFF; | |
131 | |
132 #ifdef DTI | |
133 dti_send_data | |
134 ( | |
135 aci_hDTI, | |
136 src_infos->srcId, | |
137 (UBYTE)peer_id, | |
138 ACI_DTI_DN_CHANNEL, | |
139 dti_data_ind | |
140 ); | |
141 #endif | |
142 } | |
143 } | |
144 | |
145 /* | |
146 +-------------------------------------------------------------------+ | |
147 | PROJECT : GSM-PS (6147) MODULE : PSA_IPA | | |
148 | ROUTINE : psa_dti_getdata_req | | |
149 +-------------------------------------------------------------------+ | |
150 | |
151 PURPOSE : | |
152 | |
153 */ | |
154 | |
155 GLOBAL void psaDTI_getdata( UBYTE src_id, T_DTI_ENTITY_ID peer_id) | |
156 { | |
157 T_ACI_DTI_PRC *src_infos = NULL; | |
158 | |
159 TRACE_FUNCTION("psaDTI_getdata"); | |
160 | |
161 src_infos = find_element (uart_src_params, src_id, cmhUARTtest_srcId); | |
162 if (src_infos EQ NULL) | |
163 { | |
164 TRACE_EVENT_P1("[ERR] psaDTI_getdata: link_id=%d not found", src_id) ; | |
165 return ; | |
166 } | |
167 | |
168 if( src_infos->RecState NEQ RECEIVING) | |
169 { | |
170 src_infos->RecState = READY_REC; | |
171 } | |
172 | |
173 #ifdef DTI | |
174 { | |
175 dti_start | |
176 ( | |
177 aci_hDTI, | |
178 src_id, | |
179 (UBYTE)peer_id, | |
180 ACI_DTI_DN_CHANNEL | |
181 ); | |
182 } | |
183 #endif /* DTI */ | |
184 } | |
185 /* | |
186 +-------------------------------------------------------------------+ | |
187 | PROJECT : GSM-PS (6147) MODULE : PSA_IPA | | |
188 | ROUTINE : psaUART_DCDreq | | |
189 +-------------------------------------------------------------------+ | |
190 | |
191 PURPOSE : | |
192 | |
193 */ | |
194 | |
195 GLOBAL void psaUART_DCDreq( UBYTE c_Id, UBYTE line_state ) | |
196 { | |
197 T_ACI_DTI_PRC *cmd = NULL; | |
198 | |
199 TRACE_FUNCTION("psaUART_DCDreq"); | |
200 | |
201 cmd = find_element (uart_src_params, c_Id, cmhUARTtest_srcId); | |
202 if (cmd EQ NULL) | |
203 { | |
204 TRACE_EVENT_P1("[ERR] psaUART_DCDreq: c_Id=%d not found", c_Id) ; | |
205 return ; | |
206 } | |
207 | |
208 { | |
209 PALLOC( uart_dcd_req, UART_DCD_REQ); | |
210 | |
211 uart_dcd_req -> device = cmd->device; | |
212 uart_dcd_req -> dlci = cmd->dlci; | |
213 if( line_state EQ IO_DCD_ON ) | |
214 { | |
215 uart_dcd_req -> line_state = UART_LINE_ON; | |
216 } | |
217 else if ( line_state EQ IO_DCD_OFF ) | |
218 { | |
219 uart_dcd_req -> line_state = UART_LINE_OFF; | |
220 } | |
221 | |
222 PSENDX( UART, uart_dcd_req ); | |
223 } | |
224 } | |
225 | |
226 /* | |
227 +-------------------------------------------------------------------+ | |
228 | PROJECT : GSM-PS (6147) MODULE : PSA_IPA | | |
229 | ROUTINE : psaUART_ESCAPEreq | | |
230 +-------------------------------------------------------------------+ | |
231 | |
232 PURPOSE : | |
233 | |
234 */ | |
235 | |
236 GLOBAL void psaUART_ESCAPEreq( UBYTE c_Id, UBYTE detection ) | |
237 { | |
238 T_ACI_DTI_PRC *cmd = NULL; | |
239 | |
240 TRACE_FUNCTION("psaUART_ESCAPEreq"); | |
241 | |
242 cmd = find_element (uart_src_params, c_Id, cmhUARTtest_srcId); | |
243 if (cmd EQ NULL) | |
244 { | |
245 TRACE_EVENT_P1("[ERR] psaUART_ESCAPEreq: c_Id=%d not found", c_Id) ; | |
246 return ; | |
247 } | |
248 | |
249 { | |
250 PALLOC( uart_escape_req, UART_ESCAPE_REQ); | |
251 | |
252 uart_escape_req -> device = cmd->device; | |
253 uart_escape_req -> dlci = cmd->dlci; | |
254 uart_escape_req -> detection = detection; | |
255 | |
256 PSENDX( UART, uart_escape_req ); | |
257 } | |
258 } | |
259 | |
260 /* | |
261 +-------------------------------------------------------------------+ | |
262 | PROJECT : GSM-PS (6147) MODULE : PSA_IPA | | |
263 | ROUTINE : psaUART_RINGreq | | |
264 +-------------------------------------------------------------------+ | |
265 | |
266 PURPOSE : | |
267 | |
268 */ | |
269 | |
270 GLOBAL void psaUART_RINGreq( UBYTE c_Id, UBYTE line_state ) | |
271 { | |
272 T_ACI_DTI_PRC *cmd = NULL; | |
273 | |
274 TRACE_FUNCTION("psaUART_RINGreq"); | |
275 | |
276 cmd = find_element (uart_src_params, c_Id, cmhUARTtest_srcId); | |
277 if (cmd EQ NULL) | |
278 { | |
279 TRACE_EVENT_P1("[ERR] psaUART_RINGreq: c_Id=%d not found", c_Id) ; | |
280 return ; | |
281 } | |
282 | |
283 if (BITFIELD_CHECK (cmd->data_cntr, UART_RING_RUNNING)) | |
284 { | |
285 TRACE_EVENT_P2 ("[WRN] psaUART_RINGreq(): no CNF for previous REQ (device: %d; dlci=%d)", | |
286 cmd->device, cmd->dlci); | |
287 return; | |
288 } | |
289 | |
290 /* | |
291 store that UART_RING_REQ was send | |
292 this is important so that the primitive queue in the UART entity not | |
293 overloaded if no PC is connected | |
294 */ | |
295 BITFIELD_SET (cmd->data_cntr, UART_RING_RUNNING); | |
296 | |
297 { | |
298 PALLOC( uart_ring_req, UART_RING_REQ); | |
299 | |
300 uart_ring_req -> device = cmd->device; | |
301 uart_ring_req -> dlci = cmd->dlci; | |
302 if( line_state EQ IO_RING_ON) | |
303 { | |
304 uart_ring_req -> line_state = UART_LINE_ON; | |
305 } | |
306 else if( line_state EQ IO_RING_OFF ) | |
307 { | |
308 uart_ring_req -> line_state = UART_LINE_OFF; | |
309 } | |
310 | |
311 PSENDX( UART, uart_ring_req ); | |
312 } | |
313 } | |
314 | |
315 #ifdef DTI | |
316 /* | |
317 +-------------------------------------------------------------------+ | |
318 | PROJECT : GSM-PS (6147) MODULE : PSA_IPA | | |
319 | ROUTINE : psaUART_SetDTIReq | | |
320 +-------------------------------------------------------------------+ | |
321 | |
322 PURPOSE : | |
323 | |
324 */ | |
325 GLOBAL void psaUART_SetDTIReq( T_DTI_CONN_LINK_ID link_id, T_DTI_ENTITY_ID conn_peer_Id ) | |
326 { | |
327 T_ACI_DTI_PRC *cmd = NULL; | |
328 CHAR *p_ent_name; | |
329 T_DTI_CNTRL info; | |
330 | |
331 /* for tracing of establishing of CMD channels for dual port version */ | |
332 #ifdef RMV_15_04_03 | |
333 extern CHAR gob_tst_buf[]; | |
334 #endif | |
335 | |
336 PALLOC( uart_dti_req, UART_DTI_REQ); | |
337 | |
338 TRACE_FUNCTION("psaUART_SetDTIReq"); | |
339 | |
340 if (dti_cntrl_get_info_from_dti_id( EXTRACT_DTI_ID(link_id), &info) EQ FALSE) | |
341 { | |
342 TRACE_EVENT_P1("cannot find info for dti_id=%d", EXTRACT_DTI_ID(link_id)); | |
343 return; | |
344 } | |
345 | |
346 cmd = find_element (uart_src_params, info.src_id, cmhUARTtest_srcId); | |
347 if (cmd EQ NULL) | |
348 { | |
349 TRACE_EVENT_P1("[ERR] psaUART_SetDTIReq: srcId=%d not found", info.src_id) ; | |
350 return; | |
351 } | |
352 | |
353 if (dti_cntrl_set_conn_parms(link_id, DTI_ENTITY_UART, cmd->device, cmd->dlci) EQ FALSE) | |
354 { | |
355 return; | |
356 } | |
357 | |
358 uart_dti_req -> dti_conn = UART_CONNECT_DTI; | |
359 uart_dti_req -> device = cmd->device; | |
360 uart_dti_req -> dlci = cmd->dlci; | |
361 uart_dti_req -> direction = DTI_CHANNEL_TO_HIGHER_LAYER; | |
362 uart_dti_req -> link_id = link_id; | |
363 | |
364 | |
365 switch( conn_peer_Id ) | |
366 { | |
367 case( DTI_ENTITY_ACI ): | |
368 p_ent_name = &ACI_NAME[0]; | |
369 break; | |
370 case( DTI_ENTITY_L2R ): | |
371 p_ent_name = &L2R_NAME[0]; | |
372 break; | |
373 case( DTI_ENTITY_TRA ): | |
374 p_ent_name = &TRA_NAME[0]; | |
375 break; | |
376 case( DTI_ENTITY_T30 ): | |
377 p_ent_name = &T30_NAME[0]; | |
378 break; | |
379 #ifdef FF_TRACE_OVER_MTST | |
380 case( DTI_ENTITY_MTST): | |
381 p_ent_name = &MTST_NAME[0]; | |
382 break; | |
383 #endif /* FF_TRACE_OVER_MTST */ | |
384 #ifdef GPRS | |
385 case( DTI_ENTITY_PPPS ): | |
386 p_ent_name = &PPP_NAME[0]; | |
387 break; | |
388 #endif /* GPRS */ | |
389 | |
390 default: | |
391 TRACE_EVENT("unknown conn_peer_Id: UART_DTI_REQ not sent"); | |
392 PFREE(uart_dti_req); | |
393 return; | |
394 } | |
395 | |
396 #ifdef GPRS | |
397 #ifdef _SIMULATION_ | |
398 p_ent_name = (CHAR *) 0xfe1234ef; | |
399 #endif /* _SIMULATION_ */ | |
400 #endif /* GPRS */ | |
401 | |
402 /* for tracing of establishing of CMD channels for dual port version */ | |
403 #ifdef RMV_15_04_03 | |
404 sprintf(gob_tst_buf+strlen(gob_tst_buf), "usr:"); | |
405 sprintf(gob_tst_buf+strlen(gob_tst_buf), "%x,%x,%s ",cmd->device, link_id, p_ent_name); | |
406 #endif | |
407 | |
408 uart_dti_req->entity_name = (ULONG)p_ent_name; | |
409 PSENDX( UART, uart_dti_req ); | |
410 } | |
411 #endif | |
412 /* | |
413 +-------------------------------------------------------------------+ | |
414 | PROJECT : GSM-PS (6147) MODULE : PSA_UART | | |
415 | ROUTINE : psaUART_StartMux | | |
416 +-------------------------------------------------------------------+ | |
417 | |
418 PURPOSE : | |
419 | |
420 */ | |
421 | |
422 GLOBAL void psaUART_StartMux( UBYTE device, | |
423 UBYTE mode, | |
424 UBYTE frame_type, | |
425 USHORT N1, | |
426 UBYTE T1, | |
427 UBYTE N2, | |
428 UBYTE T2, | |
429 UBYTE T3 ) | |
430 { | |
431 PALLOC(uart_mux_start_req, UART_MUX_START_REQ); | |
432 | |
433 uart_mux_start_req -> device = device; | |
434 | |
435 uart_mux_start_req -> mode = mode; | |
436 uart_mux_start_req -> frame_type = frame_type; | |
437 | |
438 uart_mux_start_req -> n1 = N1; | |
439 uart_mux_start_req -> t1 = T1; | |
440 uart_mux_start_req -> n2 = N2; | |
441 uart_mux_start_req -> t2 = T2; | |
442 uart_mux_start_req -> t3 = T3; | |
443 | |
444 PSENDX( UART, uart_mux_start_req ); | |
445 } | |
446 | |
447 /* | |
448 +-------------------------------------------------------------------+ | |
449 | PROJECT : GSM-PS (6147) MODULE : PSA_UART | | |
450 | ROUTINE : psaUART_MuxRes | | |
451 +-------------------------------------------------------------------+ | |
452 | |
453 PURPOSE : | |
454 | |
455 */ | |
456 | |
457 GLOBAL void psaUART_MuxRes( UBYTE device, | |
458 UBYTE dlci, | |
459 USHORT N1 ) | |
460 { | |
461 PALLOC(uart_mux_dlc_establish_res, UART_MUX_DLC_ESTABLISH_RES); | |
462 | |
463 uart_mux_dlc_establish_res -> device = device; | |
464 uart_mux_dlc_establish_res -> dlci = dlci; | |
465 uart_mux_dlc_establish_res -> n1 = N1; | |
466 | |
467 PSENDX( UART, uart_mux_dlc_establish_res ); | |
468 } | |
469 | |
470 /* | |
471 +------------------------------------------------------------------------+ | |
472 | PROJECT : GSM-PS (6147) MODULE : PSA_UART | | |
473 | ROUTINE : psaUART_SetParameters | | |
474 +------------------------------------------------------------------------+ | |
475 | |
476 PURPOSE : | |
477 | |
478 */ | |
479 | |
480 GLOBAL void psaUART_SetParameters( UBYTE device, T_comPar *comPar ) | |
481 { | |
482 PALLOC(uart_parameters_req, UART_PARAMETERS_REQ); | |
483 | |
484 uart_parameters_req->device = device; | |
485 | |
486 uart_parameters_req->comPar = *comPar; | |
487 | |
488 PSENDX( UART, uart_parameters_req ); | |
489 } | |
490 | |
491 #endif /* UART */ |