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