FreeCalypso > hg > fc-selenite
comparison src/g23m-fad/rlp/rlp_kers.c @ 1:d393cd9bb723
src/g23m-*: initial import from Magnetite
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 15 Jul 2018 04:40:46 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:b6a5e36de839 | 1:d393cd9bb723 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : CSD (8411) | |
4 | Modul : Rlp_kers.c | |
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 defines the functions for processing | |
18 | of incomming signals for the component | |
19 | Radio Link Protocol of the base station | |
20 +----------------------------------------------------------------------------- | |
21 */ | |
22 | |
23 #ifndef RLP_KERS_C | |
24 #define RLP_KERS_C | |
25 #endif | |
26 | |
27 #define ENTITY_RLP | |
28 | |
29 /*==== INCLUDES ===================================================*/ | |
30 | |
31 #include <string.h> | |
32 #include "typedefs.h" | |
33 #include "vsi.h" | |
34 #include "macdef.h" | |
35 #include "custom.h" | |
36 #include "gsm.h" | |
37 #include "cus_rlp.h" | |
38 #include "prim.h" | |
39 #include "tok.h" | |
40 #include "rlp.h" | |
41 | |
42 /*==== CONST =======================================================*/ | |
43 | |
44 /*==== TYPES =======================================================*/ | |
45 | |
46 /*==== VAR EXPORT ==================================================*/ | |
47 | |
48 /*==== VAR LOCAL ===================================================*/ | |
49 | |
50 /*==== FUNCTIONS ===================================================*/ | |
51 | |
52 /* | |
53 +------------------------------------------------------------------------------ | |
54 | Function : sig_rcv_ker_sabm_ind | |
55 +------------------------------------------------------------------------------ | |
56 | Description :Process signal SIG_SABM_IND received from process rcv. | |
57 | | |
58 | Parameters : - | |
59 | | |
60 | | |
61 | Return : - | |
62 +------------------------------------------------------------------------------ | |
63 */ | |
64 | |
65 GLOBAL void sig_rcv_ker_sabm_ind(void) | |
66 { | |
67 TRACE_FUNCTION ("sig_rcv_ker_sabm_ind()"); | |
68 | |
69 TRACE_EVENT ("SABM rcvd"); | |
70 | |
71 switch (GET_STATE (KER)) | |
72 { | |
73 case RLP_ADM_AND_DETACHED: | |
74 rlp_data->ker.DM_State = IS_SEND; | |
75 rlp_data->ker.DM_FBit = 1; | |
76 break; | |
77 | |
78 case RLP_ADM_AND_ATTACHED: | |
79 { | |
80 PALLOC (rlp_connect_ind, RLP_CONNECT_IND); | |
81 PSENDX (L2R, rlp_connect_ind); | |
82 rlp_data->ker.DM_State = IS_IDLE; | |
83 SET_STATE (KER, RLP_PENDING_CONNECT_IND); | |
84 break; | |
85 } | |
86 | |
87 case RLP_PENDING_CONNECT_REQ: | |
88 { | |
89 PALLOC (rlp_connect_cnf, RLP_CONNECT_CNF); | |
90 | |
91 TIMERSTOP (TT_HANDLE); | |
92 | |
93 rlp_connect_cnf->ack_flg = RLP_ACK; | |
94 | |
95 PSENDX (L2R, rlp_connect_cnf); | |
96 | |
97 rlp_data->ker.UA_State = IS_SEND; | |
98 rlp_data->ker.UA_FBit = 1; | |
99 ker_init_link_vars (); | |
100 SET_STATE (KER, RLP_CONNECTION_ESTABLISHED); | |
101 break; | |
102 } | |
103 | |
104 case RLP_CONNECTION_ESTABLISHED: | |
105 case RLP_PENDING_REMAP_REQ: | |
106 case RLP_REMAP_DATA: | |
107 { | |
108 PALLOC (rlp_reset_ind, RLP_RESET_IND); | |
109 | |
110 TIMERSTOP (TT_HANDLE); | |
111 TIMERSTOP (TRCVR_HANDLE); | |
112 ker_reset_all_t_rcvs (); | |
113 | |
114 PSENDX (L2R, rlp_reset_ind); | |
115 | |
116 ker_deinit_link_vars (); | |
117 SET_STATE (KER, RLP_PENDING_RESET_IND); | |
118 break; | |
119 } | |
120 | |
121 case RLP_PENDING_RESET_REQ: | |
122 { | |
123 PALLOC (rlp_reset_cnf, RLP_RESET_CNF); | |
124 | |
125 TIMERSTOP (TT_HANDLE); | |
126 PSENDX (L2R, rlp_reset_cnf); | |
127 | |
128 rlp_data->ker.UA_State = IS_SEND; | |
129 rlp_data->ker.UA_FBit = 1; | |
130 | |
131 ker_init_link_vars (); | |
132 SET_STATE (KER, RLP_CONNECTION_ESTABLISHED); | |
133 break; | |
134 } | |
135 } | |
136 } | |
137 | |
138 /* | |
139 +------------------------------------------------------------------------------ | |
140 | Function : sig_rcv_ker_disc_ind | |
141 +------------------------------------------------------------------------------ | |
142 | Description : Process signal SIG_DISC_IND received from process rcv. | |
143 | | |
144 | Parameters : pFBit - | |
145 | | |
146 | | |
147 | Return : - | |
148 +------------------------------------------------------------------------------ | |
149 */ | |
150 | |
151 | |
152 GLOBAL void sig_rcv_ker_disc_ind(T_BIT pFBit) | |
153 { | |
154 TRACE_FUNCTION ("sig_rcv_ker_disc_ind()"); | |
155 | |
156 TRACE_EVENT ("DISC rcvd"); | |
157 | |
158 switch (GET_STATE (KER)) | |
159 { | |
160 case RLP_ADM_AND_DETACHED: | |
161 rlp_data->ker.DM_State = IS_SEND; | |
162 rlp_data->ker.DM_FBit = pFBit; | |
163 break; | |
164 | |
165 case RLP_ADM_AND_ATTACHED: | |
166 rlp_data->ker.UA_State = IS_SEND; | |
167 rlp_data->ker.UA_FBit = pFBit; | |
168 rlp_data->ker.DM_State = IS_IDLE; | |
169 break; | |
170 | |
171 case RLP_PENDING_CONNECT_REQ: | |
172 case RLP_PENDING_CONNECT_IND: | |
173 { | |
174 PALLOC (rlp_disc_ind, RLP_DISC_IND); | |
175 | |
176 TIMERSTOP (TT_HANDLE); | |
177 PSENDX (L2R, rlp_disc_ind); | |
178 | |
179 rlp_data->ker.UA_State = IS_SEND; | |
180 rlp_data->ker.UA_FBit = pFBit; | |
181 SET_STATE (KER, RLP_ADM_AND_ATTACHED); | |
182 break; | |
183 } | |
184 | |
185 case RLP_CONNECTION_ESTABLISHED: | |
186 case RLP_PENDING_REMAP_REQ: | |
187 case RLP_REMAP_DATA: | |
188 { | |
189 PALLOC (rlp_disc_ind, RLP_DISC_IND); | |
190 | |
191 TIMERSTOP (TT_HANDLE); | |
192 TIMERSTOP (TRCVR_HANDLE); | |
193 ker_reset_all_t_rcvs (); | |
194 | |
195 PSENDX (L2R, rlp_disc_ind); | |
196 | |
197 rlp_data->ker.UA_State = IS_SEND; | |
198 rlp_data->ker.UA_FBit = pFBit; | |
199 ker_deinit_link_vars (); | |
200 SET_STATE (KER, RLP_ADM_AND_ATTACHED); | |
201 break; | |
202 } | |
203 | |
204 case RLP_DISCONNECT_INITIATED: | |
205 { | |
206 rlp_data->ker.UA_State = IS_SEND; | |
207 rlp_data->ker.UA_FBit = pFBit; | |
208 | |
209 TIMERSTOP (TT_HANDLE); | |
210 | |
211 if (rlp_data->ker.DISC_Ind) | |
212 { | |
213 PALLOC (rlp_disc_ind, RLP_DISC_IND); | |
214 PSENDX (L2R, rlp_disc_ind); | |
215 SET_STATE (KER, RLP_ADM_AND_ATTACHED); | |
216 } | |
217 else | |
218 { | |
219 PALLOC (rlp_disc_cnf, RLP_DISC_CNF); | |
220 PSENDX (L2R, rlp_disc_cnf); | |
221 SET_STATE (KER, RLP_ADM_AND_ATTACHED); | |
222 } | |
223 | |
224 break; | |
225 } | |
226 | |
227 case RLP_PENDING_RESET_REQ: | |
228 { | |
229 PALLOC (rlp_disc_ind, RLP_DISC_IND); | |
230 | |
231 TIMERSTOP (TT_HANDLE); | |
232 PSENDX (L2R, rlp_disc_ind); | |
233 | |
234 rlp_data->ker.UA_State = IS_SEND; | |
235 rlp_data->ker.UA_FBit = pFBit; | |
236 | |
237 SET_STATE (KER, RLP_ADM_AND_ATTACHED); | |
238 break; | |
239 } | |
240 | |
241 case RLP_PENDING_RESET_IND: | |
242 { | |
243 PALLOC (rlp_disc_ind, RLP_DISC_IND); | |
244 | |
245 PSENDX (L2R, rlp_disc_ind); | |
246 | |
247 rlp_data->ker.UA_State = IS_SEND; | |
248 rlp_data->ker.UA_FBit = pFBit; | |
249 | |
250 SET_STATE (KER, RLP_ADM_AND_ATTACHED); | |
251 break; | |
252 } | |
253 } | |
254 } | |
255 | |
256 /* | |
257 +------------------------------------------------------------------------------ | |
258 | Function : sig_rcv_ker_ua_ind | |
259 +------------------------------------------------------------------------------ | |
260 | Description : Process signal SIG_UA_IND received from process rcv. | |
261 | | |
262 | Parameters : pFBit - | |
263 | | |
264 | | |
265 | Return : - | |
266 +------------------------------------------------------------------------------ | |
267 */ | |
268 | |
269 GLOBAL void sig_rcv_ker_ua_ind(T_BIT pFBit) | |
270 { | |
271 TRACE_FUNCTION ("sig_rcv_ker_ua_ind()"); | |
272 | |
273 TRACE_EVENT ("UA rcvd"); | |
274 | |
275 switch (GET_STATE (KER)) | |
276 { | |
277 case RLP_PENDING_CONNECT_REQ: | |
278 switch (rlp_data->ker.SABM_State) | |
279 { | |
280 case ISW_WAIT: | |
281 if (pFBit EQ 1) | |
282 { | |
283 PALLOC (rlp_connect_cnf, RLP_CONNECT_CNF); | |
284 TIMERSTOP (TT_HANDLE); | |
285 | |
286 rlp_connect_cnf->ack_flg = RLP_ACK; | |
287 | |
288 PSENDX (L2R, rlp_connect_cnf); | |
289 ker_init_link_vars (); | |
290 SET_STATE (KER, RLP_CONNECTION_ESTABLISHED); | |
291 } | |
292 break; | |
293 | |
294 default: | |
295 break; | |
296 } | |
297 break; | |
298 | |
299 case RLP_DISCONNECT_INITIATED: | |
300 switch (rlp_data->ker.DISC_State) | |
301 { | |
302 case ISW_WAIT: | |
303 if (pFBit EQ rlp_data->ker.DISC_PBit) | |
304 { | |
305 if (rlp_data->ker.DISC_PBit EQ 1) | |
306 rlp_data->ker.Poll_xchg = IW_IDLE; | |
307 | |
308 TIMERSTOP (TT_HANDLE); | |
309 if (rlp_data->ker.DISC_Ind) | |
310 { | |
311 PALLOC (rlp_disc_ind, RLP_DISC_IND); | |
312 PSENDX (L2R, rlp_disc_ind); | |
313 SET_STATE (KER, RLP_ADM_AND_ATTACHED); | |
314 } | |
315 else | |
316 { | |
317 PALLOC (rlp_disc_cnf, RLP_DISC_CNF); | |
318 PSENDX (L2R, rlp_disc_cnf); | |
319 SET_STATE (KER, RLP_ADM_AND_ATTACHED); | |
320 } | |
321 | |
322 } | |
323 break; | |
324 } | |
325 break; | |
326 | |
327 case RLP_PENDING_RESET_REQ: | |
328 switch (rlp_data->ker.SABM_State) | |
329 { | |
330 case ISW_WAIT: | |
331 if (pFBit EQ 1) | |
332 { | |
333 PALLOC (rlp_reset_cnf, RLP_RESET_CNF); | |
334 | |
335 TIMERSTOP (TT_HANDLE); | |
336 PSENDX (L2R, rlp_reset_cnf); | |
337 | |
338 ker_init_link_vars (); | |
339 SET_STATE (KER, RLP_CONNECTION_ESTABLISHED); | |
340 } | |
341 break; | |
342 } | |
343 break; | |
344 } | |
345 } | |
346 | |
347 /* | |
348 +------------------------------------------------------------------------------ | |
349 | Function : sig_rcv_ker_dm_ind | |
350 +------------------------------------------------------------------------------ | |
351 | Description : Process signal SIG_DM_IND received from process rcv. | |
352 | | |
353 | Parameters : pFBit - | |
354 | | |
355 | | |
356 | Return : - | |
357 +------------------------------------------------------------------------------ | |
358 */ | |
359 | |
360 | |
361 GLOBAL void sig_rcv_ker_dm_ind(T_BIT pFBit) | |
362 { | |
363 TRACE_FUNCTION ("sig_rcv_ker_dm_ind()"); | |
364 | |
365 TRACE_EVENT ("DM rcvd"); | |
366 | |
367 switch (GET_STATE (KER)) | |
368 { | |
369 case RLP_PENDING_CONNECT_REQ: | |
370 switch (rlp_data->ker.SABM_State) | |
371 { | |
372 case ISW_WAIT: | |
373 if (pFBit EQ 1) | |
374 { | |
375 PALLOC (rlp_connect_cnf, RLP_CONNECT_CNF); | |
376 TIMERSTOP (TT_HANDLE); | |
377 rlp_data->ker.Poll_xchg = IW_IDLE; | |
378 | |
379 rlp_connect_cnf->ack_flg = RLP_NAK; | |
380 | |
381 PSENDX (L2R, rlp_connect_cnf); | |
382 SET_STATE (KER, RLP_ADM_AND_ATTACHED); | |
383 } | |
384 break; | |
385 } | |
386 break; | |
387 | |
388 case RLP_DISCONNECT_INITIATED: | |
389 switch (rlp_data->ker.DISC_State) | |
390 { | |
391 case ISW_WAIT: | |
392 if (pFBit EQ rlp_data->ker.DISC_PBit) | |
393 { | |
394 if (rlp_data->ker.DISC_PBit EQ 1) | |
395 rlp_data->ker.Poll_xchg = IW_IDLE; | |
396 | |
397 TIMERSTOP (TT_HANDLE); | |
398 | |
399 if (rlp_data->ker.DISC_Ind) | |
400 { | |
401 PALLOC (rlp_disc_ind, RLP_DISC_IND); | |
402 PSENDX (L2R, rlp_disc_ind); | |
403 SET_STATE (KER, RLP_ADM_AND_ATTACHED); | |
404 } | |
405 else | |
406 { | |
407 PALLOC (rlp_disc_cnf, RLP_DISC_CNF); | |
408 PSENDX (L2R, rlp_disc_cnf); | |
409 SET_STATE (KER, RLP_ADM_AND_ATTACHED); | |
410 } | |
411 } | |
412 break; | |
413 } | |
414 break; | |
415 } | |
416 } | |
417 | |
418 /* | |
419 +------------------------------------------------------------------------------ | |
420 | Function : sig_rcv_ker_rr_ind | |
421 +------------------------------------------------------------------------------ | |
422 | Description : Process signal SIG_RR_IND received from process rcv. | |
423 | | |
424 | Parameters : cBit | |
425 | pFBit | |
426 | nr | |
427 | | |
428 | Return : - | |
429 +------------------------------------------------------------------------------ | |
430 */ | |
431 | |
432 | |
433 GLOBAL void sig_rcv_ker_rr_ind | |
434 ( | |
435 T_BIT cBit, | |
436 T_BIT pFBit, | |
437 T_FRAME_NUM nr | |
438 ) | |
439 { | |
440 | |
441 BOOL retransError; | |
442 | |
443 TRACE_FUNCTION ("sig_rcv_ker_rr_ind()"); | |
444 | |
445 switch (GET_STATE (KER)) | |
446 { | |
447 case RLP_CONNECTION_ESTABLISHED: | |
448 rlp_data->ker.SF = SF_RR; | |
449 | |
450 /* | |
451 * unsolicited F_Bit ? | |
452 */ | |
453 if (!(pFBit EQ 1 AND cBit EQ 0 AND rlp_data->ker.Poll_State NEQ ISW_WAIT)) | |
454 { | |
455 /* | |
456 * NR within range of send frames pending for acknowledgement ? | |
457 */ | |
458 if (sbm_frame_in_range (nr)) | |
459 { | |
460 ker_s_handler (cBit, pFBit, rlp_data->ker.SF, nr, &retransError); | |
461 if (retransError) | |
462 { | |
463 SET_STATE(KER, RLP_DISCONNECT_INITIATED); | |
464 TRACE_EVENT("#2"); | |
465 } | |
466 } | |
467 } | |
468 break; | |
469 } | |
470 } | |
471 | |
472 /* | |
473 +------------------------------------------------------------------------------ | |
474 | Function : sig_rcv_ker_rnr_ind | |
475 +------------------------------------------------------------------------------ | |
476 | Description : Process signal SIG_RNR_IND received from process rcv. | |
477 | | |
478 | Parameters : cBit | |
479 | pFBit | |
480 | nr | |
481 | | |
482 | Return : - | |
483 +------------------------------------------------------------------------------ | |
484 */ | |
485 | |
486 | |
487 GLOBAL void sig_rcv_ker_rnr_ind | |
488 ( | |
489 T_BIT cBit, | |
490 T_BIT pFBit, | |
491 T_FRAME_NUM nr | |
492 ) | |
493 { | |
494 BOOL retransError; | |
495 | |
496 TRACE_FUNCTION ("sig_rcv_ker_rnr_ind()"); | |
497 | |
498 switch (GET_STATE (KER)) | |
499 { | |
500 case RLP_CONNECTION_ESTABLISHED: | |
501 rlp_data->ker.SF = SF_RNR; | |
502 | |
503 /* | |
504 * unsolicited F_Bit ? | |
505 */ | |
506 if (!(pFBit EQ 1 AND cBit EQ 0 AND rlp_data->ker.Poll_State NEQ ISW_WAIT)) | |
507 { | |
508 /* | |
509 * NR within range of send frames pending | |
510 * for acknowledgement ?? | |
511 */ | |
512 if (sbm_frame_in_range (nr)) | |
513 { | |
514 ker_s_handler (cBit, pFBit, rlp_data->ker.SF, nr, &retransError); | |
515 if (retransError) | |
516 { | |
517 SET_STATE(KER, RLP_DISCONNECT_INITIATED); | |
518 TRACE_EVENT("#3"); | |
519 } | |
520 } | |
521 } | |
522 break; | |
523 } | |
524 } | |
525 | |
526 /* | |
527 +------------------------------------------------------------------------------ | |
528 | Function : sig_rcv_ker_rej_ind | |
529 +------------------------------------------------------------------------------ | |
530 | Description : Process signal SIG_REJ_IND received from process rcv. | |
531 | | |
532 | Parameters : cBit | |
533 | pFBit | |
534 | nr | |
535 | | |
536 | Return : - | |
537 +------------------------------------------------------------------------------ | |
538 */ | |
539 | |
540 | |
541 GLOBAL void sig_rcv_ker_rej_ind | |
542 ( | |
543 T_BIT cBit, | |
544 T_BIT pFBit, | |
545 T_FRAME_NUM nr | |
546 ) | |
547 { | |
548 | |
549 BOOL retransError; | |
550 | |
551 TRACE_FUNCTION ("sig_rcv_ker_rej_ind()"); | |
552 | |
553 switch (GET_STATE (KER)) | |
554 { | |
555 case RLP_CONNECTION_ESTABLISHED: | |
556 rlp_data->ker.SF = SF_REJ; | |
557 | |
558 /* | |
559 * unsolicited F_Bit ? | |
560 */ | |
561 if (!(pFBit EQ 1 AND cBit EQ 0 AND rlp_data->ker.Poll_State NEQ ISW_WAIT)) | |
562 { | |
563 /* | |
564 * NR within range of send frames pending for acknowledgement ? | |
565 */ | |
566 if (sbm_frame_in_range (nr)) | |
567 { | |
568 ker_s_handler (cBit, pFBit, rlp_data->ker.SF, nr, &retransError); | |
569 if (retransError) | |
570 { | |
571 SET_STATE(KER, RLP_DISCONNECT_INITIATED); | |
572 TRACE_EVENT("#4"); | |
573 } | |
574 } | |
575 } | |
576 break; | |
577 } | |
578 } | |
579 | |
580 /* | |
581 +------------------------------------------------------------------------------ | |
582 | Function : sig_rcv_ker_srej_ind | |
583 +------------------------------------------------------------------------------ | |
584 | Description : Process signal SIG_SREJ_IND received from process rcv. | |
585 | | |
586 | Parameters :cBit - | |
587 | pFBit - | |
588 | nr - | |
589 | | |
590 | Return : - | |
591 +------------------------------------------------------------------------------ | |
592 */ | |
593 | |
594 | |
595 GLOBAL void sig_rcv_ker_srej_ind | |
596 ( | |
597 T_BIT cBit, | |
598 T_BIT pFBit, | |
599 T_FRAME_NUM nr | |
600 ) | |
601 { | |
602 | |
603 BOOL retransError; | |
604 | |
605 TRACE_FUNCTION ("sig_rcv_ker_srej_ind()"); | |
606 | |
607 switch (GET_STATE (KER)) | |
608 { | |
609 case RLP_CONNECTION_ESTABLISHED: | |
610 rlp_data->ker.SF = SF_SREJ; | |
611 | |
612 /* | |
613 * unsolicited F_Bit ? | |
614 */ | |
615 if (!(pFBit EQ 1 AND cBit EQ 0 AND rlp_data->ker.Poll_State NEQ ISW_WAIT)) | |
616 { | |
617 /* | |
618 * NR within range of send frames pending | |
619 * for acknowledgement ?? | |
620 */ | |
621 if (sbm_frame_in_range (nr)) | |
622 { | |
623 ker_s_handler (cBit, pFBit, rlp_data->ker.SF, nr, &retransError); | |
624 if (retransError) | |
625 { | |
626 SET_STATE(KER, RLP_DISCONNECT_INITIATED); | |
627 TRACE_EVENT("#5"); | |
628 } | |
629 } | |
630 } | |
631 break; | |
632 } | |
633 } | |
634 | |
635 /* | |
636 +------------------------------------------------------------------------------ | |
637 | Function : sig_rcv_ker_rr_i_ind | |
638 +------------------------------------------------------------------------------ | |
639 | Description : Process signal SIG_RR_I_IND received from process rcv. | |
640 | | |
641 | Parameters : cBit - | |
642 | pFBit - | |
643 | nr - | |
644 | ns - | |
645 | | |
646 | Return : - | |
647 +------------------------------------------------------------------------------ | |
648 */ | |
649 | |
650 | |
651 GLOBAL void sig_rcv_ker_rr_i_ind | |
652 ( | |
653 T_BIT cBit, | |
654 T_BIT pFBit, | |
655 T_FRAME_NUM nr, | |
656 T_FRAME_NUM ns | |
657 ) | |
658 { | |
659 | |
660 BOOL retransError; | |
661 | |
662 TRACE_FUNCTION ("sig_rcv_ker_rr_i_ind()"); | |
663 | |
664 switch (GET_STATE (KER)) | |
665 { | |
666 case RLP_CONNECTION_ESTABLISHED: | |
667 rlp_data->ker.SF = SF_RR; | |
668 | |
669 /* | |
670 * unsolicited F_Bit ? | |
671 */ | |
672 if (!(pFBit EQ 1 AND cBit EQ 0 AND rlp_data->ker.Poll_State NEQ ISW_WAIT)) | |
673 { | |
674 /* | |
675 * NR within range of send frames pending | |
676 * for acknowledgement ?? | |
677 */ | |
678 if (sbm_frame_in_range (nr)) | |
679 if (!ker_i_handler (ns)) | |
680 { | |
681 ker_s_handler (cBit, pFBit, rlp_data->ker.SF, nr, &retransError); | |
682 if (retransError) | |
683 { | |
684 SET_STATE(KER, RLP_DISCONNECT_INITIATED); | |
685 TRACE_EVENT("#6"); | |
686 } | |
687 } | |
688 } | |
689 break; | |
690 } | |
691 } | |
692 | |
693 /* | |
694 +------------------------------------------------------------------------------ | |
695 | Function : sig_rcv_ker_rnr_i_ind | |
696 +------------------------------------------------------------------------------ | |
697 | Description : Process signal SIG_RNR_I_IND received from process rcv. | |
698 | | |
699 | Parameters : cBit | |
700 | pFBit | |
701 | nr | |
702 | ns | |
703 | | |
704 | Return : | |
705 +------------------------------------------------------------------------------ | |
706 */ | |
707 | |
708 | |
709 GLOBAL void sig_rcv_ker_rnr_i_ind | |
710 ( | |
711 T_BIT cBit, | |
712 T_BIT pFBit, | |
713 T_FRAME_NUM nr, | |
714 T_FRAME_NUM ns | |
715 ) | |
716 { | |
717 | |
718 BOOL retransError; | |
719 | |
720 TRACE_FUNCTION ("sig_rcv_ker_rnr_i_ind()"); | |
721 | |
722 switch (GET_STATE (KER)) | |
723 { | |
724 case RLP_CONNECTION_ESTABLISHED: | |
725 /* | |
726 * processing for state RLP_CONNECTION_ESTABLISHED | |
727 */ | |
728 rlp_data->ker.SF = SF_RNR; | |
729 | |
730 /* | |
731 * unsolicited F_Bit ? | |
732 */ | |
733 if (!(pFBit EQ 1 AND cBit EQ 0 AND rlp_data->ker.Poll_State NEQ ISW_WAIT)) | |
734 { | |
735 /* | |
736 * NR within range of send frames pending | |
737 * for acknowledgement ?? | |
738 */ | |
739 if (sbm_frame_in_range (nr)) | |
740 if (!ker_i_handler (ns)) | |
741 { | |
742 ker_s_handler (cBit, pFBit, rlp_data->ker.SF, nr, &retransError); | |
743 if (retransError) | |
744 { | |
745 SET_STATE(KER, RLP_DISCONNECT_INITIATED); | |
746 TRACE_EVENT("#7"); | |
747 } | |
748 } | |
749 } | |
750 break; | |
751 } | |
752 } | |
753 | |
754 /* | |
755 +------------------------------------------------------------------------------ | |
756 | Function : sig_rcv_ker_rej_i_ind | |
757 +------------------------------------------------------------------------------ | |
758 | Description : Process signal SIG_REJ_I_IND received from process rcv. | |
759 | | |
760 | | |
761 | Parameters : cBit - | |
762 | pFBit - | |
763 | nr - | |
764 | : ns - | |
765 | Return | |
766 +------------------------------------------------------------------------------ | |
767 */ | |
768 | |
769 | |
770 GLOBAL void sig_rcv_ker_rej_i_ind | |
771 ( | |
772 T_BIT cBit, | |
773 T_BIT pFBit, | |
774 T_FRAME_NUM nr, | |
775 T_FRAME_NUM ns | |
776 ) | |
777 { | |
778 | |
779 BOOL retransError; | |
780 | |
781 TRACE_FUNCTION ("sig_rcv_ker_rej_i_ind()"); | |
782 | |
783 switch (GET_STATE (KER)) | |
784 { | |
785 case RLP_CONNECTION_ESTABLISHED: | |
786 /* | |
787 * processing for state RLP_CONNECTION_ESTABLISHED | |
788 */ | |
789 rlp_data->ker.SF = SF_REJ; | |
790 | |
791 /* | |
792 * unsolicited F_Bit ? | |
793 */ | |
794 if (!(pFBit EQ 1 AND cBit EQ 0 AND rlp_data->ker.Poll_State NEQ ISW_WAIT)) | |
795 { | |
796 /* | |
797 * NR within range of send frames pending | |
798 * for acknowledgement ?? | |
799 */ | |
800 if (sbm_frame_in_range (nr)) | |
801 if (!ker_i_handler (ns)) | |
802 { | |
803 ker_s_handler (cBit, pFBit, rlp_data->ker.SF, nr, &retransError); | |
804 if (retransError) | |
805 { | |
806 SET_STATE(KER, RLP_DISCONNECT_INITIATED); | |
807 TRACE_EVENT("#8"); | |
808 } | |
809 } | |
810 } | |
811 break; | |
812 } | |
813 } | |
814 | |
815 /* | |
816 +------------------------------------------------------------------------------ | |
817 | Function : sig_rcv_ker_srej_i_ind | |
818 +------------------------------------------------------------------------------ | |
819 | Description : Process signal SIG_SREJ_I_IND received from process rcv. | |
820 | | |
821 | Parameters : cBit - | |
822 | pFBit - | |
823 | nr - | |
824 | ns - | |
825 | | |
826 | Return : | |
827 +------------------------------------------------------------------------------ | |
828 */ | |
829 | |
830 | |
831 GLOBAL void sig_rcv_ker_srej_i_ind | |
832 ( | |
833 T_BIT cBit, | |
834 T_BIT pFBit, | |
835 T_FRAME_NUM nr, | |
836 T_FRAME_NUM ns | |
837 ) | |
838 { | |
839 | |
840 BOOL retransError; | |
841 | |
842 TRACE_FUNCTION ("sig_rcv_ker_srej_i_ind()"); | |
843 | |
844 switch (GET_STATE (KER)) | |
845 { | |
846 case RLP_CONNECTION_ESTABLISHED: | |
847 /* | |
848 * processing for state RLP_CONNECTION_ESTABLISHED | |
849 */ | |
850 rlp_data->ker.SF = SF_SREJ; | |
851 | |
852 /* | |
853 * unsolicited F_Bit ? | |
854 */ | |
855 if (!(pFBit EQ 1 AND cBit EQ 0 AND rlp_data->ker.Poll_State NEQ ISW_WAIT)) | |
856 { | |
857 /* | |
858 * NR within range of send frames pending | |
859 * for acknowledgement ?? | |
860 */ | |
861 if (sbm_frame_in_range (nr)) | |
862 if (!ker_i_handler (ns)) | |
863 { | |
864 ker_s_handler (cBit, pFBit, rlp_data->ker.SF, nr, &retransError); | |
865 if (retransError) | |
866 { | |
867 SET_STATE(KER, RLP_DISCONNECT_INITIATED); | |
868 TRACE_EVENT("#9"); | |
869 } | |
870 } | |
871 } | |
872 break; | |
873 } | |
874 } | |
875 | |
876 /* | |
877 +------------------------------------------------------------------------------ | |
878 | Function : sig_rcv_ker_ui_ind | |
879 +------------------------------------------------------------------------------ | |
880 | Description : Process signal SIG_UI_IND received from process rcv. | |
881 | | |
882 | Parameters : cBit - | |
883 | pFBit - | |
884 | | |
885 | Return : - | |
886 +------------------------------------------------------------------------------ | |
887 */ | |
888 | |
889 | |
890 /* | |
891 +------------------------------------------------------------------------------ | |
892 | Function : sig_rcv_ker_xid_ind | |
893 +------------------------------------------------------------------------------ | |
894 | Description : Process signal SIG_XID_IND received from process rcv. | |
895 | | |
896 | Parameters : cBit | |
897 | pFBit | |
898 | | |
899 | Return : - | |
900 +------------------------------------------------------------------------------ | |
901 */ | |
902 | |
903 | |
904 GLOBAL void sig_rcv_ker_xid_ind | |
905 ( | |
906 T_BIT cBit, | |
907 T_BIT pFBit | |
908 ) | |
909 { | |
910 TRACE_FUNCTION ("sig_rcv_ker_xid_ind()"); | |
911 | |
912 switch (GET_STATE (KER)) | |
913 { | |
914 case RLP_ADM_AND_DETACHED: | |
915 /* | |
916 * processing for state RLP_ADM_AND_DETACHED | |
917 */ | |
918 | |
919 break; | |
920 | |
921 default: | |
922 /* | |
923 * processing for all other kernel states | |
924 */ | |
925 if (cBit EQ 1) | |
926 { | |
927 switch (GET_STATE(KERXID_C)) | |
928 { | |
929 case ISW_WAIT: | |
930 { | |
931 rlp_data->ker.Poll_xchg = IW_IDLE; | |
932 SET_STATE(KERXID_C, ISW_IDLE); | |
933 | |
934 /* | |
935 TIMERSTOP (rlp_data->txid_handle); | |
936 | |
937 TIMERSTART | |
938 ( | |
939 TXID, | |
940 rlp_data->ker.T1, | |
941 rlp_data->txid_handle | |
942 ); | |
943 */ | |
944 } | |
945 break; | |
946 | |
947 default: | |
948 { | |
949 PALLOC (rlp_xid_ind, RLP_XID_IND); | |
950 | |
951 ker_get_xid_data | |
952 ( | |
953 rbm_get_current_frame () + HEADER_LEN, | |
954 0, | |
955 rlp_xid_ind, | |
956 FALSE, | |
957 &rlp_data->ker.XID_R_Used_Flg | |
958 ); | |
959 | |
960 PSENDX (L2R, rlp_xid_ind); | |
961 | |
962 ker_put_xid_data | |
963 ( | |
964 rlp_data->ker.XID_R_Frame + HEADER_LEN, | |
965 0, | |
966 rlp_data->ker.XID_R_Used_Flg, | |
967 FALSE, | |
968 rlp_data->ker.Rlp_Vers, | |
969 rlp_data->ker.K_iwf_ms, | |
970 rlp_data->ker.K_ms_iwf, | |
971 rlp_data->ker.T1, | |
972 rlp_data->ker.N2, | |
973 rlp_data->ker.T2, | |
974 rlp_data->ker.Pt, | |
975 rlp_data->ker.P0, | |
976 rlp_data->ker.P1, | |
977 rlp_data->ker.P2 | |
978 ); | |
979 | |
980 rlp_data->ker.XID_R_State = IS_SEND; | |
981 | |
982 rlp_data->ker.XID_R_FBit = pFBit; | |
983 | |
984 SET_STATE(KERXID_C, ISW_IDLE); | |
985 } | |
986 break; | |
987 } | |
988 } | |
989 else | |
990 { | |
991 switch (GET_STATE(KERXID_C)) | |
992 { | |
993 case ISW_WAIT: | |
994 if (pFBit EQ 1) | |
995 { | |
996 PALLOC (rlp_xid_ind, RLP_XID_IND); | |
997 | |
998 rlp_data->ker.Poll_xchg = IW_IDLE; | |
999 | |
1000 TIMERSTOP (TXID_HANDLE); | |
1001 ker_get_xid_data | |
1002 ( | |
1003 rbm_get_current_frame () + HEADER_LEN, | |
1004 0, | |
1005 rlp_xid_ind, | |
1006 TRUE, | |
1007 &rlp_data->ker.XID_C_Used_Flg | |
1008 ); | |
1009 | |
1010 PSENDX (L2R, rlp_xid_ind); | |
1011 | |
1012 SET_STATE(KERXID_C, ISW_IDLE); | |
1013 } | |
1014 break; | |
1015 | |
1016 default: | |
1017 break; | |
1018 } | |
1019 } | |
1020 break; | |
1021 } | |
1022 } | |
1023 | |
1024 /* | |
1025 +------------------------------------------------------------------------------ | |
1026 | Function : sig_rcv_ker_test_ind | |
1027 +------------------------------------------------------------------------------ | |
1028 | Description : Process signal SIG_TEST_IND received from process rcv. | |
1029 | | |
1030 | Parameters : cBit - | |
1031 | pFBit - | |
1032 | | |
1033 | Return : - | |
1034 +------------------------------------------------------------------------------ | |
1035 */ | |
1036 | |
1037 | |
1038 GLOBAL void sig_rcv_ker_test_ind | |
1039 ( | |
1040 T_BIT cBit, | |
1041 T_BIT pFBit | |
1042 ) | |
1043 { | |
1044 TRACE_FUNCTION ("sig_rcv_ker_test_ind()"); | |
1045 | |
1046 switch (GET_STATE (KER)) | |
1047 { | |
1048 case RLP_ADM_AND_DETACHED: | |
1049 /* | |
1050 * no processing for state RLP_ADM_AND_DETACHED | |
1051 */ | |
1052 break; | |
1053 | |
1054 default: | |
1055 /* | |
1056 * processing for all other kernel states | |
1057 */ | |
1058 if (cBit EQ 1) | |
1059 { | |
1060 rlp_data->ker.TEST_R_State = IS_SEND; | |
1061 rlp_data->ker.TEST_R_FBit = pFBit; | |
1062 memcpy | |
1063 ( | |
1064 rlp_data->ker.TEST_R_Frame, | |
1065 rbm_get_current_frame (), | |
1066 rlp_data->ker.FrameSize | |
1067 ); | |
1068 } | |
1069 break; | |
1070 } | |
1071 } | |
1072 | |
1073 /* | |
1074 +------------------------------------------------------------------------------ | |
1075 | Function : sig_rcv_ker_remap_ind | |
1076 +------------------------------------------------------------------------------ | |
1077 | Description : Process signal SIG_REMAP_IND received from process rcv. | |
1078 | | |
1079 | Parameters : - | |
1080 | | |
1081 | | |
1082 | Return : - | |
1083 +------------------------------------------------------------------------------ | |
1084 */ | |
1085 | |
1086 | |
1087 GLOBAL void sig_rcv_ker_remap_ind | |
1088 ( | |
1089 void | |
1090 ) | |
1091 { | |
1092 T_RBM_FRAMEPTR remapFrame; | |
1093 | |
1094 TRACE_FUNCTION ("sig_rcv_ker_remap_ind()"); | |
1095 | |
1096 switch (GET_STATE (KER)) | |
1097 { | |
1098 case RLP_PENDING_REMAP_REQ: | |
1099 { | |
1100 PALLOC (rlp_xid_ind, RLP_XID_IND); | |
1101 | |
1102 remapFrame = rbm_get_current_frame(); | |
1103 | |
1104 rlp_data->ker.RemapNr = (*(T_RLP_FRAME_LONG *)remapFrame)[HEADER_LEN] >> 2; | |
1105 | |
1106 sbm_ack_upto_n (rlp_data->ker.RemapNr); | |
1107 | |
1108 ker_get_xid_data | |
1109 ( | |
1110 remapFrame + HEADER_LEN, | |
1111 2, | |
1112 rlp_xid_ind, | |
1113 TRUE, | |
1114 &rlp_data->ker.XID_C_Used_Flg | |
1115 ); | |
1116 | |
1117 PSENDX (L2R, rlp_xid_ind); | |
1118 | |
1119 if (!ker_send_remap_data ()) | |
1120 { | |
1121 PALLOC (rlp_remap_cnf, RLP_REMAP_CNF); | |
1122 | |
1123 sbm_reset_after_remap | |
1124 ( | |
1125 rlp_data->ker.FrameSize, | |
1126 rlp_data->ker.RemapNr | |
1127 ); | |
1128 | |
1129 PSENDX (L2R, rlp_remap_cnf); | |
1130 SET_STATE (KER, RLP_CONNECTION_ESTABLISHED); | |
1131 break; | |
1132 } | |
1133 | |
1134 SET_STATE (KER, RLP_REMAP_DATA); | |
1135 break; | |
1136 } | |
1137 | |
1138 default: | |
1139 break; | |
1140 } | |
1141 } | |
1142 | |
1143 /* | |
1144 +------------------------------------------------------------------------------ | |
1145 | Function : sig_rcv_ker_ready_ind | |
1146 +------------------------------------------------------------------------------ | |
1147 | Description : Process signal SIG_READY_IND received from process rcv. | |
1148 | | |
1149 | Parameters : - | |
1150 | | |
1151 | | |
1152 | Return : - | |
1153 +------------------------------------------------------------------------------ | |
1154 */ | |
1155 | |
1156 GLOBAL void sig_rcv_ker_ready_ind(void) | |
1157 { | |
1158 /* | |
1159 * FreeCalypso: when we tried to compile this code from TCS3.2 | |
1160 * in our TCS211-mimicking Magnetite environment, we hit a BUG | |
1161 * in TI's compiler, or more precisely, the compiler version used | |
1162 * in TCS211: compiling this C module would fail as the compiler | |
1163 * was producing bad assembly which the asm step rejected. | |
1164 * Analysis of the generated asm showed that the switch table | |
1165 * and all of the switch case code was omitted, but the reference | |
1166 * to the switch table was still there, hence asm failing. | |
1167 * | |
1168 * The following four volatile char initialized but otherwise unused | |
1169 * automatic variables constitute the workaround we have added to | |
1170 * get this C module past the broken compiler. This workaround was | |
1171 * inspired by the disassembly of the rlp_kers.obj binary object | |
1172 * from the TCS211 blob library: it appears that TI had applied a | |
1173 * very similar workaround on their end to get this code past the | |
1174 * same broken compiler. The generated code we get is not exactly | |
1175 * the same as what's in the blob, so our recreation of TI's compiler | |
1176 * workaround is probably inexact, but it does the job of getting | |
1177 * this C module past the compiler. | |
1178 */ | |
1179 volatile char bug1 = 'A'; | |
1180 volatile char bug2 = 'B'; | |
1181 volatile char bug3 = 'C'; | |
1182 volatile char bug4 = 0; | |
1183 | |
1184 TRACE_FUNCTION ("sig_rcv_ker_ready_ind()"); | |
1185 | |
1186 switch (GET_STATE (KER)) | |
1187 { | |
1188 case RLP_ADM_AND_DETACHED: | |
1189 switch (rlp_data->ker.DM_State) | |
1190 { | |
1191 case IS_IDLE: | |
1192 sig_ker_snd_null_req (); | |
1193 break; | |
1194 | |
1195 case IS_SEND: | |
1196 sig_ker_snd_dm_req (rlp_data->ker.DM_FBit); | |
1197 rlp_data->ker.DM_State = IS_IDLE; | |
1198 break; | |
1199 } | |
1200 break; | |
1201 | |
1202 case RLP_ADM_AND_ATTACHED: | |
1203 if (!ker_send_txu()) | |
1204 { | |
1205 switch(rlp_data->ker.DM_State) | |
1206 { | |
1207 case IS_IDLE: | |
1208 switch (rlp_data->ker.UA_State) | |
1209 { | |
1210 case IS_IDLE: | |
1211 sig_ker_snd_null_req (); | |
1212 break; | |
1213 | |
1214 case IS_SEND: | |
1215 sig_ker_snd_ua_req (rlp_data->ker.UA_FBit); | |
1216 rlp_data->ker.UA_State = IS_IDLE; | |
1217 break; | |
1218 } | |
1219 break; | |
1220 | |
1221 case IS_SEND: | |
1222 sig_ker_snd_dm_req(rlp_data->ker.DM_FBit); | |
1223 rlp_data->ker.DM_State = IS_IDLE; | |
1224 break; | |
1225 } | |
1226 } | |
1227 break; | |
1228 | |
1229 case RLP_PENDING_CONNECT_REQ: | |
1230 if (!ker_send_txu()) | |
1231 { | |
1232 switch (rlp_data->ker.SABM_State) | |
1233 { | |
1234 case ISW_SEND: | |
1235 switch (rlp_data->ker.Poll_xchg) | |
1236 { | |
1237 case IW_IDLE: | |
1238 sig_ker_snd_sabm_req (); | |
1239 rlp_data->ker.SABM_State = ISW_WAIT; | |
1240 rlp_data->ker.SABM_Count++; | |
1241 rlp_data->ker.Poll_xchg = IW_WAIT; | |
1242 TIMERSTART(TT_HANDLE, rlp_data->ker.T1); | |
1243 break; | |
1244 | |
1245 default: | |
1246 sig_ker_snd_null_req (); | |
1247 break; | |
1248 } | |
1249 break; | |
1250 | |
1251 default: | |
1252 sig_ker_snd_null_req (); | |
1253 break; | |
1254 } | |
1255 } | |
1256 break; | |
1257 | |
1258 case RLP_PENDING_CONNECT_IND: | |
1259 if (!ker_send_txu()) | |
1260 sig_ker_snd_null_req (); | |
1261 break; | |
1262 | |
1263 case RLP_CONNECTION_ESTABLISHED: | |
1264 if (!ker_send_txu()) | |
1265 ker_send_data (); | |
1266 break; | |
1267 | |
1268 case RLP_DISCONNECT_INITIATED: | |
1269 if (!ker_send_txu()) | |
1270 { | |
1271 switch (rlp_data->ker.DISC_State) | |
1272 { | |
1273 case ISW_WAIT: | |
1274 sig_ker_snd_null_req (); | |
1275 break; | |
1276 | |
1277 default: | |
1278 if (rlp_data->ker.DISC_PBit EQ 1 AND rlp_data->ker.Poll_xchg EQ IW_WAIT) | |
1279 { | |
1280 sig_ker_snd_null_req (); | |
1281 } | |
1282 else | |
1283 { | |
1284 sig_ker_snd_disc_req (rlp_data->ker.DISC_PBit); | |
1285 if (rlp_data->ker.DISC_PBit EQ 1) | |
1286 rlp_data->ker.Poll_xchg = IW_WAIT; | |
1287 | |
1288 rlp_data->ker.DISC_State = ISW_WAIT; | |
1289 rlp_data->ker.DISC_Count++; | |
1290 TIMERSTART (TT_HANDLE, rlp_data->ker.T1); | |
1291 } | |
1292 break; | |
1293 } | |
1294 } | |
1295 break; | |
1296 | |
1297 case RLP_PENDING_RESET_REQ: | |
1298 if (!ker_send_txu()) | |
1299 { | |
1300 switch (rlp_data->ker.SABM_State) | |
1301 { | |
1302 case ISW_WAIT: | |
1303 sig_ker_snd_null_req (); | |
1304 break; | |
1305 | |
1306 case ISW_SEND: | |
1307 switch (rlp_data->ker.Poll_xchg) | |
1308 { | |
1309 case IW_IDLE: | |
1310 sig_ker_snd_sabm_req (); | |
1311 rlp_data->ker.SABM_State = ISW_WAIT; | |
1312 rlp_data->ker.SABM_Count++; | |
1313 rlp_data->ker.Poll_xchg = IW_WAIT; | |
1314 TIMERSTART (TT_HANDLE, rlp_data->ker.T1); | |
1315 break; | |
1316 | |
1317 default: | |
1318 sig_ker_snd_null_req (); | |
1319 break; | |
1320 } | |
1321 break; | |
1322 } | |
1323 } | |
1324 break; | |
1325 | |
1326 case RLP_PENDING_RESET_IND: | |
1327 if (!ker_send_txu()) | |
1328 sig_ker_snd_null_req (); | |
1329 break; | |
1330 | |
1331 case RLP_PENDING_REMAP_REQ: | |
1332 if (!ker_send_txu()) | |
1333 { | |
1334 if (rlp_data->ker.Poll_xchg EQ IW_IDLE) | |
1335 { | |
1336 TIMERSTART(TT_HANDLE, rlp_data->ker.T1 * rlp_data->ker.N2); | |
1337 rlp_data->ker.Poll_xchg = IW_WAIT; | |
1338 } | |
1339 sig_ker_snd_remap_req (&rlp_data->ker.REMAP_FrameDesc); | |
1340 } | |
1341 break; | |
1342 } | |
1343 } | |
1344 | |
1345 /* | |
1346 +--------------------------------------------------------------------+ | |
1347 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
1348 | STATE : code ROUTINE : ker_interpret_rlp_frame | | |
1349 +--------------------------------------------------------------------+ | |
1350 | |
1351 PURPOSE : decodes the elements from the given RLP frame | |
1352 | |
1353 */ | |
1354 | |
1355 LOCAL void ker_interpret_rlp_frame | |
1356 ( | |
1357 T_RLP_FRAMEPTR frame, | |
1358 T_PDU_TYPE *pduType, | |
1359 T_BIT *cBit, | |
1360 T_BIT *pFBit, | |
1361 T_FRAME_NUM *nr, | |
1362 T_FRAME_NUM *ns, | |
1363 BOOL *crcOk | |
1364 ) | |
1365 { | |
1366 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1367 T_RLP_DEBUG *deb = &rlp_data->deb; | |
1368 | |
1369 deb->idx=0; | |
1370 deb->trc_buf[deb->idx++] = ((crcOk NEQ NULL) ? 'D' : 'U'); | |
1371 deb->trc_buf[deb->idx++] = ':'; | |
1372 #endif | |
1373 | |
1374 #ifdef _SIMULATION_ | |
1375 TRACE_FUNCTION ("ker_interpret_rlp_frame()"); | |
1376 #endif | |
1377 | |
1378 *cBit = (T_BIT) (frame[0] & 1); | |
1379 *ns = (T_FRAME_NUM) ((frame[0] >> 3) | ((frame[1] & 1)<<5)); | |
1380 *pFBit = (T_BIT) ((frame[1] & 2)>>1); | |
1381 | |
1382 switch (*ns) | |
1383 { | |
1384 case 62: /* S-Frame */ | |
1385 { | |
1386 T_SF sFrame; | |
1387 | |
1388 *nr = (T_FRAME_NUM) ((frame[1]>>2) & 0x3f); | |
1389 | |
1390 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1391 deb->trc_buf[deb->idx++] = 'S'; | |
1392 deb->trc_buf[deb->idx++] = 'r'; | |
1393 DEC_BYTE (*nr, &deb->trc_buf[deb->idx]); deb->idx+=3; | |
1394 deb->trc_buf[deb->idx++] = ' '; | |
1395 #endif | |
1396 | |
1397 sFrame = (T_SF) ((frame[0]>>1) & 0x03); | |
1398 | |
1399 /* | |
1400 * maybe optimize with a table!! | |
1401 */ | |
1402 switch (sFrame) | |
1403 { | |
1404 case SF_RR: | |
1405 *pduType = PDU_RR; | |
1406 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1407 memcpy(&deb->trc_buf[deb->idx], "RR ",3); | |
1408 #endif | |
1409 break; | |
1410 | |
1411 case SF_RNR: | |
1412 *pduType = PDU_RNR; | |
1413 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1414 memcpy(&deb->trc_buf[deb->idx], "RNR",3); | |
1415 #endif | |
1416 break; | |
1417 case SF_REJ: | |
1418 *pduType = PDU_REJ; | |
1419 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1420 memcpy(&deb->trc_buf[deb->idx], "REJ",3); | |
1421 #endif | |
1422 break; | |
1423 case SF_SREJ: | |
1424 *pduType = PDU_SREJ; | |
1425 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1426 memcpy(&deb->trc_buf[deb->idx], "SRJ",3); | |
1427 #endif | |
1428 break; | |
1429 default: | |
1430 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1431 memcpy(&deb->trc_buf[deb->idx], "***",3); | |
1432 #endif | |
1433 break; | |
1434 | |
1435 } | |
1436 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1437 deb->idx+=3; | |
1438 #endif | |
1439 break; | |
1440 } | |
1441 | |
1442 case 63: /* U-Frame */ | |
1443 { | |
1444 T_UF uFrame; | |
1445 uFrame = (T_UF) ((frame[1]>>2) & 0x1f); | |
1446 | |
1447 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1448 deb->trc_buf[deb->idx++] = 'U'; | |
1449 deb->trc_buf[deb->idx++] = ' '; | |
1450 #endif | |
1451 | |
1452 /* | |
1453 * maybe optimize with a table!! | |
1454 */ | |
1455 switch (uFrame) | |
1456 { | |
1457 case UF_UI: | |
1458 *pduType = PDU_UI; | |
1459 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1460 memcpy(&deb->trc_buf[deb->idx], "UI ",4); | |
1461 #endif | |
1462 break; | |
1463 | |
1464 case UF_DM: | |
1465 *pduType = PDU_DM; | |
1466 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1467 memcpy(&deb->trc_buf[deb->idx], "DM ",4); | |
1468 #endif | |
1469 break; | |
1470 | |
1471 case UF_SABM: | |
1472 *pduType = PDU_SABM; | |
1473 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1474 memcpy(&deb->trc_buf[deb->idx], "SABM",4); | |
1475 #endif | |
1476 break; | |
1477 | |
1478 case UF_DISC: | |
1479 *pduType = PDU_DISC; | |
1480 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1481 memcpy(&deb->trc_buf[deb->idx], "DISC",4); | |
1482 #endif | |
1483 break; | |
1484 | |
1485 case UF_UA: | |
1486 *pduType = PDU_UA; | |
1487 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1488 memcpy(&deb->trc_buf[deb->idx], "UA ",4); | |
1489 #endif | |
1490 break; | |
1491 | |
1492 case UF_NULL: | |
1493 *pduType = PDU_NULL; | |
1494 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1495 memcpy(&deb->trc_buf[deb->idx], "NULL",4); | |
1496 #endif | |
1497 break; | |
1498 | |
1499 case UF_XID: | |
1500 *pduType = PDU_XID; | |
1501 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1502 memcpy(&deb->trc_buf[deb->idx], "XID ",4); | |
1503 #endif | |
1504 break; | |
1505 | |
1506 case UF_TEST: | |
1507 *pduType = PDU_TEST; | |
1508 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1509 memcpy(&deb->trc_buf[deb->idx], "TEST",4); | |
1510 #endif | |
1511 break; | |
1512 | |
1513 case UF_REMAP: | |
1514 *pduType = PDU_REMAP; | |
1515 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1516 memcpy(&deb->trc_buf[deb->idx], "RMAP",4); | |
1517 #endif | |
1518 break; | |
1519 | |
1520 default: | |
1521 *pduType = PDU_INVALID; | |
1522 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1523 memcpy(&deb->trc_buf[deb->idx], "****",4); | |
1524 #endif | |
1525 break; | |
1526 } | |
1527 *nr = 0; | |
1528 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1529 deb->idx += 4; | |
1530 #endif | |
1531 break; | |
1532 } | |
1533 | |
1534 default: /* I+S-Frame */ | |
1535 { | |
1536 T_SF sFrame; | |
1537 | |
1538 *nr = (T_FRAME_NUM) ((frame[1]>>2) & 0x3f); | |
1539 | |
1540 sFrame = (T_SF) ((frame[0]>>1) & 0x03); | |
1541 | |
1542 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1543 deb->trc_buf[deb->idx++] = 'I'; | |
1544 deb->trc_buf[deb->idx++] = 'r'; | |
1545 DEC_BYTE (*nr, &deb->trc_buf[deb->idx]); deb->idx+=3; | |
1546 deb->trc_buf[deb->idx++] = 's'; | |
1547 DEC_BYTE (*ns, &deb->trc_buf[deb->idx]); deb->idx+=3; | |
1548 deb->trc_buf[deb->idx++] = ' '; | |
1549 #endif | |
1550 /* | |
1551 * maybe optimize with a table!! | |
1552 */ | |
1553 switch (sFrame) | |
1554 { | |
1555 case SF_RR: | |
1556 *pduType = PDU_RR_I; | |
1557 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1558 memcpy(&deb->trc_buf[deb->idx], "RR ",3); | |
1559 #endif | |
1560 break; | |
1561 | |
1562 case SF_RNR: | |
1563 *pduType = PDU_RNR_I; | |
1564 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1565 memcpy(&deb->trc_buf[deb->idx], "RNR",3); | |
1566 #endif | |
1567 break; | |
1568 case SF_REJ: | |
1569 *pduType = PDU_REJ_I; | |
1570 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1571 memcpy(&deb->trc_buf[deb->idx], "REJ",3); | |
1572 #endif | |
1573 break; | |
1574 case SF_SREJ: | |
1575 *pduType = PDU_SREJ_I; | |
1576 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1577 memcpy(&deb->trc_buf[deb->idx], "SRJ",3); | |
1578 #endif | |
1579 break; | |
1580 default: | |
1581 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1582 memcpy(&deb->trc_buf[deb->idx], "***",3); | |
1583 #endif | |
1584 break; | |
1585 } | |
1586 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1587 deb->idx += 3; | |
1588 #endif | |
1589 break; | |
1590 } | |
1591 } | |
1592 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1593 if ( | |
1594 (*pduType NEQ PDU_NULL) | |
1595 AND | |
1596 ( | |
1597 (crcOk EQ NULL AND rlp_data->uplink_frame_trace) | |
1598 OR | |
1599 (crcOk NEQ NULL AND rlp_data->downlink_frame_trace) | |
1600 ) | |
1601 ) | |
1602 { | |
1603 deb->trc_buf[deb->idx++] = ' '; | |
1604 deb->trc_buf[deb->idx++] = ((*cBit) ? 'C' : 'R'); | |
1605 deb->trc_buf[deb->idx++] = ((*cBit) ? 'P' : 'F'); | |
1606 deb->trc_buf[deb->idx++] = ' '; | |
1607 HEX_BYTE (frame[1], &deb->trc_buf[deb->idx]); deb->idx+=2; | |
1608 HEX_BYTE (frame[0], &deb->trc_buf[deb->idx]); deb->idx+=2; | |
1609 deb->trc_buf[deb->idx++] = ' '; | |
1610 HEX_BYTE (frame[2], &deb->trc_buf[deb->idx]); deb->idx+=2; | |
1611 HEX_BYTE (frame[3], &deb->trc_buf[deb->idx]); deb->idx+=2; | |
1612 | |
1613 deb->trc_buf[deb->idx] = '\0'; | |
1614 TRACE_EVENT (deb->trc_buf); | |
1615 } | |
1616 #endif | |
1617 /* | |
1618 * no CRC checking at this point. Checking is performed at | |
1619 * Layer 1, so only correct frames are forwared. | |
1620 */ | |
1621 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1622 if (crcOk NEQ NULL) | |
1623 #endif | |
1624 *crcOk = TRUE; | |
1625 } | |
1626 | |
1627 #ifdef _SIMULATION_ | |
1628 /* | |
1629 +--------------------------------------------------------------------+ | |
1630 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
1631 | STATE : code ROUTINE : ker_get_frame_from_sdu | | |
1632 +--------------------------------------------------------------------+ | |
1633 | |
1634 PURPOSE : | |
1635 | |
1636 */ | |
1637 | |
1638 LOCAL T_RLP_FRAMEPTR ker_get_frame_from_sdu(T_sdu *sdu) | |
1639 { | |
1640 TRACE_FUNCTION ("ker_get_frame_from_sdu()"); | |
1641 | |
1642 return sdu->buf+(sdu->o_buf>>3); | |
1643 } | |
1644 #endif | |
1645 | |
1646 /* | |
1647 +--------------------------------------------------------------------+ | |
1648 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
1649 | STATE : code ROUTINE : ker_analyse_prim | | |
1650 +--------------------------------------------------------------------+ | |
1651 | |
1652 PURPOSE : | |
1653 | |
1654 */ | |
1655 | |
1656 #ifdef _SIMULATION_ | |
1657 LOCAL void ker_analyse_prim(T_RA_DATA_IND *ra_data_ind) | |
1658 #else | |
1659 LOCAL void ker_analyse_prim(void) | |
1660 #endif | |
1661 { | |
1662 T_RLP_FRAMEPTR frame; | |
1663 T_PDU_TYPE pduType; | |
1664 T_BIT cBit; | |
1665 T_BIT pFBit; | |
1666 T_FRAME_NUM nr, ns; | |
1667 BOOL crcOk; | |
1668 | |
1669 TRACE_FUNCTION ("ker_analyse_prim()"); | |
1670 | |
1671 #ifdef _SIMULATION_ | |
1672 PACCESS (ra_data_ind); | |
1673 frame = ker_get_frame_from_sdu (&ra_data_ind->sdu); | |
1674 rbm_store_frame (frame); | |
1675 PFREE (ra_data_ind); | |
1676 #endif | |
1677 | |
1678 frame = rbm_get_current_frame (); | |
1679 | |
1680 /* | |
1681 TRACE_DATA_RLP_FRAME(frame); | |
1682 */ | |
1683 | |
1684 ker_interpret_rlp_frame | |
1685 ( | |
1686 frame, | |
1687 &pduType, | |
1688 &cBit, | |
1689 &pFBit, | |
1690 &nr, | |
1691 &ns, | |
1692 &crcOk | |
1693 ); | |
1694 | |
1695 sig_ker_rcv_rawdata_res | |
1696 ( | |
1697 pduType, | |
1698 cBit, | |
1699 pFBit, | |
1700 nr, | |
1701 ns, | |
1702 crcOk | |
1703 ); | |
1704 | |
1705 } | |
1706 | |
1707 /* | |
1708 +------------------------------------------------------------------------------ | |
1709 | Function : sig_rcv_ker_rawdata_ind | |
1710 +------------------------------------------------------------------------------ | |
1711 | Description : Process signal SIG_RAWDATA_IND received from process rcv. | |
1712 | | |
1713 | Parameters : ra_data_ind - | |
1714 | | |
1715 | | |
1716 | Return : - | |
1717 +------------------------------------------------------------------------------ | |
1718 */ | |
1719 | |
1720 #ifdef _SIMULATION_ | |
1721 GLOBAL void sig_rcv_ker_rawdata_ind(T_RA_DATA_IND *ra_data_ind) | |
1722 #else | |
1723 GLOBAL void sig_rcv_ker_rawdata_ind(void) | |
1724 #endif | |
1725 { | |
1726 TRACE_FUNCTION ("sig_rcv_ker_rawdata_ind()"); | |
1727 | |
1728 #ifdef _SIMULATION_ | |
1729 ker_analyse_prim(ra_data_ind); | |
1730 #else | |
1731 ker_analyse_prim(); | |
1732 #endif | |
1733 } |