comparison gsm-fw/g23m-aci/aci/psa_psip.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
comparison
equal deleted inserted replaced
774:40a721fd9854 775:eedbf248bac0
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS (6147)
4 | Modul : PSA_PSIP
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 #if defined (FF_PSI) && defined (DTI)
23 #define PSA_PSIP_C
24
25
26 #include "aci_all.h"
27
28 /*==== INCLUDES ===================================================*/
29 #include "aci_cmh.h"
30 #include "ati_cmd.h"
31 #include "dti.h" /* functionality of the dti library */
32
33 #include "aci.h"
34 #include "aci_lst.h"
35
36 #include "dti_conn_mng.h"
37 #include "dti_cntrl_mng.h"
38
39
40 #include "psa_psi.h"
41 #include "cmh_psi.h"
42 #include "ati_src_psi.h"
43 #include "ati_io.h"
44 #include "aci_mem.h"
45 #include "sap_dti.h"
46
47 /*==== CONSTANTS ==================================================*/
48
49
50 /*==== TYPES ======================================================*/
51 GLOBAL T_ACI_LIST *psi_dev_list=NULL;
52
53 /*==== EXPORT =====================================================*/
54
55
56 /*==== VARIABLES ==================================================*/
57
58 /*==== FUNCTIONS ==================================================*/
59
60 /* for tracing of establishing of CMD channels for dual port version */
61
62
63
64 /*
65 +----------------------------------------------------------------------+
66 | PROJECT : GPRS (8441) MODULE : PSA_PSIP |
67 | STATE : finished ROUTINE : find_psi_dev_no |
68 +----------------------------------------------------------------------+
69
70 PURPOSE : search psi device number in psi device list
71 */
72 LOCAL BOOL find_psi_dev_id ( U32 devId, void * elem )
73 {
74 T_ACI_PSI *compared = (T_ACI_PSI *)elem;
75
76 if (compared NEQ NULL)
77 {
78 if (compared->devId EQ devId )
79 {
80 return TRUE;
81 }
82 else
83 {
84 return FALSE;
85 }
86 }
87 else
88 {
89 return FALSE;
90 }
91 }
92
93 #ifdef _SIMULATION_
94 /*
95 +----------------------------------------------------------------------+
96 | PROJECT : GPRS (8441) MODULE : PSA_PSIP |
97 | STATE : finished ROUTINE : mng_psi_dev_list_test |
98 +----------------------------------------------------------------------+
99
100 PURPOSE : manage psi device list
101 */
102 LOCAL BOOL mng_psi_dev_list_test ( T_PSI_CONN_IND_TEST *psi_conn_ind_test )
103 {
104 T_ACI_PSI *msg_ptr = NULL;
105
106 if(psi_dev_list EQ NULL)
107 {/* there is no psi device list */
108 psi_dev_list = new_list();
109 }
110 msg_ptr = psi_find_element(psi_dev_list, psi_conn_ind_test->devId, find_psi_dev_id);
111 if(msg_ptr EQ NULL)
112 {/* added new device */
113 {
114 ACI_MALLOC(msg_ptr,sizeof(T_ACI_PSI));
115 msg_ptr->devId = psi_conn_ind_test->devId;
116 msg_ptr->psi_data_mode = psi_conn_ind_test->psi_data_mode;
117 switch (psi_conn_ind_test->devId & DIO_TYPE_DAT_MASK)
118 {
119 case DIO_DATA_SER:
120 memcpy(&msg_ptr->psi_cap.dio_cap_ser,&psi_conn_ind_test->DIO_CAP_UN.DIO_CAP_SER,
121 sizeof(msg_ptr->psi_cap.dio_cap_ser));
122 break;
123 case DIO_DATA_MUX:
124 memcpy(&msg_ptr->psi_cap.dio_cap_ser_mux, &psi_conn_ind_test->DIO_CAP_UN.DIO_CAP_SER_MUX,
125 sizeof(msg_ptr->psi_cap.dio_cap_ser_mux));
126 break;
127 case DIO_DATA_PKT:
128 memcpy(&msg_ptr->psi_cap.dio_cap_pkt, &psi_conn_ind_test->DIO_CAP_UN.DIO_CAP_PKT,
129 sizeof(msg_ptr->psi_cap.dio_cap_pkt));
130 break;
131 }
132 insert_list(psi_dev_list,msg_ptr);
133 return (TRUE);
134 }
135 }
136 else
137 {/* new DIO capabilities for existing device */
138 return (FALSE);
139 }
140 }
141 #endif /* _SIMULATION_ */
142
143 /*
144 +----------------------------------------------------------------------+
145 | PROJECT : GPRS (8441) MODULE : PSA_PSIP |
146 | STATE : finished ROUTINE : mng_psi_dev_list |
147 +----------------------------------------------------------------------+
148
149 PURPOSE : manage psi device list
150 */
151 LOCAL BOOL mng_psi_dev_list ( T_PSI_CONN_IND *psi_conn_ind )
152 {
153 T_ACI_PSI *msg_ptr = NULL;
154
155 if(psi_dev_list EQ NULL)
156 {/* there is no psi device list */
157 psi_dev_list = new_list();
158 }
159 msg_ptr = psi_find_element(psi_dev_list, psi_conn_ind->devId, find_psi_dev_id);
160 if(msg_ptr EQ NULL)
161 { /* added new device */
162 /* if((psi_conn_ind->dio_cap->data_mode >= DTI_CPBLTY_CMD )
163 AND
164 (psi_conn_ind->dio_cap->data_mode <=(DTI_CPBLTY_CMD|DTI_CPBLTY_PKT|DTI_CPBLTY_SER)))*/
165 {
166 ACI_MALLOC(msg_ptr,sizeof(T_ACI_PSI));
167 msg_ptr->devId = psi_conn_ind->devId;
168 msg_ptr->psi_data_mode = psi_conn_ind->psi_data_mode;
169 switch (psi_conn_ind->devId & DIO_TYPE_DAT_MASK)
170 {
171 case DIO_DATA_SER:
172 if(psi_conn_ind->ptr_DIO_CAP NEQ NULL)
173 {
174 memcpy(&msg_ptr->psi_cap.dio_cap_ser,(T_DIO_CAP_SER *)&(psi_conn_ind->ptr_DIO_CAP),
175 sizeof(msg_ptr->psi_cap.dio_cap_ser));
176 }
177 break;
178 case DIO_DATA_MUX:
179 if(psi_conn_ind->ptr_DIO_CAP NEQ NULL)
180 {
181 memcpy(&msg_ptr->psi_cap.dio_cap_ser_mux, (T_DIO_CAP_SER_MUX *)&(psi_conn_ind->ptr_DIO_CAP),
182 sizeof(msg_ptr->psi_cap.dio_cap_ser_mux));
183 }
184 break;
185 case DIO_DATA_PKT:
186 if(psi_conn_ind->ptr_DIO_CAP NEQ NULL)
187 {
188 memcpy(&msg_ptr->psi_cap.dio_cap_pkt, (T_DIO_CAP_PKT *)&(psi_conn_ind->ptr_DIO_CAP),
189 sizeof(msg_ptr->psi_cap.dio_cap_pkt));
190 }
191 break;
192 }
193 insert_list(psi_dev_list,msg_ptr);
194 return (TRUE);
195 }
196 /* else
197 { neither CMD, SER nor PKT mode
198 return (FALSE);
199 }*/
200 }
201 else
202 {/* new DIO capabilities for existing device */
203 return (FALSE);
204 }
205 }
206
207 /*
208 +--------------------------------------------------------------------+
209 | PROJECT : GPRS (8441) MODULE : PSA_PSIP |
210 | STATE : code ROUTINE : PSI_erase_dev_elem |
211 +--------------------------------------------------------------------+
212
213 PURPOSE : erase an entry element from the psi_dev_list list.
214
215 */
216 LOCAL void PSI_erase_dev_elem(U32 devId)
217 {
218 T_ACI_DTI_PRC_PSI *content;
219 content = psi_remove_element (psi_dev_list, devId, find_psi_dev_id);
220 ACI_MFREE (content);
221 }
222 #ifdef _SIMULATION_
223 /*
224 +----------------------------------------------------------------------+
225 | PROJECT : GPRS (8441) MODULE : PSA_PSI |
226 | STATE : finished ROUTINE : psa_psi_conn_ind_test |
227 +----------------------------------------------------------------------+
228
229 PURPOSE : processes the PSI_CONN_IND_TEST primitive send by PSI.
230 add new device to psi device list, create the ATI source and
231 register the DIO capabilities in ACI
232 */
233
234 GLOBAL const void psa_psi_conn_ind_test ( T_PSI_CONN_IND_TEST *psi_conn_ind_test )
235 {
236 T_ACI_PSI * msg_ptr;
237 UBYTE src_id = 0;
238 U32 dio_cap;
239
240 TRACE_FUNCTION ("psa_psi_conn_ind_test()");
241
242 dio_cap =psi_conn_ind_test->devId & DIO_TYPE_DAT_MASK;
243
244 if(mng_psi_dev_list_test(psi_conn_ind_test) EQ TRUE )
245 {
246 msg_ptr = psi_find_element(psi_dev_list, psi_conn_ind_test->devId, find_psi_dev_id);
247 switch (dio_cap)
248 {
249 case DIO_DATA_SER: /*lint -fallthrough*/
250 case DIO_DATA_MUX: /*lint -fallthrough*/
251 case DIO_DATA_PKT:
252 /* Create a new AT source if driver supports AT commands */
253 if(psi_conn_ind_test->psi_data_mode EQ DRIVER_MODE_AT OR
254 psi_conn_ind_test->psi_data_mode EQ DRIVER_MODE_AT_DATA)
255 {
256 src_id = psi_new_source(psi_conn_ind_test->devId, NOT_PRESENT_8BIT, dio_cap);
257 }
258 cmhPSI_Ind(msg_ptr, src_id,dio_cap);
259 break;
260
261 default:
262 break;
263 }
264 }
265 else
266 {/* second PSI_CONNECT_IND from same device or wrong convergence (mode) in
267 DIO capabilities */
268 psaPSI_ConnRej(psi_conn_ind_test->devId);
269 }
270 /* free the primitive buffer */
271 PFREE (psi_conn_ind_test);
272 }
273 #endif /* _SIMULATION_ */
274 /*
275 +----------------------------------------------------------------------+
276 | PROJECT : GPRS (8441) MODULE : PSA_PSI |
277 | STATE : finished ROUTINE : psa_psi_conn_ind |
278 +----------------------------------------------------------------------+
279
280 PURPOSE : processes the PSI_CONN_IND primitive send by PSI.
281 add new device to psi device list, create the ATI source and
282 register the DIO capabilities in ACI
283 */
284
285 GLOBAL void psa_psi_conn_ind ( T_PSI_CONN_IND *psi_conn_ind )
286 {
287 T_ACI_PSI * msg_ptr;
288 UBYTE src_id = 0;
289 U32 dio_cap;
290
291 TRACE_FUNCTION ("psa_psi_conn_ind()");
292 /* cmhPSI_SetDcbParToUnchanged( device_entry );*/
293
294 dio_cap =psi_conn_ind->devId & DIO_TYPE_DAT_MASK;
295
296 if(mng_psi_dev_list(psi_conn_ind) EQ TRUE )
297 {
298 msg_ptr = psi_find_element(psi_dev_list, psi_conn_ind->devId, find_psi_dev_id);
299 switch (dio_cap)
300 {
301 case DIO_DATA_SER: /*lint -fallthrough*/
302 case DIO_DATA_MUX: /*lint -fallthrough*/
303 case DIO_DATA_PKT:
304 /* Create a new AT source if driver supports AT commands */
305 if(psi_conn_ind->psi_data_mode EQ DRIVER_MODE_AT OR
306 psi_conn_ind->psi_data_mode EQ DRIVER_MODE_AT_DATA)
307 {
308 src_id = psi_new_source(psi_conn_ind->devId, NOT_PRESENT_8BIT, dio_cap);
309 }
310 cmhPSI_Ind(msg_ptr, src_id,dio_cap);
311 break;
312
313 default:
314 break;
315 }
316 }
317 else
318 {/* second PSI_CONNECT_IND from same device or wrong convergence (mode) in
319 DIO capabilities */
320 psaPSI_ConnRej(psi_conn_ind->devId);
321 }
322 /* free the primitive buffer */
323 PFREE (psi_conn_ind);
324 }
325
326
327
328 /*
329 +----------------------------------------------------------------------+
330 | PROJECT : GPRS (8441) MODULE : PSA_PSI |
331 | STATE : finished ROUTINE : psa_psi_dti_close_ind |
332 +----------------------------------------------------------------------+
333
334 PURPOSE : processes the PSI_DTI_CLOSE_IND primitive send by PSI.
335 this indicates the dti disconnection caused by the DIO driver
336 */
337
338 GLOBAL void psa_psi_dti_close_ind( T_PSI_DTI_CLOSE_IND *psi_dti_close_ind )
339 {
340 T_ACI_PSI * msg_ptr;
341
342 TRACE_FUNCTION ("psa_psi_dti_close_ind()");
343
344 msg_ptr = psi_find_element(psi_dev_list, psi_dti_close_ind->devId, find_psi_dev_id);
345 /* if the device_no does not exist in the psi_dev_list
346 the primitive is ignored */
347 if(msg_ptr NEQ NULL)
348 {
349 cmhPSI_DTI_Close(psi_dti_close_ind->devId, PSI_DTI_CLS_IND, psi_dti_close_ind->link_id);
350 }
351 else
352 {
353 TRACE_EVENT ("ERROR: DEVICE NOT FOUND.");
354 }
355 /* free the primitive buffer */
356 PFREE (psi_dti_close_ind);
357 }
358
359 /*
360 +----------------------------------------------------------------------+
361 | PROJECT : GPRS (8441) MODULE : PSA_PSI |
362 | STATE : finished ROUTINE : psa_psi_disconn_ind |
363 +----------------------------------------------------------------------+
364
365 PURPOSE : processes the PSI_DISCONN_IND primitive send by PSI.
366 this indicates the disconnection of data call caused by the DIO driver
367 */
368 GLOBAL void psa_psi_disconn_ind ( T_PSI_DISCONN_IND *psi_disconn_ind )
369 {
370 T_ACI_PSI * msg_ptr;
371 T_ACI_DTI_PRC_PSI *cmd;
372
373 TRACE_FUNCTION ("psa_psi_disconn_ind()");
374
375 msg_ptr = psi_find_element(psi_dev_list, psi_disconn_ind->devId, find_psi_dev_id);
376 cmd = cmhPSI_find_dlci (psi_src_params, psi_disconn_ind->devId,
377 UART_DLCI_NOT_MULTIPLEXED);
378 /* if the device_no does not exist in the psi_dev_list the primitive is ignored */
379 if(msg_ptr NEQ NULL)
380 {
381 /*erase the source*/
382 psi_erase_source( cmd->srcId );
383 /*erase the src element in the <psi_src_params>*/
384 cmhPSI_erase_src_elem (cmd->srcId );
385 /*erase the devie from the device list*/
386 PSI_erase_dev_elem (psi_disconn_ind->devId);
387 }
388 /* free the primitive buffer */
389 PFREE (psi_disconn_ind);
390 }
391
392
393
394 /*
395 +----------------------------------------------------------------------+
396 | PROJECT : GPRS (8441) MODULE : PSA_PSI |
397 | STATE : finished ROUTINE : psa_psi_dti_close_cnf |
398 +----------------------------------------------------------------------+
399
400 PURPOSE : processes the PSI_DTI_CLOSE_CNF primitive sent by PSI.
401 this confirms the dti disconnection requested by PSI_DTI_CLOSE_REQ
402 */
403 GLOBAL void psa_psi_dti_close_cnf ( T_PSI_DTI_CLOSE_CNF *psi_dti_close_cnf )
404 {
405 T_ACI_PSI * msg_ptr;
406
407 TRACE_FUNCTION ("psa_psi_dti_close_cnf()");
408 msg_ptr = psi_find_element(psi_dev_list, psi_dti_close_cnf->devId, find_psi_dev_id);
409 /* if the devId does not exist in the psi_dev_list
410 the primitive is ignored */
411 if(msg_ptr NEQ NULL)
412 {
413 cmhPSI_DTI_Close(psi_dti_close_cnf->devId, PSI_DTI_CLS_CNF, psi_dti_close_cnf->link_id);
414 }
415 /* psaPSI_CloseReq(psi_dti_close_cnf->devId);*/
416 /* free the primitive buffer */
417 PFREE (psi_dti_close_cnf);
418 }
419
420
421 /*
422 +----------------------------------------------------------------------+
423 | PROJECT : GPRS (8441) MODULE : PSA_PSI |
424 | STATE : finished ROUTINE : psa_psi_close_cnf |
425 +----------------------------------------------------------------------+
426
427 PURPOSE : processes the PSI_CLOSE_CNF primitive sent by PSI.
428 this confirms the dti disconnection requested by PSI_CLOSE_REQ
429 */
430 GLOBAL void psa_psi_close_cnf ( T_PSI_CLOSE_CNF *psi_close_cnf )
431 {
432 T_ACI_PSI * msg_ptr;
433 T_ACI_DTI_PRC_PSI *cmd;
434
435 TRACE_FUNCTION ("psa_psi_close_cnf()");
436 msg_ptr = psi_find_element(psi_dev_list, psi_close_cnf->devId, find_psi_dev_id);
437 cmd = cmhPSI_find_dlci (psi_src_params, psi_close_cnf->devId,
438 UART_DLCI_NOT_MULTIPLEXED);
439 /* if the devId does not exist in the psi_dev_list
440 the primitive is ignored */
441 if(msg_ptr NEQ NULL)
442 {
443 /*erase the source*/
444 psi_erase_source( cmd->srcId );
445 /*erase the src element in the <psi_src_params>*/
446 cmhPSI_erase_src_elem (cmd->srcId );
447 /*erase the devie from the device list*/
448 PSI_erase_dev_elem (psi_close_cnf->devId);
449 }
450 /* free the primitive buffer */
451 PFREE (psi_close_cnf);
452 }
453
454
455
456
457 /*
458 +----------------------------------------------------------------------+
459 | PROJECT : GPRS (8441) MODULE : PSA_PSI |
460 | STATE : finished ROUTINE : psa_psi_dti_open_cnf |
461 +----------------------------------------------------------------------+
462
463 PURPOSE : processes the PSI_DTI_OPEN_CNF primitive send by PSI.
464 this confirms the dti connection requested by PSI_DTI_OPEN_REQ
465 */
466 GLOBAL void psa_psi_dti_open_cnf ( T_PSI_DTI_OPEN_CNF *psi_dti_open_cnf )
467 {
468 T_ACI_PSI * msg_ptr;
469
470 TRACE_FUNCTION ("psa_psi_dti_open_cnf()");
471
472 msg_ptr = psi_find_element(psi_dev_list, psi_dti_open_cnf->devId, find_psi_dev_id);
473 /* if the devId does not exist in the psi_dev_list
474 the primitive is ignored */
475 if(msg_ptr NEQ NULL)
476 {
477 switch(psi_dti_open_cnf->cause)
478 {
479 case PSICS_SUCCESS:
480 cmhPSI_DTI_OpenCnf(psi_dti_open_cnf->devId, psi_dti_open_cnf->link_id, DTI_OK);
481 break;
482 case PSICS_INVALID_PARAMS:
483 case PSICS_DISCONNECT:
484 case PSICS_INTERNAL_DRV_ERROR:
485 default:
486 cmhPSI_DTI_OpenCnf(psi_dti_open_cnf->devId, psi_dti_open_cnf->link_id, DTI_ERROR);
487 break;
488 }
489 }
490 /* free the primitive buffer */
491 PFREE (psi_dti_open_cnf);
492 }
493
494
495 /*
496 +----------------------------------------------------------------------+
497 | PROJECT : GPRS (8441) MODULE : PSA_PSI |
498 | STATE : finished ROUTINE : psa_psi_setconf_cnf |
499 +----------------------------------------------------------------------+
500
501 PURPOSE : processes the PSI_DTI_SETCONF_CNF primitive send by PSI.
502 this confirms the changed driver configuration requested
503 by PSI_SETCONF_REQ
504 */
505
506 GLOBAL void psa_psi_setconf_cnf (T_PSI_SETCONF_CNF *psi_setconf_cnf)
507 {
508 TRACE_FUNCTION ("psa_psi_setconf_cnf()");
509 /* free the primitive buffer */
510 PFREE (psi_setconf_cnf);
511 }
512
513
514 /*
515 +---------------------------------------------------------------------+
516 | PROJECT : GSM-PS (6147) MODULE :PSA_PSIP |
517 | ROUTINE : psa_psi_line_state_cnf |
518 +---------------------------------------------------------------------+
519
520 PURPOSE :
521
522 */
523
524 GLOBAL void psa_psi_line_state_cnf(T_PSI_LINE_STATE_CNF *psi_line_state_cnf)
525 {
526 T_ACI_DTI_PRC_PSI *src_infos = NULL;
527
528 TRACE_FUNCTION("psa_psi_line_state_cnf ()");
529
530 src_infos = cmhPSI_find_dlci (psi_src_params, psi_line_state_cnf->devId, UART_DLCI_NOT_MULTIPLEXED);
531
532 if (src_infos EQ NULL)
533 {
534 TRACE_EVENT_P1 ("[ERR] psa_psi_line_state_cnf: not found: device=%d;",psi_line_state_cnf->devId);
535 }
536 else
537 {
538 BITFIELD_CLEAR (src_infos->data_cntr, PSI_RING_RUNNING);
539 }
540
541 PFREE(psi_line_state_cnf);
542 }
543
544 /*
545 +---------------------------------------------------------------------+
546 | PROJECT : GSM-PS (6147) MODULE : PSA_PSIP |
547 | ROUTINE : psa_psi_line_state_ind |
548 +---------------------------------------------------------------------+
549
550 PURPOSE :
551 */
552
553 GLOBAL void psa_psi_line_state_ind(T_PSI_LINE_STATE_IND *psi_line_state_ind )
554 {
555 TRACE_FUNCTION("psa_psi_line_state_ind()");
556
557 cmhPSI_Line_State_Ind ( psi_line_state_ind->devId, psi_line_state_ind->line_state );
558
559 PFREE(psi_line_state_ind);
560 }
561
562 #endif /*FF_PSI*/
563 /*==== EOF =======================================================*/
564