FreeCalypso > hg > fc-selenite
comparison src/g23m-gsm/rr/rr_cs.c @ 1:d393cd9bb723
src/g23m-*: initial import from Magnetite
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 15 Jul 2018 04:40:46 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:b6a5e36de839 | 1:d393cd9bb723 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : | |
4 | Modul : | |
5 +----------------------------------------------------------------------------- | |
6 | Copyright 2002 Texas Instruments Berlin, AG | |
7 | All rights reserved. | |
8 | | |
9 | This file is confidential and a trade secret of Texas | |
10 | Instruments Berlin, AG | |
11 | The receipt of or possession of this file does not convey | |
12 | any rights to reproduce or disclose its contents or to | |
13 | manufacture, use, or sell anything it may describe, in | |
14 | whole, or in part, without the specific written consent of | |
15 | Texas Instruments Berlin, AG. | |
16 +----------------------------------------------------------------------------- | |
17 | Purpose : This module defines the functions for Cell Selection | |
18 | capability of Radio Resource. | |
19 +----------------------------------------------------------------------------- | |
20 */ | |
21 | |
22 #ifndef RR_CS_C | |
23 #define RR_CS_C | |
24 | |
25 #define ENTITY_RR | |
26 | |
27 /*==== INCLUDES ===================================================*/ | |
28 | |
29 #include <string.h> | |
30 #include <stdlib.h> | |
31 #include <stddef.h> /* offsetof */ | |
32 #include "typedefs.h" | |
33 #include "pcm.h" | |
34 #include "pconst.cdg" | |
35 #include "mconst.cdg" | |
36 #include "message.h" | |
37 #include "ccdapi.h" | |
38 #include "vsi.h" | |
39 #include "custom.h" | |
40 #include "gsm.h" | |
41 #include "prim.h" | |
42 #include "cnf_rr.h" | |
43 #include "tok.h" | |
44 #include "rr.h" | |
45 | |
46 /*==== EXPORT =====================================================*/ | |
47 | |
48 /*==== PRIVATE ====================================================*/ | |
49 static void cs_remove_co_chan (USHORT arfcn, USHORT co_arfcn); | |
50 static void cs_remove_co_channels (USHORT arfcn); | |
51 static UBYTE cs_check_channel (USHORT arfcn); | |
52 static BOOL cs_sync_next_bsic (void); | |
53 | |
54 | |
55 /*==== VARIABLES ==================================================*/ | |
56 | |
57 EXTERN UBYTE test_house; | |
58 | |
59 /*==== FUNCTIONS ==================================================*/ | |
60 | |
61 LOCAL void cs_add_current_network_to_found_list (); | |
62 LOCAL BOOL cs_check_black_list_criteria(U8 region, U16 arfcn, U8 rxlev); | |
63 LOCAL BOOL cs_is_in_black_list(U8 region, U16 arfcn); | |
64 LOCAL BOOL cs_is_in_white_list(U8 region, U16 arfcn); | |
65 LOCAL U8 cs_get_sync_fail_counter(U8 region, U16 arfcn); | |
66 LOCAL void cs_reset_sync_fail_counter(U8 region, U16 arfcn); | |
67 LOCAL void cs_inc_sync_fail_counter(U8 region, U16 arfcn); | |
68 LOCAL void cs_use_white_list_info(U8 num_of_chan); | |
69 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT | |
70 LOCAL UBYTE cs_update_std_ffs (UBYTE new_std); | |
71 #else | |
72 LOCAL UBYTE get_band_index(USHORT arfcn); | |
73 #endif | |
74 | |
75 | |
76 /* | |
77 * ------------------------------------------------------------------- | |
78 * Procedures | |
79 * ------------------------------------------------------------------- | |
80 */ | |
81 | |
82 /* | |
83 * The cell selection process bases on attributes for each channel | |
84 * of the power campaign. This attributes are defined by a bitmap | |
85 * | |
86 * Bit 1 0 priority | |
87 * --------------------------------- | |
88 * 0 0 low priority | |
89 * 0 1 mid priority | |
90 * 1 0 high priority | |
91 * 1 1 reserved | |
92 * | |
93 * The selection of a cell for synchronisation depends on | |
94 * the priority and the fieldstrength. It will be the cell | |
95 * selected, which is not checked yet, has the highest | |
96 * priority and the highest fieldstrength. | |
97 * | |
98 * Bit 2 reserved | |
99 * | |
100 * Bit 3 checked flag | |
101 * --------------------------------- | |
102 * 0 cell is not checked | |
103 * 1 cell is checked | |
104 * | |
105 * The flag indicates whether a cell is already checked or not. | |
106 * | |
107 * Bit 4 detected flag | |
108 * --------------------------------- | |
109 * 0 bcch is not detected | |
110 * 1 bcch is checked | |
111 * | |
112 * The flag indicates whether a BCCH is detected or not. | |
113 * | |
114 * Bit 5 emergency cell flag | |
115 * --------------------------------- | |
116 * 0 emergency services possible | |
117 * 1 emergency services not possible | |
118 * | |
119 * The flag indicates whether emergency services are possible or not. | |
120 * | |
121 * Bit 6 low priority cell flag | |
122 * --------------------------------- | |
123 * 0 no low priority cell | |
124 * 1 low priority cell | |
125 * | |
126 * The flag indicates whether a cell has a low priority or not. | |
127 * | |
128 * Bit 8 BCCH info list flag | |
129 * --------------------------------- | |
130 * 0 not member of the BCCH info list | |
131 * 1 member of the BCCH info list | |
132 * | |
133 * The flag indicates whether a cell is member of the BCCH information list or not. | |
134 */ | |
135 | |
136 /* | |
137 +--------------------------------------------------------------------+ | |
138 | PROJECT : GSM-PS (6147) MODULE : RR_CS | | |
139 | STATE : code ROUTINE : cs_init_process | | |
140 +--------------------------------------------------------------------+ | |
141 | |
142 PURPOSE : Initialisation of the cell selection process. | |
143 Called from 'pei_init' exclusively and rr_deactivate. | |
144 | |
145 */ | |
146 | |
147 GLOBAL void cs_init_process (void) | |
148 { | |
149 GET_INSTANCE_DATA; | |
150 TRACE_FUNCTION ("cs_init_process()"); | |
151 | |
152 /* | |
153 * set the state and clear all variables. | |
154 */ | |
155 SET_STATE (STATE_CELL_SEL, CS_NULL); | |
156 memset (&rr_data->cs_data, 0, sizeof (&rr_data->cs_data)); | |
157 | |
158 rr_data->cs_data.arfcn_sc = NOT_PRESENT_16BIT; | |
159 rr_data->cs_data.arfcn_cr = NOT_PRESENT_16BIT; | |
160 | |
161 /* CSI-LLD section:4.1.1.11 */ | |
162 rr_data->cs_data.initial_plmn_search = INITIAL_PLMN_SEARCH_NOT_ACTIVE; | |
163 | |
164 /* In all simulation testcases written prior to cell selection | |
165 * improvements feature, US_BIT and STD values were not set in | |
166 * the ARFCN field | |
167 */ | |
168 #if !defined (_SIMULATION_) | |
169 rr_data->cs_data.region = NOT_PRESENT_8BIT; | |
170 #endif | |
171 | |
172 rr_data->cs_data.white_list.last_sc_arfcn = NOT_PRESENT_16BIT; | |
173 rr_data->cs_data.white_list.region = NOT_PRESENT_8BIT; | |
174 TRACE_EVENT_P1("white_list_region %d", rr_data->cs_data.white_list.region); | |
175 | |
176 rr_data->start_cell_reselection = TRUE; | |
177 TRACE_EVENT_P1("start_cell_reselection %d", rr_data->start_cell_reselection); | |
178 | |
179 /* Dynamic configuration parameters */ | |
180 rr_data->dyn_config.bl_cs_en = TRUE; | |
181 rr_data->dyn_config.tfast_cs_val = TFAST_CS_VALUE; | |
182 rr_data->dyn_config.tnormal_cs_val = TNORMAL_CS_VALUE; | |
183 rr_data->dyn_config.lim_ser_nps_delay= DELAY_NON_PAR_SEARCH_LIM_SER; | |
184 | |
185 #if defined(_SIMULATION_FFS_) | |
186 rr_csf_ffs_init(); | |
187 #endif | |
188 } | |
189 | |
190 /* | |
191 +--------------------------------------------------------------------+ | |
192 | PROJECT : GSM-PS (6147) MODULE : RR_CS | | |
193 | STATE : code ROUTINE : cs_set_bcch_info | | |
194 +--------------------------------------------------------------------+ | |
195 | |
196 PURPOSE : The function merges bcch information from SIM to White list | |
197 database | |
198 CSI-LLD - 4.1.2.2.1 | |
199 */ | |
200 | |
201 GLOBAL void cs_set_bcch_info (T_bcch_info * sim_bcch_info) | |
202 { | |
203 GET_INSTANCE_DATA; | |
204 T_LIST tmp_list; | |
205 BUF_neigh_cell_desc cd; | |
206 | |
207 TRACE_FUNCTION ("cs_set_bcch_info()"); | |
208 | |
209 /* Check for availability of sim_bcch_info data */ | |
210 if(cs_check_region(rr_data->cs_data.white_list.region) AND | |
211 (sim_bcch_info NEQ NULL)) | |
212 { | |
213 if(sim_bcch_info->v_bcch) | |
214 { | |
215 /* Store the sim_bcch_info data to white_list structure */ | |
216 memcpy(cd.b_neigh_cell_desc,sim_bcch_info->bcch,BA_BITMAP_SIZE); | |
217 cd.o_neigh_cell_desc = 0; | |
218 cd.l_neigh_cell_desc = NCELL_DESC_BIT_LEN; | |
219 | |
220 /* Merge BCCH info into white list */ | |
221 for_create_channel_list((T_f_range *)&cd,&tmp_list); | |
222 srv_merge_list(&rr_data->cs_data.white_list.list,&tmp_list); | |
223 } | |
224 } | |
225 } | |
226 | |
227 /* | |
228 +--------------------------------------------------------------------+ | |
229 | PROJECT : GSM-PS (6147) MODULE : RR_CS | | |
230 | STATE : code ROUTINE : cs_clear_white_list | | |
231 +--------------------------------------------------------------------+ | |
232 | |
233 PURPOSE : The function clears the bcch information (neigbour cell | |
234 description) of sys info 2, 2bis and 2ter stored in RAM | |
235 and FFS. | |
236 CSI-LLD - 4.1.2.2.6 | |
237 */ | |
238 | |
239 GLOBAL void cs_clear_white_list(U8 clr_bcch_info) | |
240 { | |
241 GET_INSTANCE_DATA; | |
242 TRACE_FUNCTION ("cs_clear_white_list()"); | |
243 | |
244 if (clr_bcch_info & CLR_WHITE_LIST_SIM) | |
245 { | |
246 dat_send_bcchinfo_mm (NULL); | |
247 | |
248 TRACE_EVENT ("White List: SIM cleared"); | |
249 } | |
250 | |
251 if (clr_bcch_info & CLR_WHITE_LIST_RAM) | |
252 { | |
253 rr_data->cs_data.arfcn_sc = NOT_PRESENT_16BIT; | |
254 rr_data->cs_data.arfcn_cr = NOT_PRESENT_16BIT; | |
255 | |
256 memset(&rr_data->cs_data.white_list, 0 , sizeof(T_CS_WHITE_LIST)); | |
257 | |
258 rr_data->cs_data.white_list.last_sc_arfcn = NOT_PRESENT_16BIT; | |
259 rr_data->cs_data.white_list.region = NOT_PRESENT_8BIT; | |
260 | |
261 TRACE_EVENT ("White List: RAM cleared"); | |
262 } | |
263 | |
264 #if defined (_SIMULATION_FFS_) | |
265 if (clr_bcch_info & CLR_WHITE_LIST_FFS) | |
266 { | |
267 T_CS_WHITE_LIST white_list; | |
268 memset(&white_list,0,sizeof(T_CS_WHITE_LIST)); | |
269 | |
270 rr_data->cs_data.white_list.region = NOT_PRESENT_8BIT; | |
271 rr_data->cs_data.white_list.last_sc_arfcn = NOT_PRESENT_16BIT; | |
272 | |
273 rr_csf_write_white_list(&white_list); | |
274 | |
275 TRACE_EVENT ("White List: FFS cleared"); | |
276 } | |
277 #endif /* _SIMULATION_FFS_ */ | |
278 } | |
279 | |
280 | |
281 #if defined (_SIMULATION_FFS_) | |
282 /* | |
283 +--------------------------------------------------------------------+ | |
284 | PROJECT : GSM-PS (6147) MODULE : RR_CS | | |
285 | STATE : code ROUTINE : cs_store_white_list | | |
286 +--------------------------------------------------------------------+ | |
287 | |
288 PURPOSE : The function stores while list information to FFS. | |
289 CSI-LLD - 4.1.2.2.3 | |
290 */ | |
291 | |
292 GLOBAL void cs_store_white_list (void) | |
293 { | |
294 GET_INSTANCE_DATA; | |
295 /* Store the white List to FFS */ | |
296 rr_csf_write_white_list(&rr_data->cs_data.white_list); | |
297 } | |
298 #endif /*_SIMULATION_FFS_*/ | |
299 | |
300 /* | |
301 +--------------------------------------------------------------------+ | |
302 | PROJECT : GSM-PS (6147) MODULE : RR_CS | | |
303 | STATE : code ROUTINE : cs_use_white_list_info | | |
304 +--------------------------------------------------------------------+ | |
305 | |
306 PURPOSE : The function uses the stored white list information and | |
307 increases the priority of these channels. | |
308 CSI-LLD - 4.1.2.2.8 | |
309 */ | |
310 | |
311 LOCAL void cs_use_white_list_info(U8 num_of_chan) | |
312 { | |
313 GET_INSTANCE_DATA; | |
314 U8 i, priority; | |
315 | |
316 TRACE_FUNCTION ("cs_use_white_list_info()"); | |
317 | |
318 /* Boot Time: If white list is invalidated by the second activate_req, | |
319 * decrease priority of white list carriers in power_cnf | |
320 */ | |
321 priority = (cs_check_region(rr_data->cs_data.white_list.region)) ? | |
322 CS_HIGH_PRIORITY : CS_LOW_PRIORITY ; | |
323 | |
324 for (i=0;i<num_of_chan;i++) | |
325 { | |
326 /* | |
327 * Power cnf always contains White list carriers at the top | |
328 */ | |
329 rr_data->cs_data.attributes [i] = priority; | |
330 | |
331 TRACE_EVENT_P3 ("Whie List: change prio of [%d]%u to 0x%02x", | |
332 rr_data->cs_data.arfcn[i]&ARFCN_MASK, | |
333 i, rr_data->cs_data.attributes [i]); | |
334 } | |
335 } | |
336 | |
337 /* | |
338 +--------------------------------------------------------------------+ | |
339 | PROJECT : GSM-PS (6147) MODULE : RR_CS | | |
340 | STATE : code ROUTINE : cs_set_all | | |
341 +--------------------------------------------------------------------+ | |
342 | |
343 PURPOSE : The function clears all attributes and all stored BCCH | |
344 information. | |
345 | |
346 */ | |
347 | |
348 GLOBAL void cs_set_all (void) | |
349 { | |
350 GET_INSTANCE_DATA; | |
351 TRACE_FUNCTION ("cs_set_all()"); | |
352 | |
353 /* | |
354 * clear all attributes | |
355 */ | |
356 memset (&rr_data->cs_data.attributes, 0, sizeof (rr_data->cs_data.attributes)); | |
357 } | |
358 | |
359 /* | |
360 +--------------------------------------------------------------------+ | |
361 | PROJECT : GSM-PS (6147) MODULE : RR_CS | | |
362 | STATE : code ROUTINE : cs_set_freq_band | | |
363 +--------------------------------------------------------------------+ | |
364 | |
365 PURPOSE : This function sets the frequency band bit mask. | |
366 | |
367 */ | |
368 | |
369 GLOBAL UBYTE cs_get_freq_band (UBYTE pch_interrupt) | |
370 { | |
371 UBYTE freq_bands; | |
372 | |
373 rr_csf_get_freq_bands (&freq_bands); | |
374 | |
375 if (!pch_interrupt) | |
376 {/* | |
377 * Power measurements without PCH interruption => PLMN search | |
378 * ---------------------------------------------------------- | |
379 * In this case we use the found and set value of 'std' for the frequency | |
380 * area to mask out not available frequencies from 'freq_bands'. | |
381 * Use only frequencies of the current area. | |
382 */ | |
383 switch (std) | |
384 { | |
385 case STD_900: | |
386 freq_bands &= BAND_GSM_900; | |
387 break; | |
388 case STD_EGSM: | |
389 freq_bands &= BAND_E_GSM; /* BAND_GSM_900|BAND_E_GSM */ | |
390 break; | |
391 case STD_1900: | |
392 freq_bands &= BAND_PCS_1900; | |
393 break; | |
394 case STD_1800: | |
395 freq_bands &= BAND_DCS_1800; | |
396 break; | |
397 case STD_DUAL: | |
398 freq_bands &= BAND_DUAL; /* BAND_GSM_900|BAND_DCS_1800 */ | |
399 break; | |
400 case STD_DUAL_EGSM: | |
401 freq_bands &= BAND_DUAL_EXT; /* BAND_GSM_900|BAND_E_GSM|BAND_DCS_1800 */ | |
402 break; | |
403 case STD_850: | |
404 freq_bands &= BAND_GSM_850; | |
405 break; | |
406 case STD_DUAL_US: | |
407 freq_bands &= BAND_DUAL_US; /* BAND_GSM_850|BAND_PCS_1900 */ | |
408 break; | |
409 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT | |
410 case STD_850_1800: | |
411 freq_bands &= BAND_850_1800; /* BAND_GSM_850|BAND_DCS_1800 */ | |
412 break; | |
413 case STD_900_1900: | |
414 freq_bands &= BAND_900_1900; /* BAND_E_GSM|BAND_PCS_1900 */ | |
415 break; | |
416 case STD_850_900_1800: | |
417 freq_bands &= BAND_850_900_1800; /* BAND_E_GSM|BAND_GSM_850|BAND_DCS_1800 */ | |
418 break; | |
419 case STD_850_900_1900: | |
420 freq_bands &= BAND_850_900_1900; /* BAND_GSM_850|BAND_E_GSM|BAND_PCS_1900 */ | |
421 break; | |
422 #endif | |
423 } | |
424 } | |
425 return freq_bands; | |
426 } | |
427 | |
428 /* | |
429 +--------------------------------------------------------------------+ | |
430 | PROJECT : GSM-PS (6147) MODULE : RR_CS | | |
431 | STATE : code ROUTINE : get_band_index | | |
432 +--------------------------------------------------------------------+ | |
433 | |
434 PURPOSE : The function extracts the frequency band index from the given | |
435 'arfcn' parameter. | |
436 */ | |
437 | |
438 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT | |
439 GLOBAL UBYTE cs_get_band_index (USHORT arfcn) | |
440 #else | |
441 GLOBAL UBYTE get_band_index (USHORT arfcn) | |
442 #endif | |
443 { | |
444 UBYTE local_std = STD_GET_FROM_ARFCN(arfcn); | |
445 UBYTE sc_band; | |
446 | |
447 if(local_std EQ STD_NOT_PRESENT) | |
448 { | |
449 /* Parallel search case */ | |
450 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT | |
451 local_std = std; | |
452 #else | |
453 local_std = std_bands[std-1]; | |
454 #endif | |
455 } | |
456 | |
457 switch (local_std) | |
458 { | |
459 case STD_900: | |
460 sc_band = B_GSM_900; | |
461 break; | |
462 | |
463 case STD_EGSM: | |
464 sc_band = B_E_GSM; | |
465 break; | |
466 | |
467 case STD_1800: | |
468 sc_band = B_DCS_1800; | |
469 break; | |
470 | |
471 case STD_1900: | |
472 sc_band = B_PCS_1900; | |
473 break; | |
474 | |
475 case STD_850: | |
476 sc_band = B_GSM_850; | |
477 break; | |
478 | |
479 case STD_DUAL: | |
480 if (arfcn >= LOW_CHANNEL_1800) | |
481 sc_band = B_DCS_1800; | |
482 else | |
483 sc_band = B_GSM_900; | |
484 break; | |
485 | |
486 case STD_DUAL_EGSM: | |
487 if (arfcn >= LOW_CHANNEL_EGSM) | |
488 sc_band = B_E_GSM; | |
489 else if (arfcn >= LOW_CHANNEL_1800) | |
490 sc_band = B_DCS_1800; | |
491 else if (arfcn EQ CHANNEL_0) | |
492 sc_band = B_E_GSM; | |
493 else | |
494 sc_band = B_GSM_900; | |
495 break; | |
496 | |
497 case STD_DUAL_US: | |
498 if (arfcn >= LOW_CHANNEL_1900) | |
499 sc_band = B_PCS_1900; | |
500 else | |
501 sc_band = B_GSM_850; | |
502 break; | |
503 | |
504 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT | |
505 case STD_850_1800: | |
506 if (arfcn >= LOW_CHANNEL_1800) | |
507 sc_band = B_DCS_1800; | |
508 else | |
509 sc_band = B_GSM_850; | |
510 break; | |
511 | |
512 case STD_900_1900: | |
513 if (arfcn >= LOW_CHANNEL_EGSM) | |
514 sc_band = B_E_GSM; | |
515 else if (arfcn >= LOW_CHANNEL_1900) | |
516 sc_band = B_PCS_1900; | |
517 else if (arfcn EQ CHANNEL_0) | |
518 sc_band = B_E_GSM; | |
519 else | |
520 sc_band = B_GSM_900; | |
521 break; | |
522 | |
523 case STD_850_900_1800: | |
524 if (arfcn >= LOW_CHANNEL_EGSM) | |
525 sc_band = B_E_GSM; | |
526 else if (arfcn >= LOW_CHANNEL_1800) | |
527 sc_band = B_DCS_1800; | |
528 else if (arfcn EQ CHANNEL_0) | |
529 sc_band = B_E_GSM; | |
530 else if (arfcn >= LOW_CHANNEL_850) | |
531 sc_band = B_GSM_850; | |
532 else | |
533 sc_band = B_GSM_900; | |
534 break; | |
535 | |
536 case STD_850_900_1900: | |
537 if (arfcn >= LOW_CHANNEL_EGSM) | |
538 sc_band = B_E_GSM; | |
539 else if (arfcn >= LOW_CHANNEL_1900) | |
540 sc_band = B_PCS_1900; | |
541 else if (arfcn EQ CHANNEL_0) | |
542 sc_band = B_E_GSM; | |
543 else if (arfcn >= LOW_CHANNEL_850) | |
544 sc_band = B_GSM_850; | |
545 else | |
546 sc_band = B_GSM_900; | |
547 break; | |
548 #endif | |
549 | |
550 default: | |
551 sc_band = MAX_NUM_BANDS; | |
552 break; | |
553 } | |
554 /* this trace causes a lot of trace load; switch on only if needed | |
555 TRACE_EVENT_P3 (" [%u] std=%02x, sc_band=%02x", arfcn&ARFCN_MASK, local_std, sc_band); | |
556 */ | |
557 return sc_band; | |
558 } | |
559 | |
560 /* | |
561 +--------------------------------------------------------------------+ | |
562 | PROJECT : GSM-PS (6147) MODULE : RR_CS | | |
563 | STATE : code ROUTINE : cs_start_scan | | |
564 +--------------------------------------------------------------------+ | |
565 | |
566 PURPOSE : This function starts the scanning. The power measurements | |
567 are triggered. Power measurements means that layer 1 | |
568 performs fieldstrength measurements on all carriers and | |
569 sends a list of the best to RR back for FB/SB scanning and | |
570 BCCH reading. There are two variants: with or without | |
571 paging channel (PCH) interruption. If RR is already in | |
572 idle mode, scanning without PCH interruption is performed, | |
573 that means the MS is pageable during that time. | |
574 | |
575 */ | |
576 | |
577 GLOBAL void cs_start_scan () | |
578 { | |
579 GET_INSTANCE_DATA; | |
580 U16 arfcn; | |
581 U8 i=0; | |
582 U8 region; | |
583 PALLOC (mph_power_req, MPH_POWER_REQ);/* T_MPH_POWER_REQ */ | |
584 | |
585 TRACE_FUNCTION ("cs_start_scan()"); | |
586 | |
587 memset(mph_power_req,0,sizeof(T_MPH_POWER_REQ )); | |
588 | |
589 TIMERSTOP (TREG); | |
590 rr_data->cs_data.act_index = NOT_PRESENT_8BIT; | |
591 | |
592 switch (GET_STATE (STATE_CELL_SEL)) | |
593 { | |
594 case CS_NULL: | |
595 case CS_NULL_ACTIVE: | |
596 /* | |
597 * start power measurements with PCH interruption | |
598 */ | |
599 mph_power_req->pch_interrupt = PCH_INTERRUPT; | |
600 rr_data->first_meas_received = FALSE; | |
601 rr_data->resel_pending = FALSE; | |
602 rr_data->c_ncell_bcch = NOT_INITIALISED; | |
603 rr_data->cs_data.all_freq_area = FALSE; | |
604 /* In all simulation testcases written prior to cell selection | |
605 * improvements feature, US_BIT and STD values were not set in | |
606 * the ARFCN field | |
607 */ | |
608 #if !defined (_SIMULATION_) | |
609 rr_data->cs_data.region = NOT_PRESENT_8BIT; | |
610 #endif | |
611 | |
612 dat_att_null (); | |
613 SET_STATE (STATE_CELL_SEL, CS_NULL_ACTIVE); | |
614 | |
615 /* stop possibly parallel search and allow start of cell reselection */ | |
616 att_notify_stop_plmn_search (FALSE); | |
617 break; | |
618 | |
619 case CS_IDLE: | |
620 case CS_IDLE_ACTIVE: | |
621 /* | |
622 * start power measurements without PCH interruption. | |
623 */ | |
624 mph_power_req->pch_interrupt = NO_PCH_INTERRUPT; | |
625 SET_STATE (STATE_CELL_SEL, CS_IDLE_ACTIVE); | |
626 | |
627 /* indicate suspend state of nc monitoring in lower layer */ | |
628 rr_data->start_cell_reselection = FALSE; | |
629 TRACE_EVENT_P1("start_cell_reselection %d", rr_data->start_cell_reselection); | |
630 break; | |
631 | |
632 default: | |
633 break; | |
634 } | |
635 | |
636 #ifndef TI_PS_FF_QUAD_BAND_SUPPORT | |
637 mph_power_req->freq_bands = cs_get_freq_band (mph_power_req->pch_interrupt); | |
638 #endif | |
639 | |
640 /* CSI-LLD : 4.1.3.4.1.4 */ | |
641 /* Set the new search mode */ | |
642 mph_power_req->search_mode = CS_GET_CURRENT_SEARCH_MODE; | |
643 | |
644 /* Set Lower Rxlev threshold */ | |
645 memcpy( mph_power_req->lower_rxlevel_threshold, rr_data->dyn_config.lower_rxlev_thr, MAX_NUM_BANDS*sizeof(UBYTE)); | |
646 | |
647 /* Copy the black list information */ | |
648 for(i=0;i<MAX_REGIONS;i++) | |
649 { | |
650 srv_copy_list ((T_LIST *)&mph_power_req->black_list.list[i], | |
651 &rr_data->cs_data.black_list.list[i],sizeof(T_LIST)); | |
652 } | |
653 | |
654 /* In case of Black List search, include "grey" carriers also | |
655 * in the Black list while sending to ALR | |
656 */ | |
657 if(CS_GET_CURRENT_SEARCH_MODE EQ BLACK_LIST_SEARCH_MODE) | |
658 { | |
659 TRACE_EVENT(" Black_List_Search_Started"); | |
660 | |
661 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT | |
662 mph_power_req->freq_bands = cs_get_freq_band (FALSE); | |
663 #endif | |
664 | |
665 region = rr_data->cs_data.region; | |
666 | |
667 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT | |
668 if (region EQ BOTH_REGIONS) | |
669 { | |
670 for (i=0; i<MAX_REGIONS; i++) | |
671 { | |
672 for(arfcn=CHANNEL_0;arfcn<CHANNEL_0_INTERNAL;arfcn++) | |
673 { | |
674 /* Since Black List search is always a parallel search, "grey" carriers | |
675 * belonging to the current region only have to be added | |
676 */ | |
677 if(cs_get_sync_fail_counter(i,arfcn)) | |
678 srv_set_channel((T_LIST*)&mph_power_req->black_list.list[i],arfcn); | |
679 } | |
680 } | |
681 } | |
682 else | |
683 { | |
684 #endif | |
685 for(arfcn=CHANNEL_0;arfcn<CHANNEL_0_INTERNAL;arfcn++) | |
686 { | |
687 /* Since Black List search is always a parallel search, "grey" carriers | |
688 * belonging to the current region only have to be added | |
689 */ | |
690 if(cs_get_sync_fail_counter(region,arfcn)) | |
691 srv_set_channel((T_LIST*)&mph_power_req->black_list.list[region],arfcn); | |
692 } | |
693 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT | |
694 } | |
695 #endif | |
696 } | |
697 else | |
698 { | |
699 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT | |
700 mph_power_req->freq_bands = cs_get_freq_band (TRUE); | |
701 #endif | |
702 | |
703 TRACE_EVENT_P9 ( "White List:[%d]Reg,[%d]Arfcn, MCC/MNC r=%x%x%x/%x%x%x/%d", | |
704 rr_data->cs_data.white_list.region, | |
705 rr_data->cs_data.white_list.last_sc_arfcn, | |
706 rr_data->cs_data.white_list.last_sc_lac.mcc[0], | |
707 rr_data->cs_data.white_list.last_sc_lac.mcc[1], | |
708 rr_data->cs_data.white_list.last_sc_lac.mcc[2], | |
709 rr_data->cs_data.white_list.last_sc_lac.mnc[0], | |
710 rr_data->cs_data.white_list.last_sc_lac.mnc[1], | |
711 rr_data->cs_data.white_list.last_sc_lac.mnc[2], | |
712 rr_data->cs_data.white_list.last_sc_lac.lac); | |
713 | |
714 /* Copy white list information | |
715 * White list cannot be used, when the region it belongs to, is not known | |
716 * or its PLMN ID does not match with the requested PLMN | |
717 */ | |
718 if((!cs_check_region(rr_data->cs_data.white_list.region)) OR | |
719 ((rr_data->ms_data.req_mm_service NEQ FUNC_PLMN_SRCH) AND | |
720 (GET_STATE(STATE_ATT) NEQ ATT_CS_INIT)) OR | |
721 ((rr_data->ms_data.req_mm_service EQ FUNC_PLMN_SRCH) AND | |
722 (!dat_plmn_equal_req(rr_data->cs_data.white_list.last_sc_lac.mcc, | |
723 rr_data->cs_data.white_list.last_sc_lac.mnc, | |
724 rr_data->ms_data.plmn.mcc, | |
725 rr_data->ms_data.plmn.mnc)))) | |
726 { | |
727 TRACE_EVENT("White List is not used"); | |
728 } | |
729 else | |
730 { | |
731 /* Copy the white list information */ | |
732 srv_copy_list((T_LIST*)&mph_power_req->white_list.list, | |
733 &rr_data->cs_data.white_list.list,sizeof (T_LIST)); | |
734 | |
735 /* Set the region */ | |
736 mph_power_req->white_list.region = rr_data->cs_data.white_list.region; | |
737 | |
738 /* White list is valid */ | |
739 mph_power_req->white_list.white_list_valid = TRUE; | |
740 | |
741 } | |
742 } | |
743 | |
744 /* Handle the search mode timers based on the new search mode */ | |
745 cs_handle_search_mode_timer(CS_GET_CURRENT_SEARCH_MODE); | |
746 | |
747 /* | |
748 * reset the time for net search to finish | |
749 * a PLMN available search during 35 seconds. | |
750 */ | |
751 if( rr_data->ms_data.req_mm_service EQ FUNC_NET_SRCH_BY_MMI) | |
752 TIMERSTART(T_PLMN_SEARCH, T_PLMN_SEARCH_VALUE); | |
753 | |
754 /* | |
755 * start power measurements in layer 1. | |
756 */ | |
757 TRACE_EVENT_P2 ("cs_start_scan(): freq_bands=%02x Search Mode = %d", | |
758 mph_power_req->freq_bands,mph_power_req->search_mode); | |
759 | |
760 PSENDX (PL, mph_power_req); | |
761 } | |
762 | |
763 /* | |
764 +--------------------------------------------------------------------+ | |
765 | PROJECT : GSM-PS (6147) MODULE : RR_CS | | |
766 | STATE : code ROUTINE : cs_start_sync | | |
767 +--------------------------------------------------------------------+ | |
768 | |
769 PURPOSE : Start the synchronisation to FB/SB without power measurements. | |
770 Synchronisation to the frequency correction burst (FB) followed | |
771 by a synchronisation to the synchron burst (SB) is carried | |
772 out by layer 1. It means that the MS is synchronised to the | |
773 base station and then able to read the BCCH to check the cell. | |
774 | |
775 */ | |
776 | |
777 GLOBAL void cs_start_sync (void) | |
778 { | |
779 GET_INSTANCE_DATA; | |
780 UBYTE i; | |
781 | |
782 TRACE_FUNCTION ("cs_start_sync()"); | |
783 | |
784 /* While scanning for limited service, we scan all carriers */ | |
785 if((CS_GET_PREVIOUS_SEARCH_MODE NEQ FAST_SEARCH_MODE) AND | |
786 (rr_data->cs_data.scan_mode EQ CS_SECOND_SCAN)) | |
787 { | |
788 for (i=0;i<rr_data->cs_data.max_arfcn;i++) | |
789 /* | |
790 * reset check bit for all channels | |
791 */ | |
792 rr_data->cs_data.attributes[i] &= CS_NON_CHECKED_BITS; | |
793 } | |
794 | |
795 if (cs_sync_next_bsic () EQ FALSE) | |
796 { | |
797 /* | |
798 * indicate the end of scanning to attachment process | |
799 */ | |
800 TIMERSTOP(T_PLMN_SEARCH); | |
801 att_no_bsic_ind (); | |
802 } | |
803 else | |
804 { | |
805 /* | |
806 * Another FB/SB scan is requested | |
807 */ | |
808 SET_STATE (STATE_CELL_SEL, CS_IDLE_ACTIVE); | |
809 } | |
810 } | |
811 | |
812 | |
813 /* | |
814 +--------------------------------------------------------------------+ | |
815 | PROJECT : GSM-PS (6147) MODULE : RR_CS | | |
816 | STATE : code ROUTINE : cs_del_list | | |
817 +--------------------------------------------------------------------+ | |
818 | |
819 PURPOSE : A list of carriers (neighbourcell list) is used to speed up | |
820 the cell selection process. All members of the list and the | |
821 list of the power campaign are set to low priority. | |
822 | |
823 */ | |
824 | |
825 GLOBAL void cs_del_list (T_LIST *list) | |
826 { | |
827 GET_INSTANCE_DATA; | |
828 UBYTE i; | |
829 | |
830 TRACE_FUNCTION ("cs_del_list()"); | |
831 | |
832 /* | |
833 * for all cells of the power campaign list | |
834 */ | |
835 | |
836 for (i=0;i<rr_data->cs_data.max_arfcn;i++) | |
837 { | |
838 /* | |
839 * if they are member of the given list and not just checked | |
840 */ | |
841 if (srv_get_channel (list, (USHORT)(rr_data->cs_data.arfcn[i]&ARFCN_MASK)) AND | |
842 rr_data->cs_data.act_index NEQ i) | |
843 { | |
844 /* | |
845 * set to low priority | |
846 */ | |
847 rr_data->cs_data.attributes [i] &= CS_SET_TO_LOW_PRIORITY; | |
848 /*TRACE_EVENT_P1("[%u] del from list",rr_data->cs_data.arfcn[i]);*/ | |
849 } | |
850 } | |
851 } | |
852 | |
853 /* | |
854 +--------------------------------------------------------------------+ | |
855 | PROJECT : GSM-PS (6147) MODULE : RR_CS | | |
856 | STATE : code ROUTINE : cs_set_list | | |
857 +--------------------------------------------------------------------+ | |
858 | |
859 PURPOSE : A list of carriers (neighbourcell list) is used to speed up | |
860 the cell selection process. All members of the list and the | |
861 list of the power campaign are set to high priority. | |
862 | |
863 | |
864 */ | |
865 | |
866 GLOBAL void cs_set_list (T_LIST *list) | |
867 { | |
868 GET_INSTANCE_DATA; | |
869 UBYTE i; | |
870 | |
871 TRACE_FUNCTION ("cs_set_list()"); | |
872 | |
873 /* | |
874 * Not in the test house | |
875 */ | |
876 if (rr_data->cell_test_operation OR | |
877 dat_test_sim_available ()) | |
878 return; | |
879 | |
880 /* | |
881 * for all channels in the power campaign list | |
882 */ | |
883 for (i=0;i<rr_data->cs_data.max_arfcn;i++) | |
884 { | |
885 /* | |
886 * if they are also member of the given list | |
887 */ | |
888 if (srv_get_channel (list, (USHORT)(rr_data->cs_data.arfcn[i]&ARFCN_MASK))) | |
889 { | |
890 /* | |
891 * set to high priority | |
892 */ | |
893 rr_data->cs_data.attributes [i] &= CS_SET_TO_LOW_PRIORITY; | |
894 rr_data->cs_data.attributes [i] += CS_HIGH_PRIORITY; | |
895 } | |
896 } | |
897 } | |
898 | |
899 /* | |
900 +--------------------------------------------------------------------+ | |
901 | PROJECT : GSM-PS (6147) MODULE : RR_CS | | |
902 | STATE : code ROUTINE : cs_def_list | | |
903 +--------------------------------------------------------------------+ | |
904 | |
905 PURPOSE : Checks whether a member of the list has the requested | |
906 attributes (e.g. emergency or low priority cell) | |
907 | |
908 */ | |
909 | |
910 GLOBAL UBYTE cs_def_list (UBYTE attribute) | |
911 { | |
912 GET_INSTANCE_DATA; | |
913 UBYTE i; | |
914 UBYTE result = FALSE; | |
915 | |
916 TRACE_FUNCTION ("cs_def_list()"); | |
917 | |
918 /* | |
919 * for all channels of the power campaign list | |
920 */ | |
921 for (i=0;i<rr_data->cs_data.max_arfcn;i++) | |
922 { | |
923 | |
924 /* | |
925 * check only cells which have high/mid priority | |
926 */ | |
927 if ((rr_data->cs_data.attributes [i] & CS_CHECK_FLAG) EQ 0 AND | |
928 (rr_data->cs_data.attributes [i] & CS_PRIORITY) NEQ 0) | |
929 /* | |
930 * channel is not checked yet, so it is possible that | |
931 * the channel has this attribute | |
932 */ | |
933 { | |
934 rr_data->cs_data.attributes [i] = CS_MID_PRIORITY; | |
935 result = TRUE; | |
936 } | |
937 | |
938 /* | |
939 * check the attribute of the cell. If an attribute | |
940 * like emergency or low priority cell is set, the channel | |
941 * has been checked. | |
942 */ | |
943 if (rr_data->cs_data.attributes[i] & attribute) | |
944 { | |
945 /* | |
946 * channel has this attribute, then set priority to high | |
947 */ | |
948 rr_data->cs_data.attributes [i] &= CS_SET_TO_LOW_PRIORITY; | |
949 rr_data->cs_data.attributes [i] += CS_HIGH_PRIORITY; | |
950 | |
951 /* reset check bit for this channel */ | |
952 rr_data->cs_data.attributes[i] &= CS_NON_CHECKED_BITS; | |
953 result = TRUE; | |
954 } | |
955 } | |
956 | |
957 return result; | |
958 } | |
959 | |
960 /* | |
961 +--------------------------------------------------------------------+ | |
962 | PROJECT : GSM-PS (6147) MODULE : RR_CS | | |
963 | STATE : code ROUTINE : cs_sync_next | | |
964 +--------------------------------------------------------------------+ | |
965 | |
966 PURPOSE : The function starts the next FB/SB synchronisation request. | |
967 It selects the channel with the highest priority and field- | |
968 strength which is not checked yet. | |
969 | |
970 */ | |
971 | |
972 GLOBAL BOOL cs_sync_next (void) | |
973 { | |
974 GET_INSTANCE_DATA; | |
975 TRACE_FUNCTION ("cs_sync_next()"); | |
976 | |
977 /* | |
978 * no further channel is possible | |
979 */ | |
980 if (cs_sync_next_bsic () EQ FALSE) | |
981 { | |
982 /* | |
983 * stop any timer which controls cell selection | |
984 */ | |
985 TIMERSTOP (T_RESELECT); | |
986 SET_STATE (STATE_CELL_SEL, CS_IDLE); | |
987 | |
988 /* | |
989 * indicate end of search to attachment process | |
990 */ | |
991 TIMERSTOP(T_PLMN_SEARCH); | |
992 att_no_bsic_ind (); | |
993 | |
994 return FALSE; | |
995 } | |
996 | |
997 return TRUE; | |
998 } | |
999 | |
1000 /* | |
1001 +--------------------------------------------------------------------+ | |
1002 | PROJECT : GSM-PS (6147) MODULE : RR_CS | | |
1003 | STATE : code ROUTINE : cs_sync_next_bsic | | |
1004 +--------------------------------------------------------------------+ | |
1005 | |
1006 PURPOSE : The function looks for the next candidate for a FB/SB | |
1007 sync request. The channel is not checked yet, has the | |
1008 highest priority and the highest fieldstrength. | |
1009 Return TRUE if another MPH_BSIC_REQ is sent. | |
1010 */ | |
1011 | |
1012 static BOOL cs_sync_next_bsic (void) | |
1013 { | |
1014 GET_INSTANCE_DATA; | |
1015 UBYTE i; | |
1016 UBYTE x = NOT_PRESENT_8BIT; | |
1017 | |
1018 TRACE_FUNCTION ("cs_sync_next_bsic()"); | |
1019 | |
1020 /* | |
1021 * try to use 'found channel' from previous cell selection | |
1022 */ | |
1023 | |
1024 if( rr_data->found_channel NEQ NOT_PRESENT_16BIT ) | |
1025 { | |
1026 for ( i = 0; i < rr_data->cs_data.max_arfcn; i++ ) | |
1027 { | |
1028 if ( ((rr_data->cs_data.arfcn[i] & ARFCN_MASK) EQ | |
1029 (rr_data->found_channel & ARFCN_MASK)) AND | |
1030 ((rr_data->cs_data.arfcn[i] & US_BIT) EQ | |
1031 (rr_data->found_channel & US_BIT)) AND | |
1032 (rr_data->cs_data.attributes[i] & CS_CHECK_FLAG) EQ 0) | |
1033 { | |
1034 TRACE_EVENT ( "rr_found_channel in CS_DATA" ); | |
1035 rr_data->found_channel = NOT_PRESENT_16BIT; | |
1036 x = i; | |
1037 break; | |
1038 } | |
1039 } | |
1040 } | |
1041 | |
1042 /* | |
1043 * for all channels of the power campaign list | |
1044 */ | |
1045 if ( x EQ NOT_PRESENT_8BIT ) | |
1046 { | |
1047 for ( i=0; i < rr_data->cs_data.max_arfcn; i++ ) | |
1048 { | |
1049 if ((rr_data->cs_data.attributes[i] & CS_CHECK_FLAG) EQ 0) | |
1050 { | |
1051 /* | |
1052 * channel is not checked yet | |
1053 */ | |
1054 if (x EQ NOT_PRESENT_8BIT) | |
1055 { | |
1056 /* | |
1057 * first channel which is not checked yet | |
1058 */ | |
1059 x = i; | |
1060 | |
1061 /* High priority cell. Start sync */ | |
1062 if((rr_data->cs_data.attributes[i] & CS_PRIORITY) EQ CS_HIGH_PRIORITY) | |
1063 break; | |
1064 } | |
1065 else | |
1066 { | |
1067 if ((rr_data->cs_data.attributes[i] & CS_PRIORITY) > | |
1068 (rr_data->cs_data.attributes[x] & CS_PRIORITY)) | |
1069 { | |
1070 /* | |
1071 * new channel has higher priority | |
1072 */ | |
1073 x = i; | |
1074 } | |
1075 } | |
1076 } /* CS_CHECK FLAG */ | |
1077 } /* i < max_arfcn */ | |
1078 } /* x NEQ NOT_PRESENT_8BIT */ | |
1079 | |
1080 if (x NEQ NOT_PRESENT_8BIT) | |
1081 { | |
1082 rr_data->cs_data.act_index = x; | |
1083 | |
1084 if ((rr_data->ms_data.rr_service NEQ NO_SERVICE) AND | |
1085 (rr_data->cs_data.arfcn[x] EQ rr_data->nc_data[SC_INDEX].arfcn)) | |
1086 { | |
1087 /* | |
1088 * Synchronization request for serving cell. | |
1089 * No need to send MPH_BSIC_REQ as we are already synchronized to | |
1090 * serving cell, instead fake MPH_BSIC_CNF. | |
1091 */ | |
1092 PALLOC (mph_bsic_cnf, MPH_BSIC_CNF); /* T_MPH_BSIC_CNF */ | |
1093 mph_bsic_cnf->arfcn = rr_data->cs_data.arfcn[x]; | |
1094 mph_bsic_cnf->bsic = rr_data->nc_data[SC_INDEX].bsic; | |
1095 mph_bsic_cnf->cs = CS_NO_ERROR; | |
1096 if (srv_store_prim ((T_PRIM *)D2P(mph_bsic_cnf))) | |
1097 { | |
1098 TRACE_EVENT ("Shortcut for sync to SC taken"); | |
1099 USE_STORED_ENTRIES(); | |
1100 return TRUE; | |
1101 } | |
1102 else | |
1103 { | |
1104 /* In the unlikely event that we could not store the primitive */ | |
1105 PFREE (mph_bsic_cnf); | |
1106 } | |
1107 } | |
1108 else | |
1109 { | |
1110 | |
1111 /* | |
1112 *start BSIC Reading;For fast search, the first scan is only on reasonably strong carriers.i.e carrires with rxlev>MEDIUM_RXLEV_THRESHOLD | |
1113 *This is as per the cell selection improvements document. Hence dont send BSIC request on white listed low power carrires for first scan. | |
1114 *(OMAPS00109145)*/ | |
1115 if( (rr_data->cs_data.previous_search_mode EQ FAST_SEARCH_MODE) AND (rr_data->cs_data.scan_mode NEQ CS_SECOND_SCAN) AND ( rr_data->cs_data.rxlev[x]<MEDIUM_RXLEV_THRESHOLD)) | |
1116 return FALSE; | |
1117 else | |
1118 { | |
1119 PALLOC (mph_bsic_req, MPH_BSIC_REQ); | |
1120 | |
1121 mph_bsic_req->arfcn = rr_data->cs_data.arfcn[x]; | |
1122 | |
1123 TRACE_EVENT_P3 ("BSIC REQ[%u]%u a=0x%x", | |
1124 rr_data->cs_data.arfcn[x] & ARFCN_MASK, | |
1125 x, rr_data->cs_data.attributes[x]); | |
1126 | |
1127 PSENDX (PL, mph_bsic_req); | |
1128 } | |
1129 return TRUE; | |
1130 } | |
1131 } | |
1132 else | |
1133 return FALSE; | |
1134 } | |
1135 | |
1136 /* | |
1137 +--------------------------------------------------------------------+ | |
1138 | PROJECT : GSM-PS (6147) MODULE : RR_CS | | |
1139 | STATE : code ROUTINE : cs_set_null | | |
1140 +--------------------------------------------------------------------+ | |
1141 | |
1142 PURPOSE : Initialize the cell selection process. | |
1143 | |
1144 */ | |
1145 | |
1146 GLOBAL void cs_set_null (void) | |
1147 { | |
1148 GET_INSTANCE_DATA; | |
1149 TRACE_FUNCTION ("cs_set_null()"); | |
1150 | |
1151 SET_STATE (STATE_CELL_SEL, CS_NULL); | |
1152 } | |
1153 | |
1154 /* | |
1155 +--------------------------------------------------------------------+ | |
1156 | PROJECT : GSM-PS (6147) MODULE : RR_CS | | |
1157 | STATE : code ROUTINE : cs_set_stop_active | | |
1158 +--------------------------------------------------------------------+ | |
1159 | |
1160 PURPOSE : The function resets the state of the cell selection | |
1161 process to an non-active state. | |
1162 | |
1163 */ | |
1164 | |
1165 GLOBAL void cs_set_stop_active (void) | |
1166 { | |
1167 GET_INSTANCE_DATA; | |
1168 TRACE_FUNCTION ("cs_set_stop_active()"); | |
1169 | |
1170 switch (GET_STATE(STATE_CELL_SEL)) | |
1171 { | |
1172 case CS_NULL: | |
1173 case CS_NULL_ACTIVE: | |
1174 SET_STATE (STATE_CELL_SEL, CS_NULL); | |
1175 break; | |
1176 case CS_IDLE: | |
1177 case CS_IDLE_ACTIVE: | |
1178 SET_STATE (STATE_CELL_SEL, CS_IDLE); | |
1179 break; | |
1180 } | |
1181 } | |
1182 | |
1183 /* | |
1184 +--------------------------------------------------------------------+ | |
1185 | PROJECT : GSM-PS (6147) MODULE : RR_CS | | |
1186 | STATE : code ROUTINE : cs_set_attributes | | |
1187 +--------------------------------------------------------------------+ | |
1188 | |
1189 PURPOSE : The function sets an attribute for a channel (e.g. | |
1190 emergency or low priority cell). | |
1191 | |
1192 */ | |
1193 | |
1194 GLOBAL void cs_set_attributes (UBYTE attribute, USHORT arfcn) | |
1195 { | |
1196 GET_INSTANCE_DATA; | |
1197 UBYTE i; | |
1198 | |
1199 TRACE_FUNCTION ("cs_set_attributes()"); | |
1200 | |
1201 /* | |
1202 * for all channels of the power campaign list | |
1203 */ | |
1204 for (i=0;i<rr_data->cs_data.max_arfcn;i++) | |
1205 { | |
1206 /* | |
1207 * if it is the given channel number, set the attributes. | |
1208 */ | |
1209 if ((rr_data->cs_data.arfcn[i]&ARFCN_MASK) EQ arfcn) | |
1210 rr_data->cs_data.attributes [i] |= attribute; | |
1211 } | |
1212 } | |
1213 | |
1214 /* | |
1215 +--------------------------------------------------------------------+ | |
1216 | PROJECT : GSM-PS (6147) MODULE : RR_CS | | |
1217 | STATE : code ROUTINE : cs_set_rxlev | | |
1218 +--------------------------------------------------------------------+ | |
1219 | |
1220 PURPOSE : Updating of a fieldstrength value in the list of the | |
1221 power campaign. | |
1222 | |
1223 */ | |
1224 | |
1225 GLOBAL void cs_set_rxlev (UBYTE rxlev, USHORT arfcn) | |
1226 { | |
1227 GET_INSTANCE_DATA; | |
1228 UBYTE i; | |
1229 | |
1230 TRACE_FUNCTION ("cs_set_rxlev()"); | |
1231 | |
1232 /* | |
1233 * for all channels in the power campaign list | |
1234 */ | |
1235 for (i=0;i<rr_data->cs_data.max_arfcn;i++) | |
1236 { | |
1237 /* | |
1238 * if it is the given channel number, update the fieldstrength. | |
1239 */ | |
1240 if ((rr_data->cs_data.arfcn[i]&ARFCN_MASK) EQ arfcn) | |
1241 rr_data->cs_data.rxlev [i] = rxlev; | |
1242 } | |
1243 } | |
1244 | |
1245 /* | |
1246 +--------------------------------------------------------------------+ | |
1247 | PROJECT : GSM-PS (6147) MODULE : RR_CS | | |
1248 | STATE : code ROUTINE : cs_clear_attributes | | |
1249 +--------------------------------------------------------------------+ | |
1250 | |
1251 PURPOSE : The function clears an attribute for a channel (e.g. | |
1252 emergency or low priority cell). | |
1253 | |
1254 */ | |
1255 | |
1256 GLOBAL void cs_clear_attributes (UBYTE attribute, USHORT arfcn) | |
1257 { | |
1258 GET_INSTANCE_DATA; | |
1259 UBYTE i; | |
1260 | |
1261 TRACE_FUNCTION ("cs_clear_attributes()"); | |
1262 | |
1263 /* | |
1264 * for all channels in the power campaign list | |
1265 */ | |
1266 for (i=0;i<rr_data->cs_data.max_arfcn;i++) | |
1267 { | |
1268 /* | |
1269 * if it is the given channel number, clear the attributes. | |
1270 */ | |
1271 if ((rr_data->cs_data.arfcn[i]&ARFCN_MASK) EQ arfcn) | |
1272 rr_data->cs_data.attributes [i] &= ~attribute; | |
1273 } | |
1274 } | |
1275 | |
1276 /* | |
1277 +--------------------------------------------------------------------+ | |
1278 | PROJECT : GSM-PS (6147) MODULE : RR_CS | | |
1279 | STATE : code ROUTINE : cs_mph_power_cnf | | |
1280 +--------------------------------------------------------------------+ | |
1281 | |
1282 PURPOSE : The result of a power request to layer 1. Layer 1 returns | |
1283 a list of up to 40 GSM 900 + 40 DCS 1800 channels to RR. | |
1284 | |
1285 */ | |
1286 | |
1287 GLOBAL void cs_mph_power_cnf (T_MPH_POWER_CNF * mph_power_cnf) | |
1288 { | |
1289 GET_INSTANCE_DATA; | |
1290 UBYTE i,j,rxlev; | |
1291 USHORT mask = 0xFFFF; /* no mask */ | |
1292 U8 x; | |
1293 BOOL copy = TRUE; | |
1294 | |
1295 TRACE_FUNCTION ("cs_mph_power_cnf()"); | |
1296 | |
1297 if(GET_STATE(STATE_ATT) EQ ATT_CS_INIT ) | |
1298 { | |
1299 if( !srv_store_prim ((T_PRIM *)D2P(mph_power_cnf)) ) | |
1300 { | |
1301 /* | |
1302 * primitive storing failed | |
1303 */ | |
1304 PFREE (mph_power_cnf); | |
1305 SET_STATE(STATE_CELL_SEL, CS_NULL); | |
1306 SET_STATE(STATE_ATT, ATT_NULL); | |
1307 } | |
1308 else | |
1309 { | |
1310 /* | |
1311 * Boot Time: Do not store primitive for more than 10 s in case | |
1312 * of quick registration. If the second activate_req does not | |
1313 * come before this time move to ATT_NULL. | |
1314 * The T_RESELECT timer is used for a different purpose here. | |
1315 */ | |
1316 TIMERSTART(T_RESELECT, TRESELECT_VALUE); | |
1317 } | |
1318 return; | |
1319 } | |
1320 | |
1321 TRACE_EVENT_P1 ("mph_power_cnf: %u freq.", mph_power_cnf->num_of_chan); | |
1322 | |
1323 for (i = 0; i < mph_power_cnf->num_of_chan; i++) | |
1324 { | |
1325 TRACE_EVENT_P3("[%4u] std=%u rx_lev=%2u", | |
1326 mph_power_cnf->arfcn[i]&ARFCN_MASK, | |
1327 STD_GET_FROM_ARFCN(mph_power_cnf->arfcn[i]), | |
1328 mph_power_cnf->rx_lev[i]); | |
1329 } | |
1330 | |
1331 /* Remove the inactive carriers from Black List */ | |
1332 if((CS_GET_CURRENT_SEARCH_MODE EQ BLACK_LIST_SEARCH_MODE) OR | |
1333 (mph_power_cnf->num_of_chan)) | |
1334 { | |
1335 /* In case of "Full", "Normal" and "Fast" search modes, remove | |
1336 * inactive carriers from Black List, only when there is atleast | |
1337 * one strong carrier in that area | |
1338 */ | |
1339 cs_rem_inactive_carriers_from_bl(mph_power_cnf); | |
1340 } | |
1341 | |
1342 if(CS_GET_CURRENT_SEARCH_MODE NEQ BLACK_LIST_SEARCH_MODE) | |
1343 { | |
1344 /* Update previous search mode */ | |
1345 CS_SET_PREVIOUS_SEARCH_MODE(CS_GET_CURRENT_SEARCH_MODE); | |
1346 | |
1347 switch (GET_STATE(STATE_CELL_SEL)) | |
1348 { | |
1349 case CS_IDLE_ACTIVE: | |
1350 /* We will start parallel scan in 2 cases | |
1351 1. After HPLMN timer expiry | |
1352 2. After TREG timer expiry | |
1353 In these both cases don't mask out std and US_BIT | |
1354 */ | |
1355 #ifndef TI_PS_FF_QUAD_BAND_SUPPORT | |
1356 mask = ARFCN_MASK; /* for parallel search mask out 'std' and US_BIT. */ | |
1357 #endif | |
1358 /*lint -fallthrough*/ | |
1359 case CS_NULL_ACTIVE: | |
1360 /* | |
1361 * copy channel list from layer 1, set the number | |
1362 * of entries in the list | |
1363 */ | |
1364 rr_data->cs_data.max_arfcn = mph_power_cnf->num_of_chan; | |
1365 | |
1366 /* | |
1367 * for all channels coming from layer 1 | |
1368 */ | |
1369 for (i=0,j=0;i<mph_power_cnf->num_of_chan;i++) | |
1370 { | |
1371 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT | |
1372 x = cs_get_band_index(mph_power_cnf->arfcn[i]); | |
1373 #else | |
1374 x = get_band_index(mph_power_cnf->arfcn[i]); | |
1375 #endif | |
1376 | |
1377 /* for OMAPS00109145, in which the I-Sample is not camping on to the agilent ,once down link failure is | |
1378 occured on current cell and at power levels < -100dB, this is because in the fast search mode we are not | |
1379 considering the low rxlev carriers. So this modification is required in order to come back to the network | |
1380 even after a down link failure has happened and if another BCCH carrer of less power become active and available | |
1381 for the mobile to camp */ | |
1382 | |
1383 rxlev = rr_data->dyn_config.lower_rxlev_thr[x]; | |
1384 copy = TRUE; | |
1385 | |
1386 if((i >= mph_power_cnf->num_of_white_list_chan) AND | |
1387 (mph_power_cnf->rx_lev[i] < rxlev)) | |
1388 | |
1389 { | |
1390 copy = FALSE; | |
1391 } | |
1392 | |
1393 /* | |
1394 * check against band restrictions | |
1395 */ | |
1396 if (copy AND cs_check_channel ((USHORT)(mph_power_cnf->arfcn[i]&ARFCN_MASK))) | |
1397 { | |
1398 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT | |
1399 /* For parallel search mask serving cell */ | |
1400 if ((GET_STATE(STATE_CELL_SEL) EQ CS_IDLE_ACTIVE) AND (rr_data->nc_data[SC_INDEX].arfcn EQ (mph_power_cnf->arfcn[i]&ARFCN_MASK))) | |
1401 rr_data->cs_data.arfcn[j] = mph_power_cnf->arfcn[i]&ARFCN_MASK; | |
1402 else | |
1403 #endif | |
1404 rr_data->cs_data.arfcn[j] = mph_power_cnf->arfcn[i]&mask; | |
1405 rr_data->cs_data.rxlev[j] = mph_power_cnf->rx_lev[i]; | |
1406 /* | |
1407 * set initial to middle priority | |
1408 */ | |
1409 rr_data->cs_data.attributes [j++] = CS_MID_PRIORITY; | |
1410 } | |
1411 else | |
1412 { | |
1413 /* | |
1414 * a cell is not copied due to band restrictions | |
1415 */ | |
1416 rr_data->cs_data.max_arfcn--; | |
1417 } | |
1418 } | |
1419 | |
1420 TRACE_EVENT_P2("No_chan > [%d]min_rxlev copied:%d",rxlev,rr_data->cs_data.max_arfcn); | |
1421 | |
1422 /* Increase the priority of white list carriers */ | |
1423 if(rr_data->cs_data.max_arfcn ) | |
1424 cs_use_white_list_info(mph_power_cnf->num_of_white_list_chan); | |
1425 | |
1426 /* | |
1427 * add actual PLMN to the found list, if available | |
1428 */ | |
1429 if (rr_data->ms_data.req_mm_service EQ FUNC_NET_SRCH_BY_MMI AND | |
1430 GET_STATE(STATE_ATT) EQ ATT_IDLE AND | |
1431 (!rr_data->net_lost)) | |
1432 cs_add_current_network_to_found_list (); | |
1433 | |
1434 /* | |
1435 * Select channel with the highest fieldstrength and priority | |
1436 * and start BSIC scanning, else send signal that no further | |
1437 * channel is available | |
1438 */ | |
1439 if (cs_sync_next_bsic () EQ FALSE) | |
1440 { | |
1441 SET_STATE (STATE_CELL_SEL, CS_IDLE); | |
1442 TIMERSTOP(T_PLMN_SEARCH); | |
1443 att_no_bsic_ind (); | |
1444 } | |
1445 else | |
1446 { | |
1447 SET_STATE (STATE_CELL_SEL, CS_IDLE_ACTIVE); | |
1448 } | |
1449 | |
1450 /* | |
1451 * CS power measurements may be used to reorder arfcns'n in | |
1452 * MPH_NEIGHBOURCELL_REQ while TCSVALID is running | |
1453 */ | |
1454 TIMERSTART(TCSVALID, THIRTY_SEC); | |
1455 break; | |
1456 } | |
1457 } /* NEQ black list search */ | |
1458 else | |
1459 { | |
1460 | |
1461 /* Stop the parallel PLMN search */ | |
1462 att_notify_stop_plmn_search(FALSE); | |
1463 | |
1464 SET_STATE (STATE_CELL_SEL, CS_IDLE); | |
1465 | |
1466 /* Black list search is a temporary search. It is not used | |
1467 * in deciding the next search. Hence we need to update current search | |
1468 * mode when Black List search is over */ | |
1469 CS_SET_CURRENT_SEARCH_MODE(CS_GET_PREVIOUS_SEARCH_MODE); | |
1470 | |
1471 | |
1472 } /* Black list search */ | |
1473 | |
1474 PFREE (mph_power_cnf); | |
1475 srv_use_stored_prim (); | |
1476 } | |
1477 | |
1478 /* | |
1479 +--------------------------------------------------------------------+ | |
1480 | PROJECT : GSM-PS (6147) MODULE : RR_CS | | |
1481 | STATE : code ROUTINE : cs_mph_bsic_cnf | | |
1482 +--------------------------------------------------------------------+ | |
1483 | |
1484 PURPOSE : The response of a FB/SB synchronisation request from layer 1. | |
1485 | |
1486 */ | |
1487 | |
1488 GLOBAL void cs_mph_bsic_cnf (T_MPH_BSIC_CNF * mph_bsic_cnf) | |
1489 { | |
1490 GET_INSTANCE_DATA; | |
1491 U8 local_region; | |
1492 U16 local_arfcn; | |
1493 | |
1494 TRACE_FUNCTION ("cs_mph_bsic_cnf()"); | |
1495 | |
1496 switch (GET_STATE (STATE_CELL_SEL)) | |
1497 { | |
1498 case CS_IDLE_ACTIVE: | |
1499 if (mph_bsic_cnf->cs EQ CS_NO_ERROR) | |
1500 { | |
1501 UBYTE new_std = STD_GET_FROM_ARFCN(mph_bsic_cnf->arfcn); | |
1502 /* | |
1503 * FB / SB is decoded, cell has the attributes | |
1504 * BCCH detected and checked | |
1505 */ | |
1506 /* | |
1507 * reset std from the current MPH_BSIC_CNF(only if it is non-zero) | |
1508 */ | |
1509 TRACE_EVENT_P2("reset std: new_std = %d, old_std = %d", new_std, std); | |
1510 if(new_std) | |
1511 { | |
1512 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT | |
1513 UBYTE new_region; | |
1514 | |
1515 std = cs_update_std_ffs (new_std); | |
1516 new_region = srv_get_region_from_std(std); | |
1517 TRACE_EVENT_P1("update std: new_std = %d", std); | |
1518 #else | |
1519 UBYTE new_region = srv_get_region_from_std(new_std); | |
1520 | |
1521 std = new_std; | |
1522 #endif | |
1523 | |
1524 /* Both American and European bands are detected in the current | |
1525 * region. Following TREG timer expiry in Limited Service state, | |
1526 * non-parallel search will be issued | |
1527 * CSI-LLD section:4.3 | |
1528 */ | |
1529 if(rr_data->cs_data.region NEQ NOT_PRESENT_8BIT) | |
1530 { | |
1531 if(rr_data->cs_data.region NEQ new_region) | |
1532 { | |
1533 rr_data->cs_data.all_freq_area = TRUE; | |
1534 TRACE_EVENT("all_freq_area : 1"); | |
1535 } | |
1536 | |
1537 } | |
1538 | |
1539 /* CSI-LLD section:4.1.1.3.12 | |
1540 * This stores region in rr_data base by extracting from std | |
1541 */ | |
1542 rr_data->cs_data.region = new_region; | |
1543 } | |
1544 /* | |
1545 * remove co channels | |
1546 */ | |
1547 if (test_house EQ FALSE) | |
1548 cs_remove_co_channels ((USHORT)(mph_bsic_cnf->arfcn&ARFCN_MASK)); | |
1549 | |
1550 rr_data->cs_data.attributes [rr_data->cs_data.act_index] |= | |
1551 (CS_CHECK_FLAG | CS_BCCH_READ); | |
1552 | |
1553 /* CSI-LLD section:4.1.1.11 | |
1554 * Synchronisation succeeded. Remove the carrier from black list | |
1555 */ | |
1556 cs_del_from_black_list(rr_data->cs_data.region, | |
1557 (U16)(mph_bsic_cnf->arfcn&ARFCN_MASK)); | |
1558 | |
1559 att_bsic_ind ((USHORT)(mph_bsic_cnf->arfcn&ARFCN_MASK), | |
1560 rr_data->cs_data.rxlev [rr_data->cs_data.act_index], | |
1561 mph_bsic_cnf->bsic); | |
1562 } | |
1563 else | |
1564 { | |
1565 /* | |
1566 * FB / SB is not decoded, cell has the attributes | |
1567 * BCCH not detected and checked | |
1568 */ | |
1569 rr_data->cs_data.attributes [rr_data->cs_data.act_index] |= CS_CHECK_FLAG; | |
1570 | |
1571 /* Extract region information */ | |
1572 | |
1573 local_arfcn = rr_data->cs_data.arfcn[rr_data->cs_data.act_index]; | |
1574 | |
1575 if(STD_GET_FROM_ARFCN(local_arfcn) NEQ STD_NOT_PRESENT) | |
1576 { | |
1577 /* During Non-Parallel search, region information is available | |
1578 * in ARFCN | |
1579 */ | |
1580 local_region = CS_GET_REGION_FROM_FREQ(local_arfcn); | |
1581 } | |
1582 else | |
1583 { | |
1584 /* Parallel search case */ | |
1585 local_region = srv_get_region_from_std(std); | |
1586 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT | |
1587 if (local_region EQ BOTH_REGIONS) | |
1588 local_region = srv_get_region_from_std_arfcn (std, local_arfcn); | |
1589 #endif | |
1590 } | |
1591 | |
1592 /* CSI-LLD section:4.1.1.6 | |
1593 * Sync failed. Add the carrier to Black list | |
1594 */ | |
1595 cs_add_to_black_list(local_region, | |
1596 (U16)(local_arfcn), | |
1597 rr_data->cs_data.rxlev[rr_data->cs_data.act_index]); | |
1598 | |
1599 /* CSI-LLD section:4.1.1.11 | |
1600 * Set the BLACK LIST attribute flag for this carrier | |
1601 */ | |
1602 if(rr_data->cs_data.initial_plmn_search EQ INITIAL_PLMN_SEARCH_ACTIVE) | |
1603 { | |
1604 CS_SET_BLACK_LIST_FLAG(rr_data->cs_data.act_index); | |
1605 } | |
1606 | |
1607 if (cs_sync_next_bsic () EQ FALSE) | |
1608 { | |
1609 TIMERSTOP(T_PLMN_SEARCH); | |
1610 SET_STATE (STATE_CELL_SEL, CS_IDLE); | |
1611 att_no_bsic_ind (); /* stop in RR */ | |
1612 } | |
1613 } | |
1614 break; | |
1615 | |
1616 #ifdef GPRS | |
1617 case CS_CCO: | |
1618 SET_STATE (STATE_CELL_SEL, CS_IDLE); | |
1619 if (rr_data->gprs_data.cr_pbcch_active OR rr_data->gprs_data.cr_pcco_active) | |
1620 { | |
1621 /* | |
1622 * a Packet Cell Change Order for a cell which | |
1623 * is not in the BA list has been requested by the NW | |
1624 */ | |
1625 if (mph_bsic_cnf->cs EQ CS_NO_ERROR AND | |
1626 (mph_bsic_cnf->arfcn&ARFCN_MASK) EQ rr_data->gprs_data.arfcn AND | |
1627 mph_bsic_cnf->bsic EQ rr_data->gprs_data.bsic ) | |
1628 { | |
1629 /* | |
1630 * PL successfuly sycnhronized to the cell | |
1631 * now RR will do a normal Cell Reselection | |
1632 */ | |
1633 memset (&rr_data->nc_data[CR_INDEX], | |
1634 0, | |
1635 sizeof (T_NC_DATA)); | |
1636 rr_data->nc_data[CR_INDEX].arfcn = mph_bsic_cnf->arfcn&ARFCN_MASK; | |
1637 rr_data->nc_data[CR_INDEX].bsic = mph_bsic_cnf->bsic; | |
1638 | |
1639 /* CSI-LLD section:4.1.1.11 | |
1640 * Synchronisation succeeded. Remove the carrier from black list | |
1641 */ | |
1642 cs_del_from_black_list(rr_data->cs_data.region, | |
1643 (U16)(mph_bsic_cnf->arfcn&ARFCN_MASK)); | |
1644 | |
1645 if( rr_data->gprs_data.cr_pbcch_active ) | |
1646 att_start_cell_reselection_pbcch(MODE_CELL_RESELECTION); | |
1647 else | |
1648 { | |
1649 att_init_cell_selection(CELL_RESELECTION, RR_ORIGINATED); | |
1650 rr_data->dyn_config.fcr = 0; | |
1651 rr_data->dyn_config.scr = 0; | |
1652 rr_data->bcch_error = 0; | |
1653 rr_data->pag_rec = FALSE; | |
1654 srv_clear_stored_prim (MPH_PAGING_IND); | |
1655 gprs_init_data_cr(); | |
1656 dat_att_null(); | |
1657 SET_STATE (STATE_ATT, ATT_CS3); | |
1658 att_build_idle_req (CR_INDEX, MODE_CELL_RESELECTION); | |
1659 } | |
1660 } | |
1661 else | |
1662 { | |
1663 /* | |
1664 * PL did not sycnhronize to the cell | |
1665 * inform GRR and wait for a CR_REQ(CR_REQ) with | |
1666 * the old cell and return to it | |
1667 */ | |
1668 PALLOC(gprs_ind, RRGRR_GPRS_SI13_IND); | |
1669 rr_data->gprs_data.cr_pbcch_active = FALSE; | |
1670 | |
1671 gprs_ind->cause = GPRS_CELL_NOT_SUITABLE; | |
1672 gprs_ind->serving_cell_info.bcch_arfcn = rr_data->gprs_data.arfcn; | |
1673 gprs_ind->serving_cell_info.bcch_bsic = rr_data->gprs_data.bsic; | |
1674 | |
1675 TRACE_EVENT_P4 ("cs=%u C[%d] bsic=%u #%u", | |
1676 gprs_ind->cause, | |
1677 gprs_ind->serving_cell_info.bcch_arfcn, | |
1678 gprs_ind->serving_cell_info.bcch_bsic, | |
1679 __LINE__); | |
1680 | |
1681 PSENDX(GRR, gprs_ind); | |
1682 /* wait for CR_REQ for old cell */ | |
1683 } | |
1684 } | |
1685 else | |
1686 if (mph_bsic_cnf->cs EQ CS_NO_ERROR AND | |
1687 (mph_bsic_cnf->arfcn&ARFCN_MASK) EQ rr_data->gprs_data.arfcn AND | |
1688 mph_bsic_cnf->bsic EQ rr_data->gprs_data.bsic ) | |
1689 { | |
1690 rr_data->gprs_data.tbf_est = TBF_EST_CCO; | |
1691 | |
1692 rr_data->nc_data[CR_INDEX].arfcn = rr_data->gprs_data.arfcn; | |
1693 rr_data->nc_data[CR_INDEX].rxlev = 0; | |
1694 rr_data->nc_data[CR_INDEX].bsic = rr_data->gprs_data.bsic; | |
1695 | |
1696 att_init_cr_data(); | |
1697 TIMERSTART (T_RESELECT, TRESELECT_VALUE); | |
1698 rr_data->nc_data[CR_INDEX].bcch_error = 0; | |
1699 srv_clear_list (&rr_data->cr_data.cd.ncell_list); | |
1700 SET_STATE (STATE_ATT, ATT_CS2); | |
1701 | |
1702 /* CSI-LLD section:4.1.1.11 | |
1703 * Synchronisation succeeded. Remove the carrier from black list | |
1704 */ | |
1705 cs_del_from_black_list(rr_data->cs_data.region, | |
1706 (U16)(mph_bsic_cnf->arfcn&ARFCN_MASK)); | |
1707 /* wait for System Information Messages */ | |
1708 } | |
1709 else /* initiate switch back to old cell */ | |
1710 { | |
1711 dat_code_mph_old_chan_req(); | |
1712 | |
1713 PFREE ( rr_data->gprs_data.dl_data_ind ); | |
1714 rr_data->gprs_data.dl_data_ind = NULL; | |
1715 | |
1716 rr_data->gprs_data.reconn_cause = RRC_PROT_UNSPECIFIED; | |
1717 rr_data->gprs_data.cco_need_reconnect_cnf = FALSE; | |
1718 SET_STATE (STATE_DAT, DAT_CCO_3); | |
1719 } | |
1720 break; | |
1721 | |
1722 case CS_XMEAS: | |
1723 | |
1724 /* enter result in rr_data->gprs_data.rrgrr_ext_meas_cnf, call att_ext_meas_next_bsic */ | |
1725 | |
1726 { | |
1727 UBYTE bsic = mph_bsic_cnf->bsic; | |
1728 T_GPRS_DATA *gprs_data = &rr_data->gprs_data; | |
1729 T_RRGRR_EXT_MEAS_REQ *rrgrr_ext_meas_req = gprs_data->rrgrr_ext_meas_req; | |
1730 | |
1731 | |
1732 if ( rrgrr_ext_meas_req->report_type EQ REP_TYPE_1 OR /* "6 strongest carriers independent of BSIC decoding or not" */ | |
1733 rrgrr_ext_meas_req->report_type EQ REP_TYPE_2 AND /* "BSICs for 6 carriers with decoded BSIC with allowed NCC" */ | |
1734 mph_bsic_cnf->cs EQ CS_NO_ERROR AND | |
1735 (rrgrr_ext_meas_req->ncc_permitted & (1 << ((bsic>>3) & 0x07)))) /* check for "NCC allowed" */ | |
1736 { | |
1737 T_RRGRR_EXT_MEAS_CNF *rrgrr_ext_meas_cnf = gprs_data->rrgrr_ext_meas_cnf; | |
1738 T_MPH_EXT_MEAS_CNF *mph_ext_meas_cnf = gprs_data->mph_ext_meas_cnf; | |
1739 UBYTE n = gprs_data->mph_ext_meas_num; | |
1740 USHORT arfcn = mph_ext_meas_cnf->arfcn[n]; | |
1741 UBYTE rx_lev = mph_ext_meas_cnf->rx_lev[n]; | |
1742 UBYTE idx = rr_ext_meas_idx ( arfcn ); | |
1743 UBYTE k = rrgrr_ext_meas_cnf->c_xmeas_res++; | |
1744 T_xmeas_res *xmeas_res = &rrgrr_ext_meas_cnf-> xmeas_res[k]; | |
1745 | |
1746 /* | |
1747 * Function att_ext_meas_next_bsic checks for the maximum number of elements in the | |
1748 * array rrgrr_ext_meas_cnf->xmeas_res. Therefore this check is not performed here. | |
1749 */ | |
1750 | |
1751 xmeas_res->arfcn_idx.arfcn = arfcn; | |
1752 xmeas_res->arfcn_idx.idx = idx; | |
1753 xmeas_res->rxlev = rx_lev; | |
1754 if (mph_bsic_cnf->cs EQ CS_NO_ERROR) | |
1755 xmeas_res->bsic = bsic; | |
1756 else | |
1757 xmeas_res->bsic = RRGRR_INVALID_BSIC; | |
1758 } | |
1759 } | |
1760 | |
1761 rr_data->gprs_data.mph_ext_meas_num++; | |
1762 att_ext_meas_next_bsic(); | |
1763 break; | |
1764 #endif | |
1765 default: | |
1766 break; | |
1767 } | |
1768 PFREE (mph_bsic_cnf); | |
1769 } | |
1770 | |
1771 | |
1772 /* | |
1773 +--------------------------------------------------------------------+ | |
1774 | PROJECT : GSM-PS (6147) MODULE : RR_CS | | |
1775 | STATE : code ROUTINE : cs_get_channel_from_found_list | | |
1776 +--------------------------------------------------------------------+ | |
1777 | |
1778 PURPOSE : If a network available list was created in former times | |
1779 (found_plmn / found_channel) and one of this networks is | |
1780 requested, the associated channel is stored to give it | |
1781 high priority to speed up cell selection. | |
1782 | |
1783 */ | |
1784 GLOBAL void cs_get_channel_from_found_list () | |
1785 { | |
1786 GET_INSTANCE_DATA; | |
1787 UBYTE i; | |
1788 T_FOUND_ELEMENT * found; | |
1789 | |
1790 TRACE_FUNCTION ("cs_get_channel_from_found_list()"); | |
1791 | |
1792 /* | |
1793 * initialise the local variable | |
1794 */ | |
1795 rr_data->found_channel = NOT_PRESENT_16BIT; | |
1796 | |
1797 /* | |
1798 * for all PLMNs stored in the found list | |
1799 */ | |
1800 found = &rr_data->sc_data.found[0]; | |
1801 for (i=0; i<rr_data->sc_data.found_entries; i++, found++) | |
1802 { | |
1803 /* | |
1804 * if the network in the found list is equal to the PLMN requested by MM, | |
1805 * set the found channel | |
1806 */ | |
1807 /* Implements Measure#32: Row 124 */ | |
1808 att_print_mcc_mnc(found->arfcn, found->plmn.mcc, found->plmn.mnc, S2I_STRING("list")); | |
1809 if (dat_plmn_equal_req (found->plmn.mcc, | |
1810 found->plmn.mnc, | |
1811 rr_data->ms_data.plmn.mcc, | |
1812 rr_data->ms_data.plmn.mnc)) | |
1813 { | |
1814 rr_data->found_channel = found->arfcn; | |
1815 | |
1816 /* Embed region information in the found channel arfcn */ | |
1817 if(found->region EQ AMERICAN_REGION) | |
1818 rr_data->found_channel |= US_BIT; | |
1819 /* Implements Measure#32: Row 125 */ | |
1820 att_print_mcc_mnc(found->arfcn, found->plmn.mcc, found->plmn.mnc, S2I_STRING("found_channel")); | |
1821 return; | |
1822 } | |
1823 } | |
1824 } | |
1825 | |
1826 /* | |
1827 +--------------------------------------------------------------------+ | |
1828 | PROJECT : GSM-PS (6147) MODULE : RR_CS | | |
1829 | STATE : code ROUTINE : cs_clear_channel_from_found_list | | |
1830 +--------------------------------------------------------------------+ | |
1831 | |
1832 PURPOSE : If a network available list was created in former times | |
1833 (found_plmn / rr_found_channel) and one of this networks is | |
1834 requested, the associated channel is stored to give it | |
1835 high priority to speed up cell selection. This function | |
1836 clear the stored data if a network or limited search is | |
1837 started. | |
1838 | |
1839 */ | |
1840 | |
1841 GLOBAL void cs_clear_channel_from_found_list (void) | |
1842 { | |
1843 GET_INSTANCE_DATA; | |
1844 /* | |
1845 * initialize the found channel number | |
1846 */ | |
1847 rr_data->found_channel = NOT_PRESENT_16BIT; | |
1848 } | |
1849 | |
1850 /* | |
1851 +--------------------------------------------------------------------+ | |
1852 | PROJECT : GSM-PS (6147) MODULE : RR_CS | | |
1853 | STATE : code ROUTINE : cs_remove_co_channels | | |
1854 +--------------------------------------------------------------------+ | |
1855 | |
1856 PURPOSE : If a channel x fails and the channels x-1 and x+1 have | |
1857 a fieldstrength difference greater 9 dB, it is not necessary | |
1858 to try on this cells. Sense of this is to speed up search. | |
1859 | |
1860 */ | |
1861 | |
1862 static void cs_remove_co_channels (USHORT arfcn) | |
1863 { | |
1864 /* | |
1865 * depending on the channel number. Some extra cases | |
1866 * for channel numbers on the boarders of the frequency Band | |
1867 */ | |
1868 switch (arfcn) | |
1869 { | |
1870 case CHANNEL_0: | |
1871 /* | |
1872 * E-GSM channel 0 has no co-channels | |
1873 */ | |
1874 break; | |
1875 | |
1876 /* | |
1877 * all LOW channel boarders | |
1878 */ | |
1879 case LOW_CHANNEL_850: | |
1880 case LOW_CHANNEL_900: | |
1881 case LOW_CHANNEL_1800: | |
1882 case LOW_CHANNEL_EGSM: | |
1883 cs_remove_co_chan (arfcn, (USHORT)(arfcn+1)); | |
1884 break; | |
1885 | |
1886 /* | |
1887 * all HIGH channel boarders | |
1888 */ | |
1889 case HIGH_CHANNEL_1900: | |
1890 if (std NEQ STD_1900 AND std NEQ STD_DUAL_US) | |
1891 { | |
1892 cs_remove_co_chan (arfcn, (USHORT)(arfcn+1));/* DCS 1800 */ | |
1893 } | |
1894 /*lint -fallthrough*/ | |
1895 case HIGH_CHANNEL_850: | |
1896 case HIGH_CHANNEL_900: | |
1897 case HIGH_CHANNEL_1800: | |
1898 case HIGH_CHANNEL_EGSM-1: | |
1899 cs_remove_co_chan (arfcn, (USHORT)(arfcn-1)); | |
1900 break; | |
1901 | |
1902 default: | |
1903 /* | |
1904 * all other channels inside the frequency bands | |
1905 */ | |
1906 cs_remove_co_chan (arfcn, (USHORT)(arfcn+1)); | |
1907 cs_remove_co_chan (arfcn, (USHORT)(arfcn-1)); | |
1908 break; | |
1909 } | |
1910 } | |
1911 | |
1912 | |
1913 /* | |
1914 +--------------------------------------------------------------------+ | |
1915 | PROJECT : GSM-PS (6147) MODULE : RR_CS | | |
1916 | STATE : code ROUTINE : cs_remove_co_chan | | |
1917 +--------------------------------------------------------------------+ | |
1918 | |
1919 PURPOSE : if co_chan - chan has a fieldstrength difference greater | |
1920 9 dBm, remove the channel. | |
1921 | |
1922 */ | |
1923 | |
1924 static void cs_remove_co_chan (USHORT arfcn, USHORT co_arfcn) | |
1925 { | |
1926 GET_INSTANCE_DATA; | |
1927 UBYTE index_arfcn = NOT_PRESENT_8BIT; | |
1928 UBYTE index_co_arfcn = NOT_PRESENT_8BIT; | |
1929 UBYTE i; | |
1930 SHORT rxlev_arfcn; | |
1931 SHORT rxlev_co_arfcn; | |
1932 USHORT *p_arfcn; | |
1933 TRACE_FUNCTION ("cs_remove_co_chan()"); | |
1934 | |
1935 /* | |
1936 * calculate the index in the power campaign list | |
1937 * for the channel | |
1938 */ | |
1939 p_arfcn = rr_data->cs_data.arfcn; | |
1940 for (i=0; i<rr_data->cs_data.max_arfcn; i++) | |
1941 { | |
1942 if (arfcn EQ (p_arfcn[i]&ARFCN_MASK)) | |
1943 { | |
1944 index_arfcn = i; | |
1945 break; | |
1946 } | |
1947 } | |
1948 /* | |
1949 * if the channel is not inside the list, | |
1950 * then nothing is to compare else get the | |
1951 * fieldstrength. | |
1952 */ | |
1953 if (index_arfcn EQ NOT_PRESENT_8BIT) | |
1954 return; | |
1955 | |
1956 /* | |
1957 * calculate the index in the power campaign list | |
1958 * for the co-channel | |
1959 */ | |
1960 for (i=0;i<rr_data->cs_data.max_arfcn;i++) | |
1961 { | |
1962 if (co_arfcn EQ (p_arfcn[i]&ARFCN_MASK)) | |
1963 { | |
1964 index_co_arfcn = i; | |
1965 break; | |
1966 } | |
1967 } | |
1968 /* | |
1969 * if the co-channel is not inside the list, | |
1970 * then nothing is to compare else get the | |
1971 * fieldstrength. | |
1972 */ | |
1973 if (index_co_arfcn EQ NOT_PRESENT_8BIT) | |
1974 return; | |
1975 | |
1976 rxlev_arfcn = (SHORT)rr_data->cs_data.rxlev [index_arfcn]; | |
1977 rxlev_co_arfcn = (SHORT)rr_data->cs_data.rxlev [index_co_arfcn]; | |
1978 | |
1979 /* | |
1980 * if the difference is > 9 dBm, | |
1981 * set to low priority. | |
1982 */ | |
1983 if ((rxlev_arfcn - rxlev_co_arfcn) > 9) | |
1984 { | |
1985 rr_data->cs_data.attributes [index_co_arfcn] &= CS_SET_TO_LOW_PRIORITY; | |
1986 } | |
1987 } | |
1988 | |
1989 /* | |
1990 +---------------------------------------------------------------------+ | |
1991 | PROJECT : GSM-PS (6147) MODULE : RR_CS | | |
1992 | STATE : code ROUTINE : cs_add_current_network .... | | |
1993 +---------------------------------------------------------------------+ | |
1994 | |
1995 PURPOSE : Adds the current PLMN to the found list if available. | |
1996 | |
1997 */ | |
1998 LOCAL void cs_add_current_network_to_found_list (void) | |
1999 { | |
2000 GET_INSTANCE_DATA; | |
2001 T_loc_area_ident *lai = &rr_data->nc_data[SC_INDEX].lai; | |
2002 | |
2003 TRACE_FUNCTION ("cs_add_current_network_to_found_list()"); | |
2004 | |
2005 switch (rr_data->ms_data.rr_service) | |
2006 { | |
2007 case LIMITED_SERVICE: | |
2008 case FULL_SERVICE: | |
2009 /* | |
2010 * The mobile was in full service | |
2011 * Add this PLMN to the list of found PLMN | |
2012 * and clean power measurement list. | |
2013 */ | |
2014 if (! att_plmn_in_found_list (lai->mcc, lai->mnc) AND | |
2015 rr_data->sc_data.found_entries < MAX_PLMN) | |
2016 { | |
2017 att_save_found_plmn ( | |
2018 &rr_data->sc_data.found[rr_data->sc_data.found_entries], | |
2019 lai->mcc, lai->mnc, | |
2020 rr_data->nc_data[SC_INDEX].arfcn, | |
2021 rr_data->nc_data[SC_INDEX].rxlev, lai->lac, 0); | |
2022 rr_data->sc_data.found_entries++; | |
2023 } | |
2024 /* | |
2025 * Consider only high priority cells to speed up search | |
2026 */ | |
2027 cs_del_list (&rr_data->sc_data.cd.ncell_list); | |
2028 break; | |
2029 } | |
2030 } | |
2031 | |
2032 /* | |
2033 +--------------------------------------------------------------------+ | |
2034 | PROJECT : GSM-PS (8403) MODULE : RR_CS | | |
2035 | STATE : code ROUTINE : cs_check_channel | | |
2036 +--------------------------------------------------------------------+ | |
2037 | |
2038 PURPOSE : Depending on the settings (default, GSM 900, DCS 1800) | |
2039 all non-interesting channels are removed. | |
2040 | |
2041 */ | |
2042 static UBYTE cs_check_channel (USHORT arfcn) | |
2043 { | |
2044 GET_INSTANCE_DATA; | |
2045 /* | |
2046 * TRACE_FUNCTION ("cs_check_channel") | |
2047 */ | |
2048 { | |
2049 switch (rr_data->dyn_config.set_band) | |
2050 { | |
2051 case 0: | |
2052 /* | |
2053 * default behaviour | |
2054 */ | |
2055 return TRUE; | |
2056 | |
2057 case 1: | |
2058 /* | |
2059 * set to GSM 900 | |
2060 */ | |
2061 /* | |
2062 if (arfcn <= LOW_CHANNEL_900 OR | |
2063 arfcn >= HIGH_CHANNEL_900) | |
2064 */ | |
2065 if (INRANGE(LOW_CHANNEL_900,arfcn,HIGH_CHANNEL_900)) | |
2066 return FALSE; | |
2067 else | |
2068 return TRUE; | |
2069 | |
2070 case 2: | |
2071 /* | |
2072 * set to DCS 1800 | |
2073 */ | |
2074 /* | |
2075 if (arfcn >= LOW_CHANNEL_1800 AND | |
2076 arfcn <= HIGH_CHANNEL_1800) | |
2077 */ | |
2078 if (INRANGE(LOW_CHANNEL_1800,arfcn,HIGH_CHANNEL_1800)) | |
2079 return TRUE; | |
2080 else | |
2081 return FALSE; | |
2082 } | |
2083 } | |
2084 return TRUE; | |
2085 } | |
2086 | |
2087 /* | |
2088 +----------------------------------------------------------------------+ | |
2089 | PROJECT : GSM-PS (8403) MODULE : RR_CS | | |
2090 | STATE : code ROUTINE : cs_check_region | | |
2091 +----------------------------------------------------------------------+ | |
2092 | |
2093 PURPOSE : This routine validates the region | |
2094 Cell Selection Improvements-LLD section:4.1.1.2 | |
2095 */ | |
2096 | |
2097 GLOBAL BOOL cs_check_region(U8 region) | |
2098 { | |
2099 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT | |
2100 if((region EQ EUROPEAN_REGION) OR (region EQ AMERICAN_REGION) OR (region EQ BOTH_REGIONS)) | |
2101 #else | |
2102 if((region EQ EUROPEAN_REGION) OR (region EQ AMERICAN_REGION)) | |
2103 #endif | |
2104 { | |
2105 return TRUE; | |
2106 } | |
2107 else | |
2108 { | |
2109 TRACE_ERROR("Invalid region"); | |
2110 return FALSE; | |
2111 } | |
2112 } | |
2113 | |
2114 /* | |
2115 +----------------------------------------------------------------------+ | |
2116 | PROJECT : GSM-PS (8403) MODULE : RR_CS | | |
2117 | STATE : code ROUTINE : cs_validate_arfcn_index | | |
2118 +----------------------------------------------------------------------+ | |
2119 | |
2120 PURPOSE : This routine validates the ARFCN index | |
2121 Cell Selection Improvements-LLD section:4.1.1.2 | |
2122 */ | |
2123 | |
2124 GLOBAL BOOL cs_check_arfcn_range(U16 arfcn) | |
2125 { | |
2126 | |
2127 if(arfcn EQ CHANNEL_0) | |
2128 arfcn = CHANNEL_0_INTERNAL; | |
2129 | |
2130 if((arfcn > CHANNEL_0) AND (arfcn <= CHANNEL_0_INTERNAL)) | |
2131 { | |
2132 return TRUE; | |
2133 } | |
2134 else | |
2135 { | |
2136 TRACE_ERROR("Invalid ARFCN"); | |
2137 return FALSE; | |
2138 } | |
2139 } | |
2140 | |
2141 /* | |
2142 +----------------------------------------------------------------------+ | |
2143 | PROJECT : GSM-PS (8403) MODULE : RR_CS | | |
2144 | STATE : code ROUTINE : cs_inc_sync_fail_counter | | |
2145 +----------------------------------------------------------------------+ | |
2146 | |
2147 PURPOSE : This routine increments the sync fail counter value for GSM | |
2148 carrier. Seperate counters are maintained for European and | |
2149 American regions.The size of SFC counter is 4 bits. As a | |
2150 result two carriers are accommodated in one byte. This function | |
2151 first converts the ARFCN range from 1-1023 to 0-511 format and | |
2152 increments the SFC accordingly. The SFC format is shown below | |
2153 | |
2154 CSI-LLD section:4.1.1.5.9 | |
2155 | |
2156 ------------------------------------------ | |
2157 | Index | MSB 4 bits | LSB 4 bits | | |
2158 ------------------------------------------ | |
2159 | 0 | ARFCN : 2 | ARFCN : 1 | | |
2160 ------------------------------------------ | |
2161 | 1 | ARFCN : 4 | ARFCN 3 | | |
2162 ------------------------------------------ | |
2163 | - | - | - | | |
2164 ------------------------------------------ | |
2165 | - | - | - | | |
2166 ------------------------------------------ | |
2167 | 510 | ARFCN : 1022 | ARFCN: 1021 | | |
2168 ------------------------------------------ | |
2169 | 511 | ARFCN : 0 | ARFCN :1023 | | |
2170 ----------------------------------------- | |
2171 ARFCN: 0 = CHANNEL_0_INTERNAL | |
2172 | |
2173 */ | |
2174 | |
2175 LOCAL void cs_inc_sync_fail_counter(U8 region, U16 arfcn) | |
2176 { | |
2177 GET_INSTANCE_DATA; | |
2178 U16 index=0; | |
2179 U8 inc = 0; | |
2180 | |
2181 if(!cs_check_region(region)) | |
2182 return; | |
2183 | |
2184 if(!cs_check_arfcn_range((U16)(arfcn & ARFCN_MASK))) | |
2185 return; | |
2186 | |
2187 if(arfcn EQ CHANNEL_0) | |
2188 arfcn = CHANNEL_0_INTERNAL; | |
2189 | |
2190 /* Convert ARFCN range to 0-511 from 1-1023 range */ | |
2191 index = ((arfcn & ARFCN_MASK) -1) >> 1; | |
2192 | |
2193 if(arfcn & 0x01) | |
2194 { | |
2195 /* Increment LSB 4 bits for odd ARFCN */ | |
2196 inc = 0x01; | |
2197 } | |
2198 else | |
2199 { | |
2200 /* Increment MSB 4 bits for even ARFCN */ | |
2201 inc = 0x10; | |
2202 } | |
2203 | |
2204 /* Increment the synchronisation counter */ | |
2205 rr_data->cs_data.black_list.sfc[region][index] += inc; | |
2206 | |
2207 TRACE_EVENT_P3("[%d]Reg,[%d]Arfcn, SFC = 0x%x", | |
2208 region, | |
2209 arfcn, | |
2210 rr_data->cs_data.black_list.sfc[region][index]); | |
2211 } | |
2212 | |
2213 /* | |
2214 +----------------------------------------------------------------------+ | |
2215 | PROJECT : GSM-PS (8403) MODULE : RR_CS | | |
2216 | STATE : code ROUTINE : cs_reset_sync_fail_counter | | |
2217 +----------------------------------------------------------------------+ | |
2218 | |
2219 PURPOSE : This routine resets the synchronisation fail counter value of | |
2220 GSM carrier. | |
2221 Seperate counters are maintained for European and American | |
2222 regions.The size of SFC counter is 4 bits. As a result two | |
2223 carriers are accommodated in one byte. This function | |
2224 first converts the ARFCN range from 1-1023 to 0-511 format and | |
2225 increments the SFC accordingly.The SFC format is shown below | |
2226 | |
2227 CSI-LLD section:4.1.1.5.10 | |
2228 | |
2229 ------------------------------------------ | |
2230 | Index | MSB 4 bits | LSB 4 bits | | |
2231 ------------------------------------------ | |
2232 | 0 | ARFCN : 2 | ARFCN : 1 | | |
2233 ------------------------------------------ | |
2234 | 1 | ARFCN : 4 | ARFCN 3 | | |
2235 ------------------------------------------ | |
2236 | - | - | - | | |
2237 ------------------------------------------ | |
2238 | - | - | - | | |
2239 ------------------------------------------ | |
2240 | 510 | ARFCN : 1022 | ARFCN: 1021 | | |
2241 ------------------------------------------ | |
2242 | 511 | ARFCN : 0 | ARFCN :1023 | | |
2243 ----------------------------------------- | |
2244 ARFCN: 0 = CHANNEL_0_INTERNAL | |
2245 */ | |
2246 | |
2247 LOCAL void cs_reset_sync_fail_counter(U8 region, U16 arfcn) | |
2248 { | |
2249 GET_INSTANCE_DATA; | |
2250 USHORT index=0; | |
2251 | |
2252 if(!cs_check_region(region)) | |
2253 return; | |
2254 | |
2255 if(!cs_check_arfcn_range((U16)(arfcn & ARFCN_MASK))) | |
2256 return; | |
2257 | |
2258 if(arfcn EQ CHANNEL_0) | |
2259 arfcn = CHANNEL_0_INTERNAL; | |
2260 | |
2261 /* Convert ARFCN range to 0-511 from 1-1023 range */ | |
2262 index = ((arfcn & ARFCN_MASK) -1) >> 1; | |
2263 | |
2264 if(arfcn & 0x01) | |
2265 { | |
2266 /* Reset LSB 4 bits for odd ARFCN */ | |
2267 rr_data->cs_data.black_list.sfc[region][index] &=0xf0; | |
2268 } | |
2269 else | |
2270 { | |
2271 /* Reset MSB 4 bits for even ARFCN */ | |
2272 rr_data->cs_data.black_list.sfc[region][index] &=0x0f; | |
2273 } | |
2274 | |
2275 TRACE_EVENT_P2("SFC reset for [%d]Reg,[%d]Arfcn",region,arfcn); | |
2276 } | |
2277 | |
2278 /* | |
2279 +----------------------------------------------------------------------+ | |
2280 | PROJECT : GSM-PS (8403) MODULE : RR_CS | | |
2281 | STATE : code ROUTINE : cs_get_sync_fail_counter | | |
2282 +----------------------------------------------------------------------+ | |
2283 | |
2284 PURPOSE : This function returns the SFC counter of GSM carriers | |
2285 Seperate counters are maintained for European and American | |
2286 regions.The size of SFC counter is 4 bits. As a result two | |
2287 carriers are accommodated in one byte. This function | |
2288 first converts the ARFCN range from 1-1023 to 0-511 format and | |
2289 increments the SFC accordingly.The SFC format is shown below | |
2290 | |
2291 CSI-LLD section:4.1.1.5.11 | |
2292 | |
2293 ------------------------------------------ | |
2294 | Index | MSB 4 bits | LSB 4 bits | | |
2295 ------------------------------------------ | |
2296 | 0 | ARFCN : 2 | ARFCN : 1 | | |
2297 ------------------------------------------ | |
2298 | 1 | ARFCN : 4 | ARFCN 3 | | |
2299 ------------------------------------------ | |
2300 | - | - | - | | |
2301 ------------------------------------------ | |
2302 | - | - | - | | |
2303 ------------------------------------------ | |
2304 | 510 | ARFCN : 1022 | ARFCN: 1021 | | |
2305 ------------------------------------------ | |
2306 | 511 | ARFCN : 0 | ARFCN :1023 | | |
2307 ----------------------------------------- | |
2308 ARFCN: 0 = CHANNEL_0_INTERNAL | |
2309 */ | |
2310 | |
2311 LOCAL U8 cs_get_sync_fail_counter(U8 region, U16 arfcn) | |
2312 { | |
2313 GET_INSTANCE_DATA; | |
2314 USHORT index=0; | |
2315 UBYTE sfc_count=0; | |
2316 | |
2317 if(!cs_check_region(region)) | |
2318 return sfc_count; | |
2319 | |
2320 if(!cs_check_arfcn_range((U16)(arfcn & ARFCN_MASK))) | |
2321 return sfc_count; | |
2322 | |
2323 if(arfcn EQ CHANNEL_0) | |
2324 arfcn = CHANNEL_0_INTERNAL; | |
2325 | |
2326 /* Convert to 0-511 range from 1-1024 range */ | |
2327 index = ((arfcn & ARFCN_MASK) -1) >> 1; | |
2328 | |
2329 if(arfcn & 0x01) | |
2330 { | |
2331 /* obtain LSB 4 bits for odd ARFCN */ | |
2332 sfc_count = (rr_data->cs_data.black_list.sfc[region][index] & 0x0f); | |
2333 } | |
2334 else | |
2335 { | |
2336 /* obtain MSB 4 bits for even ARFCN */ | |
2337 sfc_count = (rr_data->cs_data.black_list.sfc[region][index] & 0xf0) >> 4; | |
2338 } | |
2339 | |
2340 return sfc_count; | |
2341 } | |
2342 | |
2343 /* | |
2344 +--------------------------------------------------------------------+ | |
2345 | PROJECT : GSM-PS (8403) MODULE : RR_CS | | |
2346 | STATE : code ROUTINE : cs_add_to_black_list | | |
2347 +--------------------------------------------------------------------+ | |
2348 | |
2349 PURPOSE : This function is used to add GSM channels to "Black List". | |
2350 The function checks the "Black List" criteria before adding | |
2351 it to the list. This function is called whenever MS fails | |
2352 to synchronize to a GSM channel. | |
2353 CSI-LLD section:4.1.1.5.5 | |
2354 */ | |
2355 | |
2356 GLOBAL void cs_add_to_black_list(U8 region, U16 arfcn, U8 rxlev) | |
2357 { | |
2358 GET_INSTANCE_DATA; | |
2359 U16 local_arfcn = arfcn & ARFCN_MASK; | |
2360 | |
2361 TRACE_FUNCTION("cs_add_to_black_list()"); | |
2362 | |
2363 /* "Region" and "arfcn" are used to index "Black List" database | |
2364 * Check whether they are within proper range | |
2365 */ | |
2366 if(!cs_check_region(region)) | |
2367 return; | |
2368 | |
2369 if(!cs_check_arfcn_range(local_arfcn)) | |
2370 return; | |
2371 | |
2372 /* Check Black List criteria */ | |
2373 if(cs_check_black_list_criteria(region,arfcn,rxlev)) | |
2374 { | |
2375 /* Add the channel to Black List */ | |
2376 srv_set_channel(&rr_data->cs_data.black_list.list[region],local_arfcn); | |
2377 | |
2378 /* Reset the sync fail counter for this channel. So that when this | |
2379 * carrier is removed from BL(BA_MA list), counter will start from zero | |
2380 * again | |
2381 */ | |
2382 cs_reset_sync_fail_counter(region, local_arfcn); | |
2383 | |
2384 TRACE_EVENT_P2("[%d]Reg[%d]Arfcn added to BL",region,local_arfcn); | |
2385 } | |
2386 } | |
2387 | |
2388 /* | |
2389 +--------------------------------------------------------------------+ | |
2390 | PROJECT : GSM-PS (8403) MODULE : RR_CS | | |
2391 | STATE : code ROUTINE : cs_del_from_black_list | | |
2392 +--------------------------------------------------------------------+ | |
2393 | |
2394 PURPOSE : This routine removes the arfcn from black list and resets the sync | |
2395 fail counter for that arfcn | |
2396 CSI-LLD section:4.1.1.5.6 | |
2397 */ | |
2398 | |
2399 GLOBAL void cs_del_from_black_list(U8 region, U16 arfcn) | |
2400 { | |
2401 GET_INSTANCE_DATA; | |
2402 USHORT local_arfcn = arfcn & ARFCN_MASK; | |
2403 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT | |
2404 UBYTE i; | |
2405 #endif | |
2406 | |
2407 TRACE_FUNCTION("cs_del_from_black_list()"); | |
2408 | |
2409 /* "Region" and "arfcn" are used to index "Black List" database | |
2410 * Check whether they are within proper range | |
2411 */ | |
2412 if(!cs_check_region(region)) | |
2413 return; | |
2414 | |
2415 if(!cs_check_arfcn_range(local_arfcn)) | |
2416 return; | |
2417 | |
2418 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT | |
2419 if (region EQ BOTH_REGIONS) | |
2420 { | |
2421 for (i=0; i<MAX_REGIONS; i++) | |
2422 { | |
2423 if(srv_get_channel(&rr_data->cs_data.black_list.list[i],local_arfcn)) | |
2424 { | |
2425 /* Remove the channel from Black List */ | |
2426 srv_unset_channel(&rr_data->cs_data.black_list.list[i],local_arfcn); | |
2427 | |
2428 /* Reset the sync fail counter for this channel */ | |
2429 cs_reset_sync_fail_counter(i, local_arfcn); | |
2430 | |
2431 TRACE_EVENT_P2("ARFCN:%d Region:%d deleted from BL",local_arfcn,i); | |
2432 } | |
2433 } | |
2434 } | |
2435 else | |
2436 { | |
2437 #endif | |
2438 if(srv_get_channel(&rr_data->cs_data.black_list.list[region],local_arfcn)) | |
2439 { | |
2440 /* Remove the channel from Black List */ | |
2441 srv_unset_channel(&rr_data->cs_data.black_list.list[region],local_arfcn); | |
2442 | |
2443 /* Reset the sync fail counter for this channel */ | |
2444 cs_reset_sync_fail_counter(region, local_arfcn); | |
2445 | |
2446 TRACE_EVENT_P2("ARFCN:%d Region:%d deleted from BL",local_arfcn,region); | |
2447 } | |
2448 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT | |
2449 } | |
2450 #endif | |
2451 } | |
2452 | |
2453 /* | |
2454 +--------------------------------------------------------------------+ | |
2455 | PROJECT : GSM-PS (8403) MODULE : RR_CS | | |
2456 | STATE : code ROUTINE : cs_clear_black_list | | |
2457 +--------------------------------------------------------------------+ | |
2458 | |
2459 PURPOSE : This function is used to clear "Black List" database. | |
2460 The function clears the "Black List" database from | |
2461 1) Only RAM | |
2462 2) Only FFS | |
2463 3) Both RAM and FFS. | |
2464 | |
2465 This function is called in the following cases | |
2466 1) In response to "ERASE_BL" dynamic configuration command | |
2467 2) After Initial PLMN search based on its outcome | |
2468 | |
2469 CSI-LLD section:4.1.1.5.1 | |
2470 */ | |
2471 | |
2472 GLOBAL void cs_clear_black_list(U8 erase_type) | |
2473 { | |
2474 GET_INSTANCE_DATA; | |
2475 TRACE_FUNCTION ("cs_clear_black_list()"); | |
2476 | |
2477 /* clear Black List from RAM */ | |
2478 if(erase_type & CLR_BLACK_LIST_RAM) | |
2479 { | |
2480 memset(&rr_data->cs_data.black_list,0,sizeof(T_CS_BLACK_LIST)); | |
2481 | |
2482 TRACE_EVENT ("Black List: RAM cleared"); | |
2483 } | |
2484 | |
2485 /* Clear Black List from FFS */ | |
2486 #if defined(_SIMULATION_FFS_) | |
2487 if(erase_type & CLR_BLACK_LIST_FFS) | |
2488 { | |
2489 T_LIST local_black_list[MAX_REGIONS]; | |
2490 | |
2491 memset(&local_black_list[0],0,MAX_REGIONS*sizeof(T_LIST)); | |
2492 | |
2493 rr_csf_write_black_list(&local_black_list[0]); | |
2494 | |
2495 TRACE_EVENT ("Black List: FFS cleared"); | |
2496 } | |
2497 #endif | |
2498 | |
2499 } | |
2500 | |
2501 /* | |
2502 +--------------------------------------------------------------------+ | |
2503 | PROJECT : GSM-PS (8403) MODULE : RR_CS | | |
2504 | STATE : code ROUTINE : cs_remove_BA_MA_from_black_list| | |
2505 +--------------------------------------------------------------------+ | |
2506 | |
2507 PURPOSE : This function is used to remove the GSM channels present | |
2508 in MA and BA lists from the "Black List". The function | |
2509 deletes these channels from the "Black List" and also | |
2510 resets their SFC counter to zero. This function is called | |
2511 whenever MS receives BA and MA list information in any RR | |
2512 message. | |
2513 CSI-LLD section:4.1.1.5.7 | |
2514 */ | |
2515 | |
2516 GLOBAL void cs_remove_BA_MA_from_black_list(U8 region, T_LIST *source_list) | |
2517 { | |
2518 GET_INSTANCE_DATA; | |
2519 | |
2520 TRACE_FUNCTION("cs_remove_BA_MA_from_black_list()"); | |
2521 | |
2522 /* "Region" is to index "Black List" database | |
2523 * Check whether it is within proper range | |
2524 */ | |
2525 if(!cs_check_region(region)) | |
2526 return; | |
2527 | |
2528 if(source_list NEQ NULL) | |
2529 { | |
2530 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT | |
2531 if (region EQ BOTH_REGIONS) | |
2532 { | |
2533 cs_remove_BA_MA_from_black_list(EUROPEAN_REGION,source_list); | |
2534 cs_remove_BA_MA_from_black_list(AMERICAN_REGION,source_list); | |
2535 } | |
2536 else | |
2537 #endif | |
2538 srv_unmask_list(&rr_data->cs_data.black_list.list[region],source_list); | |
2539 | |
2540 TRACE_EVENT("BL updated with BA/MA/Inactive carrier list"); | |
2541 } | |
2542 } | |
2543 | |
2544 | |
2545 /* | |
2546 +--------------------------------------------------------------------+ | |
2547 | PROJECT : GSM-PS (8403) MODULE : RR_CS | | |
2548 | STATE : code ROUTINE : cs_rem_inactive_carriers_from_bl| | |
2549 +--------------------------------------------------------------------+ | |
2550 | |
2551 PURPOSE : This function is used to remove the inactive carriers from | |
2552 the "Black List". This is done whenever the mobile changes | |
2553 LA/RA | |
2554 Cell Selection Improvements-LLD section:4.1.1.3.4 | |
2555 */ | |
2556 | |
2557 GLOBAL void cs_rem_inactive_carriers_from_bl(T_MPH_POWER_CNF *mph_power_cnf) | |
2558 { | |
2559 | |
2560 TRACE_FUNCTION("cs_remove_inactive_from_black_list"); | |
2561 | |
2562 /* Remove the inactive carriers from Black list for European region */ | |
2563 cs_remove_BA_MA_from_black_list(EUROPEAN_REGION, | |
2564 (T_LIST *)&mph_power_cnf->inactive_carrier_list.list[EUROPEAN_REGION]); | |
2565 | |
2566 /* Remove the inactive carriers from Black list for American region */ | |
2567 cs_remove_BA_MA_from_black_list(AMERICAN_REGION, | |
2568 (T_LIST *)&mph_power_cnf->inactive_carrier_list.list[AMERICAN_REGION]); | |
2569 } | |
2570 | |
2571 | |
2572 /* | |
2573 +--------------------------------------------------------------------+ | |
2574 | PROJECT : GSM-PS (8403) MODULE : RR_CS | | |
2575 | STATE : code ROUTINE : cs_is_in_black_list | | |
2576 +--------------------------------------------------------------------+ | |
2577 | |
2578 PURPOSE : This routine checks whether a carrier is already part of Black | |
2579 list or not | |
2580 CSI-LLD section:4.1.1.5.12 | |
2581 */ | |
2582 | |
2583 LOCAL BOOL cs_is_in_black_list(U8 region, U16 arfcn) | |
2584 { | |
2585 GET_INSTANCE_DATA; | |
2586 U8 status; | |
2587 | |
2588 status = srv_get_channel((T_LIST*)&rr_data->cs_data.black_list.list[region], | |
2589 (USHORT)arfcn & ARFCN_MASK); | |
2590 | |
2591 TRACE_EVENT_P3("[%d]Reg[%d]Arfcn, BL status:%d",region,arfcn,status); | |
2592 | |
2593 return status; | |
2594 } | |
2595 | |
2596 /* | |
2597 +--------------------------------------------------------------------+ | |
2598 | PROJECT : GSM-PS (8403) MODULE : RR_CS | | |
2599 | STATE : code ROUTINE : cs_is_in_white_list | | |
2600 +--------------------------------------------------------------------+ | |
2601 | |
2602 PURPOSE : This routine checks whether a carrier is part of White | |
2603 list or not | |
2604 CSI-LLD section:4.1.2.2.7 | |
2605 */ | |
2606 | |
2607 LOCAL BOOL cs_is_in_white_list(U8 region, U16 arfcn) | |
2608 { | |
2609 GET_INSTANCE_DATA; | |
2610 U8 status = FALSE; | |
2611 | |
2612 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT | |
2613 if((rr_data->cs_data.white_list.region EQ BOTH_REGIONS) OR | |
2614 (region EQ rr_data->cs_data.white_list.region)) | |
2615 #else | |
2616 if(region EQ rr_data->cs_data.white_list.region) | |
2617 #endif | |
2618 { | |
2619 status = srv_get_channel(&rr_data->cs_data.white_list.list, | |
2620 ((U16)arfcn & ARFCN_MASK)); | |
2621 } | |
2622 | |
2623 TRACE_EVENT_P3("[%d]Reg[%d]Arfcn, WL status:%d", region,arfcn,status); | |
2624 | |
2625 return status; | |
2626 } | |
2627 | |
2628 /* | |
2629 +---------------------------------------------------------------------+ | |
2630 | PROJECT : GSM-PS (8403) MODULE : RR_CS | | |
2631 | STATE : code ROUTINE : cs_check_black_list_criteria| | |
2632 +---------------------------------------------------------------------+ | |
2633 | |
2634 PURPOSE : This function checks the criteria for adding a GSM channel | |
2635 to "Black List". GSM channels are added to "Black List" only | |
2636 after they satisfy this criteria. | |
2637 CSI-LLD section:4.1.1.5.13 | |
2638 */ | |
2639 | |
2640 LOCAL BOOL cs_check_black_list_criteria(U8 region,U16 arfcn,U8 rxlev) | |
2641 { | |
2642 GET_INSTANCE_DATA; | |
2643 UBYTE band_index; | |
2644 U16 local_arfcn = arfcn&ARFCN_MASK; | |
2645 TRACE_FUNCTION("cs_check_black_list_criteria()"); | |
2646 | |
2647 /* Check if the carrier is already present in the black list */ | |
2648 if(cs_is_in_black_list(region, local_arfcn)) | |
2649 return FALSE; | |
2650 | |
2651 /* Check if the carrier is present in White List */ | |
2652 if(cs_is_in_white_list(region, local_arfcn)) | |
2653 return FALSE; | |
2654 | |
2655 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT | |
2656 band_index = cs_get_band_index(arfcn); | |
2657 #else | |
2658 band_index = get_band_index(arfcn); | |
2659 #endif | |
2660 /* RxLev of carrier is above upper threshold. Add the carrier | |
2661 * to Black List immediately | |
2662 */ | |
2663 if(rxlev >= rr_data->dyn_config.upper_rxlev_thr[band_index]) | |
2664 { | |
2665 return TRUE; | |
2666 } | |
2667 | |
2668 /* Reasonably strong carrier. Add to Black List only if its sync fail | |
2669 * counter criteria is satisfied | |
2670 */ | |
2671 if((rxlev >= rr_data->dyn_config.medium_rxlev_thr[band_index]) AND | |
2672 (rxlev < rr_data->dyn_config.upper_rxlev_thr[band_index])) | |
2673 { | |
2674 cs_inc_sync_fail_counter(region, local_arfcn); | |
2675 | |
2676 if(cs_get_sync_fail_counter(region, local_arfcn) >= MAX_SYNC_FAILURES) | |
2677 { | |
2678 return TRUE; | |
2679 } | |
2680 } | |
2681 return FALSE; | |
2682 } | |
2683 | |
2684 /* | |
2685 +----------------------------------------------------------------+ | |
2686 | PROJECT : GSM-PS (8403) MODULE : RR_CS | | |
2687 | STATE : code ROUTINE : cs_update_black_list | | |
2688 +----------------------------------------------------------------+ | |
2689 | |
2690 PURPOSE : This function is used to update "Black List" database | |
2691 after initial PLMN search.It first clears the current | |
2692 "Black list" database from RAM and then adds some cells | |
2693 to "Black List" according to the current attrib-utes | |
2694 array values(BLACK_LIST_FLAG) of the Initial PLMN | |
2695 selection process. This function is called un-der the | |
2696 following cases | |
2697 1.MS enters Limited or No service after Initial PLMN search | |
2698 2.MS enters Full service in a different Location area | |
2699 from where it is switched off after initial PLMN search | |
2700 CSI-LLD section:4.1.1.5.8 | |
2701 */ | |
2702 | |
2703 GLOBAL void cs_update_black_list(void) | |
2704 { | |
2705 GET_INSTANCE_DATA; | |
2706 | |
2707 U8 update_black_list = FALSE; | |
2708 U8 i, region; | |
2709 | |
2710 TRACE_FUNCTION("cs_update_black_list()"); | |
2711 | |
2712 /* If the outcome of first FUNC_PLMN_SEARCH is not full service. | |
2713 * Erase the Black List | |
2714 */ | |
2715 if((rr_data->ms_data.req_mm_service EQ FUNC_PLMN_SRCH AND | |
2716 rr_data->ms_data.rr_service NEQ FULL_SERVICE)) | |
2717 { | |
2718 update_black_list = TRUE; | |
2719 } | |
2720 | |
2721 TRACE_EVENT_P8 ( "Old [%d]SC MCC/MNC r=%x%x%x/%x%x%x/%d", | |
2722 rr_data->cs_data.white_list.last_sc_arfcn, | |
2723 rr_data->cs_data.white_list.last_sc_lac.mcc[0], | |
2724 rr_data->cs_data.white_list.last_sc_lac.mcc[1], | |
2725 rr_data->cs_data.white_list.last_sc_lac.mcc[2], | |
2726 rr_data->cs_data.white_list.last_sc_lac.mnc[0], | |
2727 rr_data->cs_data.white_list.last_sc_lac.mnc[1], | |
2728 rr_data->cs_data.white_list.last_sc_lac.mnc[2], | |
2729 rr_data->cs_data.white_list.last_sc_lac.lac); | |
2730 | |
2731 TRACE_EVENT_P8 ( "New [%d]SC MCC/MNC r=%x%x%x/%x%x%x/%d", | |
2732 rr_data->nc_data[SC_INDEX].arfcn, | |
2733 rr_data->nc_data[SC_INDEX].lai.mcc[0], | |
2734 rr_data->nc_data[SC_INDEX].lai.mcc[1], | |
2735 rr_data->nc_data[SC_INDEX].lai.mcc[2], | |
2736 rr_data->nc_data[SC_INDEX].lai.mnc[0], | |
2737 rr_data->nc_data[SC_INDEX].lai.mnc[1], | |
2738 rr_data->nc_data[SC_INDEX].lai.mnc[2], | |
2739 rr_data->nc_data[SC_INDEX].lai.lac); | |
2740 | |
2741 /* If the current serving cell belongs to a different Location area. | |
2742 * Erase the Black List | |
2743 */ | |
2744 if((rr_data->ms_data.rr_service EQ FULL_SERVICE) AND | |
2745 ((rr_data->cs_data.white_list.last_sc_arfcn EQ NOT_PRESENT_16BIT) OR | |
2746 (!dat_plmn_equal_req(rr_data->cs_data.white_list.last_sc_lac.mcc, | |
2747 rr_data->cs_data.white_list.last_sc_lac.mnc, | |
2748 rr_data->nc_data[SC_INDEX].lai.mcc, | |
2749 rr_data->nc_data[SC_INDEX].lai.mnc)) OR | |
2750 (rr_data->cs_data.white_list.last_sc_lac.lac NEQ | |
2751 rr_data->nc_data[SC_INDEX].lai.lac))) | |
2752 { | |
2753 update_black_list = TRUE; | |
2754 } | |
2755 | |
2756 if(update_black_list) | |
2757 { | |
2758 /* Erase the current Black List */ | |
2759 cs_clear_black_list(CLR_BLACK_LIST_RAM); | |
2760 | |
2761 for(i=0;i<rr_data->cs_data.max_arfcn;i++) | |
2762 { | |
2763 if(CS_GET_BLACK_LIST_FLAG(i)) | |
2764 { | |
2765 /* Obtain the region */ | |
2766 region = CS_GET_REGION_FROM_FREQ(rr_data->cs_data.arfcn[i]); | |
2767 | |
2768 cs_add_to_black_list(region, | |
2769 (USHORT)(rr_data->cs_data.arfcn[i]), | |
2770 rr_data->cs_data.rxlev[i]); | |
2771 } | |
2772 } /* i < max_arfcn */ | |
2773 | |
2774 TRACE_EVENT("BL updated after inital PLMN search"); | |
2775 } | |
2776 } | |
2777 | |
2778 /* | |
2779 +----------------------------------------------------------------------+ | |
2780 | PROJECT : GSM-PS (8403) MODULE : RR_CS | | |
2781 | STATE : code ROUTINE : cs_store_black_list | | |
2782 +----------------------------------------------------------------------+ | |
2783 | |
2784 PURPOSE : This is a wrapper function for storing "Black List" | |
2785 information to FFS . This in turn calls | |
2786 rr_csf_write_black_list( ) to store "Black List" to FFS. | |
2787 This function is called during power off. | |
2788 CSI-LLD section:4.1.1.5.2 | |
2789 */ | |
2790 | |
2791 GLOBAL void cs_store_black_list(void) | |
2792 { | |
2793 GET_INSTANCE_DATA; | |
2794 #if defined(_SIMULATION_FFS_) | |
2795 rr_csf_write_black_list(&rr_data->cs_data.black_list.list[0]); | |
2796 #endif | |
2797 } | |
2798 | |
2799 /* | |
2800 +----------------------------------------------------------------------+ | |
2801 | PROJECT : GSM-PS (8403) MODULE : RR_CS | | |
2802 | STATE : code ROUTINE : cs_get_new_search_mode | | |
2803 +----------------------------------------------------------------------+ | |
2804 | |
2805 PURPOSE : This routine returns the new search mode depending on the timer active | |
2806 and the previous search mode | |
2807 CSI-LLD section:4.1.3.4.1.1 | |
2808 */ | |
2809 | |
2810 GLOBAL U8 cs_get_new_search_mode(void) | |
2811 { | |
2812 GET_INSTANCE_DATA; | |
2813 TRACE_FUNCTION("cs_get_new_search_mode()"); | |
2814 | |
2815 if(IS_TIMER_ACTIVE(T_FAST_CS)) | |
2816 { | |
2817 /* Fast search timer is active */ | |
2818 return FAST_SEARCH_MODE; | |
2819 } | |
2820 | |
2821 if(IS_TIMER_ACTIVE(T_NORMAL_CS)) | |
2822 { | |
2823 /* Normal search timer is active */ | |
2824 return NORMAL_SEARCH_MODE; | |
2825 } | |
2826 | |
2827 TRACE_EVENT_P1("Previous Search Mode : %d", | |
2828 rr_data->cs_data.previous_search_mode); | |
2829 | |
2830 if((rr_data->cs_data.previous_search_mode EQ FULL_SEARCH_MODE) | |
2831 OR (rr_data->cs_data.previous_search_mode EQ FAST_SEARCH_MODE)) | |
2832 { | |
2833 return NORMAL_SEARCH_MODE; | |
2834 } | |
2835 | |
2836 if(rr_data->cs_data.previous_search_mode EQ NORMAL_SEARCH_MODE) | |
2837 { | |
2838 return FULL_SEARCH_MODE; | |
2839 } | |
2840 | |
2841 return FULL_SEARCH_MODE; | |
2842 } | |
2843 /* | |
2844 +----------------------------------------------------------------------+ | |
2845 | PROJECT : GSM-PS (8403) MODULE : RR_CS | | |
2846 | STATE : code ROUTINE : cs_handle_search_mode_timer | | |
2847 +----------------------------------------------------------------------+ | |
2848 | |
2849 PURPOSE : This routine handles the timers for the new search modes | |
2850 CSI-LLD section:4.1.3.4.1.2 | |
2851 */ | |
2852 GLOBAL void cs_handle_search_mode_timer(U8 search_mode) | |
2853 { | |
2854 GET_INSTANCE_DATA; | |
2855 TRACE_FUNCTION("cs_handle_search_mode_timer()"); | |
2856 | |
2857 if((search_mode EQ FAST_SEARCH_MODE) AND (rr_data->dyn_config.tfast_cs_val)) | |
2858 { | |
2859 if(!IS_TIMER_ACTIVE(T_FAST_CS)) | |
2860 { | |
2861 TIMERSTART (T_FAST_CS,rr_data->dyn_config.tfast_cs_val); | |
2862 } | |
2863 } | |
2864 | |
2865 if((search_mode EQ NORMAL_SEARCH_MODE) AND (rr_data->dyn_config.tnormal_cs_val)) | |
2866 { | |
2867 if(!IS_TIMER_ACTIVE(T_NORMAL_CS)) | |
2868 { | |
2869 TIMERSTART (T_NORMAL_CS, rr_data->dyn_config.tnormal_cs_val); | |
2870 } | |
2871 } | |
2872 | |
2873 if(search_mode EQ FULL_SEARCH_MODE) | |
2874 { | |
2875 if(rr_data->sc_data.mm_started EQ MM_ORIGINATED AND | |
2876 rr_data->ms_data.req_mm_service NEQ FUNC_NET_SRCH_BY_MMI) | |
2877 { | |
2878 TIMERSTOP(T_FAST_CS); | |
2879 TIMERSTOP(T_NORMAL_CS); | |
2880 } | |
2881 } | |
2882 } | |
2883 | |
2884 /* | |
2885 +--------------------------------------------------------------------+ | |
2886 | PROJECT : GSM-PS (6147) MODULE : RR_CS | | |
2887 | STATE : code ROUTINE : cs_update_std_ffs | | |
2888 +--------------------------------------------------------------------+ | |
2889 | |
2890 PURPOSE : This function updates the std value depending upon the | |
2891 frequency band support by MS. Frequncy band support is | |
2892 available in the FFS. | |
2893 | |
2894 */ | |
2895 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT | |
2896 LOCAL UBYTE cs_update_std_ffs (UBYTE new_std) | |
2897 { | |
2898 UBYTE freq_bands; | |
2899 | |
2900 rr_csf_get_freq_bands (&freq_bands); | |
2901 switch (new_std) | |
2902 { | |
2903 case STD_DUAL_EGSM: | |
2904 if ((freq_bands & BAND_GSM_850) EQ BAND_GSM_850) | |
2905 { | |
2906 return STD_850_900_1800; | |
2907 } | |
2908 break; | |
2909 case STD_DUAL_US: | |
2910 if ((freq_bands & BAND_GSM_900) EQ BAND_GSM_900) | |
2911 { | |
2912 return STD_850_900_1900; | |
2913 } | |
2914 break; | |
2915 default: | |
2916 TRACE_EVENT_P1 ("wrong std for updation using FFS %x", new_std); | |
2917 } | |
2918 return new_std; | |
2919 } | |
2920 #endif | |
2921 #endif |