comparison src/g23m-gsm/alr2/alr.h @ 3:b4c81ea2d291

src/g23m-gsm/alr2: initial import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 15 Jul 2018 04:43:28 +0000
parents
children 935692f51b38
comparison
equal deleted inserted replaced
2:e636eadcad21 3:b4c81ea2d291
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS
4 | Modul : ALR
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 ALR
18 +-----------------------------------------------------------------------------
19 */
20
21 #ifndef ALR_H
22 #define ALR_H
23
24 #define STOP_SYNC_TASK /* stop always any sync tasks before start a new one */
25 #if 0
26 #define DL_TRACE_ENABLED /* use DL offline trace */
27 #define TRACE_STATE_TRANSITION /* trace some state transitions */
28 #endif /* 0 */
29
30 #if !defined(_SIMULATION_) && defined(WIN32)
31 #define _SIMULATION_
32 #endif /* !_SIMULATION_ && WIN32 */
33
34 #if defined(_SIMULATION_)
35 #undef DL_TRACE_ENABLED /* no _SYST trace during simulation */
36 #endif /* WIN32 */
37
38 #define SYST_TRACE(a) vsi_o_ttrace(0, 0xFFFF,a)
39 #define SYST 0, 0xffff
40 #define SYST_TRACE_P(a) vsi_o_ttrace a
41 /*
42 * use it as showed next line...
43 * SYST_TRACE_P((SYST, "e.g. two parameter: %d %d", p1, p2));
44 */
45
46
47 #if !defined(ELEMENTS)
48 #define ELEMENTS(array) (sizeof(array)/sizeof(array[0]))
49 #endif /* !ELEMENTS */
50
51 /*
52 * for voice memo
53 */
54 #include "p_cst.h"
55
56 /* Bitoffset for Message Buffer allocation */
57 #define ENCODE_OFFSET 24
58
59 /*
60 * Bitmasks
61 */
62 #define BIT_0 0x01
63 #define BIT_1 0x02
64 #define BIT_2 0x04
65 #define BIT_3 0x08
66 #define BIT_4 0x10
67 #define BIT_5 0x20
68 #define BIT_6 0x40
69 #define BIT_7 0x80
70 #define BIT_012 0x07
71
72 #include "p_ph.h"
73 #include "p_mph.h"
74
75 /* First 40 carriers per band will be added at top of the MPH_POWER_CNF
76 * and the next 20 Carriers (40 to 60) will be added at the bottom.
77 * Remaining carriers needs to be ignored.
78 */
79
80 #define ADD_AT_THE_TOP 0x01 /* first 40 carrier */
81 #define ADD_AT_THE_BOTTOM 0x02 /* already 40 carriers were added */
82 #define REACHED_THE_MAXIMUM 0x04 /* already 60 carriers were added */
83 #define DO_NOT_ADD 0x08 /* wrong carrier */
84
85
86 /* Private modes */
87 #define MODE_CHAN_ASS_FAIL 16
88 #define MODE_HANDOVER_FAIL 17
89
90 /* Results of configuration dedicated mode */
91 #define DEDICATED_SUCCESS 0
92
93 #define ALR_ALLOCATE_NEW_BA(v) ((((v)+1) % (ALR_BA_HIGH-ALR_BA_LOW+1)) + ALR_BA_LOW)
94 #define IS_EXT_MEAS_RUNNING (alr_data->cs_data.mph_ext_meas_req NEQ NULL)
95
96 /*
97 * Dynamic Configurations
98 */
99 #define ID_STD 1
100 #define ID_CONFIG 2
101 #define ID_MON_COUNTER_IDLE 3
102 #define ID_MON_COUNTER_DEDI 4
103 #define ID_TRC_DATA_IND 5
104 #define ID_RACH_FAILURE 6
105 #define ID_EOTD 7
106
107 #define ID_TRC_DATA_IND_ALL 0xff
108 #define ID_TRC_DATA_IND_VALID 0x7f
109 #define ID_TRC_DATA_IND_INVALID 0x80
110 #define ID_TRC_DATA_IND_BCCH 0x01 /* normal and extended BCCH */
111 #define ID_TRC_DATA_IND_PCH 0x02 /* normal and extended PCH */
112 #define ID_TRC_DATA_IND_CCCH 0x04
113 #define ID_TRC_DATA_IND_CBCH 0x08
114 #define ID_TRC_DATA_IND_SCCH 0x10 /* SACCH and SDCCH */
115 #define ID_TRC_DATA_IND_FCCH 0x20 /* full and half rate FACCH */
116 #define ID_TRC_DATA_IND_STATE 0x40 /* MA status */
117 #define ID_TRC_DATA_IND_INIT 0x3f /* all valid frames without stati */
118 #define ID_TRC_DATA_IND_INIT2 0x1f /* ... without FACCH */
119
120 EXTERN UBYTE v_mon_trc_data_ind;
121 EXTERN UBYTE v_cfg_rach_failure;
122
123 /* In addition to normal page modes defined in SAP */
124 #define PGM_REORG_CS 3
125 #define NO_PGM_CHANGE 4
126 #define SAVED_PGM 0xff
127
128 /*If page mode is set to REORG and a HPLMN search is performed, L1 cannot
129 synchronize to NC's. Therefore NORMAL page mode is started. This state
130 defines that the mobile should be in REORG, but actual is in NORMAL.*/
131 #define PGM_REORG_NC_SYNC 5
132 EXTERN UBYTE page_mode_before_hplmn_search;/*to distinguish PGM_REORG and PGM_REORG_CS */
133
134 /* Page Mode Changes */
135 #define NONE 0
136 #define SWAP_TO_EXTEND 1
137 #define SWAP_TO_REORG 2
138 #define SWAP_TO_NORMAL 3
139
140 #define MAX_GSM_CHANNEL_ATTEMPTS 40 /* GSM says 30, but this is done in the field */
141 #define MAX_DPCS_CHANNEL_ATTEMPTS 40
142
143 /* Band Limitations for multiband reporting */
144 #define NO_BAND_LIMITATION 0
145 #define EXCLUDE_SC_BAND 1
146 #define ONLY_SC_BAND 2
147
148 #define IMSI_LEN 9
149 #define SI_CONTENTS_MSG_T 2
150 #define SI_CONTENTS_CS2 9
151 #define ONLY_ACS 0x80
152 #define STOP_PCH_READING 1
153 #define DONT_STOP_PCH_READING 0
154 #define STOP_MEASUREMENTS 2
155
156 /*
157 * Neighbour cell status
158 */
159 /* #define DEFINE_OLD_NC_STATUS */
160 #if !defined(DEFINE_OLD_NC_STATUS)
161 /* neighbour cell base stati */
162 #define NCS_INACTIVE 0x00
163 #define NCS_IDLE 0x01
164 #define NCS_FB_SB 0x02
165 #define NCS_SB 0x03
166 /* neighbour cell bit masks */
167 #define NCB_BCCH 0x04
168 #define NCB_READ 0x08
169 #define NCB_PENDING 0x10
170 #define NCB_SYNC 0x20
171 #define NCB_RR_NOT_INFORMED 0x40
172 #define NCB_FAILED 0x80
173
174 /* neighbour cell stati */
175 /* 1of<n> n = 6,12 means that the cell belongs to the n strongest */
176 /* RLA_C means Received Level Averages according GSM 05.08 seciton 6.1 */
177
178 /* (1) no PERIODIC measurement received; cell is excluded from all activities except rxlev measurement */
179 #define INACTIVE (NCS_INACTIVE)
180
181 /* (2) PERIODIC measurement received; not synchronized; BCCH data unknown */
182 #define IDLE (NCS_IDLE)
183
184 /* (11a) not a 1of12 cell any more; synchronized */
185 #define IDLE_SYNC (NCS_IDLE|NCB_SYNC)
186
187 /* (3) strong cell(1of12); not synchronized yet; need first FB and SB synchronization */
188 #define READ_FB_SB (NCS_FB_SB|NCB_READ)
189
190 /* (4) first FB and SB synchronization ongoing */
191 #define READ_FB_SB_PENDING (NCS_FB_SB|NCB_READ|NCB_PENDING)
192
193 /* (9) synchronized; need re-synchronization of SB (10/30 sec); no need to read BCCH */
194 #define READ_SB (NCS_SB|NCB_READ)
195
196 /* (10) re-synchronization of SB ongoing (10/30 sec); no reading of BCCH */
197 #define READ_SB_PENDING (NCS_SB|NCB_READ|NCB_PENDING)
198
199 /* (9a) synchronized; need re-synchronization of SB and re-reading of BCCH (5 min) */
200 #define READ_SB_BCCH (NCS_SB|NCB_READ|NCB_BCCH)
201
202 /* (10a) re-synchronization of SB ongoing (5 min) */
203 #define READ_SB_BCCH_PENDING (NCS_SB|NCB_READ|NCB_BCCH|NCB_PENDING)
204
205 /* (11a) re-synchronization of SB finished; need re-reading of BCCH (5 min) */
206 #define READ_BCCH (NCS_SB|NCB_READ|NCB_BCCH|NCB_SYNC)
207
208 /* (12a) re-reading of BCCH ongoing (5 min) */
209 #define READ_BCCH_PENDING (NCS_SB|NCB_READ|NCB_BCCH|NCB_SYNC|NCB_PENDING)
210
211 /* (5) 1of6 cell; synchronized; BCCH data unknown; need to read BCCH, but to notify RR after a measurement ind only */
212 #define READ_BCCH_RR_NOT_INFORMED (NCS_SB|NCB_READ|NCB_BCCH|NCB_SYNC|NCB_RR_NOT_INFORMED)
213
214 /* (6) 1of6 cell; reading of BCCH ongoing */
215 #define READ_BCCH_PENDING_RR_NOT_INFORMED (NCS_SB|NCB_READ|NCB_BCCH|NCB_SYNC|NCB_RR_NOT_INFORMED|NCB_PENDING)
216
217 /* (8) 1of12 cell; synchronized; in case 1of6: BCCH data known; RR is notified; subsequent RLA_Cs being computed */
218 #define FB_SB_SYNC (NCS_FB_SB|NCB_SYNC)
219
220 /* (7) 1of6 cell; synchronized; BCCH data known; RR not yet notified; first RLA_C being computed */
221 #define FB_SB_SYNC_RR_NOT_INFORMED (NCS_FB_SB|NCB_SYNC|NCB_RR_NOT_INFORMED)
222
223 /* (13) 1of<n> cell state questionable; FB/SB sync or BCCH reading failed 1 thru 8 times */
224 #define FB_SB_FAILED (NCS_FB_SB|NCB_FAILED)
225
226 /* (14) 1of<n> cell; synchronization of FB/SB or reading of BCCH failed > 8 times; NCC check failed; */
227 #define EXCLUDED (NCB_FAILED)
228
229 #else /* !DEFINE_OLD_NC_STATUS */
230 #define INACTIVE 0
231 #define IDLE 1
232 #define READ_BCCH 2
233 #define FB_SB_SYNC 3
234 #define FB_SB_FAILED 4
235 #define READ_FB_SB 5
236 #define READ_SB 6
237 #define IDLE_SYNC 7
238 #define EXCLUDED 8
239 #define FB_SB_SYNC_RR_NOT_INFORMED 9
240 #define READ_SB_BCCH 10
241 #define READ_BCCH_PENDING 11
242 #define READ_FB_SB_PENDING 12
243 #define READ_SB_PENDING 13
244 #define READ_SB_BCCH_PENDING 14
245 #define READ_BCCH_RR_NOT_INFORMED 15
246 #define READ_BCCH_PENDING_RR_NOT_INFORMED 16
247 #endif /* !DEFINE_OLD_NC_STATUS */
248
249 /*
250 * states of a neighbour cell with respect to the BA list
251 * in the last MPH_NEIGHBOURCELL_REQ.
252 */
253 #define IN_BA 0 /* NCell was in last MPH_NEIGHBOURCELL_REQ */
254 #define NOT_IN_BA_SHORT 1 /* NCell wasn't in last MPH_NEIGHBOURCELL_REQ but at last confirmation it had state IN_BA (not in BA for a short time) */
255 #define NOT_IN_BA_LONG 2 /* NCell wasn't in last MPH_NEIGHBOURCELL_REQ and at last confirmation it hadn't state IN_BA (not in BA for a long time) */
256 /*
257 * Definitions for AMR
258 */
259 #define CM_AMR 0x41
260
261 /*
262 * The times are given in number of multiframes. Each multiframe is
263 * equal to circa 217 milliseconds.
264 */
265 #define THIRTY_SECONDS_SCELL_BCCH 128
266
267 /*
268 * States Main Control
269 */
270 #define MA_NULL 0
271 #define MA_CELL_SELECTION 1
272 #define MA_IDLE 2
273 #define MA_CON_EST 3
274 #define MA_DEDICATED 4
275 #define MA_CELL_RESELECTION 5
276
277 #ifdef GPRS
278 #define MA_PTM 6
279 #endif
280
281 EXTERN const char * const
282 STATE_MA_NAME[];
283 #ifndef GPRS
284 #define STATE_MA_NAME_INIT \
285 "MA_NULL" ,\
286 "MA_CELL_SELECTION" ,\
287 "MA_IDLE" ,\
288 "MA_CON_EST" ,\
289 "MA_DEDICATED" ,\
290 "MA_CELL_RESELECTION"
291 #else /* !GPRS */
292 #define STATE_MA_NAME_INIT \
293 "MA_NULL" ,\
294 "MA_CELL_SELECTION" ,\
295 "MA_IDLE" ,\
296 "MA_CON_EST" ,\
297 "MA_DEDICATED" ,\
298 "MA_CELL_RESELECTION",\
299 "MA_PTM"
300 #endif /* !GPRS */
301 /*
302 * States Idle Neighbour Cell
303 */
304 #define NC_NULL 0
305 #define NC_IDLE 1
306 #define NC_DEDICATED 2
307 #define NC_CON_EST 3
308 #ifdef GPRS
309 #define NC_PIM_PBCCH 4
310 #define NC_PTM_PBCCH 5
311
312 EXTERN const char * const
313 STATE_NC_NAME[];
314 #define STATE_NC_NAME_INIT \
315 "NC_NULL" ,\
316 "NC_IDLE" ,\
317 "NC_DEDICATED" ,\
318 "NC_CON_EST" ,\
319 "NC_PIM_PBCCH" ,\
320 "NC_PTM_PBCCH"
321 #else
322 EXTERN const char * const
323 STATE_NC_NAME[];
324 #define STATE_NC_NAME_INIT \
325 "NC_NULL" ,\
326 "NC_IDLE" ,\
327 "NC_DEDICATED" ,\
328 "NC_CON_EST"
329 #endif
330
331 /*
332 * States Dedicated Control
333 */
334 #define DEDI_INACTIVE 0
335 #define DEDI_IMM_ASS 1
336 #define DEDI_IMM_ASS_RECONN 2
337 #define DEDI_ACTIVE 3
338
339 EXTERN const char * const
340 STATE_DEDI_NAME[];
341 #define STATE_DEDI_NAME_INIT \
342 "DEDI_INACTIVE" ,\
343 "DEDI_IMM_ASS" ,\
344 "DEDI_IMM_ASS_RECONN",\
345 "DEDI_ACTIVE"
346
347 /*
348 * States Cell Selection
349 */
350 #define CS_NULL 0
351 #define CS_INIT_L1 1 /* start with configuration of the radio band */
352 #define CS_INIT_ACTIVE 2 /* configuration of the radio band is active */
353 #define CS_INIT_DONE 3 /* configuration has done */
354 #define CS_START_MEASURE 4 /* start measurement with preceding configuration */
355 #define CS_ACTIVE_MEASURE 5 /* power measurement step is active */
356 #define CS_MEASURED 6 /* power measurement step has finished */
357 #define CS_INIT_SYNC 7 /* configuration of the radio band before SYNC */
358 #define CS_STOP_SYNC 8 /* stop any sync task */
359 #define CS_STOP_SYNC_DONE 9 /* no sync task active */
360 #define CS_ACTIVE_SYNC 10
361 #define CS_ACTIVE_BCCH 11
362 #define CS_NW_SYNC_TIMEOUT 12 /* ALR has timed out whilst attempting to sync to a nw */
363
364 EXTERN const char * const
365 STATE_CS_NAME[];
366 #define STATE_CS_NAME_INIT\
367 "CS_NULL" ,\
368 "CS_INIT_L1" ,\
369 "CS_INIT_ACTIVE" ,\
370 "CS_INIT_DONE" ,\
371 "CS_START_MEASURE" ,\
372 "CS_ACTIVE_MEASURE" ,\
373 "CS_MEASURED" ,\
374 "CS_INIT_SYNC" ,\
375 "CS_STOP_SYNC" ,\
376 "CS_STOP_SYNC_DONE" ,\
377 "CS_ACTIVE_SYNC" ,\
378 "CS_ACTIVE_BCCH" ,\
379 "CS_NW_SYNC_TIMEOUT"
380
381 /*
382 * States PCH Control
383 */
384 #define PCH_NULL 0
385 #define PCH_ACTIVE 1
386
387 EXTERN const char * const
388 STATE_PCH_NAME[];
389 #define STATE_PCH_NAME_INIT\
390 "PCH_NULL" ,\
391 "PCH_ACTIVE"
392
393 /*
394 * States RACH Control
395 */
396 #define RA_NULL 0
397 #define RA_ACTIVE 1
398 #define RA_LISTEN_TO_CCCH 2
399
400 EXTERN const char * const
401 STATE_RA_NAME[];
402 #define STATE_RA_NAME_INIT \
403 "RA_NULL" ,\
404 "RA_ACTIVE" ,\
405 "RA_LISTEN_TO_CCCH"
406
407 /*
408 * States CBCH Control
409 */
410 #define CBCH_NULL 0
411 #define CBCH_IDLE 1
412 #define CBCH_NO_DRX 2
413 #define CBCH_DRX 3
414
415 #define CBCH_HZ_OFF 0
416 #define CBCH_HZ_IDLE 5
417 #define CBCH_HZ_PENDING 6
418 #define CBCH_HZ_RECEIVED 7
419
420
421 EXTERN const char * const STATE_NORMAL_CBCH_NAME[];
422 EXTERN const char * const STATE_EXT_CBCH_NAME[];
423
424 #define STATE_CBCH_NAME_INIT\
425 "CBCH_NULL" ,\
426 "CBCH_IDLE" ,\
427 "CBCH_NO_DRX" ,\
428 "CBCH_DRX"
429
430 /*
431 * States Idle Mode Serving Cell
432 */
433 #define SC_NULL 0
434 #define SC_IDLE_INITIAL 1
435 #define SC_IDLE 2
436
437 EXTERN const char * const
438 STATE_SC_NAME[];
439 #define STATE_SC_NAME_INIT \
440 "SC_NULL" ,\
441 "SC_IDLE_INITIAL" ,\
442 "SC_IDLE"
443
444 /*
445 * States Idle Mode Serving Cell
446 */
447
448 typedef enum {
449 NC_ACQUIRE=0,
450 NC_CONFIRM
451 } T_NCELL_PROC;
452
453 EXTERN const char * const
454 STATE_NC_PROC_NAME[];
455 #define STATE_NC_PROC_NAME_INIT \
456 "NC_ACQUIRE" ,\
457 "NC_CONFIRM"
458
459
460 /*
461 * ALR manages 9 (MAX_STATE) states: CBCH,CS,MA,NC,PCH,RA,SC,DEDI,NC_PROC
462 */
463
464 #define STATE_CS 0
465 #define STATE_MA 1
466 #define STATE_NC 2
467 #define STATE_PCH 3
468 #define STATE_RA 4
469 #define STATE_SC 5
470 #define STATE_DEDI 6
471 #define STATE_NC_PROC 7
472 #define STATE_NORMAL_CBCH 8
473 #define STATE_EXT_CBCH 9
474 #define MAX_STATE 10
475
476 /*
477 * A definition is provided in ALR_PEI.C
478 */
479 #ifdef ALR_PEI_C
480 GLOBAL const char * const STATE_NORMAL_CBCH_NAME[] = { STATE_CBCH_NAME_INIT };
481 GLOBAL const char * const STATE_EXT_CBCH_NAME[] = { STATE_CBCH_NAME_INIT };
482 GLOBAL const char * const STATE_CS_NAME [] = { STATE_CS_NAME_INIT };
483 GLOBAL const char * const STATE_MA_NAME [] = { STATE_MA_NAME_INIT };
484 GLOBAL const char * const STATE_NC_NAME [] = { STATE_NC_NAME_INIT };
485 GLOBAL const char * const STATE_PCH_NAME [] = { STATE_PCH_NAME_INIT };
486 GLOBAL const char * const STATE_RA_NAME [] = { STATE_RA_NAME_INIT };
487 GLOBAL const char * const STATE_SC_NAME [] = { STATE_SC_NAME_INIT };
488 GLOBAL const char * const STATE_DEDI_NAME[] = { STATE_DEDI_NAME_INIT };
489 GLOBAL const char * const STATE_NC_PROC_NAME[]={ STATE_NC_PROC_NAME_INIT };
490 #endif /* ALR_PIC_C */
491
492 /*==== MACROS =====================================================*/
493
494 /*
495
496 This macros convert channel numbers from and to the layer 1 specific
497 representation for the target version.
498
499 For the single bands GSM900, DCS1800 and PCS1900 the macro is removed
500 at compile time.
501
502 For dualband (STD==5,STD==6) a DCS1800 channel number is converted
503 using the convert function located at the end of alr_main.c
504
505 In the windows variant no change occurs.
506
507 */
508
509 EXTERN USHORT convert_arfcn_to_l1 (USHORT arfcn, UBYTE local_std);
510 EXTERN USHORT convert_arfcn_to_g23 (USHORT arfcn, UBYTE local_std);
511
512 /* range check with the fastest way for ARM */
513 /* corresponds with ((min <= x) AND (x <= max)) */
514 #define INRANGE(min, x, max) ((unsigned)(x-min) <= (max-min))
515
516 #if defined (WIN32)
517 #define ARFCN_TO_L1(a) ((USHORT)((a)&ARFCN_MASK))
518 #define ARFCN_TO_G23(a) ((USHORT)((a)&ARFCN_MASK))
519 #define ARFCN_STD_TO_L1(a,std) ((USHORT)((a)&ARFCN_MASK))
520 #define ARFCN_STD_TO_G23(a,std) ((USHORT)((a)&ARFCN_MASK))
521 #else
522 /*
523 * target version
524 */
525 #define ARFCN_TO_L1(a) convert_arfcn_to_l1((USHORT)(a),std)
526 #define ARFCN_TO_G23(a) convert_arfcn_to_g23((USHORT)(a),std)
527 #define ARFCN_STD_TO_L1(a,std) convert_arfcn_to_l1((USHORT)(a),std)
528 #define ARFCN_STD_TO_G23(a,std) convert_arfcn_to_g23((USHORT)(a),std)
529 #endif
530
531 /* add resp. get the std value to resp. from arfcn */
532 #define STD_ADD_TO_ARFCN(a,std) (((a)&~STD_BIT_MASK) | ((std)<<STD_BIT_SHIFT))
533 #define STD_GET_FROM_ARFCN(a) ((((a)&STD_BIT_MASK)>>STD_BIT_SHIFT))
534
535 /* find the frequency band index to which the given arfcn belongs. */
536 EXTERN const int array_band_index[];
537 #define get_band_index_from_arfcn(arfcn, idx, std)\
538 {\
539 UBYTE local_std = STD_GET_FROM_ARFCN(arfcn);\
540 if( !local_std )\
541 local_std = std;\
542 idx = local_std;\
543 if( local_std == STD_DUAL ) {\
544 if (arfcn >= LOW_CHANNEL_1800)\
545 idx = STD_1800;\
546 else\
547 idx = STD_900;\
548 }\
549 else if ( local_std EQ STD_DUAL_EGSM ) {\
550 if (arfcn >= LOW_CHANNEL_EGSM)\
551 idx = BAND_E_GSM;\
552 else if (arfcn >= LOW_CHANNEL_1800)\
553 idx = STD_1800;\
554 else if (arfcn EQ CHANNEL_0)\
555 idx = STD_EGSM;\
556 else\
557 idx = STD_900;\
558 }\
559 else if( local_std EQ STD_DUAL_US ) {\
560 if (arfcn >= LOW_CHANNEL_1900)\
561 idx = STD_1900;\
562 else\
563 idx = STD_850;\
564 }\
565 (local_std<=STD_DUAL_US)?(idx=array_band_index[idx-1]):(idx=MAX_NUM_BANDS) ;\
566 }
567
568 /*==== TYPES ======================================================*/
569
570 EXTERN UBYTE std; /*lint -esym(526,std) : not defined | defined in other entity */
571 EXTERN UBYTE test_house; /*lint -esym(526,test_house) : not defined | defined in other entity */
572
573 typedef struct {
574 USHORT radio_freq;
575 SHORT accum_power_result;
576 } T_POWER_ARRAY;
577
578 typedef struct {
579 USHORT power_array_size;
580 T_POWER_ARRAY power_array[MAX_CARRIERS];
581 } T_POWER_MEAS;
582
583 typedef struct {
584 USHORT power_array_size;
585 T_POWER_ARRAY power_array[MAX_CARRIERS_DUAL_EGSM];
586 } T_POWER_MEAS1;
587
588 typedef struct {
589 USHORT power_array_size;
590 T_POWER_ARRAY power_array[MAX_CARRIERS_DUAL_US];
591 } T_POWER_MEAS2;
592
593 EXTERN T_POWER_MEAS1 alr_power_meas_result1;
594 EXTERN T_POWER_MEAS2 alr_power_meas_result2;
595
596 #define CS_SYNC_FAIL_COUNT_MAX 5
597 #define CS_BCCH_FAIL_COUNT_MAX 10
598
599 typedef struct {
600 T_POWER_MEAS *p_results1;
601 T_POWER_MEAS *p_results2;
602 T_MPH_POWER_CNF *p_power_cnf;
603 T_MPH_POWER_REQ *p_power_req; /* CSI-LLD section: 4.1.3.1.2 */
604 T_MPH_EXT_MEAS_REQ *mph_ext_meas_req;
605 USHORT arfcn;
606 UBYTE ext_meas_state_pend; /* wait for pending MPHC_RXLEV_IND or MPHC_NCELL_SYNC_IND */
607 UBYTE sync_active;
608 UBYTE freq_bands;
609 UBYTE std;
610 UBYTE std12;
611 UBYTE freq_area;
612 UBYTE search_mode;
613 UBYTE sync_fail_count;
614 UBYTE bcch_fail_count;
615 UBYTE c_meas;
616 UBYTE c_max_meas;
617 T_TIME c_tim_meas;
618 } T_CS_DATA;
619
620 #define MAX_OLD_CB 10
621 #define CBCH_BLOCK_SIZE 22
622 #define CBCH_BLOCKS 4
623 #define CBCH_MSG_SIZE (CBCH_BLOCKS*CBCH_BLOCK_SIZE)
624
625 /* no alignment or gaps between members ! */
626 typedef struct cbmsg_header_t
627 {
628 UBYTE serial_no1;
629 UBYTE serial_no2;
630 UBYTE msg_id3;
631 UBYTE msg_id4;
632 UBYTE dcs;
633 UBYTE page;
634 } T_CBMSG_HEADER;
635
636 typedef struct
637 {
638 UBYTE cnt;
639 T_CBMSG_HEADER header [MAX_OLD_CB];
640 } T_CB_MSG;
641
642 #define CBCH_CHANNELS 2
643 /*
644 * index defines are in alr_cbch.c :
645 * CBCH_NORM 0
646 * CBCH_EXT 1
647 */
648 typedef struct
649 {
650 /* message which currently read */
651 UBYTE msg_is_extended;
652 UBYTE msg [CBCH_MSG_SIZE];
653 USHORT msg_id_sat [MAX_IDENTS_SAT];
654 UBYTE msg_type;
655 UBYTE sat_enabled;
656 UBYTE expected_seq_number[CBCH_CHANNELS];
657 /* schedule support for normal and extended CBCH */
658 UBYTE begin_schedule[CBCH_CHANNELS];
659 UBYTE end_schedule[CBCH_CHANNELS];
660 UBYTE scheduled_sched_msg[CBCH_CHANNELS];
661 UBYTE schedule_length[CBCH_CHANNELS];
662 UBYTE last_slot_read[CBCH_CHANNELS];
663 ULONG schedule_map[CBCH_CHANNELS][2];
664 /* configured by MMI: specifies which messages are wanted */
665 UBYTE modus;
666 UBYTE old_cid_plmn_lac [7];
667 UBYTE dcs_id [MAX_IDENTS];
668 USHORT msg_id [MAX_IDENTS];
669 T_CB_MSG old_cbch_msg;
670 #if defined(FF_HOMEZONE)
671 /*
672 * special handling for homezone CBCH message after cell reselecting
673 */
674 UBYTE homezone;
675 USHORT msg_hz_id;
676 UBYTE dcs_hz_id;
677 USHORT hz_timeout;
678 #endif /* FF_HOMEZONE */
679 #if !defined (L1_STORES_CBCH_CONFIG)
680 T_MPHC_CONFIG_CBCH_REQ mphc_config_cbch;
681 #endif
682 } T_CBCH_DATA;
683
684 typedef struct
685 {
686 UBYTE sys_info_1[22];
687 UBYTE sys_info_2[22];
688 UBYTE sys_info_2bis[22];
689 UBYTE sys_info_2ter[22];
690 UBYTE sys_info_3[22];
691 UBYTE sys_info_4[22];
692 UBYTE sys_info_5[18];
693 UBYTE sys_info_5bis[18];
694 UBYTE sys_info_5ter[18];
695 UBYTE sys_info_6[18];
696 #ifdef GPRS
697 UBYTE sys_info_13[22];
698 #endif
699 } T_MA_DATA;
700
701 typedef struct
702 {
703 /* information for using the cell */
704 USHORT ba_arfcn;
705 UBYTE last_rxlev;
706 UBYTE tim_valid;
707 ULONG frame_offset;
708 ULONG time_align;
709 UBYTE bsic;
710 /* power measurements of the cell */
711 UBYTE rxlev[5];
712 UBYTE rxlev_average;
713 UBYTE c_rxlev;
714 /* state of the cell */
715 UBYTE one_of_six; /* this is a subset of one_of_twelve */
716 UBYTE one_of_twelve;
717 UBYTE status;
718 UBYTE ba_status;
719 UBYTE new_strong_cell;
720 /* counters for status handling */
721 UBYTE c_attempt;
722 UBYTE c_error;
723 UBYTE c_bcch;
724 UBYTE c_sync;
725 USHORT blocks_required;
726 /* Meas results for averaging when NC=1 or NC=2 */
727 #ifdef GPRS
728 USHORT nc_rxlev;
729 UBYTE c_nc_rxlev;
730 #endif
731 /* temporary BCCH storage */
732 T_MPH_UNITDATA_IND* mph_unitdata_ind;
733 T_MPH_UNITDATA_IND* mph_unitdata_ind78;
734
735 } T_NC;
736
737 /* values for component tim_state */
738 #define NC_TIM_STOPPED 0
739 #define NC_CONF_ENABLED 1
740 #define NC_CONF_DISABLED 2
741 #define NC_CONF_PENDING 3
742
743 typedef struct
744 {
745 /* +1 because we use this for idle mode cell selection */
746 #define LAST_BSIC_REQ BA_LIST_SIZE
747 T_NC cell[BA_LIST_SIZE+1];
748 T_NC cr_cell; /* */
749 UBYTE c_ba_arfcn;
750 UBYTE ba_id;
751 USHORT channel;
752 USHORT rxlev_full;
753 USHORT rxlev_sub;
754 UBYTE rxqual_full;
755 UBYTE rxqual_sub;
756 USHORT tav;
757 UBYTE pwrc;
758 UBYTE dtx;
759 UBYTE act_dtx;
760 UBYTE update;
761 UBYTE sc_included;
762 UBYTE multiband;
763 UBYTE c_nc_timer;
764 /*
765 * Counter variable used to store 10sec timer interval
766 * in terms of the number of 51 frame control multi-frames.
767 * This counter is decremented for every measurement indication
768 * received from L1. This is initialized with TEN_SECONDS_ NCSYNC.
769 */
770 UBYTE c_ncsync_tim;
771 /*
772 *Variable to store the system time whenever
773 * the NCSYNC counter is re-assigned
774 */
775 T_TIME ncsync_start_tim;
776 /* for MPH_MEASUREMENT_IND */
777 USHORT fn_offset;
778 UBYTE max_reports;
779 UBYTE c_reports; /*
780 * counters to keep track of the send NCELL_SYNC_REQ's
781 * and NCELL_BCCH_REQ's valid ranges are 0..12 and 0..6
782 */
783 UBYTE c_sync_req;
784 UBYTE c_bcch_req;
785 /* EOTD related */
786 UBYTE eotd_avail;
787 UBYTE tim_state;
788 UBYTE new_strong_cell_detect;
789 UBYTE c_sync_intrupted;
790 T_MPH_NCELL_POS_IND* ppos_ind;
791 T_MPH_NCELL_POS_REQ* ppos_req;
792 } T_NC_DATA;
793
794 #define SYSTEM_INFO_1_READ 0x01
795 #define SYSTEM_INFO_2_READ 0x02
796 #define SYSTEM_INFO_3_READ 0x04
797 #define SYSTEM_INFO_4_READ 0x08
798
799 #ifdef GPRS
800 #define SYSTEM_INFO_13_READ 0x10
801 #endif
802
803 #define ALL_SI_READ_EXCEPT_SI13 0x0F
804
805 typedef struct
806 {
807 T_MPHC_START_CCCH_REQ pl_idle, last_start_ccch_req;
808 SHORT imsi_mod_1000;
809 UBYTE dlt;
810 UBYTE act_dlt;
811 UBYTE si3_read;
812 UBYTE saved_page_mode;
813 UBYTE imsi [IMSI_LEN];
814 UBYTE v_tmsi;
815 ULONG tmsi;
816 BOOL reorg_bcch_reading;
817 UBYTE si_bitmap;
818 } T_PCH_DATA;
819
820 typedef struct
821 {
822 UBYTE ms_class;
823 UBYTE dcs_class;
824 UBYTE max_tx_pwr_ccch;
825 UBYTE delta [8];
826 UBYTE channel_request [8];
827 #ifdef GPRS
828 UBYTE t1 [8];
829 UBYTE t2 [8];
830 UBYTE t3 [8];
831 #endif
832 UBYTE max_bursts;
833 UBYTE c_burst;
834 } T_RACH_DATA;
835
836 typedef struct
837 {
838 UBYTE rlt;
839 UBYTE act_rlt;
840 USHORT act_bcch;
841 UBYTE act_mode;
842 /*
843 * Description of the actual used
844 * channel, confirmed by layer 1
845 */
846 T_channel_desc act_channel_desc;
847 T_frequency_list act_frequency_list;
848 T_starting_time act_starting_time;
849 T_frequency_list_bef_sti act_frequency_list_bef_sti;
850 T_channel_desc act_channel_desc_bef_sti;
851 UBYTE act_channel_mode;
852 BOOL act_pwrc;
853 UBYTE act_cipher_mode;
854 UBYTE act_a5_algorithm;
855 T_cipher_key act_cipher_key;
856 T_amr_configuration act_amr_configuration;
857 UBYTE act_power;
858 UBYTE act_dtx_allowed;
859 /*
860 * Description of the old used
861 * channel.
862 */
863 USHORT old_bcch;
864 UBYTE old_bsic;
865 UBYTE old_channel;
866 UBYTE old_channel_mode;
867 T_channel_desc old_channel_desc;
868 T_frequency_list old_frequency_list;
869 T_starting_time old_starting_time;
870 T_frequency_list_bef_sti old_frequency_list_bef_sti;
871 T_channel_desc old_channel_desc_bef_sti;
872 BOOL old_pwrc;
873 UBYTE old_cipher_mode;
874 UBYTE old_a5_algorithm;
875 T_cipher_key old_cipher_key;
876 T_amr_configuration old_amr_configuration;
877 UBYTE old_power;
878 UBYTE old_dtx_allowed;
879
880 /*
881 * Description of the new configured
882 * channel, not yet confirmed by layer 1.
883 */
884 USHORT temp_bcch;
885 UBYTE temp_bsic;
886 UBYTE temp_channel;
887 UBYTE temp_channel_mode;
888 T_channel_desc temp_channel_desc;
889 T_frequency_list temp_frequency_list;
890 T_starting_time temp_starting_time;
891 T_frequency_list_bef_sti temp_frequency_list_bef_sti;
892 T_channel_desc temp_channel_desc_bef_sti;
893 BOOL temp_pwrc;
894 UBYTE temp_cipher_mode;
895 UBYTE temp_a5_algorithm;
896 T_cipher_key temp_cipher_key;
897 T_amr_configuration temp_amr_configuration;
898 UBYTE temp_power;
899 UBYTE temp_dtx_allowed;
900
901 /*
902 * Description of frequency redefinition
903 * parameter.
904 */
905 T_channel_desc redef_channel_desc;
906 T_frequency_list redef_frequency_list;
907 T_starting_time redef_starting_time;
908 /*
909 * Extended Measurmeent Order parameter.
910 */
911 UBYTE emo_ba_id;
912 } T_DEDI_DATA;
913
914 #define TIM_NCSYNC_VALUE 10000
915 #define TIM_NW_SYNC_GUARD_VALUE 2500
916
917 /*
918 * timer
919 */
920 #define TIMER_TRACE
921
922 #if defined (TIMER_TRACE)
923 #define TIMERSTART(i,v) tim_start_timer (i, v)
924 #define TIMERSTOP(i) tim_stop_timer (i)
925 #define IS_TIMER_ACTIVE(i) tim_check_timer (i)
926 #else
927 #define TIMERSTART(i,v)
928 #define TIMERSTOP(i)
929 #define IS_TIMER_ACTIVE(i)
930 #endif /* TIMER_TRACE */
931
932 enum tim_index_e
933 {
934 TIM_POWERMEAS,
935 TIM_NW_SYNC_GUARD,
936 #if defined(FF_HOMEZONE)
937 TIM_HOMEZONE,
938 #endif /* FF_HOMEZONE */
939 NUM_OF_ALR_TIMERS
940 };
941
942 typedef void (*T_TIMER_EXPIRY)(void);
943
944 typedef struct
945 {
946 UBYTE running[NUM_OF_ALR_TIMERS];
947 T_TIMER_EXPIRY expire[NUM_OF_ALR_TIMERS];
948 } T_TIM_DATA;
949
950 #ifdef OPTION_MULTITHREAD
951 #define tim_init _ENTITY_PREFIXED(tim_init)
952 #define tim_exec_timeout _ENTITY_PREFIXED(tim_exec_timeout)
953 #define tim_stop_timer _ENTITY_PREFIXED(tim_stop_timer)
954 #define tim_start_timer _ENTITY_PREFIXED(tim_start_timer)
955 #define tim_check_timer _ENTITY_PREFIXED(tim_check_timer)
956 #define trace_timer _ENTITY_PREFIXED(trace_timer)
957 #endif
958
959 EXTERN void tim_init (void);
960 EXTERN void tim_exec_timeout (USHORT index);
961 EXTERN void tim_stop_timer (USHORT index);
962 EXTERN void tim_start_timer (USHORT index, T_TIME value);
963 EXTERN BOOL tim_check_timer(USHORT index);
964
965 /* all data is stored so, that it doesn't need
966 to be converted if send to the upper layers.
967 Exceptions are alr_data.cs_data.results,
968 alr_data.pch_data.pl_idle
969 alr_data.pch_data.imsi */
970
971 typedef struct
972 {
973 UBYTE state[MAX_STATE];
974 /*
975 * each of these elements is only
976 * accessed by the appropiate
977 * process
978 */
979 T_CBCH_DATA cbch_data;
980 T_CS_DATA cs_data;
981 T_MA_DATA ma_data;
982 T_NC_DATA nc_data;
983 T_PCH_DATA pch_data;
984 T_RACH_DATA rach_data;
985 T_DEDI_DATA dedi_data;
986 #ifdef GPRS
987 T_ALR_GPRS_DATA gprs_data;
988 #endif /* GPRS */
989 T_TIM_DATA tim_data;
990
991 UBYTE mmi; /* mmi variant */
992 UBYTE keypad; /* keypad variant */
993 UBYTE sc_band; /* frequency band of the serving cell */
994 BOOL ext_display; /* ext display */
995 EF_MSCAP mscap; /* MS capabilities (channel mode, data cap., features */
996 /* is this component really needed ?? */
997 /*
998 * these parameters are used by more than one process
999 * this is to avoid data inconsistencies between
1000 * the different processes
1001 */
1002 USHORT serving_cell;
1003 USHORT old_serving_cell;
1004 UBYTE bsic;
1005 UBYTE bs_pa_mfrms;
1006 UBYTE ncc_permitted;
1007 UBYTE plmn_search_running;
1008 #ifdef GPRS
1009 UBYTE nc_sync_with_grr;
1010 UBYTE nwctrl_meas_active; /* indicates whether averaging when NC=1,2 is active */
1011 #endif
1012 } T_ALR_DATA;
1013
1014 /*==== EXPORT =====================================================*/
1015 /*
1016 * Main Control
1017 */
1018 EXTERN void ma_init (void);
1019 /*
1020 * Primitive processing functions for upper layer (RR)
1021 */
1022 EXTERN void ma_mph_idle_req (T_MPH_IDLE_REQ *mph_idle_req);
1023 EXTERN void ma_mph_neighbourcell_req (T_MPH_NEIGHBOURCELL_REQ *mph_neighbourcell_req);
1024 EXTERN void ma_mph_emo_req (T_MPH_EMO_REQ *mph_emo_req);
1025 EXTERN void ma_mph_dedicated_req (T_MPH_DEDICATED_REQ *mph_dedicated_req);
1026 EXTERN void ma_mph_dedicated_fail_req (T_MPH_DEDICATED_FAIL_REQ *mph_dedicated_fail_req);
1027 EXTERN void ma_mph_ciphering_req (T_MPH_CIPHERING_REQ *mph_ciphering_req);
1028 EXTERN void ma_mph_freq_redef_req (T_MPH_FREQ_REDEF_REQ *mph_freq_redef_req);
1029 EXTERN void ma_mph_channel_mode_req (T_MPH_CHANNEL_MODE_REQ *mph_channel_mode_req);
1030 EXTERN void ma_mph_deactivate_req (T_MPH_DEACTIVATE_REQ *mph_deactivate_req);
1031 EXTERN void ma_mph_classmark_req (T_MPH_CLASSMARK_REQ *mph_classmark_req);
1032 EXTERN void ma_mph_ext_meas_req (T_MPH_EXT_MEAS_REQ *mph_ext_meas_req);
1033 EXTERN void ma_mph_tch_loop_req (T_MPH_TCH_LOOP_REQ *mph_tch_loop_req);
1034 EXTERN void ma_mph_dai_req (T_MPH_DAI_REQ *mph_dai_req);
1035 EXTERN void ma_mph_cbch_req (T_MPH_CBCH_REQ *mph_cbch_req);
1036 EXTERN void ma_mph_identity_req (T_MPH_IDENTITY_REQ *mph_identity_req);
1037 EXTERN void ma_mph_power_req (T_MPH_POWER_REQ *mph_power_req);
1038 EXTERN void ma_mph_bsic_req (T_MPH_BSIC_REQ *mph_bsic_req);
1039 EXTERN void ma_mph_random_access_req (T_MPH_RANDOM_ACCESS_REQ *mph_random_access_req);
1040 EXTERN void ma_mph_sync_req (T_MPH_SYNC_REQ *mph_sync_req);
1041 EXTERN void ma_mph_ncell_pos_req (T_MPH_NCELL_POS_REQ *mph_ncell_pos_req);
1042 EXTERN void ma_mph_clean_buf_req (T_MPH_CLEAN_BUF_REQ *mph_clean_buf_req);
1043 EXTERN void ma_mph_stop_dedi_req (T_MPH_STOP_DEDICATED_REQ *mph_stop_dedi_req);
1044 #ifdef GPRS
1045 EXTERN void ma_mph_meas_rep_req (T_MPH_MEAS_REP_REQ *mph_meas_rep_req);
1046 #endif
1047 /*
1048 * Primitive processing functions for lower layer
1049 */
1050 EXTERN void ma_mphc_rxlev_ind (T_MPHC_RXLEV_IND *rxlev_ind);
1051 EXTERN void ma_mphc_stop_rxlev_cnf (T_MPHC_STOP_RXLEV_CON *rxlev_con);
1052 EXTERN void ma_mphc_empty_cnf (void *);
1053 EXTERN void ma_mphc_network_sync_ind (T_MPHC_NETWORK_SYNC_IND *network_sync_ind);
1054 EXTERN void ma_cs_stop_network_sync_req (void);
1055 EXTERN void ma_mphc_new_scell_cnf (T_MPHC_NEW_SCELL_CON *new_Scell_cnf);
1056 EXTERN void ma_mphc_ncell_bcch_ind (T_MPHC_NCELL_BCCH_IND *ncell_bcch_data_ind);
1057 EXTERN void ma_mphc_ncell_sync_ind (T_MPHC_NCELL_SYNC_IND *ncell_sync_ind);
1058 GLOBAL void ma_mphc_stop_ncell_sync_cnf (T_MPHC_STOP_NCELL_SYNC_CON *ncell_sync_cnf );
1059 EXTERN void ma_mphc_rxlev_periodic_ind (T_MPHC_RXLEV_PERIODIC_IND *rxlev_periodic_ind);
1060 EXTERN void ma_mphc_ra_cnf (T_MPHC_RA_CON *ra_cnf);
1061 EXTERN void ma_mphc_data_ind (T_MPHC_DATA_IND *data_ind);
1062 EXTERN void ma_mphc_change_frequency_cnf (T_MPHC_CHANGE_FREQUENCY_CON *change_frequency_cnf);
1063 EXTERN void ma_mphc_async_ho_cnf (T_MPHC_ASYNC_HO_CON *async_ho_cnf);
1064 EXTERN void ma_mphc_channel_assign_cnf (T_MPHC_CHANNEL_ASSIGN_CON *channel_assign_cnf);
1065 EXTERN void ma_mphc_handover_fail_cnf (T_MPHC_HANDOVER_FAIL_CON *handover_fail_cnf);
1066 EXTERN void ma_mphc_immed_assign_cnf (T_MPHC_IMMED_ASSIGN_CON *immed_assign_cnf);
1067 EXTERN void ma_mphc_pre_sync_ho_cnf (T_MPHC_PRE_SYNC_HO_CON *pre_sync_ho_cnf);
1068 EXTERN void ma_mphc_sync_ho_cnf (T_MPHC_SYNC_HO_CON *sync_ho_cnf);
1069 EXTERN void ma_mphc_ta_fail_ind (T_MPHC_TA_FAIL_IND *ta_fail_ind);
1070 EXTERN void ma_mphc_handover_finished_ind (T_MPHC_HANDOVER_FINISHED *handover_finished);
1071 EXTERN void ma_mphc_meas_report_ind (T_MPHC_MEAS_REPORT *meas_report);
1072 EXTERN void ma_mphc_adc_ind (T_MPHC_ADC_IND *adc_results);
1073 EXTERN void ma_mphc_init_l1_cnf (T_MPHC_INIT_L1_CON *init_l1_cnf);
1074 EXTERN void ma_mphc_stop_dedi_con (T_MPHC_STOP_DEDICATED_CON *stop_cnf);
1075 #if defined(STOP_SYNC_TASK)
1076 EXTERN void ma_mphc_stop_network_sync_cnf (T_MPHC_STOP_NETWORK_SYNC_CON *stop_network_sync_cnf);
1077 #endif /* STOP_SYNC_TASK */
1078 /* Signal processing functions for process Cell Selection */
1079 EXTERN void ma_cs_init_l1_req (UBYTE radio_band_config);
1080 EXTERN void ma_cs_stop_network_sync_req (void);
1081 EXTERN void ma_cs_network_sync_req (USHORT channel);
1082 EXTERN void ma_cs_rxlev_req (void);
1083 EXTERN void ma_cs_power_cnf (T_MPH_POWER_CNF *mph_power_cnf);
1084
1085 /* Signal processing functions for process Neigbour Cell */
1086 EXTERN void ma_nc_rxlev_periodic_req (T_MPHC_RXLEV_PERIODIC_REQ *update);
1087 EXTERN void ma_nc_stop_ncell_bcch_req (USHORT arfcn);
1088 EXTERN void ma_nc_stop_ncell_sync_req (USHORT arfcn);
1089 EXTERN void ma_nc_sync_req (T_MPHC_NCELL_SYNC_REQ *sync_req);
1090 EXTERN void ma_nc_list_sync_req (T_MPHC_NCELL_LIST_SYNC_REQ *list_sync_req);
1091 EXTERN void ma_nc_bcch_req (T_MPHC_NCELL_BCCH_REQ *bcch_req);
1092 EXTERN void ma_nc_update_ba_list (T_MPHC_UPDATE_BA_LIST *update_ba_list);
1093 EXTERN void nc_new_serving_cell (USHORT serving_cell);
1094 EXTERN void ma_nc_report_res (T_MPH_MEASUREMENT_IND *mph_measurement_ind);
1095
1096 /* Signal processing functions for process RACH_Contol */
1097 EXTERN void ma_rach_stop_ra_req (void);
1098 EXTERN void ma_rach_ra_req (T_MPHC_RA_REQ *mph_ra_req);
1099 EXTERN void ma_rach_random_cnf (T_MPH_RANDOM_ACCESS_CNF *mph_random_access_cnf);
1100
1101 /* Signal processing functions for process Dedi_Control */
1102 EXTERN void ma_dedi_stop_req (void);
1103 EXTERN void ma_dedi_cnf (UBYTE cause);
1104 EXTERN void ma_dedi_chan_ass_req (T_MPHC_CHANNEL_ASSIGN_REQ *mphc_channel_assign_req);
1105 EXTERN void ma_dedi_async_ho_req (T_MPHC_ASYNC_HO_REQ *async_ho_req);
1106 EXTERN void ma_dedi_sync_ho_req (T_MPHC_SYNC_HO_REQ *sync_ho_req);
1107 EXTERN void ma_dedi_pre_sync_ho_req (T_MPHC_PRE_SYNC_HO_REQ *pre_sync_ho_req);
1108 EXTERN void ma_dedi_fail_cnf (void);
1109 EXTERN void ma_dedi_ho_fail_req (void);
1110 EXTERN void ma_dedi_imm_ass_req (T_MPHC_IMMED_ASSIGN_REQ *immed_assign_req);
1111 EXTERN void ma_dedi_change_freq_req (T_MPHC_CHANGE_FREQUENCY *change_frequency);
1112 EXTERN void ma_dedi_chan_mode_req (T_MPHC_CHANNEL_MODE_MODIFY_REQ *channel_mode_modify_req);
1113 EXTERN void ma_dedi_ciph_req (T_MPHC_SET_CIPHERING_REQ *set_ciphering_req);
1114 EXTERN void ma_dedi_start_dai_req (T_OML1_START_DAI_TEST_REQ *oml1_start_dai_test_req);
1115 EXTERN void ma_dedi_close_tch_loop_req (T_OML1_CLOSE_TCH_LOOP_REQ *oml1_close_tch_loop_req);
1116 EXTERN void ma_dedi_stop_dai_req (void);
1117 EXTERN void ma_dedi_open_tch_loop_req (void);
1118
1119 /* Signal processing functions for process PCH_control */
1120 EXTERN void ma_pch_start_ccch_req (T_MPHC_START_CCCH_REQ *pl_idle);
1121 EXTERN void ma_pch_paging_ind (UBYTE id_type,
1122 UBYTE channel_needed);
1123 EXTERN void ma_pch_stop (void);
1124
1125 /* Signal processing functions for process MMI_control */
1126 EXTERN void ma_mmi_cbch_req (T_MMI_CBCH_REQ *cbch_req);
1127 EXTERN void ma_mmi_sat_cbch_dwnld_req (T_MMI_SAT_CBCH_DWNLD_REQ *cbch_req);
1128 /* Signal processing functions for process CBCH_control */
1129 EXTERN void ma_cb_stop_cbch_req (void);
1130 EXTERN void ma_cb_sched_req (T_MPHC_CBCH_SCHEDULE_REQ *sched_req);
1131 EXTERN void ma_cb_config_cbch (T_MPHC_CONFIG_CBCH_REQ *config_cbch);
1132 EXTERN void ma_cb_mmi_cbch_ind (T_MMI_CBCH_IND *mmi_cbch_ind);
1133 EXTERN void ma_cb_info_req (UBYTE bitmap);
1134
1135 /* Signal processing functions used by more then one process */
1136 EXTERN void ma_scell_nbcch_req (T_MPHC_SCELL_NBCCH_REQ *nbcch_req);
1137 EXTERN void ma_scell_ebcch_req (T_MPHC_SCELL_EBCCH_REQ *ebcch_req);
1138 EXTERN void ma_stop_scell_bcch_req (void);
1139 EXTERN void ma_stop_active_procs (UBYTE flags);
1140 EXTERN void ma_bsic_cnf (T_MPH_BSIC_CNF *mph_bsic_cnf);
1141 EXTERN void ma_send_unitdata (T_MPHC_DATA_IND *data_ind);
1142 EXTERN void ma_error_ind (UBYTE cause,
1143 USHORT arfcn);
1144 EXTERN void ma_clean_dedi_sys_buffer (void);
1145 EXTERN void ma_new_scell_req (T_MPHC_NEW_SCELL_REQ *new_scell);
1146 EXTERN void ma_scell_full_nbcch (void);
1147 #ifdef GPRS
1148 EXTERN BOOL ma_is_ptm (void);
1149 EXTERN void ma_nc_rxlev_sc_req (T_TB_RXLEV_SC_REQ *rxlev_sc_req);
1150 #endif
1151 EXTERN void ma_clean_sys_buffer (USHORT si_mask);
1152
1153 /* defined in dl_pei.c */
1154 EXTERN void dl1_downlink_indication (UBYTE chan,
1155 UBYTE *frame);
1156
1157 /*
1158 * CBCH Control
1159 */
1160 EXTERN void cb_init (void);
1161 EXTERN void cb_stop (void);
1162 EXTERN void cb_start (void);
1163 EXTERN void cb_mmi_cbch_req (T_MMI_CBCH_REQ *cbch);
1164 EXTERN void cb_mph_cbch_req (T_cbch *cbch);
1165 EXTERN void cb_data_ind (T_MPHC_DATA_IND *cbch_ind);
1166 EXTERN void cb_mmi_sat_cbch_req (T_MMI_SAT_CBCH_DWNLD_REQ *cbch_req);
1167 #if defined(FF_HOMEZONE)
1168 EXTERN void cb_tim_homezone (void);
1169 #endif /* FF_HOMEZONE */
1170
1171 /*
1172 * Cell Selection
1173 */
1174 EXTERN void cs_init (void);
1175 EXTERN void cs_rxlev_ind (T_MPHC_RXLEV_IND *rxlev_ind);
1176 EXTERN void cs_network_sync_ind (T_MPHC_NETWORK_SYNC_IND *network_sync_ind);
1177 EXTERN void cs_stop (void);
1178 EXTERN T_POWER_MEAS* cs_prepare_power_req (void);
1179 EXTERN void cs_power_req (UBYTE pch_interrupt);
1180 EXTERN void cs_bsic_req (T_MPH_BSIC_REQ *mph_bsic_req);
1181 EXTERN void cs_read_scell_bcch (void);
1182 EXTERN UBYTE get_band (USHORT arfcn);
1183 EXTERN void cs_increment_bfc (void);
1184 EXTERN void cs_decrement_bfc (void);
1185 EXTERN void cs_set_wideband_sync (void);
1186
1187 /*
1188 * Dedicated Control
1189 */
1190 EXTERN void dedi_init (void);
1191 EXTERN void dedi_req (T_MPH_DEDICATED_REQ *dedicated_req);
1192 EXTERN void dedi_fail_req (void);
1193 EXTERN void dedi_ta_fail_ind (void);
1194 EXTERN void dedi_ho_finished (UBYTE cause);
1195 EXTERN void dedi_freq_redef_req (T_MPH_FREQ_REDEF_REQ *freq);
1196 EXTERN void dedi_chan_mode_req (T_MPH_CHANNEL_MODE_REQ *ch_mode);
1197 EXTERN void dedi_ciph_req (T_MPH_CIPHERING_REQ *ciph_req);
1198 EXTERN void dedi_tch_loop_req (T_MPH_TCH_LOOP_REQ *tloop);
1199 EXTERN void dedi_dai_req (T_MPH_DAI_REQ *dai);
1200 EXTERN void dedi_change_freq_cnf (void);
1201 EXTERN void dedi_async_ho_cnf (void);
1202 EXTERN void dedi_chan_ass_cnf (void);
1203 EXTERN void dedi_ho_fail_cnf (void);
1204 EXTERN void dedi_imm_ass_cnf (void);
1205 EXTERN void dedi_pre_sync_ho_cnf (void);
1206 EXTERN void dedi_sync_ho_cnf (void);
1207 EXTERN void dedi_stop (void);
1208 EXTERN void dedi_increment_rlt (void);
1209 EXTERN void dedi_decrement_rlt (void);
1210
1211 /*
1212 * MMI Control
1213 */
1214 EXTERN USHORT RX_GetValue (void);
1215
1216 /*
1217 * Idle Mode Neighbour Cell
1218 */
1219 EXTERN void nc_init (void);
1220 EXTERN void nc_ncell_list (T_MPH_NEIGHBOURCELL_REQ *mph_neighbourcell_req);
1221 EXTERN void nc_stop (void);
1222 EXTERN void nc_bsic_req (T_MPH_BSIC_REQ *mph_bsic_req);
1223 EXTERN void nc_sync_ind (T_MPHC_NCELL_SYNC_IND *sync_ind);
1224 EXTERN void nc_bcch_ind (T_MPHC_NCELL_BCCH_IND *data_ind);
1225 EXTERN void nc_start_dedicated (UBYTE pwrc,
1226 UBYTE dtx);
1227 EXTERN void nc_update_dedicated (UBYTE dtx,
1228 UBYTE pwrc);
1229 EXTERN void nc_update_list (USHORT channel);
1230 EXTERN BOOL nc_get_fn_time (USHORT channel,
1231 ULONG *fn,
1232 ULONG *time);
1233 EXTERN void nc_suspend (void);
1234 EXTERN void nc_add_offset (void);
1235 EXTERN void nc_report (T_MPHC_RXLEV_PERIODIC_IND *rxlev_periodic_ind);
1236 EXTERN void nc_start_reselect (USHORT arfcn);
1237 EXTERN void nc_start_monitoring (void);
1238 EXTERN void nc_report_dedicated (T_MPHC_MEAS_REPORT *meas_report);
1239 EXTERN void nc_fill_report_sc_dedi (T_MPH_MEASUREMENT_IND *rr_report,
1240 UBYTE ncells);
1241 EXTERN void nc_store_tav (USHORT tav);
1242 EXTERN void nc_check_new_ncc_permitted (UBYTE new_ncc_permitted);
1243 EXTERN void nc_stop_rr_activity (UBYTE stop);
1244 EXTERN void nc_stop_ext_meas_ind (void);
1245 EXTERN void nc_resume (void);
1246 EXTERN void nc_check_activity (void);
1247 EXTERN void nc_set_status (USHORT index,
1248 UBYTE new_status);
1249 EXTERN USHORT nc_get_index (USHORT arfcn);
1250 EXTERN void nc_ncsync_tim_expiry (void);
1251 EXTERN void nc_ncell_pos_req (T_MPH_NCELL_POS_REQ* pos_req);
1252 GLOBAL void nc_resume_dedicated(void);
1253 GLOBAL void nc_suspend_handover (void);
1254
1255 #ifdef GPRS
1256 EXTERN void nc_start_pbcch(void);
1257 EXTERN void nc_build_nwctrl_rr_report (T_MPH_MEAS_REP_CNF *rr_report);
1258 #endif
1259 /*
1260 * PCH Control
1261 */
1262 EXTERN void pch_init (void);
1263 EXTERN void pch_configure (T_MPH_IDLE_REQ *idle,
1264 UBYTE page_mode);
1265 EXTERN void pch_start_ccch_req (void);
1266 EXTERN void pch_save_pgm (UBYTE mode);
1267 EXTERN void pch_identity_req (T_MPH_IDENTITY_REQ *mph_identity_req);
1268 EXTERN void pch_check_pag_3 (T_MPHC_DATA_IND *data_ind);
1269 EXTERN void pch_check_pag_2 (T_MPHC_DATA_IND *data_ind);
1270 EXTERN void pch_check_pag_1 (T_MPHC_DATA_IND *data_ind);
1271 EXTERN void pch_check_page_mode (T_MPHC_DATA_IND *data_ind);
1272 EXTERN void pch_check_page_mode_cr (T_MPHC_DATA_IND *data_ind);
1273 EXTERN void pch_decrement_dlt (void);
1274 EXTERN void pch_increment_dlt (void);
1275 EXTERN void pch_stop (void);
1276 EXTERN UBYTE pch_mode_reorg (void);
1277 EXTERN void pch_config_resel (T_MPHC_DATA_IND *data_ind);
1278 /*
1279 * RACH Control
1280 */
1281 EXTERN void rach_init (void);
1282 EXTERN void rach_configure_power (UBYTE power);
1283 EXTERN void rach_configure_class (UBYTE class,
1284 UBYTE dcs_class);
1285 EXTERN void rach_stop (void);
1286 EXTERN UBYTE cut_power_value (UBYTE power,
1287 T_MPH_DEDICATED_REQ *mph_dedicated_req);
1288
1289 EXTERN void rach_random_req (T_MPH_RANDOM_ACCESS_REQ *random_req);
1290 EXTERN void rach_ra_cnf (T_MPHC_RA_CON* ra_cnf);
1291
1292 /*
1293 * Idle Mode Serving Cell
1294 */
1295 EXTERN void sc_start_periodic (void);
1296 EXTERN const void csf_show_version (T_TST_TEST_HW_CON *ver);
1297 EXTERN void tim_stop_sync_to_nw (void);
1298
1299
1300
1301 EXTERN UBYTE grlc_test_mode_active(void); /*lint -esym(526,grlc_test_mode_active) : not defined | defined in other entity */
1302 EXTERN void cst_pei_config (char *, char *); /*lint -esym(526,cst_pei_config) : not defined | defined in other entity */
1303 #if defined (_SIMULATION_)
1304 EXTERN void rr_csf_check_rfcap (UBYTE init); /*lint -esym(526,rr_csf_check_rfcap) : not defined | defined in other entity */
1305 #endif /* _SIMULATION_ */
1306 EXTERN CHAR* alr_version(void);
1307
1308 #if defined(ALR_CSF_C) && defined(_TMS470)
1309 EXTERN void Cust_Init_Layer1(void);
1310 EXTERN void SIM_PowerOff (void);
1311 EXTERN void TM_EnableWatchdog (void);
1312 EXTERN void TM_ResetWatchdog(SYS_UWORD16 count);
1313 #endif /* ALR_CSF_C && _TMS470 */
1314
1315 #if defined(WIN32)
1316 #include <stdio.h> /* prototype of sprintf() */
1317 #endif /* WIN32 */
1318
1319 #if !defined NTRACE
1320 EXTERN void trc_mon_counter_idle (UBYTE act_dlt, UBYTE max_dlt);
1321 EXTERN void trc_mon_counter_dedi (UBYTE act_rlt, UBYTE max_rlt);
1322 #endif /* (!defined NTRACE ) */
1323
1324
1325
1326 EXTERN T_ALR_DATA * alr_data;
1327 #ifdef WIN32
1328 EXTERN T_POWER_MEAS tap_rxlev_response_european[];
1329 EXTERN T_POWER_MEAS tap_rxlev_response_american[];
1330 #endif
1331
1332 #define ENTITY_DATA alr_data
1333
1334 /*
1335 * If all entities are linked into one module this definitions
1336 * prefixes the global data with the enity name
1337 */
1338 #ifdef OPTION_MULTITHREAD
1339 #define hCommL1 _ENTITY_PREFIXED(hCommL1)
1340 #define hCommPL _ENTITY_PREFIXED(hCommPL)
1341 #define hCommDL _ENTITY_PREFIXED(hCommDL)
1342 #define hCommRR _ENTITY_PREFIXED(hCommRR)
1343 #define hCommMMI _ENTITY_PREFIXED(hCommMMI)
1344 #define hCommCST _ENTITY_PREFIXED(hCommCST)
1345 #ifdef GPRS
1346 #define hCommGPL _ENTITY_PREFIXED(hCommGPL)
1347 #endif /* #ifdef GPRS */
1348 #endif
1349
1350 EXTERN T_HANDLE hCommPL; /* PL own handle */
1351 EXTERN T_HANDLE hCommL1; /* L1 Communication */
1352 EXTERN T_HANDLE hCommDL; /* DL Communication */
1353 EXTERN T_HANDLE hCommRR; /* RR Communication */
1354 EXTERN T_HANDLE hCommMMI; /* MMI Communication */
1355 EXTERN T_HANDLE hCommCST; /* CST Communication */
1356 #ifdef GPRS
1357 EXTERN T_HANDLE hCommGPL; /* GPL Communication */
1358 #endif /* GPRS */
1359 EXTERN T_HANDLE pl_handle;
1360
1361 EXTERN UBYTE v_mon_counter_idle;
1362 EXTERN UBYTE v_mon_counter_dedi;
1363 EXTERN UBYTE v_eotd;
1364
1365 #if defined(DL_TRACE_ENABLED)
1366 EXTERN void dl_trace (UCHAR trace_type,
1367 UCHAR channel,
1368 UCHAR ch_type,
1369 UCHAR * data);
1370 #ifdef OPTION_MULTITHREAD
1371 #define dl_trace_buf _ENTITY_PREFIXED(dl_trace_buf)
1372 #endif
1373 #if defined(ALR_MAIN_C)
1374 GLOBAL char dl_trace_buf[100];
1375 #else /* ALR_MAIN_C */
1376 EXTERN char dl_trace_buf[100];
1377 #endif /* ALR_MAIN_C */
1378 #define TRACE_PL_EVENT 4
1379 #define DOES_NOT_MATTER 0
1380 #define DL_OFFLINE_TRACE(s) \
1381 dl_trace (TRACE_PL_EVENT, DOES_NOT_MATTER, DOES_NOT_MATTER, (UCHAR*)s)
1382 #else /* DL_TRACE_ENABLED */
1383 #define DL_OFFLINE_TRACE(s)
1384 #endif /* DL_TRACE_ENABLED */
1385
1386 #if !defined(NCONFIG) && !defined(NTRACE) && defined(TRACE_STATE_TRANSITION)
1387 void trc_state_transition(int line, UBYTE newstate);
1388 #else
1389 #define trc_state_transition(line,newstate)
1390 #endif /* !NCONFIG && !NTRACE && TRACE_STATE_TRANSITION */
1391
1392 #if defined(_SIMULATION_)
1393 #define TRACING
1394 #define TRACE_EVENT_WIN(s) TRACE_EVENT(s)
1395 #define TRACE_EVENT_WIN_P1(s,a1) TRACE_EVENT_P1(s,a1)
1396 #define TRACE_EVENT_WIN_P2(s,a1,a2) TRACE_EVENT_P2(s,a1,a2)
1397 #define TRACE_EVENT_WIN_P3(s,a1,a2,a3) TRACE_EVENT_P3(s,a1,a2,a3)
1398 #define TRACE_EVENT_WIN_P4(s,a1,a2,a3,a4) TRACE_EVENT_P4(s,a1,a2,a3,a4)
1399 #define TRACE_EVENT_WIN_P5(s,a1,a2,a3,a4,a5) TRACE_EVENT_P5(s,a1,a2,a3,a4,a5)
1400 #define TRACE_EVENT_WIN_P6(s,a1,a2,a3,a4,a5,a6) TRACE_EVENT_P6(s,a1,a2,a3,a4,a5,a6)
1401 #define TRACE_EVENT_WIN_P7(s,a1,a2,a3,a4,a5,a6,a7) TRACE_EVENT_P7(s,a1,a2,a3,a4,a5,a6,a7)
1402 #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)
1403 #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)
1404 #else /* _SIMULATION_ */
1405 #define TRACE_EVENT_WIN(s)
1406 #define TRACE_EVENT_WIN_P1(s,a1)
1407 #define TRACE_EVENT_WIN_P2(s,a1,a2)
1408 #define TRACE_EVENT_WIN_P3(s,a1,a2,a3)
1409 #define TRACE_EVENT_WIN_P4(s,a1,a2,a3,a4)
1410 #define TRACE_EVENT_WIN_P5(s,a1,a2,a3,a4,a5)
1411 #define TRACE_EVENT_WIN_P6(s,a1,a2,a3,a4,a5,a6)
1412 #define TRACE_EVENT_WIN_P7(s,a1,a2,a3,a4,a5,a6,a7)
1413 #define TRACE_EVENT_WIN_P8(s,a1,a2,a3,a4,a5,a6,a7,a8)
1414 #define TRACE_EVENT_WIN_P9(s,a1,a2,a3,a4,a5,a6,a7,a8,a9)
1415 #endif /* _SIMULATION_ */
1416
1417 #if defined TRACING
1418 #define ALR_TRACE(a) vsi_o_ttrace(VSI_CALLER TC_EVENT,a);
1419 #else
1420 #define ALR_TRACE(a)
1421 #endif /* TRACING */
1422
1423 #define TNNN_WITH_TIMER
1424
1425 /*
1426 #define ALR_TRACE_ENABLED
1427 */
1428 #if defined(ALR_TRACE_ENABLED)
1429 void alr_trc_init (void);
1430 void alr_trc_exit (void);
1431 void alr_trc_store (UCHAR event, UCHAR channel, UCHAR state, void* l2_data);
1432 void alr_trc_read_all (void);
1433 void alr_trc_read (int count);
1434 #else /* ALR_TRACE_ENABLED */
1435 #define alr_trc_init()
1436 #define alr_trc_exit()
1437 #define alr_trc_store(e,c,s,p)
1438 #define alr_trc_read(c)
1439 #define alr_trc_read_all()
1440 #endif /* ALR_TRACE_ENABLED */
1441
1442 /*
1443 * ALR TRACE defines
1444 */
1445 #define ALR_TRC_UPLINK 0
1446 #define ALR_TRC_DOWNLINK 1
1447 #define ALR_TRC_EVENT 2
1448 #define ALR_TRC_STRING 3
1449
1450 #define ALR_TRC_CH_UNDEF 0
1451 #define ALR_TRC_CH_FACCH_FR 1
1452 #define ALR_TRC_CH_FACCH_HR 2
1453 #define ALR_TRC_CH_SDCCH4 3
1454 #define ALR_TRC_CH_SDCCH8 4
1455 #define ALR_TRC_CH_SACCH 5
1456 #define ALR_TRC_CH_UNKNOWN 6
1457
1458 #define ALR_TRC_DATA_SIZE 40
1459
1460 #define ALR_RXLEV_AVERAGE_MIN 0
1461 #define ALR_RXLEV_AVERAGE_LWR_THR 4
1462
1463 #endif /* ALR_H */