comparison src/g23m-aci/uart/uart_drxs.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 process internal signals as
19 | described in the SDL-documentation (DRX-statemachine)
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifndef UART_DRXS_C
24 #define UART_DRXS_C
25 #endif /* !UART_DRXS_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_drxf.h" /* to get the DRX function declarations */
59 #include "uart_kers.h" /* to get the KER signal declarations */
60 #ifdef FF_MULTI_PORT
61 #include "uart_ptxs.h" /* to get signal definitions for service TX */
62 #else /* FF_MULTI_PORT */
63 #include "uart_txs.h" /* to get signal definitions for service TX */
64 #endif /* FF_MULTI_PORT */
65
66 /*==== CONST ================================================================*/
67
68 /*==== LOCAL VARS ===========================================================*/
69
70 /*==== PRIVATE FUNCTIONS ====================================================*/
71
72 /*==== PUBLIC FUNCTIONS =====================================================*/
73
74
75
76 /*
77 +------------------------------------------------------------------------------
78 | Function : sig_ker_drx_ready_mode_req
79 +------------------------------------------------------------------------------
80 | Description : Handles the internal signal SIG_KER_DRX_READY_MODE_REQ
81 |
82 | Parameters : dlc_instance - dlc instance wich belongs to this DRX instance
83 |
84 +------------------------------------------------------------------------------
85 */
86 GLOBAL void sig_ker_drx_ready_mode_req (UBYTE dlc_instance)
87 {
88 TRACE_ISIG( "sig_ker_drx_ready_mode_req" );
89
90 uart_data->drx->dlc_instance = dlc_instance;
91
92 switch( GET_STATE( UART_SERVICE_DRX ) )
93 {
94 case DRX_DEAD:
95 /*
96 * new DLC starts with enabled data flow
97 */
98 uart_data->drx->data_flow = UART_FLOW_ENABLED;
99
100 #ifdef DTILIB
101 if((uart_data->drx->dti_drx_state NEQ DTI_CLOSED ) &&
102 (uart_data->drx->sending_state EQ UART_DRX_NOT_SENDING))
103 {
104 /*
105 * signal availability to higher layer if currently not sending
106 */
107 SET_STATE( UART_SERVICE_DRX, DRX_READY );
108 #ifdef FLOW_TRACE
109 sndcp_trace_flow_control(FLOW_TRACE_UART, FLOW_TRACE_DOWN, FLOW_TRACE_TOP, TRUE);
110 #endif /* FLOW_TRACE */
111 dti_start(
112 uart_hDTI,
113 uart_data->device,
114 UART_DTI_UP_INTERFACE,
115 uart_data->drx->dlc_instance);
116 }
117 #else /* DTILIB */
118 if((uart_data->drx->hComm_DRX_UPLINK NEQ VSI_ERROR ) &&
119 (uart_data->drx->sending_state EQ UART_DRX_NOT_SENDING))
120 {
121 /*
122 * signal availability to higher layer if currently not sending
123 */
124 PALLOC (dti_ready_ind, DTI_READY_IND);
125 SET_STATE( UART_SERVICE_DRX, DRX_READY );
126 dti_ready_ind->tui = uart_data->tui_uart;
127 dti_ready_ind->c_id = drx_get_channel_id();
128 #ifdef _SIMULATION_
129 dti_ready_ind->op_ack = 0;
130 #endif /* _SIMULATION_ */
131 #ifdef FLOW_TRACE
132 sndcp_trace_flow_control(FLOW_TRACE_UART, FLOW_TRACE_DOWN, FLOW_TRACE_TOP, TRUE);
133 #endif /* FLOW_TRACE */
134 PSEND (uart_data->drx->hComm_DRX_UPLINK, dti_ready_ind);
135 }
136 #endif /* DTILIB */
137 else
138 {
139 /*
140 * no peer yet, just switch to NOT READY and wait
141 * for the signal SIG_KER_DRX_SET_DTI_PEER_REQ
142 */
143 #ifdef DTILIB
144 if(uart_data->drx->dti_drx_state NEQ DTI_CLOSED )
145 dti_stop(
146 uart_hDTI,
147 uart_data->device,
148 UART_DTI_UP_INTERFACE,
149 uart_data->drx->dlc_instance
150 );
151 #endif /* DTILIB */
152 SET_STATE( UART_SERVICE_DRX, DRX_NOT_READY );
153 }
154 break;
155
156 case DRX_READY:
157 case DRX_NOT_READY:
158 case DRX_FLUSHING:
159 break;
160
161 default:
162 TRACE_ERROR( "SIG_KER_DRX_READY_MODE_REQ unexpected" );
163 break;
164 }
165 } /* sig_ker_drx_ready_mode_req() */
166
167
168
169 /*
170 +------------------------------------------------------------------------------
171 | Function : sig_ker_drx_dead_mode_req
172 +------------------------------------------------------------------------------
173 | Description : Handles the internal signal SIG_KER_DRX_DEAD_MODE_REQ
174 |
175 | Parameters : none
176 |
177 +------------------------------------------------------------------------------
178 */
179 GLOBAL void sig_ker_drx_dead_mode_req ()
180 {
181 TRACE_ISIG( "sig_ker_drx_dead_mode_req" );
182
183 switch( GET_STATE( UART_SERVICE_DRX ) )
184 {
185 case DRX_READY:
186 SET_STATE( UART_SERVICE_DRX, DRX_DEAD );
187 /*
188 * free all resources
189 */
190 #ifdef DTILIB
191 uart_data->drx->dti_drx_state = DTI_CLOSED;
192 #else /* DTILIB */
193 uart_data->drx->hComm_DRX_UPLINK = VSI_ERROR;
194 #endif /* DTILIB */
195 drx_free_resources();
196 break;
197
198 case DRX_FLUSHING:
199 sig_any_ker_flushed_ind(uart_data->drx->dlc_instance);
200 /* fall through */
201 case DRX_NOT_READY:
202 SET_STATE( UART_SERVICE_DRX, DRX_DEAD );
203
204 #ifdef DTILIB
205 uart_data->drx->dti_drx_state = DTI_CLOSED;
206 #else /* DTILIB */
207 uart_data->drx->hComm_DRX_UPLINK = VSI_ERROR;
208 #endif /* DTILIB */
209 if(uart_data->drx->sending_state EQ UART_DRX_NOT_SENDING)
210 {
211 /*
212 * signal that there is not any more data available
213 */
214 sig_drx_tx_data_not_available_ind(uart_data->drx->dlc_instance);
215 /*
216 * free all resources:
217 */
218 drx_free_resources();
219 }
220 else
221 uart_data->drx->sending_state = UART_DRX_INVALID;
222 break;
223
224 case DRX_DEAD:
225 break;
226
227 default:
228 TRACE_ERROR( "SIG_KER_DRX_DEAD_MODE_REQ unexpected" );
229 break;
230 }
231 } /* sig_ker_drx_dead_mode_req() */
232
233
234
235 /*
236 +------------------------------------------------------------------------------
237 | Function : sig_ker_drx_enable_req
238 +------------------------------------------------------------------------------
239 | Description : Handles the internal signal SIG_KER_DRX_ENABLE_REQ
240 |
241 | Parameters : none
242 |
243 +------------------------------------------------------------------------------
244 */
245 GLOBAL void sig_ker_drx_enable_req ()
246 {
247 TRACE_ISIG( "sig_ker_drx_enable_req" );
248
249 uart_data->drx->data_flow = UART_FLOW_ENABLED;
250
251 switch( GET_STATE( UART_SERVICE_DRX ) )
252 {
253 case DRX_READY:
254 break;
255
256 case DRX_FLUSHING:
257 case DRX_NOT_READY:
258 /*
259 * if DRX is not already sending and there is some data to be sent out,
260 * notify service TX that there is data available
261 */
262 if(uart_data->drx->sending_state EQ UART_DRX_NOT_SENDING)
263 {
264 if(uart_data->drx->received_data)
265 sig_drx_tx_data_available_ind( uart_data->drx->dlc_instance,
266 uart_data->drx->received_data,
267 uart_data->drx->read_pos);
268 else
269 #ifdef DTILIB
270 if( uart_data->drx->dti_drx_state NEQ DTI_CLOSED )
271 {
272 SET_STATE( UART_SERVICE_DRX, DRX_READY );
273 #ifdef FLOW_TRACE
274 sndcp_trace_flow_control(FLOW_TRACE_UART, FLOW_TRACE_DOWN, FLOW_TRACE_TOP, TRUE);
275 #endif /* FLOW_TRACE */
276 dti_start(
277 uart_hDTI,
278 uart_data->device,
279 UART_DTI_UP_INTERFACE,
280 uart_data->drx->dlc_instance
281 );
282 }
283 #else /* DTILIB */
284 if(uart_data->drx->hComm_DRX_UPLINK NEQ VSI_ERROR)
285 {
286 /*
287 * nothing more to send,
288 * signal to higher layer that we are able to receive more data
289 */
290 PALLOC (dti_ready_ind, DTI_READY_IND);
291 SET_STATE( UART_SERVICE_DRX, DRX_READY );
292 dti_ready_ind->tui = uart_data->tui_uart;
293 dti_ready_ind->c_id = drx_get_channel_id();
294 #ifdef _SIMULATION_
295 dti_ready_ind->op_ack = 0;
296 #endif /* _SIMULATION_ */
297 #ifdef FLOW_TRACE
298 sndcp_trace_flow_control(FLOW_TRACE_UART, FLOW_TRACE_DOWN, FLOW_TRACE_TOP, TRUE);
299 #endif /* FLOW_TRACE */
300 PSEND (uart_data->drx->hComm_DRX_UPLINK, dti_ready_ind);
301 }
302 #endif /* DTILIB */
303 }
304 break;
305
306 default:
307 TRACE_ERROR( "SIG_KER_DRX_ENABLE_REQ unexpected" );
308 break;
309 }
310 } /* sig_ker_drx_enable_req() */
311
312
313
314 /*
315 +------------------------------------------------------------------------------
316 | Function : sig_ker_drx_disable_req
317 +------------------------------------------------------------------------------
318 | Description : Handles the internal signal SIG_KER_DRX_DISABLE_REQ
319 |
320 | Parameters : none
321 |
322 +------------------------------------------------------------------------------
323 */
324 GLOBAL void sig_ker_drx_disable_req ()
325 {
326 TRACE_ISIG( "sig_ker_drx_disable_req" );
327
328 uart_data->drx->data_flow = UART_FLOW_DISABLED;
329
330 switch( GET_STATE( UART_SERVICE_DRX ) )
331 {
332 case DRX_READY:
333 break;
334
335 case DRX_FLUSHING:
336 case DRX_NOT_READY:
337 /*
338 * stop sending if possible
339 */
340 if(uart_data->drx->sending_state EQ UART_DRX_NOT_SENDING)
341 sig_drx_tx_data_not_available_ind(uart_data->drx->dlc_instance);
342 break;
343
344 default:
345 TRACE_ERROR( "SIG_KER_DRX_DISABLE_REQ unexpected" );
346 break;
347 }
348 } /* sig_ker_drx_disable_req() */
349
350
351
352 /*
353 +------------------------------------------------------------------------------
354 | Function : sig_tx_drx_sending_req
355 +------------------------------------------------------------------------------
356 | Description : Handles the internal signal SIG_TX_DRX_SENDING_REQ
357 |
358 | Parameters : dummy - description of parameter dummy
359 |
360 +------------------------------------------------------------------------------
361 */
362 GLOBAL void sig_tx_drx_sending_req ()
363 {
364 TRACE_ISIG( "sig_tx_drx_sending_req" );
365
366 switch( GET_STATE( UART_SERVICE_DRX ) )
367 {
368 case DRX_FLUSHING:
369 case DRX_NOT_READY:
370 uart_data->drx->sending_state = UART_DRX_SENDING;
371 break;
372
373 default:
374 TRACE_ERROR( "SIG_TX_DRX_SENDING_REQ unexpected" );
375 break;
376 }
377 } /* sig_tx_drx_sending_req() */
378
379
380
381 /*
382 +------------------------------------------------------------------------------
383 | Function : sig_tx_drx_data_sent_req
384 +------------------------------------------------------------------------------
385 | Description : Handles the internal signal SIG_TX_DRX_DATA_SENT_REQ
386 |
387 | Parameters : rest_data - generic data descriptor of "still to send" data
388 | pos - current position in first rest data buffer
389 |
390 +------------------------------------------------------------------------------
391 */
392 GLOBAL void sig_tx_drx_data_sent_req ( T_desc2 *rest_data, USHORT pos )
393 {
394 T_desc2 *next_desc;
395 T_desc2 *desc;
396
397 TRACE_ISIG( "sig_tx_drx_data_sent_req" );
398
399 switch( GET_STATE( UART_SERVICE_DRX ) )
400 {
401 case DRX_DEAD:
402 uart_data->drx->sending_state = UART_DRX_NOT_SENDING;
403 /*
404 * Since the service is dead, free all resources and the rest of data
405 */
406 drx_free_resources();
407 break;
408
409 case DRX_NOT_READY:
410 if(uart_data->drx->sending_state EQ UART_DRX_INVALID)
411 {
412 /*
413 * because we are in an invalid sending state, free all resources
414 */
415 drx_free_resources();
416 }
417 else
418 {
419 /*
420 * free all data descriptors in front of the remaining data
421 */
422 desc = uart_data->drx->received_data;
423 while((desc NEQ rest_data) && (desc NEQ NULL))
424 {
425 next_desc = (T_desc2 *)desc->next;
426 MFREE (desc);
427 desc = next_desc;
428 }
429 /*
430 * set received_data descriptor to remaining data, remember position
431 */
432 uart_data->drx->received_data = desc;
433 uart_data->drx->read_pos = pos;
434 }
435
436 uart_data->drx->sending_state = UART_DRX_NOT_SENDING;
437
438 if(uart_data->drx->data_flow EQ UART_FLOW_ENABLED)
439 {
440 if(uart_data->drx->received_data)
441 {
442 /*
443 * data flow is enabled and there is more data to send
444 */
445 sig_drx_tx_data_available_ind(uart_data->drx->dlc_instance,
446 uart_data->drx->received_data,
447 uart_data->drx->read_pos);
448 }
449 else
450 /*
451 * data flow is enabled but there is nothing more to send,
452 * so do positive flow control
453 */
454 #ifdef DTILIB
455 if( uart_data->drx->dti_drx_state NEQ DTI_CLOSED )
456 {
457 SET_STATE( UART_SERVICE_DRX, DRX_READY );
458 #ifdef FLOW_TRACE
459 sndcp_trace_flow_control(FLOW_TRACE_UART, FLOW_TRACE_DOWN, FLOW_TRACE_TOP, TRUE);
460 #endif /* FLOW_TRACE */
461 dti_start(
462 uart_hDTI,
463 uart_data->device,
464 UART_DTI_UP_INTERFACE,
465 uart_data->drx->dlc_instance
466 );
467 }
468 #else /* DTILIB */
469 if(uart_data->drx->hComm_DRX_UPLINK NEQ VSI_ERROR)
470 {
471 PALLOC (dti_ready_ind, DTI_READY_IND);
472 SET_STATE( UART_SERVICE_DRX, DRX_READY );
473 dti_ready_ind->tui = uart_data->tui_uart;
474 dti_ready_ind->c_id = drx_get_channel_id();
475 #ifdef _SIMULATION_
476 dti_ready_ind->op_ack = 0;
477 #endif /* _SIMULATION_ */
478 #ifdef FLOW_TRACE
479 sndcp_trace_flow_control(FLOW_TRACE_UART, FLOW_TRACE_DOWN, FLOW_TRACE_TOP, TRUE);
480 #endif /* FLOW_TRACE */
481 PSEND (uart_data->drx->hComm_DRX_UPLINK, dti_ready_ind);
482 }
483 #endif /* DTILIB */
484 }
485 break;
486
487 case DRX_FLUSHING:
488 /*
489 * free all data descriptors in front of the remaining data
490 */
491 desc = uart_data->drx->received_data;
492 while((desc NEQ rest_data) && (desc NEQ NULL))
493 {
494 next_desc = (T_desc2 *)desc->next;
495 MFREE (desc);
496 desc = next_desc;
497 }
498 /*
499 * set received_data descriptor to remaining data, remember position
500 */
501 uart_data->drx->received_data = desc;
502 uart_data->drx->read_pos = pos;
503
504 uart_data->drx->sending_state = UART_DRX_NOT_SENDING;
505
506 if(uart_data->drx->received_data)
507 {
508 if(uart_data->drx->data_flow EQ UART_FLOW_ENABLED)
509 /*
510 * data flow is enabled and there is more data to send
511 */
512 sig_drx_tx_data_available_ind(uart_data->drx->dlc_instance,
513 uart_data->drx->received_data,
514 uart_data->drx->read_pos);
515 }
516 else
517 #ifdef DTILIB
518 if(( uart_data->drx->dti_drx_state NEQ DTI_CLOSED ) &&
519 (uart_data->drx->data_flow EQ UART_FLOW_ENABLED))
520 {
521 SET_STATE( UART_SERVICE_DRX, DRX_READY );
522 sig_any_ker_flushed_ind(uart_data->drx->dlc_instance);
523 #ifdef FLOW_TRACE
524 sndcp_trace_flow_control(FLOW_TRACE_UART, FLOW_TRACE_DOWN, FLOW_TRACE_TOP, TRUE);
525 #endif /* FLOW_TRACE */
526 dti_start(
527 uart_hDTI,
528 uart_data->device,
529 UART_DTI_UP_INTERFACE,
530 uart_data->drx->dlc_instance
531 );
532 }
533 #else /* DTILIB */
534 if((uart_data->drx->hComm_DRX_UPLINK NEQ VSI_ERROR) &&
535 (uart_data->drx->data_flow EQ UART_FLOW_ENABLED))
536 {
537 /*
538 * data flow is enabled but there is nothing more to send,
539 * so send flush signal and positive flow control
540 */
541 PALLOC (dti_ready_ind, DTI_READY_IND);
542 SET_STATE( UART_SERVICE_DRX, DRX_READY );
543 sig_any_ker_flushed_ind(uart_data->drx->dlc_instance);
544 dti_ready_ind->tui = uart_data->tui_uart;
545 dti_ready_ind->c_id = drx_get_channel_id();
546 #ifdef _SIMULATION_
547 dti_ready_ind->op_ack = 0;
548 #endif /* _SIMULATION_ */
549 #ifdef FLOW_TRACE
550 sndcp_trace_flow_control(FLOW_TRACE_UART, FLOW_TRACE_DOWN, FLOW_TRACE_TOP, TRUE);
551 #endif /* FLOW_TRACE */
552 PSEND (uart_data->drx->hComm_DRX_UPLINK, dti_ready_ind);
553 }
554 #endif /* DTILIB */
555 else
556 {
557 /*
558 * data flushed
559 */
560 SET_STATE( UART_SERVICE_DRX, DRX_NOT_READY );
561 #ifdef DTILIB
562 dti_stop(
563 uart_hDTI,
564 uart_data->device,
565 UART_DTI_UP_INTERFACE,
566 uart_data->drx->dlc_instance
567 );
568 #endif /* DTILIB */
569 sig_any_ker_flushed_ind(uart_data->drx->dlc_instance);
570 }
571 break;
572
573 default:
574 TRACE_ERROR( "SIG_TX_DRX_DATA_SENT_REQ unexpected" );
575 break;
576 }
577 } /* sig_tx_drx_data_sent_req() */
578
579
580
581 #ifdef DTILIB
582
583 /*
584 +------------------------------------------------------------------------------
585 | Function : sig_ker_drx_disconnected_mode_req
586 +------------------------------------------------------------------------------
587 | Description : Handles the internal signal SIG_KER_DRX_DISCONNECTED_MODE_REQ
588 |
589 | Parameters : none
590 |
591 +------------------------------------------------------------------------------
592 */
593 GLOBAL void sig_ker_drx_disconnected_mode_req ()
594 {
595 TRACE_ISIG( "sig_ker_drx_disconnected_mode_req" );
596
597 uart_data->drx->dti_drx_state = DTI_CLOSED;
598
599 switch(GET_STATE( UART_SERVICE_DRX) )
600 {
601 case DRX_READY:
602 SET_STATE( UART_SERVICE_DRX, DRX_NOT_READY );
603 break;
604 case DRX_NOT_READY:
605 break;
606 default:
607 TRACE_ERROR( "SIG_KER_DRX_DISCONNECTED_MODE_REQ unexpected" );
608 break;
609 }
610
611 } /* sig_ker_drx_disconnected_mode_req() */
612
613
614
615 /*
616 +------------------------------------------------------------------------------
617 | Function : sig_ker_drx_set_dtilib_peer_req
618 +------------------------------------------------------------------------------
619 | Description : Handles the internal signal SIG_KER_DRX_SET_DTI_PEER_REQ
620 | which is used to inform the service DRX that from now on it
621 | needs to communicate with a (new) peer
622 |
623 | Parameters : -
624 |
625 +------------------------------------------------------------------------------
626 */
627 GLOBAL void sig_ker_drx_set_dtilib_peer_req ()
628 {
629 TRACE_ISIG( "sig_ker_drx_set_dtilib_peer_req" );
630
631 uart_data->drx->dti_drx_state = DTI_IDLE;
632
633 switch( GET_STATE( UART_SERVICE_DRX ) )
634 {
635 case DRX_READY:
636 case DRX_NOT_READY:
637 /*
638 * signal availability to higher layer if currently not sending
639 */
640 if((uart_data->drx->received_data EQ NULL) &&
641 (uart_data->drx->data_flow EQ UART_FLOW_ENABLED) &&
642 (uart_data->drx->sending_state EQ UART_DRX_NOT_SENDING))
643 {
644 SET_STATE( UART_SERVICE_DRX, DRX_READY );
645 #ifdef FLOW_TRACE
646 sndcp_trace_flow_control(FLOW_TRACE_UART, FLOW_TRACE_DOWN, FLOW_TRACE_TOP, TRUE);
647 #endif /* FLOW_TRACE */
648 dti_start(
649 uart_hDTI,
650 uart_data->device,
651 UART_DTI_UP_INTERFACE,
652 uart_data->drx->dlc_instance
653 );
654 }
655 else
656 {
657 SET_STATE( UART_SERVICE_DRX, DRX_NOT_READY );
658 dti_stop(
659 uart_hDTI,
660 uart_data->device,
661 UART_DTI_UP_INTERFACE,
662 uart_data->drx->dlc_instance
663 );
664 }
665 break;
666
667 case DRX_FLUSHING:
668 case DRX_DEAD:
669 break;
670
671 default:
672 TRACE_ERROR( "SIG_KER_DRX_SET_DTI_PEER_REQ unexpected" );
673 break;
674 }
675 } /* sig_ker_drx_set_dtilib_peer_req() */
676
677
678 #else /* DTILIB */
679
680 /*
681 +------------------------------------------------------------------------------
682 | Function : sig_ker_drx_set_dti_peer_req
683 +------------------------------------------------------------------------------
684 | Description : Handles the internal signal SIG_KER_DRX_SET_DTI_PEER_REQ
685 | which is used to inform the service DRX that from now on it
686 | needs to communicate with a (new) peer
687 |
688 | Parameters : tui_peer - transmission unit identifier of peer
689 | peer_handle - VSI handle of peer (channel has to be opened)
690 | c_id - channel identifier of peer
691 |
692 +------------------------------------------------------------------------------
693 */
694 GLOBAL void sig_ker_drx_set_dti_peer_req (USHORT tui_peer,
695 T_HANDLE peer_handle,
696 UBYTE c_id)
697 {
698 USHORT i,pos;
699
700 TRACE_ISIG( "sig_ker_drx_set_dti_peer_req" );
701
702 /*
703 * set new vsi handle and
704 */
705 uart_data->drx->hComm_DRX_UPLINK = peer_handle;
706
707 /*
708 * search position in table
709 */
710 pos = UART_INSTANCES * UART_MAX_NUMBER_OF_CHANNELS;
711 for(i = 0; i < pos; i++)
712 {
713 if((uart_cid_table[i].drx EQ uart_data->drx) ||
714 (uart_cid_table[i].c_id EQ c_id))
715 {
716 pos = i;
717 }
718 }
719
720 if(pos < (UART_INSTANCES * UART_MAX_NUMBER_OF_CHANNELS))
721 {
722 /*
723 * valid position in table, update entry
724 */
725 uart_cid_table[pos].c_id = c_id;
726 uart_cid_table[pos].drx = uart_data->drx;
727 uart_cid_table[pos].uart_data = uart_data;
728 }
729 else
730 {
731 /*
732 * create new entry in table
733 */
734 for(i = 0; i < UART_INSTANCES * UART_MAX_NUMBER_OF_CHANNELS; i++)
735 {
736 if(uart_cid_table[i].dtx EQ NULL)
737 {
738 /*
739 * free space found, insert data
740 */
741 uart_cid_table[i].c_id = c_id;
742 uart_cid_table[i].drx = uart_data->drx;
743 uart_cid_table[i].uart_data = uart_data;
744 break;
745 }
746 }
747 }
748
749 switch( GET_STATE( UART_SERVICE_DRX ) )
750 {
751 case DRX_READY:
752 case DRX_NOT_READY:
753 /*
754 * signal availability to higher layer if currently not sending
755 */
756 if((uart_data->drx->received_data EQ NULL) &&
757 (uart_data->drx->data_flow EQ UART_FLOW_ENABLED) &&
758 (uart_data->drx->sending_state EQ UART_DRX_NOT_SENDING))
759 {
760 PALLOC (dti_ready_ind, DTI_READY_IND);
761 SET_STATE( UART_SERVICE_DRX, DRX_READY );
762 dti_ready_ind->tui = uart_data->tui_uart;
763 dti_ready_ind->c_id = drx_get_channel_id();
764 #ifdef _SIMULATION_
765 dti_ready_ind->op_ack = 0;
766 #endif /* _SIMULATION_ */
767 #ifdef FLOW_TRACE
768 sndcp_trace_flow_control(FLOW_TRACE_UART, FLOW_TRACE_DOWN, FLOW_TRACE_TOP, TRUE);
769 #endif /* FLOW_TRACE */
770 PSEND (uart_data->drx->hComm_DRX_UPLINK, dti_ready_ind);
771 }
772 else
773 {
774 SET_STATE( UART_SERVICE_DRX, DRX_NOT_READY );
775 }
776 break;
777
778 case DRX_FLUSHING:
779 case DRX_DEAD:
780 break;
781
782 default:
783 TRACE_ERROR( "SIG_KER_DRX_SET_DTI_PEER_REQ unexpected" );
784 break;
785 }
786 } /* sig_ker_drx_set_dti_peer_req() */
787
788 #endif /* DTILIB */
789
790
791 /*
792 +------------------------------------------------------------------------------
793 | Function : sig_ker_drx_flush_req
794 +------------------------------------------------------------------------------
795 | Description : Handles the internal signal SIG_KER_DRX_FLUSH_REQ which is used
796 | to trigger flushing of the service.
797 |
798 | Parameters : no parameters
799 |
800 +------------------------------------------------------------------------------
801 */
802 GLOBAL void sig_ker_drx_flush_req ()
803 {
804 TRACE_ISIG( "sig_ker_drx_flush_req" );
805
806 switch( GET_STATE( UART_SERVICE_DRX ) )
807 {
808 case DRX_READY:
809 sig_any_ker_flushed_ind(uart_data->drx->dlc_instance);
810 break;
811
812 case DRX_NOT_READY:
813 if((uart_data->drx->received_data) &&
814 (uart_data->drx->sending_state NEQ UART_DRX_INVALID))
815 {
816 SET_STATE( UART_SERVICE_DRX, DRX_FLUSHING );
817 }
818 else
819 {
820 sig_any_ker_flushed_ind(uart_data->drx->dlc_instance);
821 }
822 break;
823
824 case DRX_FLUSHING:
825 break;
826
827 default:
828 TRACE_ERROR( "SIG_KER_DRX_FLUSH_REQ unexpected" );
829 break;
830 }
831 } /* sig_ker_drx_flush_req() */