FreeCalypso > hg > fc-tourmaline
comparison src/g23m-aci/uart/uart_dtxs.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 (DTX-statemachine) | |
20 +----------------------------------------------------------------------------- | |
21 */ | |
22 | |
23 #ifndef UART_DTXS_C | |
24 #define UART_DTXS_C | |
25 #endif /* !UART_DTXS_C */ | |
26 | |
27 #define ENTITY_UART | |
28 | |
29 /*==== INCLUDES =============================================================*/ | |
30 | |
31 #ifdef _SIMULATION_ | |
32 #include <stdio.h> | |
33 #endif | |
34 #ifdef WIN32 | |
35 #include "nucleus.h" | |
36 #endif /* WIN32 */ | |
37 #include "typedefs.h" /* to get Condat data types */ | |
38 #include "vsi.h" /* to get a lot of macros */ | |
39 #include "macdef.h" /* to get a lot of macros */ | |
40 #include "custom.h" | |
41 #include "gsm.h" /* to get a lot of macros */ | |
42 #include "cnf_uart.h" /* to get cnf-definitions */ | |
43 #include "mon_uart.h" /* to get mon-definitions */ | |
44 #include "prim.h" /* to get the definitions of used SAP and directions */ | |
45 #include "dti.h" /* to get dti lib */ | |
46 #include "pei.h" /* to get PEI interface */ | |
47 #ifdef FF_MULTI_PORT | |
48 #include "gsi.h" /* to get definitions of serial driver */ | |
49 #else /* FF_MULTI_PORT */ | |
50 #ifdef _TARGET_ | |
51 #include "uart/serialswitch.h" | |
52 #include "uart/traceswitch.h" | |
53 #else /* _TARGET_ */ | |
54 #include "serial_dat.h" /* to get definitions of serial driver */ | |
55 #endif /* _TARGET_ */ | |
56 #endif /* FF_MULTI_PORT */ | |
57 #include "uart.h" /* to get the global entity definitions */ | |
58 | |
59 #include "uart_dtxf.h" /* to get DTX function definitions */ | |
60 #include "uart_dtxp.h" /* to get DTX primitive definitions */ | |
61 #include "uart_kers.h" /* to get KER signal definitions */ | |
62 #include "uart_rts.h" /* to get RT signal definitions */ | |
63 #ifdef FF_MULTI_PORT | |
64 #include "uart_prxs.h" /* to get signal definitions for service TX */ | |
65 #else /* FF_MULTI_PORT */ | |
66 #include "uart_rxs.h" /* to get TX signal definitions */ | |
67 #endif /* FF_MULTI_PORT */ | |
68 #include <string.h> /* JK, delete warnings: to get memmove, memcpy */ | |
69 | |
70 /*==== CONST ================================================================*/ | |
71 | |
72 /*==== LOCAL VARS ===========================================================*/ | |
73 | |
74 /*==== PRIVATE FUNCTIONS ====================================================*/ | |
75 | |
76 /*==== PUBLIC FUNCTIONS =====================================================*/ | |
77 | |
78 | |
79 | |
80 /* | |
81 +------------------------------------------------------------------------------ | |
82 | Function : sig_ker_dtx_ready_mode_req | |
83 +------------------------------------------------------------------------------ | |
84 | Description : Handles the internal signal SIG_KER_DTX_READY_MODE_REQ | |
85 | | |
86 | Parameters : dlc_instance - dlc instance wich belongs to this DTX instance | |
87 | | |
88 +------------------------------------------------------------------------------ | |
89 */ | |
90 GLOBAL void sig_ker_dtx_ready_mode_req (UBYTE dlc_instance) | |
91 { | |
92 TRACE_ISIG( "sig_ker_dtx_ready_mode_req" ); | |
93 | |
94 uart_data->dtx->dlc_instance = dlc_instance; | |
95 | |
96 switch( GET_STATE( UART_SERVICE_DTX ) ) | |
97 { | |
98 case DTX_DEAD: | |
99 SET_STATE( UART_SERVICE_DTX, DTX_NOT_READY ); | |
100 | |
101 /* | |
102 * reset line states | |
103 */ | |
104 uart_data->dtx->st_flow = DTI_FLOW_ON; | |
105 uart_data->dtx->st_line_sa = DTI_SA_ON; | |
106 uart_data->dtx->st_line_sb = DTI_SB_ON; | |
107 uart_data->dtx->st_break_len = DTI_BREAK_OFF; | |
108 uart_data->dtx->detect_escape = TRUE; | |
109 | |
110 uart_data->dtx->data_flow = UART_FLOW_ENABLED; | |
111 if(uart_data->dtx->receiving_state EQ UART_DTX_NOT_RECEIVING) | |
112 { | |
113 /* | |
114 * reset escape sequence detection | |
115 */ | |
116 dtx_set_esd_state( UART_ESD_NULL ); | |
117 uart_data->dtx->detect_escape = TRUE; | |
118 if(vsi_t_time (VSI_CALLER &(uart_data->dtx->esd_guard_time)) | |
119 NEQ VSI_OK) | |
120 { | |
121 TRACE_ERROR_P1("VSI entity: Can't restart timer, uart_dtxs.c(%d)", | |
122 __LINE__); | |
123 } | |
124 uart_data->dtx->esd_pos = 0; | |
125 /* | |
126 * start reception | |
127 */ | |
128 dtx_allocate_resources(); | |
129 sig_dtx_rx_ready_to_receive_req( uart_data->dtx->dlc_instance, | |
130 uart_data->dtx->to_send_data, | |
131 uart_data->dtx->write_pos, | |
132 uart_data->dtx->cur_desc_size ); | |
133 } | |
134 break; | |
135 | |
136 case DTX_READY: | |
137 case DTX_NOT_READY: | |
138 break; | |
139 | |
140 default: | |
141 TRACE_ERROR( "SIG_KER_DTX_READY_MODE_REQ unexpected" ); | |
142 break; | |
143 } | |
144 } /* sig_ker_dtx_ready_mode_req() */ | |
145 | |
146 | |
147 | |
148 /* | |
149 +------------------------------------------------------------------------------ | |
150 | Function : sig_ker_dtx_dead_mode_req | |
151 +------------------------------------------------------------------------------ | |
152 | Description : Handles the internal signal SIG_KER_DTX_DEAD_MODE_REQ | |
153 | | |
154 | Parameters : none | |
155 | | |
156 +------------------------------------------------------------------------------ | |
157 */ | |
158 GLOBAL void sig_ker_dtx_dead_mode_req () | |
159 { | |
160 TRACE_ISIG( "sig_ker_dtx_dead_mode_req" ); | |
161 | |
162 switch( GET_STATE( UART_SERVICE_DTX ) ) | |
163 { | |
164 case DTX_READY: | |
165 case DTX_NOT_READY: | |
166 SET_STATE( UART_SERVICE_DTX, DTX_DEAD ); | |
167 /* | |
168 * reset hComm_DTX_UPLINK and size_multiplier | |
169 */ | |
170 uart_data->dtx->dti_dtx_state = DTI_CLOSED; | |
171 uart_data->dtx->size_multiplier = 3; | |
172 | |
173 if(uart_data->dtx->receiving_state EQ UART_DTX_NOT_RECEIVING) | |
174 { | |
175 /* | |
176 * free recources and stop receiving | |
177 */ | |
178 sig_dtx_rx_not_ready_to_receive_req(uart_data->dtx->dlc_instance); | |
179 dtx_free_resources(); | |
180 } | |
181 else | |
182 uart_data->dtx->receiving_state = UART_DTX_INVALID; | |
183 break; | |
184 | |
185 case DTX_DEAD: | |
186 break; | |
187 | |
188 default: | |
189 TRACE_ERROR( "SIG_KER_DTX_DEAD_MODE_REQ unexpected" ); | |
190 break; | |
191 } | |
192 } /* sig_ker_dtx_dead_mode_req() */ | |
193 | |
194 | |
195 | |
196 /* | |
197 +------------------------------------------------------------------------------ | |
198 | Function : sig_rx_dtx_receiving_ind | |
199 +------------------------------------------------------------------------------ | |
200 | Description : Handles the internal signal SIG_RX_DTX_RECEIVING_IND | |
201 | | |
202 | Parameters : none | |
203 | | |
204 +------------------------------------------------------------------------------ | |
205 */ | |
206 GLOBAL void sig_rx_dtx_receiving_ind () | |
207 { | |
208 TRACE_ISIG( "sig_rx_dtx_receiving_ind" ); | |
209 | |
210 uart_data->dtx->receiving_state = UART_DTX_RECEIVING; | |
211 | |
212 switch( GET_STATE( UART_SERVICE_DTX ) ) | |
213 { | |
214 case DTX_READY: | |
215 case DTX_NOT_READY: | |
216 break; | |
217 | |
218 default: | |
219 TRACE_ERROR( "SIG_RX_DTX_RECEIVING_IND unexpected" ); | |
220 break; | |
221 } | |
222 } /* sig_ker_dtx_receiving_ind() */ | |
223 | |
224 | |
225 | |
226 /* | |
227 +------------------------------------------------------------------------------ | |
228 | Function : sig_rx_dtx_data_received_ind | |
229 +------------------------------------------------------------------------------ | |
230 | Description : Handles the internal signal SIG_RX_DTX_DATA_RECEIVED_IND | |
231 | | |
232 | Parameters : none | |
233 | | |
234 +------------------------------------------------------------------------------ | |
235 */ | |
236 GLOBAL void sig_rx_dtx_data_received_ind (T_desc2* received_data, | |
237 USHORT write_pos) | |
238 { | |
239 T_DATA_FLOW_STATE old_data_flow; | |
240 T_desc2* temp_desc; | |
241 USHORT esd_pos; | |
242 T_TIME cur_time; | |
243 | |
244 TRACE_ISIG( "sig_rx_dtx_data_received_ind" ); | |
245 | |
246 #ifdef UART_RANGE_CHECK | |
247 if(received_data EQ NULL) | |
248 { | |
249 TRACE_EVENT("ERROR: received_data is NULL"); | |
250 } | |
251 else if((*((ULONG*)((UBYTE*)received_data - 8))) NEQ 0) | |
252 { | |
253 TRACE_EVENT_P1("ERROR: received_data=%08x is not allocated", | |
254 received_data); | |
255 } | |
256 if(uart_data->dtx->to_send_data NEQ received_data) | |
257 { | |
258 TRACE_EVENT_P2("ERROR: to_send_data=%08x NEQ received_data=%08x", | |
259 uart_data->dtx->to_send_data, | |
260 received_data); | |
261 } | |
262 if(uart_data->dtx->to_send_data->len > uart_data->dtx->cur_desc_size) | |
263 { | |
264 TRACE_EVENT_P2("ERROR: to_send_data->len=%d > cur_desc_size=%d", | |
265 uart_data->dtx->to_send_data->len, | |
266 uart_data->dtx->cur_desc_size); | |
267 } | |
268 if(write_pos > uart_data->dtx->cur_desc_size) | |
269 { | |
270 TRACE_EVENT_P2("ERROR: write_pos=%d > cur_desc_size=%d", | |
271 write_pos, | |
272 uart_data->dtx->cur_desc_size); | |
273 } | |
274 if(uart_data->dtx->to_send_data->len > write_pos) | |
275 { | |
276 TRACE_EVENT_P2("ERROR: to_send_data->len=%d > write_pos=%d", | |
277 uart_data->dtx->to_send_data->len, | |
278 write_pos); | |
279 } | |
280 if(uart_data->dtx->esd_pos > write_pos) | |
281 { | |
282 TRACE_EVENT_P2("ERROR: esd_pos=%d > write_pos=%d", | |
283 uart_data->dtx->esd_pos, | |
284 write_pos); | |
285 } | |
286 switch(dtx_get_esd_state()) | |
287 { | |
288 case UART_ESD_DETECTED: | |
289 if(uart_data->dtx->esd_pos < 3) | |
290 { | |
291 TRACE_EVENT_P1("ERROR: esd_pos=%d < 3 in UART_ESD_DETECTED state", | |
292 uart_data->dtx->esd_pos); | |
293 } | |
294 break; | |
295 case UART_ESD_CHAR_1: | |
296 if(uart_data->dtx->esd_pos < 1) | |
297 { | |
298 TRACE_EVENT_P1("ERROR: esd_pos=%d < 1 in UART_ESD_CHAR_1 state", | |
299 uart_data->dtx->esd_pos); | |
300 } | |
301 break; | |
302 case UART_ESD_CHAR_2: | |
303 if(uart_data->dtx->esd_pos < 2) | |
304 { | |
305 TRACE_EVENT_P1("ERROR: esd_pos=%d < 2 in UART_ESD_CHAR_2 state", | |
306 uart_data->dtx->esd_pos); | |
307 } | |
308 break; | |
309 case UART_ESD_CHAR_3: | |
310 if(uart_data->dtx->esd_pos < 3) | |
311 { | |
312 TRACE_EVENT_P1("ERROR: esd_pos=%d < 3 in UART_ESD_CHAR_3 state", | |
313 uart_data->dtx->esd_pos); | |
314 } | |
315 break; | |
316 } | |
317 #endif /* UART_RANGE_CHECK */ | |
318 | |
319 /* | |
320 * store new write position, | |
321 * current data_flow state and | |
322 * current data descriptor | |
323 */ | |
324 uart_data->dtx->write_pos = write_pos; | |
325 old_data_flow = uart_data->dtx->data_flow; | |
326 temp_desc = received_data; | |
327 | |
328 /* | |
329 * Introduce local variable here in order to prevent | |
330 * the target compiler from doing wrong calculations ... | |
331 */ | |
332 esd_pos = uart_data->dtx->esd_pos; | |
333 | |
334 /* | |
335 * escape sequence detection | |
336 */ | |
337 if(uart_data->dtx->receiving_state EQ UART_DTX_RECEIVING && | |
338 uart_data->dtx->detect_escape EQ TRUE) | |
339 { | |
340 if (vsi_t_time (VSI_CALLER &cur_time) EQ VSI_OK) | |
341 { | |
342 switch(dtx_get_esd_state()) | |
343 { | |
344 case UART_ESD_DETECTED: | |
345 /* | |
346 * remove escape characters because escape sequence was detected | |
347 */ | |
348 if(uart_data->dtx->write_pos > esd_pos) | |
349 { | |
350 memmove(&temp_desc->buffer[esd_pos - 3], | |
351 &temp_desc->buffer[esd_pos], | |
352 uart_data->dtx->write_pos - esd_pos); | |
353 } | |
354 uart_data->dtx->write_pos-= 3; | |
355 esd_pos -= 3; | |
356 uart_data->dtx->esd_pos = esd_pos; | |
357 dtx_set_esd_state( UART_ESD_NULL ); | |
358 /* fall through */ | |
359 case UART_ESD_NULL: | |
360 #ifdef _SIMULATION_ | |
361 TRACE_EVENT_P2("uart_data->act_gp: %d, silence: %d", | |
362 uart_data->act_gp, | |
363 (cur_time - uart_data->dtx->esd_guard_time)); | |
364 #endif /* _SIMULATION_ */ | |
365 if(esd_pos >= temp_desc->len) | |
366 break; | |
367 | |
368 if(((cur_time - | |
369 uart_data->dtx->esd_guard_time) < uart_data->act_gp) || | |
370 (temp_desc-> | |
371 buffer[esd_pos] NEQ uart_data->act_ec)) | |
372 { | |
373 /* | |
374 * set new reference time and | |
375 * update esd_pos | |
376 */ | |
377 esd_pos = temp_desc->len; | |
378 uart_data->dtx->esd_pos = esd_pos; | |
379 uart_data->dtx->esd_guard_time = cur_time; | |
380 break; | |
381 } | |
382 /* | |
383 * first guard period complete and | |
384 * first escape character detected | |
385 */ | |
386 #ifdef _SIMULATION_ | |
387 TRACE_EVENT("+ + + first guard period complete + + +"); | |
388 #endif /* _SIMULATION_ */ | |
389 dtx_set_esd_state( UART_ESD_CHAR_1 ); | |
390 esd_pos++; | |
391 uart_data->dtx->esd_pos = esd_pos; | |
392 uart_data->dtx->esd_guard_time = cur_time; | |
393 sig_dtx_rt_start_tesd_req (uart_data->act_gp); | |
394 /* fall trough */ | |
395 case UART_ESD_CHAR_1: | |
396 if(esd_pos >= temp_desc->len) | |
397 { | |
398 /* | |
399 * hide 1 character | |
400 */ | |
401 temp_desc->len = esd_pos - 1; | |
402 temp_desc->size = temp_desc->len; | |
403 break; | |
404 } | |
405 | |
406 if(temp_desc-> | |
407 buffer[esd_pos] NEQ uart_data->act_ec) | |
408 { | |
409 /* | |
410 * second character is not an escape character | |
411 */ | |
412 dtx_set_esd_state( UART_ESD_NULL ); | |
413 esd_pos = temp_desc->len; | |
414 uart_data->dtx->esd_pos = esd_pos; | |
415 uart_data->dtx->esd_guard_time = cur_time; | |
416 break; | |
417 } | |
418 /* | |
419 * second escape character received | |
420 */ | |
421 dtx_set_esd_state( UART_ESD_CHAR_2 ); | |
422 esd_pos++; | |
423 uart_data->dtx->esd_pos = esd_pos; | |
424 /* fall trough */ | |
425 case UART_ESD_CHAR_2: | |
426 if(esd_pos >= temp_desc->len) | |
427 { | |
428 /* | |
429 * hide 2 characters | |
430 */ | |
431 temp_desc->len = esd_pos - 2; | |
432 temp_desc->size = temp_desc->len; | |
433 break; | |
434 } | |
435 /* | |
436 * set new reference time | |
437 */ | |
438 uart_data->dtx->esd_guard_time = cur_time; | |
439 | |
440 if(temp_desc-> | |
441 buffer[esd_pos] NEQ uart_data->act_ec) | |
442 { | |
443 /* | |
444 * third character is not an escape character | |
445 */ | |
446 dtx_set_esd_state( UART_ESD_NULL ); | |
447 esd_pos = temp_desc->len; | |
448 uart_data->dtx->esd_pos = esd_pos; | |
449 break; | |
450 } | |
451 /* | |
452 * third escape character received | |
453 */ | |
454 dtx_set_esd_state( UART_ESD_CHAR_3 ); | |
455 esd_pos++; | |
456 uart_data->dtx->esd_pos = esd_pos; | |
457 sig_dtx_rt_start_tesd_req (uart_data->act_gp); | |
458 /* fall trough */ | |
459 case UART_ESD_CHAR_3: | |
460 if(esd_pos >= temp_desc->len) | |
461 { | |
462 /* | |
463 * hide 3 characters | |
464 */ | |
465 temp_desc->len = esd_pos - 3; | |
466 temp_desc->size = temp_desc->len; | |
467 break; | |
468 } | |
469 /* | |
470 * fourth character received | |
471 */ | |
472 dtx_set_esd_state( UART_ESD_NULL ); | |
473 esd_pos = temp_desc->len; | |
474 uart_data->dtx->esd_pos = esd_pos; | |
475 uart_data->dtx->esd_guard_time = cur_time; | |
476 break; | |
477 | |
478 default: | |
479 TRACE_ERROR("wrong esd state"); | |
480 break; | |
481 } | |
482 } | |
483 else | |
484 { | |
485 TRACE_ERROR_P1("VSI entity: Can't restart timer, uart_dtxs.c(%d)", | |
486 __LINE__); | |
487 } | |
488 } | |
489 | |
490 switch( GET_STATE( UART_SERVICE_DTX ) ) | |
491 { | |
492 case DTX_DEAD: | |
493 dtx_free_resources(); | |
494 uart_data->dtx->receiving_state = UART_DTX_NOT_RECEIVING; | |
495 break; | |
496 | |
497 case DTX_READY: | |
498 /* | |
499 * enable data flow if necessary | |
500 */ | |
501 if(old_data_flow NEQ UART_FLOW_ENABLED) | |
502 { | |
503 uart_data->dtx->data_flow = UART_FLOW_ENABLED; | |
504 sig_dtx_ker_enable_ind(uart_data->dtx->dlc_instance); | |
505 } | |
506 | |
507 if(uart_data->dtx->receiving_state EQ UART_DTX_RECEIVING) | |
508 { | |
509 /* | |
510 * if data to send available or | |
511 * line states changed | |
512 */ | |
513 if((temp_desc->len) || | |
514 (uart_data->dtx->lines_changed)) | |
515 { | |
516 PALLOC_DESC2 (dti_data_ind, DTI2_DATA_IND); | |
517 SET_STATE( UART_SERVICE_DTX, DTX_NOT_READY ); | |
518 | |
519 if(temp_desc->len) | |
520 { | |
521 /* | |
522 * mark entity descriptor as invalid, since data will be forwarded | |
523 */ | |
524 uart_data->dtx->to_send_data = NULL; | |
525 | |
526 dti_data_ind->desc_list2.first = (ULONG)temp_desc; | |
527 dti_data_ind->desc_list2.list_len = temp_desc->len; | |
528 | |
529 /* | |
530 * calculate new size multiplier according to fillrate of buffer | |
531 */ | |
532 dtx_calculate_size_multiplier (temp_desc, old_data_flow); | |
533 /* | |
534 * allocate a new descriptor with size according to new size_multiplier | |
535 */ | |
536 dtx_allocate_resources(); | |
537 /* | |
538 * Check for data which has not yet been validated, i.e. because | |
539 * the frame containing the data has not yet been received completely. | |
540 * In this case, the not yet validated data is copied to the newly | |
541 * allocated descriptor. | |
542 */ | |
543 if(uart_data->dtx->write_pos > temp_desc->len) | |
544 { | |
545 memcpy(uart_data->dtx->to_send_data->buffer, | |
546 &temp_desc->buffer[temp_desc->len], | |
547 uart_data->dtx->write_pos - temp_desc->len); | |
548 uart_data->dtx->write_pos-= temp_desc->len; | |
549 } | |
550 esd_pos-= temp_desc->len; | |
551 uart_data->dtx->esd_pos = esd_pos; | |
552 } | |
553 else | |
554 { | |
555 /* | |
556 * just line states has been changed | |
557 */ | |
558 dti_data_ind->desc_list2.first = (ULONG)NULL; | |
559 dti_data_ind->desc_list2.list_len = 0; | |
560 } | |
561 | |
562 /* | |
563 * set line states and | |
564 * mark line states as unchanged; | |
565 */ | |
566 dti_data_ind->parameters.st_lines.st_flow = uart_data->dtx->st_flow; | |
567 dti_data_ind->parameters.st_lines.st_line_sa = uart_data->dtx->st_line_sa; | |
568 dti_data_ind->parameters.st_lines.st_line_sb = uart_data->dtx->st_line_sb; | |
569 dti_data_ind->parameters.st_lines.st_break_len = uart_data->dtx->st_break_len; | |
570 | |
571 uart_data->dtx->lines_changed = FALSE; | |
572 uart_data->dtx->st_break_len = DTI_BREAK_OFF; | |
573 | |
574 dti_send_data( | |
575 uart_hDTI, | |
576 uart_data->device, | |
577 UART_DTI_UP_INTERFACE, | |
578 uart_data->dtx->dlc_instance, | |
579 dti_data_ind | |
580 ); | |
581 } | |
582 } | |
583 else | |
584 { | |
585 /* | |
586 * invalid data | |
587 * free recources and allocate a new descriptor because | |
588 * size_multiplier may have changed | |
589 */ | |
590 dtx_free_resources(); | |
591 dtx_allocate_resources(); | |
592 /* | |
593 * reset escape sequence detection | |
594 */ | |
595 dtx_set_esd_state( UART_ESD_NULL ); | |
596 if(vsi_t_time (VSI_CALLER &(uart_data->dtx->esd_guard_time)) NEQ VSI_OK) | |
597 { | |
598 TRACE_ERROR_P1("VSI entity: Can't restart timer, uart_dtxs.c(%d)", | |
599 __LINE__); | |
600 } | |
601 | |
602 esd_pos = 0; | |
603 uart_data->dtx->esd_pos = esd_pos; | |
604 } | |
605 | |
606 /* | |
607 * signal availability to receive to RX service | |
608 */ | |
609 uart_data->dtx->receiving_state = UART_DTX_NOT_RECEIVING; | |
610 sig_dtx_rx_ready_to_receive_req( uart_data->dtx->dlc_instance, | |
611 uart_data->dtx->to_send_data, | |
612 uart_data->dtx->write_pos, | |
613 uart_data->dtx->cur_desc_size ); | |
614 break; | |
615 | |
616 case DTX_NOT_READY: | |
617 if(uart_data->dtx->receiving_state EQ UART_DTX_RECEIVING) | |
618 { | |
619 uart_data->dtx->receiving_state = UART_DTX_NOT_RECEIVING; | |
620 if((old_data_flow NEQ UART_FLOW_DISABLED) && | |
621 ((uart_data->dtx->cur_desc_size - temp_desc->len) < | |
622 ((USHORT)uart_data->n1 << 1))) | |
623 { | |
624 /* | |
625 * the service DTX is receiving but there is not enough space left | |
626 * therefore it is necessary to disable the data flow | |
627 */ | |
628 uart_data->dtx->data_flow = UART_FLOW_DISABLED; | |
629 sig_dtx_ker_disable_ind(uart_data->dtx->dlc_instance); | |
630 } | |
631 if((uart_data->dtx->cur_desc_size - | |
632 esd_pos) >= uart_data->n1) | |
633 { | |
634 /* | |
635 * there is still enough space left to continue reception | |
636 */ | |
637 sig_dtx_rx_ready_to_receive_req(uart_data->dtx->dlc_instance, | |
638 uart_data->dtx->to_send_data, | |
639 uart_data->dtx->write_pos, | |
640 uart_data->dtx->cur_desc_size); | |
641 } | |
642 } | |
643 else | |
644 { | |
645 /* | |
646 * invalid data | |
647 * free recources and allocate a new descriptor | |
648 * because size_multiplier may have changed | |
649 */ | |
650 dtx_free_resources(); | |
651 dtx_allocate_resources(); | |
652 /* | |
653 * reset escape sequence detection | |
654 */ | |
655 dtx_set_esd_state( UART_ESD_NULL ); | |
656 if(vsi_t_time (VSI_CALLER &(uart_data->dtx->esd_guard_time)) NEQ VSI_OK) | |
657 { | |
658 TRACE_ERROR_P1("VSI entity: Can't restart timer, uart_dtxs.c(%d)", | |
659 __LINE__); | |
660 } | |
661 | |
662 esd_pos = 0; | |
663 uart_data->dtx->esd_pos = esd_pos; | |
664 /* | |
665 * enable flow control if necessary | |
666 */ | |
667 if(old_data_flow NEQ UART_FLOW_ENABLED) | |
668 { | |
669 uart_data->dtx->data_flow = UART_FLOW_ENABLED; | |
670 sig_dtx_ker_enable_ind(uart_data->dtx->dlc_instance); | |
671 } | |
672 /* | |
673 * signal availability to receive to RX service | |
674 */ | |
675 uart_data->dtx->receiving_state = UART_DTX_NOT_RECEIVING; | |
676 sig_dtx_rx_ready_to_receive_req( uart_data->dtx->dlc_instance, | |
677 uart_data->dtx->to_send_data, | |
678 uart_data->dtx->write_pos, | |
679 uart_data->dtx->cur_desc_size ); | |
680 } | |
681 break; | |
682 | |
683 default: | |
684 TRACE_ERROR( "SIG_RX_DTX_DATA_RECEIVED_IND unexpected" ); | |
685 break; | |
686 | |
687 } | |
688 } /* sig_rx_dtx_data_received_ind() */ | |
689 | |
690 | |
691 /* | |
692 +------------------------------------------------------------------------------ | |
693 | Function : sig_ker_dtx_line_states_req | |
694 +------------------------------------------------------------------------------ | |
695 | Description : Handles the internal signal SIG_KER_DTX_LINE_STATES_REQ | |
696 | which indicates that one or more line status signals have | |
697 | changed | |
698 | | |
699 | Parameters : st_flow - flow control state (X bit) | |
700 | st_line_sa - line state SA | |
701 | st_line_sa - line state SB | |
702 | st_break_len - break length | |
703 | | |
704 +------------------------------------------------------------------------------ | |
705 */ | |
706 GLOBAL void sig_ker_dtx_line_states_req(UBYTE st_flow, | |
707 UBYTE st_line_sa, | |
708 UBYTE st_line_sb, | |
709 UBYTE st_break_len) | |
710 { | |
711 TRACE_ISIG( "sig_ker_dtx_line_states_req" ); | |
712 | |
713 switch( GET_STATE( UART_SERVICE_DTX ) ) | |
714 { | |
715 case DTX_READY: | |
716 if((st_flow NEQ uart_data->dtx->st_flow) || | |
717 (st_line_sa NEQ uart_data->dtx->st_line_sa) || | |
718 (st_line_sb NEQ uart_data->dtx->st_line_sb) || | |
719 (st_break_len NEQ uart_data->dtx->st_break_len)) | |
720 { | |
721 /* | |
722 * send line states to DTI peer | |
723 */ | |
724 PALLOC_DESC2 (dti_data_ind, DTI2_DATA_IND); | |
725 SET_STATE( UART_SERVICE_DTX, DTX_NOT_READY ); | |
726 | |
727 /* | |
728 * store new line states | |
729 */ | |
730 uart_data->dtx->st_flow = st_flow; | |
731 uart_data->dtx->st_line_sa = st_line_sa; | |
732 uart_data->dtx->st_line_sb = st_line_sb; | |
733 uart_data->dtx->st_break_len = st_break_len; | |
734 | |
735 /* | |
736 * just line states has been changed | |
737 */ | |
738 dti_data_ind->desc_list2.first = (ULONG)NULL; | |
739 dti_data_ind->desc_list2.list_len = 0; | |
740 /* | |
741 * set line states and | |
742 * mark line states as unchanged; | |
743 */ | |
744 dti_data_ind->parameters.st_lines.st_flow = uart_data->dtx->st_flow; | |
745 dti_data_ind->parameters.st_lines.st_line_sa = uart_data->dtx->st_line_sa; | |
746 dti_data_ind->parameters.st_lines.st_line_sb = uart_data->dtx->st_line_sb; | |
747 dti_data_ind->parameters.st_lines.st_line_sb = uart_data->dtx->st_line_sb; | |
748 dti_data_ind->parameters.st_lines.st_break_len = uart_data->dtx->st_break_len; | |
749 | |
750 uart_data->dtx->lines_changed = FALSE; | |
751 uart_data->dtx->st_break_len = DTI_BREAK_OFF; | |
752 | |
753 dti_send_data( | |
754 uart_hDTI, | |
755 uart_data->device, | |
756 UART_DTI_UP_INTERFACE, | |
757 uart_data->dtx->dlc_instance, | |
758 dti_data_ind | |
759 ); | |
760 } | |
761 break; | |
762 | |
763 case DTX_NOT_READY: | |
764 if((st_flow NEQ uart_data->dtx->st_flow) || | |
765 (st_line_sa NEQ uart_data->dtx->st_line_sa) || | |
766 (st_line_sb NEQ uart_data->dtx->st_line_sb) || | |
767 (st_break_len NEQ uart_data->dtx->st_break_len)) | |
768 { | |
769 /* | |
770 * If previously break detected keep information in | |
771 * uart_data->dtx->st_break_len | |
772 */ | |
773 if(uart_data->dtx->st_break_len EQ DTI_BREAK_OFF) | |
774 uart_data->dtx->st_break_len = st_break_len; | |
775 /* | |
776 * store new line states | |
777 */ | |
778 uart_data->dtx->st_flow = st_flow; | |
779 uart_data->dtx->st_line_sa = st_line_sa; | |
780 uart_data->dtx->st_line_sb = st_line_sb; | |
781 /* | |
782 * mark line states as changed | |
783 */ | |
784 uart_data->dtx->lines_changed = TRUE; | |
785 } | |
786 break; | |
787 | |
788 default: | |
789 TRACE_ERROR( "SIG_KER_DTX_LINE_STATES_REQ unexpected" ); | |
790 break; | |
791 } | |
792 } /* sig_ker_dtx_line_states_req */ | |
793 | |
794 | |
795 | |
796 /* | |
797 +------------------------------------------------------------------------------ | |
798 | Function : sig_ker_dtx_detect_escape_req | |
799 +------------------------------------------------------------------------------ | |
800 | Description : Handles the internal signal SIG_KER_DTX_DETECT_ESCAPE_REQ | |
801 | which enables escape sequence detection | |
802 | | |
803 | Parameters : detect_escape - TRUE/FALSE | |
804 | | |
805 +------------------------------------------------------------------------------ | |
806 */ | |
807 GLOBAL void sig_ker_dtx_detect_escape_req (UBYTE detect_escape) | |
808 { | |
809 TRACE_ISIG( "sig_ker_dtx_detect_req" ); | |
810 | |
811 uart_data->dtx->detect_escape = detect_escape; | |
812 } /* sig_ker_dtx_detect_req() */ | |
813 | |
814 | |
815 /* | |
816 +------------------------------------------------------------------------------ | |
817 | Function : sig_ker_dtx_disconnected_mode_req | |
818 +------------------------------------------------------------------------------ | |
819 | Description : Handles the internal signal SIG_KER_DTX_DISCONNECTED_MODE_REQ | |
820 | | |
821 | Parameters : none | |
822 | | |
823 +------------------------------------------------------------------------------ | |
824 */ | |
825 GLOBAL void sig_ker_dtx_disconnected_mode_req () | |
826 { | |
827 TRACE_ISIG( "sig_ker_dtx_disconnected_mode_req" ); | |
828 | |
829 uart_data->dtx->dti_dtx_state = DTI_CLOSED; | |
830 | |
831 switch(GET_STATE( UART_SERVICE_DTX) ) | |
832 { | |
833 case DTX_READY: | |
834 SET_STATE( UART_SERVICE_DTX, DTX_NOT_READY ); | |
835 break; | |
836 case DTX_NOT_READY: | |
837 break; | |
838 default: | |
839 TRACE_ERROR( "SIG_KER_DTX_DISCONNECTED_MODE_REQ unexpected" ); | |
840 break; | |
841 } | |
842 | |
843 } /* sig_ker_dtx_disconnected_mode_req() */ | |
844 | |
845 | |
846 | |
847 /* | |
848 +------------------------------------------------------------------------------ | |
849 | Function : sig_ker_dtx_set_dtilib_peer_req | |
850 +------------------------------------------------------------------------------ | |
851 | Description : Handles the internal signal SIG_KER_DTX_SET_DTI_PEER_REQ | |
852 | which is used to inform the service DTX that from now on it | |
853 | needs to communicate with a (new) peer | |
854 | | |
855 | Parameters : - | |
856 | | |
857 +------------------------------------------------------------------------------ | |
858 */ | |
859 GLOBAL void sig_ker_dtx_set_dtilib_peer_req () | |
860 | |
861 { | |
862 TRACE_ISIG( "sig_ker_dtx_set_dtilib_peer_req" ); | |
863 | |
864 /* | |
865 * set dtilib parameters | |
866 */ | |
867 uart_data->dtx->dti_dtx_state = DTI_IDLE; | |
868 | |
869 /* | |
870 * reset size_multiplier | |
871 */ | |
872 uart_data->dtx->size_multiplier = 3; | |
873 | |
874 /* | |
875 * switch to new DTX state depending on current state | |
876 */ | |
877 switch( GET_STATE( UART_SERVICE_DTX ) ) | |
878 { | |
879 case DTX_READY: | |
880 SET_STATE( UART_SERVICE_DTX, DTX_NOT_READY ); | |
881 /* fall through */ | |
882 case DTX_NOT_READY: | |
883 { | |
884 if(uart_data->dtx->receiving_state EQ UART_DTX_NOT_RECEIVING) | |
885 { | |
886 /* | |
887 * reset received data | |
888 */ | |
889 dtx_free_resources(); | |
890 dtx_allocate_resources(); | |
891 /* | |
892 * reset escape sequence detection | |
893 */ | |
894 dtx_set_esd_state( UART_ESD_NULL ); | |
895 if(vsi_t_time (VSI_CALLER &(uart_data->dtx->esd_guard_time)) NEQ VSI_OK) | |
896 { | |
897 TRACE_ERROR_P1("VSI entity: Can't restart timer, uart_dtxs.c(%d)", | |
898 __LINE__); | |
899 } | |
900 | |
901 uart_data->dtx->esd_pos = 0; | |
902 /* | |
903 * enable flow control if necessary | |
904 */ | |
905 if(uart_data->dtx->data_flow NEQ UART_FLOW_ENABLED) | |
906 { | |
907 uart_data->dtx->data_flow = UART_FLOW_ENABLED; | |
908 sig_dtx_ker_enable_ind(uart_data->dtx->dlc_instance); | |
909 } | |
910 /* | |
911 * signal availability to receive to RX service | |
912 */ | |
913 sig_dtx_rx_ready_to_receive_req( uart_data->dtx->dlc_instance, | |
914 uart_data->dtx->to_send_data, | |
915 uart_data->dtx->write_pos, | |
916 uart_data->dtx->cur_desc_size ); | |
917 } | |
918 else | |
919 uart_data->dtx->receiving_state = UART_DTX_INVALID; | |
920 } | |
921 break; | |
922 | |
923 case DTX_DEAD: | |
924 break; | |
925 | |
926 default: | |
927 TRACE_ERROR( "SIG_KER_DTX_SET_DTI_PEER_REQ unexpected" ); | |
928 break; | |
929 } | |
930 } /* sig_ker_dtx_set_dtilib_peer_req() */ | |
931 | |
932 | |
933 | |
934 /* | |
935 +------------------------------------------------------------------------------ | |
936 | Function : sig_ker_dtx_timeout_tesd_req | |
937 +------------------------------------------------------------------------------ | |
938 | Description : Handles the internal signal SIG_KER_DTX_TIMEOUT_TESD_REQ | |
939 | which is used to inform the service DTX that the Escape | |
940 | Sequence Guard Period timer has expired. | |
941 | | |
942 | Parameters : none | |
943 | | |
944 +------------------------------------------------------------------------------ | |
945 */ | |
946 GLOBAL void sig_ker_dtx_timeout_tesd_req() | |
947 { | |
948 T_DATA_FLOW_STATE old_data_flow; | |
949 T_TIME cur_time; | |
950 T_TIME elapsed; | |
951 T_desc2* temp_desc; | |
952 | |
953 TRACE_ISIG( "sig_ker_dtx_timeout_tesd_req" ); | |
954 | |
955 switch( GET_STATE( UART_SERVICE_DTX ) ) | |
956 { | |
957 case DTX_READY: | |
958 if (vsi_t_time (VSI_CALLER &cur_time) EQ VSI_OK) | |
959 { | |
960 elapsed = cur_time - uart_data->dtx->esd_guard_time; | |
961 switch (dtx_get_esd_state()) | |
962 { | |
963 case UART_ESD_DETECTED: | |
964 case UART_ESD_NULL: | |
965 break; | |
966 | |
967 case UART_ESD_CHAR_1: | |
968 case UART_ESD_CHAR_2: | |
969 if(elapsed < uart_data->act_gp) | |
970 { | |
971 /* | |
972 * escape sequence guard period not complete: start timer | |
973 * with remaining time value | |
974 */ | |
975 sig_dtx_rt_start_tesd_req (uart_data->act_gp - elapsed); | |
976 } | |
977 else | |
978 { | |
979 /* | |
980 * Guard Period complete | |
981 * reset detection because detected characters do not belong to | |
982 * an escape sequence | |
983 */ | |
984 dtx_set_esd_state( UART_ESD_NULL ); | |
985 | |
986 /* | |
987 * if possible send the escape character | |
988 */ | |
989 if(uart_data->dtx->receiving_state EQ UART_DTX_NOT_RECEIVING) | |
990 { | |
991 /* | |
992 * Guard Period complete | |
993 * send one escape character to DTI peer and reset detection | |
994 */ | |
995 PALLOC_DESC2 (dti_data_ind, DTI2_DATA_IND); | |
996 SET_STATE( UART_SERVICE_DTX, DTX_NOT_READY ); | |
997 | |
998 /* | |
999 * enable data flow if necessary | |
1000 */ | |
1001 old_data_flow = uart_data->dtx->data_flow; | |
1002 if(uart_data->dtx->data_flow NEQ UART_FLOW_ENABLED) | |
1003 { | |
1004 uart_data->dtx->data_flow = UART_FLOW_ENABLED; | |
1005 sig_dtx_ker_enable_ind(uart_data->dtx->dlc_instance); | |
1006 } | |
1007 /* | |
1008 * mark entity descriptor as invalid, since data will be | |
1009 * forwarded | |
1010 */ | |
1011 temp_desc = uart_data->dtx->to_send_data; | |
1012 uart_data->dtx->to_send_data = NULL; | |
1013 | |
1014 /* | |
1015 * make escape character valid to send and insert values in | |
1016 * primitive | |
1017 */ | |
1018 temp_desc->len = uart_data->dtx->esd_pos; | |
1019 temp_desc->size = temp_desc->len; | |
1020 | |
1021 dti_data_ind->desc_list2.first = (ULONG)temp_desc; | |
1022 dti_data_ind->desc_list2.list_len = temp_desc->len; | |
1023 | |
1024 /* | |
1025 * calculate new size multiplier according to fillrate of buffer | |
1026 */ | |
1027 dtx_calculate_size_multiplier (temp_desc, old_data_flow); | |
1028 /* | |
1029 * allocate a new descriptor with size according to new size_multiplier | |
1030 */ | |
1031 dtx_allocate_resources(); | |
1032 /* | |
1033 * Check for data which has not yet been validated, i.e. because | |
1034 * the frame containing the data has not yet been received completely. | |
1035 * In this case, the not yet validated data is copied to the newly | |
1036 * allocated descriptor. | |
1037 */ | |
1038 if(uart_data->dtx->write_pos > temp_desc->len) | |
1039 { | |
1040 memcpy(uart_data->dtx->to_send_data->buffer, | |
1041 &temp_desc->buffer[temp_desc->len], | |
1042 uart_data->dtx->write_pos - temp_desc->len); | |
1043 uart_data->dtx->write_pos-= temp_desc->len; | |
1044 } | |
1045 uart_data->dtx->esd_pos = 0; | |
1046 sig_dtx_rx_ready_to_receive_req(uart_data->dtx->dlc_instance, | |
1047 uart_data->dtx->to_send_data, | |
1048 uart_data->dtx->write_pos, | |
1049 uart_data->dtx->cur_desc_size); | |
1050 | |
1051 /* | |
1052 * set line states | |
1053 */ | |
1054 dti_data_ind->parameters.st_lines.st_flow = uart_data->dtx->st_flow; | |
1055 dti_data_ind->parameters.st_lines.st_line_sa = uart_data->dtx->st_line_sa; | |
1056 dti_data_ind->parameters.st_lines.st_line_sb = uart_data->dtx->st_line_sb; | |
1057 dti_data_ind->parameters.st_lines.st_break_len = uart_data->dtx->st_break_len; | |
1058 | |
1059 uart_data->dtx->lines_changed = FALSE; | |
1060 uart_data->dtx->st_break_len = DTI_BREAK_OFF; | |
1061 | |
1062 #ifdef _SIMULATION_ | |
1063 dti_data_ind->parameters.p_id = DTI_PID_UOS; | |
1064 #endif /* _SIMULATION_ */ | |
1065 dti_send_data( | |
1066 uart_hDTI, | |
1067 uart_data->device, | |
1068 UART_DTI_UP_INTERFACE, | |
1069 uart_data->dtx->dlc_instance, | |
1070 dti_data_ind | |
1071 ); | |
1072 } | |
1073 } | |
1074 break; | |
1075 | |
1076 case UART_ESD_CHAR_3: | |
1077 if(elapsed < uart_data->act_gp) | |
1078 { | |
1079 /* | |
1080 * escape sequence guard period not complete: start timer | |
1081 * with remaining time value | |
1082 */ | |
1083 sig_dtx_rt_start_tesd_req (uart_data->act_gp - elapsed); | |
1084 } | |
1085 else | |
1086 { | |
1087 /* | |
1088 * Guard Period complete | |
1089 * Escape Sequence detected | |
1090 */ | |
1091 /* | |
1092 * remove escape characters from data stream | |
1093 */ | |
1094 if(uart_data->dtx->receiving_state EQ UART_DTX_NOT_RECEIVING) | |
1095 { | |
1096 if(uart_data->dtx->write_pos > 3) | |
1097 { | |
1098 memmove(uart_data->dtx->to_send_data->buffer, | |
1099 &uart_data->dtx->to_send_data->buffer[3], | |
1100 uart_data->dtx->write_pos - 3) | |
1101 ; /*lint !e416 creation of out-of-bounds pointer */ | |
1102 uart_data->dtx->write_pos-= 3; | |
1103 } | |
1104 else | |
1105 uart_data->dtx->write_pos = 0; | |
1106 uart_data->dtx->esd_pos = 0; | |
1107 sig_dtx_rx_ready_to_receive_req(uart_data->dtx->dlc_instance, | |
1108 uart_data->dtx->to_send_data, | |
1109 uart_data->dtx->write_pos, | |
1110 uart_data->dtx->cur_desc_size); | |
1111 /* | |
1112 * Reset the state of the Escape Sequence Detection | |
1113 */ | |
1114 dtx_set_esd_state( UART_ESD_NULL ); | |
1115 } | |
1116 else | |
1117 { | |
1118 /* | |
1119 * escape characters are not removeable | |
1120 * so we will do this later | |
1121 */ | |
1122 #ifdef _SIMULATION_ | |
1123 TRACE_EVENT("ESD: escape characters are not removeable"); | |
1124 #endif /* _SIMULATION_ */ | |
1125 dtx_set_esd_state( UART_ESD_DETECTED ); | |
1126 } | |
1127 #ifdef _SIMULATION_ | |
1128 TRACE_EVENT_P3("+ + + dlc_instance: %d, silence %d \ | |
1129 (from %d) Escape Sequence Detected + + + ", | |
1130 uart_data->dtx->dlc_instance, | |
1131 elapsed, | |
1132 uart_data->dtx->esd_guard_time); | |
1133 #endif /* _SIMULATION_ */ | |
1134 | |
1135 /* | |
1136 * send detected escape sequence to MMI | |
1137 */ | |
1138 sig_dtx_ker_escape_detected_ind(uart_data->dtx->dlc_instance); | |
1139 } | |
1140 break; | |
1141 | |
1142 default: | |
1143 { | |
1144 TRACE_ERROR_P1("Error: wrong ESD state, uart_dtxs.c(%d)", __LINE__); | |
1145 } | |
1146 break; | |
1147 } | |
1148 } | |
1149 else | |
1150 { | |
1151 TRACE_ERROR_P1("VSI entity: Cannot restart timer, uart_dtxs.c(%d)", | |
1152 __LINE__); | |
1153 } | |
1154 break; | |
1155 | |
1156 case DTX_NOT_READY: | |
1157 if (vsi_t_time (VSI_CALLER &cur_time) EQ VSI_OK) | |
1158 { | |
1159 elapsed = cur_time - uart_data->dtx->esd_guard_time; | |
1160 switch (dtx_get_esd_state()) | |
1161 { | |
1162 case UART_ESD_DETECTED: | |
1163 case UART_ESD_NULL: | |
1164 break; | |
1165 | |
1166 case UART_ESD_CHAR_1: | |
1167 case UART_ESD_CHAR_2: | |
1168 if(elapsed < uart_data->act_gp) | |
1169 { | |
1170 /* | |
1171 * escape sequence guard period not complete: start timer | |
1172 * with remaining time value | |
1173 */ | |
1174 sig_dtx_rt_start_tesd_req (uart_data->act_gp - elapsed); | |
1175 } | |
1176 else | |
1177 { | |
1178 /* | |
1179 * Guard Period complete | |
1180 * reset detection because detected characters do not belong to | |
1181 * an escape sequence | |
1182 */ | |
1183 dtx_set_esd_state( UART_ESD_NULL ); | |
1184 | |
1185 /* | |
1186 * if possible insert escape characters to usual data stream | |
1187 */ | |
1188 if(uart_data->dtx->receiving_state EQ UART_DTX_NOT_RECEIVING) | |
1189 { | |
1190 /* | |
1191 * make escape character valid to send and insert values in | |
1192 * primitive | |
1193 */ | |
1194 uart_data->dtx->to_send_data->len = uart_data->dtx->esd_pos; | |
1195 uart_data->dtx->to_send_data->size = uart_data->dtx->esd_pos; | |
1196 uart_data->dtx->to_send_data->offset = 0; | |
1197 | |
1198 if((uart_data->dtx->cur_desc_size - | |
1199 uart_data->dtx->esd_pos) >= uart_data->n1) | |
1200 { | |
1201 /* | |
1202 * there is still enough space left to continue reception | |
1203 */ | |
1204 sig_dtx_rx_ready_to_receive_req( | |
1205 uart_data->dtx->dlc_instance, | |
1206 uart_data->dtx->to_send_data, | |
1207 uart_data->dtx->write_pos, | |
1208 uart_data->dtx->cur_desc_size); | |
1209 } | |
1210 | |
1211 } | |
1212 } | |
1213 break; | |
1214 | |
1215 case UART_ESD_CHAR_3: | |
1216 if(elapsed < uart_data->act_gp) | |
1217 { | |
1218 /* | |
1219 * escape sequence guard period not complete: start timer | |
1220 * with remaining time value | |
1221 */ | |
1222 sig_dtx_rt_start_tesd_req (uart_data->act_gp - elapsed); | |
1223 } | |
1224 else | |
1225 { | |
1226 /* | |
1227 * Guard Period complete | |
1228 * Escape Sequence detected | |
1229 * store the occurence of the Escape Sequence | |
1230 */ | |
1231 #ifdef _SIMULATION_ | |
1232 TRACE_EVENT_P3("+ + + dlc_instance: %d, silence %d \ | |
1233 (from %d) Escape Sequence Detected + + + ", | |
1234 uart_data->dtx->dlc_instance, | |
1235 elapsed, | |
1236 uart_data->dtx->esd_guard_time); | |
1237 #endif /* _SIMULATION_ */ | |
1238 /* | |
1239 * remove escape characters from data stream | |
1240 */ | |
1241 if(uart_data->dtx->receiving_state EQ UART_DTX_NOT_RECEIVING) | |
1242 { | |
1243 if(uart_data->dtx->write_pos > uart_data->dtx->esd_pos) | |
1244 { | |
1245 memmove( | |
1246 &uart_data->dtx->to_send_data->buffer[ | |
1247 uart_data->dtx->esd_pos - 3], | |
1248 &uart_data->dtx->to_send_data->buffer[ | |
1249 uart_data->dtx->esd_pos], | |
1250 uart_data->dtx->write_pos - uart_data->dtx->esd_pos); | |
1251 } | |
1252 uart_data->dtx->write_pos-= 3; | |
1253 uart_data->dtx->esd_pos -= 3; | |
1254 /* | |
1255 * Reset the state of the Escape Sequence Detection | |
1256 */ | |
1257 dtx_set_esd_state( UART_ESD_NULL ); | |
1258 | |
1259 if((uart_data->dtx->cur_desc_size - | |
1260 uart_data->dtx->esd_pos) >= uart_data->n1) | |
1261 { | |
1262 /* | |
1263 * there is still enough space left to continue reception | |
1264 */ | |
1265 sig_dtx_rx_ready_to_receive_req( | |
1266 uart_data->dtx->dlc_instance, | |
1267 uart_data->dtx->to_send_data, | |
1268 uart_data->dtx->write_pos, | |
1269 uart_data->dtx->cur_desc_size); | |
1270 } | |
1271 } | |
1272 else | |
1273 { | |
1274 /* | |
1275 * escape characters are not removeable | |
1276 * so we will do this later | |
1277 */ | |
1278 #ifdef _SIMULATION_ | |
1279 TRACE_EVENT("ESD: escape characters are not removeable"); | |
1280 #endif /* _SIMULATION_ */ | |
1281 dtx_set_esd_state( UART_ESD_DETECTED ); | |
1282 } | |
1283 | |
1284 /* | |
1285 * send detected escape sequence to MMI | |
1286 */ | |
1287 sig_dtx_ker_escape_detected_ind(uart_data->dtx->dlc_instance); | |
1288 } | |
1289 break; | |
1290 | |
1291 default: | |
1292 TRACE_ERROR("wrong esd state"); | |
1293 break; | |
1294 } | |
1295 } | |
1296 break; | |
1297 | |
1298 case DTX_DEAD: | |
1299 break; | |
1300 | |
1301 default: | |
1302 TRACE_ERROR( "SIG_KER_DTX_TIMEOUT_TESD_REQ unexpected" ); | |
1303 break; | |
1304 } | |
1305 } /* sig_ker_dtx_timeout_tesd_req() */ |