comparison src/g23m-gsm/dl/dl.h @ 104:27a4235405c6

src/g23m-gsm: import from LoCosto source
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 04 Oct 2016 18:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
103:76d139c7a25e 104:27a4235405c6
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS
4 | Modul : DL
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 : Definitions for the Protocol Stack Entity
18 | Data Link Layer
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef __DL_H__
23 #define __DL_H__
24
25 #ifdef TI_PS_HCOMM_CHANGE
26 #include "cl_hComm_handle.h"
27 #endif
28
29 #if !defined(_SIMULATION_) && defined(WIN32)
30 #define _SIMULATION_
31 #endif /* !_SIMULATION_ && WIN32 */
32
33 #if defined (_SIMULATION_)
34 #if defined(DL_2TO1)
35 #include <p_8010_148_l1test_sap.h>
36 #endif /* DL_2TO1 */
37 #else /* _SIMULATION_ */
38 #if !defined(_TARGET_)
39 #define _TARGET_
40 #endif /* !_TARGET_ */
41 #endif /* _SIMULATION_ */
42
43 /*
44 * the following defines have an impact on the behaviour of the layer 2
45 */
46 /*
47 * DL_TRACE_ENABLED
48 * is set : Enables the trace feature (buffered or immediately trace)
49 * isīnt set: Disables the trace feature
50 */
51 #define DL_TRACE_ENABLED
52
53 /*
54 * DL_IMMEDIATE_TRACE
55 * operates only with enabled trace feature!
56 * is set : Enables unbuffered trace. Write out the trace immediately without
57 * buffering (or rather delayed by signalling to itself while the MS
58 * is in interrupt context state).
59 * isīnt set: Enables buffered trace (write out in idle mode only)
60 * Attention: Due to the interrupt context of the uplink and downlink trace
61 this feature requires very fast trace capability. The normal trace
62 transfer rate of 115200 Baud is not sufficient!
63 */
64 #define DL_IMMEDIATE_TRACE
65
66 /*
67 * DISABLE_MEASREPORT_TRACE
68 * operates only with enabled buffered trace!
69 * is set : Disables trace of measurement reports
70 * isīnt set: Normal trace of measurement reports
71 #define DISABLE_MEASREPORT_TRACE
72 */
73 /*
74 * DISABLE_EMPTY_UI
75 * operates only with enabled buffered trace!
76 * is set : Disables trace of empty frames
77 * isīnt set: Normal trace of empty frames
78 */
79 #define DISABLE_EMPTY_UI
80
81 /*
82 * DELAYED_RELEASE_IND
83 * is set : Delayed release indication after reception of DISC to enable
84 * layer 1 the transmission of the UA acknowledge (After sent of the
85 * release indication to RR, RR stops the dedicated mode in layer 1).
86 * During the delay, DL sends only dummy frames for some uplink
87 * opportunities (see DL_FACCH_RELEASE_DELAY_VALUE and
88 * DL_SDCCH_RELEASE_DELAY_VALUE). The delay stops after the given
89 * count of uplinked dummy frames or at a downlink on this channel.
90 * isīnt set: No delayed release indication
91 */
92 #define DELAYED_RELEASE_IND
93
94 #if defined(DELAYED_RELEASE_IND)
95 /*
96 * When RR stops the dedicated mode, the TI layer is not capable for correct
97 * completion of the UA response transmission. Therefore DL delays the release
98 * indication to RR for some uplink opportunities to give layer 1 time to
99 * transmit the frame completely before RR stops the dedicated mode.
100 */
101 #define DL_FACCH_RELEASE_DELAY_VALUE 4 /* number of wait dummies on FACCH */
102 #define DL_SDCCH_RELEASE_DELAY_VALUE 1 /* number of wait dummies on SDCCH */
103 #endif /* DELAYED_RELEASE_IND */
104
105 /*
106 * DELAYED_SABM
107 * is set : To give layer 1 some time to switch the physical channel on FACCH
108 * DL delays the transmit of the SABM frame. After (re-)establishment
109 * request from RR, DL sends only dummies (return NULL) for the first
110 * uplink opportunities (see DL_FACCH_SABM_DELAY_VALUE).
111 * isīnt set: No delayed uplink of the SABM frame.
112 */
113 #define DELAYED_SABM
114
115 #if defined(DELAYED_SABM)
116 #undef DELAYED_SABM
117 #endif /* DELAYED_SABM */
118
119 #if defined(DELAYED_SABM)
120 /*
121 * To give layer 1 some time to switch the physical channel on FACCH
122 * DL delays the transmit of the SABM frame. After (re-)establishment request
123 * from RR, DL sends only dummies (return NULL) for the first uplink
124 * opportunities.
125 */
126 #define DL_FACCH_SABM_DELAY_VALUE 1
127 #endif /* DELAYED_SABM */
128
129 /*
130 * LATE_LEAVING_DEDICATED
131 * is set : The leaving of dedicated mode happens in latest moment, after
132 * the reception of an UA frame after sent of DISC
133 * or before uplink of the UA frame after reception of a DISC frame.
134 * isīnt set: In this case the dedicated mode is leaving immediately after
135 * the detection of a release (after the incoming L3 message
136 * CHANNEL RELEASE, or after reception of a DISC frame or before
137 * the uplink of a DISC frame).
138 */
139 #define LATE_LEAVING_DEDICATED
140
141 /*
142 * IFRAME_AS_RR
143 * is set : I frame might response with I frame
144 * isīnt set: I frame must response with RR frame
145 */
146 #define IFRAME_AS_RR
147
148 /*
149 * INVOKE_SIGNAL
150 * is set : DL does not send primitives or traces within L1 interrupt context
151 * anymore. It sends signals instead. The primitives or traces are
152 * delayed until the entity will be in the own context.
153 * isīnt set: Primitves or traces are processed immediately even is DL within
154 * in L1 interrupt context.
155 */
156 #define INVOKE_SIGNAL
157
158 /*
159 * SEND_FN_TO_L2_IN_DCCH
160 * is set to 1: The function dll_dcch_downlink() contains one more parameter,
161 the absolute frame number FN.
162 * is set to 0: No changes relating to dll_dcch_downlink.
163 */
164 #define SEND_FN_TO_L2_IN_DCCH 1
165
166 /*
167 * RR_SHORT_PD_DETECT_KNOWN_MSG_ONLY
168 * is set to 1: The Bter format is detected for known message types
169 * only (the known messages are defined some lines after in
170 * this header file).
171 * is set to 0: The Bter format is detected on the basis of the short L2 header
172 * format. This is a more general approach, but with the
173 * disadvantage of possibly misconstrued invalid messages.
174 */
175 //#define RR_SHORT_PD_DETECT_KNOWN_MSG_ONLY
176
177 /*
178 * DL_2TO1 flag is used to identify new L1 interface via the MPHC entity
179 * as well as the test interface of the new 2to1 stack.
180 */
181 #ifdef DL_2TO1
182 #define MAX_L2_FRAME_SIZE L1_MAX_L2_FRAME_SIZE
183 #define T_RADIO_FRAME T_L1_RADIO_FRAME
184 #define T_PH_DATA_IND T_MPHC_PH_DATA_IND
185 #define PH_DATA_IND MPHC_PH_DATA_IND
186 #define L2_CHANNEL_SDCCH L1_L2_CHANNEL_SDCCH
187 #define L2_CHANNEL_FACCH_F L1_L2_CHANNEL_FACCH_F
188 #define L2_CHANNEL_FACCH_H L1_L2_CHANNEL_FACCH_H
189 #define L2_CHANNEL_SACCH L1_L2_CHANNEL_SACCH
190 #define CM_SIGNALLING_ONLY MPHC_CM_SIGNALLING_ONLY
191 #define CM_TCH_FS MPHC_CM_TCH_FS
192 #define CM_TCH_HS MPHC_CM_TCH_HS
193 #define VALID_BLOCK L1_VALID_BLOCK
194 #define DATA_VALID MPHC_DATA_VALID
195 #define DL_SAPI_0 PS_SAPI_0
196 #define DL_SAPI_3 PS_SAPI_3
197 #define PH_READY_TO_SEND L1TEST_CALL_MPHC_READ_DCCH
198 #endif /*DL_2TO1*/
199
200 #if defined(_SIMULATION_)
201 #define DL_TRACE_ENABLED /* trace during simulation */
202 #define DL_IMMEDIATE_TRACE /* is write out immediately */
203 #undef DISABLE_MEASREPORT_TRACE /* enable trace of measurement reports */
204 #undef DISABLE_EMPTY_UI /* enable trace of empty frames */
205 #define DL_TRACE_WIN32
206
207 #define TRACE_EVENT_WIN(s) TRACE_EVENT(s)
208 #define TRACE_EVENT_WIN_P1(s,a1) TRACE_EVENT_P1(s,a1)
209 #define TRACE_EVENT_WIN_P2(s,a1,a2) TRACE_EVENT_P2(s,a1,a2)
210 #define TRACE_EVENT_WIN_P3(s,a1,a2,a3) TRACE_EVENT_P3(s,a1,a2,a3)
211 #define TRACE_EVENT_WIN_P4(s,a1,a2,a3,a4) TRACE_EVENT_P4(s,a1,a2,a3,a4)
212 #define TRACE_EVENT_WIN_P5(s,a1,a2,a3,a4,a5) TRACE_EVENT_P5(s,a1,a2,a3,a4,a5)
213 #define TRACE_EVENT_WIN_P6(s,a1,a2,a3,a4,a5,a6) TRACE_EVENT_P6(s,a1,a2,a3,a4,a5,a6)
214 #if 0
215 #define TRACE_EVENT_WIN_P7(s,a1,a2,a3,a4,a5,a6,a7) TRACE_EVENT_P7(s,a1,a2,a3,a4,a5,a6,a7)
216 #endif /* 0 */
217 #define TRACE_EVENT_WIN_P8(s,a1,a2,a3,a4,a5,a6,a7,a8) TRACE_EVENT_P8(s,a1,a2,a3,a4,a5,a6,a7,a8)
218 #define TRACE_EVENT_WIN_P9(s,a1,a2,a3,a4,a5,a6,a7,a8,a9) TRACE_EVENT_P9(s,a1,a2,a3,a4,a5,a6,a7,a8,a9)
219 #else /* _SIMULATION_ */
220 #undef DL_TRACE_WIN32
221
222 #define TRACE_EVENT_WIN(s)
223 #define TRACE_EVENT_WIN_P1(s,a1)
224 #define TRACE_EVENT_WIN_P2(s,a1,a2)
225 #define TRACE_EVENT_WIN_P3(s,a1,a2,a3)
226 #define TRACE_EVENT_WIN_P4(s,a1,a2,a3,a4)
227 #define TRACE_EVENT_WIN_P5(s,a1,a2,a3,a4,a5)
228 #define TRACE_EVENT_WIN_P6(s,a1,a2,a3,a4,a5,a6)
229 #define TRACE_EVENT_WIN_P7(s,a1,a2,a3,a4,a5,a6,a7)
230 #define TRACE_EVENT_WIN_P8(s,a1,a2,a3,a4,a5,a6,a7,a8)
231 #define TRACE_EVENT_WIN_P9(s,a1,a2,a3,a4,a5,a6,a7,a8,a9)
232 #endif /* _SIMULATION_ */
233
234
235 /*==== CONSTANTS ==================================================*/
236 /*
237 * Frame Header Macros
238 */
239 #define GET_LENGTH_INDICATOR(s) ((((s)[2]) & 0xFC)>>2)
240 #define GET_P_BIT(s) ((((s)[1]) & 0x10)>>4)
241 #define GET_M_BIT(s) ((((s)[2]) & 0x02)>>1)
242 #define GET_RECEIVE_NUMBER(s) ((((s)[1]) & 0xE0)>>5)
243 #define GET_SEND_NUMBER(s) ((((s)[1]) & 0x0E)>>1)
244 #define GET_SAPI(s) ((((s)[0]) & 0x1C)>>2)
245 #define GET_EA(s) (((s)[0]) & 1)
246 #define GET_FORMAT_TYPE(s) (((s)[1]) & 3)
247 #define GET_CR(s) ((((s)[0]) & 2)>>1)
248 #define GET_EL(s) (((s)[2]) & 1)
249 #define GET_S_TYPE(s) (((s)[1]) & 0x0F)
250 #define GET_U_TYPE(s) (((s)[1]) & 0xEF)
251 #define GET_BTER_FORMAT(s) (((s)[0]) & (BTER_FORMAT_MASK))
252 #if 0
253 #define GET_LENGTH_FIELD(s) (((s)[2]))
254 #define GET_PSEUDO_LENGTH(s) ((((s)[0]) & 0xFC)>>2)
255 #endif /* 0 */
256
257
258
259 /* Boolean constants */
260 #if !defined(TRUE)
261 #define TRUE (1 EQ 1)
262 #define FALSE (1 EQ 0)
263 #endif
264
265 #if !defined(ELEMENTS)
266 #define ELEMENTS(array) (sizeof(array)/sizeof(array[0]))
267 #endif /* !ELEMENTS */
268
269 /*
270 * Bitoffset for encoding/decoding
271 */
272 #define ENCODE_OFFSET 24
273
274 /*
275 * TI Circuit Switches Interface
276 */
277 #define SIG_ONLY 0
278 #define NO_SIGNALLING 1
279
280 /*
281 * Frame Sizes
282 * Maximum number of octets for the information field for frames of
283 * format A and B (SACCH, SDCCH, FACCH)
284 */
285 #define N201_SDCCH DL_N201_DCCH_A_B
286 #define N201_SACCH DL_N201_SACCH_A_B
287 #define N201_FACCH DL_N201_DCCH_A_B
288
289 /*
290 * VTX commands
291 */
292 #define EMPTY_CMD 0
293 #define RR_CMD 1
294 #define SABM_CMD 2
295 #define DISC_CMD 3
296 #define UA_CMD 4
297 #define DM_CMD 5
298 #define RR_RSP 6
299 #define REJ_CMD 7
300
301 /*
302 * Format Types (Control field format: octet bits 2+1)
303 */
304 #define I_FORMAT 0 /* information transfer format (only bit 1) */
305 #define I1_FORMAT 2 /* information transfer format (only bit 1) + N(S) */
306 #define S_FORMAT 1 /* supervisory format (bits 2+1) */
307 #define U_FORMAT 3 /* unnumbered format (bits 2+1) */
308
309 /*
310 * Frame Types (Control field format: octet bits 8-6,4-1)
311 */
312 #define I_FRAME 0 /* I format (only bit 1) */
313 #define RR_FRAME 1 /* S format (bits 4-1) */
314 #define RNR_FRAME 5 /* S format (bits 4-1) */
315 #define REJ_FRAME 9 /* S format (bits 4-1) */
316 #define DISC_FRAME 0x43 /* U format (bits 8-6,4-1) */
317 #define SABM_FRAME 0x2F /* U format (bits 8-6,4-1) */
318 #define UI_FRAME 0x03 /* U format (bits 8-6,4-1) */
319 #define DM_FRAME 0x0F /* U format (bits 8-6,4-1) */
320 #define UA_FRAME 0x63 /* U format (bits 8-6,4-1) */
321
322 /*
323 * L2 Header Values
324 */
325 #define MS2BS_CMD 0
326 #define MS2BS_RSP 1
327 #if 0
328 #define BS2MS_CMD 1
329 #define BS2MS_RSP 0
330 #define ADDR_RESP_SAPI0 0x03
331 #define ADDR_RESP_SAPI3 0x0F
332 #define ADDR_CMD_SAPI0 0x01
333 #define ADDR_CMD_SAPI3 0x0D
334 #define UA_F0 0x63
335 #define UA_F1 0x73
336 #define RR_F0 0x01
337 #define RR_F1 0x11
338 #define RR_P0 0x01
339 #define RR_P1 0x11
340 #define REJ_F0 0x09
341 #define REJ_F1 0x19
342 #define DISC_P0 0x43
343 #define DISC_P1 0x53
344 #define SABM_P0 0x2F
345 #define SABM_P1 0x3F
346 #define DM_F0 0x0F
347 #define DM_F1 0x1F
348 #define UI_P0 0x03
349 #define I_P0 0x00
350 #define I_P1 0x10
351 #define LENGTH_ZERO 0x01
352 #endif /* 0 */
353
354 /*
355 * Message types for RR messsages using the RR short PD
356 *
357 * up/downlink message type channel name
358 * BSS->MS downlink | 0 0 0 0 0 | | SACCH System Information Type 10
359 * BSS->MS downlink | 0 0 0 0 1 | | FACCH Notification/FACCH
360 * BSS->MS downlink | 0 0 0 1 0 | | DCCH Uplink Free
361 * MS->BSS uplink | 0 0 1 0 0 | | SACCH Enhanced Measurement Report
362 * BSS->MS downlink | 0 0 1 0 1 | | SACCH Measurement Information
363 * | | |
364 * 0 | | RR short PD
365 * 0 0 Short L2 header type 1
366 */
367
368 #define RR_SHORT_PD 0
369 #define L2_SHORT_HEAD 0
370 #if defined(RR_SHORT_PD_DETECT_KNOWN_MSG_ONLY) /* detection of known messages only */
371 #define RR_SHORT_PD_SI10 (((RR_SHORT_PD)<<7)|(0x00<<2)|(L2_SHORT_HEAD)) /* 0x00 */
372 #define RR_SHORT_PD_NOTI_FACCH (((RR_SHORT_PD)<<7)|(0x01<<2)|(L2_SHORT_HEAD)) /* 0x04 */
373 #define RR_SHORT_PD_UPLINK_FREE (((RR_SHORT_PD)<<7)|(0x02<<2)|(L2_SHORT_HEAD)) /* 0x08 */
374 #define RR_SHORT_PD_ENH_MEAS_REP (((RR_SHORT_PD)<<7)|(0x04<<2)|(L2_SHORT_HEAD)) /* 0x10 */
375 #define RR_SHORT_PD_MEAS_INFO (((RR_SHORT_PD)<<7)|(0x05<<2)|(L2_SHORT_HEAD)) /* 0x14 */
376 #endif /* RR_SHORT_PD_DETECT_KNOWN_MSG_ONLY */
377 /* general mask for Bter format */
378 #define NOT_RR_SHORT_PD ((~RR_SHORT_PD)&0x01)
379 #define NOT_L2_SHORT_HEAD ((~L2_SHORT_HEAD)&0x03)
380 #define BTER_FORMAT_MASK (((NOT_RR_SHORT_PD)<<7)|(0x00<<2)|(NOT_L2_SHORT_HEAD)) /* 0x83 */
381 #define SHORT_L2_HEADER_TYPE_1 (((RR_SHORT_PD)<<7)|(0x00<<2)|(L2_SHORT_HEAD)) /* 0x00 */
382 /*
383 * Repetitions
384 */
385 #define FACCH_N200_FR 34
386 #define FACCH_N200_HR 29
387 #define SDCCH_N200 23
388 #define SACCH_N200 5
389 #define N200_ESTABLISHMENT 5
390
391 #ifndef DL_2TO1
392 /* align DL.sap with 8010_152_PS_Include.sap */
393 #define PS_SAPI_0 DL_SAPI_0
394 #define PS_SAPI_3 DL_SAPI_3
395 /* align DL.sap with 8010_153_Cause_Include.sap */
396 #define CAUSE_DL_INFO_FIELD_MISMATCH DL_INFO_FIELD_MISMATCH
397 #endif /* DL_2TO1 */
398
399 #define C_DCCH0 0 /* SAPI=0: SDCCH, FACCH */
400 #define C_DCCH3 1 /* SAPI=3: SDCCH, SACCH */
401 #define C_SACCH0 2 /* SAPI=0: SACCH */
402 #define MAX_CHANNELS 3
403
404 #define PROCESS_NAME_INIT \
405 "DCCH0", \
406 "DCCH3", \
407 "SACCH0"
408
409 /*
410 * States of all Processes
411 */
412 #define STATE_INVALID 0
413 #define STATE_DISABLED 1
414 #define STATE_IDLE_DL 2
415 #define STATE_SUSPENDED 3
416 #define STATE_CONTENTION_RESOLUTION 4
417 #define STATE_AWAITING_ESTABLISHMENT 4
418 #define STATE_MULTIPLE_FRAME_ESTABLISHED 5
419 #define STATE_TIMER_RECOVERY 6
420 #define STATE_AWAITING_RELEASE 7
421 #define MAX_STATES 8
422
423 /*
424 * States of the Process DCCH0, (SAPI=0: SDCCH, FACCH)
425 */
426 #define STATE_DCCH0_NAME_INIT \
427 "invalid" ,\
428 "DISABLED" ,\
429 "IDLE" ,\
430 "SUSPENDED" ,\
431 "CONTENTION_RESOLUTION" ,\
432 "MULTIPLE_FRAME_ESTABLISHED" ,\
433 "TIMER_RECOVERY" ,\
434 "AWAITING_RELEASE"
435 /*
436 * States of the Process DCCH3 (SAPI=3: SDCCH, SACCH)
437 */
438 #define STATE_DCCH3_NAME_INIT \
439 "invalid" ,\
440 "DISABLED" ,\
441 "IDLE" ,\
442 "SUSPENDED" ,\
443 "AWAITING_ESTABLISHMENT" ,\
444 "MULTIPLE_FRAME_ESTABLISHED" ,\
445 "TIMER_RECOVERY" ,\
446 "AWAITING_RELEASE"
447
448 /*
449 * DL manages 3 (MAX_CHANNELS) states: SACCH0, DCCH0, DCCH3
450 */
451 #ifdef OPTION_MULTITHREAD
452 #define PROCESS_NAME _ENTITY_PREFIXED(PROCESS_NAME)
453 #endif
454
455 /*
456 * A definition is provided in DL_PEI.C
457 */
458 #ifdef DL_PEI_C
459 GLOBAL const char * const STATE_DCCH0_NAME[MAX_STATES] = { STATE_DCCH0_NAME_INIT };
460 GLOBAL const char * const STATE_DCCH3_NAME[MAX_STATES] = { STATE_DCCH3_NAME_INIT };
461 GLOBAL const char * const PROCESS_NAME[MAX_CHANNELS] = { PROCESS_NAME_INIT };
462
463 #if defined(DL_TRACE_WIN32)
464 GLOBAL const char * const CH_TYPE_NAME[] =
465 {
466 "ch=0?",
467 "SACCH", /* 0x1 SACCH */
468 "SDCCH", /* 0x2 SDCCH */
469 "FACCH_H", /* 0x3 FACCH Halfrate */
470 "FACCH_F", /* 0x4 FACCH Fullrate */
471 "CCCH", /* 0x5 CCCH */
472 "NBCCH", /* 0x6 normal BCCH */
473 "PCH", /* 0x7 PCH */
474 "EPCH", /* 0x8 extended PCH */
475 "CBCH", /* 0x9 Cell Broadcast Channel */
476 "EBCCH" /* 0xa extended BCCH */
477 };
478 GLOBAL const char * const VTX_NAME[] =
479 {
480 "EMPTY_CMD", /* 0 */
481 "RR_CMD", /* 1 */
482 "SABM_CMD", /* 2 */
483 "DISC_CMD", /* 3 */
484 "UA_CMD", /* 4 */
485 "DM_CMD", /* 5 */
486 "RR_RSP", /* 6 */
487 "REJ_CMD" /* 7 */
488 };
489 GLOBAL const char * const SEND_NAME[] =
490 {
491 "RETURN_NULL", /* 0 */
492 "UPLINK_NULL", /* 1 */
493 "UPLINK_EMPTY", /* 2 */
494 "UPLINK_NORMAL", /* 3 */
495 "UPLINK_UA", /* 4 */
496 "UPLINK_UA_F", /* 5 */
497 "UPLINK_IFRAME", /* 6 */
498 "UPLINK_IFRAME_P", /* 7 */
499 "UPLINK_RR", /* 8 */
500 "UPLINK_RR_F", /* 9 */
501 "UPLINK_REJ", /* 10 */
502 "UPLINK_REJ_F", /* 11 */
503 "UPLINK_DCCH3", /* 12 */
504 "UPLINK_REPORT" /* 13 */
505 };
506 #endif /* DL_TRACE_WIN32 */
507
508 #else /* DL_PEI_C */
509 EXTERN const char * const STATE_DCCH0_NAME[MAX_STATES];
510 EXTERN const char * const STATE_DCCH3_NAME[MAX_STATES];
511 EXTERN const char * const PROCESS_NAME[MAX_CHANNELS];
512
513 #if defined(DL_TRACE_WIN32)
514 EXTERN const char * const CH_TYPE_NAME[];
515 EXTERN const char * const VTX_NAME[];
516 EXTERN const char * const SEND_NAME[];
517 #endif /* DL_TRACE_WIN32 */
518 #endif /* DL_PEI_C */
519
520 /*
521 * TRACE Constants
522 */
523 #define TRACE_UPLINK 0
524 #define TRACE_DOWNLINK 1
525 #define TRACE_DL_EVENT 2
526 #define TRACE_CHSTATE 3
527 #define TRACE_PL_EVENT 4
528 #define TRACE_RR_EVENT 5
529 #define TRACE_UACK_UP 6
530 #define TRACE_UACK_DN 7
531
532 #define TRACE_CH_UNKNOWN MAX_CHANNELS
533
534 /*
535 * Error Causes
536 */
537 #define T200_EXPIRED_N200_PLUS_1_TIMES 0
538 #define UNSOLICITED_UA_RESPONSE 2
539 #define UNSOLICITED_DM_RESPONSE 3
540 #define UNSOLICITED_DM_RESPONSE_ABNORMAL_REL 4
541 #define UNSOLICITED_SUPERVISORY_RESPONSE 5
542 #define SEQUENCE_ERROR 6
543 #define U_FRAME_WITH_INCORRECT_PARAMETERS 7
544 #define S_FRAME_WITH_INCORRECT_PARAMETERS 8
545 #define I_FRAME_WITH_INCORRECT_USE_OF_M_BIT 9
546 #define I_FRAME_WITH_INCORRECT_LENGTH 10
547 #define FRAME_NOT_IMPLEMENTED 11
548
549 /*
550 * DL Uplink commands
551 */
552 enum uplink_enum
553 {
554 RETURN_NULL = 0,
555 UPLINK_NULL,
556 UPLINK_EMPTY,
557 UPLINK_NORMAL,
558 UPLINK_UA,
559 UPLINK_UA_F,
560 UPLINK_IFRAME,
561 UPLINK_IFRAME_P,
562 UPLINK_RR,
563 UPLINK_RR_F,
564 UPLINK_REJ,
565 UPLINK_REJ_F,
566 UPLINK_DCCH3,
567 UPLINK_REPORT
568 };
569
570 #if defined(__PEI_H__) /* frame version 2.4.x */
571 typedef ULONG T_SIGNAL_OPC;
572 #define FRAME_2_4_X
573 #elif defined(PEI_H) /* frame version 2.3.x */
574 typedef USHORT T_SIGNAL_OPC;
575 #define FRAME_2_3_X
576 #else /* frame version unknown */
577 #pragma error("unknown frame version, missing PEI_H or __PEI_H__")
578 #endif /* frame version */
579
580
581 /*==== TYPES ======================================================*/
582 typedef struct
583 {
584 USHORT l_buf;
585 USHORT o_buf;
586 UBYTE buf [DL_MAX_L2_FRAME_SIZE];
587 } T_FRAME;
588
589 /* Buffer concept:
590 * Store buffer Contains complete layer 3 messages for the uplink direction
591 * Sending buffer Contains the complete message which is just send on uplink
592 * Transmit buffer Contains the segment which is just send on uplink
593 * Switch buffer Contains a layer 3 message in case of resumption or reconnection
594 */
595 #define INDEX_MAX_STORE_BUFFER (MAX_QUEUED_MESSAGES-1)
596 #define INDEX_SENDING_BUFFER MAX_QUEUED_MESSAGES
597 #define INDEX_SWITCH_BUFFER (MAX_QUEUED_MESSAGES+1)
598 typedef struct
599 {
600 USHORT no_of_stored_messages;
601 T_DL_DATA_REQ * store_buffer [MAX_QUEUED_MESSAGES];
602 T_DL_DATA_REQ * sending_buffer;
603 T_DL_DATA_REQ * switch_buffer;
604 USHORT act_length;
605 USHORT act_offset;
606 T_FRAME transmit_buffer;
607 UBYTE m_bit;
608 } T_QUEUE;
609
610 typedef struct
611 {
612 UBYTE ch_type;
613 UBYTE vtx;
614 UBYTE T200_counter;
615 UBYTE time_flag;
616 UBYTE contention_resolution;
617 UBYTE reject_exception;
618 UBYTE acknowledge_pending;
619 UBYTE rc;
620 UBYTE f_bit;
621 UBYTE f_bit_flag;
622 UBYTE p_bit_flag;
623 UBYTE va;
624 UBYTE vr;
625 UBYTE vs;
626 } T_CCH;
627
628 #if defined(INVOKE_SIGNAL)
629 typedef struct
630 {
631 UBYTE ch_type;
632 UBYTE sapi;
633 UBYTE indication;
634 } T_DL_SIG_ESTABLISH_IND;
635
636 typedef struct
637 {
638 UBYTE ch_type;
639 UBYTE sapi;
640 } T_DL_SIG_ESTABLISH_CNF;
641
642 typedef struct
643 {
644 UBYTE ch_type;
645 UBYTE sapi;
646 ULONG fn;
647 } T_DL_SIG_DATA_IND;
648
649 typedef struct
650 {
651 UBYTE sapi;
652 } T_DL_SIG_DATA_CNF;
653
654 #if 0 /* happens in primitive context only */
655 typedef struct
656 {
657 UBYTE error_flag;
658 UBYTE layer1head[2];
659 UBYTE layer3msg[DL_N201_SACCH_A_B];
660 UBYTE length;
661 ULONG fn;
662 } T_DL_SIG_UNITDATA_IND;
663 #endif /* 0 */
664
665 typedef struct
666 {
667 UBYTE ch_type;
668 UBYTE error_flag;
669 UBYTE layer1head[2];
670 UBYTE layer3msg[DL_N201_DCCH_Bter];
671 UBYTE length;
672 ULONG fn;
673 } T_DL_SIG_SHORT_UNITDATA_IND;
674
675 typedef struct
676 {
677 UBYTE ch_type;
678 UBYTE sapi;
679 UBYTE cs;
680 BOOL init;
681 } T_DL_SIG_RELEASE_IND;
682
683 typedef struct
684 {
685 UBYTE ch_type;
686 UBYTE sapi;
687 BOOL init;
688 } T_DL_SIG_RELEASE_CNF;
689
690 typedef struct
691 {
692 UBYTE ch_type;
693 UBYTE sapi;
694 } T_DL_SIG_ERROR_IND;
695
696 typedef struct
697 {
698 void *pointer;
699 } T_DL_SIG_FREE_POINTER;
700
701 typedef struct
702 {
703 T_DL_DATA_IND ** in_msg;
704 UBYTE new_data_in[MAX_L2_FRAME_SIZE];
705 } T_DL_SIG_CONCATENATE;
706
707 typedef struct
708 {
709 UBYTE trace_type;
710 UBYTE channel;
711 UBYTE ch_type;
712 UBYTE data_len;
713 T_TIME trace_time;
714 UBYTE data[MAX_L2_FRAME_SIZE];
715 } T_DL_SIG_L2TRACE;
716
717 typedef struct
718 {
719 UBYTE type;
720 UBYTE ch_type;
721 UBYTE *frame;
722 } T_DL_SIG_L3TRACE;
723
724 typedef struct
725 {
726 UBYTE data[7 /*EM_DL_BUFFER_SIZE*/];
727 UBYTE length;
728 } T_DL_SIG_EM_WRITE;
729
730
731 typedef union
732 {
733 T_DL_SIG_ESTABLISH_IND establish_ind;
734 T_DL_SIG_ESTABLISH_CNF establish_cnf;
735 T_DL_SIG_DATA_IND data_ind;
736 T_DL_SIG_DATA_CNF data_cnf;
737 #if 0 /* happens in primitive context only */
738 T_DL_SIG_UNITDATA_IND unitdata_ind;
739 #endif /* 0 */
740 T_DL_SIG_SHORT_UNITDATA_IND short_unitdata_ind;
741 T_DL_SIG_RELEASE_IND release_ind;
742 T_DL_SIG_RELEASE_CNF release_cnf;
743 T_DL_SIG_ERROR_IND error_ind;
744 T_DL_SIG_FREE_POINTER free_pointer;
745 T_DL_SIG_CONCATENATE concatenate;
746 T_DL_SIG_L3TRACE l3trace;
747 #if defined(DL_TRACE_ENABLED) && defined(DL_IMMEDIATE_TRACE)
748 T_DL_SIG_L2TRACE l2trace;
749 #endif /* DL_TRACE_ENABLED && DL_IMMEDIATE_TRACE */
750 #if defined(FF_EM_MODE)
751 T_DL_SIG_EM_WRITE em_write;
752 #endif /* FF_EM_MODE */
753 } T_DL_SIGNAL_DATA_UNION;
754
755 typedef struct
756 {
757 BOOL busy;
758 #if defined(_SIMULATION_)
759 UBYTE idx;
760 #endif /* _SIMULATION_ */
761 T_DL_SIGNAL_DATA_UNION u;
762 } T_DL_SIGNAL_DATA;
763
764 #if defined(DL_TRACE_ENABLED)
765 #define DL_SIGNAL_DATA_ELEMENTS 9
766 #else /* DL_TRACE_ENABLED */
767 #define DL_SIGNAL_DATA_ELEMENTS 6
768 #endif /* DL_TRACE_ENABLED */
769
770 /*
771 * number of signal data entries must be sufficient for
772 * 1 data indication or confirmation
773 * 1 error indication
774 * 1-2 free commands
775 * 1-2 engineering command
776 * 2-3 traces
777 */
778 typedef struct
779 {
780 int sig_idx;
781 T_DL_SIGNAL_DATA sig_data[DL_SIGNAL_DATA_ELEMENTS];
782 } T_DL_SIGNAL;
783 #endif /* INVOKE_SIGNAL */
784
785 typedef struct
786 {
787 BOOL dl_active;
788 BOOL interrupt_context;
789 UBYTE state[MAX_CHANNELS];
790 T_CCH cch[MAX_CHANNELS];
791 T_FRAME sacch_act_buffer;
792 T_FRAME sacch_last_buffer;
793 T_FRAME rr_short_pd_buffer;
794 UBYTE rr_short_pd_ch_type;
795 UBYTE sacch_mode;
796 T_DL_DATA_IND * dcch0_in_msg;
797 T_DL_DATA_IND * dcch3_in_msg;
798 T_QUEUE dcch0_queue;
799 T_QUEUE dcch3_queue;
800 BOOL dcch0_unserved; /* storing of indication (unserved DL-DATA_REQīs) */
801 BOOL dcch3_unserved; /* for use with DL-ESTABLISHMENT-CNF */
802 T_RADIO_FRAME l2_frame;/* Buffer for l2_frame and empty l2 frame */
803 BOOL RR_dedicated;/* Flag for RR dedictated mode
804 * (necessary for measurement reports) */
805 ULONG fn; /* last received frame number */
806 UBYTE dcch0_ch_type;
807 UBYTE dcch0_disc_request;/* Flags for faster sending of DISC */
808 UBYTE dcch3_disc_request;/* after L3 msg CAHNNEL RELEASE */
809
810 /*
811 * Flag for priority arrangement on the SACCH channel.
812 * DL must ensure that if a SAPI=3 frame is awaiting transmission, two SAPI=3
813 * frames are not sent in consecutive SACCH frames.
814 * Dl must also be ensured that any SAPI=3 frame is followed by at least one
815 * SAPI=0 frame.
816 * This flag controls the priority of SMS messages and measurement reports.
817 */
818 UBYTE sacch_last_uplink_sapi;
819 #if !defined(FF_GTI)
820 #if defined(DELAYED_SABM)
821 UBYTE dcch0_sabm_flag;
822 UBYTE dcch0_sabm_delay;
823 #endif /* DELAYED_SABM */
824 #if defined(DELAYED_RELEASE_IND)
825 UBYTE release_ind_ch_type;
826 UBYTE release_ind_sapi;
827 UBYTE release_ind_delay;
828 #endif /* DELAYED_RELEASE_IND */
829 #endif /* !FF_GTI */
830 #if defined(INVOKE_SIGNAL)
831 T_DL_SIGNAL signal_struct;
832 #endif /* INVOKE_SIGNAL */
833
834 } T_DL_DATA_STORE;
835
836 /*
837 * Predefined mesaurement reports
838 *
839 * If all entities are linked into one module this definitions
840 * prefixes all this functions with the enity name
841 */
842 #ifdef OPTION_MULTITHREAD
843 #define meas_report_no_nc _ENTITY_PREFIXED(meas_report_no_nc)
844 #endif
845 EXTERN const T_FRAME meas_report_no_nc;
846
847 /*==== EXPORT =====================================================*/
848 #if defined(WIN32)
849 #include <stdio.h>
850 #endif /* WIN32 */
851
852 /*
853 * Prototypes Distribute RR
854 */
855 EXTERN void drr_dl_establish_req (T_DL_ESTABLISH_REQ * est_req);
856 EXTERN void drr_dl_establish_ind (UBYTE ch_type,
857 UBYTE sapi,
858 UBYTE indication);
859 EXTERN void drr_dl_resume_req (T_DL_RESUME_REQ * resume_req);
860 EXTERN void drr_dl_reconnect_req (T_DL_RECONNECT_REQ * reconnect_req);
861 EXTERN void drr_dl_release_req (T_DL_RELEASE_REQ * release_req);
862 #ifndef DL_2TO1
863 EXTERN void drr_mdl_release_req (T_MDL_RELEASE_REQ * release_req);
864 #endif /* DL_2TO1 */
865 EXTERN void drr_dl_suspend_req (T_DL_SUSPEND_REQ * suspend_req);
866 EXTERN void drr_dl_data_req (T_DL_DATA_REQ * data_req);
867 EXTERN void drr_dl_data_ind (UBYTE sapi,
868 ULONG fn);
869 EXTERN void drr_dl_data_cnf (UBYTE sapi);
870 EXTERN void drr_dl_unitdata_req (T_DL_UNITDATA_REQ * unitdata_req);
871 EXTERN void drr_dl_unitdata_ind (UBYTE error_flag,
872 UBYTE * layer1head,
873 UBYTE * layer3msg,
874 UBYTE length,
875 ULONG fn);
876 EXTERN void drr_dl_short_unitdata_req (T_DL_SHORT_UNITDATA_REQ * short_unitdata_req);
877 EXTERN void drr_dl_short_unitdata_ind (UBYTE ch_type,
878 UBYTE error_flag,
879 UBYTE * layer1head,
880 UBYTE * layer3msg,
881 UBYTE length,
882 ULONG fn);
883 EXTERN void drr_dl_establish_cnf (UBYTE ch_type,
884 UBYTE sapi);
885 EXTERN void drr_dl_release_ind (UBYTE ch_type,
886 UBYTE sapi,
887 UBYTE cs,
888 BOOL init);
889 EXTERN void drr_dl_release_cnf (UBYTE ch_type,
890 UBYTE sapi,
891 BOOL init);
892 EXTERN void drr_error_ind (UBYTE ch_type,
893 UBYTE sapi);
894
895 /*
896 * Prototypes Slow Associated Control Channel
897 */
898 EXTERN void sacch0_init_dl_data (void);
899 EXTERN void sacch0_reset_meas (void);
900 EXTERN void sacch0_send_data (void);
901 /*
902 * Prototypes Slow Dedicated Control Channel (SAPI 0)
903 */
904 EXTERN void dcch0_init_dl_data (void);
905 EXTERN void dcch0_delay_sabm (T_CCH * pcch);
906 EXTERN void dcch0_establish_req (T_DL_ESTABLISH_REQ * est_req);
907 EXTERN void dcch0_resume_req (T_DL_RESUME_REQ * resume_req);
908 EXTERN void dcch0_reconnect_req (T_DL_RECONNECT_REQ * reconnect_req);
909 EXTERN BOOL dcch0_release_req (T_DL_RELEASE_REQ * dl_release_req);
910 EXTERN void dcch0_mdl_release_req (void);
911 EXTERN void dcch0_suspend_req (T_DL_SUSPEND_REQ * suspend_req);
912 EXTERN void dcch0_data_req (T_DL_DATA_REQ * data_req);
913 EXTERN int dcch0_check_disc (int send);
914
915 /*
916 * Prototypes Slow Dedicated Control Channel (SAPI 3)
917 */
918 EXTERN void dcch3_init_dl_data (void);
919 EXTERN void dcch3_enable (UBYTE ch_type);
920 EXTERN void dcch3_establish_req (T_DL_ESTABLISH_REQ * est_req);
921 EXTERN BOOL dcch3_release_req (T_DL_RELEASE_REQ * dl_release_req);
922 EXTERN void dcch3_mdl_release_req (void);
923 EXTERN void dcch3_data_req (T_DL_DATA_REQ * data_req);
924 EXTERN int dcch3_check_disc (int send);
925
926 #if defined(INVOKE_SIGNAL)
927 EXTERN void sig_init_signal_data (void);
928 EXTERN void sig_invoke_drr_dl_establish_ind (UBYTE ch_type,
929 UBYTE sapi,
930 UBYTE indication);
931 EXTERN void sig_invoke_drr_dl_data_cnf (UBYTE sapi);
932 #if 0 /* happens in primitive context only */
933 EXTERN void sig_invoke_drr_dl_unitdata_ind (UBYTE error_flag,
934 UBYTE * layer1head,
935 UBYTE * layer3msg,
936 UBYTE length,
937 ULONG fn);
938 #endif /* 0 */
939 EXTERN void sig_invoke_drr_dl_short_unitdata_ind (UBYTE ch_type,
940 UBYTE error_flag,
941 UBYTE * layer1head,
942 UBYTE * layer3msg,
943 UBYTE length,
944 ULONG fn);
945 EXTERN void sig_invoke_drr_dl_establish_cnf (UBYTE ch_type,
946 UBYTE sapi);
947 EXTERN void sig_invoke_drr_dl_release_ind (UBYTE ch_type,
948 UBYTE sapi,
949 UBYTE cs,
950 BOOL init);
951 EXTERN void sig_invoke_drr_dl_release_cnf (UBYTE ch_type,
952 UBYTE sapi,
953 BOOL init);
954 EXTERN void sig_invoke_drr_error_ind (UBYTE ch_type,
955 UBYTE sapi);
956 EXTERN void sig_invoke_com_free_pointer (void * pointer);
957 EXTERN void sig_invoke_com_concatenate (T_DL_DATA_IND ** in_msg,
958 UBYTE * new_data_in);
959 EXTERN void sig_invoke_com_data_ind (UBYTE ch_type,
960 UBYTE sapi,
961 ULONG fn);
962 EXTERN void sig_invoke_com_l3trace (UBYTE type,
963 UBYTE ch_type,
964 UBYTE * frame);
965 #if defined(DL_TRACE_ENABLED) && defined(DL_IMMEDIATE_TRACE)
966 EXTERN void sig_invoke_com_l2trace (UBYTE trace_type,
967 UBYTE channel,
968 UBYTE ch_type,
969 T_TIME trace_time,
970 UBYTE * data);
971 #endif /* DL_TRACE_ENABLED && DL_IMMEDIATE_TRACE */
972 #if defined(FF_EM_MODE)
973 EXTERN void sig_invoke_dl_em_write (UBYTE length,
974 UBYTE * data);
975 EXTERN void sig_invoke_dl_em_first_event_check (void);
976 #endif /* FF_EM_MODE */
977
978 EXTERN void sig_handle_drr_dl_establish_ind (T_DL_SIGNAL_DATA * signal);
979 EXTERN void sig_handle_drr_dl_data_cnf (T_DL_SIGNAL_DATA * signal);
980
981 EXTERN void sig_handle_drr_dl_short_unitdata_ind (T_DL_SIGNAL_DATA * signal);
982 EXTERN void sig_handle_drr_dl_establish_cnf (T_DL_SIGNAL_DATA * signal);
983 EXTERN void sig_handle_drr_dl_release_ind (T_DL_SIGNAL_DATA * signal);
984 EXTERN void sig_handle_drr_dl_release_cnf (T_DL_SIGNAL_DATA * signal);
985 EXTERN void sig_handle_drr_error_ind (T_DL_SIGNAL_DATA * signal);
986 EXTERN void sig_handle_com_free_pointer (T_DL_SIGNAL_DATA * signal);
987 EXTERN void sig_handle_com_concatenate (T_DL_SIGNAL_DATA * signal);
988 EXTERN void sig_handle_com_free_pointer (T_DL_SIGNAL_DATA * signal);
989 EXTERN void sig_handle_com_data_ind (T_DL_SIGNAL_DATA * signal);
990 EXTERN void sig_handle_com_l3trace (T_DL_SIGNAL_DATA * signal);
991 #if defined(DL_TRACE_ENABLED) && defined(DL_IMMEDIATE_TRACE)
992 EXTERN void sig_handle_com_l2trace (T_DL_SIGNAL_DATA * signal);
993 #endif /* DL_TRACE_ENABLED && DL_IMMEDIATE_TRACE */
994 #if defined(FF_EM_MODE)
995 EXTERN UBYTE em_dl_write (UBYTE length,
996 UBYTE * data);
997 EXTERN void sig_handle_dl_em_write (T_DL_DATA_STORE * dl_data,
998 T_DL_SIGNAL_DATA * signal);
999 EXTERN void dl_em_first_event_check(void);/*for ACI notification of first EM event*/
1000 EXTERN void sig_handle_dl_em_first_event_check (void);
1001 #endif /* FF_EM_MODE */
1002 #endif /* INVOKE_SIGNAL */
1003
1004 /*
1005 * Prototypes Distribute PL
1006 */
1007
1008 #ifdef _SIMULATION_
1009 #ifdef DL_2TO1
1010 EXTERN void l1test_call_mphc_read_dcch (T_L1TEST_CALL_MPHC_READ_DCCH * ready);
1011 EXTERN void l1test_return_mphc_read_dcch (T_RADIO_FRAME * frame);
1012 EXTERN void l1test_call_mphc_read_sacch (T_L1TEST_CALL_MPHC_READ_SACCH * ready);
1013 EXTERN void l1test_return_mphc_read_sacch (T_RADIO_FRAME* frame);
1014 EXTERN void l1test_call_mphc_dcch_downlink (T_L1TEST_CALL_MPHC_DCCH_DOWNLINK * data_ind);
1015 EXTERN void l1test_return_mphc_dcch_downlink (T_L1TEST_RETURN_MPHC_DCCH_DOWNLINK * resp);
1016 #else /* DL_2TO1 */
1017 EXTERN void dph_ph_ready_to_send (T_PH_READY_TO_SEND * ready);
1018 #endif /* DL_2TO1 */
1019 #endif /* _SIMULATION_ */
1020
1021 /* SACCH Uplink Interface according to L1M_GS011-1 v.1.22, section 23. */
1022 EXTERN T_RADIO_FRAME *dll_read_sacch (U8 chn_mode);
1023
1024 /* SACCH Downlink Interface according to L1M_GS011-1 v.1.22, section 24. */
1025 /* SACCH (SDCCH/FACCH only simulation) Downlink Test Interface */
1026 EXTERN void dph_ph_data_ind (T_PH_DATA_IND * data_ind);
1027
1028 #if defined(DL_2TO1) || defined(USE_L1M_GS001_1)
1029 /* DCCH Uplink Interface according to L1M_GS001-1, section 25. */
1030 EXTERN T_RADIO_FRAME * dll_read_dcch (U8 chn_mode, U8 channel_type);
1031
1032 /* DCCH Downlink Interface according to L1M_GS001-1, section 26. */
1033 EXTERN void dll_dcch_downlink (U32 * data_ptr, U8 valid_flag, U8 channel_type, U32 fn);
1034
1035 #else /* DL_2TO1 || USE_L1M_GS001_1 */
1036 /* DCCH Uplink Interface according to L1M_GS001-1 v.1.22, section 25. */
1037 EXTERN T_RADIO_FRAME * dll_read_dcch (U8 chn_mode);
1038
1039 /* DCCH Downlink Interface according to L1M_GS001-1 v.1.22, section 26. */
1040 #if defined(SEND_FN_TO_L2_IN_DCCH) && (SEND_FN_TO_L2_IN_DCCH == 1)
1041 EXTERN void dll_dcch_downlink (U32 * data_ptr, U8 valid_flag, U32 fn);
1042 #else /* SEND_FN_TO_L2_IN_DCCH == 1 */
1043 EXTERN void dll_dcch_downlink (U32 * data_ptr, U8 valid_flag);
1044 #endif /* SEND_FN_TO_L2_IN_DCCH == 1 */
1045 #endif /* DL_2TO1 || USE_L1M_GS001_1 */
1046
1047 /* SACCH/SDCCH/FACCH Uplink Interface */
1048 EXTERN T_RADIO_FRAME *dl1_uplink_ind (UBYTE channel_type,
1049 UBYTE no_signalling_flag);
1050
1051 /*
1052 * Prototypes Downlink and Uplink Functions (DL_STATE.c)
1053 */
1054 EXTERN int dl_downlink (UBYTE error_flag,
1055 UBYTE channel_type,
1056 UBYTE * frame,
1057 ULONG fn);
1058 EXTERN void set_channel_state (UBYTE channel,
1059 UBYTE state);
1060 EXTERN T_RADIO_FRAME* dl_uplink (UBYTE channel,
1061 UBYTE sapi,
1062 UBYTE no_signalling_mode,
1063 BOOL recursiv);
1064
1065 EXTERN int uplink_awaiting_release (UBYTE channel,
1066 UBYTE sapi);
1067 /*
1068 * Prototypes Common Functions
1069 */
1070 EXTERN void com_free_pointer (void * pointer);
1071 EXTERN void com_free_queue_buffer (T_QUEUE * queue,
1072 USHORT index);
1073 EXTERN void com_clear_queue (UBYTE sapi);
1074 EXTERN void com_restore_queue (UBYTE sapi,
1075 T_DL_DATA_REQ * est_req);
1076 EXTERN void com_recover_queue (UBYTE sapi);
1077 EXTERN void com_store_queue (UBYTE sapi,
1078 T_DL_DATA_REQ * data_req);
1079 EXTERN void com_read_queue (UBYTE ch_type,
1080 UBYTE sapi,
1081 UBYTE * m_bit);
1082 EXTERN BOOL com_queue_awaiting_transmission (UBYTE sapi);
1083 EXTERN void com_leave_dedicated (UBYTE ch_type);
1084 EXTERN void possible_reset_dcch0_ch_type (void);
1085 EXTERN void com_concatenate (T_DL_DATA_IND ** in_msg,
1086 UBYTE * new_data_in);
1087 EXTERN UBYTE com_check_nr (UBYTE va,
1088 UBYTE vs,
1089 UBYTE nr);
1090 EXTERN void com_prepare_DISC (UBYTE channel,
1091 UBYTE sapi);
1092 EXTERN void com_build_UA_response (UBYTE ch_type,
1093 UBYTE sapi,
1094 UBYTE f_bit);
1095 EXTERN void com_build_RR_response (UBYTE ch_type,
1096 UBYTE sapi,
1097 UBYTE nr,
1098 UBYTE f_bit);
1099 EXTERN void com_build_REJ_response (UBYTE ch_type,
1100 UBYTE sapi,
1101 UBYTE nr,
1102 UBYTE f_bit);
1103 EXTERN void com_build_DISC_command (UBYTE ch_type,
1104 UBYTE sapi,
1105 UBYTE p_bit);
1106 EXTERN void com_build_SABM (UBYTE ch_type,
1107 UBYTE sapi,
1108 BOOL contention_resultion);
1109 EXTERN void com_build_DM_response (UBYTE ch_type,
1110 UBYTE sapi,
1111 UBYTE f_bit);
1112 EXTERN void com_build_I_command (UBYTE ch_type,
1113 UBYTE sapi,
1114 UBYTE ns,
1115 UBYTE nr,
1116 UBYTE p_bit,
1117 UBYTE m_bit,
1118 T_QUEUE * queue);
1119 EXTERN void com_build_UI_command (UBYTE ch_type,
1120 UBYTE sapi,
1121 const T_FRAME * buffer);
1122 EXTERN void com_build_UI_Bter (UBYTE ch_type);
1123 EXTERN UBYTE com_compare_L3_msg (T_DL_DATA_REQ * data_ind1,
1124 UBYTE * data_ind2);
1125 GLOBAL void com_data_ind (UBYTE ch_type,
1126 UBYTE sapi,
1127 ULONG fn);
1128 EXTERN void com_l2trace (UBYTE trace_type,
1129 UBYTE channel,
1130 UBYTE ch_type,
1131 T_TIME event_time,
1132 UBYTE * data);
1133 EXTERN void com_l3trace (UBYTE type,
1134 UBYTE ch_type,
1135 UBYTE * frame);
1136 EXTERN void com_print_l3trace (UBYTE type,
1137 UBYTE ch_type,
1138 UBYTE sapi,
1139 UBYTE * l3msg);
1140 EXTERN void com_init_data (void);
1141
1142
1143 EXTERN CHAR* dl_version (void);
1144 EXTERN T_DL_DATA_STORE *dl_get_data (void);
1145
1146 #if defined (DL_TRACE_ENABLED)
1147 EXTERN void dl_trace (UCHAR trace_type,
1148 UCHAR channel,
1149 UCHAR ch_type,
1150 UCHAR * data);
1151 #if defined(DL_IMMEDIATE_TRACE)
1152
1153 EXTERN void dl_fast_trace (UBYTE trace_type,
1154 UBYTE channel,
1155 UBYTE ch_type,
1156 T_TIME trace_time,
1157 ULONG trace_mask,
1158 UBYTE * data);
1159 #else /* DL_IMMEDIATE_TRACE */
1160 EXTERN void dl_trace_init (void);
1161 EXTERN void dl_trace_exit (void);
1162 EXTERN void dl_trace_read (void);
1163 EXTERN void dl_trace_read_all (void);
1164 EXTERN void dl_trace_clear (void);
1165 #endif /* DL_IMMEDIATE_TRACE */
1166 #endif /* DL_TRACE_ENABLED */
1167
1168 /*
1169 * Prototypes Customer Specific Functions
1170 */
1171
1172
1173 EXTERN USHORT dl_handle;
1174
1175 #define ENTITY_DATA dl_data
1176
1177
1178 #if defined (DL_PEI_C)
1179 GLOBAL T_DL_DATA_STORE dl_data_base;
1180 #else
1181 EXTERN T_DL_DATA_STORE dl_data_base;
1182 #endif /* DL_PEI_C */
1183
1184 #define GET_INSTANCE_DATA register T_DL_DATA_STORE *dl_data= &dl_data_base
1185
1186
1187
1188 /*
1189 * If all entities are linked into one module this definitions
1190 * prefixes the global data with the enity name
1191 */
1192 #ifdef TI_PS_HCOMM_CHANGE
1193 #define hCommDL _hCommDL
1194 #else /* for hCommHandles backward compatibility */
1195 #ifdef OPTION_MULTITHREAD
1196 #define hCommDL _ENTITY_PREFIXED(hCommDL)
1197 #define hCommRR _ENTITY_PREFIXED(hCommRR)
1198 #define hCommPL _ENTITY_PREFIXED(hCommPL)
1199 #endif
1200
1201 EXTERN T_HANDLE hCommDL; /* Self Communication */
1202 EXTERN T_HANDLE hCommRR; /* RR Communication */
1203 EXTERN T_HANDLE hCommPL; /* PL Communication */
1204 #endif
1205
1206 #define SYST_TRACE(a) vsi_o_ttrace(0, 0xFFFF,a)
1207 #define SYST 0, 0xffff
1208 #ifdef TI_PS_HCOMM_CHANGE
1209 #define DLTRC _hCommDL, 0x0200
1210 #else /* for hCommHandles backward compatibility */
1211 #define DLTRC hCommDL, 0x0200
1212 #endif
1213 #define SYST_TRACE_P(a) vsi_o_ttrace a
1214
1215
1216 #if defined(DL_TRACE_ENABLED)
1217 #if defined(DL_IMMEDIATE_TRACE)
1218 #define DL_OFFLINE_TRACE(type, ch, ch_type, data) \
1219 com_l2trace (type, (U8) (ch),(U8)(ch_type), 0, (UBYTE *)(data))
1220 #else /* DL_IMMEDIATE_TRACE */
1221 #define DL_OFFLINE_TRACE(type, ch, ch_type, data) \
1222 dl_trace ((UCHAR)(type), (UCHAR)(ch), (UCHAR)(ch_type), (UCHAR *)(data))
1223 #endif /* DL_IMMEDIATE_TRACE */
1224 #else
1225 #define DL_OFFLINE_TRACE(type, ch, ch_type, data) /* do nothing */
1226 #endif /* DL_TRACE_ENABLED */
1227
1228 #if !defined(_FILE10_)
1229 #define __FILE10__ (__FILE__+strlen(__FILE__)-11)
1230 #endif /* !_FILE10_ */
1231
1232 #if defined(DL_TRACE_ENABLED) || defined(FF_EM_MODE)
1233 EXTERN void com_semaphore_err (void);
1234 GLOBAL int com_enter_critical_section (T_HANDLE sem);
1235 GLOBAL int com_leave_critical_section (T_HANDLE sem);
1236 #define ENTER_CRITICAL_SECTION(sem) if (com_enter_critical_section(sem))return
1237 #define LEAVE_CRITICAL_SECTION(sem) if (com_leave_critical_section(sem))return
1238 #if !defined(DL_IMMEDIATE_TRACE)
1239 GLOBAL int com_semaphore_state (T_HANDLE sem);
1240 #define TEST_SEMAPHORE(sem) if (com_semaphore_state(sem)) return
1241 #endif /* !DL_IMMEDIATE_TRACE */
1242 #endif /* DL_TRACE_ENABLED || FF_EM_MODE */
1243
1244
1245 #if defined (DL_TRACE_ENABLED) && defined(DL_TRACE_PFREE)
1246 #define MY_PFREE(p) p = my_pfree (p, __LINE__, __FILE10__)
1247 void* my_pfree(void *pointer, int line, char *file);
1248 #else
1249 #define MY_PFREE(p) PFREE(p)
1250 #endif /* DL_TRACE_ENABLED */
1251
1252
1253 #if defined(_SIMULATION_)
1254 #define COM_FREE_QUEUE_BUFFER(q,i) \
1255 {TRACE_EVENT_WIN_P4 ("FREE_QUEUE_BUFFER:q=%p i=%u (%s#%u)",q,i,__FILE10__, __LINE__);\
1256 com_free_queue_buffer(q, i);}
1257 #define COM_FREE_POINTER(p) \
1258 {TRACE_EVENT_WIN_P4 ("call com_free_pointer(,%s=%08x) (%s#%u)", #p, p, __FILE10__, __LINE__);\
1259 com_free_pointer ( p);}
1260 #else /* _SIMULATION_ */
1261 #define COM_FREE_QUEUE_BUFFER(q,i) com_free_queue_buffer(q,i)
1262 #define COM_FREE_POINTER(p) com_free_pointer ( p)
1263 #endif /* _SIMULATION_ */
1264
1265
1266 #if 0
1267 #define ARRAY_TRACE
1268 #if defined(ARRAY_TRACE)
1269 EXTERN void rr_array_trace (UBYTE*array, int size, char *titel);
1270 #define TRACE_ARRAY(array, size, titel) rr_array_trace(array, size, titel)
1271 #else /* ARRAY_TRACE */
1272 #define TRACE_ARRAY(array, size, titel)
1273 #endif /* ARRAY_TRACE */
1274 #endif /* 0 */
1275
1276 #endif /* !__DL_H__ */
1277
1278