FreeCalypso > hg > fc-magnetite
comparison src/cs/layer1/p_cfile/l1p_asyn.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_ASYN.C | |
4 * | |
5 * Filename l1p_asyn.c | |
6 * Copyright 2003 (C) Texas Instruments | |
7 * | |
8 ************* Revision Controle System Header *************/ | |
9 | |
10 //#pragma DUPLICATE_FOR_INTERNAL_RAM_START | |
11 #include "l1_macro.h" | |
12 #include "l1_confg.h" | |
13 //#pragma DUPLICATE_FOR_INTERNAL_RAM_END | |
14 | |
15 #if !((MOVE_IN_INTERNAL_RAM == 1) && (GSM_IDLE_RAM !=0)) // MOVE TO INTERNAL MEM IN CASE GSM_IDLE_RAM enabled | |
16 //#pragma GSM_IDLE_DUPLICATE_FOR_INTERNAL_RAM_START // KEEP IN EXTERNAL MEM otherwise | |
17 | |
18 #define L1P_ASYN_C | |
19 | |
20 //#pragma GSM_IDLE_DUPLICATE_FOR_INTERNAL_RAM_END // KEEP IN EXTERNAL MEM otherwise | |
21 #endif | |
22 | |
23 //#pragma DUPLICATE_FOR_INTERNAL_RAM_START | |
24 | |
25 #include "l1_macro.h" | |
26 #include "l1_confg.h" | |
27 | |
28 #if L1_GPRS | |
29 | |
30 #if (CODE_VERSION == SIMULATION) | |
31 #include <string.h> | |
32 #include "l1_types.h" | |
33 #include "sys_types.h" | |
34 #include "l1_const.h" | |
35 #if TESTMODE | |
36 #include "l1tm_defty.h" | |
37 #endif | |
38 #if (AUDIO_TASK == 1) | |
39 #include "l1audio_const.h" | |
40 #include "l1audio_cust.h" | |
41 #include "l1audio_defty.h" | |
42 #endif | |
43 #if (L1_GTT == 1) | |
44 #include "l1gtt_const.h" | |
45 #include "l1gtt_defty.h" | |
46 #endif | |
47 #if (L1_MP3 == 1) | |
48 #include "l1mp3_defty.h" | |
49 #endif | |
50 #if (L1_MIDI == 1) | |
51 #include "l1midi_defty.h" | |
52 #endif | |
53 #include "l1_defty.h" | |
54 #include "cust_os.h" | |
55 #include "l1_msgty.h" | |
56 #include "l1_varex.h" | |
57 #include "l1_signa.h" | |
58 #include "l1_proto.h" | |
59 #include "l1_time.h" | |
60 #include "l1_ctl.h" | |
61 | |
62 #include "l1p_cons.h" | |
63 #include "l1p_msgt.h" | |
64 #include "l1p_deft.h" | |
65 #include "l1p_vare.h" | |
66 #include "l1p_tabs.h" | |
67 #include "l1p_sign.h" | |
68 #include "l1p_mfta.h" | |
69 #include "l1p_macr.h" | |
70 | |
71 #include "macs_def.h" | |
72 #include "macs_cst.h" | |
73 #else | |
74 #include <string.h> | |
75 #include "l1_types.h" | |
76 #include "sys_types.h" | |
77 #include "l1_const.h" | |
78 | |
79 #if TESTMODE | |
80 #include "l1tm_defty.h" | |
81 #endif | |
82 #if (AUDIO_TASK == 1) | |
83 #include "l1audio_const.h" | |
84 #include "l1audio_cust.h" | |
85 #include "l1audio_defty.h" | |
86 #endif | |
87 #if (L1_GTT == 1) | |
88 #include "l1gtt_const.h" | |
89 #include "l1gtt_defty.h" | |
90 #endif | |
91 #if (L1_MP3 == 1) | |
92 #include "l1mp3_defty.h" | |
93 #endif | |
94 #if (L1_MIDI == 1) | |
95 #include "l1midi_defty.h" | |
96 #endif | |
97 #include "l1_defty.h" | |
98 #include "cust_os.h" | |
99 #include "l1_msgty.h" | |
100 #include "l1_varex.h" | |
101 #include "l1_signa.h" | |
102 #include "l1_proto.h" | |
103 #include "l1_time.h" | |
104 #include "l1_ctl.h" | |
105 | |
106 #include "l1p_cons.h" | |
107 #include "l1p_msgt.h" | |
108 #include "l1p_deft.h" | |
109 #include "l1p_vare.h" | |
110 #include "l1p_tabs.h" | |
111 #include "l1p_sign.h" | |
112 #include "l1p_mfta.h" | |
113 #include "l1p_macr.h" | |
114 | |
115 #include "macs_def.h" | |
116 #include "macs_cst.h" | |
117 #endif | |
118 | |
119 T_TRANSFER_SET *l1pa_get_free_transfer_set (UWORD8 new_tbf); | |
120 void l1pa_transfer_process (xSignalHeaderRec *msg); | |
121 void l1pa_access_process (xSignalHeaderRec *msg); | |
122 void l1pa_idle_packet_polling_process (xSignalHeaderRec *msg); | |
123 void l1pa_idle_paging_process (xSignalHeaderRec *msg); | |
124 void l1pa_cr_meas_process (xSignalHeaderRec *msg); | |
125 void l1pa_serving_cell_pbcch_read_process (xSignalHeaderRec *msg); | |
126 void l1pa_neighbor_cell_pbcch_read_process (xSignalHeaderRec *msg); | |
127 int l1pa_sort (const void *a, const void *b); | |
128 void l1pa_reset_cr_freq_list (void); | |
129 void l1pa_tcr_meas_process (xSignalHeaderRec *msg); | |
130 T_CRES_LIST_PARAM *l1pa_get_free_cres_list_set (void); | |
131 void l1pa_idle_interference_meas_process (xSignalHeaderRec *msg); | |
132 void l1pa_transfer_interference_meas_process (xSignalHeaderRec *msg); | |
133 void l1pa_idle_smscb_process (xSignalHeaderRec *msg); | |
134 | |
135 // External prototype | |
136 void l1pa_send_int_meas_report(UWORD32 SignalCode, | |
137 T_L1P_ITMEAS_IND *last_l1s_msg, | |
138 T_L1A_INT_MEAS_PARAM *first_meas_ptr); | |
139 void l1pa_send_confirmation(UWORD32 SignalCode, UWORD8 id); | |
140 void l1pa_send_tbf_release_con(UWORD32 SignalCode, UWORD8 tbf_type); | |
141 | |
142 //#pragma DUPLICATE_FOR_INTERNAL_RAM_END | |
143 | |
144 #if !((MOVE_IN_INTERNAL_RAM == 1) && (GSM_IDLE_RAM > 1)) // MOVE TO INTERNAL MEM IN CASE GSM_IDLE_RAM == 2 | |
145 //#pragma GSM_IDLE2_DUPLICATE_FOR_INTERNAL_RAM_START // KEEP IN EXTERNAL MEM otherwise | |
146 | |
147 | |
148 /*-------------------------------------------------------*/ | |
149 /* l1pa_task() */ | |
150 /*-------------------------------------------------------*/ | |
151 /* */ | |
152 /* Description: */ | |
153 /* ------------ */ | |
154 /* L1PA (Layer 1 Asynchronous) task function. This */ | |
155 /* function manages the GPRS interface between L3 and L1.*/ | |
156 /* It is composed with a set of state machine, each */ | |
157 /* machine handles a particular GSM functionality. When */ | |
158 /* a message is received in L1_C1 message queue, it is */ | |
159 /* submitted to every state machine. The one which are */ | |
160 /* impacted by the message process it. At the end of */ | |
161 /* "l1pa_task()" function, a balance routine is called, */ | |
162 /* it enables L1S tasks consequently to the state machine*/ | |
163 /* requests. */ | |
164 /* */ | |
165 /*-------------------------------------------------------*/ | |
166 void l1pa_task(xSignalHeaderRec *msg) | |
167 { | |
168 UWORD8 process; | |
169 | |
170 // Clear L1PA "enable meas and tasks" variables. | |
171 //--------------------------------------------- | |
172 for(process=0; process<NBR_L1PA_PROCESSES; process++) | |
173 { | |
174 l1pa.l1pa_en_meas[process] = NO_TASK; | |
175 } | |
176 | |
177 #if (GSM_IDLE_RAM != 0) | |
178 if ((msg->SignalCode != L1P_PNP_INFO) && (msg->SignalCode != L1P_PEP_INFO)) | |
179 | |
180 #if (GSM_IDLE_RAM > 1) // GPF modified for GSM_IDLE_RAM -> SW still running in Internal RAM | |
181 { | |
182 #endif | |
183 l1s.gsm_idle_ram_ctl.l1s_full_exec = TRUE; | |
184 #endif // GSM_IDLE_RAM | |
185 | |
186 // Serving Cell Packet System Information Reading | |
187 l1pa_serving_cell_pbcch_read_process(msg); | |
188 | |
189 // Neighbor Cell Packet System Information Reading | |
190 l1pa_neighbor_cell_pbcch_read_process(msg); | |
191 | |
192 #if (GSM_IDLE_RAM <= 1) // GPF modified for GSM_IDLE_RAM -> SW still running in Internal RAM | |
193 { | |
194 // Serving Cell Packet Paging Reading | |
195 l1pa_idle_paging_process(msg); | |
196 } | |
197 #endif | |
198 // Cell reselection measurement process | |
199 l1pa_cr_meas_process(msg); | |
200 | |
201 // Packet access proccess | |
202 l1pa_access_process(msg); | |
203 | |
204 // Packet polling process | |
205 l1pa_idle_packet_polling_process(msg); | |
206 | |
207 // Packet transfer process. | |
208 l1pa_transfer_process(msg); | |
209 | |
210 // Neighbour Cell Measurement in Packet Transfer mode | |
211 l1pa_tcr_meas_process(msg); | |
212 | |
213 // Intererence measurements in packet idle mode | |
214 l1pa_idle_interference_meas_process(msg); | |
215 | |
216 // Intererence measurements in packet transfer mode | |
217 l1pa_transfer_interference_meas_process(msg); | |
218 | |
219 #if (GSM_IDLE_RAM > 1) // GPF modified for GSM_IDLE_RAM -> SW still running in Internal RAM | |
220 }else | |
221 { | |
222 // Serving Cell Packet Packet Idle Paging Reading | |
223 l1pa_idle_paging_process(msg); | |
224 } | |
225 #endif | |
226 } | |
227 | |
228 //#pragma GSM_IDLE_DUPLICATE_FOR_INTERNAL_RAM_END // KEEP IN EXTERNAL MEM otherwise | |
229 #endif | |
230 | |
231 /*-------------------------------------------------------*/ | |
232 /* l1pa_access_process() */ | |
233 /*-------------------------------------------------------*/ | |
234 /* Description : This state machine handles the packet */ | |
235 /* access to the network while in PACKET IDLE mode. */ | |
236 /* */ | |
237 /* Starting messages: MPHP_RA_REQ */ | |
238 /* */ | |
239 /* Subsequent messages: MPHP_RA_REQ */ | |
240 /* */ | |
241 /* Result messages (input): L1P_PRA_DONE */ | |
242 /* */ | |
243 /* Result messages (output): MPHP_RA_CON */ | |
244 /* */ | |
245 /* Reset message (input): MPHP_RA_STOP_REQ */ | |
246 /* */ | |
247 /* Reset message (input): MPHP_RA_STOP_CON */ | |
248 /*-------------------------------------------------------*/ | |
249 void l1pa_access_process(xSignalHeaderRec *msg) | |
250 { | |
251 enum states | |
252 { | |
253 RESET = 0, | |
254 WAIT_INIT = 1, | |
255 WAIT_RESULT = 2 | |
256 }; | |
257 | |
258 UWORD8 *state = &l1pa.state[P_ACC]; | |
259 UWORD32 SignalCode = msg->SignalCode; | |
260 | |
261 BOOL end_process = 0; | |
262 while(!end_process) | |
263 { | |
264 switch(*state) | |
265 { | |
266 case RESET: | |
267 { | |
268 // Step in state machine. | |
269 *state = WAIT_INIT; | |
270 | |
271 // Reset PRACH process. | |
272 l1a_l1s_com.l1s_en_task[PRACH] = TASK_DISABLED; // Clear PRACH task enable flag. | |
273 l1pa_l1ps_com.pra_info.prach_alloc = 0; | |
274 } | |
275 break; | |
276 | |
277 | |
278 case WAIT_INIT: | |
279 { | |
280 if(SignalCode == MPHP_RA_REQ) | |
281 // 1st Random access request message. | |
282 //----------------------------------- | |
283 { | |
284 | |
285 // Download Transmit power configuration. | |
286 // Given value must be used on 1st TX. | |
287 // TXPWR value supplied by L3 is the max. TX power level the MS may use in the given band | |
288 l1s.applied_txpwr = ((T_MPHP_RA_REQ *)(msg->SigP))->txpwr; | |
289 | |
290 | |
291 #if L1_R99 | |
292 // Init PRACH process. | |
293 // "rand" parameter chosen by protocol in range [1..4] for R99 | |
294 l1pa_l1ps_com.pra_info.rand = ((T_MPHP_RA_REQ *)(msg->SigP))->rand; | |
295 #else | |
296 // "rand" parameter from msg is not used for the 1st PRACH. | |
297 l1pa_l1ps_com.pra_info.rand = 1; // First PRACH has to be sent immediately | |
298 #endif | |
299 l1pa_l1ps_com.pra_info.channel_request_data = ((T_MPHP_RA_REQ *)(msg->SigP))->channel_request_data; | |
300 l1pa_l1ps_com.pra_info.bs_prach_blks = ((T_MPHP_RA_REQ *)(msg->SigP))->bs_prach_blks; | |
301 l1pa_l1ps_com.access_burst_type = ((T_MPHP_RA_REQ *)(msg->SigP))->access_burst_type; | |
302 | |
303 // Increment rand parameter by 4 in order to avoid conflict between SYNCHRO and | |
304 // PRACH tasks when MPHP_START_PCCCH_REQ and MPHP_RA_REQ are | |
305 // sent at the same time by L3 | |
306 l1pa_l1ps_com.pra_info.rand+=4; | |
307 | |
308 if ((l1pa_l1ps_com.pra_info.bs_prach_blks == 0) || // no blocks allocated | |
309 (l1pa_l1ps_com.pra_info.bs_prach_blks > 12)) // invalid number of blocks | |
310 l1pa_l1ps_com.pra_info.prach_alloc = DYN_PRACH_ALLOC; | |
311 | |
312 // step in state machine. | |
313 *state = WAIT_RESULT; | |
314 | |
315 // Change mode to connection establishment part 1. | |
316 l1a_l1s_com.mode = CON_EST_MODE1; | |
317 | |
318 // Activate PRACH task (no semaphore for UL tasks). | |
319 l1a_l1s_com.l1s_en_task[PRACH] = TASK_ENABLED; // Set PRACH task enable flag. | |
320 | |
321 } | |
322 | |
323 // end of process. | |
324 end_process = 1; | |
325 } | |
326 break; | |
327 | |
328 case WAIT_RESULT: | |
329 { | |
330 if(SignalCode == L1P_RA_DONE) | |
331 // Random access acknowledge message: PRACH sent. | |
332 //----------------------------------------------- | |
333 { | |
334 // Forward result message to L3. | |
335 l1a_send_result(MPHP_RA_CON, msg, GRRM1_QUEUE); | |
336 | |
337 // Change mode to connection establishment part 2. | |
338 l1a_l1s_com.mode = CON_EST_MODE2; | |
339 | |
340 // end of process. | |
341 return; | |
342 } | |
343 | |
344 else | |
345 if(SignalCode == MPHP_RA_REQ) | |
346 // Random access message. | |
347 //----------------------- | |
348 { | |
349 // REM: rand is added the msg content since its current content is the already | |
350 // spent "slots" from the last PRACH sending. | |
351 l1pa_l1ps_com.pra_info.rand += ((T_MPHP_RA_REQ *)(msg->SigP))->rand + 1; | |
352 l1pa_l1ps_com.pra_info.channel_request_data = ((T_MPHP_RA_REQ *)(msg->SigP))->channel_request_data; | |
353 l1pa_l1ps_com.pra_info.bs_prach_blks = ((T_MPHP_RA_REQ *)(msg->SigP))->bs_prach_blks; | |
354 l1pa_l1ps_com.access_burst_type = ((T_MPHP_RA_REQ *)(msg->SigP))->access_burst_type; | |
355 | |
356 if ((l1pa_l1ps_com.pra_info.bs_prach_blks == 0) || // no blocks allocated | |
357 (l1pa_l1ps_com.pra_info.bs_prach_blks > 12)) // invalid number of blocks | |
358 l1pa_l1ps_com.pra_info.prach_alloc = DYN_PRACH_ALLOC; | |
359 // else | |
360 // l1pa_l1ps_com.pra_info.prach_alloc = FIX_PRACH_ALLOC; | |
361 else | |
362 l1pa_l1ps_com.pra_info.prach_alloc = 0; //must be reset for each burst sent | |
363 | |
364 | |
365 // Activate PRACH task (no semaphore for UL tasks). | |
366 l1a_l1s_com.l1s_en_task[PRACH] = TASK_ENABLED; // Set PRACH task enable flag. | |
367 | |
368 // end of process. | |
369 return; | |
370 } | |
371 | |
372 else | |
373 if(SignalCode == MPHP_RA_STOP_REQ) | |
374 // Request to STOP the LINK ACCESS procedure. | |
375 //------------------------------------------- | |
376 { | |
377 UWORD8 i; | |
378 | |
379 // send confirmation | |
380 l1a_send_confirmation(MPHP_RA_STOP_CON,GRRM1_QUEUE); | |
381 | |
382 // Store MAX TXPWR value to be used for first Tx PDCH blocks | |
383 for(i = 0; i < 8; i++) | |
384 { | |
385 l1pa_l1ps_com.transfer.dl_pwr_ctrl.txpwr[i] = l1s.applied_txpwr; | |
386 } | |
387 | |
388 // This process must be reset. | |
389 *state = RESET; | |
390 } | |
391 | |
392 else | |
393 if(SignalCode == MPHP_POLLING_RESPONSE_REQ) | |
394 // Stop packet access when packet polling initiated. | |
395 //-------------------------------------------------- | |
396 { | |
397 // Unacknowledged | |
398 | |
399 // This process must be reset. | |
400 *state = RESET; | |
401 } | |
402 | |
403 else | |
404 // No action in this machine for other messages. | |
405 //---------------------------------------------- | |
406 { | |
407 // End of process. | |
408 end_process = 1; | |
409 } | |
410 } | |
411 break; | |
412 } // end of "switch". | |
413 } // end of "while" | |
414 } // end of procedure. | |
415 | |
416 /*-------------------------------------------------------*/ | |
417 /* l1pa_cr_meas_process() */ | |
418 /*-------------------------------------------------------*/ | |
419 /* Description : This state machine handles periodic */ | |
420 /* signal strength monitoring on carriers specified */ | |
421 /* in a frequency list: BA(GPRS), NC_FREQUENCY_LIST, */ | |
422 /* EXT_FREEQUENCY_LIST (respectively: cell reselection */ | |
423 /* Network Control and Extended measurements. */ | |
424 /* */ | |
425 /* Starting messages: MPHP_CR_MEAS_REQ */ | |
426 /* ------------------ */ | |
427 /* L1 starts then the periodic FREQUENCY list receive */ | |
428 /* level monitoring. */ | |
429 /* */ | |
430 /* Subsequent messages: MPHP_CR_MEAS_REQ */ | |
431 /* -------------------- */ | |
432 /* The frequency list is updated only when measures */ | |
433 /* on all the carriers of the current list are */ | |
434 /* performed. */ | |
435 /* */ | |
436 /* Result messages (input): L1P_RXLEV_PERIODIC_DONE */ | |
437 /* ------------------------ */ | |
438 /* This is a message reported to L1A from L1S. */ | |
439 /* Reporting is done when last carrier of the frequency */ | |
440 /* list is read. */ | |
441 /* */ | |
442 /* Result messages (output): MPHP_CR_MEAS_IND */ | |
443 /* ------------------------- */ | |
444 /* This is the periodic reporting message to L3. */ | |
445 /* */ | |
446 /* Reset messages (input): MPHP_CR_MEAS_STOP_REQ */ | |
447 /* ----------------------- */ | |
448 /* Frequency list measurement process is stopped by */ | |
449 /* this message. */ | |
450 /* */ | |
451 /*-------------------------------------------------------*/ | |
452 void l1pa_cr_meas_process(xSignalHeaderRec *msg) | |
453 { | |
454 enum states | |
455 { | |
456 RESET = 0, | |
457 WAIT_INIT = 1, | |
458 WAIT_RESULT = 2 | |
459 | |
460 }; | |
461 | |
462 UWORD8 *state = &l1pa.state[CR_MEAS]; | |
463 UWORD32 SignalCode = msg->SignalCode; | |
464 | |
465 BOOL end_process = 0; | |
466 while(!end_process) | |
467 { | |
468 switch(*state) | |
469 { | |
470 case RESET: | |
471 { | |
472 // step in state machine. | |
473 *state = WAIT_INIT; | |
474 | |
475 // Reset P_CRMS_MEAS process. | |
476 l1pa_l1ps_com.l1ps_en_meas &= P_CRMS_MEAS_MASK; // Reset Packet Cell Reselection Measurement enable flag. | |
477 } | |
478 break; | |
479 | |
480 case WAIT_INIT: | |
481 { | |
482 if(SignalCode == MPHP_CR_MEAS_REQ) | |
483 // We receive the Frequency list to be monitored. | |
484 //---------------------------------------------- | |
485 { | |
486 UWORD8 i; | |
487 T_CRES_LIST_PARAM *free_list; | |
488 | |
489 // Set parameter synchro semaphore for P_CRMS_MEAS task. | |
490 l1pa_l1ps_com.meas_param |= P_CRMS_MEAS; | |
491 | |
492 // Reset the frequency list structure. | |
493 l1pa_reset_cr_freq_list(); | |
494 | |
495 // Get Ptr to the free Neighbour meas list. | |
496 // The number of carriers in the list and the list | |
497 // identification are initialized. | |
498 free_list = l1pa_get_free_cres_list_set(); | |
499 | |
500 // Set number of carrier in the frequency list. | |
501 free_list->nb_carrier = ((T_MPHP_CR_MEAS_REQ *)(msg->SigP))->nb_carrier; | |
502 | |
503 // Store ARFCN list in the Packet Cell Reselection structure. | |
504 for(i=0;i<free_list->nb_carrier;i++) | |
505 free_list->freq_list[i] = ((T_MPHP_CR_MEAS_REQ *)(msg->SigP))->radio_freq_no[i]; | |
506 | |
507 // Download Frequency list identifier. | |
508 free_list->list_id = ((T_MPHP_CR_MEAS_REQ *)(msg->SigP))->list_id; | |
509 | |
510 // Set "flist" with new set of frequency list parameter | |
511 l1pa_l1ps_com.cres_freq_list.flist = free_list; | |
512 | |
513 // Enable Packet Cell Reselection measurement task. | |
514 l1pa.l1pa_en_meas[CR_MEAS] |= P_CRMS_MEAS; | |
515 | |
516 // step in state machine. | |
517 *state = WAIT_RESULT; | |
518 } | |
519 | |
520 // End of process. | |
521 end_process = 1; | |
522 } | |
523 break; | |
524 | |
525 case WAIT_RESULT: | |
526 { | |
527 if(SignalCode == L1P_CR_MEAS_DONE) | |
528 // One set of measurement has been completed. | |
529 //--------------------------------------------- | |
530 { | |
531 // Forward result message to L3. | |
532 l1a_send_result(MPHP_CR_MEAS_IND, msg, GRRM1_QUEUE); | |
533 | |
534 // End of process. | |
535 end_process = 1; | |
536 } | |
537 | |
538 else | |
539 if((SignalCode == MPHP_CR_MEAS_STOP_REQ) || | |
540 (SignalCode == L1P_TRANSFER_DONE) || | |
541 (SignalCode == L1C_DEDIC_DONE)) | |
542 // Request to STOP this activity. | |
543 //------------------------------- | |
544 { | |
545 // send confirmation message | |
546 l1a_send_confirmation(MPHP_CR_MEAS_STOP_CON,GRRM1_QUEUE); | |
547 // This process must be reset. | |
548 *state = RESET; | |
549 } | |
550 | |
551 else | |
552 if (SignalCode == MPHP_CR_MEAS_REQ) | |
553 { | |
554 // This process must be reset. | |
555 *state = RESET; | |
556 } | |
557 | |
558 else | |
559 // No action in this machine for other messages. | |
560 //---------------------------------------------- | |
561 { | |
562 // End of process. | |
563 end_process = 1; | |
564 } | |
565 } | |
566 break; | |
567 } // end of "switch". | |
568 } // end of "while" | |
569 } // end of procedure. | |
570 | |
571 #if !((MOVE_IN_INTERNAL_RAM == 1) && (GSM_IDLE_RAM > 1)) // MOVE TO INTERNAL MEM IN CASE GSM_IDLE_RAM == 2 | |
572 //#pragma GSM_IDLE2_DUPLICATE_FOR_INTERNAL_RAM_START // KEEP IN EXTERNAL MEM otherwise | |
573 | |
574 /*-------------------------------------------------------*/ | |
575 /* l1pa_idle_paging_process() */ | |
576 /*-------------------------------------------------------*/ | |
577 /* */ | |
578 /*-------------------------------------------------------*/ | |
579 void l1pa_idle_paging_process(xSignalHeaderRec *msg) | |
580 { | |
581 enum states | |
582 { | |
583 RESET = 0, | |
584 WAIT_INIT = 1, | |
585 WAIT_MSG = 2 | |
586 }; | |
587 | |
588 enum pg_mode | |
589 { | |
590 NORM_PG = 0, | |
591 EXT_PG = 1, | |
592 REORG_PG = 2 | |
593 }; | |
594 | |
595 UWORD8 *state = &l1pa.state[PI_SCP]; | |
596 UWORD32 SignalCode = msg->SignalCode; | |
597 UWORD16 imsimod; | |
598 UWORD16 split_pg_cycle; | |
599 UWORD16 kcn; | |
600 UWORD8 page_mode; | |
601 | |
602 BOOL end_process = 0; | |
603 | |
604 while(!end_process) | |
605 { | |
606 switch(*state) | |
607 { | |
608 case RESET: | |
609 { | |
610 // Step in state machine. | |
611 *state = WAIT_INIT; | |
612 | |
613 // Disable serving cell tasks. | |
614 l1a_l1s_com.l1s_en_task[PALLC] = TASK_DISABLED; // Reset PALLC (reorg) task enable flag. | |
615 l1a_l1s_com.l1s_en_task[PNP] = TASK_DISABLED; // Reset PNP task enable flag. | |
616 l1a_l1s_com.l1s_en_task[PEP] = TASK_DISABLED; // Reset PEP task enable flag. | |
617 | |
618 // No Paging => no gauging => no Deep sleep | |
619 l1s.pw_mgr.enough_gaug = FALSE; // forbid Deep sleep | |
620 | |
621 } | |
622 break; | |
623 | |
624 case WAIT_INIT: | |
625 { | |
626 if(SignalCode == MPHP_START_PCCCH_REQ) | |
627 { | |
628 // Set semaphores for any PCCCH reading tasks. | |
629 l1a_l1s_com.task_param[PALLC] = SEMAPHORE_SET; | |
630 l1a_l1s_com.task_param[PNP] = SEMAPHORE_SET; | |
631 l1a_l1s_com.task_param[PEP] = SEMAPHORE_SET; | |
632 | |
633 // Request to enter in PACKET PAGING REORGANIZATION or NORMAL mode. | |
634 //---------------------------------------------------------------- | |
635 // The initial page mode in the Mobile Station shall be set to paging Reorganization | |
636 // cf 04.08 section 3.3.2.1.1. however current implementation allows to init the Paging | |
637 // procedure either in Reorganization or in Normal paging mode. | |
638 | |
639 // Download the PAGING PARAMETERS from the command message. | |
640 page_mode = ((T_MPHP_START_PCCCH_REQ *)(msg->SigP))->page_mode; | |
641 imsimod = ((T_MPHP_START_PCCCH_REQ *)(msg->SigP))->imsimod; | |
642 kcn = ((T_MPHP_START_PCCCH_REQ *)(msg->SigP))->kcn; | |
643 split_pg_cycle = ((T_MPHP_START_PCCCH_REQ *)(msg->SigP))->split_pg_cycle; | |
644 l1pa_l1ps_com.pccch.bs_pag_blks_res = ((T_MPHP_START_PCCCH_REQ *)(msg->SigP))->bs_pag_blks_res; | |
645 l1pa_l1ps_com.pccch.bs_pbcch_blks = ((T_MPHP_START_PCCCH_REQ *)(msg->SigP))->bs_pbcch_blks; | |
646 l1pa_l1ps_com.pccch.frequency_list = ((T_MPHP_START_PCCCH_REQ *)(msg->SigP))->frequency_list; | |
647 l1pa_l1ps_com.pccch.packet_chn_desc = ((T_MPHP_START_PCCCH_REQ *)(msg->SigP))->packet_chn_desc; | |
648 l1a_l1s_com.Scell_info.pb = ((T_MPHP_START_PCCCH_REQ *)(msg->SigP))->pb << 2; // Pb format 7.1 | |
649 | |
650 // Number of paging blocks "available" on one PCCCH = number of ppch blocks per MF52 * 64 | |
651 // = (12 - BS_PAG_BLKS_RES - BS_PBCCH_BLKS)*64 | |
652 l1pa_l1ps_com.pccch.nb_ppch_per_mf52 = (12 - l1pa_l1ps_com.pccch.bs_pag_blks_res - (l1pa_l1ps_com.pccch.bs_pbcch_blks + 1)); | |
653 | |
654 // Compute M. | |
655 l1pa_l1ps_com.pccch.pg_blks_avail = l1pa_l1ps_com.pccch.nb_ppch_per_mf52 * 64; | |
656 | |
657 // (IMSI mod 1000) div (KC*N) (Note: N = 1 for PCCCH) | |
658 l1pa_l1ps_com.pccch.pg_offset = imsimod / kcn; | |
659 | |
660 // First Paging Group value: PAGING_GROUP = ((IMSI mod 1000) div ((KC*N)*N)) (for m = 0) | |
661 l1pa_l1ps_com.pccch.first_pg_grp = (l1pa_l1ps_com.pccch.pg_offset % l1pa_l1ps_com.pccch.pg_blks_avail); | |
662 | |
663 // Split Paging computation = min (pg_blks_avail, SPLIT_PG_CYCLE) | |
664 l1pa_l1ps_com.pccch.split_pg_value = Min(l1pa_l1ps_com.pccch.pg_blks_avail, split_pg_cycle); | |
665 | |
666 // Paging Period computation | |
667 l1pa_l1ps_com.pccch.pnp_period = (64*52) / l1pa_l1ps_com.pccch.split_pg_value; | |
668 | |
669 // Rem: changing the paging parameters changes the place where "Periodic Packet | |
670 // Measurement" task must be executed. It implies to set semaphore for P_CRMS task. | |
671 l1pa_l1ps_com.meas_param |= P_CRMS_MEAS; | |
672 | |
673 // Layer 1 internal mode is set to IDLE MODE. | |
674 l1a_l1s_com.mode = I_MODE; | |
675 | |
676 // In order to keep tn_difference and dl_tn consistent, we need to avoid | |
677 // the execution of the SYNCHRO task with tn_difference updated and | |
678 // dl_tn not yet updated (this can occur if we go in the HISR just after | |
679 // the update of tn_difference). To do this the solution is to use the Semaphore | |
680 // associated to the SYNCHRO task. SYNCHRO task will be schedule only if its | |
681 // associated Semaphore is reset. | |
682 // Note: Due to the specificity of the SYNCHRO task which can be enabled | |
683 // by L1A state machines as by L1S processes, the semaphore can't followed | |
684 // the generic rules of the Semaphore shared between L1A and L1S. | |
685 // We must shift the mobile time setting to the timeslot provided by | |
686 // ((T_MPHP_START_PCCCH_REQ *)(msg->SigP))->packet_chn_desc.timeslot_no parameter. | |
687 // tn_difference -> loaded with the number of timeslot to shift. | |
688 // dl_tn -> loaded with the new timeslot. | |
689 l1a_l1s_com.task_param[SYNCHRO] = SEMAPHORE_SET; | |
690 { | |
691 l1a_l1s_com.tn_difference += l1pa_l1ps_com.pccch.packet_chn_desc.timeslot_no - l1a_l1s_com.dl_tn; | |
692 l1a_l1s_com.dl_tn = l1pa_l1ps_com.pccch.packet_chn_desc.timeslot_no; | |
693 | |
694 // Select GPRS DSP Scheduler. | |
695 l1a_l1s_com.dsp_scheduler_mode = GPRS_SCHEDULER; | |
696 | |
697 // Timing must be shifted to a new timeslot, enables SYNCHRO task.. | |
698 l1a_l1s_com.l1s_en_task[SYNCHRO] = TASK_ENABLED; | |
699 } | |
700 l1a_l1s_com.task_param[SYNCHRO] = SEMAPHORE_RESET; | |
701 // Note: The using of the semaphore associated to the SYNCHRO task can't be done | |
702 // as it is for the other semaphores. This is due to the specificity of the SYNCHRO | |
703 // task both touch by L1A and L1S. Here above the semaphore is set prior to touching | |
704 // the SYNCHRO parameters and reset after. In L1S this semaphore is checked. If it's | |
705 // seen SET then L1S will not execute SYNCHRO task nor modify its parameters. | |
706 | |
707 // Step in state machine. | |
708 *state = WAIT_MSG; | |
709 | |
710 if(page_mode == REORG_PG) | |
711 // Paging Reorganization mode... | |
712 { | |
713 // Enable Packet Paging Reorganisation tasks. | |
714 l1a_l1s_com.l1s_en_task[PALLC] = TASK_ENABLED; | |
715 l1a_l1s_com.l1s_en_task[PNP] = TASK_ENABLED; | |
716 | |
717 // End of process. | |
718 end_process = 1; | |
719 } | |
720 else | |
721 if(page_mode == NORM_PG) | |
722 // Normal Paging mode... | |
723 { | |
724 // Enable Packet Paging tasks in mode "NORMAL". | |
725 l1a_l1s_com.l1s_en_task[PNP] = TASK_ENABLED; | |
726 | |
727 // End of process. | |
728 end_process = 1; | |
729 } | |
730 else | |
731 // Extended Paging mode... | |
732 { | |
733 // Initialize Paging State for PAGING_GROUP computation (L1S part) | |
734 l1pa_l1ps_com.pccch.epg_computation = PPCH_POS_NOT_COMP; | |
735 | |
736 // Enable Packet Paging tasks in mode "EXTENDED". | |
737 l1a_l1s_com.l1s_en_task[PNP] = TASK_ENABLED; | |
738 l1a_l1s_com.l1s_en_task[PEP] = TASK_ENABLED; | |
739 | |
740 // End of process. | |
741 end_process = 1; | |
742 } | |
743 | |
744 } // end of test on SignalCode == MPHP_START_PCCCH_REQ | |
745 | |
746 else | |
747 // No action in this machine for other messages. | |
748 //---------------------------------------------- | |
749 { | |
750 // End of process. | |
751 end_process = 1; | |
752 } | |
753 | |
754 } // end of case WAIT_INIT | |
755 break; | |
756 | |
757 case WAIT_MSG: | |
758 { | |
759 if((SignalCode == L1P_PNP_INFO) || | |
760 (SignalCode == L1P_PALLC_INFO) || | |
761 (SignalCode == L1P_PEP_INFO)) | |
762 // Paging Task results | |
763 { | |
764 // Forward result message to L3. | |
765 l1a_send_result(MPHP_DATA_IND, msg, GRRM1_QUEUE); | |
766 | |
767 // End of process. | |
768 return; | |
769 } | |
770 | |
771 else | |
772 if(SignalCode == MPHP_START_PCCCH_REQ) | |
773 // New PCCCH configuration is provided. | |
774 //-------------------------------------------------------- | |
775 { | |
776 // Step in state machine | |
777 *state = RESET; | |
778 } | |
779 | |
780 else | |
781 if((SignalCode == MPHP_STOP_PCCCH_REQ) || | |
782 (SignalCode == L1P_TRANSFER_DONE) || (SignalCode == L1C_DEDIC_DONE)) | |
783 // Request to STOP any serving cell Packet Paging activity, OR | |
784 // Packet Transfer has just started. | |
785 // In both cases, PCCCH reading must be stopped. | |
786 //-------------------------------------------------------- | |
787 { | |
788 // Send confirmation message to L3. | |
789 l1a_send_confirmation(MPHP_STOP_PCCCH_CON,GRRM1_QUEUE); | |
790 | |
791 // This process must be reset. | |
792 *state = RESET; | |
793 } | |
794 | |
795 else | |
796 if((SignalCode == L1P_SINGLE_BLOCK_CON) || | |
797 (SignalCode == MPHP_SINGLE_BLOCK_CON)) | |
798 // If Two Phase Access is ongoing: Packet Resource Request | |
799 // msg has been sent to the network. PCCCH reading must be | |
800 // stopped to let PDCH reading going. | |
801 // REM: we must check both L1P/MPHP messages since an other | |
802 // process could have renamed L1P into MPHP. | |
803 //-------------------------------------------------------- | |
804 { | |
805 if(((T_MPHP_SINGLE_BLOCK_CON *)(msg->SigP))->purpose == TWO_PHASE_ACCESS) | |
806 { | |
807 // This process must be reset. | |
808 *state = RESET; | |
809 } | |
810 else | |
811 { | |
812 // End of process. | |
813 return; | |
814 } | |
815 } | |
816 | |
817 else | |
818 // No action in this machine for other messages. | |
819 //---------------------------------------------- | |
820 { | |
821 // End of process. | |
822 return; | |
823 } | |
824 | |
825 } // end of case WAIT_MSG | |
826 break; | |
827 } // end of switch | |
828 } // end of while | |
829 } // end of procedure | |
830 | |
831 //#pragma GSM_IDLE_DUPLICATE_FOR_INTERNAL_RAM_END | |
832 #endif | |
833 | |
834 /*-------------------------------------------------------*/ | |
835 /* l1pa_idle_packet_polling_process() */ | |
836 /*-------------------------------------------------------*/ | |
837 /* Description : . */ | |
838 /* This state machine handles packet polling after */ | |
839 /* initiation of the packet acces procedure, when a */ | |
840 /* packet queuing notification is sent by the network */ | |
841 /* */ | |
842 /* Starting messages: MPHP_POLLING_RESPONSE_REQ */ | |
843 /* */ | |
844 /* Subsequent messages: */ | |
845 /* */ | |
846 /* Result messages (input): L1P_PRA_DONE */ | |
847 /* */ | |
848 /* Result messages (output): MPHP_POLLING_IND */ | |
849 /* */ | |
850 /* Reset message (input): */ | |
851 /* */ | |
852 /* Reset message (input): */ | |
853 /*-------------------------------------------------------*/ | |
854 void l1pa_idle_packet_polling_process(xSignalHeaderRec *msg) | |
855 { | |
856 enum states | |
857 { | |
858 RESET = 0, | |
859 WAIT_INIT = 1, | |
860 WAIT_RESULT = 2 | |
861 }; | |
862 | |
863 UWORD8 *state = &l1pa.state[P_POLL]; | |
864 UWORD32 SignalCode = msg->SignalCode; | |
865 | |
866 BOOL end_process = 0; | |
867 while(!end_process) | |
868 { | |
869 switch(*state) | |
870 { | |
871 case RESET: | |
872 { | |
873 // Step in state machine. | |
874 *state = WAIT_INIT; | |
875 | |
876 // Reset POLL process. | |
877 l1a_l1s_com.l1s_en_task[POLL] = TASK_DISABLED; // Clear RAACC task enable flag. | |
878 } | |
879 break; | |
880 | |
881 | |
882 case WAIT_INIT: | |
883 { | |
884 if(SignalCode == MPHP_POLLING_RESPONSE_REQ) | |
885 // Polling response request for access procedure. | |
886 //----------------------------------------------- | |
887 { | |
888 UWORD8 i; | |
889 | |
890 // Init POLL process. | |
891 l1pa_l1ps_com.poll_info.pol_resp_type = ((T_MPHP_POLLING_RESPONSE_REQ *)(msg->SigP))->pol_resp_type; | |
892 l1pa_l1ps_com.poll_info.fn = ((T_MPHP_POLLING_RESPONSE_REQ *)(msg->SigP))->fn; | |
893 | |
894 // TXPWR value supplied by L3 is the max. TX power level the MS may use in the given band | |
895 l1s.applied_txpwr = ((T_MPHP_POLLING_RESPONSE_REQ *)(msg->SigP))->txpwr; | |
896 | |
897 // 1 RLC/MAC block is sent: | |
898 // This is a special case, only possible if the MS has a valid TA available from a pending | |
899 // assignment and is pooled for an RLC/MAC block. | |
900 if (l1pa_l1ps_com.poll_info.pol_resp_type == CS1_TYPE_POLL) | |
901 { | |
902 for (i=0; i<24; i++) | |
903 { | |
904 // download 24 bytes from message | |
905 l1pa_l1ps_com.poll_info.chan_req.cs1_data[i] = | |
906 ((T_MPHP_POLLING_RESPONSE_REQ *)(msg->SigP))->channel_request_data[i]; | |
907 } | |
908 l1pa_l1ps_com.poll_info.timing_advance = ((T_MPHP_POLLING_RESPONSE_REQ *)(msg->SigP))->timing_advance; | |
909 | |
910 // Store MAX TXPWR value to be used for first POLL RESPONSE | |
911 // if not already done by Packet Access process... | |
912 for(i = 0; i < 8; i++) | |
913 { | |
914 l1pa_l1ps_com.transfer.dl_pwr_ctrl.txpwr[i] = l1s.applied_txpwr; | |
915 } | |
916 } | |
917 // 4 identical PRACH are sent | |
918 else | |
919 { | |
920 // UWORD16 = data[1]<<8 | data[0] | |
921 l1pa_l1ps_com.poll_info.chan_req.prach_data[0] = | |
922 ((T_MPHP_POLLING_RESPONSE_REQ *)(msg->SigP))->channel_request_data[0]; | |
923 l1pa_l1ps_com.poll_info.chan_req.prach_data[0] |= | |
924 (((T_MPHP_POLLING_RESPONSE_REQ *)(msg->SigP))->channel_request_data[1] << 8); | |
925 | |
926 l1pa_l1ps_com.poll_info.timing_advance = 0; | |
927 } | |
928 | |
929 // step in state machine. | |
930 *state = WAIT_RESULT; | |
931 | |
932 // Change mode to connection establishment part 1. | |
933 l1a_l1s_com.mode = CON_EST_MODE1; | |
934 | |
935 // Activate POLL task (no semaphore for UL tasks). | |
936 // Enable Paging Reorg and Normal paging tasks. | |
937 l1a_l1s_com.l1s_en_task[POLL] = TASK_ENABLED; // Set PRACH task enable flag. | |
938 } | |
939 | |
940 // end of process. | |
941 end_process = 1; | |
942 } | |
943 break; | |
944 | |
945 case WAIT_RESULT: | |
946 { | |
947 if(SignalCode == L1P_POLL_DONE) | |
948 // Random access acqnowledge message. | |
949 //----------------------------------- | |
950 { | |
951 // Forward result message to L3. | |
952 l1a_send_result(MPHP_POLLING_IND, msg, GRRM1_QUEUE); | |
953 | |
954 // Change mode to connection establishment part 2. | |
955 l1a_l1s_com.mode = CON_EST_MODE2; | |
956 | |
957 // This state machine has to be reset | |
958 *state = RESET; | |
959 | |
960 // end of process. | |
961 end_process = 1; | |
962 } | |
963 | |
964 else | |
965 // No action in this machine for other messages. | |
966 //---------------------------------------------- | |
967 { | |
968 // End of process. | |
969 end_process = 1; | |
970 } | |
971 } | |
972 break; | |
973 } // end of "switch". | |
974 } // end of "while" | |
975 } // end of procedure. | |
976 | |
977 | |
978 /*-------------------------------------------------------*/ | |
979 /* l1pa_transfer_process() */ | |
980 /*-------------------------------------------------------*/ | |
981 /* Description: */ | |
982 /* ------------ */ | |
983 /* */ | |
984 /* Starting messages: */ | |
985 /* ------------------ */ | |
986 /* */ | |
987 /* Subsequent messages: */ | |
988 /* -------------------- */ | |
989 /* */ | |
990 /* Result messages (input): */ | |
991 /* ------------------------ */ | |
992 /* */ | |
993 /* Result messages (output): */ | |
994 /* ------------------------- */ | |
995 /* */ | |
996 /* Reset messages (input): */ | |
997 /* ----------------------- */ | |
998 /* */ | |
999 /*-------------------------------------------------------*/ | |
1000 void l1pa_transfer_process(xSignalHeaderRec *msg) | |
1001 { | |
1002 enum states | |
1003 { | |
1004 RESET = 0, | |
1005 WAIT_MSG = 1 | |
1006 }; | |
1007 | |
1008 UWORD8 *state = &l1pa.state[TRANSFER]; | |
1009 UWORD32 SignalCode = msg->SignalCode; | |
1010 | |
1011 BOOL end_process = 0; | |
1012 while(!end_process) | |
1013 { | |
1014 switch(*state) | |
1015 { | |
1016 case RESET: | |
1017 { | |
1018 // Step in state machine. | |
1019 *state = WAIT_MSG; | |
1020 | |
1021 // Rise transfert parameter semaphore. | |
1022 l1pa_l1ps_com.transfer.semaphore = TRUE; | |
1023 } | |
1024 break; | |
1025 | |
1026 case WAIT_MSG: | |
1027 { | |
1028 switch(SignalCode) | |
1029 // switch on input message. | |
1030 //------------------------- | |
1031 { | |
1032 case MPHP_SINGLE_BLOCK_REQ: | |
1033 // Repeat fixed allocation. | |
1034 //------------------------- | |
1035 { | |
1036 T_TRANSFER_SET *free_set; | |
1037 UWORD8 purpose; | |
1038 UWORD8 i; | |
1039 | |
1040 // Rise transfert parameter semaphore to prevent L1S to use partial configuration. | |
1041 l1pa_l1ps_com.transfer.semaphore = TRUE; | |
1042 | |
1043 purpose = ((T_MPHP_SINGLE_BLOCK_REQ *)(msg->SigP))->purpose; | |
1044 | |
1045 // Get Ptr to the free dedicated parameter set. | |
1046 // All important fields are initialised. | |
1047 free_set = l1pa_get_free_transfer_set(purpose); | |
1048 | |
1049 // Fill Transfer mode generic parameters. | |
1050 free_set->assignment_id = ((T_MPHP_SINGLE_BLOCK_REQ *)(msg->SigP))->assignment_id; | |
1051 free_set->assignment_command = purpose; | |
1052 free_set->allocated_tbf = purpose; | |
1053 free_set->packet_ta = ((T_MPHP_SINGLE_BLOCK_REQ *)(msg->SigP))->packet_ta; | |
1054 | |
1055 if((purpose == SINGLE_BLOCK_DL)||(purpose == SINGLE_BLOCK_UL)) | |
1056 { | |
1057 free_set->packet_ta.ta_index = 255; | |
1058 free_set->packet_ta.ta_tn = 255; | |
1059 } | |
1060 | |
1061 free_set->dl_pwr_ctl = ((T_MPHP_SINGLE_BLOCK_REQ *)(msg->SigP))->dl_pwr_ctl; | |
1062 if (free_set->dl_pwr_ctl.p0 != 255) | |
1063 free_set->dl_pwr_ctl.p0 <<= 2; // P0 format 7.1 | |
1064 free_set->tsc = ((T_MPHP_SINGLE_BLOCK_REQ *)(msg->SigP))->tsc; | |
1065 free_set->freq_param = ((T_MPHP_SINGLE_BLOCK_REQ *)(msg->SigP))->freq_param; | |
1066 free_set->tbf_sti = ((T_MPHP_SINGLE_BLOCK_REQ *)(msg->SigP))->tbf_sti; | |
1067 free_set->pc_meas_chan = ((T_MPHP_SINGLE_BLOCK_REQ *)(msg->SigP))->pc_meas_chan; | |
1068 | |
1069 // Download access_burst_type | |
1070 l1pa_l1ps_com.transfer.psi_param.access_burst_type = ((T_MPHP_SINGLE_BLOCK_REQ *)(msg->SigP))->access_burst_type; | |
1071 // Keep the same Pb factor | |
1072 l1pa_l1ps_com.transfer.psi_param.Scell_pb = l1a_l1s_com.Scell_info.pb; | |
1073 // Enable PSI param updating in order to update access_burst_type in L1S | |
1074 l1pa_l1ps_com.transfer.psi_param.psi_param_update_cmd = TRUE; | |
1075 | |
1076 // Fill single block specific parameters. | |
1077 for(i=0;i<23;i++) | |
1078 { | |
1079 l1pa_l1ps_com.transfer.single_block.data_array[i] = | |
1080 ((T_MPHP_SINGLE_BLOCK_REQ *)(msg->SigP))->data_array[i]; | |
1081 } | |
1082 l1pa_l1ps_com.transfer.single_block.tn = | |
1083 ((T_MPHP_SINGLE_BLOCK_REQ *)(msg->SigP))->timeslot_number; | |
1084 | |
1085 l1pa_l1ps_com.transfer.single_block.dl_tn_to_restore = l1a_l1s_com.dl_tn; | |
1086 | |
1087 // Fill "synchro_timeslot" which will be the frame synchro slot. | |
1088 free_set->ul_tbf_synchro_timeslot = l1pa_l1ps_com.transfer.single_block.tn; | |
1089 free_set->transfer_synchro_timeslot = l1pa_l1ps_com.transfer.single_block.tn; | |
1090 | |
1091 // Step in state machine. | |
1092 *state = WAIT_MSG; | |
1093 | |
1094 // Store signalcode. | |
1095 free_set->SignalCode = MPHP_SINGLE_BLOCK_REQ; | |
1096 | |
1097 // Clear transfer parameter semaphore to let L1S use the new parameters. | |
1098 l1pa_l1ps_com.transfer.semaphore = FALSE; | |
1099 | |
1100 // end of process. | |
1101 end_process = 1; | |
1102 } | |
1103 break; | |
1104 | |
1105 case MPHP_ASSIGNMENT_REQ: | |
1106 // Assignement message. | |
1107 //--------------------- | |
1108 { | |
1109 static int count =0; | |
1110 | |
1111 T_TRANSFER_SET *free_set; | |
1112 UWORD8 assignment_command; | |
1113 UWORD8 timeslot_alloc; | |
1114 UWORD8 timeslot; /* TCS211 reconstruction, =0 in TCS3 */ | |
1115 | |
1116 // TBF_changes | |
1117 | |
1118 #if FF_TBF | |
1119 | |
1120 BOOL pseudo_tbf_two_phase_acc; | |
1121 | |
1122 // Special case for two phase access (single or multi allocation): | |
1123 // It is handled as a pseudo UL TBF using a fixed allocation. | |
1124 // Still needs to be flagged to preempt TBF establishment switch in | |
1125 // transfer manager. | |
1126 if (((T_MPHP_ASSIGNMENT_REQ *)(msg->SigP))->assignment_command == TWO_PHASE_ACCESS) | |
1127 { | |
1128 ((T_MPHP_ASSIGNMENT_REQ *)(msg->SigP))->assignment_command = UL_TBF; | |
1129 pseudo_tbf_two_phase_acc = TRUE; | |
1130 } | |
1131 else | |
1132 pseudo_tbf_two_phase_acc = FALSE; | |
1133 #endif | |
1134 count++ ; | |
1135 | |
1136 // Rise transfert parameter semaphore to prevent L1S to use partial configuration. | |
1137 l1pa_l1ps_com.transfer.semaphore = TRUE; | |
1138 | |
1139 assignment_command = ((T_MPHP_ASSIGNMENT_REQ *)(msg->SigP))->assignment_command; | |
1140 | |
1141 // Get Ptr to the free dedicated parameter set. | |
1142 // All important fields are initialised. | |
1143 free_set = l1pa_get_free_transfer_set(assignment_command); | |
1144 | |
1145 // Download message containt. | |
1146 free_set->assignment_id = ((T_MPHP_ASSIGNMENT_REQ *)(msg->SigP))->assignment_id; | |
1147 free_set->assignment_command = assignment_command; | |
1148 free_set->multislot_class = ((T_MPHP_ASSIGNMENT_REQ *)(msg->SigP))->multislot_class; | |
1149 free_set->dl_pwr_ctl = ((T_MPHP_ASSIGNMENT_REQ *)(msg->SigP))->dl_pwr_ctl; | |
1150 if (free_set->dl_pwr_ctl.p0 != 255) | |
1151 free_set->dl_pwr_ctl.p0 <<= 2; // P0 format 7.1 | |
1152 free_set->packet_ta = ((T_MPHP_ASSIGNMENT_REQ *)(msg->SigP))->packet_ta; | |
1153 free_set->tsc = ((T_MPHP_ASSIGNMENT_REQ *)(msg->SigP))->tsc; | |
1154 free_set->freq_param = ((T_MPHP_ASSIGNMENT_REQ *)(msg->SigP))->freq_param; | |
1155 free_set->mac_mode = ((T_MPHP_ASSIGNMENT_REQ *)(msg->SigP))->mac_mode; | |
1156 free_set->tbf_sti = ((T_MPHP_ASSIGNMENT_REQ *)(msg->SigP))->tbf_sti; | |
1157 free_set->interf_meas_enable = ((T_MPHP_ASSIGNMENT_REQ *)(msg->SigP))->interf_meas_enable; | |
1158 free_set->pc_meas_chan = ((T_MPHP_ASSIGNMENT_REQ *)(msg->SigP))->pc_meas_chan; | |
1159 | |
1160 // TBF_changes | |
1161 | |
1162 #if FF_TBF | |
1163 // Two phase access condition is stored in FSET structure to be | |
1164 // transfered in ASET for transfer mode manager use. | |
1165 free_set->pseudo_tbf_two_phase_acc = pseudo_tbf_two_phase_acc; | |
1166 #endif | |
1167 | |
1168 // Download access_burst_type | |
1169 l1pa_l1ps_com.transfer.psi_param.access_burst_type = ((T_MPHP_ASSIGNMENT_REQ *)(msg->SigP))->access_burst_type; | |
1170 // Keep the same Pb factor | |
1171 l1pa_l1ps_com.transfer.psi_param.Scell_pb = l1a_l1s_com.Scell_info.pb; | |
1172 // Enable PSI param updating in order to update access_burst_type in L1S | |
1173 l1pa_l1ps_com.transfer.psi_param.psi_param_update_cmd = TRUE; | |
1174 | |
1175 switch(assignment_command) | |
1176 { | |
1177 case DL_TBF: | |
1178 { | |
1179 free_set->dl_tbf_alloc = ((T_MPHP_ASSIGNMENT_REQ *)(msg->SigP))->dl_ressource_alloc; | |
1180 | |
1181 if((free_set->allocated_tbf == UL_TBF) || | |
1182 (free_set->allocated_tbf == BOTH_TBF)) | |
1183 free_set->allocated_tbf = BOTH_TBF; | |
1184 else | |
1185 free_set->allocated_tbf = DL_TBF; | |
1186 | |
1187 // Look for 1st allocated timeslot. | |
1188 // MSB=TS0...LSB=TS7 | |
1189 timeslot_alloc = free_set->dl_tbf_alloc.timeslot_alloc; | |
1190 timeslot = 0; | |
1191 while((timeslot<7) && !(timeslot_alloc & (0x80>>timeslot))) | |
1192 { | |
1193 timeslot++; | |
1194 } | |
1195 | |
1196 // Fill "synchro_timeslot" which will be the frame synchro slot. | |
1197 free_set->dl_tbf_synchro_timeslot = timeslot; | |
1198 free_set->transfer_synchro_timeslot = timeslot; | |
1199 } | |
1200 break; | |
1201 | |
1202 case UL_TBF: | |
1203 { | |
1204 *(free_set->ul_tbf_alloc) = ((T_MPHP_ASSIGNMENT_REQ *)(msg->SigP))->ul_ressource_alloc; | |
1205 | |
1206 if((free_set->allocated_tbf == DL_TBF) || | |
1207 (free_set->allocated_tbf == BOTH_TBF)) | |
1208 free_set->allocated_tbf = BOTH_TBF; | |
1209 else | |
1210 free_set->allocated_tbf = UL_TBF; | |
1211 | |
1212 // Look for 1st allocated timeslot. | |
1213 // MSB=TS0...LSB=TS7 | |
1214 | |
1215 // Dynamic mode: the uplink PDCH are always monitored | |
1216 // The 1st allocated timeslot is a RX on the lowest numbered | |
1217 // timeslot allocated in uplink | |
1218 #if L1_EDA | |
1219 if((free_set->mac_mode == DYN_ALLOC) || (free_set->mac_mode == EXT_DYN_ALLOC)) | |
1220 #else | |
1221 if(free_set->mac_mode == DYN_ALLOC) | |
1222 #endif | |
1223 { | |
1224 timeslot_alloc = free_set->ul_tbf_alloc->timeslot_alloc; | |
1225 | |
1226 timeslot = 0; | |
1227 while((timeslot<7) && !(timeslot_alloc & (0x80>>timeslot))) | |
1228 { | |
1229 timeslot++; | |
1230 } | |
1231 } | |
1232 else | |
1233 | |
1234 // Fixed mode: the 1st allocated timeslot is the downlink control | |
1235 // timeslot allocated by the network, which is a timeslot allocated | |
1236 // in uplink | |
1237 if(free_set->mac_mode == FIX_ALLOC_NO_HALF) | |
1238 { | |
1239 timeslot = free_set->ul_tbf_alloc->fixed_alloc.ctrl_timeslot; | |
1240 } | |
1241 | |
1242 // Fill "synchro_timeslot" which will be the frame synchro slot. | |
1243 free_set->ul_tbf_synchro_timeslot = timeslot; | |
1244 free_set->transfer_synchro_timeslot = timeslot; | |
1245 } | |
1246 break; | |
1247 | |
1248 case BOTH_TBF: | |
1249 { | |
1250 free_set->dl_tbf_alloc = ((T_MPHP_ASSIGNMENT_REQ *)(msg->SigP))->dl_ressource_alloc; | |
1251 *(free_set->ul_tbf_alloc) = ((T_MPHP_ASSIGNMENT_REQ *)(msg->SigP))->ul_ressource_alloc; | |
1252 free_set->allocated_tbf = BOTH_TBF; | |
1253 | |
1254 // Process the downlink TBF first allocated timeslot | |
1255 timeslot_alloc = free_set->dl_tbf_alloc.timeslot_alloc; | |
1256 timeslot = 0; | |
1257 | |
1258 while((timeslot<7) && !(timeslot_alloc & (0x80>>timeslot))) | |
1259 { | |
1260 timeslot++; | |
1261 } | |
1262 | |
1263 free_set->dl_tbf_synchro_timeslot = timeslot; | |
1264 | |
1265 // Process the uplink TBF first allocated timeslot | |
1266 | |
1267 // Dynamic mode: the uplink PDCH are always monitored | |
1268 // The 1st allocated timeslot is a RX on the lowest numbered | |
1269 // timeslot allocated in uplink | |
1270 #if L1_EDA | |
1271 if((free_set->mac_mode == DYN_ALLOC) || (free_set->mac_mode == EXT_DYN_ALLOC)) | |
1272 #else | |
1273 if(free_set->mac_mode == DYN_ALLOC) | |
1274 #endif | |
1275 { | |
1276 timeslot_alloc = free_set->ul_tbf_alloc->timeslot_alloc; | |
1277 | |
1278 timeslot = 0; | |
1279 while((timeslot<7) && !(timeslot_alloc & (0x80>>timeslot))) | |
1280 { | |
1281 timeslot++; | |
1282 } | |
1283 } | |
1284 else | |
1285 | |
1286 // Fixed mode: the 1st allocated timeslot is the downlink control | |
1287 // timeslot allocated by the network, which is a timeslot allocated | |
1288 // in uplink | |
1289 if(free_set->mac_mode == FIX_ALLOC_NO_HALF) | |
1290 { | |
1291 timeslot = free_set->ul_tbf_alloc->fixed_alloc.ctrl_timeslot; | |
1292 } | |
1293 | |
1294 free_set->ul_tbf_synchro_timeslot = timeslot; | |
1295 | |
1296 // Fill "synchro_timeslot" which will be the frame synchro slot. | |
1297 if (free_set->dl_tbf_synchro_timeslot > free_set->ul_tbf_synchro_timeslot) | |
1298 { | |
1299 free_set->transfer_synchro_timeslot = free_set->ul_tbf_synchro_timeslot; | |
1300 } | |
1301 else | |
1302 { | |
1303 free_set->transfer_synchro_timeslot = free_set->dl_tbf_synchro_timeslot; | |
1304 } | |
1305 | |
1306 } | |
1307 break; | |
1308 } | |
1309 | |
1310 // Cancel any pending release on the assigned TBF | |
1311 if (l1pa_l1ps_com.transfer.tbf_release_param.tbf_release_cmd == TRUE) | |
1312 { | |
1313 // If pending released TBF = assigned TBF or assigned TBF = BOTH | |
1314 if ((assignment_command == l1pa_l1ps_com.transfer.tbf_release_param.released_tbf) || | |
1315 (assignment_command == BOTH_TBF)) | |
1316 { | |
1317 /* | |
1318 * FreeCalypso TCS211 reconstruction: in the LoCosto version | |
1319 * the call to l1pa_send_tbl_release_con() came first, | |
1320 * but in the TCS211 object it comes after the two | |
1321 * assignments. | |
1322 */ | |
1323 | |
1324 // Cancel the TBF release order | |
1325 l1pa_l1ps_com.transfer.tbf_release_param.tbf_release_cmd = FALSE; | |
1326 l1pa_l1ps_com.transfer.tbf_release_param.released_tbf = NO_TBF; | |
1327 | |
1328 // Send a "TBF Release confirmation" msg to L3 : CQ 46842 | |
1329 l1pa_send_tbf_release_con(MPHP_TBF_RELEASE_CON,l1pa_l1ps_com.transfer.tbf_release_param.released_tbf); | |
1330 } | |
1331 // If BOTH TBF release order pending and no BOTH TBF assigned | |
1332 else if (l1pa_l1ps_com.transfer.tbf_release_param.released_tbf == BOTH_TBF) | |
1333 { | |
1334 // Keep the release of the TBF which is not assigned by this message | |
1335 if (assignment_command == DL_TBF) | |
1336 l1pa_l1ps_com.transfer.tbf_release_param.released_tbf = UL_TBF; | |
1337 else | |
1338 l1pa_l1ps_com.transfer.tbf_release_param.released_tbf = DL_TBF; | |
1339 } | |
1340 } | |
1341 | |
1342 // Step in state machine. | |
1343 *state = WAIT_MSG; | |
1344 | |
1345 // Store signalcode. | |
1346 free_set->SignalCode = MPHP_ASSIGNMENT_REQ; | |
1347 | |
1348 // Clear transfer parameter semaphore to let L1S use the new parameters. | |
1349 l1pa_l1ps_com.transfer.semaphore = FALSE; | |
1350 | |
1351 // end of process. | |
1352 end_process = 1; | |
1353 } | |
1354 break; | |
1355 | |
1356 case L1P_TRANSFER_DONE: | |
1357 // Switch to TRANSFER mode has been done. Send a Assignment confirmation | |
1358 // msg to L3. | |
1359 { | |
1360 l1pa_send_confirmation(MPHP_ASSIGNMENT_CON, | |
1361 ((T_L1P_TRANSFER_DONE *) msg->SigP)->assignment_id); | |
1362 | |
1363 // End of process. | |
1364 end_process = 1; | |
1365 } | |
1366 break; | |
1367 | |
1368 case MPHP_TBF_RELEASE_REQ: | |
1369 // TBF Release. | |
1370 //------------- | |
1371 { | |
1372 UWORD8 i; | |
1373 | |
1374 // Rise transfert parameter semaphore to prevent L1S to use partial configuration. | |
1375 l1pa_l1ps_com.transfer.semaphore = TRUE; | |
1376 | |
1377 // Cumulate with a possible TBF release request received during the same block period | |
1378 if (l1pa_l1ps_com.transfer.tbf_release_param.tbf_release_cmd == TRUE) | |
1379 { | |
1380 if (l1pa_l1ps_com.transfer.tbf_release_param.released_tbf != ((T_MPHP_TBF_RELEASE_REQ *)(msg->SigP))->tbf_type) | |
1381 { | |
1382 l1pa_l1ps_com.transfer.tbf_release_param.released_tbf = BOTH_TBF; | |
1383 } | |
1384 } | |
1385 else | |
1386 { | |
1387 // Enables the TBF release processing in L1S. | |
1388 l1pa_l1ps_com.transfer.tbf_release_param.tbf_release_cmd = TRUE; | |
1389 | |
1390 // Download msg info into L1PA_L1PS_COM. | |
1391 l1pa_l1ps_com.transfer.tbf_release_param.released_tbf = ((T_MPHP_TBF_RELEASE_REQ *)(msg->SigP))->tbf_type; | |
1392 } | |
1393 | |
1394 // Disable all pending TBFs those type is the same as the released TBF | |
1395 for(i = 0; i < 2; i++) | |
1396 { | |
1397 // Pending assignment | |
1398 if (l1pa_l1ps_com.transfer.fset[i]->SignalCode == MPHP_ASSIGNMENT_REQ) | |
1399 { | |
1400 #if !FF_TBF | |
1401 switch(l1pa_l1ps_com.transfer.tbf_release_param.released_tbf) | |
1402 #else | |
1403 UWORD8 released_tbf; | |
1404 | |
1405 // Special case if we got a request to release a two phase access TBF: | |
1406 // It is registered within FSET structure as an uplink TBF. If current | |
1407 // structure is pseudo TBF for two phase access, we process the request | |
1408 // like an uplink release, otherwise we skip it. | |
1409 | |
1410 released_tbf = l1pa_l1ps_com.transfer.tbf_release_param.released_tbf; | |
1411 | |
1412 if (released_tbf == TWO_PHASE_ACCESS) | |
1413 { | |
1414 if (l1pa_l1ps_com.transfer.fset[i]->pseudo_tbf_two_phase_acc) | |
1415 released_tbf = UL_TBF; | |
1416 else | |
1417 released_tbf = NO_TBF; | |
1418 } | |
1419 | |
1420 switch(released_tbf) | |
1421 #endif // FF_TBF | |
1422 { | |
1423 case UL_TBF: | |
1424 { | |
1425 if (l1pa_l1ps_com.transfer.fset[i]->allocated_tbf == UL_TBF) | |
1426 { | |
1427 l1pa_l1ps_com.transfer.fset[i]->allocated_tbf = NO_TBF; | |
1428 l1pa_l1ps_com.transfer.fset[i]->SignalCode = NULL; | |
1429 } | |
1430 if (l1pa_l1ps_com.transfer.fset[i]->allocated_tbf == BOTH_TBF) | |
1431 { | |
1432 l1pa_l1ps_com.transfer.fset[i]->allocated_tbf = DL_TBF; | |
1433 } | |
1434 } break; | |
1435 | |
1436 case DL_TBF: | |
1437 { | |
1438 if (l1pa_l1ps_com.transfer.fset[i]->allocated_tbf == DL_TBF) | |
1439 { | |
1440 l1pa_l1ps_com.transfer.fset[i]->allocated_tbf = NO_TBF; | |
1441 l1pa_l1ps_com.transfer.fset[i]->SignalCode = NULL; | |
1442 } | |
1443 if (l1pa_l1ps_com.transfer.fset[i]->allocated_tbf == BOTH_TBF) | |
1444 { | |
1445 l1pa_l1ps_com.transfer.fset[i]->allocated_tbf = UL_TBF; | |
1446 } | |
1447 } break; | |
1448 | |
1449 case BOTH_TBF: | |
1450 { | |
1451 l1pa_l1ps_com.transfer.fset[i]->allocated_tbf = NO_TBF; | |
1452 l1pa_l1ps_com.transfer.fset[i]->SignalCode = NULL; | |
1453 } break; | |
1454 | |
1455 } // End of switch "tbf_release" | |
1456 } // End if SignalCode = MPHP_ASSIGNMENT_REQ or MPHP_REPEAT_UL_FIXED_ALLOC | |
1457 } // End "for" | |
1458 | |
1459 // Clear transfer parameter semaphore to let L1S use the new parameters. | |
1460 l1pa_l1ps_com.transfer.semaphore = FALSE; | |
1461 | |
1462 // end of process. | |
1463 end_process = 1; | |
1464 } | |
1465 break; | |
1466 | |
1467 case L1P_TBF_RELEASED: | |
1468 // TBF has been release by L1S. Send a "TBF Release confirmation" | |
1469 // msg to L3 | |
1470 { | |
1471 // Send confirmation message to L3. | |
1472 l1pa_send_tbf_release_con(MPHP_TBF_RELEASE_CON,((T_L1P_TBF_RELEASED *)(msg->SigP))->tbf_type); | |
1473 | |
1474 // End of process. | |
1475 end_process = 1; | |
1476 } | |
1477 break; | |
1478 | |
1479 case MPHP_STOP_SINGLE_BLOCK_REQ: | |
1480 // Stop SINGLE block activity. | |
1481 //---------------------------- | |
1482 { | |
1483 UWORD8 i; | |
1484 | |
1485 // Rise transfert parameter semaphore to prevent L1S to use partial configuration. | |
1486 l1pa_l1ps_com.transfer.semaphore = TRUE; | |
1487 | |
1488 // Disable SINGLE task. | |
1489 l1a_l1s_com.l1s_en_task[SINGLE] = TASK_DISABLED; | |
1490 | |
1491 // No more TBF... | |
1492 // Disable PDTCH task. | |
1493 l1a_l1s_com.l1s_en_task[PDTCH] = TASK_DISABLED; | |
1494 | |
1495 // Disable PTCCH task. | |
1496 l1a_l1s_com.l1s_en_task[PTCCH] = TASK_DISABLED; | |
1497 | |
1498 // Free the active set. | |
1499 l1pa_l1ps_com.transfer.aset->allocated_tbf = NO_TBF; | |
1500 | |
1501 // Send confirmation message to L3. | |
1502 l1a_send_confirmation(MPHP_STOP_SINGLE_BLOCK_CON,GRRM1_QUEUE); | |
1503 | |
1504 // disable all pending TBF those type is a single block | |
1505 for(i = 0; i < 2; i++) | |
1506 { | |
1507 // check for pending single block req (MPHP_SINGLE_BLOCK_REQ) | |
1508 if (l1pa_l1ps_com.transfer.fset[i]->SignalCode == MPHP_SINGLE_BLOCK_REQ) | |
1509 { | |
1510 // disable the fset corresponding to single blocks | |
1511 l1pa_l1ps_com.transfer.fset[i]->allocated_tbf = NO_TBF; | |
1512 l1pa_l1ps_com.transfer.fset[i]->SignalCode = NULL; | |
1513 } | |
1514 } | |
1515 | |
1516 // This process must be reset. | |
1517 *state = RESET; | |
1518 | |
1519 // end of process. | |
1520 end_process = 1; | |
1521 } | |
1522 break; | |
1523 | |
1524 case MPHP_PDCH_RELEASE_REQ: | |
1525 // PDCH Release. | |
1526 //-------------- | |
1527 { | |
1528 // Rise transfert parameter semaphore to prevent L1S to use partial configuration. | |
1529 l1pa_l1ps_com.transfer.semaphore = TRUE; | |
1530 | |
1531 // Enables the PDCH release processing in L1S. | |
1532 l1pa_l1ps_com.transfer.pdch_release_param.pdch_release_cmd = TRUE; | |
1533 | |
1534 // Download msg info into L1PA_L1PS_COM. | |
1535 l1pa_l1ps_com.transfer.pdch_release_param.timeslot_available = ((T_MPHP_PDCH_RELEASE_REQ *)(msg->SigP))->timeslot_available; | |
1536 l1pa_l1ps_com.transfer.pdch_release_param.assignment_id = ((T_MPHP_PDCH_RELEASE_REQ *)(msg->SigP))->assignment_id; | |
1537 | |
1538 // Clear transfer parameter semaphore to let L1S use the new parameters. | |
1539 l1pa_l1ps_com.transfer.semaphore = FALSE; | |
1540 | |
1541 // end of process. | |
1542 end_process = 1; | |
1543 } | |
1544 break; | |
1545 | |
1546 case L1P_PDCH_RELEASED: | |
1547 // PDCHs have been release by L1S. Send a "PDCH Release confirmation" | |
1548 // msg to L3 | |
1549 { | |
1550 // Send confirmation message to L3. | |
1551 l1pa_send_confirmation(MPHP_PDCH_RELEASE_CON, | |
1552 ((T_L1P_PDCH_RELEASE_CON *) msg->SigP)->assignment_id); | |
1553 | |
1554 // End of process. | |
1555 end_process = 1; | |
1556 } | |
1557 break; | |
1558 | |
1559 case MPHP_TIMING_ADVANCE_REQ: | |
1560 // TA configuration. | |
1561 //------------------ | |
1562 { | |
1563 // Rise transfert parameter semaphore to prevent L1S to use partial configuration. | |
1564 l1pa_l1ps_com.transfer.semaphore = TRUE; | |
1565 | |
1566 // Enables the timing advance update in L1S. | |
1567 l1pa_l1ps_com.transfer.ptcch.ta_update_cmd = TRUE; | |
1568 | |
1569 // Download message content. | |
1570 l1pa_l1ps_com.transfer.ptcch.packet_ta = ((T_MPHP_TIMING_ADVANCE_REQ *)(msg->SigP))->packet_ta; | |
1571 l1pa_l1ps_com.transfer.ptcch.assignment_id = ((T_MPHP_TIMING_ADVANCE_REQ *)(msg->SigP))->assignment_id; | |
1572 | |
1573 // Clear transfer parameter semaphore to let L1S use the new parameters. | |
1574 l1pa_l1ps_com.transfer.semaphore = FALSE; | |
1575 | |
1576 // end of process. | |
1577 end_process = 1; | |
1578 } | |
1579 break; | |
1580 | |
1581 case L1P_TA_CONFIG_DONE: | |
1582 // TA configuration done. | |
1583 //----------------------- | |
1584 { | |
1585 // Send confirmation message to L3. | |
1586 l1pa_send_confirmation(MPHP_TIMING_ADVANCE_CON, | |
1587 ((T_MPHP_TIMING_ADVANCE_CON *) msg->SigP)->assignment_id); | |
1588 | |
1589 // end of process. | |
1590 end_process = 1; | |
1591 } | |
1592 break; | |
1593 | |
1594 case MPHP_UPDATE_PSI_PARAM_REQ: | |
1595 // Update PSI Parameters. | |
1596 //---------------------- | |
1597 { | |
1598 // Download msg content | |
1599 l1pa_l1ps_com.transfer.psi_param.Scell_pb = ((T_MPHP_UPDATE_PSI_PARAM_REQ *)(msg->SigP))->pb << 2; // Pb format 7.1 | |
1600 l1pa_l1ps_com.transfer.psi_param.access_burst_type = ((T_MPHP_UPDATE_PSI_PARAM_REQ *)(msg->SigP))->access_burst_type; | |
1601 | |
1602 l1pa_l1ps_com.transfer.psi_param.psi_param_update_cmd = TRUE; | |
1603 | |
1604 // send confirmation message | |
1605 l1a_send_confirmation(MPHP_UPDATE_PSI_PARAM_CON,GRRM1_QUEUE); | |
1606 | |
1607 // end of process. | |
1608 end_process = 1; | |
1609 } | |
1610 break; | |
1611 | |
1612 case L1P_PACCH_INFO: | |
1613 // Two Phase Access is ongoing: Packet Resource Request | |
1614 // msg has been sent to the network. CCCH reading must be | |
1615 // stopped to let PDCH reading going. | |
1616 //-------------------------------------------------------- | |
1617 { | |
1618 // Forward result message to RR. | |
1619 l1a_send_result(MPHP_DATA_IND, msg, GRRM1_QUEUE); | |
1620 | |
1621 // end of process. | |
1622 end_process = 1; | |
1623 } | |
1624 break; | |
1625 | |
1626 case L1P_SINGLE_BLOCK_CON: | |
1627 // Two Phase Access is ongoing: Packet Resource Request | |
1628 // msg has been sent to the network. CCCH reading must be | |
1629 // stopped to let PDCH reading going. | |
1630 //-------------------------------------------------------- | |
1631 { | |
1632 // Forward result message to RR. | |
1633 l1a_send_result(MPHP_SINGLE_BLOCK_CON, msg, GRRM1_QUEUE); | |
1634 | |
1635 // This process must be reset. | |
1636 *state = RESET; | |
1637 | |
1638 // end of process. | |
1639 end_process = 1; | |
1640 } | |
1641 break; | |
1642 | |
1643 case MPHP_REPEAT_UL_FIXED_ALLOC_REQ: | |
1644 // Repeat uplink fixed mode allocation bitmap | |
1645 //------------------------------------------- | |
1646 { | |
1647 // Rise transfert parameter semaphore to prevent L1S to use partial configuration. | |
1648 l1pa_l1ps_com.transfer.semaphore = TRUE; | |
1649 | |
1650 // If an UL TBF is running... | |
1651 if ((l1pa_l1ps_com.transfer.aset->allocated_tbf == UL_TBF) || | |
1652 (l1pa_l1ps_com.transfer.aset->allocated_tbf == BOTH_TBF)) | |
1653 { | |
1654 // Download info. from message | |
1655 l1pa_l1ps_com.transfer.repeat_alloc = *((T_MPHP_REPEAT_UL_FIXED_ALLOC_REQ *) msg->SigP); | |
1656 } | |
1657 | |
1658 // Send confirmation if this message was a repeat allocation cancelling | |
1659 if (!((T_MPHP_REPEAT_UL_FIXED_ALLOC_REQ *) msg->SigP)->repeat_allocation) | |
1660 { | |
1661 l1a_send_confirmation(MPHP_REPEAT_UL_FIXED_ALLOC_CON,GRRM1_QUEUE); | |
1662 } | |
1663 else | |
1664 { | |
1665 UWORD8 i; | |
1666 | |
1667 // Disable all pending UL TBF | |
1668 for(i = 0; i < 2; i++) | |
1669 { | |
1670 // Pending assignment | |
1671 if (l1pa_l1ps_com.transfer.fset[i]->SignalCode == MPHP_ASSIGNMENT_REQ) | |
1672 { | |
1673 switch(l1pa_l1ps_com.transfer.fset[i]->allocated_tbf) | |
1674 { | |
1675 // Remove pending UL TBF | |
1676 case UL_TBF: | |
1677 { | |
1678 l1pa_l1ps_com.transfer.fset[i]->allocated_tbf = NO_TBF; | |
1679 l1pa_l1ps_com.transfer.fset[i]->SignalCode = NULL; | |
1680 } | |
1681 break; | |
1682 | |
1683 // Change pending BOTH_TBF in pending DL_TBF | |
1684 case BOTH_TBF: | |
1685 { | |
1686 l1pa_l1ps_com.transfer.fset[i]->allocated_tbf = DL_TBF; | |
1687 } | |
1688 break; | |
1689 | |
1690 } // End of switch "allocated_tbf" | |
1691 } // End if SignalCode = MPHP_ASSIGNMENT_REQ | |
1692 } // End "for" | |
1693 } | |
1694 | |
1695 // Clear transfer parameter semaphore to let L1S use the new parameters. | |
1696 l1pa_l1ps_com.transfer.semaphore = FALSE; | |
1697 | |
1698 // end of process. | |
1699 end_process = 1; | |
1700 } | |
1701 break; | |
1702 | |
1703 case L1P_REPEAT_ALLOC_DONE: | |
1704 { | |
1705 // Send confirmation message to L3. | |
1706 l1a_send_confirmation(MPHP_REPEAT_UL_FIXED_ALLOC_CON,GRRM1_QUEUE); | |
1707 | |
1708 // end of process. | |
1709 end_process = 1; | |
1710 } | |
1711 break; | |
1712 | |
1713 default: | |
1714 // End of process. | |
1715 //---------------- | |
1716 { | |
1717 return; | |
1718 } | |
1719 } // end of switch(SignalCode) | |
1720 } // end of case WAIT_CONFIG. | |
1721 } // end of "switch". | |
1722 } // end of "while" | |
1723 } // end of procedure. | |
1724 | |
1725 /*-------------------------------------------------------*/ | |
1726 /* l1pa_serving_cell_pbcch_read_process() */ | |
1727 /*-------------------------------------------------------*/ | |
1728 /* Description : This state machine handles Packet */ | |
1729 /* serving cell PBCCH reading. */ | |
1730 /* */ | |
1731 /* Starting messages: MPHP_SCELL_PBCCH_REQ */ | |
1732 /* ------------------ */ | |
1733 /* */ | |
1734 /* L1 continuously reads the serving cell PBCCH */ | |
1735 /* as requested by the scheduling info (PSI1 repeat */ | |
1736 /* period and relative position. */ | |
1737 /* */ | |
1738 /* Result messages (input): L1C_PBCCHS_INFO */ | |
1739 /* ------------------------ */ | |
1740 /* System information data block from L1S. */ | |
1741 /* */ | |
1742 /* Reset messages (input): MPHP_SCELL_PBCCH_STOP_REQ */ | |
1743 /* ----------------------- */ | |
1744 /* */ | |
1745 /*-------------------------------------------------------*/ | |
1746 void l1pa_serving_cell_pbcch_read_process(xSignalHeaderRec *msg) | |
1747 { | |
1748 enum states | |
1749 { | |
1750 RESET = 0, | |
1751 WAIT_PBCCHS_CONFIG = 1, | |
1752 WAIT_PBCCHS_RESULT = 2, | |
1753 PBCCHS_CONFIG = 3 | |
1754 }; | |
1755 | |
1756 UWORD8 *state = &l1pa.state[SCPB]; | |
1757 UWORD32 SignalCode = msg->SignalCode; | |
1758 | |
1759 #define PbcchS l1pa_l1ps_com.pbcchs | |
1760 | |
1761 BOOL end_process = 0; | |
1762 while(!end_process) | |
1763 { | |
1764 switch(*state) | |
1765 { | |
1766 case RESET: | |
1767 { | |
1768 // Step in state machine. | |
1769 *state = WAIT_PBCCHS_CONFIG; | |
1770 | |
1771 // Reset PBCCHS process. | |
1772 l1a_l1s_com.l1s_en_task[PBCCHS] = TASK_DISABLED; // Clear PBCCHS task enable flag. | |
1773 } | |
1774 break; | |
1775 | |
1776 case WAIT_PBCCHS_CONFIG: | |
1777 { | |
1778 // Request to read Normal BCCH from serving cell. | |
1779 if(SignalCode == MPHP_SCELL_PBCCH_REQ) | |
1780 { | |
1781 #define MAX_PSI1_PERIOD 16 | |
1782 | |
1783 UWORD8 i; | |
1784 | |
1785 // Set semaphores for Serving Cell PBCCH reading task. | |
1786 l1a_l1s_com.task_param[PBCCHS] = SEMAPHORE_SET; | |
1787 | |
1788 // Download message content. | |
1789 //-------------------------- | |
1790 PbcchS.nbr_psi = ((T_MPHP_SCELL_PBCCH_REQ *)(msg->SigP))->nbr_psi; | |
1791 PbcchS.bs_pbcch_blks = ((T_MPHP_SCELL_PBCCH_REQ *)(msg->SigP))->bs_pbcch_blks; | |
1792 PbcchS.packet_chn_desc = ((T_MPHP_SCELL_PBCCH_REQ *)(msg->SigP))->packet_chn_desc; | |
1793 PbcchS.frequency_list = ((T_MPHP_SCELL_PBCCH_REQ *)(msg->SigP))->frequency_list; | |
1794 l1a_l1s_com.Scell_info.pb = ((T_MPHP_SCELL_PBCCH_REQ *)(msg->SigP))->pb << 2; // Pb format 7.1 | |
1795 PbcchS.psi1_repeat_period = ((T_MPHP_SCELL_PBCCH_REQ *)(msg->SigP))->psi1_repeat_period; | |
1796 | |
1797 // PBCCH Period is: MF52 * psi1_repeat_period | |
1798 PbcchS.pbcch_period = 52L * PbcchS.psi1_repeat_period; | |
1799 | |
1800 if(PbcchS.nbr_psi == 0) | |
1801 // Full PBCCH reading: Emulated throw "relative positions". | |
1802 //--------------------------------------------------------- | |
1803 { | |
1804 // Emulate full PBCCH reading throw "relative positions" and a repeat period | |
1805 // of 1 MF52. | |
1806 // bs_pbcch_blks= 0 -> Read B0 | |
1807 // bs_pbcch_blks= 1 -> Read B0,B6 | |
1808 // bs_pbcch_blks= 2 -> Read B0,B6,B3 | |
1809 // bs_pbcch_blks= 3 -> Read B0,B6,B3,B9 | |
1810 | |
1811 PbcchS.nbr_psi = PbcchS.bs_pbcch_blks+1; | |
1812 PbcchS.read_all_psi = TRUE; | |
1813 | |
1814 for(i=0;i<PbcchS.nbr_psi;i++) | |
1815 { | |
1816 ((T_MPHP_SCELL_PBCCH_REQ *)(msg->SigP))->relative_position_array[i] = i; | |
1817 } | |
1818 } | |
1819 | |
1820 else | |
1821 // PBCCH reading: use provided "relative positions". | |
1822 //-------------------------------------------------- | |
1823 { | |
1824 PbcchS.read_all_psi = FALSE; | |
1825 } | |
1826 | |
1827 // Compute FN offset for each PSI. | |
1828 //-------------------------------- | |
1829 for(i=0;i<l1pa_l1ps_com.pbcchs.nbr_psi;i++) | |
1830 { | |
1831 WORD8 nbr_mf52; // Range 0..MAX_PSI1_PERIOD (can be negative along its estimation) | |
1832 UWORD8 nbr_rest; // Range 0..3 | |
1833 UWORD8 relative_position; // Range 0..4*MAX_PSI1_PERIOD | |
1834 UWORD8 psi_period; // psi1_repeat_period = 1 if nbr_psi = 0 | |
1835 | |
1836 relative_position = ((T_MPHP_SCELL_PBCCH_REQ *)(msg->SigP))->relative_position_array[i]; | |
1837 | |
1838 nbr_mf52 = relative_position / (PbcchS.bs_pbcch_blks+1); | |
1839 nbr_rest = relative_position % (PbcchS.bs_pbcch_blks+1); | |
1840 | |
1841 // Block B0 is a special case since CTRL phase occurs during | |
1842 // the MF52 before. | |
1843 if(nbr_rest == 0) | |
1844 { | |
1845 nbr_mf52 -= 1; | |
1846 | |
1847 // Set psi_period to 1 when all PSI have to be read (nbr_psi = 0) | |
1848 if(PbcchS.read_all_psi) | |
1849 psi_period = 1; | |
1850 else | |
1851 psi_period = PbcchS.psi1_repeat_period; | |
1852 | |
1853 if(nbr_mf52 < 0) | |
1854 nbr_mf52 += psi_period; | |
1855 } | |
1856 | |
1857 PbcchS.offset_array[i] = (nbr_mf52 * 52L) + PBCCH_POSITION[PbcchS.bs_pbcch_blks][nbr_rest]; | |
1858 PbcchS.relative_position_array[i] = relative_position; | |
1859 } | |
1860 | |
1861 // Step in state machine. | |
1862 *state = PBCCHS_CONFIG; | |
1863 } | |
1864 | |
1865 // No action in this machine for other messages. | |
1866 else | |
1867 { | |
1868 // End of process. | |
1869 return; | |
1870 } | |
1871 } | |
1872 break; | |
1873 | |
1874 case PBCCHS_CONFIG: | |
1875 { | |
1876 WORD8 tn_pbcch; | |
1877 | |
1878 // If PBCCH TS is inferior to L1 synchronization TS, the PBCCH reading | |
1879 // control must be done one frame in advance | |
1880 if (PbcchS.packet_chn_desc.timeslot_no < l1a_l1s_com.dl_tn) | |
1881 PbcchS.control_offset = TRUE; | |
1882 else | |
1883 PbcchS.control_offset = FALSE; | |
1884 | |
1885 // Set "change_synchro" flag to trigger L1S to change the synchro on fly | |
1886 // within PBCCHS and to restore current synchro when PBCCHS task is completed. | |
1887 if(((PbcchS.packet_chn_desc.timeslot_no - l1a_l1s_com.dl_tn + 8) % 8) >=4) | |
1888 { | |
1889 // L1S will make a intra PBCCHS task synchro to current TS + 4. | |
1890 PbcchS.change_synchro = TRUE; | |
1891 tn_pbcch = PbcchS.packet_chn_desc.timeslot_no - l1a_l1s_com.dl_tn - 4; | |
1892 } | |
1893 else | |
1894 { | |
1895 // L1S will NOT make the intra PBCCHS task synchro. | |
1896 PbcchS.change_synchro = FALSE; | |
1897 tn_pbcch = PbcchS.packet_chn_desc.timeslot_no - l1a_l1s_com.dl_tn; | |
1898 } | |
1899 | |
1900 if(tn_pbcch < 0) | |
1901 PbcchS.tn_pbcch = tn_pbcch + 8; | |
1902 else | |
1903 PbcchS.tn_pbcch = tn_pbcch; | |
1904 | |
1905 // Enable PBCCHS task. | |
1906 l1a_l1s_com.l1s_en_task[PBCCHS] = TASK_ENABLED; | |
1907 | |
1908 | |
1909 // Step in state machine. | |
1910 *state = WAIT_PBCCHS_RESULT; | |
1911 | |
1912 // End of process. | |
1913 end_process = 1; | |
1914 } | |
1915 break; | |
1916 | |
1917 case WAIT_PBCCHS_RESULT: | |
1918 { | |
1919 if(SignalCode == L1P_PBCCHS_INFO) | |
1920 // Serving cell BCCH reading result. | |
1921 //---------------------------------- | |
1922 { | |
1923 // Forward result message to L3. | |
1924 l1a_send_result(MPHP_DATA_IND, msg, GRRM1_QUEUE); | |
1925 | |
1926 // End of process. | |
1927 return; | |
1928 } | |
1929 | |
1930 else | |
1931 if(SignalCode == MPHP_SCELL_PBCCH_REQ) | |
1932 // Request to re-configure PBCCH reading. | |
1933 //-------------------------------------- | |
1934 { | |
1935 // Step in state machine. | |
1936 *state = WAIT_PBCCHS_CONFIG; | |
1937 } | |
1938 | |
1939 else | |
1940 if(SignalCode == MPHP_SCELL_PBCCH_STOP_REQ) | |
1941 // Request to STOP any serving cell pbcch activity. | |
1942 //------------------------------------------------ | |
1943 { | |
1944 // Send confirmation message to L3. | |
1945 l1a_send_confirmation(MPHP_SCELL_PBCCH_STOP_CON,GRRM1_QUEUE); | |
1946 | |
1947 // This process must be reset. | |
1948 *state = RESET; | |
1949 } | |
1950 | |
1951 else | |
1952 // End of packet transfer mode: test PDTCH to be sure that TBF downlink and uplink are released | |
1953 if((SignalCode == L1P_TBF_RELEASED) && (((T_L1P_TBF_RELEASED *)(msg->SigP))->released_all)) | |
1954 { | |
1955 // This process must be reset. | |
1956 *state = RESET; | |
1957 } | |
1958 | |
1959 else | |
1960 if ((SignalCode == L1P_TRANSFER_DONE) || (SignalCode == L1P_TBF_RELEASED) || //change of Time Slot | |
1961 (SignalCode == L1P_REPEAT_ALLOC_DONE) || (SignalCode == L1P_ALLOC_EXHAUST_DONE)) | |
1962 { | |
1963 // Clear PBCCHS task enable flag. | |
1964 l1a_l1s_com.l1s_en_task[PBCCHS] = TASK_DISABLED; | |
1965 | |
1966 // Set semaphores for Serving Cell PBCCH reading task. | |
1967 l1a_l1s_com.task_param[PBCCHS] = SEMAPHORE_SET; | |
1968 | |
1969 // l1a_l1s_com.dl_tn was changed. Check if a change synchro is needed | |
1970 *state = PBCCHS_CONFIG; // Step in state machine. | |
1971 } | |
1972 | |
1973 else | |
1974 // No action in this machine for other messages. | |
1975 //---------------------------------------------- | |
1976 { | |
1977 // End of process. | |
1978 return; | |
1979 } | |
1980 } | |
1981 break; | |
1982 } // end of "switch". | |
1983 } // end of "while" | |
1984 } // end of procedure. | |
1985 | |
1986 | |
1987 /*-------------------------------------------------------*/ | |
1988 /* l1pa_neighbor_cell_pbcch_read_process() */ | |
1989 /*-------------------------------------------------------*/ | |
1990 /* Description : This state machine handles Packet */ | |
1991 /* neighbor cell PBCCH reading. */ | |
1992 /* */ | |
1993 /* Starting messages: MPHP_NCELL_PBCCH_REQ */ | |
1994 /* ------------------ */ | |
1995 /* */ | |
1996 /* L1 continuously reads the neighbor cell PBCCH */ | |
1997 /* as requested by the scheduling info (PSI1 repeat */ | |
1998 /* period and relative position. */ | |
1999 /* */ | |
2000 /* Result messages (input): L1C_PBCCHN_INFO */ | |
2001 /* ------------------------ */ | |
2002 /* System information data block from L1S. */ | |
2003 /* */ | |
2004 /* Reset messages (input): MPHP_NCELL_PBCCH_STOP_REQ */ | |
2005 /* ----------------------- */ | |
2006 /* */ | |
2007 /*-------------------------------------------------------*/ | |
2008 void l1pa_neighbor_cell_pbcch_read_process(xSignalHeaderRec *msg) | |
2009 { | |
2010 enum states | |
2011 { | |
2012 RESET = 0, | |
2013 WAIT_PBCCHN_CONFIG = 1, | |
2014 WAIT_PBCCHN_RESULT = 2, | |
2015 PBCCHN_CONFIG = 3 | |
2016 }; | |
2017 | |
2018 UWORD8 *state = &l1pa.state[NCPB]; | |
2019 UWORD32 SignalCode = msg->SignalCode; | |
2020 | |
2021 #define PbcchN l1pa_l1ps_com.pbcchn | |
2022 | |
2023 static WORD32 fn_offset_mem; | |
2024 static WORD32 time_alignmt_mem; | |
2025 | |
2026 BOOL end_process = 0; | |
2027 while(!end_process) | |
2028 { | |
2029 switch(*state) | |
2030 { | |
2031 case RESET: | |
2032 { | |
2033 // Step in state machine. | |
2034 *state = WAIT_PBCCHN_CONFIG; | |
2035 | |
2036 // Reset PBCCHS process. | |
2037 l1a_l1s_com.l1s_en_task[PBCCHN_IDLE] = TASK_DISABLED; // Clear PBCCHN task enable flag used in IDLE mode | |
2038 l1a_l1s_com.l1s_en_task[PBCCHN_TRAN] = TASK_DISABLED; // Clear PBCCHN task enable flag used in Transfer Packet mode | |
2039 } | |
2040 break; | |
2041 | |
2042 case WAIT_PBCCHN_CONFIG: | |
2043 { | |
2044 // Request to read Normal PBCCH from neighbor cell. | |
2045 if(SignalCode == MPHP_NCELL_PBCCH_REQ) | |
2046 { | |
2047 #define MAX_PSI1_PERIOD 16 | |
2048 | |
2049 // Set semaphores for Neighbor Cell PBCCH reading task. | |
2050 l1a_l1s_com.task_param[PBCCHN_IDLE] = SEMAPHORE_SET; | |
2051 l1a_l1s_com.task_param[PBCCHN_TRAN] = SEMAPHORE_SET; | |
2052 | |
2053 // Download message content. | |
2054 //-------------------------- | |
2055 PbcchN.bcch_carrier = ((T_MPHP_NCELL_PBCCH_REQ *)(msg->SigP))->bcch_carrier; | |
2056 PbcchN.bs_pbcch_blks = ((T_MPHP_NCELL_PBCCH_REQ *)(msg->SigP))->bs_pbcch_blks; | |
2057 PbcchN.packet_chn_desc = ((T_MPHP_NCELL_PBCCH_REQ *)(msg->SigP))->packet_chn_desc; | |
2058 PbcchN.frequency_list = ((T_MPHP_NCELL_PBCCH_REQ *)(msg->SigP))->frequency_list; | |
2059 PbcchN.psi1_repeat_period = ((T_MPHP_NCELL_PBCCH_REQ *)(msg->SigP))->psi1_repeat_period; | |
2060 PbcchN.relative_position = ((T_MPHP_NCELL_PBCCH_REQ *)(msg->SigP))->relative_position; | |
2061 fn_offset_mem = ((T_MPHP_NCELL_PBCCH_REQ *)(msg->SigP))->fn_offset; | |
2062 time_alignmt_mem = ((T_MPHP_NCELL_PBCCH_REQ *)(msg->SigP))->time_alignment; | |
2063 PbcchN.pb = ((T_MPHP_NCELL_PBCCH_REQ *)(msg->SigP))->pb << 2; // Pb format 7.1 | |
2064 | |
2065 // PBCCH Period is: MF52 * psi1_repeat_period | |
2066 PbcchN.pbcch_period = 52L * PbcchN.psi1_repeat_period; | |
2067 | |
2068 // Compute FN offset. | |
2069 //------------------ | |
2070 { | |
2071 WORD8 nbr_mf52; // Range 0..MAX_PSI1_PERIOD (can be negative along its estimation) | |
2072 UWORD8 nbr_rest; // Range 0..3 | |
2073 UWORD8 relative_position; // Range 0..4*MAX_PSI1_PERIOD | |
2074 | |
2075 relative_position = PbcchN.relative_position; | |
2076 | |
2077 // number of PBCCH blocs | |
2078 nbr_mf52 = relative_position / (PbcchN.bs_pbcch_blks+1); | |
2079 nbr_rest = relative_position % (PbcchN.bs_pbcch_blks+1); | |
2080 | |
2081 // Block B0 is a special case since CTRL phase occurs during the MF52 before. | |
2082 if(nbr_rest == 0) | |
2083 { | |
2084 nbr_mf52 -= 1; | |
2085 | |
2086 if(nbr_mf52 < 0) | |
2087 nbr_mf52 += PbcchN.psi1_repeat_period; | |
2088 } | |
2089 | |
2090 PbcchN.offset = (nbr_mf52 * 52L) + PBCCH_POSITION[PbcchN.bs_pbcch_blks][nbr_rest]; | |
2091 | |
2092 // In case of idle mode | |
2093 if (l1a_l1s_com.mode != PACKET_TRANSFER_MODE) | |
2094 { | |
2095 PbcchN.offset -= 2 ; // because of the 2 frames for the measurement windows | |
2096 // note: PbcchN.offset can not be negative (PbcchN.offset > 12). | |
2097 } | |
2098 } | |
2099 // Step in state machine. | |
2100 *state = PBCCHN_CONFIG; | |
2101 } | |
2102 | |
2103 // No action in this machine for other messages. | |
2104 else | |
2105 { | |
2106 // End of process. | |
2107 return; | |
2108 } | |
2109 } | |
2110 break; | |
2111 | |
2112 case PBCCHN_CONFIG: | |
2113 { | |
2114 //================================================================================== | |
2115 // choose a relative base time in the neighbor cell in order to simplify the L1S scheduling. | |
2116 //================================================================================== | |
2117 PbcchN.fn_offset = fn_offset_mem; | |
2118 PbcchN.time_alignmt = time_alignmt_mem; | |
2119 | |
2120 //the new relative base time is set in order to have the Neighbor burst in position 0. | |
2121 //update with the burts position of the neighor cell : PbcchN.packet_chn_desc.timeslot_no | |
2122 //update according to the current serving cell synchro : l1a_l1s_com.dl_tn | |
2123 PbcchN.time_alignmt += (PbcchN.packet_chn_desc.timeslot_no - l1a_l1s_com.dl_tn ) * TN_WIDTH; | |
2124 | |
2125 // PbcchN.time_alignmt is in [-7TS..+16TS[. | |
2126 // more than 1 frame between the serving cell and the neighbor burst | |
2127 if ( PbcchN.time_alignmt >= 8*TN_WIDTH) | |
2128 { | |
2129 PbcchN.time_alignmt -= 8*TN_WIDTH; | |
2130 PbcchN.fn_offset --; | |
2131 } | |
2132 else | |
2133 if ( PbcchN.time_alignmt < 0) | |
2134 { | |
2135 PbcchN.time_alignmt += 8*TN_WIDTH; | |
2136 PbcchN.fn_offset ++; | |
2137 } | |
2138 | |
2139 // Set "change_synchro" flag to trigger L1S to change the synchro on fly | |
2140 // within PBCCHN and to restore current synchro when PBCCHN task is completed. | |
2141 if (PbcchN.time_alignmt >= 4 * TN_WIDTH) | |
2142 { | |
2143 PbcchN.time_alignmt -= 4 * TN_WIDTH; | |
2144 PbcchN.change_synchro = TRUE; | |
2145 } | |
2146 else | |
2147 PbcchN.change_synchro = FALSE; | |
2148 | |
2149 // In case of packet transfer mode | |
2150 if (l1a_l1s_com.mode == PACKET_TRANSFER_MODE) | |
2151 { | |
2152 // Enable Packet Transfer PBCCHN task | |
2153 l1a_l1s_com.l1s_en_task[PBCCHN_TRAN] = TASK_ENABLED; | |
2154 | |
2155 } | |
2156 // in case of Idle mode | |
2157 else | |
2158 { | |
2159 // Enable IDLE PBCCHN task | |
2160 l1a_l1s_com.l1s_en_task[PBCCHN_IDLE] = TASK_ENABLED; | |
2161 } | |
2162 | |
2163 // Step in state machine. | |
2164 *state = WAIT_PBCCHN_RESULT; | |
2165 | |
2166 // End of process. | |
2167 end_process = 1; | |
2168 } | |
2169 break; | |
2170 | |
2171 case WAIT_PBCCHN_RESULT: | |
2172 { | |
2173 if(SignalCode == L1P_PBCCHN_INFO) | |
2174 // Serving cell BCCH reading result. | |
2175 //---------------------------------- | |
2176 { | |
2177 // Forward result message to L3. | |
2178 l1a_send_result(MPHP_NCELL_PBCCH_IND, msg, GRRM1_QUEUE); | |
2179 | |
2180 // This process must be reset. | |
2181 *state = RESET; | |
2182 } | |
2183 | |
2184 else | |
2185 if(SignalCode == MPHP_NCELL_PBCCH_REQ) | |
2186 // Request to re-configure PBCCH reading. | |
2187 //-------------------------------------- | |
2188 { | |
2189 // Step in state machine. | |
2190 *state = WAIT_PBCCHN_CONFIG; | |
2191 } | |
2192 | |
2193 else | |
2194 if(SignalCode == MPHP_NCELL_PBCCH_STOP_REQ) | |
2195 // Request to STOP any serving cell pbcch activity. | |
2196 //------------------------------------------------ | |
2197 { | |
2198 // Send confirmation message to L3. | |
2199 l1a_send_confirmation(MPHP_NCELL_PBCCH_STOP_CON,GRRM1_QUEUE); | |
2200 | |
2201 // This process must be reset. | |
2202 *state = RESET; | |
2203 } | |
2204 else | |
2205 // End of packet transfer mode: test PDTCH to be sure that TBF downlink and uplink are released | |
2206 if((SignalCode == L1P_TBF_RELEASED) && (((T_L1P_TBF_RELEASED *)(msg->SigP))->released_all)) | |
2207 { | |
2208 // This process must be reset. | |
2209 *state = RESET; | |
2210 } | |
2211 else | |
2212 if ((SignalCode == L1P_TRANSFER_DONE) || (SignalCode == L1P_TBF_RELEASED) || //change of Time Slot | |
2213 (SignalCode == L1P_REPEAT_ALLOC_DONE) || (SignalCode == L1P_ALLOC_EXHAUST_DONE)) | |
2214 { | |
2215 // We consider only the case: packet Transfer => packet Transfer,the serving TS may be changed | |
2216 // For other cases such as Idle -> Transfer... decision not yet taken. | |
2217 | |
2218 // update the PBCCHN parameters | |
2219 // Clear PBCCHN_TRAN task disable flag. | |
2220 l1a_l1s_com.l1s_en_task[PBCCHN_TRAN] = TASK_DISABLED; | |
2221 | |
2222 // Set semaphores for Neighbor Cell PBCCH reading task. | |
2223 l1a_l1s_com.task_param[PBCCHN_TRAN] = SEMAPHORE_SET; | |
2224 | |
2225 // update the PBCCHN parameters | |
2226 *state = PBCCHN_CONFIG;// Step in state machine. | |
2227 } | |
2228 else | |
2229 // No action in this machine for other messages. | |
2230 //---------------------------------------------- | |
2231 { | |
2232 // End of process. | |
2233 return; | |
2234 } | |
2235 } | |
2236 break; | |
2237 } // end of "switch". | |
2238 } // end of "while" | |
2239 } // end of procedure. | |
2240 | |
2241 | |
2242 | |
2243 /*-------------------------------------------------------*/ | |
2244 /* l1pa_tcr_meas_process() */ | |
2245 /*-------------------------------------------------------*/ | |
2246 /* Description : This state machine handles Neigbor cell */ | |
2247 /* measurement process in Packet Transfer mode. */ | |
2248 /* Measurement are made on a specified frequency list. */ | |
2249 /* The process is started automatically by L1 (on receipt*/ | |
2250 /* of a L1P_TRANSFER_DONE message from L1S) and doesn't */ | |
2251 /* need to receive any message from L3. */ | |
2252 /* In order to update the frequency list, a */ | |
2253 /* MHPC_TCR_MEAS_REQ msg will be sent from L3 to L1 */ | |
2254 /* */ | |
2255 /* Starting messages: L1P_TRANSFER_DONE */ | |
2256 /* ------------------ */ | |
2257 /* L1 starts then measures on carriers specified in the */ | |
2258 /* frequency list. Measures are performed on every */ | |
2259 /* frames with the occurence of 1 measure per frame */ | |
2260 /* */ | |
2261 /* Subsequent messages: MPHP_TCR_MEAS_REQ */ | |
2262 /* -------------------- */ | |
2263 /* The update is not done asap but postponed until the */ | |
2264 /* end of the reporting period. Frequency list is */ | |
2265 /* updated with the new list. */ | |
2266 /* */ | |
2267 /* Result messages (input): L1P_TRANSFER_MEAS_DONE */ | |
2268 /* ------------------------ */ | |
2269 /* This is the periodic reporting message sent by L1S. */ | |
2270 /* The reporting is done every "reporting period". */ | |
2271 /* The beguining of the reporting period is arbitrary */ | |
2272 /* and starts when the Neigh Meas task is enabled. */ | |
2273 /* */ | |
2274 /* Result messages (output): MPHP_TCR_MEAS_IND */ | |
2275 /* ------------------------- */ | |
2276 /* This is the periodic reporting message to L3. */ | |
2277 /* */ | |
2278 /* Reset messages (input): MPHP_TCR_MEAS_STOP_REQ */ | |
2279 /* ----------------------- */ | |
2280 /* Frequency list neigbor cell measurement process in */ | |
2281 /* Packet Transfer mode is stopped by this message. */ | |
2282 /* */ | |
2283 /*-------------------------------------------------------*/ | |
2284 void l1pa_tcr_meas_process(xSignalHeaderRec *msg) | |
2285 { | |
2286 enum states | |
2287 { | |
2288 RESET = 0, | |
2289 WAIT_INIT = 1, | |
2290 WAIT_RESULT = 3 | |
2291 | |
2292 }; | |
2293 | |
2294 UWORD8 *state = &l1pa.state[TCR_MEAS]; | |
2295 UWORD32 SignalCode = msg->SignalCode; | |
2296 UWORD8 i; | |
2297 UWORD8 list_size; | |
2298 T_CRES_LIST_PARAM *free_list; | |
2299 | |
2300 BOOL end_process = 0; | |
2301 while(!end_process) | |
2302 { | |
2303 switch(*state) | |
2304 { | |
2305 case RESET: | |
2306 { | |
2307 // step in state machine. | |
2308 *state = WAIT_INIT; | |
2309 | |
2310 // Reset TCR_MEAS process. | |
2311 l1pa_l1ps_com.l1ps_en_meas &= P_TCRMS_MEAS_MASK; // Disable Neighbour Measurement task. | |
2312 } | |
2313 break; | |
2314 | |
2315 case WAIT_INIT: | |
2316 { | |
2317 if(SignalCode == L1P_TRANSFER_DONE) | |
2318 // We enter in Packet Transfer mode. | |
2319 //--------------------------------- | |
2320 { | |
2321 #if 0 /* FreeCalypso: the following code is not present in TCS211 */ | |
2322 #if (CODE_VERSION != SIMULATION) | |
2323 //no meas when entering in Transfer if no BA list initialized | |
2324 //stay in this state and wait for a MPHP_TCR_MEAS_REQ from L3 | |
2325 if((l1pa_l1ps_com.cres_freq_list.alist->nb_carrier == 0) && | |
2326 (l1pa_l1ps_com.tcr_freq_list.new_list_present == FALSE) && (l1a_l1s_com.ba_list.nbr_carrier == 0)) | |
2327 return; | |
2328 #endif | |
2329 #endif | |
2330 // Set parameter synchro semaphore for P_TCRMS_MEAS task. | |
2331 l1pa_l1ps_com.meas_param |= P_TCRMS_MEAS; | |
2332 | |
2333 // Reset Neighbour Cell measurement parameters. | |
2334 l1pa_l1ps_com.tcr_freq_list.tcr_next_to_ctrl = 0; | |
2335 l1pa_l1ps_com.tcr_freq_list.tcr_next_to_read = 0; | |
2336 l1pa_l1ps_com.tcr_freq_list.last_stored_tcr_to_read = 0; | |
2337 l1pa_l1ps_com.tcr_freq_list.first_pass_flag = TRUE; | |
2338 | |
2339 // Initialize counter used to report measurements | |
2340 l1pa_l1ps_com.tcr_freq_list.cres_meas_report = 0; | |
2341 | |
2342 | |
2343 // If no Packet Idle phase has been done and no BA(GPRS) list has been | |
2344 // downloaded, init BA(GPRS) list with BA list used in CS Idle mode. | |
2345 if((l1pa_l1ps_com.cres_freq_list.alist->nb_carrier == 0) && | |
2346 (l1pa_l1ps_com.tcr_freq_list.new_list_present == FALSE)) | |
2347 { | |
2348 // Get Ptr to the free Neighbour meas list. | |
2349 // The number of carriers in the list and the list | |
2350 // identification are initialized. | |
2351 free_list = l1pa_get_free_cres_list_set(); | |
2352 | |
2353 // Download new list within T_CRES_LIST_PARAM structure. | |
2354 free_list->nb_carrier = l1a_l1s_com.ba_list.nbr_carrier; | |
2355 | |
2356 for(i = 0; i < free_list->nb_carrier; i++) | |
2357 { | |
2358 free_list->freq_list[i] = l1a_l1s_com.ba_list.A[i].radio_freq; | |
2359 } | |
2360 | |
2361 free_list->list_id = l1a_l1s_com.ba_list.ba_id; | |
2362 | |
2363 // Set "flist" with Circuit Swithed BA frequency list parameters | |
2364 l1pa_l1ps_com.cres_freq_list.alist = free_list; | |
2365 } | |
2366 | |
2367 // Reset flags. | |
2368 l1pa_l1ps_com.tcr_freq_list.ms_ctrl = 0; | |
2369 l1pa_l1ps_com.tcr_freq_list.ms_ctrl_d = 0; | |
2370 l1pa_l1ps_com.tcr_freq_list.ms_ctrl_dd = 0; | |
2371 | |
2372 // Reset measures made on beacon frequency. | |
2373 l1pa_l1ps_com.tcr_freq_list.beacon_meas = 0; | |
2374 | |
2375 // Enable Packet Transfer Neighbour Measurement task. | |
2376 l1pa.l1pa_en_meas[TCR_MEAS] |= P_TCRMS_MEAS; | |
2377 | |
2378 // step in state machine. | |
2379 *state = WAIT_RESULT; | |
2380 } | |
2381 else | |
2382 if(SignalCode == MPHC_RXLEV_PERIODIC_REQ) | |
2383 // We receive the BA list to be monitored in Idle mode | |
2384 //---------------------------------------------------- | |
2385 { | |
2386 // When enter in Transfer the Idle list must be used | |
2387 // =>reset the packet Transfert list in order to use the Idle list | |
2388 l1pa_l1ps_com.cres_freq_list.alist->nb_carrier = 0; | |
2389 l1pa_l1ps_com.tcr_freq_list.new_list_present = FALSE; | |
2390 } | |
2391 #if 0 /* FreeCalypso: the following code is not present in TCS211 */ | |
2392 else | |
2393 if(SignalCode == MPHP_TCR_MEAS_REQ) | |
2394 // Restart Packet Transfer measurement in TBF after | |
2395 // MPHP_TCR_MEAS_STOP_REQ | |
2396 // ### Check reason why was missing (s921_bis note)... | |
2397 //---------------------------------------------------- | |
2398 { | |
2399 | |
2400 // Set parameter synchro semaphore for P_TCRMS_MEAS task. | |
2401 l1pa_l1ps_com.meas_param |= P_TCRMS_MEAS; | |
2402 | |
2403 free_list = l1pa_get_free_cres_list_set(); | |
2404 | |
2405 | |
2406 // Download new list within T_CRES_LIST_PARAM structure. | |
2407 free_list->nb_carrier = ((T_MPHP_TCR_MEAS_REQ *)(msg->SigP))->nb_carrier; | |
2408 | |
2409 for(i = 0; i < free_list->nb_carrier; i++) | |
2410 { | |
2411 free_list->freq_list[i] = ((T_MPHP_TCR_MEAS_REQ *)(msg->SigP))->radio_freq_no[i]; | |
2412 } | |
2413 | |
2414 free_list->list_id = ((T_MPHP_TCR_MEAS_REQ *)(msg->SigP))->list_id; | |
2415 | |
2416 // Set "flist" with Circuit Swithed BA frequency list parameters | |
2417 l1pa_l1ps_com.cres_freq_list.alist = free_list; | |
2418 | |
2419 // Reset Neighbour Cell measurement parameters. | |
2420 l1pa_l1ps_com.tcr_freq_list.tcr_next_to_ctrl = 0; | |
2421 l1pa_l1ps_com.tcr_freq_list.tcr_next_to_read = 0; | |
2422 l1pa_l1ps_com.tcr_freq_list.last_stored_tcr_to_read = 0; | |
2423 l1pa_l1ps_com.tcr_freq_list.first_pass_flag = TRUE; | |
2424 | |
2425 // Initialize counter used to report measurements | |
2426 l1pa_l1ps_com.tcr_freq_list.cres_meas_report = 0; | |
2427 | |
2428 // Reset flags. | |
2429 l1pa_l1ps_com.tcr_freq_list.ms_ctrl = 0; | |
2430 l1pa_l1ps_com.tcr_freq_list.ms_ctrl_d = 0; | |
2431 l1pa_l1ps_com.tcr_freq_list.ms_ctrl_dd = 0; | |
2432 | |
2433 // Reset measures made on beacon frequency. | |
2434 l1pa_l1ps_com.tcr_freq_list.beacon_meas = 0; | |
2435 | |
2436 // Enable Packet Transfer Neighbour Measurement task. | |
2437 l1pa.l1pa_en_meas[TCR_MEAS] |= P_TCRMS_MEAS; | |
2438 | |
2439 // step in state machine. | |
2440 *state = WAIT_RESULT; | |
2441 } | |
2442 #endif | |
2443 | |
2444 // End of process. | |
2445 end_process = 1; | |
2446 } | |
2447 break; | |
2448 | |
2449 case WAIT_RESULT: | |
2450 { | |
2451 switch(SignalCode) | |
2452 { | |
2453 case L1P_TCR_MEAS_DONE: | |
2454 // One reporting period has been completed. A set of measures is forward to L3. | |
2455 //----------------------------------------------------------------------------- | |
2456 { | |
2457 // Forward result message to L3. | |
2458 l1a_send_result(MPHP_TCR_MEAS_IND, msg, GRRM1_QUEUE); | |
2459 | |
2460 // End of process. | |
2461 end_process = 1; | |
2462 } | |
2463 break; | |
2464 | |
2465 case MPHP_TCR_MEAS_REQ: | |
2466 // Update of the parameters are postponed until end of the reporting period. | |
2467 // Parameters are saved in a double buffer. | |
2468 { | |
2469 // Reset present flag to avoid to mix 2 updates in case of | |
2470 // an update already pending within "l1pa_l1ps_com.cres_freq_list.flist". | |
2471 l1pa_l1ps_com.tcr_freq_list.new_list_present = FALSE; | |
2472 | |
2473 // Get Ptr to the free Neighbour meas list. | |
2474 // The number of carriers in the list and the list | |
2475 // identification are initialized. | |
2476 free_list = l1pa_get_free_cres_list_set(); | |
2477 | |
2478 | |
2479 // Download new list within T_CRES_LIST_PARAM structure. | |
2480 list_size = ((T_MPHP_TCR_MEAS_REQ *)(msg->SigP))->nb_carrier; | |
2481 free_list->nb_carrier = list_size; | |
2482 | |
2483 for(i = 0; i < list_size; i++) | |
2484 { | |
2485 free_list->freq_list[i] = ((T_MPHP_TCR_MEAS_REQ *)(msg->SigP))->radio_freq_no[i]; | |
2486 } | |
2487 | |
2488 free_list->list_id = ((T_MPHP_TCR_MEAS_REQ *)(msg->SigP))->list_id; | |
2489 | |
2490 // Set "flist" with new set of frequency list parameter | |
2491 l1pa_l1ps_com.cres_freq_list.flist = free_list; | |
2492 | |
2493 // Set present flag only when the list has been downloaded. | |
2494 l1pa_l1ps_com.tcr_freq_list.new_list_present = TRUE; | |
2495 | |
2496 // End of process. | |
2497 end_process = 1; | |
2498 } | |
2499 break; | |
2500 | |
2501 case L1P_TBF_RELEASED: | |
2502 { | |
2503 // Test if all TBF have been released | |
2504 // Then stop Neighbour Measurement process | |
2505 if(((T_L1P_TBF_RELEASED *)(msg->SigP))->released_all) | |
2506 { | |
2507 // This process must be reset. | |
2508 *state = RESET; | |
2509 } | |
2510 else | |
2511 { | |
2512 return; | |
2513 } | |
2514 } | |
2515 break; | |
2516 | |
2517 case MPHP_TCR_MEAS_STOP_REQ: | |
2518 // Note: A TBF stop do not imply a stop of the Neighbour Measurement process. | |
2519 // L3 has to send a MPHP_TCR_MEAS_STOP message to stop the measurement process. | |
2520 { | |
2521 // send confirmation message | |
2522 l1a_send_confirmation(MPHP_TCR_MEAS_STOP_CON,GRRM1_QUEUE); | |
2523 | |
2524 // This process must be reset. | |
2525 *state = RESET; | |
2526 } | |
2527 break; | |
2528 | |
2529 default: | |
2530 // No action in this machine for other messages. | |
2531 // Note: No action is performed on receipt of a L1P_TRANSFER_DONE | |
2532 // message. However a SYNCHRO task is programmed, which implies | |
2533 // a reset of measures related to the Serving Cell (cf. L1S). | |
2534 //-------------------------------------------------------------- | |
2535 { | |
2536 return; | |
2537 } | |
2538 } // end of switch(SignalCode) | |
2539 } | |
2540 break; | |
2541 } // end of "switch". | |
2542 } // end of "while" | |
2543 } // end of procedure. | |
2544 | |
2545 /*-------------------------------------------------------*/ | |
2546 /* l1pa_idle_interference_meas_process() */ | |
2547 /*-------------------------------------------------------*/ | |
2548 /* Description : */ | |
2549 /* */ | |
2550 /* Starting messages: MPHP_INT_MEAS_REQ */ | |
2551 /* */ | |
2552 /* This message requests signal strength measurements */ | |
2553 /* on several channels of a specific carrier. */ | |
2554 /* Measurements must be done on one search frame and one */ | |
2555 /* PTCCH frame. */ | |
2556 /* */ | |
2557 /* Result messages (input): L1PS_ITMEAS_IND */ | |
2558 /* */ | |
2559 /* This message is reported to L1A when signal strength */ | |
2560 /* has been measured on one idle frame (PTCCH or search) */ | |
2561 /* */ | |
2562 /* Result messages (output): MPHP_INT_MEAS_IND */ | |
2563 /* */ | |
2564 /* This message is reported to L3 when measurements have */ | |
2565 /* been done on two contiguous idle frames */ | |
2566 /* */ | |
2567 /* Reset message (input): MPHP_INT_MEAS_STOP_REQ */ | |
2568 /* */ | |
2569 /* Interference measurement processing is stopped by */ | |
2570 /* this message */ | |
2571 /*-------------------------------------------------------*/ | |
2572 void l1pa_idle_interference_meas_process(xSignalHeaderRec *msg) | |
2573 { | |
2574 enum states | |
2575 { | |
2576 RESET = 0, | |
2577 WAIT_INIT = 1, | |
2578 WAIT_1ST_RESULT = 2, | |
2579 WAIT_2ND_RESULT = 3 | |
2580 }; | |
2581 | |
2582 static T_L1A_INT_MEAS_PARAM int_meas_param; | |
2583 UWORD8 *state = &l1pa.state[PI_INT_MEAS]; | |
2584 UWORD32 SignalCode = msg->SignalCode; | |
2585 | |
2586 BOOL end_process = 0; | |
2587 while(!end_process) | |
2588 { | |
2589 switch(*state) | |
2590 { | |
2591 case RESET: | |
2592 { | |
2593 // Step in state machine. | |
2594 *state = WAIT_INIT; | |
2595 | |
2596 // Reset ITMEAS process. | |
2597 l1a_l1s_com.l1s_en_task[ITMEAS] = TASK_DISABLED; // Clear ITMEAS task enable flag. | |
2598 } | |
2599 break; | |
2600 | |
2601 case WAIT_INIT: | |
2602 { | |
2603 // Interference measurement request | |
2604 //--------------------------------- | |
2605 if (SignalCode == MPHP_INT_MEAS_REQ) | |
2606 { | |
2607 UWORD8 bitmap,i; | |
2608 | |
2609 // Set semaphore | |
2610 l1a_l1s_com.task_param[ITMEAS] = SEMAPHORE_SET; | |
2611 | |
2612 // Download message content | |
2613 l1pa_l1ps_com.itmeas.packet_intm_freq_param = ((T_MPHP_INT_MEAS_REQ *)(msg->SigP))->packet_intm_freq_param; | |
2614 l1pa_l1ps_com.itmeas.multislot_class = ((T_MPHP_INT_MEAS_REQ *)(msg->SigP))->multislot_class; | |
2615 int_meas_param.id = ((T_MPHP_INT_MEAS_REQ *)(msg->SigP))->carrier_id; | |
2616 | |
2617 // Processing of the 2 possible measurement bitmaps | |
2618 //------------------------------------------------- | |
2619 | |
2620 // 1- Without Rx on the frame before | |
2621 | |
2622 l1pa_l1ps_com.itmeas.idle_tn_no_rx = ((T_MPHP_INT_MEAS_REQ *)(msg->SigP))->tn; | |
2623 | |
2624 // Trb respect after measurements | |
2625 // We consider that the timeslot on which the Layer 1 is synchronized is | |
2626 // always allocated on the frame after the idle frame. | |
2627 // For the Trb multi-slot class parameter respect, we must clear the bits at | |
2628 // the right of the interference measurement bitmap | |
2629 l1pa_l1ps_com.itmeas.idle_tn_no_rx &= (UWORD8) | |
2630 ~( 0xFF | |
2631 >> ( 8 + l1a_l1s_com.dl_tn | |
2632 - MS_CLASS[l1pa_l1ps_com.itmeas.multislot_class].trb)); | |
2633 | |
2634 // 2- With a Rx programmed on the frame before | |
2635 // Note: This Rx is always on the dl_tn | |
2636 | |
2637 l1pa_l1ps_com.itmeas.idle_tn_rx = l1pa_l1ps_com.itmeas.idle_tn_no_rx; | |
2638 | |
2639 // Trb respect before measurements | |
2640 // The timeslot on which the Layer 1 is synchronized is allocated on the frame | |
2641 // before the idle frame. | |
2642 // For the Trb multi-slot class parameter respect, we must clear the bits at | |
2643 // the left of the interference measurement bitmap | |
2644 bitmap = 0x80; | |
2645 | |
2646 i = 8 - l1a_l1s_com.dl_tn - MS_CLASS[l1pa_l1ps_com.itmeas.multislot_class].trb; | |
2647 if (i > 8) | |
2648 bitmap >>= (-i); | |
2649 else | |
2650 bitmap <<= i; | |
2651 | |
2652 for (i = 1; i<= MS_CLASS[l1pa_l1ps_com.itmeas.multislot_class].trb; i++) | |
2653 { | |
2654 l1pa_l1ps_com.itmeas.idle_tn_rx &= (UWORD8) ~bitmap; | |
2655 bitmap <<= 1; | |
2656 } | |
2657 | |
2658 // Initialize parameters | |
2659 l1pa_l1ps_com.itmeas.position = ANY_IDLE_FRAME; // First measurement on any idle frame | |
2660 | |
2661 // Enable synchronous task | |
2662 l1a_l1s_com.l1s_en_task[ITMEAS] = TASK_ENABLED; | |
2663 | |
2664 // Step in state machine | |
2665 *state = WAIT_1ST_RESULT; | |
2666 | |
2667 // End of process | |
2668 end_process = 1; | |
2669 } | |
2670 | |
2671 // No action in this machine for other messages. | |
2672 else | |
2673 { | |
2674 // End of process. | |
2675 end_process = 1; | |
2676 } | |
2677 } | |
2678 break; | |
2679 | |
2680 case WAIT_1ST_RESULT: | |
2681 { | |
2682 // Reporting of 1st measurement session | |
2683 //------------------------------------- | |
2684 if (SignalCode == L1P_ITMEAS_IND) | |
2685 { | |
2686 UWORD8 i; | |
2687 | |
2688 // Set semaphore | |
2689 l1a_l1s_com.task_param[ITMEAS] = SEMAPHORE_SET; | |
2690 | |
2691 // Save interference measurements | |
2692 for(i=0; i<8; i++) | |
2693 int_meas_param.rxlev[i] = ((T_L1P_ITMEAS_IND *)(msg->SigP))->rxlev[i]; | |
2694 | |
2695 // Save bitmap | |
2696 int_meas_param.meas_bitmap = ((T_L1P_ITMEAS_IND *)(msg->SigP))->meas_bitmap; | |
2697 | |
2698 // Save reported fn | |
2699 int_meas_param.fn = ((T_L1P_ITMEAS_IND *)(msg->SigP))->fn; | |
2700 | |
2701 // Position = complement of reported position | |
2702 if (((T_L1P_ITMEAS_IND *)(msg->SigP))->position == PTCCH_FRAME) | |
2703 l1pa_l1ps_com.itmeas.position = SEARCH_FRAME; | |
2704 else | |
2705 l1pa_l1ps_com.itmeas.position = PTCCH_FRAME; | |
2706 | |
2707 // Enable ITMEAS | |
2708 l1a_l1s_com.l1s_en_task[ITMEAS] = TASK_ENABLED; | |
2709 | |
2710 // Step in state machine | |
2711 *state = WAIT_2ND_RESULT; | |
2712 | |
2713 // End of process | |
2714 return; | |
2715 } | |
2716 | |
2717 else | |
2718 if (SignalCode == MPHP_INT_MEAS_STOP_REQ) | |
2719 { | |
2720 // Send confirmation | |
2721 l1a_send_confirmation(MPHP_INT_MEAS_STOP_CON,GRRM1_QUEUE); | |
2722 | |
2723 // Reset process | |
2724 *state = RESET; | |
2725 } | |
2726 | |
2727 // No action in this machine for other messages. | |
2728 else | |
2729 { | |
2730 // End of process | |
2731 return; | |
2732 } | |
2733 } | |
2734 break; | |
2735 | |
2736 case WAIT_2ND_RESULT: | |
2737 { | |
2738 // Reporting subsequent measurement session | |
2739 //----------------------------------------- | |
2740 if (SignalCode == L1P_ITMEAS_IND) | |
2741 { | |
2742 // At least one measurement session has already been reported | |
2743 //----------------------------------------------------------- | |
2744 UWORD32 reported_fn; | |
2745 | |
2746 // Check fn | |
2747 // The two measurement sessions must be done in two contiguous idle frames | |
2748 | |
2749 // Modulo | |
2750 if (((T_L1P_ITMEAS_IND *)(msg->SigP))->fn < int_meas_param.fn) | |
2751 { | |
2752 reported_fn = ((T_L1P_ITMEAS_IND *)(msg->SigP))->fn + MAX_FN; | |
2753 } | |
2754 else | |
2755 { | |
2756 reported_fn = ((T_L1P_ITMEAS_IND *)(msg->SigP))->fn; | |
2757 } | |
2758 | |
2759 // The two last measurement sessions are enough close | |
2760 if ((reported_fn - int_meas_param.fn) == 13) | |
2761 { | |
2762 // Build and send result msg to L3. | |
2763 l1pa_send_int_meas_report(MPHP_INT_MEAS_IND, | |
2764 ((T_L1P_ITMEAS_IND *)(msg->SigP)), | |
2765 &int_meas_param); | |
2766 | |
2767 // Only one measurement session per request | |
2768 *state = RESET; | |
2769 } | |
2770 | |
2771 // The two last measurement sessions aren't enough close | |
2772 else | |
2773 { | |
2774 // 1st measurement result is no more valid, second result | |
2775 // must replace it: this is achieved by WAIT_1ST_RESULT state!!! | |
2776 | |
2777 // Step in state machine | |
2778 *state = WAIT_1ST_RESULT; | |
2779 } | |
2780 } | |
2781 | |
2782 else | |
2783 if (SignalCode == MPHP_INT_MEAS_STOP_REQ) | |
2784 { | |
2785 // Send confirmation | |
2786 l1a_send_confirmation(MPHP_INT_MEAS_STOP_CON,GRRM1_QUEUE); | |
2787 | |
2788 // Reset process | |
2789 *state = RESET; | |
2790 } | |
2791 | |
2792 // No action in this machine for other messages. | |
2793 else | |
2794 { | |
2795 // End of process | |
2796 return; | |
2797 } | |
2798 } | |
2799 break; | |
2800 | |
2801 } // End of "switch" | |
2802 } // End of "while" | |
2803 } // End of "procedure" | |
2804 | |
2805 /*-------------------------------------------------------*/ | |
2806 /* l1pa_transfer_interference_meas_process() */ | |
2807 /*-------------------------------------------------------*/ | |
2808 /* Description : */ | |
2809 /* */ | |
2810 /* Starting messages: L1P_TRANFSER_DONE */ | |
2811 /* */ | |
2812 /* Interference measurement processing starts each time */ | |
2813 /* a new starting time occurs if the interference */ | |
2814 /* measurements are enabled */ | |
2815 /* Measurements must be done on one search frame and one */ | |
2816 /* PTCCH frame. */ | |
2817 /* */ | |
2818 /* Result messages (input): L1PS_ITMEAS_IND */ | |
2819 /* */ | |
2820 /* This message is reported to L1A when signal strength */ | |
2821 /* has been measured on one idle frame (PTCCH or search) */ | |
2822 /* */ | |
2823 /* Result messages (output): MPHP_TINT_MEAS_IND */ | |
2824 /* */ | |
2825 /* This message is reported to L3 when measurements have */ | |
2826 /* been done on two idle frames as close as possible */ | |
2827 /* */ | |
2828 /* Reset message (input): L1P_TBF_RELEASED */ | |
2829 /* */ | |
2830 /* Interference measurement processing is stopped when */ | |
2831 /* all TBF are released */ | |
2832 /*-------------------------------------------------------*/ | |
2833 void l1pa_transfer_interference_meas_process(xSignalHeaderRec *msg) | |
2834 { | |
2835 /* Bitmaps used for the processing of full_allocation */ | |
2836 /*----------------------------------------------------*/ | |
2837 const UWORD8 FULL_ALLOCATION[9]= | |
2838 { | |
2839 0x00, | |
2840 0x80, | |
2841 0xc0, | |
2842 0xe0, | |
2843 0xf0, | |
2844 0xf8, | |
2845 0xfc, | |
2846 0xfe, | |
2847 0xff | |
2848 }; | |
2849 | |
2850 enum states | |
2851 { | |
2852 RESET = 0, | |
2853 WAIT_INIT = 1, | |
2854 CONFIG = 2, | |
2855 WAIT_1ST_RESULT = 3, | |
2856 WAIT_2ND_RESULT = 4 | |
2857 }; | |
2858 | |
2859 static T_L1A_INT_MEAS_PARAM int_meas_param; | |
2860 UWORD8 *state = &l1pa.state[PT_INT_MEAS]; | |
2861 UWORD32 SignalCode = msg->SignalCode; | |
2862 | |
2863 BOOL end_process = 0; | |
2864 while(!end_process) | |
2865 { | |
2866 switch(*state) | |
2867 { | |
2868 case RESET: | |
2869 { | |
2870 // Step in state machine. | |
2871 *state = WAIT_INIT; | |
2872 | |
2873 // Reset ITMEAS process. | |
2874 l1a_l1s_com.l1s_en_task[ITMEAS] = TASK_DISABLED; // Clear ITMEAS task enable flag. | |
2875 } | |
2876 break; | |
2877 | |
2878 case WAIT_INIT: | |
2879 { | |
2880 // New channel assignment | |
2881 //----------------------- | |
2882 if ((SignalCode == L1P_TRANSFER_DONE) || (SignalCode == L1P_REPEAT_ALLOC_DONE) || | |
2883 (SignalCode == L1P_ALLOC_EXHAUST_DONE)) | |
2884 { | |
2885 *state = CONFIG; | |
2886 } | |
2887 | |
2888 // No action in this machine for other messages. | |
2889 else | |
2890 { | |
2891 // End of process. | |
2892 return; | |
2893 } | |
2894 } | |
2895 break; | |
2896 | |
2897 case CONFIG: | |
2898 { | |
2899 // Rise transfert parameter semaphore to prevent L1S to use partial configuration. | |
2900 l1pa_l1ps_com.transfer.semaphore = TRUE; | |
2901 | |
2902 // If the interference measurements are disabled | |
2903 if (l1pa_l1ps_com.transfer.aset->interf_meas_enable == FALSE) | |
2904 { | |
2905 *state = WAIT_INIT; | |
2906 } | |
2907 else | |
2908 { | |
2909 // Set semaphore | |
2910 l1a_l1s_com.task_param[ITMEAS] = SEMAPHORE_SET; | |
2911 | |
2912 // Initialize parameters | |
2913 l1pa_l1ps_com.itmeas.position = ANY_IDLE_FRAME; // First measurement on any idle frame | |
2914 | |
2915 // Save assignment ID for the interference measurements reporting message | |
2916 int_meas_param.id = l1pa_l1ps_com.transfer.aset->assignment_id; | |
2917 | |
2918 // Processing of the measurement bitmap | |
2919 l1pa_l1ps_com.itmeas.meas_bitmap = (UWORD8) | |
2920 FULL_ALLOCATION[MS_CLASS[l1pa_l1ps_com.transfer.aset->multislot_class].rx] >> | |
2921 l1a_l1s_com.dl_tn; | |
2922 | |
2923 // Enable synchronous task | |
2924 l1a_l1s_com.l1s_en_task[ITMEAS] = TASK_ENABLED; | |
2925 | |
2926 // Step in state machine | |
2927 *state = WAIT_1ST_RESULT; | |
2928 } | |
2929 | |
2930 // Clear transfer parameter semaphore to let L1S use the new parameters. | |
2931 l1pa_l1ps_com.transfer.semaphore = FALSE; | |
2932 | |
2933 // End of process. | |
2934 end_process = 1; | |
2935 } | |
2936 break; | |
2937 | |
2938 case WAIT_1ST_RESULT: | |
2939 { | |
2940 // Reporting of 1st measurement session | |
2941 //------------------------------------- | |
2942 if (SignalCode == L1P_ITMEAS_IND) | |
2943 { | |
2944 UWORD8 i; | |
2945 | |
2946 // Set semaphore | |
2947 l1a_l1s_com.task_param[ITMEAS] = SEMAPHORE_SET; | |
2948 | |
2949 // Save interference measurements | |
2950 for(i=0; i<8; i++) | |
2951 int_meas_param.rxlev[i] = ((T_L1P_ITMEAS_IND *)(msg->SigP))->rxlev[i]; | |
2952 | |
2953 // Save bitmap | |
2954 int_meas_param.meas_bitmap = ((T_L1P_ITMEAS_IND *)(msg->SigP))->meas_bitmap; | |
2955 | |
2956 // Save reported fn | |
2957 int_meas_param.fn = ((T_L1P_ITMEAS_IND *)(msg->SigP))->fn; | |
2958 | |
2959 // Position = complement of reported position | |
2960 if (((T_L1P_ITMEAS_IND *)(msg->SigP))->position == PTCCH_FRAME) | |
2961 l1pa_l1ps_com.itmeas.position = SEARCH_FRAME; | |
2962 else | |
2963 l1pa_l1ps_com.itmeas.position = PTCCH_FRAME; | |
2964 | |
2965 // Enable ITMEAS | |
2966 l1a_l1s_com.l1s_en_task[ITMEAS] = TASK_ENABLED; | |
2967 | |
2968 // Step in state machine | |
2969 *state = WAIT_2ND_RESULT; | |
2970 | |
2971 // End of process | |
2972 return; | |
2973 } | |
2974 | |
2975 else | |
2976 if (SignalCode == L1P_TRANSFER_DONE) | |
2977 // The starting time of a new TBF occurs | |
2978 { | |
2979 // Reset process | |
2980 *state = RESET; | |
2981 } | |
2982 | |
2983 else | |
2984 if (SignalCode == L1P_TBF_RELEASED) | |
2985 // A TBF has been released | |
2986 { | |
2987 // No remaining TBF | |
2988 if(((T_L1P_TBF_RELEASED *)(msg->SigP))->released_all) | |
2989 { | |
2990 // Reset process | |
2991 *state = RESET; | |
2992 } | |
2993 else | |
2994 { | |
2995 // Enable a new measurement session | |
2996 *state = CONFIG; | |
2997 } | |
2998 } | |
2999 | |
3000 else | |
3001 if (SignalCode == L1P_PDCH_RELEASED) | |
3002 // PDCH have been released | |
3003 { | |
3004 // Enable a new measurement session | |
3005 *state = CONFIG; | |
3006 } | |
3007 | |
3008 // No action in this machine for other messages. | |
3009 else | |
3010 { | |
3011 // End of process | |
3012 return; | |
3013 } | |
3014 } | |
3015 break; | |
3016 | |
3017 case WAIT_2ND_RESULT: | |
3018 { | |
3019 // Reporting subsequent measurement session | |
3020 //----------------------------------------- | |
3021 if (SignalCode == L1P_ITMEAS_IND) | |
3022 { | |
3023 // At least one measurement session has already been reported | |
3024 //----------------------------------------------------------- | |
3025 UWORD32 reported_fn; | |
3026 | |
3027 // Check fn | |
3028 // The two measurement sessions must be done in two contiguous idle frames | |
3029 | |
3030 // Modulo | |
3031 if (((T_L1P_ITMEAS_IND *)(msg->SigP))->fn < int_meas_param.fn) | |
3032 { | |
3033 reported_fn = ((T_L1P_ITMEAS_IND *)(msg->SigP))->fn + MAX_FN; | |
3034 } | |
3035 else | |
3036 { | |
3037 reported_fn = ((T_L1P_ITMEAS_IND *)(msg->SigP))->fn; | |
3038 } | |
3039 | |
3040 // The two last measurement sessions are enough close | |
3041 if ((reported_fn - int_meas_param.fn) <= 104) | |
3042 { | |
3043 // Build and send result msg to L3. | |
3044 l1pa_send_int_meas_report(MPHP_TINT_MEAS_IND, | |
3045 ((T_L1P_ITMEAS_IND *)(msg->SigP)), | |
3046 &int_meas_param); | |
3047 | |
3048 // Enable a new measurement session | |
3049 *state = CONFIG; | |
3050 } | |
3051 | |
3052 // The two last measurement sessions aren't enough close | |
3053 else | |
3054 { | |
3055 // 1st measurement result is no more valid, second result | |
3056 // must replace it: this is achieved by WAIT_1ST_RESULT state!!! | |
3057 | |
3058 // Step in state machine | |
3059 *state = WAIT_1ST_RESULT; | |
3060 } | |
3061 } | |
3062 | |
3063 else | |
3064 | |
3065 // New channel assignment | |
3066 //----------------------- | |
3067 if ((SignalCode == L1P_TRANSFER_DONE) || (SignalCode == L1P_REPEAT_ALLOC_DONE) || | |
3068 (SignalCode == L1P_ALLOC_EXHAUST_DONE)) | |
3069 { | |
3070 // Reset process | |
3071 *state = RESET; | |
3072 } | |
3073 | |
3074 else | |
3075 if (SignalCode == L1P_TBF_RELEASED) | |
3076 // A TBF has been released | |
3077 { | |
3078 // No remaining TBF | |
3079 if(((T_L1P_TBF_RELEASED *)(msg->SigP))->released_all) | |
3080 { | |
3081 // Reset process | |
3082 *state = RESET; | |
3083 } | |
3084 else | |
3085 { | |
3086 // Enable a new measurement session | |
3087 *state = CONFIG; | |
3088 } | |
3089 } | |
3090 | |
3091 else | |
3092 if (SignalCode == L1P_PDCH_RELEASED) | |
3093 // PDCH have been released | |
3094 { | |
3095 // Enable a new measurement session | |
3096 *state = CONFIG; | |
3097 } | |
3098 | |
3099 // No action in this machine for other messages. | |
3100 else | |
3101 { | |
3102 // End of process | |
3103 return; | |
3104 } | |
3105 } | |
3106 break; | |
3107 | |
3108 } // End of "switch" | |
3109 } // End of "while" | |
3110 } // End of "procedure" | |
3111 //#pragma DUPLICATE_FOR_INTERNAL_RAM_START | |
3112 #endif | |
3113 //#pragma DUPLICATE_FOR_INTERNAL_RAM_END |