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