FreeCalypso > hg > freecalypso-citrine
comparison g23m-gsm/rr/rr_srv.c @ 0:75a11d740a02
initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 09 Jun 2016 00:02:41 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:75a11d740a02 |
---|---|
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 the common | |
18 | services of the component RR of the mobile station. | |
19 +----------------------------------------------------------------------------- | |
20 */ | |
21 | |
22 #ifndef RR_SRV_C | |
23 #define RR_SRV_C | |
24 | |
25 #include "config.h" | |
26 #include "fixedconf.h" | |
27 #include "condat-features.h" | |
28 | |
29 #define ENTITY_RR | |
30 | |
31 /*==== INCLUDES ===================================================*/ | |
32 | |
33 #include <string.h> | |
34 #include <stdlib.h> | |
35 #include <stddef.h> /* offsetof */ | |
36 #include "typedefs.h" | |
37 #include "pcm.h" | |
38 #include "pconst.cdg" | |
39 #include "mconst.cdg" | |
40 #include "message.h" | |
41 #include "ccdapi.h" | |
42 #include "vsi.h" | |
43 #include "custom.h" | |
44 #include "gsm.h" | |
45 #include "prim.h" | |
46 #include "cnf_rr.h" | |
47 #include "tok.h" | |
48 #include "rr.h" | |
49 | |
50 | |
51 /*==== EXPORT =====================================================*/ | |
52 | |
53 /*==== PRIVAT =====================================================*/ | |
54 LOCAL UBYTE srv_is_not_in_list (USHORT * channels, | |
55 USHORT new_channel, | |
56 USHORT size); | |
57 /*==== VARIABLES ==================================================*/ | |
58 | |
59 /*==== FUNCTIONS ==================================================*/ | |
60 /* | |
61 +--------------------------------------------------------------------+ | |
62 | PROJECT : GSM-PS (6147) MODULE : RR_SRV | | |
63 | STATE : code ROUTINE : srv_store_prim | | |
64 +--------------------------------------------------------------------+ | |
65 | |
66 PURPOSE : stores a primitive into a ring buffer. The buffer contains | |
67 up to MAX_RR_STORED_PRIM primitives. The ring buffer is | |
68 controlled by the variables stored_prim_in, which is the | |
69 index of the next free place in the buffer. The variable | |
70 stored_prim_read defines the number of stored primitives, | |
71 which are already indicated as to be read again (by function | |
72 srv_use_stored_prim. The variable stored_prim_write indicates | |
73 the number of stored primitives, which are not indicated as | |
74 to be read again (by function srv_use_stored_prim). | |
75 The return value of the function indicates whether the storing | |
76 was successful or not. | |
77 | |
78 */ | |
79 | |
80 BOOL srv_store_prim (T_PRIM * prim) | |
81 { | |
82 GET_INSTANCE_DATA; | |
83 TRACE_FUNCTION ("srv_store_prim()"); | |
84 | |
85 /* | |
86 * check the limits. If buffer is full, return false. | |
87 */ | |
88 if (rr_data->stored_prim_read + rr_data->stored_prim_write >= | |
89 MAX_RR_STORED_PRIM) | |
90 { | |
91 TRACE_EVENT ("Buffer overrun"); | |
92 return FALSE; | |
93 } | |
94 | |
95 /* | |
96 * Else store the primitive | |
97 */ | |
98 TRACE_EVENT ("save prim"); | |
99 | |
100 /* | |
101 * store primitive address and increment stored_prim_in | |
102 * to next free location. | |
103 */ | |
104 rr_data->stored_prim [rr_data->stored_prim_in++] = prim; | |
105 | |
106 /* | |
107 * set stored_prim_in to 0 if at the boarder of the ring buffer | |
108 */ | |
109 if (rr_data->stored_prim_in EQ MAX_RR_STORED_PRIM) | |
110 { | |
111 rr_data->stored_prim_in = 0; | |
112 } | |
113 | |
114 /* | |
115 * increment Number of the stored primitives which are not | |
116 * indicated as to be read again. | |
117 */ | |
118 rr_data->stored_prim_write++; | |
119 | |
120 /* | |
121 * return the success of storing of the primitive. | |
122 */ | |
123 return TRUE; | |
124 } | |
125 | |
126 /* | |
127 +--------------------------------------------------------------------+ | |
128 | PROJECT : GSM-PS (6147) MODULE : RR_SRV | | |
129 | STATE : code ROUTINE : srv_use_stored_prim | | |
130 +--------------------------------------------------------------------+ | |
131 | |
132 PURPOSE : The function re-send all stored primitives to RR. This | |
133 function is called by RR whenever a stored primitive must | |
134 be taken in account, e.g. after cell reselection to handle | |
135 a stored paging. | |
136 | |
137 */ | |
138 | |
139 GLOBAL void srv_use_stored_prim (void) | |
140 { | |
141 GET_INSTANCE_DATA; | |
142 TRACE_FUNCTION ("srv_use_stored_prim()"); | |
143 | |
144 ENTITY_DATA->use_stored_entries = FALSE; | |
145 | |
146 /* | |
147 * Only if anything new has been stored | |
148 */ | |
149 if (rr_data->stored_prim_write > 0) | |
150 { | |
151 /* | |
152 * increment the number of primitives which | |
153 * must be re-send to RR by the number of | |
154 * newly stored primitives and reset this variable | |
155 * to zero. | |
156 */ | |
157 rr_data->stored_prim_read += | |
158 rr_data->stored_prim_write; | |
159 rr_data->stored_prim_write = 0; | |
160 | |
161 /* | |
162 * For all stored primitives | |
163 */ | |
164 while (rr_data->stored_prim_read NEQ 0) | |
165 { | |
166 T_PRIM * prim; | |
167 | |
168 rr_data->stored_prim_read--; | |
169 | |
170 /* | |
171 * get the primitive address | |
172 */ | |
173 prim = rr_data->stored_prim[rr_data->stored_prim_out]; | |
174 rr_data->stored_prim[rr_data->stored_prim_out ] = NULL; | |
175 rr_data->stored_prim_out++; | |
176 /* | |
177 * set the stored_prim_out pointer to the start of the | |
178 * ring buffer, if it is at the end of the buffer | |
179 */ | |
180 if (rr_data->stored_prim_out EQ MAX_RR_STORED_PRIM) | |
181 rr_data->stored_prim_out = 0; | |
182 | |
183 /* | |
184 * If the stored primitive is a paging_ind clear the stored paging flag | |
185 * right away. If not the paging will be thrown away if the flag was | |
186 * not reset propperly on the outside | |
187 */ | |
188 if(prim NEQ NULL AND prim->custom.opc EQ MPH_PAGING_IND) | |
189 { | |
190 rr_data->pag_rec = FALSE; | |
191 } | |
192 | |
193 /* | |
194 * call the protocol entity interface function to handle | |
195 * the stored primitive. | |
196 */ | |
197 rr_pei_primitive (prim); | |
198 } | |
199 } | |
200 } | |
201 | |
202 /* | |
203 +--------------------------------------------------------------------+ | |
204 | PROJECT : GSM-PS (6147) MODULE : RR_SRV | | |
205 | STATE : code ROUTINE : srv_clear_stored_prim | | |
206 +--------------------------------------------------------------------+ | |
207 | |
208 PURPOSE : The function clears all primitives with the given opcode | |
209 from the ring buffer. If the opcode matches, it releases | |
210 the partition and stores instead a NULL pointer. | |
211 | |
212 */ | |
213 | |
214 GLOBAL void srv_clear_stored_prim (ULONG opc) | |
215 { | |
216 GET_INSTANCE_DATA; | |
217 USHORT i, out; | |
218 | |
219 TRACE_FUNCTION ("srv_clear_stored_prim()"); | |
220 | |
221 /* | |
222 * Only if anything is stored | |
223 */ | |
224 if (rr_data->stored_prim_read + rr_data->stored_prim_write > 0) | |
225 { | |
226 /* | |
227 * Calculate the number of stored primitives and the beginning | |
228 */ | |
229 i = rr_data->stored_prim_read + rr_data->stored_prim_write; | |
230 out = rr_data->stored_prim_out; | |
231 | |
232 while (i NEQ 0) | |
233 { | |
234 /* | |
235 * for each stored primitive | |
236 */ | |
237 T_PRIM * prim; | |
238 | |
239 i--; | |
240 | |
241 /* | |
242 * Get the partition | |
243 */ | |
244 prim = rr_data->stored_prim[out]; | |
245 if (prim NEQ NULL AND prim->custom.opc EQ opc) | |
246 { | |
247 /* | |
248 * If a primitive is stored and it has the | |
249 * exspected opcode, release the primitive | |
250 * and store instead a NULL pointer. | |
251 */ | |
252 PFREE (P2D(prim)); | |
253 rr_data->stored_prim[out] = NULL; | |
254 } | |
255 /* | |
256 * increment out index and set it to 0 if | |
257 * it is on the right boarder of the ring buffer | |
258 */ | |
259 out++; | |
260 if (out EQ MAX_RR_STORED_PRIM) | |
261 out = 0; | |
262 } | |
263 } | |
264 } | |
265 | |
266 /* | |
267 +--------------------------------------------------------------------+ | |
268 | PROJECT : GSM-PS (6147) MODULE : RR_SRV | | |
269 | STATE : code ROUTINE : srv_check_stored_prim | | |
270 +--------------------------------------------------------------------+ | |
271 | |
272 PURPOSE : Check specific stored primitives. Indicates whether | |
273 a primitive with opcode opc is already stored. | |
274 | |
275 */ | |
276 | |
277 GLOBAL UBYTE srv_check_stored_prim (ULONG opc) | |
278 { | |
279 GET_INSTANCE_DATA; | |
280 USHORT i, out; | |
281 | |
282 TRACE_FUNCTION ("srv_check_stored_prim()"); | |
283 | |
284 /* | |
285 * only if a primitve is stored | |
286 */ | |
287 if (rr_data->stored_prim_read + rr_data->stored_prim_write > 0) | |
288 { | |
289 /* | |
290 * calculate number of stored primitives and the beginning | |
291 */ | |
292 i = rr_data->stored_prim_read + rr_data->stored_prim_write; | |
293 out = rr_data->stored_prim_out; | |
294 | |
295 while (i NEQ 0) | |
296 { | |
297 /* | |
298 * for all stored primitives | |
299 */ | |
300 T_PRIM * prim; | |
301 | |
302 i--; | |
303 /* | |
304 * get the primitive address | |
305 */ | |
306 prim = rr_data->stored_prim[out]; | |
307 if (prim NEQ NULL AND prim->custom.opc EQ opc) | |
308 { | |
309 /* | |
310 * return TRUE if a primitive is stored and the opcode | |
311 * is as expected. | |
312 */ | |
313 return TRUE; | |
314 } | |
315 /* | |
316 * increase out index to the next entry | |
317 */ | |
318 out++; | |
319 if (out EQ MAX_RR_STORED_PRIM) | |
320 out = 0; | |
321 } | |
322 } | |
323 | |
324 /* | |
325 * nothing found | |
326 */ | |
327 return FALSE; | |
328 } | |
329 | |
330 /* | |
331 +---------------------------------------------------------------------------+ | |
332 | PROJECT : GSM-PS (6147) MODULE : RR_SRV | | |
333 | STATE : code ROUTINE : srv_compare_used_frequency_bands | | |
334 +---------------------------------------------------------------------------+ | |
335 | |
336 PURPOSE : Looks at the frequency bands which were used and compares | |
337 them with the supported bands. Checks if the MA spans more | |
338 then one band (exception is the EGSM part). | |
339 | |
340 */ | |
341 | |
342 LOCAL int srv_compare_used_frequency_bands (int frequency_bands_used) | |
343 { | |
344 int nr_of_frequency_bands_used; | |
345 switch(frequency_bands_used) | |
346 { | |
347 case LOW_BAND_USED: | |
348 if(std EQ STD_900 OR std EQ STD_EGSM OR std EQ STD_850 OR | |
349 std EQ STD_DUAL OR std EQ STD_DUAL_EGSM OR std EQ STD_DUAL_US | |
350 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT | |
351 OR std EQ STD_850_1800 OR std EQ STD_900_1900 OR std EQ STD_850_900_1800 OR | |
352 std EQ STD_850_900_1900 | |
353 #endif | |
354 ) | |
355 nr_of_frequency_bands_used = 1; | |
356 else | |
357 nr_of_frequency_bands_used = 0; | |
358 break; | |
359 case HIGH_BAND_USED: | |
360 if(std EQ STD_1800 OR std EQ STD_1900 OR | |
361 std EQ STD_DUAL OR std EQ STD_DUAL_EGSM OR std EQ STD_DUAL_US | |
362 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT | |
363 OR std EQ STD_850_1800 OR std EQ STD_900_1900 OR std EQ STD_850_900_1800 OR | |
364 std EQ STD_850_900_1900 | |
365 #endif | |
366 ) | |
367 nr_of_frequency_bands_used = 1; | |
368 else | |
369 nr_of_frequency_bands_used = 0; | |
370 break; | |
371 case EXT_BAND_USED: | |
372 case LOW_BAND_USED|EXT_BAND_USED: | |
373 if(std EQ STD_EGSM OR std EQ STD_DUAL_EGSM | |
374 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT | |
375 OR std EQ STD_900_1900 OR std EQ STD_850_900_1800 OR std EQ STD_850_900_1900 | |
376 #endif | |
377 ) | |
378 nr_of_frequency_bands_used = 1; | |
379 else | |
380 nr_of_frequency_bands_used = 0; | |
381 break; | |
382 default: | |
383 nr_of_frequency_bands_used = 0; | |
384 break; | |
385 } | |
386 | |
387 return nr_of_frequency_bands_used; | |
388 } | |
389 | |
390 /* | |
391 +--------------------------------------------------------------------+ | |
392 | PROJECT : GSM-PS (6147) MODULE : RR_SRV | | |
393 | STATE : code ROUTINE : srv_create_chan_mob_alloc | | |
394 +--------------------------------------------------------------------+ | |
395 | |
396 PURPOSE : create a frequency hopping list from channel list and | |
397 mobile allocation. The mobile allocation is a bitmap. | |
398 if the n-th bit of the mobile allocation is set to zero, | |
399 the n-th channel in the channel list is not member of the | |
400 frequency hopping list. If the n-th bit of the mobile | |
401 allocation is set to one, the n-th channel in the channel list | |
402 is member of the frequency hopping list. | |
403 | |
404 e.g: channel list has the members 10,20,30,40,50,60,70 and | |
405 in the mobile allocation the bits 1,3 and 4 are set: | |
406 | |
407 channel list: 10 20 30 40 50 60 70 | |
408 mobile allocation: 0 1 0 1 1 0 0 | |
409 | |
410 that means the hopping list is 20, 40, 50. | |
411 | |
412 The format of the mobile allocation is an UBYTE array with the | |
413 end identifier NOT_PRESENT_8BIT (0xFF). | |
414 | |
415 The function returns TRUE if the Mobile Allocation is in one | |
416 frequency band. If the Mobile Allocation is spread over multiple | |
417 frequency bands FALSE is returned and the values returned are | |
418 invalid. | |
419 | |
420 */ | |
421 | |
422 GLOBAL int srv_create_chan_mob_alloc (T_LIST *clist, | |
423 T_LIST *list, | |
424 UBYTE *mobile_alloc) | |
425 { | |
426 /* | |
427 * index in the mobile allocation list | |
428 */ | |
429 USHORT ma_index = 0; | |
430 /* | |
431 * get value of the first bit which is set in the mobile allocation | |
432 */ | |
433 UBYTE ma_value = mobile_alloc [ma_index++]; | |
434 UBYTE x = 0; | |
435 UBYTE result; | |
436 USHORT arfcn; | |
437 UBYTE band_used; | |
438 UBYTE freq_band_used = 0; | |
439 | |
440 TRACE_FUNCTION ("srv_create_chan_mob_alloc()"); | |
441 | |
442 /* | |
443 * clear the result list | |
444 */ | |
445 srv_clear_list (list); | |
446 | |
447 /* | |
448 * Check all Frequencies. | |
449 */ | |
450 if(ma_value NEQ NOT_PRESENT_8BIT) | |
451 { | |
452 for (arfcn=LOW_CHANNEL_900; arfcn<HIGH_CHANNEL_EGSM; arfcn++) | |
453 { | |
454 result = srv_get_channel (clist, arfcn); | |
455 if (result) | |
456 { | |
457 x++; | |
458 } | |
459 if (x EQ ma_value) | |
460 { | |
461 band_used = for_check_frequency(arfcn); | |
462 if(band_used <= INVALID_BAND_USED) | |
463 return FALSE; | |
464 | |
465 freq_band_used = freq_band_used | band_used; | |
466 | |
467 srv_set_channel (list, arfcn); | |
468 ma_value = mobile_alloc [ma_index++]; | |
469 if (ma_value EQ NOT_PRESENT_8BIT) | |
470 break; | |
471 } | |
472 } | |
473 } | |
474 else | |
475 { | |
476 TRACE_EVENT("Mobile Allocation list empty"); | |
477 return FALSE; | |
478 } | |
479 | |
480 /* | |
481 * at last add channel 0 if needed | |
482 */ | |
483 | |
484 if (ma_value NEQ NOT_PRESENT_8BIT) | |
485 { | |
486 result = srv_get_channel (clist, CHANNEL_0); | |
487 if (result) | |
488 { | |
489 x++; | |
490 } | |
491 if (x EQ ma_value) | |
492 { | |
493 srv_set_channel (list, CHANNEL_0); | |
494 band_used = for_check_frequency(CHANNEL_0); | |
495 if(band_used <= INVALID_BAND_USED) | |
496 return FALSE; | |
497 freq_band_used = freq_band_used | EXT_BAND_USED; | |
498 } | |
499 } | |
500 | |
501 return srv_compare_used_frequency_bands(freq_band_used); | |
502 } | |
503 | |
504 | |
505 /* | |
506 +----------------------------------------------------------------------+ | |
507 | PROJECT : GSM-PS (6147) MODULE : RR_SRV | | |
508 | STATE : code ROUTINE : srv_check_frequencies_in_list| | |
509 +----------------------------------------------------------------------+ | |
510 | |
511 PURPOSE : Checks used frequencies and returns. Returns number | |
512 of frequencies used. | |
513 | |
514 */ | |
515 | |
516 GLOBAL int srv_check_frequencies_in_list(T_LIST *clist) | |
517 { | |
518 int frequency_bands_used = 0; | |
519 int i; | |
520 | |
521 TRACE_FUNCTION ("srv_check_frequencies_in_list()"); | |
522 | |
523 /* | |
524 * Depending on the frequency standard | |
525 */ | |
526 switch (std) | |
527 { | |
528 case STD_900: | |
529 case STD_EGSM: | |
530 case STD_1800: | |
531 case STD_DUAL: | |
532 case STD_DUAL_EGSM: | |
533 /* | |
534 * First check GSM 900 | |
535 */ | |
536 for (i=LOW_CHANNEL_900; i<=HIGH_CHANNEL_900; i++) | |
537 { | |
538 if (srv_get_channel (clist, i)) | |
539 frequency_bands_used |= LOW_BAND_USED; | |
540 } | |
541 | |
542 for (i=LOW_CHANNEL_1800; i<=HIGH_CHANNEL_1800; i++) | |
543 { | |
544 if (srv_get_channel (clist, i)) | |
545 frequency_bands_used |= HIGH_BAND_USED; | |
546 } | |
547 for (i=LOW_CHANNEL_EGSM; i<HIGH_CHANNEL_EGSM; i++) | |
548 { | |
549 if (srv_get_channel (clist, i)) | |
550 frequency_bands_used |= EXT_BAND_USED; | |
551 } | |
552 if (srv_get_channel (clist, CHANNEL_0)) | |
553 frequency_bands_used |= EXT_BAND_USED; | |
554 break; | |
555 case STD_850: | |
556 case STD_1900: | |
557 case STD_DUAL_US: | |
558 for (i=LOW_CHANNEL_850; i<=HIGH_CHANNEL_850; i++) | |
559 { | |
560 if (srv_get_channel (clist, i)) | |
561 frequency_bands_used |= LOW_BAND_USED; | |
562 } | |
563 | |
564 for (i=LOW_CHANNEL_1900; i<=HIGH_CHANNEL_1900; i++) | |
565 { | |
566 if (srv_get_channel (clist, i)) | |
567 frequency_bands_used |= HIGH_BAND_USED; | |
568 } | |
569 break; | |
570 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT | |
571 case STD_850_1800: | |
572 for (i=LOW_CHANNEL_850; i<=HIGH_CHANNEL_850; i++) | |
573 { | |
574 if (srv_get_channel (clist, i)) | |
575 frequency_bands_used |= LOW_BAND_USED; | |
576 } | |
577 | |
578 for (i=LOW_CHANNEL_1800; i<=HIGH_CHANNEL_1800; i++) | |
579 { | |
580 if (srv_get_channel (clist, i)) | |
581 frequency_bands_used |= HIGH_BAND_USED; | |
582 } | |
583 break; | |
584 case STD_900_1900: | |
585 for (i=LOW_CHANNEL_900; i<=HIGH_CHANNEL_900; i++) | |
586 { | |
587 if (srv_get_channel (clist, i)) | |
588 frequency_bands_used |= LOW_BAND_USED; | |
589 } | |
590 | |
591 for (i=LOW_CHANNEL_1900; i<=HIGH_CHANNEL_1900; i++) | |
592 { | |
593 if (srv_get_channel (clist, i)) | |
594 frequency_bands_used |= HIGH_BAND_USED; | |
595 } | |
596 for (i=LOW_CHANNEL_EGSM; i<HIGH_CHANNEL_EGSM; i++) | |
597 { | |
598 if (srv_get_channel (clist, i)) | |
599 frequency_bands_used |= EXT_BAND_USED; | |
600 } | |
601 if (srv_get_channel (clist, CHANNEL_0)) | |
602 frequency_bands_used |= EXT_BAND_USED; | |
603 break; | |
604 case STD_850_900_1800: | |
605 for (i=LOW_CHANNEL_900; i<=HIGH_CHANNEL_900; i++) | |
606 { | |
607 if (srv_get_channel (clist, i)) | |
608 frequency_bands_used |= LOW_BAND_USED; | |
609 } | |
610 | |
611 for (i=LOW_CHANNEL_1800; i<=HIGH_CHANNEL_1800; i++) | |
612 { | |
613 if (srv_get_channel (clist, i)) | |
614 frequency_bands_used |= HIGH_BAND_USED; | |
615 } | |
616 for (i=LOW_CHANNEL_EGSM; i<HIGH_CHANNEL_EGSM; i++) | |
617 { | |
618 if (srv_get_channel (clist, i)) | |
619 frequency_bands_used |= EXT_BAND_USED; | |
620 } | |
621 for (i=LOW_CHANNEL_850; i<=HIGH_CHANNEL_850; i++) | |
622 { | |
623 if (srv_get_channel (clist, i)) | |
624 frequency_bands_used |= LOW_BAND_USED; | |
625 } | |
626 if (srv_get_channel (clist, CHANNEL_0)) | |
627 frequency_bands_used |= EXT_BAND_USED; | |
628 break; | |
629 case STD_850_900_1900: | |
630 for (i=LOW_CHANNEL_900; i<=HIGH_CHANNEL_900; i++) | |
631 { | |
632 if (srv_get_channel (clist, i)) | |
633 frequency_bands_used |= LOW_BAND_USED; | |
634 } | |
635 for (i=LOW_CHANNEL_EGSM; i<HIGH_CHANNEL_EGSM; i++) | |
636 { | |
637 if (srv_get_channel (clist, i)) | |
638 frequency_bands_used |= EXT_BAND_USED; | |
639 } | |
640 for (i=LOW_CHANNEL_850; i<=HIGH_CHANNEL_850; i++) | |
641 { | |
642 if (srv_get_channel (clist, i)) | |
643 frequency_bands_used |= LOW_BAND_USED; | |
644 } | |
645 for (i=LOW_CHANNEL_1900; i<=HIGH_CHANNEL_1900; i++) | |
646 { | |
647 if (srv_get_channel (clist, i)) | |
648 frequency_bands_used |= HIGH_BAND_USED; | |
649 } | |
650 if (srv_get_channel (clist, CHANNEL_0)) | |
651 frequency_bands_used |= EXT_BAND_USED; | |
652 break; | |
653 #endif | |
654 default: | |
655 /* | |
656 * just for LINT | |
657 */ | |
658 break; | |
659 } | |
660 | |
661 return srv_compare_used_frequency_bands (frequency_bands_used); | |
662 } | |
663 | |
664 /* | |
665 +--------------------------------------------------------------------+ | |
666 | PROJECT : GSM-PS (6147) MODULE : RR_SRV | | |
667 | STATE : code ROUTINE : srv_remove_frequencies_in_array_gen | | |
668 +--------------------------------------------------------------------+ | |
669 | |
670 PURPOSE : The functions manipulates the neighbourcell list send to | |
671 layer 1. It filters out not supported frequencies or if | |
672 enabled allows to configure a band restriction, that means that | |
673 the mobile camps inside GSM 900 or DCS 1800. The band | |
674 restriction can be configured by a dynamic configuration | |
675 command. | |
676 | |
677 */ | |
678 | |
679 GLOBAL UBYTE srv_remove_frequencies_in_array_gen (USHORT* arfcn_list, UBYTE c_arfcn_list) | |
680 { | |
681 GET_INSTANCE_DATA; | |
682 int in,out, ranges; | |
683 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT | |
684 USHORT low[4], high[4]; | |
685 #else | |
686 USHORT low[3], high[3]; | |
687 #endif | |
688 UBYTE local_std = std; | |
689 | |
690 TRACE_FUNCTION ("att_check_band_restrictions()"); | |
691 | |
692 in = out = ranges = 0; | |
693 | |
694 memset (low, NOT_PRESENT_8BIT, sizeof (low)); | |
695 memset (high, NOT_PRESENT_8BIT, sizeof (high)); | |
696 | |
697 if(rr_data->dyn_config.set_band) | |
698 { | |
699 /* set band is activated */ | |
700 if (rr_data->dyn_config.set_band EQ 1) local_std = STD_900; | |
701 else if (rr_data->dyn_config.set_band EQ 2) local_std = STD_1800; | |
702 } | |
703 | |
704 switch (local_std) | |
705 { | |
706 case STD_DUAL: | |
707 ranges=2; | |
708 low[0]=LOW_CHANNEL_1800; | |
709 low[1]=LOW_CHANNEL_900; | |
710 high[0]=HIGH_CHANNEL_1800; | |
711 high[1]=HIGH_CHANNEL_900; | |
712 break; | |
713 case STD_DUAL_EGSM: | |
714 /* shift the ranges to allow CHANNEL_0 */ | |
715 ranges=3; | |
716 low[0]=LOW_CHANNEL_900-1;/*lint !e778 */ | |
717 low[1]=LOW_CHANNEL_EGSM; | |
718 low[2]=LOW_CHANNEL_1800; | |
719 high[0]=HIGH_CHANNEL_900; | |
720 high[1]=HIGH_CHANNEL_EGSM-1; | |
721 high[2]=HIGH_CHANNEL_1800; | |
722 break; | |
723 case STD_DUAL_US: | |
724 ranges=2; | |
725 low[0]=LOW_CHANNEL_1900; | |
726 low[1]=LOW_CHANNEL_850; | |
727 high[0]=HIGH_CHANNEL_1900; | |
728 high[1]=HIGH_CHANNEL_850; | |
729 break; | |
730 case STD_EGSM: | |
731 low[0] = LOW_CHANNEL_EGSM; | |
732 low[1] = LOW_CHANNEL_900-1;/*lint !e778 */ | |
733 high[0] = HIGH_CHANNEL_EGSM-1; | |
734 high[1] = HIGH_CHANNEL_900; | |
735 ranges=2; | |
736 break; | |
737 case STD_900: | |
738 low[0] = LOW_CHANNEL_900; | |
739 high[0] = HIGH_CHANNEL_900; | |
740 ranges=1; | |
741 break; | |
742 case STD_1800: | |
743 low[0] = LOW_CHANNEL_1800; | |
744 high[0] = HIGH_CHANNEL_1800; | |
745 ranges=1; | |
746 break; | |
747 case STD_1900: | |
748 low[0] = LOW_CHANNEL_1900; | |
749 high[0] = HIGH_CHANNEL_1900; | |
750 ranges=1; | |
751 break; | |
752 case STD_850: | |
753 low[0] = LOW_CHANNEL_850; | |
754 high[0] = HIGH_CHANNEL_850; | |
755 ranges=1; | |
756 break; | |
757 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT | |
758 case STD_850_1800: | |
759 ranges=2; | |
760 low[0]=LOW_CHANNEL_1800; | |
761 low[1]=LOW_CHANNEL_850; | |
762 high[0]=HIGH_CHANNEL_1800; | |
763 high[1]=HIGH_CHANNEL_850; | |
764 break; | |
765 case STD_900_1900: | |
766 /* shift the ranges to allow CHANNEL_0 */ | |
767 ranges=3; | |
768 low[0]=LOW_CHANNEL_900-1;/*lint !e778 */ | |
769 low[1]=LOW_CHANNEL_EGSM; | |
770 low[2]=LOW_CHANNEL_1900; | |
771 high[0]=HIGH_CHANNEL_900; | |
772 high[1]=HIGH_CHANNEL_EGSM-1; | |
773 high[2]=HIGH_CHANNEL_1900; | |
774 break; | |
775 case STD_850_900_1800: | |
776 ranges=4; | |
777 low[0]=LOW_CHANNEL_900-1;/*lint !e778 */ | |
778 low[1]=LOW_CHANNEL_EGSM; | |
779 low[2]=LOW_CHANNEL_1800; | |
780 low[3]=LOW_CHANNEL_850; | |
781 high[0]=HIGH_CHANNEL_900; | |
782 high[1]=HIGH_CHANNEL_EGSM-1; | |
783 high[2]=HIGH_CHANNEL_1800; | |
784 high[3]=HIGH_CHANNEL_850; | |
785 break; | |
786 case STD_850_900_1900: | |
787 ranges=4; | |
788 low[0]=LOW_CHANNEL_900-1;/*lint !e778 */ | |
789 low[1]=LOW_CHANNEL_EGSM; | |
790 low[2]=LOW_CHANNEL_1900; | |
791 low[3]=LOW_CHANNEL_850; | |
792 high[0]=HIGH_CHANNEL_900; | |
793 high[1]=HIGH_CHANNEL_EGSM-1; | |
794 high[2]=HIGH_CHANNEL_1900; | |
795 high[3]=HIGH_CHANNEL_850; | |
796 break; | |
797 #endif | |
798 default: | |
799 /* default */ | |
800 break; | |
801 } | |
802 | |
803 if (ranges) | |
804 { | |
805 while (arfcn_list[in] NEQ NOT_PRESENT_16BIT AND | |
806 in < c_arfcn_list) | |
807 { | |
808 UBYTE r = ranges; | |
809 while(r) | |
810 { | |
811 if (INRANGE(low[r-1],arfcn_list[in],high[r-1])) | |
812 { | |
813 arfcn_list[out] = arfcn_list[in]; | |
814 out++; | |
815 } | |
816 r--; | |
817 } | |
818 in++; | |
819 } | |
820 arfcn_list[out] = NOT_PRESENT_16BIT; | |
821 } | |
822 | |
823 TRACE_EVENT_WIN_P2 ("%d of %d arfcn's removed", in - out, in); | |
824 | |
825 return out; | |
826 } | |
827 | |
828 /* | |
829 +--------------------------------------------------------------------+ | |
830 | PROJECT : GSM-PS (6147) MODULE : RR_SRV | | |
831 | STATE : code ROUTINE : srv_remove_frequencies_in_array | | |
832 +--------------------------------------------------------------------+ | |
833 | |
834 PURPOSE : The functions manipulates the neighbourcell list send to | |
835 layer 1. It filters out not supported frequencies or if | |
836 enabled allows to configure a band restriction, that means that | |
837 the mobile camps inside GSM 900 or DCS 1800. The band | |
838 restriction can be configured by a dynamic configuration | |
839 command. | |
840 | |
841 */ | |
842 | |
843 GLOBAL void srv_remove_frequencies_in_array (USHORT* arfcn_list) | |
844 { | |
845 srv_remove_frequencies_in_array_gen (arfcn_list, MAX_NEIGHBOURCELLS); | |
846 } | |
847 | |
848 /* | |
849 +-------------------------------------------------------------+ | |
850 | PROJECT : GSM-PS (6147) MODULE : RR_SRV | | |
851 | STATE : code ROUTINE : srv_trace_black_list| | |
852 +-------------------------------------------------------------+ | |
853 | |
854 PURPOSE : Traces Black list channels | |
855 */ | |
856 | |
857 GLOBAL void srv_trace_black_list() | |
858 { | |
859 GET_INSTANCE_DATA; | |
860 U8 i; | |
861 T_LIST *list; | |
862 | |
863 /* Trace Black List Channels */ | |
864 for(i=0;i<MAX_REGIONS;i++) | |
865 { | |
866 list = &rr_data->cs_data.black_list.list[i]; | |
867 | |
868 TRACE_EVENT_P1("Black List:[%d]Region",i); | |
869 | |
870 srv_trace_freq_in_list(list); | |
871 | |
872 } | |
873 } | |
874 | |
875 /* | |
876 +--------------------------------------------------------------+ | |
877 | PROJECT : GSM-PS (6147) MODULE : RR_SRV | | |
878 | STATE : code ROUTINE : srv_trace_white_list | | |
879 +--------------------------------------------------------------+ | |
880 | |
881 PURPOSE : Traces White list channels | |
882 */ | |
883 | |
884 GLOBAL void srv_trace_white_list() | |
885 { | |
886 GET_INSTANCE_DATA; | |
887 T_LIST *list; | |
888 | |
889 /* Trace White List Channels */ | |
890 if(rr_data->cs_data.white_list.region NEQ NOT_PRESENT_8BIT) | |
891 { | |
892 list = &rr_data->cs_data.white_list.list; | |
893 | |
894 TRACE_EVENT_P9 ( "[%d]Reg [%d]SC MCC/MNC r=%x%x%x/%x%x%x/%d", | |
895 rr_data->cs_data.white_list.region, | |
896 rr_data->cs_data.white_list.last_sc_arfcn, | |
897 rr_data->cs_data.white_list.last_sc_lac.mcc[0], | |
898 rr_data->cs_data.white_list.last_sc_lac.mcc[1], | |
899 rr_data->cs_data.white_list.last_sc_lac.mcc[2], | |
900 rr_data->cs_data.white_list.last_sc_lac.mnc[0], | |
901 rr_data->cs_data.white_list.last_sc_lac.mnc[1], | |
902 rr_data->cs_data.white_list.last_sc_lac.mnc[2], | |
903 rr_data->cs_data.white_list.last_sc_lac.lac); | |
904 | |
905 srv_trace_freq_in_list(list); | |
906 } | |
907 else | |
908 { | |
909 TRACE_EVENT("White List absent"); | |
910 } | |
911 | |
912 } | |
913 | |
914 #if !defined(NTRACE) | |
915 #if 0 | |
916 | |
917 /* | |
918 +--------------------------------------------------------------------+ | |
919 | PROJECT : GSM-PS (6147) MODULE : RR_ATT | | |
920 | STATE : code ROUTINE : srv_list_channels | | |
921 +--------------------------------------------------------------------+ | |
922 | |
923 PURPOSE : print list of channels to the trace interface. | |
924 */ | |
925 #define SRV_LIST_CHANNELS_TMPBUFSIZE 80 /* sprintf is limited to 80 characters */ | |
926 static char src_list_channels_tmpbuf[SRV_LIST_CHANNELS_TMPBUFSIZE]; | |
927 #if defined(_SIMULATION_) | |
928 int sprintf( char *buffer, const char *format, ... ); | |
929 #endif | |
930 | |
931 GLOBAL void srv_list_channels (USHORT* channel_list, USHORT size, char* titel) | |
932 { | |
933 UBYTE i,o; | |
934 | |
935 o = sprintf(src_list_channels_tmpbuf, "%s ", titel); | |
936 for (i = 0; i < size; i++) | |
937 if (channel_list[i] NEQ NOT_PRESENT_16BIT) | |
938 { | |
939 if (o>SRV_LIST_CHANNELS_TMPBUFSIZE-5) | |
940 { | |
941 TRACE_EVENT (src_list_channels_tmpbuf); | |
942 o = 0; | |
943 } | |
944 o += sprintf(src_list_channels_tmpbuf+o, "%u,", channel_list[i]); | |
945 } | |
946 if (o) | |
947 { | |
948 src_list_channels_tmpbuf[o-1] = 0; | |
949 TRACE_EVENT (src_list_channels_tmpbuf); | |
950 } | |
951 } | |
952 #endif /* !NTRACE */ | |
953 #endif | |
954 | |
955 #ifdef GPRS | |
956 | |
957 /* | |
958 +--------------------------------------------------------------------+ | |
959 | PROJECT : GSM-PS (6147) MODULE : RR_SRV | | |
960 | STATE : code ROUTINE : srv_get_cell_alloc_list | | |
961 +--------------------------------------------------------------------+ | |
962 | |
963 PURPOSE : Access function in RR to get cell alloc list. Needed by GRR to set | |
964 up hopping config. | |
965 | |
966 */ | |
967 /* called by GRR */ | |
968 /*lint -esym(714,srv_get_cell_alloc_list) | Symbol not referenced */ | |
969 /*lint -esym(765,srv_get_cell_alloc_list) | external could be made static */ | |
970 GLOBAL void srv_get_cell_alloc_list (T_LIST * target_list) | |
971 { | |
972 GET_INSTANCE_DATA; | |
973 srv_merge_list ( target_list, &rr_data->sc_data.cd.cell_chan_desc ); | |
974 } | |
975 | |
976 #endif /* GPRS */ | |
977 | |
978 #if defined(ARRAY_TRACE) | |
979 GLOBAL void array_trace (UBYTE*array, int size, char *titel) | |
980 { | |
981 #define MAXCOL 80 | |
982 static char buf[MAXCOL+1]; | |
983 int col=0, n=0; | |
984 UBYTE b, nh, nl; | |
985 | |
986 memset (buf, 0, MAXCOL+1); | |
987 TRACE_EVENT_P2 ("%s size=%u bytes", titel, size); | |
988 while (n < size) | |
989 { | |
990 if (col >= MAXCOL-3) | |
991 { | |
992 TRACE_EVENT (buf); | |
993 col = 0; | |
994 memset (buf, 0, MAXCOL+1); | |
995 } | |
996 b = array[n++]; | |
997 nh = b>>4; | |
998 nl = b&0x0f; | |
999 buf[col++] = nh > 9 ? nh + 'A' - 10 : nh + '0'; | |
1000 buf[col++] = nl > 9 ? nl + 'A' - 10 : nl + '0'; | |
1001 buf[col++] = ' '; | |
1002 } | |
1003 if (col) | |
1004 { | |
1005 TRACE_EVENT (buf); | |
1006 } | |
1007 } | |
1008 #endif /* ARRAY_TRACE */ | |
1009 | |
1010 #if defined (REL99) AND defined (TI_PS_FF_EMR) AND defined (GPRS) | |
1011 #ifdef GPRS | |
1012 | |
1013 /* | |
1014 +--------------------------------------------------------------------+ | |
1015 | PROJECT : GSM-PS (6147) MODULE : RR_SRV | | |
1016 | STATE : code ROUTINE : rr_get_support_for_emr | | |
1017 +--------------------------------------------------------------------+ | |
1018 | |
1019 PURPOSE : PS-EMR flag is enabled or not. | |
1020 */ | |
1021 GLOBAL BOOL rr_get_support_for_emr(void) | |
1022 { | |
1023 GET_INSTANCE_DATA; | |
1024 if(rr_data->ms_data.enable_ps_emr EQ TRUE) /*for grr*/ | |
1025 { | |
1026 return TRUE; | |
1027 } | |
1028 | |
1029 return FALSE; | |
1030 } | |
1031 | |
1032 #endif /*GPRS*/ | |
1033 #endif | |
1034 | |
1035 #endif /* !RR_SRV_C */ |