comparison src/cs/layer1/p_cfile/l1p_afun.c @ 302:0740b5ff15f6

reconstructed L1_GPRS source imported from tcs211-l1-reconst
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 31 Oct 2017 03:42:35 +0000
parents
children
comparison
equal deleted inserted replaced
301:a963c5c35f8d 302:0740b5ff15f6
1 /************* Revision Controle System Header *************
2 * GSM Layer 1 software
3 * L1P_AFUN.C
4 *
5 * Filename l1p_afun.c
6 * Copyright 2003 (C) Texas Instruments
7 *
8 ************* Revision Controle System Header *************/
9
10 #define L1P_AFUN_C
11
12 #include "l1_macro.h"
13 #include "l1_confg.h"
14
15 #if L1_GPRS
16
17 #if (CODE_VERSION == SIMULATION)
18 #include <string.h>
19 #include "l1_types.h"
20 #include "sys_types.h"
21 #include "l1_const.h"
22 #if TESTMODE
23 #include "l1tm_defty.h"
24 #endif
25 #if (AUDIO_TASK == 1)
26 #include "l1audio_const.h"
27 #include "l1audio_cust.h"
28 #include "l1audio_defty.h"
29 #endif
30 #if (L1_GTT == 1)
31 #include "l1gtt_const.h"
32 #include "l1gtt_defty.h"
33 #endif
34 #if (L1_MP3 == 1)
35 #include "l1mp3_defty.h"
36 #endif
37 #if (L1_MIDI == 1)
38 #include "l1midi_defty.h"
39 #endif
40 #include "l1_defty.h"
41 #include "cust_os.h"
42 #include "l1_varex.h"
43 #include "l1p_cons.h"
44 #include "l1p_msgt.h"
45 #include "l1p_deft.h"
46 #include "l1p_vare.h"
47
48 #include "l1_msgty.h"
49 #include "l1_proto.h"
50
51 #else
52
53 #include <string.h>
54 #include "l1_types.h"
55 #include "sys_types.h"
56 #include "l1_const.h"
57 #if TESTMODE
58 #include "l1tm_defty.h"
59 #endif
60 #if (AUDIO_TASK == 1)
61 #include "l1audio_const.h"
62 #include "l1audio_cust.h"
63 #include "l1audio_defty.h"
64 #endif
65 #if (L1_GTT == 1)
66 #include "l1gtt_const.h"
67 #include "l1gtt_defty.h"
68 #endif
69 #if (L1_MP3 == 1)
70 #include "l1mp3_defty.h"
71 #endif
72 #if (L1_MIDI == 1)
73 #include "l1midi_defty.h"
74 #endif
75 #include "l1_defty.h"
76 #include "cust_os.h"
77 #include "l1_varex.h"
78 #include "l1p_cons.h"
79 #include "l1p_msgt.h"
80 #include "l1p_deft.h"
81 #include "l1p_vare.h"
82
83 #include "l1_msgty.h"
84 #include "l1_proto.h"
85
86 #endif
87
88 // Internal prototypes
89 T_TRANSFER_SET *l1pa_get_free_transfer_set (UWORD8 new_tbf);
90 int l1pa_sort (const void *a, const void *b);
91 void l1pa_reset_cr_freq_list ();
92 T_CRES_LIST_PARAM *l1pa_get_free_cres_list_set();
93 void l1pa_send_int_meas_report (UWORD32 SignalCode,
94 T_L1P_ITMEAS_IND *last_l1s_msg,
95 T_L1A_INT_MEAS_PARAM *first_meas_ptr);
96 void l1pa_send_confirmation (UWORD32 SignalCode, UWORD8 id);
97
98 /*-------------------------------------------------------*/
99 /* l1pa_get_free_transfer_set() */
100 /*-------------------------------------------------------*/
101 /* */
102 /* Description: */
103 /* ------------ */
104 /* */
105 /* Modified parameters from globals: */
106 /* --------------------------------- */
107 /* */
108 /*-------------------------------------------------------*/
109 T_TRANSFER_SET *l1pa_get_free_transfer_set(UWORD8 new_tbf)
110 {
111 T_TRANSFER_SET *transfer_set;
112
113 #define clear_and_new(i, tbf) \
114 switch(tbf) \
115 { \
116 case UL_TBF: \
117 l1pa_l1ps_com.transfer.fset[i]->allocated_tbf = DL_TBF; \
118 break; \
119 \
120 case DL_TBF: \
121 l1pa_l1ps_com.transfer.fset[i]->allocated_tbf = UL_TBF; \
122 break; \
123 }
124
125 // If new_tbf is to replace an existing one, we must return
126 // the considered free set.
127 if(new_tbf == BOTH_TBF)
128 {
129 if(l1pa_l1ps_com.transfer.fset[0]->allocated_tbf == NO_TBF)
130 transfer_set = l1pa_l1ps_com.transfer.fset[1];
131 else
132 transfer_set = l1pa_l1ps_com.transfer.fset[0];
133 }
134 else
135 if(l1pa_l1ps_com.transfer.fset[0]->allocated_tbf == new_tbf)
136 transfer_set = l1pa_l1ps_com.transfer.fset[0];
137 else
138 if(l1pa_l1ps_com.transfer.fset[1]->allocated_tbf == new_tbf)
139 transfer_set = l1pa_l1ps_com.transfer.fset[1];
140 else
141 if(l1pa_l1ps_com.transfer.fset[0]->allocated_tbf == BOTH_TBF)
142 {
143 clear_and_new(0, new_tbf);
144 transfer_set = l1pa_l1ps_com.transfer.fset[1];
145 }
146 else
147 if(l1pa_l1ps_com.transfer.fset[1]->allocated_tbf == BOTH_TBF)
148 {
149 clear_and_new(1, new_tbf);
150 transfer_set = l1pa_l1ps_com.transfer.fset[0];
151 }
152 else
153 if(l1pa_l1ps_com.transfer.fset[0]->allocated_tbf == NO_TBF)
154 transfer_set = l1pa_l1ps_com.transfer.fset[0];
155 else
156 transfer_set = l1pa_l1ps_com.transfer.fset[1];
157
158 transfer_set->SignalCode = NULL;
159 transfer_set->dl_tbf_synchro_timeslot = 0;
160 transfer_set->ul_tbf_synchro_timeslot = 0;
161 transfer_set->transfer_synchro_timeslot = 0;
162
163 // No init of "allocated_tbf"
164
165 transfer_set->assignment_command = NO_TBF;
166 transfer_set->multislot_class = 0;
167 transfer_set->packet_ta.ta = 255; // Not present
168 transfer_set->packet_ta.ta_index = 255; // Not present
169 transfer_set->packet_ta.ta_tn = 255; // Not present
170 transfer_set->tsc = 0;
171
172 transfer_set->freq_param.chan_sel.h = 0;
173 transfer_set->freq_param.chan_sel.rf_channel.single_rf.radio_freq = 0;
174 transfer_set->freq_param.chan_sel.rf_channel.hopping_rf.maio = 0;
175 transfer_set->freq_param.chan_sel.rf_channel.hopping_rf.hsn = 0;
176 transfer_set->freq_param.freq_list.rf_chan_cnt = 0;
177
178 transfer_set->tbf_sti.present = FALSE;
179
180 transfer_set->dl_pwr_ctl.p0 = 255;
181 transfer_set->dl_pwr_ctl.bts_pwr_ctl_mode = 0;
182 transfer_set->dl_pwr_ctl.pr_mode = 0;
183
184 transfer_set->ts_override = 0;
185 transfer_set->pc_meas_chan = 0;
186
187 // No init of "ul_tbf_alloc" and "ul_tbf_alloc", mac_mode is enought
188
189 return(transfer_set);
190 }
191
192 /*-------------------------------------------------------*/
193 /* l1pa_sort() */
194 /*-------------------------------------------------------*/
195 /* */
196 /* Description: */
197 /* ------------ */
198 /* */
199 /* Modified parameters from globals: */
200 /* --------------------------------- */
201 /* */
202 /*-------------------------------------------------------*/
203 int l1pa_sort(const void *a, const void *b)
204 {
205 UWORD8 entry1, entry2;
206
207 entry1 = *((UWORD8*) a);
208 entry2 = *((UWORD8*) b);
209
210 if (entry1 < entry2 )
211 return(-1);
212 else if (entry1 == entry2)
213 return(0);
214 else
215 return(1);
216 }
217
218 /*-------------------------------------------------------*/
219 /* l1pa_reset_cr_freq_list() */
220 /*-------------------------------------------------------*/
221 /* */
222 /* Description: */
223 /* ------------ */
224 /* This function resets parameters used in Frequency */
225 /* list task */
226 /* */
227 /*-------------------------------------------------------*/
228 void l1pa_reset_cr_freq_list()
229 {
230 UWORD8 i;
231
232 for(i=0; i<NB_MEAS_MAX_GPRS; i++)
233 {
234 l1pa_l1ps_com.cr_freq_list.used_il_lna [i].il = l1_config.params.il_min; // IL used in CTRL phase for AGC setting.
235 l1pa_l1ps_com.cr_freq_list.used_il_lna_d [i].il = l1_config.params.il_min; // ... 1 frame delay.
236 l1pa_l1ps_com.cr_freq_list.used_il_lna_dd[i].il = l1_config.params.il_min; // ... 2 frames delay, used in READ phase.
237
238 l1pa_l1ps_com.cr_freq_list.used_il_lna [i].lna = FALSE; // LNA used in CTRL phase for AGC setting.
239 l1pa_l1ps_com.cr_freq_list.used_il_lna_d [i].lna = FALSE; // ... 1 frame delay.
240 l1pa_l1ps_com.cr_freq_list.used_il_lna_dd[i].lna = FALSE; // ... 2 frames delay, used in READ phase.
241 }
242
243 // Initialize next power measurement control.
244 l1pa_l1ps_com.cr_freq_list.next_to_ctrl = 0;
245
246 // Initialize next power measurement result.
247 l1pa_l1ps_com.cr_freq_list.next_to_read = 0;
248
249 // Reset PPCH burst ctrl indication
250 l1pa_l1ps_com.cr_freq_list.pnp_ctrl = 0;
251
252 }
253
254 /*-------------------------------------------------------*/
255 /* l1pa_get_free_cres_list_set() */
256 /*-------------------------------------------------------*/
257 /* Parameters : */
258 /* Return : */
259 /* Functionality : */
260 /*-------------------------------------------------------*/
261 T_CRES_LIST_PARAM *l1pa_get_free_cres_list_set()
262 {
263 T_CRES_LIST_PARAM *flist;
264
265 // Get free set pointer.
266 if(l1pa_l1ps_com.cres_freq_list.alist == &(l1pa_l1ps_com.cres_freq_list.list[0]))
267 flist = &(l1pa_l1ps_com.cres_freq_list.list[1]);
268 else
269 flist = &(l1pa_l1ps_com.cres_freq_list.list[0]);
270
271 // Clear free set.
272 flist->nb_carrier = 0;
273 flist->list_id = 0;
274
275 // Reset fifo used in AGC algo => NEED MORE INVESTIGATION.
276
277
278 return(flist);
279 }
280
281 /*-------------------------------------------------------*/
282 /* l1pa_send_int_meas_report() */
283 /*-------------------------------------------------------*/
284 /* */
285 /* Description: */
286 /* ------------ */
287 /* This function builds and sends the Interf. Meas. */
288 /* report to L3 */
289 /* */
290 /*-------------------------------------------------------*/
291 void l1pa_send_int_meas_report(UWORD32 SignalCode,
292 T_L1P_ITMEAS_IND *last_l1s_msg,
293 T_L1A_INT_MEAS_PARAM *first_meas_ptr)
294 {
295 xSignalHeaderRec *msg;
296 UWORD8 i,j,k;
297 UWORD8 bit_mask = 0x80;
298
299 // Allocate report msg and fill signal code.
300 msg = os_alloc_sig(sizeof(T_MPHP_INT_MEAS_IND));
301 DEBUGMSG(status,NU_ALLOC_ERR)
302 msg->SignalCode = SignalCode;
303
304 // Save measurement results
305 //-------------------------
306 for(i = 0, j = 0, k = 0; i < 8; i++, bit_mask >>= 1)
307 {
308 // Fill 1st measurement report
309 //----------------------------
310 // If a measurement was done on timeslot i
311 if(first_meas_ptr->meas_bitmap & bit_mask)
312 {
313 // The result is stored in the msg.
314 ((T_MPHP_INT_MEAS_IND *) (msg->SigP))->int_meas[i].rxlev[0] = first_meas_ptr->rxlev[j];
315
316 // Next measurement value
317 j++;
318 }
319 else
320 {
321 // No measurement processed on timeslot i (0x80 value)
322 ((T_MPHP_INT_MEAS_IND *) (msg->SigP))->int_meas[i].rxlev[0] = (WORD8)NO_MEAS; //omaps00090550
323 }
324
325 // Fill 2nd measurement report
326 //----------------------------
327 // If a measurement was done on timeslot i
328 if(last_l1s_msg->meas_bitmap & bit_mask)
329 {
330 // The result is stored in the msg.
331 ((T_MPHP_INT_MEAS_IND *) (msg->SigP))->int_meas[i].rxlev[1] = last_l1s_msg->rxlev[k];
332
333 // Next measurement value
334 k++;
335 }
336 else
337 {
338 // No measurement processed on timeslot i (0x80 value)
339 ((T_MPHP_INT_MEAS_IND *) (msg->SigP))->int_meas[i].rxlev[1] = (WORD8)NO_MEAS;
340 }
341 }
342
343 // Set ID in the report message
344 ((T_MPHP_INT_MEAS_IND *) (msg->SigP))->id = first_meas_ptr->id;
345
346 #if (TRACE_TYPE==1) || (TRACE_TYPE==4)
347 l1_trace_message(msg);
348 #endif
349
350 os_send_sig(msg, GRRM1_QUEUE);
351 DEBUGMSG(status,NU_SEND_QUEUE_ERR)
352 }
353
354 /*-------------------------------------------------------*/
355 /* l1pa_send_confirmation() */
356 /*-------------------------------------------------------*/
357 /* Parameters : */
358 /* Return : */
359 /* Functionality : */
360 /*-------------------------------------------------------*/
361 void l1pa_send_confirmation(UWORD32 SignalCode, UWORD8 id)
362 {
363 xSignalHeaderRec *msg_con;
364
365 msg_con = os_alloc_sig(sizeof(T_MPHP_ASSIGNMENT_CON));
366 DEBUGMSG(status,NU_ALLOC_ERR)
367 msg_con->SignalCode = SignalCode;
368
369 ((T_MPHP_ASSIGNMENT_CON *) msg_con->SigP)->assignment_id = id;
370
371 #if (TRACE_TYPE==1) || (TRACE_TYPE==4)
372 l1_trace_message(msg_con);
373 #endif
374
375 os_send_sig(msg_con, GRRM1_QUEUE);
376 DEBUGMSG(status,NU_SEND_QUEUE_ERR)
377 }
378
379
380 /*-------------------------------------------------------*/
381 /* l1pa_send_tbf_release_con() */
382 /*-------------------------------------------------------*/
383 /* Parameters : */
384 /* Return : */
385 /* Functionality : */
386 /*-------------------------------------------------------*/
387 void l1pa_send_tbf_release_con(UWORD32 SignalCode, UWORD8 tbf_type)
388 {
389 xSignalHeaderRec *conf_msg;
390
391 // Send the confirmation message with the TBF type to L3
392 // Allocate confirmation message...
393 conf_msg = os_alloc_sig( sizeof(T_MPHP_TBF_RELEASE_CON));
394 DEBUGMSG(status,NU_ALLOC_ERR);
395
396 //Fill the message
397 conf_msg->SignalCode = SignalCode;
398 ((T_MPHP_TBF_RELEASE_CON *)(conf_msg->SigP))->tbf_type = tbf_type;
399
400 // Send the confirmation message...
401 os_send_sig(conf_msg, GRRM1_QUEUE);
402 DEBUGMSG(status,NU_SEND_QUEUE_ERR)
403 }
404 #endif //L1_GPRS