comparison L1/dyn_dwl_cfile/l1_dyn_dwl_async.c @ 0:75a11d740a02

initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 09 Jun 2016 00:02:41 +0000
parents
children dfc7b0bc468a
comparison
equal deleted inserted replaced
-1:000000000000 0:75a11d740a02
1 /************* Revision Controle System Header *************
2 * GSM Layer 1 software
3 * L1_DYN_DWL_ASYNC.C
4 *
5 * Filename l1_dyn_dwl_async.c
6 * Copyright 2004 (C) Texas Instruments
7 *
8 ************* Revision Controle System Header *************/
9 #include <stdio.h>
10 #include <string.h>
11 #include "config.h"
12 #include "l1_confg.h"
13 #include "sys_types.h"
14 #include "../../riviera/rv/rv_general.h"
15 #include "../../nucleus/nucleus.h"
16 #include "l1_types.h"
17 #include "../../gpf/inc/cust_os.h"
18 #include "l1audio_signa.h"
19 #include "l1audio_const.h"
20 #include "l1audio_cust.h"
21 #include "l1audio_defty.h"
22 #include "l1_const.h"
23 #include "l1tm_defty.h"
24 #if (L1_GTT == 1)
25 #include "l1gtt_const.h"
26 #include "l1gtt_defty.h"
27 #endif
28 #if (L1_DYN_DSP_DWNLD==1)
29 #include "l1_dyn_dwl_defty.h"
30 #include "l1_dyn_dwl_msgty.h"
31 #include "l1_dyn_dwl_const.h"
32 #include "l1_dyn_dwl_signa.h"
33 #include "l1_dyn_dwl_error.h"
34 #include "l1_dyn_dwl_proto.h"
35 #endif
36 #if (L1_MP3 == 1)
37 #include "l1mp3_defty.h"
38 #endif //L1_MP3
39 #if (L1_MIDI == 1)
40 #include "l1midi_defty.h"
41 #endif
42 #if (L1_AAC == 1)
43 #include "l1aac_defty.h"
44 #endif //L1_AAC
45
46 #include "l1_defty.h"
47 #include "l1_varex.h"
48 #include "l1_trace.h"
49 /* #include "sys_dma.h" */
50
51
52 #if (L1_DYN_DSP_DWNLD == 1)
53 #if(CODE_VERSION == SIMULATION)
54 extern VOID trace_fct_simu_dyn_dwnld(CHAR *fct_name);
55 #endif // CODE_VERSION == SIMULATION
56
57
58
59 extern UWORD32 dyn_dwnld_address_vect[];
60 extern const UWORD8 *dyn_dwnld_copy_MCU_vect[];
61 extern UWORD16 dyn_dwnld_crc_vect[];
62 extern UWORD16 size_vect[];
63
64 /*---------------------------------------------------------------------------------------------------------*/
65 /* l1_patch_id2string */
66 /*---------------------------------------------------------------------------------------------------------*/
67 /* */
68 /* Parameters : patch identificator "patch_id", string vector "vector" which identifies the patch */
69 /* */
70 /* Return : Fills the string vector containing the patch id by reference */
71 /* */
72 /* */
73 /* Description : Links the patch ID number to its string value */
74 /* */
75 /* */
76 /*---------------------------------------------------------------------------------------------------------*/
77
78 #if 0
79 void l1_patch_id2string(UWORD16 patch_id, char* vect)
80 {
81
82 switch(patch_id)
83 {
84
85 #if ((CODE_VERSION == SIMULATION) || (((CHIPSET == 12) || (CHIPSET == 15))))
86 case MP3_PATCH:
87 {
88 vect[0] = 'M';
89 vect[1] = 'P';
90 vect[2] = '3';
91 vect[3] = '\0';
92 }
93 break;
94 #endif
95 case MMS_PATCH:
96 {
97 vect[0] = 'M';
98 vect[1] = 'M';
99 vect[2] = 'S';
100 vect[3] = '\0';
101 }
102 break;
103
104 #if ((CODE_VERSION == SIMULATION) || (((CHIPSET == 12) || (CHIPSET == 15))))
105 case E2_PATCH:
106 {
107 vect[0] = 'E';
108 vect[1] = '2';
109 vect[2] = ' ';
110 vect[3] = '\0';
111 }
112 break;
113 #endif
114 case TTY_PATCH:
115 {
116 vect[0] = 'T';
117 vect[1] = 'T';
118 vect[2] = 'Y';
119 vect[3] = '\0';
120 }
121 break;
122 case SPEECH_ACOUSTIC_PATCH:
123 {
124 vect[0] = 'A';
125 vect[1] = 'N';
126 vect[2] = 'R';
127 vect[3] = '\0';
128 }
129 break;
130 #if ((CODE_VERSION == SIMULATION) || (CHIPSET == 12) || (CHIPSET == 15))
131 case AAC_PATCH:
132 {
133 vect[0] = 'A';
134 vect[1] = 'A';
135 vect[2] = 'C';
136 vect[3] = '\0';
137 }
138 break;
139 #endif
140 #if ((CODE_VERSION == SIMULATION) || (CHIPSET == 12) || (CHIPSET == 15))
141 case PCM_EXTRACTION_PATCH:
142 {
143 vect[0] = 'P';
144 vect[1] = 'C';
145 vect[2] = 'M';
146 vect[3] = '\0';
147 }
148 break;
149 #endif
150
151 }
152 }
153 #endif
154
155 /*----------------------------------------------------------------------------------------*/
156 /* l1_dynamic_download_manager */
157 /*----------------------------------------------------------------------------------------*/
158 /* */
159 /* Parameters : Signal Code of the message, delay flag */
160 /* */
161 /* Return : True if the primitives triggers a dynamic download and sets all the */
162 /* parameters to perform a dynamic download, false otherwise */
163 /* */
164 /* Description : Implements the dynamic download manager algorithm */
165 /* */
166 /* */
167 /*----------------------------------------------------------------------------------------*/
168
169
170 BOOL l1_dynamic_download_manager(UWORD32 SignalCode, BOOL delay_flag)
171 {
172
173 UWORD16 temp_patch_array[MAX_NUM_OF_PATCH_IDS];
174 UWORD16 temp_num_patch;
175 UWORD16 num_of_patch_id_to_dwnld;
176 UWORD16 num_of_uninstall_elem;
177 UWORD16 i;
178 UWORD16 patch_id_uninstall_vect[MAX_NUM_OF_PATCH_IDS];
179 UWORD16 patch_id;
180 UWORD16 temp_patch_id[MAX_NUM_OF_PATCH_IDS]= {0}; //omaps00090550
181 BOOL return_flag = FALSE;
182
183 // Primitive is processed only if it triggers a dynamic download or there is a delay
184 if(delay_flag == TRUE || l1_does_the_incoming_primitive_trigger_dynamic_dwnld(SignalCode, FALSE) == TRUE)
185 {
186
187 //----------------------------------------------------------------------
188 // Compute which patch ids (passed by reference) and the number of patches to install
189 //----------------------------------------------------------------------
190
191 temp_num_patch= l1_lookup_primitive_patch_matrix(SignalCode,temp_patch_array);
192 i=0;
193 num_of_patch_id_to_dwnld = 0;
194
195 //--------------------------------------------
196 // Check if there is any patch that still must be installed
197 //--------------------------------------------
198
199 while(i < temp_num_patch)
200 {
201 if(l1_is_patch_already_installed(temp_patch_array[i]) == FALSE)
202 {
203 l1a.dyn_dwnld.next_patch_id[num_of_patch_id_to_dwnld++] = temp_patch_array[i];
204 }
205 i++;
206 }
207
208 //--------------------------
209 // Manage patch incompatibilities
210 //--------------------------
211
212 // if there's at least one patch that must be installed
213 if(num_of_patch_id_to_dwnld!=0)
214 {
215 return_flag = TRUE;
216 // Check if already installed patches are compatible or not and retrieve number of patches to uninstall and their ids
217 if(l1_manage_patch_incompatibilty(num_of_patch_id_to_dwnld,&(num_of_uninstall_elem),patch_id_uninstall_vect))
218 {
219 // Set L1A-API HISR variable: no elements to uninstall
220 l1a_apihisr_com.dyn_dwnld.uninstall_parameters.num_of_elem=0;
221
222 // Trace number of elements to uninstall
223 #if ((TRACE_TYPE == 1) || (TRACE_TYPE == 4) || (TRACE_TYPE == 5))
224 if((trace_info.current_config->l1_dyn_trace) & (1<<L1_DYN_TRACE_DYN_DWNLD))
225 {
226 char string[18];
227 sprintf(string,"No UNINSTALL: \r\n");
228 #if(CODE_VERSION == SIMULATION)
229 trace_fct_simu_dyn_dwnld(string);
230 #else
231 rvt_send_trace_cpy((T_RVT_BUFFER)string,trace_info.l1_trace_user_id,strlen(string),RVT_ASCII_FORMAT);
232 #endif // CODE_VERSION == SIMULATION
233 }
234 #endif // (TRACE_TYPE == 1) || (TRACE_TYPE == 4)
235 }
236 else
237 {
238 UWORD16 element,j,index_counter;
239
240 // Set uninstall elements number and their address
241 l1a_apihisr_com.dyn_dwnld.uninstall_parameters.num_of_elem=num_of_uninstall_elem;
242
243 // Trace number of elements to uninstall
244 #if ((TRACE_TYPE == 1) || (TRACE_TYPE == 4) || (TRACE_TYPE == 5))
245 if((trace_info.current_config->l1_dyn_trace) & (1<<L1_DYN_TRACE_DYN_DWNLD))
246 {
247 char str[20];
248 sprintf(str,"UNINST_NUM: %d |\r\n", l1a_apihisr_com.dyn_dwnld.uninstall_parameters.num_of_elem);
249 #if(CODE_VERSION == SIMULATION)
250 trace_fct_simu_dyn_dwnld(str);
251 #else
252 rvt_send_trace_cpy((T_RVT_BUFFER)str,trace_info.l1_trace_user_id,strlen(str),RVT_ASCII_FORMAT);
253 #endif // CODE_VERSION == SIMULATION
254 }
255 #endif // (TRACE_TYPE == 1) || (TRACE_TYPE == 4)
256
257 // For all patches to uninstall...
258 for(i=0;i<num_of_uninstall_elem;i++)
259 {
260 element=patch_id_uninstall_vect[i];
261
262 // Trace IDs of elements to uninstall
263 #if ((TRACE_TYPE == 1) || (TRACE_TYPE == 4) || (TRACE_TYPE == 5))
264 if((trace_info.current_config->l1_dyn_trace) & (1<<L1_DYN_TRACE_DYN_DWNLD))
265 {
266 char str[16];
267 sprintf(str,"UNINST_ID: %d \r\n", element);
268 #if(CODE_VERSION == SIMULATION)
269 trace_fct_simu_dyn_dwnld(str);
270 #else
271 rvt_send_trace_cpy((T_RVT_BUFFER)str,trace_info.l1_trace_user_id,strlen(str),RVT_ASCII_FORMAT);
272 #endif // CODE_VERSION == SIMULATION
273 }
274 #endif // (TRACE_TYPE == 1) || (TRACE_TYPE == 4)
275
276 // Set uninstall function address
277 l1a_apihisr_com.dyn_dwnld.uninstall_parameters.address[i]=dyn_dwnld_address_vect[element];
278 }
279
280 index_counter = 0;
281 for(i=0; i<l1a.dyn_dwnld.num_patches_installed;i++)
282 {
283 for(j=0;j<num_of_uninstall_elem;j++)
284 {
285 if(l1a.dyn_dwnld.patch_id[i] == patch_id_uninstall_vect[j])
286 {
287 l1a.dyn_dwnld.patch_id[i] = 0xFFFF; //omaps00090550 ;
288 break;
289 }
290 }
291 if(j == num_of_uninstall_elem)
292 {
293 temp_patch_id[index_counter++]=l1a.dyn_dwnld.patch_id[i];
294 }
295 }
296 // Reset global variables used by dynamic download
297 l1a.dyn_dwnld.num_patches_installed-=num_of_uninstall_elem;
298 for(i=0;i<l1a.dyn_dwnld.num_patches_installed;i++)
299 l1a.dyn_dwnld.patch_id[i] = temp_patch_id[i];
300 }
301
302 //-----------------------------------------
303 // Update L1A-L1APIHISR communication structure
304 //-----------------------------------------
305
306 l1a_apihisr_com.dyn_dwnld.copy_parameters.num_of_elem=num_of_patch_id_to_dwnld;
307 l1a.dyn_dwnld.num_of_elem_to_copy = num_of_patch_id_to_dwnld;
308
309 // Trace number of elements to download
310 #if ((TRACE_TYPE == 1) || (TRACE_TYPE == 4) || (TRACE_TYPE == 5))
311 if((trace_info.current_config->l1_dyn_trace) & (1<<L1_DYN_TRACE_DYN_DWNLD))
312 {
313 char str[18];
314 sprintf(str,"DWNLD_NUM: %d \r\n", num_of_patch_id_to_dwnld);
315 #if(CODE_VERSION == SIMULATION)
316 trace_fct_simu_dyn_dwnld(str);
317 #else
318 rvt_send_trace_cpy((T_RVT_BUFFER)str,trace_info.l1_trace_user_id,strlen(str),RVT_ASCII_FORMAT);
319 #endif // CODE_VERSION == SIMULATION
320 }
321 #endif // (TRACE_TYPE == 1) || (TRACE_TYPE == 4)
322
323 // For all patches that must be downloaded...
324 for (i=0;i<num_of_patch_id_to_dwnld;i++)
325 {
326 patch_id=l1a.dyn_dwnld.next_patch_id[i];
327
328 #if ((TRACE_TYPE == 1) || (TRACE_TYPE == 4) || (TRACE_TYPE == 5))
329 if((trace_info.current_config->l1_dyn_trace) & (1<<L1_DYN_TRACE_DYN_DWNLD))
330 {
331 char str[22];
332 sprintf(str,"DWNLD_ID: %d \r\n", patch_id);
333
334 #if(CODE_VERSION == SIMULATION)
335 trace_fct_simu_dyn_dwnld(str);
336 #else
337 rvt_send_trace_cpy((T_RVT_BUFFER)str,trace_info.l1_trace_user_id,strlen(str),RVT_ASCII_FORMAT);
338 #endif // CODE_VERSION == SIMULATION
339 }
340 #endif // (TRACE_TYPE == 1) || (TRACE_TYPE == 4)
341
342 // Set patch IDs addresses: copy source address and install address
343 l1a_apihisr_com.dyn_dwnld.copy_parameters.start_MCU_copy_address[i] =
344 (UWORD32) dyn_dwnld_copy_MCU_vect[patch_id];
345 l1a_apihisr_com.dyn_dwnld.copy_parameters.address_to_install[i] =
346 dyn_dwnld_address_vect[patch_id];
347 l1a_apihisr_com.dyn_dwnld.copy_parameters.crc[i] =
348 dyn_dwnld_crc_vect[patch_id];
349 l1a_apihisr_com.dyn_dwnld.copy_parameters.size_array[i] =
350 size_vect[patch_id];
351 }
352
353 //-----------------------------------------
354 // Set semaphores to lock involved state machines
355 //-----------------------------------------
356
357 if(delay_flag == FALSE)
358 // Tell other state machines that they have to stay in steady state waiting for dynamic download activity to be completed
359
360 l1_set_semaphores_for_all_state_machines_involved(num_of_patch_id_to_dwnld,l1a.dyn_dwnld.next_patch_id);
361 else
362
363 // Update the already set semaphores if it is the case
364
365 l1_update_semaphores_for_all_state_machines(num_of_patch_id_to_dwnld);
366 }
367 }
368 return return_flag;
369 }
370
371 /*----------------------------------------------------------------------------------------*/
372 /* l1a_dyn_dwnld_set_process */
373 /*----------------------------------------------------------------------------------------*/
374 /* */
375 /* Parameters : Signal Code of the message, delay flag */
376 /* */
377 /* Return : True if the primitives triggers a dynamic download and sets all the */
378 /* parameters to perform a dynamic download, false otherwise */
379 /* */
380 /* Description : Implements the dynamic download manager algorithm */
381 /* */
382 /* */
383 /*----------------------------------------------------------------------------------------*/
384 void l1a_dyn_dwnld_set_process(void)
385 {
386
387 #if ((TRACE_TYPE == 1) || (TRACE_TYPE == 4))
388 // Disable trace DSP upon Dynamic Download activation
389 l1_disable_dsp_trace();
390 #endif
391
392 // Reset API variables
393 l1_dyn_dwnld_reset_api();
394
395 // In case E2 is running, dynamic download must use a different area as E2 samples use trace DSP buffer
396 // area which is used as well for dynamic download
397
398 if ((l1a.dyn_dwnld.melody0_E2_flag_activated == TRUE) || (l1a.dyn_dwnld.melody1_E2_flag_activated == TRUE))
399
400 // Set download parameters: size and start download address of API area and number of patches to download
401 {
402 l1a_apihisr_com.dyn_dwnld.copy_parameters.start_of_dwnld_area= START_API_DWNLD_AREA_DURING_E2;
403 l1a_apihisr_com.dyn_dwnld.copy_parameters.size_of_dwnld_area= SIZE_API_DWNLD_AREA_DURING_E2;
404 }
405 else
406 {
407 l1a_apihisr_com.dyn_dwnld.copy_parameters.start_of_dwnld_area=START_API_DWNLD_AREA;
408 l1a_apihisr_com.dyn_dwnld.copy_parameters.size_of_dwnld_area=SIZE_API_DWNLD_AREA;
409 }
410
411 // Dynamic download HISR can be activated
412 l1_apihisr.dyn_dwnld.running=TRUE;
413
414 // Tell the L1S to start the DSP background task
415 l1a_l1s_com.dyn_dwnld_task.start=TRUE;
416 }
417
418
419 /*-------------------------------------------------------*/
420 /* l1a_dyn_dsp_dwnld_process() */
421 /*-------------------------------------------------------*/
422 /* */
423 /* Description: */
424 /* ------------ */
425 /* This function is a state machine which handles the */
426 /* dynamic download feature. */
427 /* */
428 /* Starting messages: */
429 /* */
430 /* Result messages (input): */
431 /* */
432 /* */
433 /* Result messages (output): */
434 /* */
435 /* Reset messages (input): none */
436 /* */
437 /* Stop message (input): */
438 /* */
439 /* Stop message (output): */
440 /* */
441 /* Rem: */
442 /* ---- */
443 /* */
444 /*-------------------------------------------------------*/
445
446 void l1a_dyn_dsp_dwnld_process(xSignalHeaderRec *msg)
447 {
448 enum states
449 {
450 RESET=0,
451 WAIT_INIT,
452 WAIT_RESULT,
453 WAIT_STOP
454 };
455
456 UWORD8 *state =&l1a.dyn_dwnld.state;
457 UWORD32 SignalCode=msg->SignalCode;
458 UWORD16 i;
459 UWORD16 delay_patch_array[MAX_NUM_OF_PATCH_IDS];
460 UWORD16 delay_num_patch;
461 UWORD32 delay_primitive;
462
463 while(1)
464 {
465 switch(*state)
466 {
467 // *********
468 // * RESET *
469 // *********
470 case RESET:
471 {
472 // Reset intra L1 variables: L1A-L1S interface, L1A-API interface, global API HISR variables
473 l1_dyn_dwnld_reset();
474
475 // Change state
476 *state = WAIT_INIT;
477 }
478 break;
479
480 // ******************
481 // * WAIT START REQ *
482 // ******************
483 case WAIT_INIT:
484 {
485
486 // *----------------------------*
487 // * Dynamic download manager *
488 // *----------------------------*
489
490
491 /* Run the dynamic download manager */
492 if (l1_dynamic_download_manager(SignalCode, FALSE) == TRUE)
493 {
494
495 /* Initialisation of dynamic download process */
496 l1a_dyn_dwnld_set_process();
497
498 // Change state
499 *state=WAIT_RESULT;
500
501 }
502 return;
503 }
504 //omaps00090550 break;
505
506 // ***************
507 // * WAIT_RESULT *
508 // ***************
509
510 case WAIT_RESULT:
511 {
512 if (l1_does_the_incoming_primitive_trigger_dynamic_dwnld(SignalCode,TRUE) == TRUE)
513 {
514 if (l1_push_Primitive(SignalCode) == TRUE)
515 {
516 delay_num_patch = l1_lookup_primitive_patch_matrix(SignalCode,delay_patch_array);
517
518 // Tell other state machines that they have to stay in steady state waiting for dynamic download activity to be completed
519 l1_set_semaphores_for_all_state_machines_involved(delay_num_patch, delay_patch_array);
520 }
521 else
522 {
523 #if ((TRACE_TYPE == 1) || (TRACE_TYPE == 4) || (TRACE_TYPE == 5))
524 if((trace_info.current_config->l1_dyn_trace) & (1<<L1_DYN_TRACE_DYN_DWNLD))
525 {
526 char str[16];
527 sprintf(str,"Fifo ovflw:\r\n");
528 #if(CODE_VERSION == SIMULATION)
529 trace_fct_simu_dyn_dwnld(str);
530 #else
531 rvt_send_trace_cpy((T_RVT_BUFFER)str,trace_info.l1_trace_user_id,strlen(str),RVT_ASCII_FORMAT);
532 #endif // CODE_VERSION == SIMULATION
533 }
534 #endif // (TRACE_TYPE == 1) || (TRACE_TYPE == 4)
535 }
536 }
537 switch(SignalCode)
538 {
539
540 // *----------------------------------------------------------------------------------*
541 // * CRC reported is not OK or an error has been reported; Restart patch from scratch *
542 // *----------------------------------------------------------------------------------*
543 case API_L1_CRC_NOT_OK:
544 {
545 #if ((TRACE_TYPE == 1) || (TRACE_TYPE == 4) || (TRACE_TYPE == 5))
546 // Trace
547 if((trace_info.current_config->l1_dyn_trace) & (1<<L1_DYN_TRACE_DYN_DWNLD))
548 {
549 char str[18];
550 sprintf(str,"CRC NOK: %4x \r\n",((T_API_L1_CRC_NOT_OK *)(msg->SigP))->patch_id);
551 #if(CODE_VERSION == SIMULATION)
552 trace_fct_simu_dyn_dwnld(str);
553 #else
554 rvt_send_trace_cpy((T_RVT_BUFFER)str,trace_info.l1_trace_user_id,strlen(str),RVT_ASCII_FORMAT);
555 #endif // CODE_VERSION == SIMULATION
556 }
557 #endif // (TRACE_TYPE == 1) || (TRACE_TYPE == 4)
558
559 // Set recovery flag to TRUE;
560 l1a_l1s_com.recovery_flag = TRUE;
561 *state = RESET;
562 }
563 break;
564 case API_L1_DYN_DWNLD_STOP:
565 {
566 #if ((TRACE_TYPE == 1) || (TRACE_TYPE == 4) || (TRACE_TYPE == 5))
567 if((trace_info.current_config->l1_dyn_trace) & (1<<L1_DYN_TRACE_DYN_DWNLD))
568 {
569 char str[15];
570 sprintf(str,"DSP Error \r\n");
571 #if(CODE_VERSION == SIMULATION)
572 trace_fct_simu_dyn_dwnld(str);
573 #else
574 rvt_send_trace_cpy((T_RVT_BUFFER)str,trace_info.l1_trace_user_id,strlen(str),RVT_ASCII_FORMAT);
575 #endif // CODE_VERSION == SIMULATION
576 }
577 #endif // (TRACE_TYPE == 1) || (TRACE_TYPE == 4)
578
579 // Set recovery flag to TRUE;
580 l1a_l1s_com.recovery_flag = TRUE;
581 *state = RESET;
582 }
583 break;
584
585 // *-------------------------------------------------------------*
586 // * Dynamic download finished: all patches have been downloaded *
587 // *-------------------------------------------------------------*
588 case API_L1_CRC_OK:
589 {
590 #if ((TRACE_TYPE == 1) || (TRACE_TYPE == 4) || (TRACE_TYPE == 5))
591 // Trace
592 if((trace_info.current_config->l1_dyn_trace) & (1<<L1_DYN_TRACE_DYN_DWNLD))
593 {
594 char str[18];
595 sprintf(str,"CRC OK: %4x \r\n",((T_API_L1_CRC_NOT_OK *)(msg->SigP))->patch_id);
596 #if(CODE_VERSION == SIMULATION)
597 trace_fct_simu_dyn_dwnld(str);
598 #else
599 rvt_send_trace_cpy((T_RVT_BUFFER)str,trace_info.l1_trace_user_id,strlen(str),RVT_ASCII_FORMAT);
600 #endif // CODE_VERSION == SIMULATION
601 }
602 #endif // (TRACE_TYPE == 1) || (TRACE_TYPE == 4)
603 }
604 break;
605 case API_L1_DYN_DWNLD_FINISHED:
606 {
607
608 // Store currently installed patch
609 for (i=0;i<l1a.dyn_dwnld.num_of_elem_to_copy;i++)
610 {
611 l1a.dyn_dwnld.patch_id[l1a.dyn_dwnld.num_patches_installed+i]=l1a.dyn_dwnld.next_patch_id[i];
612 }
613
614 // Update the counter of the patch currently installed and reset sempahores
615 l1a.dyn_dwnld.num_patches_installed+=l1a.dyn_dwnld.num_of_elem_to_copy;
616 l1_reset_semaphores();
617
618 // Reset number of element to copy in the next phase
619 l1a.dyn_dwnld.num_of_elem_to_copy = 0;
620
621 // Reset next patch ID global variables
622 for(i=0;i<MAX_NUM_OF_PATCH_IDS;i++)
623 l1a.dyn_dwnld.next_patch_id[i] = 0xFFFF; //omaps00090550 ;
624
625 #if ((TRACE_TYPE == 1) || (TRACE_TYPE == 4) || (TRACE_TYPE == 5))
626 // Trace
627 if((trace_info.current_config->l1_dyn_trace) & (1<<L1_DYN_TRACE_DYN_DWNLD))
628 {
629 char str[26];
630 sprintf(str,"Patch dwnld finished \r\n");
631 #if(CODE_VERSION == SIMULATION)
632 trace_fct_simu_dyn_dwnld(str);
633 #else
634 rvt_send_trace_cpy((T_RVT_BUFFER)str,trace_info.l1_trace_user_id,strlen(str),RVT_ASCII_FORMAT);
635 #endif // CODE_VERSION == SIMULATION
636 }
637 #endif // (TRACE_TYPE == 1) || (TRACE_TYPE == 4)
638
639 // Check if there is any pending primitive waiting to be de-queued
640 {
641 UWORD32 remaining_primitive_flag=0;
642 UWORD32 process_continue_flag=1;
643 UWORD32 delay_primitive_processed_flag=0;
644
645 remaining_primitive_flag = (l1_check_Fifo_Primitive()>0);
646
647 while(remaining_primitive_flag && process_continue_flag)
648 {
649 l1_pop_Primitive(&(delay_primitive));
650 if (l1_dynamic_download_manager(delay_primitive, TRUE) == TRUE)
651 {
652 process_continue_flag=0;
653 delay_primitive_processed_flag=1;
654 // If yes set the restart command at apihisr level
655 l1a_apihisr_com.dyn_dwnld.command.restart = TRUE;
656
657 /********** WORKAROUND *************/
658 #if 1 //(OP_RIV_AUDIO == 1)
659 {
660 // WARNING: temporary until os_activate_hisr() is declared in L3 functions
661 extern NU_HISR apiHISR;
662 NU_Activate_HISR(&apiHISR);
663 }
664 #else
665 os_activate_hisr(API_HISR);
666 #endif // OP_RIV_AUDIO == 1
667 /********** WORKAROUND *************/
668 *state = WAIT_RESULT;
669 }
670 remaining_primitive_flag = (l1_check_Fifo_Primitive()>0);
671 }
672
673 // else stop the DSP background task as no other patch must be downloaded
674 if(delay_primitive_processed_flag == 0)
675 {
676 #if ((TRACE_TYPE == 1) || (TRACE_TYPE == 4))
677 // Enable trace DSP upon Dynamic Download deactivation
678 l1_enable_dsp_trace();
679 //Trace_dsp_dump();
680 #endif // omaps00090550 #14-D removal
681 l1a_l1s_com.dyn_dwnld_task.stop=TRUE;
682 *state = WAIT_STOP;
683 }
684 }
685 }
686 break;
687 } // switch(SignalCode)
688 return;
689 }
690 //omaps00090550 break; // case WAIT_RESULT
691 case WAIT_STOP:
692 {
693 /* In case of a primitive which triggers a dynamic download arrives we must start over */
694 if (l1_does_the_incoming_primitive_trigger_dynamic_dwnld(SignalCode,TRUE) == TRUE)
695 {
696 /* Run the dynamic download manager */
697 if (l1_dynamic_download_manager(SignalCode, FALSE) == TRUE)
698 {
699 /* Initialisation of dynamic download process */
700 l1a_dyn_dwnld_set_process();
701
702 // Change state
703 *state=WAIT_RESULT;
704 }
705 }
706 else if (SignalCode == L1_DYN_DWNLD_STOP_CON)
707 {
708 // DYN DWNLD HISR must be deactivated
709 l1_apihisr.dyn_dwnld.running=FALSE;
710 // Change state
711 *state=RESET;
712 }
713 return;
714 }
715 //omaps00090550 break;
716 }
717 }
718 }
719 #endif // L1_DYN_DSP_DWNLD