comparison src/g23m-aci/aci/psa_uarts.c @ 1:d393cd9bb723

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