comparison src/g23m-aci/uart/uart_kerp.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 :
4 | Modul :
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 modul is part of the entity UART and implements all
18 | functions to handles the incoming primitives as described in
19 | the SDL-documentation (KER-statemachine)
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifndef UART_KERP_C
24 #define UART_KERP_C
25 #endif /* !UART_KERP_C */
26
27 #define ENTITY_UART
28
29 /*==== INCLUDES =============================================================*/
30
31 #ifdef WIN32
32 #include "nucleus.h"
33 #endif /* WIN32 */
34 #include "typedefs.h" /* to get Condat data types */
35 #include "vsi.h" /* to get a lot of macros */
36 #include "macdef.h" /* to get a lot of macros */
37 #include "custom.h"
38 #include "gsm.h" /* to get a lot of macros */
39 #include "cnf_uart.h" /* to get cnf-definitions */
40 #include "mon_uart.h" /* to get mon-definitions */
41 #include "prim.h" /* to get the definitions of used SAP and directions */
42 #ifdef DTILIB
43 #include "dti.h" /* to get dti lib */
44 #endif /* DTILIB */
45 #include "pei.h" /* to get PEI interface */
46 #ifdef FF_MULTI_PORT
47 #include "gsi.h" /* to get definitions of serial driver */
48 #else /* FF_MULTI_PORT */
49 #ifdef _TARGET_
50 #include "uart/serialswitch.h"
51 #include "uart/traceswitch.h"
52 #else /* _TARGET_ */
53 #include "serial_dat.h" /* to get definitions of serial driver */
54 #endif /* _TARGET_ */
55 #endif /* FF_MULTI_PORT */
56 #include "uart.h" /* to get the global entity definitions */
57
58 #include "uart_kerf.h" /* to get ker functions */
59 #include "uart_kers.h" /* to get ker signals */
60 #include "uart_drxs.h" /* to get drx signals */
61 #include "uart_dtxs.h" /* to get dtx signals */
62 #include "uart_rts.h" /* to get rt signals */
63 #ifdef FF_MULTI_PORT
64 #include "uart_prxs.h" /* to get rx signals */
65 #include "uart_ptxs.h" /* to get tx signals */
66 #else /* FF_MULTI_PORT */
67 #include "uart_rxs.h" /* to get rx signals */
68 #include "uart_txs.h" /* to get tx signals */
69 #endif /* FF_MULTI_PORT */
70
71 /*==== CONST ================================================================*/
72
73 /*==== LOCAL VARS ===========================================================*/
74
75 /*==== PRIVATE FUNCTIONS ====================================================*/
76
77 /*==== PUBLIC FUNCTIONS =====================================================*/
78
79
80
81 /*
82 +------------------------------------------------------------------------------
83 | Function : ker_uart_parameters_req
84 +------------------------------------------------------------------------------
85 | Description : Handles the primitive UART_PARAMETERS_REQ
86 |
87 | Parameters : *uart_parameters_req - Ptr to primitive payload
88 |
89 +------------------------------------------------------------------------------
90 */
91 GLOBAL void ker_uart_parameters_req (
92 T_UART_PARAMETERS_REQ *uart_parameters_req)
93 {
94 UBYTE i;
95 T_DLC* dlc;
96
97 TRACE_FUNCTION( "ker_uart_parameters_req" );
98
99 #ifdef UART_RANGE_CHECK
100 if(uart_parameters_req EQ NULL)
101 {
102 TRACE_EVENT("ERROR: uart_parameters_req is NULL");
103 }
104 else if((*((ULONG*)((UBYTE*)uart_parameters_req - sizeof(T_PRIM_HEADER) - 8))) NEQ 0)
105 {
106 TRACE_EVENT_P1("ERROR: uart_parameters_req=%08x is not allocated",
107 uart_parameters_req);
108 }
109 else if(uart_parameters_req->device >= UART_INSTANCES)
110 {
111 TRACE_EVENT_P2("ERROR: device=%d is greater than UART_INSTANCES=%d",
112 uart_parameters_req->device,
113 UART_INSTANCES);
114 }
115 #endif /* UART_RANGE_CHECK */
116
117 /*
118 * set UART instance
119 */
120 uart_data = &uart_data_base[uart_parameters_req->device];
121
122 #ifdef FF_MULTI_PORT
123 /*
124 * set new baud rate
125 */
126 switch (uart_parameters_req->comPar.speed)
127 {
128 case UART_IO_SPEED_AUTO:
129 uart_data->ker.act_dcb.Baud = GSI_BAUD_AUTO;
130 break;
131 case UART_IO_SPEED_75:
132 uart_data->ker.act_dcb.Baud = GSI_BAUD_75;
133 break;
134 case UART_IO_SPEED_150:
135 uart_data->ker.act_dcb.Baud = GSI_BAUD_150;
136 break;
137 case UART_IO_SPEED_300:
138 uart_data->ker.act_dcb.Baud = GSI_BAUD_300;
139 break;
140 case UART_IO_SPEED_600:
141 uart_data->ker.act_dcb.Baud = GSI_BAUD_600;
142 break;
143 case UART_IO_SPEED_1200:
144 uart_data->ker.act_dcb.Baud = GSI_BAUD_1200;
145 break;
146 case UART_IO_SPEED_2400:
147 uart_data->ker.act_dcb.Baud = GSI_BAUD_2400;
148 break;
149 case UART_IO_SPEED_4800:
150 uart_data->ker.act_dcb.Baud = GSI_BAUD_4800;
151 break;
152 case UART_IO_SPEED_7200:
153 uart_data->ker.act_dcb.Baud = GSI_BAUD_7200;
154 break;
155 case UART_IO_SPEED_9600:
156 uart_data->ker.act_dcb.Baud = GSI_BAUD_9600;
157 break;
158 case UART_IO_SPEED_14400:
159 uart_data->ker.act_dcb.Baud = GSI_BAUD_14400;
160 break;
161 case UART_IO_SPEED_19200:
162 uart_data->ker.act_dcb.Baud = GSI_BAUD_19200;
163 break;
164 case UART_IO_SPEED_28800:
165 uart_data->ker.act_dcb.Baud = GSI_BAUD_28800;
166 break;
167 case UART_IO_SPEED_33900:
168 uart_data->ker.act_dcb.Baud = GSI_BAUD_33900;
169 break;
170 case UART_IO_SPEED_38400:
171 uart_data->ker.act_dcb.Baud = GSI_BAUD_38400;
172 break;
173 case UART_IO_SPEED_57600:
174 uart_data->ker.act_dcb.Baud = GSI_BAUD_57600;
175 break;
176 case UART_IO_SPEED_115200:
177 uart_data->ker.act_dcb.Baud = GSI_BAUD_115200;
178 break;
179 case UART_IO_SPEED_203125:
180 uart_data->ker.act_dcb.Baud = GSI_BAUD_203125;
181 break;
182 case UART_IO_SPEED_406250:
183 uart_data->ker.act_dcb.Baud = GSI_BAUD_406250;
184 break;
185 case UART_IO_SPEED_812500:
186 uart_data->ker.act_dcb.Baud = GSI_BAUD_812500;
187 break;
188 case UART_IO_SPEED_UNDEF: /* unchanged */
189 break;
190 default:
191 TRACE_ERROR( "UART_PARAMETERS_REQ: baudrate unexpected" );
192 break;
193 }
194
195 /*
196 * set new bits per character
197 */
198 switch (uart_parameters_req->comPar.bpc)
199 {
200 case UART_IO_BPC_7:
201 uart_data->ker.act_dcb.DataBits = GSI_CHAR7;
202 break;
203 case UART_IO_BPC_8:
204 uart_data->ker.act_dcb.DataBits = GSI_CHAR8;
205 break;
206 case UART_IO_BPC_UNDEF: /* unchanged */
207 break;
208 default:
209 TRACE_ERROR( "UART_PARAMETERS_REQ: bpc unexpected" );
210 break;
211 }
212
213 /*
214 * set new stop bit
215 */
216 switch (uart_parameters_req->comPar.nsb)
217 {
218 case UART_IO_SB_1:
219 uart_data->ker.act_dcb.StopBits = GSI_STOP1;
220 break;
221 case UART_IO_SB_2:
222 uart_data->ker.act_dcb.StopBits = GSI_STOP2;
223 break;
224 case UART_IO_SB_UNDEF: /* unchanged */
225 break;
226 default:
227 TRACE_ERROR( "UART_PARAMETERS_REQ: stop bits unexpected" );
228 break;
229 }
230
231 /*
232 * set new parity
233 */
234 switch (uart_parameters_req->comPar.parity)
235 {
236 case UART_IO_PA_NONE:
237 uart_data->ker.act_dcb.Parity = GSI_PARITYNO;
238 break;
239 case UART_IO_PA_EVEN:
240 uart_data->ker.act_dcb.Parity = GSI_PARITYEVEN;
241 break;
242 case UART_IO_PA_ODD:
243 uart_data->ker.act_dcb.Parity = GSI_PARITYODD;
244 break;
245 case UART_IO_PA_SPACE:
246 uart_data->ker.act_dcb.Parity = GSI_PARITYSPACE;
247 break;
248 case UART_IO_PA_UNDEF: /* unchanged */
249 break;
250 default:
251 TRACE_ERROR( "UART_PARAMETERS_REQ: parity unexpected" );
252 break;
253 }
254
255 /*
256 * set new RX flow control
257 */
258 switch (uart_parameters_req->comPar.flow_rx)
259 {
260 case UART_IO_FC_RX_NONE:
261 uart_data->ker.act_dcb.RxFlowControl = GSI_FLOWNO;
262 break;
263 case UART_IO_FC_RX_RTS:
264 uart_data->ker.act_dcb.RxFlowControl = GSI_FLOWHW;
265 break;
266 case UART_IO_FC_RX_XOFF:
267 uart_data->ker.act_dcb.RxFlowControl = GSI_FLOWSW;
268 break;
269 case UART_IO_FC_RX_UNDEF: /* unchanged */
270 break;
271 default:
272 TRACE_ERROR( "UART_PARAMETERS_REQ: RX flow control unexpected" );
273 break;
274 }
275
276 /*
277 * set new TX flow control
278 */
279 switch (uart_parameters_req->comPar.flow_tx)
280 {
281 case UART_IO_FC_TX_NONE:
282 uart_data->ker.act_dcb.TxFlowControl = GSI_FLOWNO;
283 break;
284 case UART_IO_FC_TX_RTS:
285 uart_data->ker.act_dcb.TxFlowControl = GSI_FLOWHW;
286 break;
287 case UART_IO_FC_TX_XOFF:
288 uart_data->ker.act_dcb.TxFlowControl = GSI_FLOWSW;
289 break;
290 case UART_IO_FC_TX_UNDEF: /* unchanged */
291 break;
292 default:
293 TRACE_ERROR( "UART_PARAMETERS_REQ: TX flow control unexpected" );
294 break;
295 }
296
297 /*
298 * set new XON / XOFF values
299 */
300 if(uart_parameters_req->comPar.xon_valid EQ UART_IO_XON_VALID)
301 uart_data->ker.act_dcb.XON = uart_parameters_req->comPar.xon;
302 if(uart_parameters_req->comPar.xoff_valid EQ UART_IO_XOFF_VALID)
303 uart_data->ker.act_dcb.XOFF = uart_parameters_req->comPar.xoff;
304 #else /* FF_MULTI_PORT */
305 /*
306 * set new baud rate
307 */
308 switch (uart_parameters_req->comPar.speed)
309 {
310 case UART_IO_SPEED_AUTO:
311 uart_data->ker.act_br = UF_BAUD_AUTO;
312 break;
313 case UART_IO_SPEED_75:
314 uart_data->ker.act_br = UF_BAUD_75;
315 break;
316 case UART_IO_SPEED_150:
317 uart_data->ker.act_br = UF_BAUD_150;
318 break;
319 case UART_IO_SPEED_300:
320 uart_data->ker.act_br = UF_BAUD_300;
321 break;
322 case UART_IO_SPEED_600:
323 uart_data->ker.act_br = UF_BAUD_600;
324 break;
325 case UART_IO_SPEED_1200:
326 uart_data->ker.act_br = UF_BAUD_1200;
327 break;
328 case UART_IO_SPEED_2400:
329 uart_data->ker.act_br = UF_BAUD_2400;
330 break;
331 case UART_IO_SPEED_4800:
332 uart_data->ker.act_br = UF_BAUD_4800;
333 break;
334 case UART_IO_SPEED_7200:
335 uart_data->ker.act_br = UF_BAUD_7200;
336 break;
337 case UART_IO_SPEED_9600:
338 uart_data->ker.act_br = UF_BAUD_9600;
339 break;
340 case UART_IO_SPEED_14400:
341 uart_data->ker.act_br = UF_BAUD_14400;
342 break;
343 case UART_IO_SPEED_19200:
344 uart_data->ker.act_br = UF_BAUD_19200;
345 break;
346 case UART_IO_SPEED_28800:
347 uart_data->ker.act_br = UF_BAUD_28800;
348 break;
349 case UART_IO_SPEED_33900:
350 uart_data->ker.act_br = UF_BAUD_33900;
351 break;
352 case UART_IO_SPEED_38400:
353 uart_data->ker.act_br = UF_BAUD_38400;
354 break;
355 case UART_IO_SPEED_57600:
356 uart_data->ker.act_br = UF_BAUD_57600;
357 break;
358 case UART_IO_SPEED_115200:
359 uart_data->ker.act_br = UF_BAUD_115200;
360 break;
361 case UART_IO_SPEED_203125:
362 uart_data->ker.act_br = UF_BAUD_203125;
363 break;
364 case UART_IO_SPEED_406250:
365 uart_data->ker.act_br = UF_BAUD_406250;
366 break;
367 case UART_IO_SPEED_812500:
368 uart_data->ker.act_br = UF_BAUD_812500;
369 break;
370 case UART_IO_SPEED_UNDEF: /* unchanged */
371 break;
372 default:
373 TRACE_ERROR( "UART_PARAMETERS_REQ: baudrate unexpected" );
374 break;
375 }
376
377 /*
378 * set new RX flow control
379 */
380 switch (uart_parameters_req->comPar.flow_rx)
381 {
382 case UART_IO_FC_RX_NONE:
383 uart_data->ker.act_fc_rx = fc_none;
384 break;
385 case UART_IO_FC_RX_RTS:
386 uart_data->ker.act_fc_rx = fc_rts;
387 break;
388 case UART_IO_FC_RX_XOFF:
389 uart_data->ker.act_fc_rx = fc_xoff;
390 break;
391 case UART_IO_FC_RX_UNDEF: /* unchanged */
392 break;
393 default:
394 TRACE_ERROR( "UART_PARAMETERS_REQ: RX flow control unexpected" );
395 break;
396 }
397
398 /*
399 * set new TX flow control
400 */
401 switch (uart_parameters_req->comPar.flow_tx)
402 {
403 case UART_IO_FC_TX_NONE:
404 uart_data->ker.act_fc_tx = fc_none;
405 break;
406 case UART_IO_FC_TX_RTS:
407 uart_data->ker.act_fc_tx = fc_rts;
408 break;
409 case UART_IO_FC_TX_XOFF:
410 uart_data->ker.act_fc_tx = fc_xoff;
411 break;
412 case UART_IO_FC_TX_UNDEF: /* unchanged */
413 break;
414 default:
415 TRACE_ERROR( "UART_PARAMETERS_REQ: TX flow control unexpected" );
416 break;
417 }
418
419 /*
420 * set new bits per character
421 */
422 switch (uart_parameters_req->comPar.bpc)
423 {
424 case UART_IO_BPC_7:
425 uart_data->ker.act_bpc = bpc_7;
426 break;
427 case UART_IO_BPC_8:
428 uart_data->ker.act_bpc = bpc_8;
429 break;
430 case UART_IO_BPC_UNDEF: /* unchanged */
431 break;
432 default:
433 TRACE_ERROR( "UART_PARAMETERS_REQ: bpc unexpected" );
434 break;
435 }
436
437 /*
438 * set new stop bit
439 */
440 switch (uart_parameters_req->comPar.nsb)
441 {
442 case UART_IO_SB_1:
443 uart_data->ker.act_sb = sb_1;
444 break;
445 case UART_IO_SB_2:
446 uart_data->ker.act_sb = sb_2;
447 break;
448 case UART_IO_SB_UNDEF: /* unchanged */
449 break;
450 default:
451 TRACE_ERROR( "UART_PARAMETERS_REQ: stop bits unexpected" );
452 break;
453 }
454
455 /*
456 * set new parity
457 */
458 switch (uart_parameters_req->comPar.parity)
459 {
460 case UART_IO_PA_NONE:
461 uart_data->ker.act_par = pa_none;
462 break;
463 case UART_IO_PA_EVEN:
464 uart_data->ker.act_par = pa_even;
465 break;
466 case UART_IO_PA_ODD:
467 uart_data->ker.act_par = pa_odd;
468 break;
469 case UART_IO_PA_SPACE:
470 uart_data->ker.act_par = pa_space;
471 break;
472 case UART_IO_PA_UNDEF: /* unchanged */
473 break;
474 default:
475 TRACE_ERROR( "UART_PARAMETERS_REQ: parity unexpected" );
476 break;
477 }
478
479 /*
480 * set new XON / XOFF values
481 */
482 if(uart_parameters_req->comPar.xon_valid EQ UART_IO_XON_VALID)
483 uart_data->ker.act_xon = uart_parameters_req->comPar.xon;
484 if(uart_parameters_req->comPar.xoff_valid EQ UART_IO_XOFF_VALID)
485 uart_data->ker.act_xoff = uart_parameters_req->comPar.xoff;
486 #endif /* FF_MULTI_PORT */
487
488 /*
489 * set new escape detection values
490 */
491 if(uart_parameters_req->comPar.esc_valid EQ UART_IO_ESC_VALID)
492 {
493 #ifdef FF_MULTI_PORT
494 uart_data->ker.act_dcb.EscChar = uart_parameters_req->comPar.esc_char;
495 uart_data->ker.act_dcb.GuardPeriod = uart_parameters_req->comPar.esc_gp;
496 #else /* FF_MULTI_PORT */
497 uart_data->ker.act_ec = uart_parameters_req->comPar.esc_char;
498 uart_data->ker.act_gp = uart_parameters_req->comPar.esc_gp;
499 #endif /* FF_MULTI_PORT */
500 }
501
502 /*
503 * free the received primitive
504 */
505 PFREE(uart_parameters_req);
506
507 switch( GET_STATE( UART_SERVICE_KER ) )
508 {
509 case KER_READY:
510 /*
511 * flush all still to send data
512 */
513 uart_data->ker.received_prim|= UART_PARAMETERS_REQ_MASK;
514 uart_data->ker.flush_state = UART_KER_DRX_FLUSH;
515 dlc = &uart_data->dlc_table[UART_CONTROL_INSTANCE];
516 dlc->flushed = FALSE;
517 uart_data->drx = dlc->drx;
518 sig_ker_drx_flush_req();
519 break;
520
521 case KER_MUX:
522 case KER_MUX_ESTABLISH:
523 case KER_MUX_DLC_CLOSING:
524 case KER_MUX_CLOSING:
525 case KER_MUX_CLOSED:
526 /*
527 * flush all still to send data
528 */
529 uart_data->ker.received_prim|= UART_PARAMETERS_REQ_MASK;
530 uart_data->ker.flush_state = UART_KER_DRX_FLUSH;
531 /*
532 * mark all to flush DLCs
533 */
534 for(i = 0; i < UART_MAX_NUMBER_OF_CHANNELS; i++)
535 {
536 dlc = &uart_data->dlc_table[i];
537 if((i EQ UART_CONTROL_INSTANCE) ||
538 (dlc->connection_state EQ UART_CONNECTION_OPEN))
539 {
540 dlc->flushed = FALSE;
541 }
542 }
543 /*
544 * initiate flush in all to flushed DLCs
545 */
546 for(i = 0; i < UART_MAX_NUMBER_OF_CHANNELS; i++)
547 {
548 dlc = &uart_data->dlc_table[i];
549 if(dlc->flushed NEQ TRUE)
550 {
551 if(i EQ UART_CONTROL_INSTANCE)
552 {
553 if(uart_data->ker.tx_data_desc EQ NULL)
554 sig_any_ker_flushed_ind(UART_CONTROL_INSTANCE);
555 }
556 else
557 {
558 uart_data->drx = dlc->drx;
559 sig_ker_drx_flush_req();
560 }
561 }
562 }
563 break;
564
565 case KER_DEAD:
566 /*
567 * set new UART parameters
568 */
569 ker_setupUart();
570
571 #ifdef FF_MULTI_PORT
572 uart_data->ker.act_ec = uart_data->ker.act_dcb.EscChar;
573 uart_data->ker.act_gp = uart_data->ker.act_dcb.GuardPeriod;
574 #endif /* FF_MULTI_PORT */
575
576 /*
577 * send confirm primitive
578 */
579 {
580 PALLOC (uart_parameters_cnf, UART_PARAMETERS_CNF);
581 uart_parameters_cnf->device = uart_data->device;
582 PSEND (hCommMMI, uart_parameters_cnf);
583 }
584 break;
585
586 default:
587 TRACE_ERROR( "UART_PARAMETERS_REQ unexpected" );
588 break;
589 }
590 } /* ker_uart_parameters_req() */
591
592
593
594 /*
595 +------------------------------------------------------------------------------
596 | Function : ker_uart_dti_req
597 +------------------------------------------------------------------------------
598 | Description : Handles the primitive UART_DTI_REQ
599 |
600 | Parameters : *uart_dti_req - Ptr to primitive payload
601 |
602 +------------------------------------------------------------------------------
603 */
604 GLOBAL void ker_uart_dti_req ( T_UART_DTI_REQ *uart_dti_req )
605 {
606 T_DLC* dlc;
607 UBYTE dlc_instance; /* dlc_instance is used as the channel number for dtilib */
608 #ifdef DTILIB
609 U8 isOK;
610 #else /* DTILIB */
611 T_HANDLE hCommUPLINK;
612 #endif /* DTILIB */
613
614 TRACE_FUNCTION( "ker_uart_dti_req" );
615
616 #ifdef UART_RANGE_CHECK
617 if(uart_dti_req EQ NULL)
618 {
619 TRACE_EVENT("ERROR: uart_dti_req is NULL");
620 }
621 else if((*((ULONG*)((UBYTE*)uart_dti_req - sizeof(T_PRIM_HEADER) - 8))) NEQ 0)
622 {
623 TRACE_EVENT_P1("ERROR: uart_dti_req=%08x is not allocated",
624 uart_dti_req);
625 }
626 else if(uart_dti_req->device >= UART_INSTANCES)
627 {
628 TRACE_EVENT_P2("ERROR: device=%d is greater than UART_INSTANCES=%d",
629 uart_dti_req->device,
630 UART_INSTANCES);
631 }
632 #endif /* UART_RANGE_CHECK */
633
634 /*
635 * set UART instance
636 */
637 uart_data = &uart_data_base[uart_dti_req->device];
638
639 switch( GET_STATE( UART_SERVICE_KER ) )
640 {
641 case KER_MUX:
642 case KER_MUX_DLC_CLOSING:
643 dlc_instance = uart_data->dlc_instance[uart_dti_req->dlci];
644 break;
645
646 default:
647 dlc_instance = UART_CONTROL_INSTANCE;
648 break;
649 }
650
651 dlc = &uart_data->dlc_table[dlc_instance];
652 /*
653 * close communication channel
654 * if it is already closed, silently discard primitive
655 */
656 if(dlc->dti_state NEQ DTI_CLOSED)
657 {
658 dti_close(
659 uart_hDTI,
660 uart_data->device,
661 UART_DTI_UP_INTERFACE,
662 dlc_instance,
663 FALSE
664 );
665 dlc->dti_state = DTI_CLOSED;
666
667 /*
668 * no reopen
669 */
670 if (uart_dti_req->dti_conn EQ UART_DISCONNECT_DTI)
671 {
672 PALLOC (uart_dti_cnf, UART_DTI_CNF);
673 uart_data->drx = dlc->drx;
674 uart_data->dtx = dlc->dtx;
675 sig_ker_drx_disconnected_mode_req();
676 sig_ker_dtx_disconnected_mode_req();
677
678 /*
679 * send confirm primitive
680 */
681 uart_dti_cnf->device = uart_data->device;
682 uart_dti_cnf->dlci = uart_data->dlc_table[dlc_instance].dlci; /* EQ dlci */
683 uart_dti_cnf->dti_conn = UART_DISCONNECT_DTI;
684 PSEND (hCommMMI, uart_dti_cnf);
685
686 return;
687 }
688 }
689
690 #ifdef DTILIB
691 if( GET_STATE( UART_SERVICE_KER ) EQ KER_DEAD )
692 {
693 /*
694 * set dlc values - this has to happen before
695 * the call of dti_open, because within that call
696 * a callback-function may be called which makes
697 * use of them..
698 */
699 dlc = &uart_data->dlc_table[UART_CONTROL_INSTANCE];
700 dlc->drx = &uart_data->drx_base[0];
701 dlc->dtx = &uart_data->dtx_base[0];
702 dlc->dlci = 0;
703 uart_data->dlc_instance[0] = UART_CONTROL_INSTANCE;
704 dlc->priority = 0;
705 dlc->lines = 0;
706 }
707
708 /*
709 * set DTI connection
710 */
711 dlc->dti_state = DTI_SETUP;
712
713 uart_data->drx = dlc->drx;
714 uart_data->dtx = dlc->dtx;
715 #endif /* DTILIB */
716
717 #ifdef _SIMULATION_
718 /*
719 * !!! Problem with entity_name which is a pointer in new SAP
720 * !!! therefore we set the peer entity simply to "MMI".
721 * !!! This should be corrected in order to allow test case simulations
722 * !!! with other peer entities.
723 */
724
725 #ifdef DTILIB
726 isOK = dti_open(
727 uart_hDTI,
728 uart_data->device,
729 UART_DTI_UP_INTERFACE,
730 dlc_instance,
731 UART_UPLINK_QUEUE_SIZE,
732 uart_dti_req->direction,
733 DTI_QUEUE_UNUSED,
734 DTI_VERSION_10,
735 "MMI",
736 uart_dti_req->link_id
737 );
738 #else /* DTILIB */
739 hCommUPLINK = vsi_c_open (VSI_CALLER "MMI");
740 #endif /* DTILIB */
741 #else /* _SIMULATION_ */
742 /*
743 * open new communication channel
744 */
745 #ifdef DTILIB
746 isOK = dti_open(
747 uart_hDTI,
748 uart_data->device,
749 UART_DTI_UP_INTERFACE,
750 dlc_instance,
751 UART_UPLINK_QUEUE_SIZE,
752 uart_dti_req->direction,
753 DTI_QUEUE_UNUSED,
754 DTI_VERSION_10,
755 (U8*)(uart_dti_req->entity_name),
756 uart_dti_req->link_id
757 );
758 #else /* DTILIB */
759 hCommUPLINK = vsi_c_open (VSI_CALLER
760 (char *)(uart_dti_req->entity_name));
761 #endif /* DTILIB */
762 #endif /* _SIMULATION_ */
763
764
765 #ifdef DTILIB
766 if(!isOK)
767 /* error?! */
768 /*
769 * NOTE: internal initialization of the new communication channel
770 * is done in sig_dti_ker_connection_opened() when using DTILIB
771 *
772 * when debugging the below code, please also have a look there!!
773 */
774 #else /* DTILIB */
775 uart_data->tui_uart = uart_dti_req->tui_uart;
776 if(hCommUPLINK >= VSI_OK)
777 {
778 PALLOC (uart_dti_cnf, UART_DTI_CNF);
779 /*
780 * send confirm primitive
781 */
782 uart_dti_cnf->device = uart_data->device;
783 uart_dti_cnf->dlci = uart_dti_req->dlci;
784 uart_dti_cnf->dti_conn = UART_CONNECT_DTI;
785 PSEND (hCommMMI, uart_dti_cnf);
786 /*
787 * initialize new communication channel
788 */
789 switch( GET_STATE( UART_SERVICE_KER ) )
790 {
791 case KER_DEAD:
792 SET_STATE( UART_SERVICE_KER, KER_READY );
793 /*
794 * enable UART
795 */
796 #ifdef _SIMULATION_
797 {
798 /*
799 * send DTI_GETDATA_REQ
800 */
801 PALLOC (dti_getdata_req, DTI2_GETDATA_REQ);
802 dti_getdata_req->tui = 2; /* for enable */
803 dti_getdata_req->c_id = 0;
804 dti_getdata_req->op_ack = 0;
805 PSEND (hCommMMI, dti_getdata_req);
806 }
807 #else /* _SIMULATION_ */
808 #ifndef FF_MULTI_PORT
809 if((ret=UF_Enable (uart_data->device, TRUE)) NEQ UF_OK)
810 {
811 TRACE_ERROR_P2("UF Driver: Can't enable UART, [%d], uart_kerp.c(%d)",
812 ret,__LINE__);
813 }
814 #endif /* !FF_MULTI_PORT */
815 #endif /* _SIMULATION */
816 /*
817 * set dlc values
818 */
819 dlc = &uart_data->dlc_table[UART_CONTROL_INSTANCE];
820 dlc->drx = &uart_data->drx_base[0];
821 dlc->dtx = &uart_data->dtx_base[0];
822 dlc->dlci = 0;
823 dlc->priority = 0;
824 dlc->lines = 0;
825 /*
826 * set RX and TX in ready mode
827 */
828 sig_ker_rx_ready_mode_req();
829 sig_ker_tx_ready_mode_req();
830 /*
831 * set DTI connection
832 */
833 dlc->hCommUPLINK = hCommUPLINK;
834 uart_data->drx = dlc->drx;
835 uart_data->dtx = dlc->dtx;
836 sig_ker_drx_ready_mode_req(UART_CONTROL_INSTANCE);
837 sig_ker_dtx_ready_mode_req(UART_CONTROL_INSTANCE);
838 sig_ker_drx_set_dti_peer_req(uart_dti_req->tui_peer,
839 hCommUPLINK,
840 uart_dti_req->c_id);
841 sig_ker_dtx_set_dti_peer_req(uart_dti_req->tui_peer,
842 hCommUPLINK,
843 uart_dti_req->c_id);
844
845 break;
846
847 case KER_READY:
848 case KER_MUX:
849 dlc->hCommUPLINK = hCommUPLINK;
850 uart_data->drx = dlc->drx;
851 uart_data->dtx = dlc->dtx;
852 sig_ker_drx_set_dti_peer_req(uart_dti_req->tui_peer,
853 hCommUPLINK,
854 uart_dti_req->c_id);
855 sig_ker_dtx_set_dti_peer_req(uart_dti_req->tui_peer,
856 hCommUPLINK,
857 uart_dti_req->c_id);
858 break;
859
860 default:
861 TRACE_ERROR( "UART_DTI_REQ unexpected" );
862 break;
863 }
864 }
865 else /* UPLINK OK */
866 #endif /* DTILIB */
867 {
868 /*
869 * send error primitive if communication channel is not opened
870 */
871 PALLOC (uart_error_ind, UART_ERROR_IND);
872 uart_error_ind->device = uart_data->device;
873 uart_error_ind->dlci = uart_dti_req->dlci;
874 uart_error_ind->error = UART_ERROR_NO_CHANNEL;
875 PSEND (hCommMMI, uart_error_ind);
876 }
877
878 /*
879 * free the received primitive
880 */
881 PFREE(uart_dti_req);
882 } /* ker_uart_dti_req() */
883
884
885 /*
886 +------------------------------------------------------------------------------
887 | Function : ker_uart_disable_req
888 +------------------------------------------------------------------------------
889 | Description : Handles the primitive UART_DISABLE_REQ
890 |
891 | Parameters : *uart_disable_req - Ptr to primitive payload
892 |
893 +------------------------------------------------------------------------------
894 */
895 GLOBAL void ker_uart_disable_req ( T_UART_DISABLE_REQ *uart_disable_req )
896 {
897 UBYTE i;
898 T_DLC* dlc;
899
900 TRACE_FUNCTION( "ker_uart_disable_req" );
901
902 #ifdef UART_RANGE_CHECK
903 if(uart_disable_req EQ NULL)
904 {
905 TRACE_EVENT("ERROR: uart_disable_req is NULL");
906 }
907 else if((*((ULONG*)((UBYTE*)uart_disable_req - sizeof(T_PRIM_HEADER) - 8))) NEQ 0)
908 {
909 TRACE_EVENT_P1("ERROR: uart_disable_req=%08x is not allocated",
910 uart_disable_req);
911 }
912 else if(uart_disable_req->device >= UART_INSTANCES)
913 {
914 TRACE_EVENT_P2("ERROR: device=%d is greater than UART_INSTANCES=%d",
915 uart_disable_req->device,
916 UART_INSTANCES);
917 }
918 #endif /* UART_RANGE_CHECK */
919
920 /*
921 * set UART instance
922 */
923 uart_data = &uart_data_base[uart_disable_req->device];
924
925 /*
926 * free the received primitive
927 */
928 PFREE(uart_disable_req);
929
930 switch( GET_STATE( UART_SERVICE_KER ) )
931 {
932 case KER_READY:
933 /*
934 * flush all still to send data
935 */
936 uart_data->ker.received_prim|= UART_DISABLE_REQ_MASK;
937 uart_data->ker.flush_state = UART_KER_DRX_FLUSH;
938 dlc = &uart_data->dlc_table[UART_CONTROL_INSTANCE];
939 dlc->flushed = FALSE;
940 uart_data->drx = dlc->drx;
941 sig_ker_drx_flush_req();
942 break;
943
944 case KER_MUX:
945 case KER_MUX_ESTABLISH:
946 case KER_MUX_DLC_CLOSING:
947 case KER_MUX_CLOSING:
948 case KER_MUX_CLOSED:
949 /*
950 * flush all still to send data
951 */
952 uart_data->ker.received_prim|= UART_DISABLE_REQ_MASK;
953 uart_data->ker.flush_state = UART_KER_DRX_FLUSH;
954 /*
955 * mark all to flush DLCs
956 */
957 for(i = 0; i < UART_MAX_NUMBER_OF_CHANNELS; i++)
958 {
959 dlc = &uart_data->dlc_table[i];
960 if((i EQ UART_CONTROL_INSTANCE) ||
961 (dlc->connection_state EQ UART_CONNECTION_OPEN))
962 {
963 dlc->flushed = FALSE;
964 }
965 }
966 /*
967 * initiate flush in all to flushed DLCs
968 */
969 for(i = 0; i < UART_MAX_NUMBER_OF_CHANNELS; i++)
970 {
971 dlc = &uart_data->dlc_table[i];
972 if(dlc->flushed NEQ TRUE)
973 {
974 if(i EQ UART_CONTROL_INSTANCE)
975 {
976 if(uart_data->ker.tx_data_desc EQ NULL)
977 sig_any_ker_flushed_ind(UART_CONTROL_INSTANCE);
978 }
979 else
980 {
981 uart_data->drx = dlc->drx;
982 sig_ker_drx_flush_req();
983 }
984 }
985 }
986 break;
987
988 case KER_DEAD:
989 /*
990 * send confirm primitive
991 */
992 {
993 PALLOC (uart_disable_cnf, UART_DISABLE_CNF);
994 uart_disable_cnf->device = uart_data->device;
995 PSEND (hCommMMI, uart_disable_cnf);
996 }
997 break;
998
999 default:
1000 TRACE_ERROR( "UART_DISABLE_REQ unexpected" );
1001 break;
1002 }
1003 } /* ker_uart_disable_req() */
1004
1005
1006
1007 /*
1008 +------------------------------------------------------------------------------
1009 | Function : ker_uart_ring_req
1010 +------------------------------------------------------------------------------
1011 | Description : Handles the primitive UART_RING_REQ
1012 |
1013 | Parameters : *uart_ring_req - Ptr to primitive payload
1014 |
1015 +------------------------------------------------------------------------------
1016 */
1017 GLOBAL void ker_uart_ring_req ( T_UART_RING_REQ *uart_ring_req )
1018 {
1019 T_DLC* dlc;
1020
1021 TRACE_FUNCTION( "ker_uart_ring_req" );
1022
1023 #ifdef UART_RANGE_CHECK
1024 if(uart_ring_req EQ NULL)
1025 {
1026 TRACE_EVENT("ERROR: uart_ring_req is NULL");
1027 }
1028 else if((*((ULONG*)((UBYTE*)uart_ring_req - sizeof(T_PRIM_HEADER) - 8))) NEQ 0)
1029 {
1030 TRACE_EVENT_P1("ERROR: uart_ring_req=%08x is not allocated",
1031 uart_ring_req);
1032 }
1033 else if(uart_ring_req->device >= UART_INSTANCES)
1034 {
1035 TRACE_EVENT_P2("ERROR: device=%d is greater than UART_INSTANCES=%d",
1036 uart_ring_req->device,
1037 UART_INSTANCES);
1038 }
1039 #endif /* UART_RANGE_CHECK */
1040
1041 /*
1042 * set UART instance
1043 */
1044 uart_data = &uart_data_base[uart_ring_req->device];
1045
1046 /*
1047 * set DLC instance
1048 */
1049 if((GET_STATE( UART_SERVICE_KER )) EQ KER_READY)
1050 dlc = &uart_data->dlc_table[UART_CONTROL_INSTANCE];
1051 else
1052 dlc = &uart_data->dlc_table[uart_data->
1053 dlc_instance[uart_ring_req->dlci]];
1054
1055 /*
1056 * store new line states
1057 */
1058 if(uart_ring_req->line_state EQ UART_LINE_ON)
1059 {
1060 TRACE_EVENT_P1("RING: on - DLCI=%d", uart_ring_req->dlci);
1061 dlc->lines|= UART_RI_MASK;
1062 }
1063 else
1064 {
1065 TRACE_EVENT_P1("RING: off - DLCI=%d", uart_ring_req->dlci);
1066 dlc->lines&= ~(UART_RI_MASK);
1067 }
1068
1069 /*
1070 * free the received primitive
1071 */
1072 PFREE(uart_ring_req);
1073
1074 switch( GET_STATE( UART_SERVICE_KER ) )
1075 {
1076 case KER_READY:
1077 case KER_MUX:
1078 /*
1079 * flush all still to send data
1080 */
1081 dlc->received_prim |= UART_RING_REQ_MASK;
1082 uart_data->ker.flush_state = UART_KER_DRX_FLUSH;
1083 dlc->flushed = FALSE;
1084 uart_data->drx = dlc->drx;
1085 sig_ker_drx_flush_req();
1086 break;
1087
1088 default:
1089 TRACE_ERROR( "UART_RING_REQ unexpected" );
1090 break;
1091 }
1092 } /* ker_uart_ring_req() */
1093
1094
1095
1096 /*
1097 +------------------------------------------------------------------------------
1098 | Function : ker_uart_dcd_req
1099 +------------------------------------------------------------------------------
1100 | Description : Handles the primitive UART_DCD_REQ
1101 |
1102 | Parameters : *uart_dcd_req - Ptr to primitive payload
1103 |
1104 +------------------------------------------------------------------------------
1105 */
1106 GLOBAL void ker_uart_dcd_req ( T_UART_DCD_REQ *uart_dcd_req )
1107 {
1108 T_DLC* dlc;
1109
1110 TRACE_FUNCTION( "ker_uart_dcd_req" );
1111
1112 #ifdef UART_RANGE_CHECK
1113 if(uart_dcd_req EQ NULL)
1114 {
1115 TRACE_EVENT("ERROR: uart_dcd_req is NULL");
1116 }
1117 else if((*((ULONG*)((UBYTE*)uart_dcd_req - sizeof(T_PRIM_HEADER) - 8))) NEQ 0)
1118 {
1119 TRACE_EVENT_P1("ERROR: uart_dcd_req=%08x is not allocated",
1120 uart_dcd_req);
1121 }
1122 else if(uart_dcd_req->device >= UART_INSTANCES)
1123 {
1124 TRACE_EVENT_P2("ERROR: device=%d is greater than UART_INSTANCES=%d",
1125 uart_dcd_req->device,
1126 UART_INSTANCES);
1127 }
1128 #endif /* UART_RANGE_CHECK */
1129
1130 /*
1131 * set UART instance
1132 */
1133 uart_data = &uart_data_base[uart_dcd_req->device];
1134
1135 /*
1136 * set DLC instance
1137 */
1138 if((GET_STATE( UART_SERVICE_KER )) EQ KER_READY)
1139 dlc = &uart_data->dlc_table[UART_CONTROL_INSTANCE];
1140 else
1141 dlc = &uart_data->dlc_table[uart_data->
1142 dlc_instance[uart_dcd_req->dlci]];
1143
1144 /*
1145 * store new line states
1146 */
1147 if(uart_dcd_req->line_state EQ UART_LINE_ON)
1148 {
1149 TRACE_EVENT_P1("DCD: on - DLCI=%d", uart_dcd_req->dlci);
1150 dlc->lines&= ~(UART_DCD_MASK);
1151 }
1152 else
1153 {
1154 TRACE_EVENT_P1("DCD: off - DLCI=%d", uart_dcd_req->dlci);
1155 dlc->lines|= UART_DCD_MASK;
1156 }
1157
1158 /*
1159 * free the received primitive
1160 */
1161 PFREE(uart_dcd_req);
1162
1163 switch( GET_STATE( UART_SERVICE_KER ) )
1164 {
1165 case KER_READY:
1166 case KER_MUX:
1167 /*
1168 * flush all still to send data
1169 */
1170 dlc->received_prim |= UART_DCD_REQ_MASK;
1171 uart_data->ker.flush_state = UART_KER_DRX_FLUSH;
1172 dlc->flushed = FALSE;
1173 uart_data->drx = dlc->drx;
1174 sig_ker_drx_flush_req();
1175 break;
1176
1177 default:
1178 TRACE_ERROR( "UART_DCD_REQ unexpected" );
1179 break;
1180 }
1181 } /* ker_uart_dcd_req() */
1182
1183
1184
1185 /*
1186 +------------------------------------------------------------------------------
1187 | Function : ker_uart_escape_req
1188 +------------------------------------------------------------------------------
1189 | Description : Handles the primitive UART_ESCAPE_REQ
1190 |
1191 | Parameters : *uart_escape_req - Ptr to primitive payload
1192 |
1193 +------------------------------------------------------------------------------
1194 */
1195 GLOBAL void ker_uart_escape_req ( T_UART_ESCAPE_REQ *uart_escape_req )
1196 {
1197
1198 TRACE_FUNCTION( "ker_uart_escape_req" );
1199
1200 #ifdef UART_RANGE_CHECK
1201 if(uart_escape_req EQ NULL)
1202 {
1203 TRACE_EVENT("ERROR: uart_escape_req is NULL");
1204 }
1205 else if((*((ULONG*)((UBYTE*)uart_escape_req - sizeof(T_PRIM_HEADER) - 8))) NEQ 0)
1206 {
1207 TRACE_EVENT_P1("ERROR: uart_escape_req=%08x is not allocated",
1208 uart_escape_req);
1209 }
1210 else if(uart_escape_req->device >= UART_INSTANCES)
1211 {
1212 TRACE_EVENT_P2("ERROR: device=%d is greater than UART_INSTANCES=%d",
1213 uart_escape_req->device,
1214 UART_INSTANCES);
1215 }
1216 #endif /* UART_RANGE_CHECK */
1217
1218 /*
1219 * set UART instance
1220 */
1221 uart_data = &uart_data_base[uart_escape_req->device];
1222
1223 /*
1224 * set DLC instance
1225 */
1226 /* Following part of code is not required so put under comment ,but may be used
1227 * in future
1228 */
1229 /*
1230 if((GET_STATE( UART_SERVICE_KER )) EQ KER_READY)
1231 dlc = &uart_data->dlc_table[UART_CONTROL_INSTANCE];
1232 else
1233 dlc = &uart_data->dlc_table[uart_data->
1234 dlc_instance[uart_escape_req->dlci]];
1235 */
1236 /*
1237 * Send confirmation to ACI
1238 */
1239 {
1240 PALLOC (uart_escape_cnf, UART_ESCAPE_CNF);
1241
1242 uart_escape_cnf->device = uart_escape_req->device;
1243 uart_escape_cnf->dlci = uart_escape_req->dlci;
1244
1245 PSEND (hCommMMI, uart_escape_cnf);
1246 }
1247
1248 /*
1249 * TODO: Set escape on/off parameter in dtx,
1250 * Call UF_SetEscape and handle/stop ongoing
1251 * escape sequence detection if required
1252 */
1253
1254 /*
1255 * free the received primitive
1256 */
1257 PFREE(uart_escape_req);
1258
1259 switch( GET_STATE( UART_SERVICE_KER ) )
1260 {
1261 case KER_READY:
1262 case KER_MUX:
1263 break;
1264
1265 default:
1266 TRACE_ERROR( "UART_ESCAPE_REQ unexpected" );
1267 break;
1268 }
1269 } /* ker_uart_escape_req() */
1270
1271
1272
1273 /*
1274 +------------------------------------------------------------------------------
1275 | Function : ker_uart_mux_start_req
1276 +------------------------------------------------------------------------------
1277 | Description : Handles the primitive UART_MUX_START_REQ
1278 |
1279 | Parameters : *uart_mux_start_req - Ptr to primitive payload
1280 |
1281 +------------------------------------------------------------------------------
1282 */
1283 GLOBAL void ker_uart_mux_start_req ( T_UART_MUX_START_REQ *uart_mux_start_req )
1284 {
1285 T_DLC* dlc;
1286 #ifndef _SIMULATION_
1287 USHORT ret;
1288 #endif
1289 TRACE_FUNCTION( "ker_uart_mux_start_req" );
1290
1291 #ifdef UART_RANGE_CHECK
1292 if(uart_mux_start_req EQ NULL)
1293 {
1294 TRACE_EVENT("ERROR: uart_mux_start_req is NULL");
1295 }
1296 else if((*((ULONG*)((UBYTE*)uart_mux_start_req - sizeof(T_PRIM_HEADER) - 8))) NEQ 0)
1297 {
1298 TRACE_EVENT_P1("ERROR: uart_mux_start_req=%08x is not allocated",
1299 uart_mux_start_req);
1300 }
1301 else if(uart_mux_start_req->device >= UART_INSTANCES)
1302 {
1303 TRACE_EVENT_P2("ERROR: device=%d is greater than UART_INSTANCES=%d",
1304 uart_mux_start_req->device,
1305 UART_INSTANCES);
1306 }
1307 #endif /* UART_RANGE_CHECK */
1308
1309 /*
1310 * set UART instance
1311 */
1312 uart_data = &uart_data_base[uart_mux_start_req->device];
1313
1314 /*
1315 * set parameters
1316 */
1317 uart_data->n1 = uart_mux_start_req->n1;
1318 uart_data->ker.n2 = uart_mux_start_req->n2;
1319 sig_ker_rt_parameters_req(uart_mux_start_req->t1,
1320 uart_mux_start_req->t2,
1321 uart_mux_start_req->t3);
1322
1323 /*
1324 * free the received primitive
1325 */
1326 PFREE(uart_mux_start_req);
1327
1328 switch( GET_STATE( UART_SERVICE_KER ) )
1329 {
1330 case KER_READY:
1331 /*
1332 * flush all still to send data
1333 */
1334 uart_data->ker.received_prim|= UART_MUX_START_REQ_MASK;
1335 uart_data->ker.flush_state = UART_KER_DRX_FLUSH;
1336 dlc = &uart_data->dlc_table[UART_CONTROL_INSTANCE];
1337 dlc->flushed = FALSE;
1338 uart_data->drx = dlc->drx;
1339 sig_ker_drx_flush_req();
1340 break;
1341
1342 case KER_DEAD:
1343 SET_STATE( UART_SERVICE_KER, KER_MUX_ESTABLISH );
1344 #ifdef _SIMULATION_
1345 {
1346 /*
1347 * send DTI_GETDATA_REQ
1348 */
1349 PALLOC (dti_getdata_req, DTI2_GETDATA_REQ);
1350 #ifdef DTI2
1351 dti_getdata_req->link_id = LINK_ENABLE_PORT_1; /* for enable */
1352 #else /* DTI2 */
1353 dti_getdata_req->tui = 2; /* for enable */
1354 dti_getdata_req->c_id = 0;
1355 dti_getdata_req->op_ack = 0;
1356 #endif /* DTI2 */
1357 PSEND (hCommMMI, dti_getdata_req);
1358 }
1359 #else /* _SIMULATION_ */
1360 #ifndef FF_MULTI_PORT
1361 if((ret = UF_Enable (uart_data->device, TRUE)) NEQ UF_OK)
1362 {
1363 TRACE_ERROR_P2("UF Driver: Can't enable UART, [%d], uart_kerp.c(%d)",
1364 ret,__LINE__);
1365 }
1366 #endif /* !FF_MULTI_PORT */
1367 #endif /* _SIMULATION */
1368
1369 /*
1370 * set RX and TX service in mux mode
1371 */
1372 sig_ker_rx_mux_mode_req();
1373 sig_ker_tx_mux_mode_req();
1374 /*
1375 * start reception
1376 */
1377 MALLOC(uart_data->ker.rx_data_desc, (USHORT)(sizeof(T_desc2) -
1378 1 +
1379 uart_data->n1 +
1380 2));
1381 uart_data->ker.rx_data_desc->next = (ULONG)NULL;
1382 uart_data->ker.rx_data_desc->len = 0;
1383 sig_ker_rx_ready_to_receive_req(uart_data->ker.rx_data_desc,
1384 0,
1385 (USHORT)(uart_data->n1 + 2));
1386 /*
1387 * start timer
1388 */
1389 sig_ker_rt_start_t3_req();
1390
1391 /*
1392 * send confirm primitive
1393 */
1394 {
1395 PALLOC (uart_mux_start_cnf, UART_MUX_START_CNF);
1396 uart_mux_start_cnf->device = uart_data->device;
1397 PSEND (hCommMMI, uart_mux_start_cnf);
1398 }
1399 break;
1400
1401 default:
1402 TRACE_ERROR( "UART_MUX_START_REQ unexpected" );
1403 break;
1404 }
1405 } /* ker_uart_mux_start_req() */
1406
1407
1408
1409 /*
1410 +------------------------------------------------------------------------------
1411 | Function : ker_uart_mux_dlc_establish_res
1412 +------------------------------------------------------------------------------
1413 | Description : Handles the primitive UART_MUX_DLC_ESTABLISH_RES
1414 |
1415 | Parameters : *uart_mux_dlc_establish_res - Ptr to primitive payload
1416 |
1417 +------------------------------------------------------------------------------
1418 */
1419 GLOBAL void ker_uart_mux_dlc_establish_res (
1420 T_UART_MUX_DLC_ESTABLISH_RES *uart_mux_dlc_establish_res )
1421 {
1422 T_desc2* temp_desc;
1423 T_DLC* dlc;
1424
1425 TRACE_FUNCTION( "uart_mux_dlc_establish_res" );
1426
1427 #ifdef UART_RANGE_CHECK
1428 if(uart_mux_dlc_establish_res EQ NULL)
1429 {
1430 TRACE_EVENT("ERROR: uart_mux_dlc_establish_res is NULL");
1431 }
1432 else if((*((ULONG*)((UBYTE*)uart_mux_dlc_establish_res
1433 - sizeof(T_PRIM_HEADER) - 8))) NEQ 0)
1434 {
1435 TRACE_EVENT_P1("ERROR: uart_mux_dlc_establish_res=%08x is not allocated",
1436 uart_mux_dlc_establish_res);
1437 }
1438 else if(uart_mux_dlc_establish_res->device >= UART_INSTANCES)
1439 {
1440 TRACE_EVENT_P2("ERROR: device=%d is greater than UART_INSTANCES=%d",
1441 uart_mux_dlc_establish_res->device,
1442 UART_INSTANCES);
1443 }
1444 #endif /* UART_RANGE_CHECK */
1445
1446 /*
1447 * set UART instance
1448 */
1449 uart_data = &uart_data_base[uart_mux_dlc_establish_res->device];
1450
1451 switch( GET_STATE( UART_SERVICE_KER ) )
1452 {
1453 case KER_MUX:
1454 dlc = &uart_data->dlc_table[uart_data->
1455 dlc_instance[uart_mux_dlc_establish_res->dlci]];
1456 dlc->connection_state = UART_CONNECTION_OPEN;
1457 /*
1458 * send UA response
1459 */
1460 temp_desc = dlc->next_command;
1461 dlc->next_command = NULL;
1462 ker_mux_send_frame(temp_desc);
1463 /*
1464 * start Data services
1465 */
1466 uart_data->drx = dlc->drx;
1467 uart_data->dtx = dlc->dtx;
1468 sig_ker_drx_ready_mode_req(uart_data->
1469 dlc_instance[uart_mux_dlc_establish_res->dlci]);
1470 sig_ker_dtx_ready_mode_req(uart_data->
1471 dlc_instance[uart_mux_dlc_establish_res->dlci]);
1472 break;
1473
1474 default:
1475 TRACE_ERROR( "UART_MUX_DLC_ESTABLISH_RES unexpected" );
1476 break;
1477 }
1478 /*
1479 * free the received primitive
1480 */
1481 PFREE(uart_mux_dlc_establish_res);
1482 } /* uart_mux_dlc_establish_res() */
1483
1484
1485
1486 /*
1487 +------------------------------------------------------------------------------
1488 | Function : ker_uart_mux_dlc_release_req
1489 +------------------------------------------------------------------------------
1490 | Description : Handles the primitive UART_MUX_DLC_RELEASE_REQ
1491 |
1492 | Parameters : *ker_uart_mux_dlc_release_req - Ptr to primitive payload
1493 |
1494 +------------------------------------------------------------------------------
1495 */
1496 GLOBAL void ker_uart_mux_dlc_release_req (
1497 T_UART_MUX_DLC_RELEASE_REQ *uart_mux_dlc_release_req )
1498 {
1499 T_desc2* temp_desc;
1500 T_DLC* dlc;
1501 UBYTE dlc_instance; /* channel */
1502
1503 TRACE_FUNCTION( "ker_uart_mux_dlc_release_req" );
1504
1505 #ifdef UART_RANGE_CHECK
1506 if(uart_mux_dlc_release_req EQ NULL)
1507 {
1508 TRACE_EVENT("ERROR: uart_mux_dlc_release_req is NULL");
1509 }
1510 else if((*((ULONG*)((UBYTE*)uart_mux_dlc_release_req
1511 - sizeof(T_PRIM_HEADER) - 8))) NEQ 0)
1512 {
1513 TRACE_EVENT_P1("ERROR: uart_mux_dlc_release_req=%08x is not allocated",
1514 uart_mux_dlc_release_req);
1515 }
1516 else if(uart_mux_dlc_release_req->device >= UART_INSTANCES)
1517 {
1518 TRACE_EVENT_P2("ERROR: device=%d is greater than UART_INSTANCES=%d",
1519 uart_mux_dlc_release_req->device,
1520 UART_INSTANCES);
1521 }
1522 #endif /* UART_RANGE_CHECK */
1523
1524 /*
1525 * set UART instance
1526 */
1527 uart_data = &uart_data_base[uart_mux_dlc_release_req->device];
1528
1529 switch( GET_STATE( UART_SERVICE_KER ) )
1530 {
1531 case KER_MUX:
1532 dlc_instance = uart_data->dlc_instance[uart_mux_dlc_release_req->dlci];
1533 dlc = &uart_data->dlc_table[dlc_instance];
1534 /*
1535 * close DTI connection
1536 */
1537 uart_data->drx = dlc->drx;
1538 uart_data->dtx = dlc->dtx;
1539 sig_ker_drx_dead_mode_req();
1540 sig_ker_dtx_dead_mode_req();
1541 #ifdef DTILIB
1542 if(dlc->dti_state NEQ DTI_CLOSED)
1543 {
1544 dti_close(
1545 uart_hDTI,
1546 uart_data->device,
1547 UART_DTI_UP_INTERFACE,
1548 dlc_instance,
1549 FALSE
1550 );
1551 dlc->dti_state = DTI_CLOSED;
1552 }
1553 #else /* DTILIB */
1554 if(dlc->hCommUPLINK NEQ VSI_ERROR)
1555 {
1556 vsi_c_close (VSI_CALLER dlc->hCommUPLINK);
1557 dlc->hCommUPLINK = VSI_ERROR;
1558 }
1559 #endif /* DTILIB */
1560 switch(dlc->connection_state)
1561 {
1562 case UART_CONNECTION_SABM_RCVD:
1563 /*
1564 * negative response for an UART_MUX_DLC_ESTABLISH_IND
1565 * send DM response
1566 */
1567 temp_desc = dlc->next_command;
1568 dlc->next_command = NULL;
1569 temp_desc->buffer[UART_OFFSET_CONTROL] = UART_DM_CONTROL_FRAME
1570 ;/*lint !e415 access of out-of-bounds pointer*/
1571 ker_mux_send_frame(temp_desc);
1572 ker_mux_dlc_release(dlc_instance);
1573 break;
1574
1575 case UART_CONNECTION_OPEN:
1576 dlc->connection_state = UART_CONNECTION_DISC_SENT;
1577 ker_send_disc_frame(uart_mux_dlc_release_req->dlci);
1578 break;
1579 case UART_CONNECTION_DEAD:
1580 break;
1581
1582 default:
1583 TRACE_EVENT_P3("Warning: Unexpected DLC connection state: %d - \
1584 %s(%d)", dlc->connection_state, __FILE__, __LINE__);
1585 break;
1586 }
1587 break;
1588
1589 default:
1590 TRACE_ERROR( "UART_MUX_DLC_RELEASE_REQ unexpected" );
1591 break;
1592 }
1593 /*
1594 * free the received primitive
1595 */
1596 PFREE(uart_mux_dlc_release_req);
1597 } /* ker_uart_mux_dlc_release_req() */
1598
1599
1600
1601 /*
1602 +------------------------------------------------------------------------------
1603 | Function : ker_uart_mux_sleep_req
1604 +------------------------------------------------------------------------------
1605 | Description : Handles the primitive UART_MUX_SLEEP_REQ
1606 |
1607 | Parameters : *uart_mux_sleep_req - Ptr to primitive payload
1608 |
1609 +------------------------------------------------------------------------------
1610 */
1611 GLOBAL void ker_uart_mux_sleep_req (
1612 T_UART_MUX_SLEEP_REQ *uart_mux_sleep_req )
1613 {
1614 TRACE_FUNCTION( "uart_mux_sleep_req" );
1615
1616 #ifdef UART_RANGE_CHECK
1617 if(uart_mux_sleep_req EQ NULL)
1618 {
1619 TRACE_EVENT("ERROR: uart_mux_sleep_req is NULL");
1620 }
1621 else if((*((ULONG*)((UBYTE*)uart_mux_sleep_req
1622 - sizeof(T_PRIM_HEADER) - 8))) NEQ 0)
1623 {
1624 TRACE_EVENT_P1("ERROR: uart_mux_sleep_req=%08x is not allocated",
1625 uart_mux_sleep_req);
1626 }
1627 else if(uart_mux_sleep_req->device >= UART_INSTANCES)
1628 {
1629 TRACE_EVENT_P2("ERROR: device=%d is greater than UART_INSTANCES=%d",
1630 uart_mux_sleep_req->device,
1631 UART_INSTANCES);
1632 }
1633 #endif /* UART_RANGE_CHECK */
1634
1635 /*
1636 * set UART instance
1637 */
1638 uart_data = &uart_data_base[uart_mux_sleep_req->device];
1639
1640 /*
1641 * Primitive UART_MUX_SLEEP_REQ is not supported
1642 */
1643 TRACE_ERROR( "UART_MUX_SLEEP_REQ unexpected" );
1644
1645 /*
1646 * free the received primitive
1647 */
1648 PFREE(uart_mux_sleep_req);
1649 } /* ker_uart_mux_sleep_req() */
1650
1651
1652
1653 /*
1654 +------------------------------------------------------------------------------
1655 | Function : ker_uart_mux_wakeup_req
1656 +------------------------------------------------------------------------------
1657 | Description : Handles the primitive UART_MUX_WAKEUP_REQ
1658 |
1659 | Parameters : *uart_mux_wakeup_req - Ptr to primitive payload
1660 |
1661 +------------------------------------------------------------------------------
1662 */
1663 GLOBAL void ker_uart_mux_wakeup_req (
1664 T_UART_MUX_WAKEUP_REQ *uart_mux_wakeup_req )
1665 {
1666 TRACE_FUNCTION( "ker_uart_mux_wakeup_req" );
1667
1668 #ifdef UART_RANGE_CHECK
1669 if(uart_mux_wakeup_req EQ NULL)
1670 {
1671 TRACE_EVENT("ERROR: uart_mux_wakeup_req is NULL");
1672 }
1673 else if((*((ULONG*)((UBYTE*)uart_mux_wakeup_req - sizeof(T_PRIM_HEADER) - 8))) NEQ 0)
1674 {
1675 TRACE_EVENT_P1("ERROR: uart_mux_wakeup_req=%08x is not allocated",
1676 uart_mux_wakeup_req);
1677 }
1678 else if(uart_mux_wakeup_req->device >= UART_INSTANCES)
1679 {
1680 TRACE_EVENT_P2("ERROR: device=%d is greater than UART_INSTANCES=%d",
1681 uart_mux_wakeup_req->device,
1682 UART_INSTANCES);
1683 }
1684 #endif /* UART_RANGE_CHECK */
1685
1686 /*
1687 * set UART instance
1688 */
1689 uart_data = &uart_data_base[uart_mux_wakeup_req->device];
1690 /*
1691 * Primitive UART_MUX_WAKEUP_REQ is not supported
1692 */
1693 TRACE_ERROR( "UART_MUX_WAKEUP_REQ unexpected" );
1694 /*
1695 * free the received primitive
1696 */
1697 PFREE(uart_mux_wakeup_req);
1698 } /* ker_uart_mux_wakeup_req() */
1699
1700
1701
1702 /*
1703 +------------------------------------------------------------------------------
1704 | Function : ker_uart_mux_close_req
1705 +------------------------------------------------------------------------------
1706 | Description : Handles the primitive UART_MUX_CLOSE_REQ
1707 |
1708 | Parameters : *uart_mux_close_req - Ptr to primitive payload
1709 |
1710 +------------------------------------------------------------------------------
1711 */
1712 GLOBAL void ker_uart_mux_close_req (
1713 T_UART_MUX_CLOSE_REQ *uart_mux_close_req )
1714 {
1715 UBYTE i;
1716 T_DLC* dlc;
1717 T_desc2* temp_desc;
1718 BOOL continuous;
1719
1720
1721 TRACE_FUNCTION( "ker_uart_mux_close_req" );
1722
1723 #ifdef UART_RANGE_CHECK
1724 if(uart_mux_close_req EQ NULL)
1725 {
1726 TRACE_EVENT("ERROR: uart_mux_close_req is NULL");
1727 }
1728 else if((*((ULONG*)((UBYTE*)uart_mux_close_req - sizeof(T_PRIM_HEADER) - 8))) NEQ 0)
1729 {
1730 TRACE_EVENT_P1("ERROR: uart_mux_close_req=%08x is not allocated",
1731 uart_mux_close_req);
1732 }
1733 else if(uart_mux_close_req->device >= UART_INSTANCES)
1734 {
1735 TRACE_EVENT_P2("ERROR: device=%d is greater than UART_INSTANCES=%d",
1736 uart_mux_close_req->device,
1737 UART_INSTANCES);
1738 }
1739 #endif /* UART_RANGE_CHECK */
1740
1741 /*
1742 * set UART instance
1743 */
1744 uart_data = &uart_data_base[uart_mux_close_req->device];
1745
1746 switch( GET_STATE( UART_SERVICE_KER ) )
1747 {
1748 case KER_MUX_ESTABLISH:
1749 SET_STATE( UART_SERVICE_KER, KER_MUX_CLOSED );
1750 /*
1751 * stop timers and
1752 * remove all DLC instances
1753 */
1754 ker_mux_close_down();
1755 if(uart_data->ker.tx_data_desc EQ NULL)
1756 {
1757 uart_data->ker.received_prim|= UART_MUX_CLOSE_REQ_MASK;
1758
1759 if(uart_data->ker.flush_state EQ UART_KER_NOT_FLUSHING)
1760 {
1761 uart_data->ker.flush_state = UART_KER_TX_FLUSH;
1762 sig_ker_tx_flush_req();
1763 }
1764 }
1765 break;
1766
1767 case KER_MUX:
1768 SET_STATE( UART_SERVICE_KER, KER_MUX_DLC_CLOSING );
1769 /*
1770 * close all VSI channels and Data services
1771 */
1772 continuous = TRUE;
1773 for(i = 0; i <= UART_MAX_NUMBER_OF_CHANNELS; i++)
1774 {
1775 dlc = &uart_data->dlc_table[i];
1776 /*
1777 * close all DLC channels except Control channel
1778 */
1779 if(i NEQ UART_CONTROL_INSTANCE)
1780 {
1781 switch(dlc->connection_state)
1782 {
1783 case UART_CONNECTION_SABM_RCVD:
1784 /*
1785 * send DM response
1786 */
1787 temp_desc = dlc->next_command;
1788 dlc->next_command = NULL;
1789 temp_desc->buffer[UART_OFFSET_CONTROL] = UART_DM_CONTROL_FRAME
1790 ;/*lint !e415 access of out-of-bounds pointer*/
1791 ker_mux_send_frame(temp_desc);
1792 ker_mux_dlc_release(i);
1793 break;
1794
1795 case UART_CONNECTION_OPEN:
1796 dlc->connection_state = UART_CONNECTION_DISC_SENT;
1797 ker_send_disc_frame(dlc->dlci);
1798 continuous = FALSE;
1799 break;
1800
1801 case UART_CONNECTION_DISC_SENT:
1802 continuous = FALSE;
1803 break;
1804
1805 case UART_CONNECTION_DEAD:
1806 break;
1807
1808 default:
1809 TRACE_EVENT_P3("Warning: Unexpected DLC connection state: %d - \
1810 %s(%d)",dlc->connection_state,__FILE__, __LINE__);
1811 break;
1812 }
1813 }
1814 }
1815 if(continuous EQ TRUE)
1816 {
1817 SET_STATE( UART_SERVICE_KER, KER_MUX_CLOSING );
1818 /*
1819 * build and send CLD command frame:
1820 */
1821 ker_mux_send_close_down();
1822 /*
1823 * start timer
1824 */
1825 sig_ker_rt_start_t3_req();
1826 }
1827 break;
1828
1829 case KER_MUX_DLC_CLOSING:
1830 case KER_MUX_CLOSING:
1831 case KER_MUX_CLOSED:
1832 break;
1833
1834 default:
1835 TRACE_ERROR( "UART_MUX_CLOSE_REQ unexpected" );
1836 break;
1837 }
1838
1839 /*
1840 * free the received primitive
1841 */
1842 PFREE(uart_mux_close_req);
1843
1844 } /* ker_uart_mux_close_req() */
1845
1846
1847
1848 #ifdef DTILIB
1849 /*
1850 +------------------------------------------------------------------------------
1851 | Function : sig_dti_ker_connection_opened_ind
1852 +------------------------------------------------------------------------------
1853 | Description : Handles the DTILIB callback call DTI_REASON_CONNECTION_OPENED
1854 |
1855 | This signal means that a dti connection has been successfully opened.
1856 |
1857 | Parameter : dlc_instance
1858 |
1859 +------------------------------------------------------------------------------
1860 */
1861 GLOBAL void sig_dti_ker_connection_opened_ind (UBYTE dlc_instance)
1862 {
1863 #ifndef _SIMULATION_
1864 USHORT ret;
1865 #endif
1866 PALLOC (uart_dti_cnf, UART_DTI_CNF);
1867
1868 TRACE_FUNCTION( "sig_dti_ker_connection_opened_ind" );
1869
1870 /*
1871 * send confirm primitive
1872 */
1873 uart_dti_cnf->device = uart_data->device;
1874 uart_dti_cnf->dlci = uart_data->dlc_table[dlc_instance].dlci; /* EQ dlci */
1875 uart_dti_cnf->dti_conn = UART_CONNECT_DTI;
1876 PSEND (hCommMMI, uart_dti_cnf);
1877
1878 /*
1879 * initialize new communication channel
1880 */
1881 switch( GET_STATE( UART_SERVICE_KER ) )
1882 {
1883 case KER_DEAD:
1884 SET_STATE( UART_SERVICE_KER, KER_READY );
1885 /*
1886 * enable UART
1887 */
1888 #ifdef _SIMULATION_
1889 {
1890 /*
1891 * send DTI_GETDATA_REQ
1892 */
1893 PALLOC (dti_getdata_req, DTI2_GETDATA_REQ);
1894 #ifdef DTI2
1895 dti_getdata_req->link_id = LINK_ENABLE_PORT_1; /* for enable */
1896 #else /* DTI2 */
1897 dti_getdata_req->tui = 2; /* for enable */
1898 dti_getdata_req->c_id = 0;
1899 dti_getdata_req->op_ack = 0;
1900 #endif /* DTI2 */
1901 PSEND (hCommMMI, dti_getdata_req);
1902 }
1903 #else /* _SIMULATION_ */
1904 if((ret = UF_Enable (uart_data->device, TRUE)) NEQ UF_OK)
1905 {
1906 TRACE_ERROR_P2("UF Driver: Can't enable UART, [%d], uart_kerp.c(%d)",
1907 ret,__LINE__);
1908 }
1909 #endif /* _SIMULATION */
1910
1911 /*
1912 * set RX and TX in ready mode
1913 */
1914 sig_ker_rx_ready_mode_req();
1915 sig_ker_tx_ready_mode_req();
1916
1917 /*
1918 * set DTI connection
1919 */
1920 sig_ker_drx_ready_mode_req(UART_CONTROL_INSTANCE);
1921 sig_ker_dtx_ready_mode_req(UART_CONTROL_INSTANCE);
1922 sig_ker_drx_set_dtilib_peer_req();
1923 sig_ker_dtx_set_dtilib_peer_req();
1924 break;
1925
1926 case KER_READY:
1927 case KER_MUX:
1928 sig_ker_drx_set_dtilib_peer_req();
1929 sig_ker_dtx_set_dtilib_peer_req();
1930 break;
1931
1932 default:
1933 TRACE_ERROR( "UART_DTI_REQ unexpected" );
1934 break;
1935 }
1936 } /* sig_dti_ker_connection_opened_ind */
1937
1938
1939
1940 /*
1941 +------------------------------------------------------------------------------
1942 | Function : sig_dti_ker_connection_closed_ind
1943 +------------------------------------------------------------------------------
1944 | Description : Handles the DTILIB callback call DTI_REASON_CONNECTION_CLOSED
1945 |
1946 | This signal means that a dti connection has been closed by
1947 | the neighbour entity.
1948 |
1949 | Parameters : dlc_instance - affected dlc instance
1950 |
1951 +------------------------------------------------------------------------------
1952 */
1953 GLOBAL void sig_dti_ker_connection_closed_ind (U8 dlc_instance)
1954 {
1955 T_DLC *dlc;
1956
1957 TRACE_FUNCTION( "sig_dti_ker_connection_closed_ind" );
1958
1959 /*
1960 * set DLC
1961 */
1962 dlc = &uart_data->dlc_table[dlc_instance];
1963 uart_data->drx = dlc->drx;
1964 uart_data->dtx = dlc->dtx;
1965 /*
1966 * set DTI connection to closed state
1967 * if it is already closed, do nothing
1968 */
1969 if(dlc->dti_state NEQ DTI_CLOSED)
1970 {
1971 dlc->dti_state = DTI_CLOSED;
1972 sig_ker_drx_disconnected_mode_req();
1973 sig_ker_dtx_disconnected_mode_req();
1974 /*
1975 * inform MMI
1976 */
1977 {
1978 PALLOC (uart_dti_ind, UART_DTI_IND);
1979 uart_dti_ind->device = uart_data->device;
1980 uart_dti_ind->dlci = dlc->dlci;
1981 uart_dti_ind->dti_conn = UART_DISCONNECT_DTI;
1982 PSEND (hCommMMI, uart_dti_ind);
1983 }
1984 }
1985 } /* sig_dti_ker_connection_closed_ind */
1986 #endif /* DTILIB */