# HG changeset patch # User Michael Spacefalcon # Date 1411966455 0 # Node ID 61df1066039e405423c6da1ee031fbaf90af1b31 # Parent 029f631b22ff0ffed8a9b12b8d7273398f957cac alr_cs.c compiles diff -r 029f631b22ff -r 61df1066039e gsm-fw/g23m-gsm/alr/Makefile --- a/gsm-fw/g23m-gsm/alr/Makefile Mon Sep 29 01:41:48 2014 +0000 +++ b/gsm-fw/g23m-gsm/alr/Makefile Mon Sep 29 04:54:15 2014 +0000 @@ -5,7 +5,7 @@ CPPFLAGS=-I. -I../../include -I../../include/condat -I../../gpf/inc \ -I../../cdginc -OBJS= alr_cbch.o +OBJS= alr_cbch.o alr_cs.o all: ${OBJS} diff -r 029f631b22ff -r 61df1066039e gsm-fw/g23m-gsm/alr/alr_cs.c --- a/gsm-fw/g23m-gsm/alr/alr_cs.c Mon Sep 29 01:41:48 2014 +0000 +++ b/gsm-fw/g23m-gsm/alr/alr_cs.c Mon Sep 29 04:54:15 2014 +0000 @@ -21,6 +21,10 @@ #ifndef ALR_CS_C #define ALR_CS_C +#include "config.h" +#include "fixedconf.h" +#include "condat-features.h" + #define ENTITY_PL /*==== INCLUDES ===================================================*/ @@ -190,7 +194,7 @@ next_area = alr_data->cs_data.freq_area; /* - * In the case the members and value arenīt already initialized, + * In the case the members and value aren't already initialized, * next_area is set to 0 */ switch (next_area) @@ -1948,18 +1952,28 @@ PURPOSE : This function puts the White carriers at the top of the MPH_POWER_CNF list CSI-LLD 4.1.3.4.2.7 + + FreeCalypso note: when TI reworked this function for their + TI_PS_FF_QUAD_BAND_SUPPORT, they broke the configuration without this + feature. If one takes the version of ALR from the LoCosto source + and builds it without TI_PS_FF_QUAD_BAND_SUPPORT, after passing through + the C preprocessor this function will be reduced to an equivalent of + return 0; followed by unreachable code. + + Our solution: let's put the #ifdef TI_PS_FF_QUAD_BAND_SUPPORT on the + outside of the function, and have two entirely separate versions. + If one builds with the new feature, the version from LoCosto will be + built, made more readable by removing further internal ifdefs on the + same condition. The version to be built *without* TI_PS_FF_QUAD_BAND_SUPPORT + has been taken from the ALR source that miraculously survived in the + otherwise sanitized Leonardo semi-src. + */ #ifdef TI_PS_FF_QUAD_BAND_SUPPORT LOCAL U8 cs_add_whitelist_carriers(U16 p_results_size[2], U8 *r_std, U8 no_of_attempts, SHORT *min_rxlev, T_POWER_MEAS **presults, U8 no_of_carriers_per_band[4]) -#else -LOCAL U8 cs_add_whitelist_carriers(U16 p_results_size[2], U8 std, U8 no_of_attempts, - SHORT *min_rxlev, - T_POWER_MEAS *presults, - U8 no_of_carriers_per_band[4]) -#endif { GET_INSTANCE_DATA; T_MPH_POWER_CNF* mph_power_cnf = alr_data->cs_data.p_power_cnf; @@ -1970,15 +1984,12 @@ U8 temp_rxlev; UBYTE x=0; T_POWER_ARRAY *parray, *last; -#ifdef TI_PS_FF_QUAD_BAND_SUPPORT U8 std, start_region, no_of_regions, k; -#endif TRACE_FUNCTION ("cs_add_whitelist_carriers()"); i_cnf = 0; -#ifdef TI_PS_FF_QUAD_BAND_SUPPORT if (region EQ BOTH_REGIONS) { if((!(p_results_size[EUROPEAN_REGION]) OR (presults[EUROPEAN_REGION] EQ NULL)) AND @@ -1987,14 +1998,10 @@ } else if(!(p_results_size[region]) OR (presults EQ NULL)) { -#endif return i_cnf; -#ifdef TI_PS_FF_QUAD_BAND_SUPPORT } -#endif /* Move the white list carriers to MPH_POWER_CNF array first */ -#ifdef TI_PS_FF_QUAD_BAND_SUPPORT if (region EQ BOTH_REGIONS) { start_region = EUROPEAN_REGION; @@ -2017,96 +2024,73 @@ parray = presults[k]->power_array; for (i=0; (iradio_freq,std); - /*lint -e661 (Warning -- Possible access of out-of-bounds) */ - get_band_index_from_arfcn(arfcn, x, std); - if (parray->accum_power_result > (min_rxlev[x] - 1)) - { - /*lint +e661 (Warning -- Possible access of out-of-bounds) */ - if(srv_get_channel((T_LIST*)&mph_power_req->white_list.list, arfcn&ARFCN_MASK)) + /* Convert to GSM standard format from L1 format*/ + arfcn = ARFCN_STD_TO_G23(parray->radio_freq,std); + /*lint -e661 (Warning -- Possible access of out-of-bounds) */ + get_band_index_from_arfcn(arfcn, x, std); + if (parray->accum_power_result > (min_rxlev[x] - 1)) { - - /* Channel is present in white list. Add this to top of MPH_POWER_CNF */ - arfcn = STD_ADD_TO_ARFCN(arfcn, std); - - /* US_BIT should be used to differentiate an US frequency channel. */ - switch (std) + /*lint +e661 (Warning -- Possible access of out-of-bounds) */ + if(srv_get_channel((T_LIST*)&mph_power_req->white_list.list, arfcn&ARFCN_MASK)) { - case STD_1900: - case STD_850: - case STD_DUAL_US: - arfcn |= US_BIT; - break; - default: - break; - } - /*lint -e661 (Warning -- Possible access of out-of-bounds) */ - where_to_add = cs_restrict_max_carriers_per_band(arfcn&ARFCN_MASK, std, + + /* Channel is present in white list. Add this to top of MPH_POWER_CNF */ + arfcn = STD_ADD_TO_ARFCN(arfcn, std); + + /* US_BIT should be used to differentiate an US frequency channel. */ + switch (std) + { + case STD_1900: + case STD_850: + case STD_DUAL_US: + arfcn |= US_BIT; + break; + default: + break; + } + /*lint -e661 (Warning -- Possible access of out-of-bounds) */ + where_to_add = cs_restrict_max_carriers_per_band(arfcn&ARFCN_MASK, std, no_of_carriers_per_band, p_results_size, min_rxlev[x]); - /*lint +e661 (Warning -- Possible access of out-of-bounds) */ - if(where_to_add NEQ DO_NOT_ADD) - { - /* White list carriers are always added at the top */ - mph_power_cnf->arfcn[i_cnf] = arfcn; - mph_power_cnf->rx_lev[i_cnf] = (U8)(parray->accum_power_result/no_of_attempts); - i_cnf++; - } - else - { -#ifdef TI_PS_FF_QUAD_BAND_SUPPORT + /*lint +e661 (Warning -- Possible access of out-of-bounds) */ + if(where_to_add NEQ DO_NOT_ADD) + { + /* White list carriers are always added at the top */ + mph_power_cnf->arfcn[i_cnf] = arfcn; + mph_power_cnf->rx_lev[i_cnf] = (U8)(parray->accum_power_result/no_of_attempts); + i_cnf++; + } + else + { TRACE_EVENT_P2("[WL] [DO_NOT_ADD] [%d] : [%c]", arfcn&ARFCN_MASK, (k ? 'A' :'E')); -#else - TRACE_EVENT_P2("[WL] [DO_NOT_ADD] [%d] : [%c]", arfcn&ARFCN_MASK, - (region ? 'A' :'E')); -#endif } /* Exclude this carrier */ parray->accum_power_result = min_rxlev[x]-1; -#ifdef TI_PS_FF_QUAD_BAND_SUPPORT last = presults[k]->power_array + (p_results_size[k] - 1); -#else - last = presults->power_array + (p_results_size[region] - 1); -#endif - /* Swapping the current carrier with the last carrier */ - cs_power_array_swap_arfcn(parray, last); + /* Swapping the current carrier with the last carrier */ + cs_power_array_swap_arfcn(parray, last); + + /* Decrement the power array counter to exclude the above carrier */ + p_results_size[k]--; - /* Decrement the power array counter to exclude the above carrier */ -#ifdef TI_PS_FF_QUAD_BAND_SUPPORT - p_results_size[k]--; -#else - p_results_size[region]--; -#endif - - } /* Present in White List */ - else + } /* Present in White List */ + else + { + i++; parray++; + } + } /* Active Carrier */ + else { + TRACE_EVENT_P2("[WL] [IA] [%d] : [%c]", parray->radio_freq, + (k ? 'A' :'E')); i++; parray++; } - } /* Active Carrier */ - else - { -#ifdef TI_PS_FF_QUAD_BAND_SUPPORT - TRACE_EVENT_P2("[WL] [IA] [%d] : [%c]", parray->radio_freq, - (k ? 'A' :'E')); -#else - TRACE_EVENT_P2("[WL] [IA] [%d] : [%c]", parray->radio_freq, - (region ? 'A' :'E')); -#endif - i++; parray++; - } - } /* i < max */ -#ifdef TI_PS_FF_QUAD_BAND_SUPPORT + } /* i < max */ } -#endif /* Assign the total Number of white list channels */ mph_power_cnf->num_of_white_list_chan = i_cnf; @@ -2137,6 +2121,138 @@ return (i_cnf); } +#else /* no TI_PS_FF_QUAD_BAND_SUPPORT */ + +/* + * Version taken from the TCS211 ALR source, modified in a few places + * to work with the rest of ALR which is the version from LoCosto. + */ + +LOCAL U8 cs_add_whitelist_carriers(U16 p_results_size[2], U8 std, U8 no_of_attempts, + SHORT *min_rxlev, + T_POWER_MEAS *presults, + U8 no_of_carriers_per_band[4]) +{ + GET_INSTANCE_DATA; + T_MPH_POWER_CNF* mph_power_cnf = alr_data->cs_data.p_power_cnf; + T_MPH_POWER_REQ* mph_power_req = alr_data->cs_data.p_power_req; + U8 i_cnf,j, where_to_add = DO_NOT_ADD; + U8 region = mph_power_req->white_list.region; + U16 i,arfcn, temp_arfcn; + U8 temp_rxlev; + UBYTE x; + T_POWER_ARRAY *parray, *last; + + TRACE_FUNCTION ("cs_add_whitelist_carriers()"); + + i_cnf = 0; + + if((p_results_size[region]) AND (presults NEQ NULL)) + { + parray = presults->power_array; + } + else + return i_cnf; + + /* Move the white list carriers to MPH_POWER_CNF array first */ + for (i=0; (iradio_freq,std); + get_band_index_from_arfcn(arfcn, x, std); + if (parray->accum_power_result > (min_rxlev[x] - 1)) + { + if(srv_get_channel((T_LIST*)&mph_power_req->white_list.list, arfcn&ARFCN_MASK)) + { + + /* Channel is present in white list. Add this to top of MPH_POWER_CNF */ + arfcn = STD_ADD_TO_ARFCN(arfcn, std); + + /* US_BIT should be used to differentiate an US frequency channel. */ + switch (std) + { + case STD_1900: + case STD_850: + case STD_DUAL_US: + arfcn |= US_BIT; + break; + default: + break; + } + + where_to_add = cs_restrict_max_carriers_per_band(arfcn&ARFCN_MASK, std, + no_of_carriers_per_band, p_results_size, + min_rxlev[x]); + + if(where_to_add NEQ DO_NOT_ADD) + { + /* White list carriers are always added at the top */ + mph_power_cnf->arfcn[i_cnf] = arfcn; + mph_power_cnf->rx_lev[i_cnf] = (U8)(parray->accum_power_result/no_of_attempts); + i_cnf++; + } + else + { + TRACE_EVENT_P2("[WL] [DO_NOT_ADD] [%d] : [%c]", arfcn&ARFCN_MASK, + (region ? 'A' :'E')); + } + + /* Exclude this carrier */ + parray->accum_power_result = min_rxlev[x]-1; + + last = presults->power_array + (p_results_size[region] - 1); + + /* Swapping the current carrier with the last carrier */ + cs_power_array_swap_arfcn(parray, last); + + /* Decrement the power array counter to exclude the above carrier */ + p_results_size[region]--; + + } /* Present in White List */ + else + { + i++; parray++; + } + } /* Active Carrier */ + else + { + TRACE_EVENT_P2("[WL] [IA] [%d] : [%c]", parray->radio_freq, + (region ? 'A' :'E')); + i++; parray++; + } + } /* i < max */ + + /* Assign the total Number of white list channels */ + mph_power_cnf->num_of_white_list_chan = i_cnf; + + TRACE_EVENT_P1("[WL] no. of channels : %d ",mph_power_cnf->num_of_white_list_chan); + + /* + * Sort the white list carriers added to power_cnf array on the + * basis of their field strength + */ + for(i=0; i < i_cnf; i++) + { + for(j=i+1; jrx_lev[i] < mph_power_cnf->rx_lev[j]) + { + temp_rxlev = mph_power_cnf->rx_lev[i]; + temp_arfcn = mph_power_cnf->arfcn[i]; + + mph_power_cnf->rx_lev[i] = mph_power_cnf->rx_lev[j]; + mph_power_cnf->arfcn[i] = mph_power_cnf->arfcn[j]; + + mph_power_cnf->rx_lev[j] = temp_rxlev; + mph_power_cnf->arfcn[j] = temp_arfcn; + } + } + } + + return (i_cnf); +} +#endif /* +--------------------------------------------------------------------+ @@ -2414,4 +2530,3 @@ sizeof (mph_power_cnf->rx_lev[0]) * (extra_cnf)); } -